diff options
Diffstat (limited to 'drivers')
315 files changed, 14599 insertions, 4471 deletions
diff --git a/drivers/Makefile b/drivers/Makefile index 808e0ae66aa8..54ec5e718c0e 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | # Rewritten to use lists instead of if-statements. | 5 | # Rewritten to use lists instead of if-statements. |
6 | # | 6 | # |
7 | 7 | ||
8 | obj-$(CONFIG_HAVE_GPIO_LIB) += gpio/ | 8 | obj-y += gpio/ |
9 | obj-$(CONFIG_PCI) += pci/ | 9 | obj-$(CONFIG_PCI) += pci/ |
10 | obj-$(CONFIG_PARISC) += parisc/ | 10 | obj-$(CONFIG_PARISC) += parisc/ |
11 | obj-$(CONFIG_RAPIDIO) += rapidio/ | 11 | obj-$(CONFIG_RAPIDIO) += rapidio/ |
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c index cffef1bcbdbc..549db42f16cf 100644 --- a/drivers/acpi/namespace/nsnames.c +++ b/drivers/acpi/namespace/nsnames.c | |||
@@ -137,6 +137,10 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) | |||
137 | /* Calculate required buffer size based on depth below root */ | 137 | /* Calculate required buffer size based on depth below root */ |
138 | 138 | ||
139 | size = acpi_ns_get_pathname_length(node); | 139 | size = acpi_ns_get_pathname_length(node); |
140 | if (!size) { | ||
141 | ACPI_ERROR((AE_INFO, "Invalid node failure")); | ||
142 | return_PTR(NULL); | ||
143 | } | ||
140 | 144 | ||
141 | /* Allocate a buffer to be returned to caller */ | 145 | /* Allocate a buffer to be returned to caller */ |
142 | 146 | ||
@@ -229,6 +233,10 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle, | |||
229 | /* Determine size required for the caller buffer */ | 233 | /* Determine size required for the caller buffer */ |
230 | 234 | ||
231 | required_size = acpi_ns_get_pathname_length(node); | 235 | required_size = acpi_ns_get_pathname_length(node); |
236 | if (!required_size) { | ||
237 | ACPI_ERROR((AE_INFO, "Invalid node failure")); | ||
238 | return_ACPI_STATUS(AE_ERROR); | ||
239 | } | ||
232 | 240 | ||
233 | /* Validate/Allocate/Clear caller buffer */ | 241 | /* Validate/Allocate/Clear caller buffer */ |
234 | 242 | ||
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 233c40c51684..89f3b2abfdc7 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
@@ -113,20 +113,23 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) | |||
113 | 113 | ||
114 | switch (resource->type) { | 114 | switch (resource->type) { |
115 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 115 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
116 | case ACPI_RESOURCE_TYPE_END_TAG: | ||
116 | return AE_OK; | 117 | return AE_OK; |
117 | case ACPI_RESOURCE_TYPE_IRQ: | 118 | case ACPI_RESOURCE_TYPE_IRQ: |
118 | { | 119 | { |
119 | struct acpi_resource_irq *p = &resource->data.irq; | 120 | struct acpi_resource_irq *p = &resource->data.irq; |
120 | if (!p || !p->interrupt_count) { | 121 | if (!p || !p->interrupt_count) { |
121 | printk(KERN_WARNING PREFIX "Blank IRQ resource\n"); | 122 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
123 | "Blank _PRS IRQ resource\n")); | ||
122 | return AE_OK; | 124 | return AE_OK; |
123 | } | 125 | } |
124 | for (i = 0; | 126 | for (i = 0; |
125 | (i < p->interrupt_count | 127 | (i < p->interrupt_count |
126 | && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { | 128 | && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { |
127 | if (!p->interrupts[i]) { | 129 | if (!p->interrupts[i]) { |
128 | printk(KERN_WARNING PREFIX "Invalid IRQ %d\n", | 130 | printk(KERN_WARNING PREFIX |
129 | p->interrupts[i]); | 131 | "Invalid _PRS IRQ %d\n", |
132 | p->interrupts[i]); | ||
130 | continue; | 133 | continue; |
131 | } | 134 | } |
132 | link->irq.possible[i] = p->interrupts[i]; | 135 | link->irq.possible[i] = p->interrupts[i]; |
@@ -143,15 +146,16 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) | |||
143 | &resource->data.extended_irq; | 146 | &resource->data.extended_irq; |
144 | if (!p || !p->interrupt_count) { | 147 | if (!p || !p->interrupt_count) { |
145 | printk(KERN_WARNING PREFIX | 148 | printk(KERN_WARNING PREFIX |
146 | "Blank EXT IRQ resource\n"); | 149 | "Blank _PRS EXT IRQ resource\n"); |
147 | return AE_OK; | 150 | return AE_OK; |
148 | } | 151 | } |
149 | for (i = 0; | 152 | for (i = 0; |
150 | (i < p->interrupt_count | 153 | (i < p->interrupt_count |
151 | && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { | 154 | && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { |
152 | if (!p->interrupts[i]) { | 155 | if (!p->interrupts[i]) { |
153 | printk(KERN_WARNING PREFIX "Invalid IRQ %d\n", | 156 | printk(KERN_WARNING PREFIX |
154 | p->interrupts[i]); | 157 | "Invalid _PRS IRQ %d\n", |
158 | p->interrupts[i]); | ||
155 | continue; | 159 | continue; |
156 | } | 160 | } |
157 | link->irq.possible[i] = p->interrupts[i]; | 161 | link->irq.possible[i] = p->interrupts[i]; |
@@ -163,7 +167,8 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) | |||
163 | break; | 167 | break; |
164 | } | 168 | } |
165 | default: | 169 | default: |
166 | printk(KERN_ERR PREFIX "Resource is not an IRQ entry\n"); | 170 | printk(KERN_ERR PREFIX "_PRS resource type 0x%x isn't an IRQ\n", |
171 | resource->type); | ||
167 | return AE_OK; | 172 | return AE_OK; |
168 | } | 173 | } |
169 | 174 | ||
@@ -199,6 +204,9 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) | |||
199 | 204 | ||
200 | 205 | ||
201 | switch (resource->type) { | 206 | switch (resource->type) { |
207 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | ||
208 | case ACPI_RESOURCE_TYPE_END_TAG: | ||
209 | return AE_OK; | ||
202 | case ACPI_RESOURCE_TYPE_IRQ: | 210 | case ACPI_RESOURCE_TYPE_IRQ: |
203 | { | 211 | { |
204 | struct acpi_resource_irq *p = &resource->data.irq; | 212 | struct acpi_resource_irq *p = &resource->data.irq; |
@@ -208,7 +216,7 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) | |||
208 | * particularly those those w/ _STA disabled | 216 | * particularly those those w/ _STA disabled |
209 | */ | 217 | */ |
210 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 218 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
211 | "Blank IRQ resource\n")); | 219 | "Blank _CRS IRQ resource\n")); |
212 | return AE_OK; | 220 | return AE_OK; |
213 | } | 221 | } |
214 | *irq = p->interrupts[0]; | 222 | *irq = p->interrupts[0]; |
@@ -224,7 +232,7 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) | |||
224 | * return at least 1 IRQ | 232 | * return at least 1 IRQ |
225 | */ | 233 | */ |
226 | printk(KERN_WARNING PREFIX | 234 | printk(KERN_WARNING PREFIX |
227 | "Blank EXT IRQ resource\n"); | 235 | "Blank _CRS EXT IRQ resource\n"); |
228 | return AE_OK; | 236 | return AE_OK; |
229 | } | 237 | } |
230 | *irq = p->interrupts[0]; | 238 | *irq = p->interrupts[0]; |
@@ -232,10 +240,11 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) | |||
232 | } | 240 | } |
233 | break; | 241 | break; |
234 | default: | 242 | default: |
235 | printk(KERN_ERR PREFIX "Resource %d isn't an IRQ\n", resource->type); | 243 | printk(KERN_ERR PREFIX "_CRS resource type 0x%x isn't an IRQ\n", |
236 | case ACPI_RESOURCE_TYPE_END_TAG: | 244 | resource->type); |
237 | return AE_OK; | 245 | return AE_OK; |
238 | } | 246 | } |
247 | |||
239 | return AE_CTRL_TERMINATE; | 248 | return AE_CTRL_TERMINATE; |
240 | } | 249 | } |
241 | 250 | ||
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c index b9ab030a52d5..dd376f7ad090 100644 --- a/drivers/acpi/pci_slot.c +++ b/drivers/acpi/pci_slot.c | |||
@@ -6,8 +6,8 @@ | |||
6 | * Thanks to Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> for code | 6 | * Thanks to Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> for code |
7 | * review and fixes. | 7 | * review and fixes. |
8 | * | 8 | * |
9 | * Copyright (C) 2007 Alex Chiang <achiang@hp.com> | 9 | * Copyright (C) 2007-2008 Hewlett-Packard Development Company, L.P. |
10 | * Copyright (C) 2007 Hewlett-Packard Development Company, L.P. | 10 | * Alex Chiang <achiang@hp.com> |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or modify it | 12 | * This program is free software; you can redistribute it and/or modify it |
13 | * under the terms and conditions of the GNU General Public License, | 13 | * under the terms and conditions of the GNU General Public License, |
@@ -158,6 +158,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
158 | if (IS_ERR(pci_slot)) { | 158 | if (IS_ERR(pci_slot)) { |
159 | err("pci_create_slot returned %ld\n", PTR_ERR(pci_slot)); | 159 | err("pci_create_slot returned %ld\n", PTR_ERR(pci_slot)); |
160 | kfree(slot); | 160 | kfree(slot); |
161 | return AE_OK; | ||
161 | } | 162 | } |
162 | 163 | ||
163 | slot->root_handle = parent_context->root_handle; | 164 | slot->root_handle = parent_context->root_handle; |
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index 0489a7d1d42c..d13194a031bf 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -280,9 +280,36 @@ static struct platform_suspend_ops acpi_suspend_ops_old = { | |||
280 | .end = acpi_pm_end, | 280 | .end = acpi_pm_end, |
281 | .recover = acpi_pm_finish, | 281 | .recover = acpi_pm_finish, |
282 | }; | 282 | }; |
283 | |||
284 | static int __init init_old_suspend_ordering(const struct dmi_system_id *d) | ||
285 | { | ||
286 | old_suspend_ordering = true; | ||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { | ||
291 | { | ||
292 | .callback = init_old_suspend_ordering, | ||
293 | .ident = "Abit KN9 (nForce4 variant)", | ||
294 | .matches = { | ||
295 | DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"), | ||
296 | DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"), | ||
297 | }, | ||
298 | }, | ||
299 | {}, | ||
300 | }; | ||
283 | #endif /* CONFIG_SUSPEND */ | 301 | #endif /* CONFIG_SUSPEND */ |
284 | 302 | ||
285 | #ifdef CONFIG_HIBERNATION | 303 | #ifdef CONFIG_HIBERNATION |
304 | static unsigned long s4_hardware_signature; | ||
305 | static struct acpi_table_facs *facs; | ||
306 | static bool nosigcheck; | ||
307 | |||
308 | void __init acpi_no_s4_hw_signature(void) | ||
309 | { | ||
310 | nosigcheck = true; | ||
311 | } | ||
312 | |||
286 | static int acpi_hibernation_begin(void) | 313 | static int acpi_hibernation_begin(void) |
287 | { | 314 | { |
288 | acpi_target_sleep_state = ACPI_STATE_S4; | 315 | acpi_target_sleep_state = ACPI_STATE_S4; |
@@ -316,6 +343,12 @@ static void acpi_hibernation_leave(void) | |||
316 | acpi_enable(); | 343 | acpi_enable(); |
317 | /* Reprogram control registers and execute _BFS */ | 344 | /* Reprogram control registers and execute _BFS */ |
318 | acpi_leave_sleep_state_prep(ACPI_STATE_S4); | 345 | acpi_leave_sleep_state_prep(ACPI_STATE_S4); |
346 | /* Check the hardware signature */ | ||
347 | if (facs && s4_hardware_signature != facs->hardware_signature) { | ||
348 | printk(KERN_EMERG "ACPI: Hardware changed while hibernated, " | ||
349 | "cannot resume!\n"); | ||
350 | panic("ACPI S4 hardware signature mismatch"); | ||
351 | } | ||
319 | } | 352 | } |
320 | 353 | ||
321 | static void acpi_pm_enable_gpes(void) | 354 | static void acpi_pm_enable_gpes(void) |
@@ -516,6 +549,8 @@ int __init acpi_sleep_init(void) | |||
516 | u8 type_a, type_b; | 549 | u8 type_a, type_b; |
517 | #ifdef CONFIG_SUSPEND | 550 | #ifdef CONFIG_SUSPEND |
518 | int i = 0; | 551 | int i = 0; |
552 | |||
553 | dmi_check_system(acpisleep_dmi_table); | ||
519 | #endif | 554 | #endif |
520 | 555 | ||
521 | if (acpi_disabled) | 556 | if (acpi_disabled) |
@@ -544,6 +579,13 @@ int __init acpi_sleep_init(void) | |||
544 | &acpi_hibernation_ops_old : &acpi_hibernation_ops); | 579 | &acpi_hibernation_ops_old : &acpi_hibernation_ops); |
545 | sleep_states[ACPI_STATE_S4] = 1; | 580 | sleep_states[ACPI_STATE_S4] = 1; |
546 | printk(" S4"); | 581 | printk(" S4"); |
582 | if (!nosigcheck) { | ||
583 | acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, | ||
584 | (struct acpi_table_header **)&facs); | ||
585 | if (facs) | ||
586 | s4_hardware_signature = | ||
587 | facs->hardware_signature; | ||
588 | } | ||
547 | } | 589 | } |
548 | #endif | 590 | #endif |
549 | status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); | 591 | status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); |
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index d8e3f153b295..91dec448b3ed 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/proc_fs.h> | 26 | #include <linux/proc_fs.h> |
27 | #include <linux/seq_file.h> | 27 | #include <linux/seq_file.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/string.h> | ||
29 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
30 | 31 | ||
31 | #include <acpi/acpi_drivers.h> | 32 | #include <acpi/acpi_drivers.h> |
diff --git a/drivers/acpi/tables/tbfadt.c b/drivers/acpi/tables/tbfadt.c index ccb5b64bbef3..a4a41ba2484b 100644 --- a/drivers/acpi/tables/tbfadt.c +++ b/drivers/acpi/tables/tbfadt.c | |||
@@ -124,7 +124,7 @@ static struct acpi_fadt_info fadt_info_table[] = { | |||
124 | 124 | ||
125 | static void inline | 125 | static void inline |
126 | acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | 126 | acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, |
127 | u8 byte_width, u64 address) | 127 | u8 bit_width, u64 address) |
128 | { | 128 | { |
129 | 129 | ||
130 | /* | 130 | /* |
@@ -136,7 +136,7 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | |||
136 | /* All other fields are byte-wide */ | 136 | /* All other fields are byte-wide */ |
137 | 137 | ||
138 | generic_address->space_id = ACPI_ADR_SPACE_SYSTEM_IO; | 138 | generic_address->space_id = ACPI_ADR_SPACE_SYSTEM_IO; |
139 | generic_address->bit_width = byte_width << 3; | 139 | generic_address->bit_width = bit_width; |
140 | generic_address->bit_offset = 0; | 140 | generic_address->bit_offset = 0; |
141 | generic_address->access_width = 0; | 141 | generic_address->access_width = 0; |
142 | } | 142 | } |
@@ -343,11 +343,9 @@ static void acpi_tb_convert_fadt(void) | |||
343 | * | 343 | * |
344 | * The PM event blocks are split into two register blocks, first is the | 344 | * The PM event blocks are split into two register blocks, first is the |
345 | * PM Status Register block, followed immediately by the PM Enable Register | 345 | * PM Status Register block, followed immediately by the PM Enable Register |
346 | * block. Each is of length (xpm1x_event_block.bit_width/2) | 346 | * block. Each is of length (pm1_event_length/2) |
347 | */ | 347 | */ |
348 | WARN_ON(ACPI_MOD_16(acpi_gbl_FADT.xpm1a_event_block.bit_width)); | 348 | pm1_register_length = (u8) ACPI_DIV_2(acpi_gbl_FADT.pm1_event_length); |
349 | pm1_register_length = (u8) ACPI_DIV_16(acpi_gbl_FADT | ||
350 | .xpm1a_event_block.bit_width); | ||
351 | 349 | ||
352 | /* The PM1A register block is required */ | 350 | /* The PM1A register block is required */ |
353 | 351 | ||
@@ -362,17 +360,14 @@ static void acpi_tb_convert_fadt(void) | |||
362 | /* The PM1B register block is optional, ignore if not present */ | 360 | /* The PM1B register block is optional, ignore if not present */ |
363 | 361 | ||
364 | if (acpi_gbl_FADT.xpm1b_event_block.address) { | 362 | if (acpi_gbl_FADT.xpm1b_event_block.address) { |
365 | WARN_ON(ACPI_MOD_16(acpi_gbl_FADT.xpm1b_event_block.bit_width)); | ||
366 | pm1_register_length = (u8) ACPI_DIV_16(acpi_gbl_FADT | ||
367 | .xpm1b_event_block | ||
368 | .bit_width); | ||
369 | acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, | 363 | acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, |
370 | pm1_register_length, | 364 | pm1_register_length, |
371 | (acpi_gbl_FADT.xpm1b_event_block. | 365 | (acpi_gbl_FADT.xpm1b_event_block. |
372 | address + pm1_register_length)); | 366 | address + pm1_register_length)); |
373 | /* Don't forget to copy space_id of the GAS */ | 367 | /* Don't forget to copy space_id of the GAS */ |
374 | acpi_gbl_xpm1b_enable.space_id = | 368 | acpi_gbl_xpm1b_enable.space_id = |
375 | acpi_gbl_FADT.xpm1b_event_block.space_id; | 369 | acpi_gbl_FADT.xpm1a_event_block.space_id; |
370 | |||
376 | } | 371 | } |
377 | } | 372 | } |
378 | 373 | ||
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 30a341337933..912703691d36 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -769,6 +769,47 @@ static void acpi_thermal_run(unsigned long data) | |||
769 | acpi_os_execute(OSL_GPE_HANDLER, acpi_thermal_check, (void *)data); | 769 | acpi_os_execute(OSL_GPE_HANDLER, acpi_thermal_check, (void *)data); |
770 | } | 770 | } |
771 | 771 | ||
772 | static void acpi_thermal_active_off(void *data) | ||
773 | { | ||
774 | int result = 0; | ||
775 | struct acpi_thermal *tz = data; | ||
776 | int i = 0; | ||
777 | int j = 0; | ||
778 | struct acpi_thermal_active *active = NULL; | ||
779 | |||
780 | if (!tz) { | ||
781 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); | ||
782 | return; | ||
783 | } | ||
784 | |||
785 | result = acpi_thermal_get_temperature(tz); | ||
786 | if (result) | ||
787 | return; | ||
788 | |||
789 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { | ||
790 | active = &(tz->trips.active[i]); | ||
791 | if (!active || !active->flags.valid) | ||
792 | break; | ||
793 | if (tz->temperature >= active->temperature) { | ||
794 | /* | ||
795 | * If the thermal temperature is greater than the | ||
796 | * active threshod, unnecessary to turn off the | ||
797 | * the active cooling device. | ||
798 | */ | ||
799 | continue; | ||
800 | } | ||
801 | /* | ||
802 | * Below Threshold? | ||
803 | * ---------------- | ||
804 | * Turn OFF all cooling devices associated with this | ||
805 | * threshold. | ||
806 | */ | ||
807 | for (j = 0; j < active->devices.count; j++) | ||
808 | result = acpi_bus_set_power(active->devices.handles[j], | ||
809 | ACPI_STATE_D3); | ||
810 | } | ||
811 | } | ||
812 | |||
772 | static void acpi_thermal_check(void *data) | 813 | static void acpi_thermal_check(void *data) |
773 | { | 814 | { |
774 | int result = 0; | 815 | int result = 0; |
@@ -1624,6 +1665,8 @@ static int acpi_thermal_add(struct acpi_device *device) | |||
1624 | 1665 | ||
1625 | init_timer(&tz->timer); | 1666 | init_timer(&tz->timer); |
1626 | 1667 | ||
1668 | acpi_thermal_active_off(tz); | ||
1669 | |||
1627 | acpi_thermal_check(tz); | 1670 | acpi_thermal_check(tz); |
1628 | 1671 | ||
1629 | status = acpi_install_notify_handler(device->handle, | 1672 | status = acpi_install_notify_handler(device->handle, |
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 3dfb8a442b26..e7bf34a7b1d2 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c | |||
@@ -242,6 +242,10 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer, | |||
242 | { | 242 | { |
243 | acpi_status status = AE_OK; | 243 | acpi_status status = AE_OK; |
244 | 244 | ||
245 | if (!required_length) { | ||
246 | WARN_ON(1); | ||
247 | return AE_ERROR; | ||
248 | } | ||
245 | switch (buffer->length) { | 249 | switch (buffer->length) { |
246 | case ACPI_NO_BUFFER: | 250 | case ACPI_NO_BUFFER: |
247 | 251 | ||
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 37b9e16710d6..e8a51a1700f7 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -741,7 +741,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
741 | 741 | ||
742 | max_level = acpi_video_init_brightness(device); | 742 | max_level = acpi_video_init_brightness(device); |
743 | 743 | ||
744 | if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){ | 744 | if (device->cap._BCL && device->cap._BCM && max_level > 0) { |
745 | int result; | 745 | int result; |
746 | static int count = 0; | 746 | static int count = 0; |
747 | char *name; | 747 | char *name; |
@@ -753,7 +753,17 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
753 | device->backlight = backlight_device_register(name, | 753 | device->backlight = backlight_device_register(name, |
754 | NULL, device, &acpi_backlight_ops); | 754 | NULL, device, &acpi_backlight_ops); |
755 | device->backlight->props.max_brightness = device->brightness->count-3; | 755 | device->backlight->props.max_brightness = device->brightness->count-3; |
756 | device->backlight->props.brightness = acpi_video_get_brightness(device->backlight); | 756 | /* |
757 | * If there exists the _BQC object, the _BQC object will be | ||
758 | * called to get the current backlight brightness. Otherwise | ||
759 | * the brightness will be set to the maximum. | ||
760 | */ | ||
761 | if (device->cap._BQC) | ||
762 | device->backlight->props.brightness = | ||
763 | acpi_video_get_brightness(device->backlight); | ||
764 | else | ||
765 | device->backlight->props.brightness = | ||
766 | device->backlight->props.max_brightness; | ||
757 | backlight_update_status(device->backlight); | 767 | backlight_update_status(device->backlight); |
758 | kfree(name); | 768 | kfree(name); |
759 | 769 | ||
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index dc7596f028b6..ef3e5522e1a4 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -1273,7 +1273,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state, | |||
1273 | void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR]; | 1273 | void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR]; |
1274 | u32 em_ctl; | 1274 | u32 em_ctl; |
1275 | u32 message[] = {0, 0}; | 1275 | u32 message[] = {0, 0}; |
1276 | unsigned int flags; | 1276 | unsigned long flags; |
1277 | int pmp; | 1277 | int pmp; |
1278 | struct ahci_em_priv *emp; | 1278 | struct ahci_em_priv *emp; |
1279 | 1279 | ||
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index d5c1bbfbe79d..73338d231db9 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c | |||
@@ -2562,7 +2562,8 @@ fore200e_load_and_start_fw(struct fore200e* fore200e) | |||
2562 | const struct firmware *firmware; | 2562 | const struct firmware *firmware; |
2563 | struct device *device; | 2563 | struct device *device; |
2564 | struct fw_header *fw_header; | 2564 | struct fw_header *fw_header; |
2565 | u32 *fw_data, fw_size; | 2565 | const __le32 *fw_data; |
2566 | u32 fw_size; | ||
2566 | u32 __iomem *load_addr; | 2567 | u32 __iomem *load_addr; |
2567 | char buf[48]; | 2568 | char buf[48]; |
2568 | int err = -ENODEV; | 2569 | int err = -ENODEV; |
@@ -2582,7 +2583,7 @@ fore200e_load_and_start_fw(struct fore200e* fore200e) | |||
2582 | return err; | 2583 | return err; |
2583 | } | 2584 | } |
2584 | 2585 | ||
2585 | fw_data = (u32 *) firmware->data; | 2586 | fw_data = (__le32 *) firmware->data; |
2586 | fw_size = firmware->size / sizeof(u32); | 2587 | fw_size = firmware->size / sizeof(u32); |
2587 | fw_header = (struct fw_header *) firmware->data; | 2588 | fw_header = (struct fw_header *) firmware->data; |
2588 | load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset); | 2589 | load_addr = fore200e->virt_base + le32_to_cpu(fw_header->load_offset); |
@@ -3199,6 +3200,14 @@ static const struct fore200e_bus fore200e_bus[] = { | |||
3199 | {} | 3200 | {} |
3200 | }; | 3201 | }; |
3201 | 3202 | ||
3202 | #ifdef MODULE_LICENSE | ||
3203 | MODULE_LICENSE("GPL"); | 3203 | MODULE_LICENSE("GPL"); |
3204 | #ifdef CONFIG_PCI | ||
3205 | #ifdef __LITTLE_ENDIAN__ | ||
3206 | MODULE_FIRMWARE("pca200e.bin"); | ||
3207 | #else | ||
3208 | MODULE_FIRMWARE("pca200e_ecd.bin2"); | ||
3209 | #endif | ||
3210 | #endif /* CONFIG_PCI */ | ||
3211 | #ifdef CONFIG_SBUS | ||
3212 | MODULE_FIRMWARE("sba200e_ecd.bin2"); | ||
3204 | #endif | 3213 | #endif |
diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c index 683509f013ab..eacb175f6bd3 100644 --- a/drivers/auxdisplay/cfag12864b.c +++ b/drivers/auxdisplay/cfag12864b.c | |||
@@ -336,16 +336,9 @@ static int __init cfag12864b_init(void) | |||
336 | "ks0108 is not initialized\n"); | 336 | "ks0108 is not initialized\n"); |
337 | goto none; | 337 | goto none; |
338 | } | 338 | } |
339 | BUILD_BUG_ON(PAGE_SIZE < CFAG12864B_SIZE); | ||
339 | 340 | ||
340 | if (PAGE_SIZE < CFAG12864B_SIZE) { | 341 | cfag12864b_buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL); |
341 | printk(KERN_ERR CFAG12864B_NAME ": ERROR: " | ||
342 | "page size (%i) < cfag12864b size (%i)\n", | ||
343 | (unsigned int)PAGE_SIZE, CFAG12864B_SIZE); | ||
344 | ret = -ENOMEM; | ||
345 | goto none; | ||
346 | } | ||
347 | |||
348 | cfag12864b_buffer = (unsigned char *) __get_free_page(GFP_KERNEL); | ||
349 | if (cfag12864b_buffer == NULL) { | 342 | if (cfag12864b_buffer == NULL) { |
350 | printk(KERN_ERR CFAG12864B_NAME ": ERROR: " | 343 | printk(KERN_ERR CFAG12864B_NAME ": ERROR: " |
351 | "can't get a free page\n"); | 344 | "can't get a free page\n"); |
@@ -367,8 +360,6 @@ static int __init cfag12864b_init(void) | |||
367 | if (cfag12864b_workqueue == NULL) | 360 | if (cfag12864b_workqueue == NULL) |
368 | goto cachealloced; | 361 | goto cachealloced; |
369 | 362 | ||
370 | memset(cfag12864b_buffer, 0, CFAG12864B_SIZE); | ||
371 | |||
372 | cfag12864b_clear(); | 363 | cfag12864b_clear(); |
373 | cfag12864b_on(); | 364 | cfag12864b_on(); |
374 | 365 | ||
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index b0be1d18fee2..c9c92b00fd55 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -184,7 +184,7 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
184 | struct device *dev = to_dev(kobj); | 184 | struct device *dev = to_dev(kobj); |
185 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 185 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); |
186 | struct firmware *fw; | 186 | struct firmware *fw; |
187 | ssize_t ret_count = count; | 187 | ssize_t ret_count; |
188 | 188 | ||
189 | mutex_lock(&fw_lock); | 189 | mutex_lock(&fw_lock); |
190 | fw = fw_priv->fw; | 190 | fw = fw_priv->fw; |
@@ -192,14 +192,8 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
192 | ret_count = -ENODEV; | 192 | ret_count = -ENODEV; |
193 | goto out; | 193 | goto out; |
194 | } | 194 | } |
195 | if (offset > fw->size) { | 195 | ret_count = memory_read_from_buffer(buffer, count, &offset, |
196 | ret_count = 0; | 196 | fw->data, fw->size); |
197 | goto out; | ||
198 | } | ||
199 | if (offset + ret_count > fw->size) | ||
200 | ret_count = fw->size - offset; | ||
201 | |||
202 | memcpy(buffer, fw->data + offset, ret_count); | ||
203 | out: | 197 | out: |
204 | mutex_unlock(&fw_lock); | 198 | mutex_unlock(&fw_lock); |
205 | return ret_count; | 199 | return ret_count; |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 4d4e0e7b6e92..855ed1a9f97b 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -101,6 +101,21 @@ static ssize_t show_mem_phys_index(struct sys_device *dev, | |||
101 | } | 101 | } |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * Show whether the section of memory is likely to be hot-removable | ||
105 | */ | ||
106 | static ssize_t show_mem_removable(struct sys_device *dev, char *buf) | ||
107 | { | ||
108 | unsigned long start_pfn; | ||
109 | int ret; | ||
110 | struct memory_block *mem = | ||
111 | container_of(dev, struct memory_block, sysdev); | ||
112 | |||
113 | start_pfn = section_nr_to_pfn(mem->phys_index); | ||
114 | ret = is_mem_section_removable(start_pfn, PAGES_PER_SECTION); | ||
115 | return sprintf(buf, "%d\n", ret); | ||
116 | } | ||
117 | |||
118 | /* | ||
104 | * online, offline, going offline, etc. | 119 | * online, offline, going offline, etc. |
105 | */ | 120 | */ |
106 | static ssize_t show_mem_state(struct sys_device *dev, | 121 | static ssize_t show_mem_state(struct sys_device *dev, |
@@ -262,6 +277,7 @@ static ssize_t show_phys_device(struct sys_device *dev, | |||
262 | static SYSDEV_ATTR(phys_index, 0444, show_mem_phys_index, NULL); | 277 | static SYSDEV_ATTR(phys_index, 0444, show_mem_phys_index, NULL); |
263 | static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state); | 278 | static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state); |
264 | static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL); | 279 | static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL); |
280 | static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL); | ||
265 | 281 | ||
266 | #define mem_create_simple_file(mem, attr_name) \ | 282 | #define mem_create_simple_file(mem, attr_name) \ |
267 | sysdev_create_file(&mem->sysdev, &attr_##attr_name) | 283 | sysdev_create_file(&mem->sysdev, &attr_##attr_name) |
@@ -350,6 +366,8 @@ static int add_memory_block(unsigned long node_id, struct mem_section *section, | |||
350 | ret = mem_create_simple_file(mem, state); | 366 | ret = mem_create_simple_file(mem, state); |
351 | if (!ret) | 367 | if (!ret) |
352 | ret = mem_create_simple_file(mem, phys_device); | 368 | ret = mem_create_simple_file(mem, phys_device); |
369 | if (!ret) | ||
370 | ret = mem_create_simple_file(mem, removable); | ||
353 | 371 | ||
354 | return ret; | 372 | return ret; |
355 | } | 373 | } |
@@ -394,6 +412,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, | |||
394 | mem_remove_simple_file(mem, phys_index); | 412 | mem_remove_simple_file(mem, phys_index); |
395 | mem_remove_simple_file(mem, state); | 413 | mem_remove_simple_file(mem, state); |
396 | mem_remove_simple_file(mem, phys_device); | 414 | mem_remove_simple_file(mem, phys_device); |
415 | mem_remove_simple_file(mem, removable); | ||
397 | unregister_memory(mem, section); | 416 | unregister_memory(mem, section); |
398 | 417 | ||
399 | return 0; | 418 | return 0; |
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c index c04440cd6a32..181ebb85f0be 100644 --- a/drivers/block/aoe/aoechr.c +++ b/drivers/block/aoe/aoechr.c | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | #include <linux/hdreg.h> | 7 | #include <linux/hdreg.h> |
8 | #include <linux/blkdev.h> | 8 | #include <linux/blkdev.h> |
9 | #include <linux/completion.h> | ||
9 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
10 | #include <linux/smp_lock.h> | 11 | #include <linux/smp_lock.h> |
11 | #include "aoe.h" | 12 | #include "aoe.h" |
@@ -36,7 +37,7 @@ struct ErrMsg { | |||
36 | 37 | ||
37 | static struct ErrMsg emsgs[NMSG]; | 38 | static struct ErrMsg emsgs[NMSG]; |
38 | static int emsgs_head_idx, emsgs_tail_idx; | 39 | static int emsgs_head_idx, emsgs_tail_idx; |
39 | static struct semaphore emsgs_sema; | 40 | static struct completion emsgs_comp; |
40 | static spinlock_t emsgs_lock; | 41 | static spinlock_t emsgs_lock; |
41 | static int nblocked_emsgs_readers; | 42 | static int nblocked_emsgs_readers; |
42 | static struct class *aoe_class; | 43 | static struct class *aoe_class; |
@@ -141,7 +142,7 @@ bail: spin_unlock_irqrestore(&emsgs_lock, flags); | |||
141 | spin_unlock_irqrestore(&emsgs_lock, flags); | 142 | spin_unlock_irqrestore(&emsgs_lock, flags); |
142 | 143 | ||
143 | if (nblocked_emsgs_readers) | 144 | if (nblocked_emsgs_readers) |
144 | up(&emsgs_sema); | 145 | complete(&emsgs_comp); |
145 | } | 146 | } |
146 | 147 | ||
147 | static ssize_t | 148 | static ssize_t |
@@ -221,7 +222,7 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off) | |||
221 | 222 | ||
222 | spin_unlock_irqrestore(&emsgs_lock, flags); | 223 | spin_unlock_irqrestore(&emsgs_lock, flags); |
223 | 224 | ||
224 | n = down_interruptible(&emsgs_sema); | 225 | n = wait_for_completion_interruptible(&emsgs_comp); |
225 | 226 | ||
226 | spin_lock_irqsave(&emsgs_lock, flags); | 227 | spin_lock_irqsave(&emsgs_lock, flags); |
227 | 228 | ||
@@ -269,7 +270,7 @@ aoechr_init(void) | |||
269 | printk(KERN_ERR "aoe: can't register char device\n"); | 270 | printk(KERN_ERR "aoe: can't register char device\n"); |
270 | return n; | 271 | return n; |
271 | } | 272 | } |
272 | sema_init(&emsgs_sema, 0); | 273 | init_completion(&emsgs_comp); |
273 | spin_lock_init(&emsgs_lock); | 274 | spin_lock_init(&emsgs_lock); |
274 | aoe_class = class_create(THIS_MODULE, "aoe"); | 275 | aoe_class = class_create(THIS_MODULE, "aoe"); |
275 | if (IS_ERR(aoe_class)) { | 276 | if (IS_ERR(aoe_class)) { |
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index dd7ea203f940..42251095134f 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -196,6 +196,7 @@ static int virtblk_probe(struct virtio_device *vdev) | |||
196 | int err; | 196 | int err; |
197 | u64 cap; | 197 | u64 cap; |
198 | u32 v; | 198 | u32 v; |
199 | u32 blk_size; | ||
199 | 200 | ||
200 | if (index_to_minor(index) >= 1 << MINORBITS) | 201 | if (index_to_minor(index) >= 1 << MINORBITS) |
201 | return -ENOSPC; | 202 | return -ENOSPC; |
@@ -290,6 +291,13 @@ static int virtblk_probe(struct virtio_device *vdev) | |||
290 | if (!err) | 291 | if (!err) |
291 | blk_queue_max_hw_segments(vblk->disk->queue, v); | 292 | blk_queue_max_hw_segments(vblk->disk->queue, v); |
292 | 293 | ||
294 | /* Host can optionally specify the block size of the device */ | ||
295 | err = virtio_config_val(vdev, VIRTIO_BLK_F_BLK_SIZE, | ||
296 | offsetof(struct virtio_blk_config, blk_size), | ||
297 | &blk_size); | ||
298 | if (!err) | ||
299 | blk_queue_hardsect_size(vblk->disk->queue, blk_size); | ||
300 | |||
293 | add_disk(vblk->disk); | 301 | add_disk(vblk->disk); |
294 | return 0; | 302 | return 0; |
295 | 303 | ||
@@ -330,7 +338,7 @@ static struct virtio_device_id id_table[] = { | |||
330 | 338 | ||
331 | static unsigned int features[] = { | 339 | static unsigned int features[] = { |
332 | VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, | 340 | VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, |
333 | VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, | 341 | VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, |
334 | }; | 342 | }; |
335 | 343 | ||
336 | static struct virtio_driver virtio_blk = { | 344 | static struct virtio_driver virtio_blk = { |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index e0bbbfb6a36b..6c070dc5f2d4 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -578,11 +578,14 @@ config HVC_DRIVER | |||
578 | It will automatically be selected if one of the back-end console drivers | 578 | It will automatically be selected if one of the back-end console drivers |
579 | is selected. | 579 | is selected. |
580 | 580 | ||
581 | config HVC_IRQ | ||
582 | bool | ||
581 | 583 | ||
582 | config HVC_CONSOLE | 584 | config HVC_CONSOLE |
583 | bool "pSeries Hypervisor Virtual Console support" | 585 | bool "pSeries Hypervisor Virtual Console support" |
584 | depends on PPC_PSERIES | 586 | depends on PPC_PSERIES |
585 | select HVC_DRIVER | 587 | select HVC_DRIVER |
588 | select HVC_IRQ | ||
586 | help | 589 | help |
587 | pSeries machines when partitioned support a hypervisor virtual | 590 | pSeries machines when partitioned support a hypervisor virtual |
588 | console. This driver allows each pSeries partition to have a console | 591 | console. This driver allows each pSeries partition to have a console |
@@ -593,6 +596,7 @@ config HVC_ISERIES | |||
593 | depends on PPC_ISERIES | 596 | depends on PPC_ISERIES |
594 | default y | 597 | default y |
595 | select HVC_DRIVER | 598 | select HVC_DRIVER |
599 | select HVC_IRQ | ||
596 | help | 600 | help |
597 | iSeries machines support a hypervisor virtual console. | 601 | iSeries machines support a hypervisor virtual console. |
598 | 602 | ||
@@ -614,13 +618,18 @@ config HVC_XEN | |||
614 | bool "Xen Hypervisor Console support" | 618 | bool "Xen Hypervisor Console support" |
615 | depends on XEN | 619 | depends on XEN |
616 | select HVC_DRIVER | 620 | select HVC_DRIVER |
621 | select HVC_IRQ | ||
617 | default y | 622 | default y |
618 | help | 623 | help |
619 | Xen virtual console device driver | 624 | Xen virtual console device driver |
620 | 625 | ||
621 | config VIRTIO_CONSOLE | 626 | config VIRTIO_CONSOLE |
622 | bool | 627 | tristate "Virtio console" |
628 | depends on VIRTIO | ||
623 | select HVC_DRIVER | 629 | select HVC_DRIVER |
630 | help | ||
631 | Virtio console for use with lguest and other hypervisors. | ||
632 | |||
624 | 633 | ||
625 | config HVCS | 634 | config HVCS |
626 | tristate "IBM Hypervisor Virtual Console Server support" | 635 | tristate "IBM Hypervisor Virtual Console Server support" |
@@ -857,13 +866,6 @@ config DS1302 | |||
857 | 866 | ||
858 | endif # RTC_LIB | 867 | endif # RTC_LIB |
859 | 868 | ||
860 | config COBALT_LCD | ||
861 | bool "Support for Cobalt LCD" | ||
862 | depends on MIPS_COBALT | ||
863 | help | ||
864 | This option enables support for the LCD display and buttons found | ||
865 | on Cobalt systems through a misc device. | ||
866 | |||
867 | config DTLK | 869 | config DTLK |
868 | tristate "Double Talk PC internal speech card support" | 870 | tristate "Double Talk PC internal speech card support" |
869 | depends on ISA | 871 | depends on ISA |
diff --git a/drivers/char/Makefile b/drivers/char/Makefile index dc5a327d72d5..f7a0d1a754fc 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile | |||
@@ -48,6 +48,7 @@ obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o | |||
48 | obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o | 48 | obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o |
49 | obj-$(CONFIG_HVC_BEAT) += hvc_beat.o | 49 | obj-$(CONFIG_HVC_BEAT) += hvc_beat.o |
50 | obj-$(CONFIG_HVC_DRIVER) += hvc_console.o | 50 | obj-$(CONFIG_HVC_DRIVER) += hvc_console.o |
51 | obj-$(CONFIG_HVC_IRQ) += hvc_irq.o | ||
51 | obj-$(CONFIG_HVC_XEN) += hvc_xen.o | 52 | obj-$(CONFIG_HVC_XEN) += hvc_xen.o |
52 | obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o | 53 | obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o |
53 | obj-$(CONFIG_RAW_DRIVER) += raw.o | 54 | obj-$(CONFIG_RAW_DRIVER) += raw.o |
@@ -63,7 +64,6 @@ obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o | |||
63 | obj-$(CONFIG_BFIN_OTP) += bfin-otp.o | 64 | obj-$(CONFIG_BFIN_OTP) += bfin-otp.o |
64 | 65 | ||
65 | obj-$(CONFIG_PRINTER) += lp.o | 66 | obj-$(CONFIG_PRINTER) += lp.o |
66 | obj-$(CONFIG_TIPAR) += tipar.o | ||
67 | 67 | ||
68 | obj-$(CONFIG_APM_EMULATION) += apm-emulation.o | 68 | obj-$(CONFIG_APM_EMULATION) += apm-emulation.o |
69 | 69 | ||
@@ -88,7 +88,6 @@ obj-$(CONFIG_TOSHIBA) += toshiba.o | |||
88 | obj-$(CONFIG_I8K) += i8k.o | 88 | obj-$(CONFIG_I8K) += i8k.o |
89 | obj-$(CONFIG_DS1620) += ds1620.o | 89 | obj-$(CONFIG_DS1620) += ds1620.o |
90 | obj-$(CONFIG_HW_RANDOM) += hw_random/ | 90 | obj-$(CONFIG_HW_RANDOM) += hw_random/ |
91 | obj-$(CONFIG_COBALT_LCD) += lcd.o | ||
92 | obj-$(CONFIG_PPDEV) += ppdev.o | 91 | obj-$(CONFIG_PPDEV) += ppdev.o |
93 | obj-$(CONFIG_NWBUTTON) += nwbutton.o | 92 | obj-$(CONFIG_NWBUTTON) += nwbutton.o |
94 | obj-$(CONFIG_NWFLASH) += nwflash.o | 93 | obj-$(CONFIG_NWFLASH) += nwflash.o |
diff --git a/drivers/char/ds1302.c b/drivers/char/ds1302.c index fada6ddefbae..c5e67a623951 100644 --- a/drivers/char/ds1302.c +++ b/drivers/char/ds1302.c | |||
@@ -20,10 +20,11 @@ | |||
20 | #include <linux/miscdevice.h> | 20 | #include <linux/miscdevice.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/bcd.h> | 22 | #include <linux/bcd.h> |
23 | #include <linux/smp_lock.h> | ||
24 | #include <linux/uaccess.h> | ||
25 | #include <linux/io.h> | ||
23 | 26 | ||
24 | #include <asm/uaccess.h> | ||
25 | #include <asm/system.h> | 27 | #include <asm/system.h> |
26 | #include <asm/io.h> | ||
27 | #include <asm/rtc.h> | 28 | #include <asm/rtc.h> |
28 | #if defined(CONFIG_M32R) | 29 | #if defined(CONFIG_M32R) |
29 | #include <asm/m32r.h> | 30 | #include <asm/m32r.h> |
@@ -153,9 +154,7 @@ static unsigned char days_in_mo[] = | |||
153 | 154 | ||
154 | /* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */ | 155 | /* ioctl that supports RTC_RD_TIME and RTC_SET_TIME (read and set time/date). */ |
155 | 156 | ||
156 | static int | 157 | static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
157 | rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | ||
158 | unsigned long arg) | ||
159 | { | 158 | { |
160 | unsigned long flags; | 159 | unsigned long flags; |
161 | 160 | ||
@@ -165,7 +164,9 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
165 | struct rtc_time rtc_tm; | 164 | struct rtc_time rtc_tm; |
166 | 165 | ||
167 | memset(&rtc_tm, 0, sizeof (struct rtc_time)); | 166 | memset(&rtc_tm, 0, sizeof (struct rtc_time)); |
167 | lock_kernel(); | ||
168 | get_rtc_time(&rtc_tm); | 168 | get_rtc_time(&rtc_tm); |
169 | unlock_kernel(); | ||
169 | if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) | 170 | if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) |
170 | return -EFAULT; | 171 | return -EFAULT; |
171 | return 0; | 172 | return 0; |
@@ -217,6 +218,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
217 | BIN_TO_BCD(mon); | 218 | BIN_TO_BCD(mon); |
218 | BIN_TO_BCD(yrs); | 219 | BIN_TO_BCD(yrs); |
219 | 220 | ||
221 | lock_kernel(); | ||
220 | local_irq_save(flags); | 222 | local_irq_save(flags); |
221 | CMOS_WRITE(yrs, RTC_YEAR); | 223 | CMOS_WRITE(yrs, RTC_YEAR); |
222 | CMOS_WRITE(mon, RTC_MONTH); | 224 | CMOS_WRITE(mon, RTC_MONTH); |
@@ -225,6 +227,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
225 | CMOS_WRITE(min, RTC_MINUTES); | 227 | CMOS_WRITE(min, RTC_MINUTES); |
226 | CMOS_WRITE(sec, RTC_SECONDS); | 228 | CMOS_WRITE(sec, RTC_SECONDS); |
227 | local_irq_restore(flags); | 229 | local_irq_restore(flags); |
230 | unlock_kernel(); | ||
228 | 231 | ||
229 | /* Notice that at this point, the RTC is updated but | 232 | /* Notice that at this point, the RTC is updated but |
230 | * the kernel is still running with the old time. | 233 | * the kernel is still running with the old time. |
@@ -244,8 +247,10 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
244 | if(copy_from_user(&tcs_val, (int*)arg, sizeof(int))) | 247 | if(copy_from_user(&tcs_val, (int*)arg, sizeof(int))) |
245 | return -EFAULT; | 248 | return -EFAULT; |
246 | 249 | ||
250 | lock_kernel(); | ||
247 | tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F); | 251 | tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F); |
248 | ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); | 252 | ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); |
253 | unlock_kernel(); | ||
249 | return 0; | 254 | return 0; |
250 | } | 255 | } |
251 | default: | 256 | default: |
@@ -282,7 +287,7 @@ get_rtc_status(char *buf) | |||
282 | 287 | ||
283 | static const struct file_operations rtc_fops = { | 288 | static const struct file_operations rtc_fops = { |
284 | .owner = THIS_MODULE, | 289 | .owner = THIS_MODULE, |
285 | .ioctl = rtc_ioctl, | 290 | .unlocked_ioctl = rtc_ioctl, |
286 | }; | 291 | }; |
287 | 292 | ||
288 | /* Probe for the chip by writing something to its RAM and try reading it back. */ | 293 | /* Probe for the chip by writing something to its RAM and try reading it back. */ |
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index 33c466a4888f..19b88504e960 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c | |||
@@ -36,10 +36,10 @@ | |||
36 | #include <linux/smp_lock.h> | 36 | #include <linux/smp_lock.h> |
37 | #include <linux/firmware.h> | 37 | #include <linux/firmware.h> |
38 | #include <linux/platform_device.h> | 38 | #include <linux/platform_device.h> |
39 | #include <linux/uaccess.h> /* For put_user and get_user */ | ||
39 | 40 | ||
40 | #include <asm/atarihw.h> | 41 | #include <asm/atarihw.h> |
41 | #include <asm/traps.h> | 42 | #include <asm/traps.h> |
42 | #include <asm/uaccess.h> /* For put_user and get_user */ | ||
43 | 43 | ||
44 | #include <asm/dsp56k.h> | 44 | #include <asm/dsp56k.h> |
45 | 45 | ||
@@ -303,8 +303,8 @@ static ssize_t dsp56k_write(struct file *file, const char __user *buf, size_t co | |||
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | static int dsp56k_ioctl(struct inode *inode, struct file *file, | 306 | static long dsp56k_ioctl(struct file *file, unsigned int cmd, |
307 | unsigned int cmd, unsigned long arg) | 307 | unsigned long arg) |
308 | { | 308 | { |
309 | int dev = iminor(inode) & 0x0f; | 309 | int dev = iminor(inode) & 0x0f; |
310 | void __user *argp = (void __user *)arg; | 310 | void __user *argp = (void __user *)arg; |
@@ -331,8 +331,9 @@ static int dsp56k_ioctl(struct inode *inode, struct file *file, | |||
331 | if (len > DSP56K_MAX_BINARY_LENGTH) { | 331 | if (len > DSP56K_MAX_BINARY_LENGTH) { |
332 | return -EINVAL; | 332 | return -EINVAL; |
333 | } | 333 | } |
334 | 334 | lock_kernel(); | |
335 | r = dsp56k_upload(bin, len); | 335 | r = dsp56k_upload(bin, len); |
336 | unlock_kernel(); | ||
336 | if (r < 0) { | 337 | if (r < 0) { |
337 | return r; | 338 | return r; |
338 | } | 339 | } |
@@ -342,12 +343,16 @@ static int dsp56k_ioctl(struct inode *inode, struct file *file, | |||
342 | case DSP56K_SET_TX_WSIZE: | 343 | case DSP56K_SET_TX_WSIZE: |
343 | if (arg > 4 || arg < 1) | 344 | if (arg > 4 || arg < 1) |
344 | return -EINVAL; | 345 | return -EINVAL; |
346 | lock_kernel(); | ||
345 | dsp56k.tx_wsize = (int) arg; | 347 | dsp56k.tx_wsize = (int) arg; |
348 | unlock_kernel(); | ||
346 | break; | 349 | break; |
347 | case DSP56K_SET_RX_WSIZE: | 350 | case DSP56K_SET_RX_WSIZE: |
348 | if (arg > 4 || arg < 1) | 351 | if (arg > 4 || arg < 1) |
349 | return -EINVAL; | 352 | return -EINVAL; |
353 | lock_kernel(); | ||
350 | dsp56k.rx_wsize = (int) arg; | 354 | dsp56k.rx_wsize = (int) arg; |
355 | unlock_kernel(); | ||
351 | break; | 356 | break; |
352 | case DSP56K_HOST_FLAGS: | 357 | case DSP56K_HOST_FLAGS: |
353 | { | 358 | { |
@@ -359,6 +364,7 @@ static int dsp56k_ioctl(struct inode *inode, struct file *file, | |||
359 | if(get_user(out, &hf->out) < 0) | 364 | if(get_user(out, &hf->out) < 0) |
360 | return -EFAULT; | 365 | return -EFAULT; |
361 | 366 | ||
367 | lock_kernel(); | ||
362 | if ((dir & 0x1) && (out & 0x1)) | 368 | if ((dir & 0x1) && (out & 0x1)) |
363 | dsp56k_host_interface.icr |= DSP56K_ICR_HF0; | 369 | dsp56k_host_interface.icr |= DSP56K_ICR_HF0; |
364 | else if (dir & 0x1) | 370 | else if (dir & 0x1) |
@@ -373,14 +379,16 @@ static int dsp56k_ioctl(struct inode *inode, struct file *file, | |||
373 | if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; | 379 | if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; |
374 | if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; | 380 | if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; |
375 | if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; | 381 | if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; |
376 | 382 | unlock_kernel(); | |
377 | return put_user(status, &hf->status); | 383 | return put_user(status, &hf->status); |
378 | } | 384 | } |
379 | case DSP56K_HOST_CMD: | 385 | case DSP56K_HOST_CMD: |
380 | if (arg > 31 || arg < 0) | 386 | if (arg > 31 || arg < 0) |
381 | return -EINVAL; | 387 | return -EINVAL; |
388 | lock_kernel(); | ||
382 | dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | | 389 | dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | |
383 | DSP56K_CVR_HC); | 390 | DSP56K_CVR_HC); |
391 | unlock_kernel(); | ||
384 | break; | 392 | break; |
385 | default: | 393 | default: |
386 | return -EINVAL; | 394 | return -EINVAL; |
@@ -472,7 +480,7 @@ static const struct file_operations dsp56k_fops = { | |||
472 | .owner = THIS_MODULE, | 480 | .owner = THIS_MODULE, |
473 | .read = dsp56k_read, | 481 | .read = dsp56k_read, |
474 | .write = dsp56k_write, | 482 | .write = dsp56k_write, |
475 | .ioctl = dsp56k_ioctl, | 483 | .unlocked_ioctl = dsp56k_ioctl, |
476 | .open = dsp56k_open, | 484 | .open = dsp56k_open, |
477 | .release = dsp56k_release, | 485 | .release = dsp56k_release, |
478 | }; | 486 | }; |
diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c index d57ca3e4e534..67fbd7aab5db 100644 --- a/drivers/char/efirtc.c +++ b/drivers/char/efirtc.c | |||
@@ -37,8 +37,9 @@ | |||
37 | #include <linux/rtc.h> | 37 | #include <linux/rtc.h> |
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
39 | #include <linux/efi.h> | 39 | #include <linux/efi.h> |
40 | #include <linux/smp_lock.h> | ||
41 | #include <linux/uaccess.h> | ||
40 | 42 | ||
41 | #include <asm/uaccess.h> | ||
42 | #include <asm/system.h> | 43 | #include <asm/system.h> |
43 | 44 | ||
44 | #define EFI_RTC_VERSION "0.4" | 45 | #define EFI_RTC_VERSION "0.4" |
@@ -51,8 +52,8 @@ | |||
51 | 52 | ||
52 | static DEFINE_SPINLOCK(efi_rtc_lock); | 53 | static DEFINE_SPINLOCK(efi_rtc_lock); |
53 | 54 | ||
54 | static int efi_rtc_ioctl(struct inode *inode, struct file *file, | 55 | static long efi_rtc_ioctl(struct file *file, unsigned int cmd, |
55 | unsigned int cmd, unsigned long arg); | 56 | unsigned long arg); |
56 | 57 | ||
57 | #define is_leap(year) \ | 58 | #define is_leap(year) \ |
58 | ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) | 59 | ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) |
@@ -146,9 +147,8 @@ convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) | |||
146 | } | 147 | } |
147 | } | 148 | } |
148 | 149 | ||
149 | static int | 150 | static long efi_rtc_ioctl(struct file *file, unsigned int cmd, |
150 | efi_rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 151 | unsigned long arg) |
151 | unsigned long arg) | ||
152 | { | 152 | { |
153 | 153 | ||
154 | efi_status_t status; | 154 | efi_status_t status; |
@@ -175,13 +175,13 @@ efi_rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
175 | return -EINVAL; | 175 | return -EINVAL; |
176 | 176 | ||
177 | case RTC_RD_TIME: | 177 | case RTC_RD_TIME: |
178 | 178 | lock_kernel(); | |
179 | spin_lock_irqsave(&efi_rtc_lock, flags); | 179 | spin_lock_irqsave(&efi_rtc_lock, flags); |
180 | 180 | ||
181 | status = efi.get_time(&eft, &cap); | 181 | status = efi.get_time(&eft, &cap); |
182 | 182 | ||
183 | spin_unlock_irqrestore(&efi_rtc_lock,flags); | 183 | spin_unlock_irqrestore(&efi_rtc_lock,flags); |
184 | 184 | unlock_kernel(); | |
185 | if (status != EFI_SUCCESS) { | 185 | if (status != EFI_SUCCESS) { |
186 | /* should never happen */ | 186 | /* should never happen */ |
187 | printk(KERN_ERR "efitime: can't read time\n"); | 187 | printk(KERN_ERR "efitime: can't read time\n"); |
@@ -203,11 +203,13 @@ efi_rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
203 | 203 | ||
204 | convert_to_efi_time(&wtime, &eft); | 204 | convert_to_efi_time(&wtime, &eft); |
205 | 205 | ||
206 | lock_kernel(); | ||
206 | spin_lock_irqsave(&efi_rtc_lock, flags); | 207 | spin_lock_irqsave(&efi_rtc_lock, flags); |
207 | 208 | ||
208 | status = efi.set_time(&eft); | 209 | status = efi.set_time(&eft); |
209 | 210 | ||
210 | spin_unlock_irqrestore(&efi_rtc_lock,flags); | 211 | spin_unlock_irqrestore(&efi_rtc_lock,flags); |
212 | unlock_kernel(); | ||
211 | 213 | ||
212 | return status == EFI_SUCCESS ? 0 : -EINVAL; | 214 | return status == EFI_SUCCESS ? 0 : -EINVAL; |
213 | 215 | ||
@@ -223,6 +225,7 @@ efi_rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
223 | 225 | ||
224 | convert_to_efi_time(&wtime, &eft); | 226 | convert_to_efi_time(&wtime, &eft); |
225 | 227 | ||
228 | lock_kernel(); | ||
226 | spin_lock_irqsave(&efi_rtc_lock, flags); | 229 | spin_lock_irqsave(&efi_rtc_lock, flags); |
227 | /* | 230 | /* |
228 | * XXX Fixme: | 231 | * XXX Fixme: |
@@ -233,16 +236,19 @@ efi_rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
233 | status = efi.set_wakeup_time((efi_bool_t)enabled, &eft); | 236 | status = efi.set_wakeup_time((efi_bool_t)enabled, &eft); |
234 | 237 | ||
235 | spin_unlock_irqrestore(&efi_rtc_lock,flags); | 238 | spin_unlock_irqrestore(&efi_rtc_lock,flags); |
239 | unlock_kernel(); | ||
236 | 240 | ||
237 | return status == EFI_SUCCESS ? 0 : -EINVAL; | 241 | return status == EFI_SUCCESS ? 0 : -EINVAL; |
238 | 242 | ||
239 | case RTC_WKALM_RD: | 243 | case RTC_WKALM_RD: |
240 | 244 | ||
245 | lock_kernel(); | ||
241 | spin_lock_irqsave(&efi_rtc_lock, flags); | 246 | spin_lock_irqsave(&efi_rtc_lock, flags); |
242 | 247 | ||
243 | status = efi.get_wakeup_time((efi_bool_t *)&enabled, (efi_bool_t *)&pending, &eft); | 248 | status = efi.get_wakeup_time((efi_bool_t *)&enabled, (efi_bool_t *)&pending, &eft); |
244 | 249 | ||
245 | spin_unlock_irqrestore(&efi_rtc_lock,flags); | 250 | spin_unlock_irqrestore(&efi_rtc_lock,flags); |
251 | unlock_kernel(); | ||
246 | 252 | ||
247 | if (status != EFI_SUCCESS) return -EINVAL; | 253 | if (status != EFI_SUCCESS) return -EINVAL; |
248 | 254 | ||
@@ -256,7 +262,7 @@ efi_rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
256 | return copy_to_user(&ewp->time, &wtime, | 262 | return copy_to_user(&ewp->time, &wtime, |
257 | sizeof(struct rtc_time)) ? -EFAULT : 0; | 263 | sizeof(struct rtc_time)) ? -EFAULT : 0; |
258 | } | 264 | } |
259 | return -EINVAL; | 265 | return -ENOTTY; |
260 | } | 266 | } |
261 | 267 | ||
262 | /* | 268 | /* |
@@ -265,8 +271,7 @@ efi_rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
265 | * up things on a close. | 271 | * up things on a close. |
266 | */ | 272 | */ |
267 | 273 | ||
268 | static int | 274 | static int efi_rtc_open(struct inode *inode, struct file *file) |
269 | efi_rtc_open(struct inode *inode, struct file *file) | ||
270 | { | 275 | { |
271 | /* | 276 | /* |
272 | * nothing special to do here | 277 | * nothing special to do here |
@@ -277,8 +282,7 @@ efi_rtc_open(struct inode *inode, struct file *file) | |||
277 | return 0; | 282 | return 0; |
278 | } | 283 | } |
279 | 284 | ||
280 | static int | 285 | static int efi_rtc_close(struct inode *inode, struct file *file) |
281 | efi_rtc_close(struct inode *inode, struct file *file) | ||
282 | { | 286 | { |
283 | return 0; | 287 | return 0; |
284 | } | 288 | } |
@@ -289,13 +293,12 @@ efi_rtc_close(struct inode *inode, struct file *file) | |||
289 | 293 | ||
290 | static const struct file_operations efi_rtc_fops = { | 294 | static const struct file_operations efi_rtc_fops = { |
291 | .owner = THIS_MODULE, | 295 | .owner = THIS_MODULE, |
292 | .ioctl = efi_rtc_ioctl, | 296 | .unlocked_ioctl = efi_rtc_ioctl, |
293 | .open = efi_rtc_open, | 297 | .open = efi_rtc_open, |
294 | .release = efi_rtc_close, | 298 | .release = efi_rtc_close, |
295 | }; | 299 | }; |
296 | 300 | ||
297 | static struct miscdevice efi_rtc_dev= | 301 | static struct miscdevice efi_rtc_dev= { |
298 | { | ||
299 | EFI_RTC_MINOR, | 302 | EFI_RTC_MINOR, |
300 | "efirtc", | 303 | "efirtc", |
301 | &efi_rtc_fops | 304 | &efi_rtc_fops |
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index fb0a85a1eb36..b3f5dbc6d880 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c | |||
@@ -623,6 +623,7 @@ static inline int hpet_tpcheck(struct hpet_task *tp) | |||
623 | return -ENXIO; | 623 | return -ENXIO; |
624 | } | 624 | } |
625 | 625 | ||
626 | #if 0 | ||
626 | int hpet_unregister(struct hpet_task *tp) | 627 | int hpet_unregister(struct hpet_task *tp) |
627 | { | 628 | { |
628 | struct hpet_dev *devp; | 629 | struct hpet_dev *devp; |
@@ -652,6 +653,7 @@ int hpet_unregister(struct hpet_task *tp) | |||
652 | 653 | ||
653 | return 0; | 654 | return 0; |
654 | } | 655 | } |
656 | #endif /* 0 */ | ||
655 | 657 | ||
656 | static ctl_table hpet_table[] = { | 658 | static ctl_table hpet_table[] = { |
657 | { | 659 | { |
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 2f9759d625cc..02aac104842d 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/kbd_kern.h> | 28 | #include <linux/kbd_kern.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/kref.h> | ||
31 | #include <linux/kthread.h> | 30 | #include <linux/kthread.h> |
32 | #include <linux/list.h> | 31 | #include <linux/list.h> |
33 | #include <linux/module.h> | 32 | #include <linux/module.h> |
@@ -75,23 +74,6 @@ static int hvc_init(void); | |||
75 | static int sysrq_pressed; | 74 | static int sysrq_pressed; |
76 | #endif | 75 | #endif |
77 | 76 | ||
78 | struct hvc_struct { | ||
79 | spinlock_t lock; | ||
80 | int index; | ||
81 | struct tty_struct *tty; | ||
82 | unsigned int count; | ||
83 | int do_wakeup; | ||
84 | char *outbuf; | ||
85 | int outbuf_size; | ||
86 | int n_outbuf; | ||
87 | uint32_t vtermno; | ||
88 | struct hv_ops *ops; | ||
89 | int irq_requested; | ||
90 | int irq; | ||
91 | struct list_head next; | ||
92 | struct kref kref; /* ref count & hvc_struct lifetime */ | ||
93 | }; | ||
94 | |||
95 | /* dynamic list of hvc_struct instances */ | 77 | /* dynamic list of hvc_struct instances */ |
96 | static LIST_HEAD(hvc_structs); | 78 | static LIST_HEAD(hvc_structs); |
97 | 79 | ||
@@ -298,27 +280,15 @@ int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops) | |||
298 | 280 | ||
299 | return 0; | 281 | return 0; |
300 | } | 282 | } |
283 | EXPORT_SYMBOL_GPL(hvc_instantiate); | ||
301 | 284 | ||
302 | /* Wake the sleeping khvcd */ | 285 | /* Wake the sleeping khvcd */ |
303 | static void hvc_kick(void) | 286 | void hvc_kick(void) |
304 | { | 287 | { |
305 | hvc_kicked = 1; | 288 | hvc_kicked = 1; |
306 | wake_up_process(hvc_task); | 289 | wake_up_process(hvc_task); |
307 | } | 290 | } |
308 | 291 | EXPORT_SYMBOL_GPL(hvc_kick); | |
309 | static int hvc_poll(struct hvc_struct *hp); | ||
310 | |||
311 | /* | ||
312 | * NOTE: This API isn't used if the console adapter doesn't support interrupts. | ||
313 | * In this case the console is poll driven. | ||
314 | */ | ||
315 | static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance) | ||
316 | { | ||
317 | /* if hvc_poll request a repoll, then kick the hvcd thread */ | ||
318 | if (hvc_poll(dev_instance)) | ||
319 | hvc_kick(); | ||
320 | return IRQ_HANDLED; | ||
321 | } | ||
322 | 292 | ||
323 | static void hvc_unthrottle(struct tty_struct *tty) | 293 | static void hvc_unthrottle(struct tty_struct *tty) |
324 | { | 294 | { |
@@ -333,7 +303,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) | |||
333 | { | 303 | { |
334 | struct hvc_struct *hp; | 304 | struct hvc_struct *hp; |
335 | unsigned long flags; | 305 | unsigned long flags; |
336 | int irq = 0; | ||
337 | int rc = 0; | 306 | int rc = 0; |
338 | 307 | ||
339 | /* Auto increments kref reference if found. */ | 308 | /* Auto increments kref reference if found. */ |
@@ -352,18 +321,15 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) | |||
352 | tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */ | 321 | tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */ |
353 | 322 | ||
354 | hp->tty = tty; | 323 | hp->tty = tty; |
355 | /* Save for request_irq outside of spin_lock. */ | 324 | |
356 | irq = hp->irq; | 325 | if (hp->ops->notifier_add) |
357 | if (irq) | 326 | rc = hp->ops->notifier_add(hp, hp->data); |
358 | hp->irq_requested = 1; | ||
359 | 327 | ||
360 | spin_unlock_irqrestore(&hp->lock, flags); | 328 | spin_unlock_irqrestore(&hp->lock, flags); |
361 | /* check error, fallback to non-irq */ | 329 | |
362 | if (irq) | ||
363 | rc = request_irq(irq, hvc_handle_interrupt, IRQF_DISABLED, "hvc_console", hp); | ||
364 | 330 | ||
365 | /* | 331 | /* |
366 | * If the request_irq() fails and we return an error. The tty layer | 332 | * If the notifier fails we return an error. The tty layer |
367 | * will call hvc_close() after a failed open but we don't want to clean | 333 | * will call hvc_close() after a failed open but we don't want to clean |
368 | * up there so we'll clean up here and clear out the previously set | 334 | * up there so we'll clean up here and clear out the previously set |
369 | * tty fields and return the kref reference. | 335 | * tty fields and return the kref reference. |
@@ -371,7 +337,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) | |||
371 | if (rc) { | 337 | if (rc) { |
372 | spin_lock_irqsave(&hp->lock, flags); | 338 | spin_lock_irqsave(&hp->lock, flags); |
373 | hp->tty = NULL; | 339 | hp->tty = NULL; |
374 | hp->irq_requested = 0; | ||
375 | spin_unlock_irqrestore(&hp->lock, flags); | 340 | spin_unlock_irqrestore(&hp->lock, flags); |
376 | tty->driver_data = NULL; | 341 | tty->driver_data = NULL; |
377 | kref_put(&hp->kref, destroy_hvc_struct); | 342 | kref_put(&hp->kref, destroy_hvc_struct); |
@@ -386,7 +351,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) | |||
386 | static void hvc_close(struct tty_struct *tty, struct file * filp) | 351 | static void hvc_close(struct tty_struct *tty, struct file * filp) |
387 | { | 352 | { |
388 | struct hvc_struct *hp; | 353 | struct hvc_struct *hp; |
389 | int irq = 0; | ||
390 | unsigned long flags; | 354 | unsigned long flags; |
391 | 355 | ||
392 | if (tty_hung_up_p(filp)) | 356 | if (tty_hung_up_p(filp)) |
@@ -404,9 +368,8 @@ static void hvc_close(struct tty_struct *tty, struct file * filp) | |||
404 | spin_lock_irqsave(&hp->lock, flags); | 368 | spin_lock_irqsave(&hp->lock, flags); |
405 | 369 | ||
406 | if (--hp->count == 0) { | 370 | if (--hp->count == 0) { |
407 | if (hp->irq_requested) | 371 | if (hp->ops->notifier_del) |
408 | irq = hp->irq; | 372 | hp->ops->notifier_del(hp, hp->data); |
409 | hp->irq_requested = 0; | ||
410 | 373 | ||
411 | /* We are done with the tty pointer now. */ | 374 | /* We are done with the tty pointer now. */ |
412 | hp->tty = NULL; | 375 | hp->tty = NULL; |
@@ -418,10 +381,6 @@ static void hvc_close(struct tty_struct *tty, struct file * filp) | |||
418 | * waking periodically to check chars_in_buffer(). | 381 | * waking periodically to check chars_in_buffer(). |
419 | */ | 382 | */ |
420 | tty_wait_until_sent(tty, HVC_CLOSE_WAIT); | 383 | tty_wait_until_sent(tty, HVC_CLOSE_WAIT); |
421 | |||
422 | if (irq) | ||
423 | free_irq(irq, hp); | ||
424 | |||
425 | } else { | 384 | } else { |
426 | if (hp->count < 0) | 385 | if (hp->count < 0) |
427 | printk(KERN_ERR "hvc_close %X: oops, count is %d\n", | 386 | printk(KERN_ERR "hvc_close %X: oops, count is %d\n", |
@@ -436,7 +395,6 @@ static void hvc_hangup(struct tty_struct *tty) | |||
436 | { | 395 | { |
437 | struct hvc_struct *hp = tty->driver_data; | 396 | struct hvc_struct *hp = tty->driver_data; |
438 | unsigned long flags; | 397 | unsigned long flags; |
439 | int irq = 0; | ||
440 | int temp_open_count; | 398 | int temp_open_count; |
441 | 399 | ||
442 | if (!hp) | 400 | if (!hp) |
@@ -458,13 +416,12 @@ static void hvc_hangup(struct tty_struct *tty) | |||
458 | hp->count = 0; | 416 | hp->count = 0; |
459 | hp->n_outbuf = 0; | 417 | hp->n_outbuf = 0; |
460 | hp->tty = NULL; | 418 | hp->tty = NULL; |
461 | if (hp->irq_requested) | 419 | |
462 | /* Saved for use outside of spin_lock. */ | 420 | if (hp->ops->notifier_del) |
463 | irq = hp->irq; | 421 | hp->ops->notifier_del(hp, hp->data); |
464 | hp->irq_requested = 0; | 422 | |
465 | spin_unlock_irqrestore(&hp->lock, flags); | 423 | spin_unlock_irqrestore(&hp->lock, flags); |
466 | if (irq) | 424 | |
467 | free_irq(irq, hp); | ||
468 | while(temp_open_count) { | 425 | while(temp_open_count) { |
469 | --temp_open_count; | 426 | --temp_open_count; |
470 | kref_put(&hp->kref, destroy_hvc_struct); | 427 | kref_put(&hp->kref, destroy_hvc_struct); |
@@ -575,7 +532,7 @@ static u32 timeout = MIN_TIMEOUT; | |||
575 | #define HVC_POLL_READ 0x00000001 | 532 | #define HVC_POLL_READ 0x00000001 |
576 | #define HVC_POLL_WRITE 0x00000002 | 533 | #define HVC_POLL_WRITE 0x00000002 |
577 | 534 | ||
578 | static int hvc_poll(struct hvc_struct *hp) | 535 | int hvc_poll(struct hvc_struct *hp) |
579 | { | 536 | { |
580 | struct tty_struct *tty; | 537 | struct tty_struct *tty; |
581 | int i, n, poll_mask = 0; | 538 | int i, n, poll_mask = 0; |
@@ -602,10 +559,10 @@ static int hvc_poll(struct hvc_struct *hp) | |||
602 | if (test_bit(TTY_THROTTLED, &tty->flags)) | 559 | if (test_bit(TTY_THROTTLED, &tty->flags)) |
603 | goto throttled; | 560 | goto throttled; |
604 | 561 | ||
605 | /* If we aren't interrupt driven and aren't throttled, we always | 562 | /* If we aren't notifier driven and aren't throttled, we always |
606 | * request a reschedule | 563 | * request a reschedule |
607 | */ | 564 | */ |
608 | if (hp->irq == 0) | 565 | if (!hp->irq_requested) |
609 | poll_mask |= HVC_POLL_READ; | 566 | poll_mask |= HVC_POLL_READ; |
610 | 567 | ||
611 | /* Read data if any */ | 568 | /* Read data if any */ |
@@ -674,6 +631,7 @@ static int hvc_poll(struct hvc_struct *hp) | |||
674 | 631 | ||
675 | return poll_mask; | 632 | return poll_mask; |
676 | } | 633 | } |
634 | EXPORT_SYMBOL_GPL(hvc_poll); | ||
677 | 635 | ||
678 | /* | 636 | /* |
679 | * This kthread is either polling or interrupt driven. This is determined by | 637 | * This kthread is either polling or interrupt driven. This is determined by |
@@ -733,7 +691,7 @@ static const struct tty_operations hvc_ops = { | |||
733 | .chars_in_buffer = hvc_chars_in_buffer, | 691 | .chars_in_buffer = hvc_chars_in_buffer, |
734 | }; | 692 | }; |
735 | 693 | ||
736 | struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq, | 694 | struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int data, |
737 | struct hv_ops *ops, int outbuf_size) | 695 | struct hv_ops *ops, int outbuf_size) |
738 | { | 696 | { |
739 | struct hvc_struct *hp; | 697 | struct hvc_struct *hp; |
@@ -754,7 +712,7 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq, | |||
754 | memset(hp, 0x00, sizeof(*hp)); | 712 | memset(hp, 0x00, sizeof(*hp)); |
755 | 713 | ||
756 | hp->vtermno = vtermno; | 714 | hp->vtermno = vtermno; |
757 | hp->irq = irq; | 715 | hp->data = data; |
758 | hp->ops = ops; | 716 | hp->ops = ops; |
759 | hp->outbuf_size = outbuf_size; | 717 | hp->outbuf_size = outbuf_size; |
760 | hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; | 718 | hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; |
@@ -784,6 +742,7 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq, | |||
784 | 742 | ||
785 | return hp; | 743 | return hp; |
786 | } | 744 | } |
745 | EXPORT_SYMBOL_GPL(hvc_alloc); | ||
787 | 746 | ||
788 | int __devexit hvc_remove(struct hvc_struct *hp) | 747 | int __devexit hvc_remove(struct hvc_struct *hp) |
789 | { | 748 | { |
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h index 42ffb17e15df..d9ce10915625 100644 --- a/drivers/char/hvc_console.h +++ b/drivers/char/hvc_console.h | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #ifndef HVC_CONSOLE_H | 27 | #ifndef HVC_CONSOLE_H |
28 | #define HVC_CONSOLE_H | 28 | #define HVC_CONSOLE_H |
29 | #include <linux/kref.h> | ||
29 | 30 | ||
30 | /* | 31 | /* |
31 | * This is the max number of console adapters that can/will be found as | 32 | * This is the max number of console adapters that can/will be found as |
@@ -42,24 +43,50 @@ | |||
42 | */ | 43 | */ |
43 | #define HVC_ALLOC_TTY_ADAPTERS 8 | 44 | #define HVC_ALLOC_TTY_ADAPTERS 8 |
44 | 45 | ||
46 | struct hvc_struct { | ||
47 | spinlock_t lock; | ||
48 | int index; | ||
49 | struct tty_struct *tty; | ||
50 | unsigned int count; | ||
51 | int do_wakeup; | ||
52 | char *outbuf; | ||
53 | int outbuf_size; | ||
54 | int n_outbuf; | ||
55 | uint32_t vtermno; | ||
56 | struct hv_ops *ops; | ||
57 | int irq_requested; | ||
58 | int data; | ||
59 | struct list_head next; | ||
60 | struct kref kref; /* ref count & hvc_struct lifetime */ | ||
61 | }; | ||
45 | 62 | ||
46 | /* implemented by a low level driver */ | 63 | /* implemented by a low level driver */ |
47 | struct hv_ops { | 64 | struct hv_ops { |
48 | int (*get_chars)(uint32_t vtermno, char *buf, int count); | 65 | int (*get_chars)(uint32_t vtermno, char *buf, int count); |
49 | int (*put_chars)(uint32_t vtermno, const char *buf, int count); | 66 | int (*put_chars)(uint32_t vtermno, const char *buf, int count); |
50 | }; | ||
51 | 67 | ||
52 | struct hvc_struct; | 68 | /* Callbacks for notification. Called in open and close */ |
69 | int (*notifier_add)(struct hvc_struct *hp, int irq); | ||
70 | void (*notifier_del)(struct hvc_struct *hp, int irq); | ||
71 | }; | ||
53 | 72 | ||
54 | /* Register a vterm and a slot index for use as a console (console_init) */ | 73 | /* Register a vterm and a slot index for use as a console (console_init) */ |
55 | extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops); | 74 | extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops); |
56 | 75 | ||
57 | /* register a vterm for hvc tty operation (module_init or hotplug add) */ | 76 | /* register a vterm for hvc tty operation (module_init or hotplug add) */ |
58 | extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq, | 77 | extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int data, |
59 | struct hv_ops *ops, int outbuf_size); | 78 | struct hv_ops *ops, int outbuf_size); |
60 | /* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */ | 79 | /* remove a vterm from hvc tty operation (module_exit or hotplug remove) */ |
61 | extern int __devexit hvc_remove(struct hvc_struct *hp); | 80 | extern int __devexit hvc_remove(struct hvc_struct *hp); |
62 | 81 | ||
82 | /* data available */ | ||
83 | int hvc_poll(struct hvc_struct *hp); | ||
84 | void hvc_kick(void); | ||
85 | |||
86 | /* default notifier for irq based notification */ | ||
87 | extern int notifier_add_irq(struct hvc_struct *hp, int data); | ||
88 | extern void notifier_del_irq(struct hvc_struct *hp, int data); | ||
89 | |||
63 | 90 | ||
64 | #if defined(CONFIG_XMON) && defined(CONFIG_SMP) | 91 | #if defined(CONFIG_XMON) && defined(CONFIG_SMP) |
65 | #include <asm/xmon.h> | 92 | #include <asm/xmon.h> |
diff --git a/drivers/char/hvc_irq.c b/drivers/char/hvc_irq.c new file mode 100644 index 000000000000..73a59cdb8947 --- /dev/null +++ b/drivers/char/hvc_irq.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * Copyright IBM Corp. 2001,2008 | ||
3 | * | ||
4 | * This file contains the IRQ specific code for hvc_console | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | #include <linux/interrupt.h> | ||
9 | |||
10 | #include "hvc_console.h" | ||
11 | |||
12 | static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance) | ||
13 | { | ||
14 | /* if hvc_poll request a repoll, then kick the hvcd thread */ | ||
15 | if (hvc_poll(dev_instance)) | ||
16 | hvc_kick(); | ||
17 | return IRQ_HANDLED; | ||
18 | } | ||
19 | |||
20 | /* | ||
21 | * For IRQ based systems these callbacks can be used | ||
22 | */ | ||
23 | int notifier_add_irq(struct hvc_struct *hp, int irq) | ||
24 | { | ||
25 | int rc; | ||
26 | |||
27 | if (!irq) { | ||
28 | hp->irq_requested = 0; | ||
29 | return 0; | ||
30 | } | ||
31 | rc = request_irq(irq, hvc_handle_interrupt, IRQF_DISABLED, | ||
32 | "hvc_console", hp); | ||
33 | if (!rc) | ||
34 | hp->irq_requested = 1; | ||
35 | return rc; | ||
36 | } | ||
37 | |||
38 | void notifier_del_irq(struct hvc_struct *hp, int irq) | ||
39 | { | ||
40 | if (!irq) | ||
41 | return; | ||
42 | free_irq(irq, hp); | ||
43 | hp->irq_requested = 0; | ||
44 | } | ||
diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c index a08f8f981c11..b71c610fe5ae 100644 --- a/drivers/char/hvc_iseries.c +++ b/drivers/char/hvc_iseries.c | |||
@@ -200,6 +200,8 @@ done: | |||
200 | static struct hv_ops hvc_get_put_ops = { | 200 | static struct hv_ops hvc_get_put_ops = { |
201 | .get_chars = get_chars, | 201 | .get_chars = get_chars, |
202 | .put_chars = put_chars, | 202 | .put_chars = put_chars, |
203 | .notifier_add = notifier_add_irq, | ||
204 | .notifier_del = notifier_del_irq, | ||
203 | }; | 205 | }; |
204 | 206 | ||
205 | static int __devinit hvc_vio_probe(struct vio_dev *vdev, | 207 | static int __devinit hvc_vio_probe(struct vio_dev *vdev, |
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c index 79711aa4b41d..93f3840c1682 100644 --- a/drivers/char/hvc_vio.c +++ b/drivers/char/hvc_vio.c | |||
@@ -80,6 +80,8 @@ static int filtered_get_chars(uint32_t vtermno, char *buf, int count) | |||
80 | static struct hv_ops hvc_get_put_ops = { | 80 | static struct hv_ops hvc_get_put_ops = { |
81 | .get_chars = filtered_get_chars, | 81 | .get_chars = filtered_get_chars, |
82 | .put_chars = hvc_put_chars, | 82 | .put_chars = hvc_put_chars, |
83 | .notifier_add = notifier_add_irq, | ||
84 | .notifier_del = notifier_del_irq, | ||
83 | }; | 85 | }; |
84 | 86 | ||
85 | static int __devinit hvc_vio_probe(struct vio_dev *vdev, | 87 | static int __devinit hvc_vio_probe(struct vio_dev *vdev, |
diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c index db2ae4216279..6b70aa66a587 100644 --- a/drivers/char/hvc_xen.c +++ b/drivers/char/hvc_xen.c | |||
@@ -100,6 +100,8 @@ static int read_console(uint32_t vtermno, char *buf, int len) | |||
100 | static struct hv_ops hvc_ops = { | 100 | static struct hv_ops hvc_ops = { |
101 | .get_chars = read_console, | 101 | .get_chars = read_console, |
102 | .put_chars = write_console, | 102 | .put_chars = write_console, |
103 | .notifier_add = notifier_add_irq, | ||
104 | .notifier_del = notifier_del_irq, | ||
103 | }; | 105 | }; |
104 | 106 | ||
105 | static int __init xen_init(void) | 107 | static int __init xen_init(void) |
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 9cb48fcd316c..689f9dcd3b86 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c | |||
@@ -203,7 +203,7 @@ static int set_serial_info(i2ChanStrPtr, struct serial_struct __user *); | |||
203 | 203 | ||
204 | static ssize_t ip2_ipl_read(struct file *, char __user *, size_t, loff_t *); | 204 | static ssize_t ip2_ipl_read(struct file *, char __user *, size_t, loff_t *); |
205 | static ssize_t ip2_ipl_write(struct file *, const char __user *, size_t, loff_t *); | 205 | static ssize_t ip2_ipl_write(struct file *, const char __user *, size_t, loff_t *); |
206 | static int ip2_ipl_ioctl(struct inode *, struct file *, UINT, ULONG); | 206 | static long ip2_ipl_ioctl(struct file *, UINT, ULONG); |
207 | static int ip2_ipl_open(struct inode *, struct file *); | 207 | static int ip2_ipl_open(struct inode *, struct file *); |
208 | 208 | ||
209 | static int DumpTraceBuffer(char __user *, int); | 209 | static int DumpTraceBuffer(char __user *, int); |
@@ -236,7 +236,7 @@ static const struct file_operations ip2_ipl = { | |||
236 | .owner = THIS_MODULE, | 236 | .owner = THIS_MODULE, |
237 | .read = ip2_ipl_read, | 237 | .read = ip2_ipl_read, |
238 | .write = ip2_ipl_write, | 238 | .write = ip2_ipl_write, |
239 | .ioctl = ip2_ipl_ioctl, | 239 | .unlocked_ioctl = ip2_ipl_ioctl, |
240 | .open = ip2_ipl_open, | 240 | .open = ip2_ipl_open, |
241 | }; | 241 | }; |
242 | 242 | ||
@@ -2845,10 +2845,10 @@ ip2_ipl_write(struct file *pFile, const char __user *pData, size_t count, loff_t | |||
2845 | /* */ | 2845 | /* */ |
2846 | /* */ | 2846 | /* */ |
2847 | /******************************************************************************/ | 2847 | /******************************************************************************/ |
2848 | static int | 2848 | static long |
2849 | ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) | 2849 | ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg ) |
2850 | { | 2850 | { |
2851 | unsigned int iplminor = iminor(pInode); | 2851 | unsigned int iplminor = iminor(pFile->f_path.dentry->d_inode); |
2852 | int rc = 0; | 2852 | int rc = 0; |
2853 | void __user *argp = (void __user *)arg; | 2853 | void __user *argp = (void __user *)arg; |
2854 | ULONG __user *pIndex = argp; | 2854 | ULONG __user *pIndex = argp; |
@@ -2859,6 +2859,8 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) | |||
2859 | printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg ); | 2859 | printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg ); |
2860 | #endif | 2860 | #endif |
2861 | 2861 | ||
2862 | lock_kernel(); | ||
2863 | |||
2862 | switch ( iplminor ) { | 2864 | switch ( iplminor ) { |
2863 | case 0: // IPL device | 2865 | case 0: // IPL device |
2864 | rc = -EINVAL; | 2866 | rc = -EINVAL; |
@@ -2919,6 +2921,7 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) | |||
2919 | rc = -ENODEV; | 2921 | rc = -ENODEV; |
2920 | break; | 2922 | break; |
2921 | } | 2923 | } |
2924 | unlock_kernel(); | ||
2922 | return rc; | 2925 | return rc; |
2923 | } | 2926 | } |
2924 | 2927 | ||
diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c deleted file mode 100644 index 1c29b20e4f4c..000000000000 --- a/drivers/char/lcd.c +++ /dev/null | |||
@@ -1,516 +0,0 @@ | |||
1 | /* | ||
2 | * LCD, LED and Button interface for Cobalt | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1996, 1997 by Andrew Bose | ||
9 | * | ||
10 | * Linux kernel version history: | ||
11 | * March 2001: Ported from 2.0.34 by Liam Davies | ||
12 | * | ||
13 | */ | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/errno.h> | ||
16 | #include <linux/miscdevice.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/ioport.h> | ||
19 | #include <linux/fcntl.h> | ||
20 | #include <linux/mc146818rtc.h> | ||
21 | #include <linux/netdevice.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/smp_lock.h> | ||
24 | #include <linux/delay.h> | ||
25 | |||
26 | #include <asm/io.h> | ||
27 | #include <asm/uaccess.h> | ||
28 | #include <asm/system.h> | ||
29 | |||
30 | #include "lcd.h" | ||
31 | |||
32 | static int lcd_ioctl(struct inode *inode, struct file *file, | ||
33 | unsigned int cmd, unsigned long arg); | ||
34 | |||
35 | static unsigned int lcd_present = 1; | ||
36 | |||
37 | /* used in arch/mips/cobalt/reset.c */ | ||
38 | int led_state = 0; | ||
39 | |||
40 | #if defined(CONFIG_TULIP) && 0 | ||
41 | |||
42 | #define MAX_INTERFACES 8 | ||
43 | static linkcheck_func_t linkcheck_callbacks[MAX_INTERFACES]; | ||
44 | static void *linkcheck_cookies[MAX_INTERFACES]; | ||
45 | |||
46 | int lcd_register_linkcheck_func(int iface_num, void *func, void *cookie) | ||
47 | { | ||
48 | if (iface_num < 0 || | ||
49 | iface_num >= MAX_INTERFACES || | ||
50 | linkcheck_callbacks[iface_num] != NULL) | ||
51 | return -1; | ||
52 | linkcheck_callbacks[iface_num] = (linkcheck_func_t) func; | ||
53 | linkcheck_cookies[iface_num] = cookie; | ||
54 | return 0; | ||
55 | } | ||
56 | #endif | ||
57 | |||
58 | static int lcd_ioctl(struct inode *inode, struct file *file, | ||
59 | unsigned int cmd, unsigned long arg) | ||
60 | { | ||
61 | struct lcd_display button_display; | ||
62 | unsigned long address, a; | ||
63 | |||
64 | switch (cmd) { | ||
65 | case LCD_On: | ||
66 | udelay(150); | ||
67 | BusyCheck(); | ||
68 | LCDWriteInst(0x0F); | ||
69 | break; | ||
70 | |||
71 | case LCD_Off: | ||
72 | udelay(150); | ||
73 | BusyCheck(); | ||
74 | LCDWriteInst(0x08); | ||
75 | break; | ||
76 | |||
77 | case LCD_Reset: | ||
78 | udelay(150); | ||
79 | LCDWriteInst(0x3F); | ||
80 | udelay(150); | ||
81 | LCDWriteInst(0x3F); | ||
82 | udelay(150); | ||
83 | LCDWriteInst(0x3F); | ||
84 | udelay(150); | ||
85 | LCDWriteInst(0x3F); | ||
86 | udelay(150); | ||
87 | LCDWriteInst(0x01); | ||
88 | udelay(150); | ||
89 | LCDWriteInst(0x06); | ||
90 | break; | ||
91 | |||
92 | case LCD_Clear: | ||
93 | udelay(150); | ||
94 | BusyCheck(); | ||
95 | LCDWriteInst(0x01); | ||
96 | break; | ||
97 | |||
98 | case LCD_Cursor_Left: | ||
99 | udelay(150); | ||
100 | BusyCheck(); | ||
101 | LCDWriteInst(0x10); | ||
102 | break; | ||
103 | |||
104 | case LCD_Cursor_Right: | ||
105 | udelay(150); | ||
106 | BusyCheck(); | ||
107 | LCDWriteInst(0x14); | ||
108 | break; | ||
109 | |||
110 | case LCD_Cursor_Off: | ||
111 | udelay(150); | ||
112 | BusyCheck(); | ||
113 | LCDWriteInst(0x0C); | ||
114 | break; | ||
115 | |||
116 | case LCD_Cursor_On: | ||
117 | udelay(150); | ||
118 | BusyCheck(); | ||
119 | LCDWriteInst(0x0F); | ||
120 | break; | ||
121 | |||
122 | case LCD_Blink_Off: | ||
123 | udelay(150); | ||
124 | BusyCheck(); | ||
125 | LCDWriteInst(0x0E); | ||
126 | break; | ||
127 | |||
128 | case LCD_Get_Cursor_Pos:{ | ||
129 | struct lcd_display display; | ||
130 | |||
131 | udelay(150); | ||
132 | BusyCheck(); | ||
133 | display.cursor_address = (LCDReadInst); | ||
134 | display.cursor_address = | ||
135 | (display.cursor_address & 0x07F); | ||
136 | if (copy_to_user | ||
137 | ((struct lcd_display *) arg, &display, | ||
138 | sizeof(struct lcd_display))) | ||
139 | return -EFAULT; | ||
140 | |||
141 | break; | ||
142 | } | ||
143 | |||
144 | |||
145 | case LCD_Set_Cursor_Pos:{ | ||
146 | struct lcd_display display; | ||
147 | |||
148 | if (copy_from_user | ||
149 | (&display, (struct lcd_display *) arg, | ||
150 | sizeof(struct lcd_display))) | ||
151 | return -EFAULT; | ||
152 | |||
153 | a = (display.cursor_address | kLCD_Addr); | ||
154 | |||
155 | udelay(150); | ||
156 | BusyCheck(); | ||
157 | LCDWriteInst(a); | ||
158 | |||
159 | break; | ||
160 | } | ||
161 | |||
162 | case LCD_Get_Cursor:{ | ||
163 | struct lcd_display display; | ||
164 | |||
165 | udelay(150); | ||
166 | BusyCheck(); | ||
167 | display.character = LCDReadData; | ||
168 | |||
169 | if (copy_to_user | ||
170 | ((struct lcd_display *) arg, &display, | ||
171 | sizeof(struct lcd_display))) | ||
172 | return -EFAULT; | ||
173 | udelay(150); | ||
174 | BusyCheck(); | ||
175 | LCDWriteInst(0x10); | ||
176 | |||
177 | break; | ||
178 | } | ||
179 | |||
180 | case LCD_Set_Cursor:{ | ||
181 | struct lcd_display display; | ||
182 | |||
183 | if (copy_from_user | ||
184 | (&display, (struct lcd_display *) arg, | ||
185 | sizeof(struct lcd_display))) | ||
186 | return -EFAULT; | ||
187 | |||
188 | udelay(150); | ||
189 | BusyCheck(); | ||
190 | LCDWriteData(display.character); | ||
191 | udelay(150); | ||
192 | BusyCheck(); | ||
193 | LCDWriteInst(0x10); | ||
194 | |||
195 | break; | ||
196 | } | ||
197 | |||
198 | |||
199 | case LCD_Disp_Left: | ||
200 | udelay(150); | ||
201 | BusyCheck(); | ||
202 | LCDWriteInst(0x18); | ||
203 | break; | ||
204 | |||
205 | case LCD_Disp_Right: | ||
206 | udelay(150); | ||
207 | BusyCheck(); | ||
208 | LCDWriteInst(0x1C); | ||
209 | break; | ||
210 | |||
211 | case LCD_Home: | ||
212 | udelay(150); | ||
213 | BusyCheck(); | ||
214 | LCDWriteInst(0x02); | ||
215 | break; | ||
216 | |||
217 | case LCD_Write:{ | ||
218 | struct lcd_display display; | ||
219 | unsigned int index; | ||
220 | |||
221 | |||
222 | if (copy_from_user | ||
223 | (&display, (struct lcd_display *) arg, | ||
224 | sizeof(struct lcd_display))) | ||
225 | return -EFAULT; | ||
226 | |||
227 | udelay(150); | ||
228 | BusyCheck(); | ||
229 | LCDWriteInst(0x80); | ||
230 | udelay(150); | ||
231 | BusyCheck(); | ||
232 | |||
233 | for (index = 0; index < (display.size1); index++) { | ||
234 | udelay(150); | ||
235 | BusyCheck(); | ||
236 | LCDWriteData(display.line1[index]); | ||
237 | BusyCheck(); | ||
238 | } | ||
239 | |||
240 | udelay(150); | ||
241 | BusyCheck(); | ||
242 | LCDWriteInst(0xC0); | ||
243 | udelay(150); | ||
244 | BusyCheck(); | ||
245 | for (index = 0; index < (display.size2); index++) { | ||
246 | udelay(150); | ||
247 | BusyCheck(); | ||
248 | LCDWriteData(display.line2[index]); | ||
249 | } | ||
250 | |||
251 | break; | ||
252 | } | ||
253 | |||
254 | case LCD_Read:{ | ||
255 | struct lcd_display display; | ||
256 | |||
257 | BusyCheck(); | ||
258 | for (address = kDD_R00; address <= kDD_R01; | ||
259 | address++) { | ||
260 | a = (address | kLCD_Addr); | ||
261 | |||
262 | udelay(150); | ||
263 | BusyCheck(); | ||
264 | LCDWriteInst(a); | ||
265 | udelay(150); | ||
266 | BusyCheck(); | ||
267 | display.line1[address] = LCDReadData; | ||
268 | } | ||
269 | |||
270 | display.line1[0x27] = '\0'; | ||
271 | |||
272 | for (address = kDD_R10; address <= kDD_R11; | ||
273 | address++) { | ||
274 | a = (address | kLCD_Addr); | ||
275 | |||
276 | udelay(150); | ||
277 | BusyCheck(); | ||
278 | LCDWriteInst(a); | ||
279 | |||
280 | udelay(150); | ||
281 | BusyCheck(); | ||
282 | display.line2[address - 0x40] = | ||
283 | LCDReadData; | ||
284 | } | ||
285 | |||
286 | display.line2[0x27] = '\0'; | ||
287 | |||
288 | if (copy_to_user | ||
289 | ((struct lcd_display *) arg, &display, | ||
290 | sizeof(struct lcd_display))) | ||
291 | return -EFAULT; | ||
292 | break; | ||
293 | } | ||
294 | |||
295 | // set all GPIO leds to led_display.leds | ||
296 | |||
297 | case LED_Set:{ | ||
298 | struct lcd_display led_display; | ||
299 | |||
300 | |||
301 | if (copy_from_user | ||
302 | (&led_display, (struct lcd_display *) arg, | ||
303 | sizeof(struct lcd_display))) | ||
304 | return -EFAULT; | ||
305 | |||
306 | led_state = led_display.leds; | ||
307 | LEDSet(led_state); | ||
308 | |||
309 | break; | ||
310 | } | ||
311 | |||
312 | |||
313 | // set only bit led_display.leds | ||
314 | |||
315 | case LED_Bit_Set:{ | ||
316 | unsigned int i; | ||
317 | int bit = 1; | ||
318 | struct lcd_display led_display; | ||
319 | |||
320 | |||
321 | if (copy_from_user | ||
322 | (&led_display, (struct lcd_display *) arg, | ||
323 | sizeof(struct lcd_display))) | ||
324 | return -EFAULT; | ||
325 | |||
326 | for (i = 0; i < (int) led_display.leds; i++) { | ||
327 | bit = 2 * bit; | ||
328 | } | ||
329 | |||
330 | led_state = led_state | bit; | ||
331 | LEDSet(led_state); | ||
332 | break; | ||
333 | } | ||
334 | |||
335 | // clear only bit led_display.leds | ||
336 | |||
337 | case LED_Bit_Clear:{ | ||
338 | unsigned int i; | ||
339 | int bit = 1; | ||
340 | struct lcd_display led_display; | ||
341 | |||
342 | |||
343 | if (copy_from_user | ||
344 | (&led_display, (struct lcd_display *) arg, | ||
345 | sizeof(struct lcd_display))) | ||
346 | return -EFAULT; | ||
347 | |||
348 | for (i = 0; i < (int) led_display.leds; i++) { | ||
349 | bit = 2 * bit; | ||
350 | } | ||
351 | |||
352 | led_state = led_state & ~bit; | ||
353 | LEDSet(led_state); | ||
354 | break; | ||
355 | } | ||
356 | |||
357 | |||
358 | case BUTTON_Read:{ | ||
359 | button_display.buttons = GPIRead; | ||
360 | if (copy_to_user | ||
361 | ((struct lcd_display *) arg, &button_display, | ||
362 | sizeof(struct lcd_display))) | ||
363 | return -EFAULT; | ||
364 | break; | ||
365 | } | ||
366 | |||
367 | case LINK_Check:{ | ||
368 | button_display.buttons = | ||
369 | *((volatile unsigned long *) (0xB0100060)); | ||
370 | if (copy_to_user | ||
371 | ((struct lcd_display *) arg, &button_display, | ||
372 | sizeof(struct lcd_display))) | ||
373 | return -EFAULT; | ||
374 | break; | ||
375 | } | ||
376 | |||
377 | case LINK_Check_2:{ | ||
378 | int iface_num; | ||
379 | |||
380 | /* panel-utils should pass in the desired interface status is wanted for | ||
381 | * in "buttons" of the structure. We will set this to non-zero if the | ||
382 | * link is in fact up for the requested interface. --DaveM | ||
383 | */ | ||
384 | if (copy_from_user | ||
385 | (&button_display, (struct lcd_display *) arg, | ||
386 | sizeof(button_display))) | ||
387 | return -EFAULT; | ||
388 | iface_num = button_display.buttons; | ||
389 | #if defined(CONFIG_TULIP) && 0 | ||
390 | if (iface_num >= 0 && | ||
391 | iface_num < MAX_INTERFACES && | ||
392 | linkcheck_callbacks[iface_num] != NULL) { | ||
393 | button_display.buttons = | ||
394 | linkcheck_callbacks[iface_num] | ||
395 | (linkcheck_cookies[iface_num]); | ||
396 | } else | ||
397 | #endif | ||
398 | button_display.buttons = 0; | ||
399 | |||
400 | if (__copy_to_user | ||
401 | ((struct lcd_display *) arg, &button_display, | ||
402 | sizeof(struct lcd_display))) | ||
403 | return -EFAULT; | ||
404 | break; | ||
405 | } | ||
406 | |||
407 | default: | ||
408 | return -EINVAL; | ||
409 | |||
410 | } | ||
411 | |||
412 | return 0; | ||
413 | |||
414 | } | ||
415 | |||
416 | static int lcd_open(struct inode *inode, struct file *file) | ||
417 | { | ||
418 | cycle_kernel_lock(); | ||
419 | |||
420 | if (!lcd_present) | ||
421 | return -ENXIO; | ||
422 | else | ||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | /* Only RESET or NEXT counts as button pressed */ | ||
427 | |||
428 | static inline int button_pressed(void) | ||
429 | { | ||
430 | unsigned long buttons = GPIRead; | ||
431 | |||
432 | if ((buttons == BUTTON_Next) || (buttons == BUTTON_Next_B) | ||
433 | || (buttons == BUTTON_Reset_B)) | ||
434 | return buttons; | ||
435 | return 0; | ||
436 | } | ||
437 | |||
438 | /* LED daemon sits on this and we wake him up once a key is pressed. */ | ||
439 | |||
440 | static int lcd_waiters = 0; | ||
441 | |||
442 | static ssize_t lcd_read(struct file *file, char *buf, | ||
443 | size_t count, loff_t *ofs) | ||
444 | { | ||
445 | long buttons_now; | ||
446 | |||
447 | if (lcd_waiters > 0) | ||
448 | return -EINVAL; | ||
449 | |||
450 | lcd_waiters++; | ||
451 | while (((buttons_now = (long) button_pressed()) == 0) && | ||
452 | !(signal_pending(current))) { | ||
453 | msleep_interruptible(2000); | ||
454 | } | ||
455 | lcd_waiters--; | ||
456 | |||
457 | if (signal_pending(current)) | ||
458 | return -ERESTARTSYS; | ||
459 | return buttons_now; | ||
460 | } | ||
461 | |||
462 | /* | ||
463 | * The various file operations we support. | ||
464 | */ | ||
465 | |||
466 | static const struct file_operations lcd_fops = { | ||
467 | .read = lcd_read, | ||
468 | .ioctl = lcd_ioctl, | ||
469 | .open = lcd_open, | ||
470 | }; | ||
471 | |||
472 | static struct miscdevice lcd_dev = { | ||
473 | MISC_DYNAMIC_MINOR, | ||
474 | "lcd", | ||
475 | &lcd_fops | ||
476 | }; | ||
477 | |||
478 | static int lcd_init(void) | ||
479 | { | ||
480 | int ret; | ||
481 | unsigned long data; | ||
482 | |||
483 | pr_info("%s\n", LCD_DRIVER); | ||
484 | ret = misc_register(&lcd_dev); | ||
485 | if (ret) { | ||
486 | printk(KERN_WARNING LCD "Unable to register misc device.\n"); | ||
487 | return ret; | ||
488 | } | ||
489 | |||
490 | /* Check region? Naaah! Just snarf it up. */ | ||
491 | /* request_region(RTC_PORT(0), RTC_IO_EXTENT, "lcd");*/ | ||
492 | |||
493 | udelay(150); | ||
494 | data = LCDReadData; | ||
495 | if ((data & 0x000000FF) == (0x00)) { | ||
496 | lcd_present = 0; | ||
497 | pr_info(LCD "LCD Not Present\n"); | ||
498 | } else { | ||
499 | lcd_present = 1; | ||
500 | WRITE_GAL(kGal_DevBank2PReg, kGal_DevBank2Cfg); | ||
501 | WRITE_GAL(kGal_DevBank3PReg, kGal_DevBank3Cfg); | ||
502 | } | ||
503 | |||
504 | return 0; | ||
505 | } | ||
506 | |||
507 | static void __exit lcd_exit(void) | ||
508 | { | ||
509 | misc_deregister(&lcd_dev); | ||
510 | } | ||
511 | |||
512 | module_init(lcd_init); | ||
513 | module_exit(lcd_exit); | ||
514 | |||
515 | MODULE_AUTHOR("Andrew Bose"); | ||
516 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/char/lcd.h b/drivers/char/lcd.h deleted file mode 100644 index 290b3ff23b03..000000000000 --- a/drivers/char/lcd.h +++ /dev/null | |||
@@ -1,154 +0,0 @@ | |||
1 | /* | ||
2 | * LED, LCD and Button panel driver for Cobalt | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1996, 1997 by Andrew Bose | ||
9 | * | ||
10 | * Linux kernel version history: | ||
11 | * March 2001: Ported from 2.0.34 by Liam Davies | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | // function headers | ||
16 | |||
17 | #define LCD_CHARS_PER_LINE 40 | ||
18 | #define MAX_IDLE_TIME 120 | ||
19 | |||
20 | struct lcd_display { | ||
21 | unsigned buttons; | ||
22 | int size1; | ||
23 | int size2; | ||
24 | unsigned char line1[LCD_CHARS_PER_LINE]; | ||
25 | unsigned char line2[LCD_CHARS_PER_LINE]; | ||
26 | unsigned char cursor_address; | ||
27 | unsigned char character; | ||
28 | unsigned char leds; | ||
29 | unsigned char *RomImage; | ||
30 | }; | ||
31 | |||
32 | |||
33 | |||
34 | #define LCD_DRIVER "Cobalt LCD Driver v2.10" | ||
35 | |||
36 | #define LCD "lcd: " | ||
37 | |||
38 | #define kLCD_IR 0x0F000000 | ||
39 | #define kLCD_DR 0x0F000010 | ||
40 | #define kGPI 0x0D000000 | ||
41 | #define kLED 0x0C000000 | ||
42 | |||
43 | #define kDD_R00 0x00 | ||
44 | #define kDD_R01 0x27 | ||
45 | #define kDD_R10 0x40 | ||
46 | #define kDD_R11 0x67 | ||
47 | |||
48 | #define kLCD_Addr 0x00000080 | ||
49 | |||
50 | #define LCDTimeoutValue 0xfff | ||
51 | |||
52 | |||
53 | // Macros | ||
54 | |||
55 | #define LCDWriteData(x) outl((x << 24), kLCD_DR) | ||
56 | #define LCDWriteInst(x) outl((x << 24), kLCD_IR) | ||
57 | |||
58 | #define LCDReadData (inl(kLCD_DR) >> 24) | ||
59 | #define LCDReadInst (inl(kLCD_IR) >> 24) | ||
60 | |||
61 | #define GPIRead (inl(kGPI) >> 24) | ||
62 | |||
63 | #define LEDSet(x) outb((char)x, kLED) | ||
64 | |||
65 | #define WRITE_GAL(x,y) outl(y, 0x04000000 | (x)) | ||
66 | #define BusyCheck() while ((LCDReadInst & 0x80) == 0x80) | ||
67 | |||
68 | |||
69 | |||
70 | /* | ||
71 | * Function command codes for io_ctl. | ||
72 | */ | ||
73 | #define LCD_On 1 | ||
74 | #define LCD_Off 2 | ||
75 | #define LCD_Clear 3 | ||
76 | #define LCD_Reset 4 | ||
77 | #define LCD_Cursor_Left 5 | ||
78 | #define LCD_Cursor_Right 6 | ||
79 | #define LCD_Disp_Left 7 | ||
80 | #define LCD_Disp_Right 8 | ||
81 | #define LCD_Get_Cursor 9 | ||
82 | #define LCD_Set_Cursor 10 | ||
83 | #define LCD_Home 11 | ||
84 | #define LCD_Read 12 | ||
85 | #define LCD_Write 13 | ||
86 | #define LCD_Cursor_Off 14 | ||
87 | #define LCD_Cursor_On 15 | ||
88 | #define LCD_Get_Cursor_Pos 16 | ||
89 | #define LCD_Set_Cursor_Pos 17 | ||
90 | #define LCD_Blink_Off 18 | ||
91 | |||
92 | #define LED_Set 40 | ||
93 | #define LED_Bit_Set 41 | ||
94 | #define LED_Bit_Clear 42 | ||
95 | |||
96 | |||
97 | // Button defs | ||
98 | #define BUTTON_Read 50 | ||
99 | |||
100 | |||
101 | // Ethernet LINK check hackaroo | ||
102 | #define LINK_Check 90 | ||
103 | #define LINK_Check_2 91 | ||
104 | |||
105 | // Button patterns _B - single layer lcd boards | ||
106 | |||
107 | #define BUTTON_NONE 0x3F | ||
108 | #define BUTTON_NONE_B 0xFE | ||
109 | |||
110 | #define BUTTON_Left 0x3B | ||
111 | #define BUTTON_Left_B 0xFA | ||
112 | |||
113 | #define BUTTON_Right 0x37 | ||
114 | #define BUTTON_Right_B 0xDE | ||
115 | |||
116 | #define BUTTON_Up 0x2F | ||
117 | #define BUTTON_Up_B 0xF6 | ||
118 | |||
119 | #define BUTTON_Down 0x1F | ||
120 | #define BUTTON_Down_B 0xEE | ||
121 | |||
122 | #define BUTTON_Next 0x3D | ||
123 | #define BUTTON_Next_B 0x7E | ||
124 | |||
125 | #define BUTTON_Enter 0x3E | ||
126 | #define BUTTON_Enter_B 0xBE | ||
127 | |||
128 | #define BUTTON_Reset_B 0xFC | ||
129 | |||
130 | |||
131 | // debounce constants | ||
132 | |||
133 | #define BUTTON_SENSE 160000 | ||
134 | #define BUTTON_DEBOUNCE 5000 | ||
135 | |||
136 | |||
137 | // Galileo register stuff | ||
138 | |||
139 | #define kGal_DevBank2Cfg 0x1466DB33 | ||
140 | #define kGal_DevBank2PReg 0x464 | ||
141 | #define kGal_DevBank3Cfg 0x146FDFFB | ||
142 | #define kGal_DevBank3PReg 0x468 | ||
143 | |||
144 | // Network | ||
145 | |||
146 | #define kIPADDR 1 | ||
147 | #define kNETMASK 2 | ||
148 | #define kGATEWAY 3 | ||
149 | #define kDNS 4 | ||
150 | |||
151 | #define kClassA 5 | ||
152 | #define kClassB 6 | ||
153 | #define kClassC 7 | ||
154 | |||
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index c2dba82eb5f7..672b08e694d0 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -327,7 +327,10 @@ static void mmap_mem_close(struct vm_area_struct *vma) | |||
327 | 327 | ||
328 | static struct vm_operations_struct mmap_mem_ops = { | 328 | static struct vm_operations_struct mmap_mem_ops = { |
329 | .open = mmap_mem_open, | 329 | .open = mmap_mem_open, |
330 | .close = mmap_mem_close | 330 | .close = mmap_mem_close, |
331 | #ifdef CONFIG_HAVE_IOREMAP_PROT | ||
332 | .access = generic_access_phys | ||
333 | #endif | ||
331 | }; | 334 | }; |
332 | 335 | ||
333 | static int mmap_mem(struct file * file, struct vm_area_struct * vma) | 336 | static int mmap_mem(struct file * file, struct vm_area_struct * vma) |
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c index fe2a95b5d3c0..30f095a8c2d4 100644 --- a/drivers/char/mspec.c +++ b/drivers/char/mspec.c | |||
@@ -193,25 +193,23 @@ mspec_close(struct vm_area_struct *vma) | |||
193 | } | 193 | } |
194 | 194 | ||
195 | /* | 195 | /* |
196 | * mspec_nopfn | 196 | * mspec_fault |
197 | * | 197 | * |
198 | * Creates a mspec page and maps it to user space. | 198 | * Creates a mspec page and maps it to user space. |
199 | */ | 199 | */ |
200 | static unsigned long | 200 | static int |
201 | mspec_nopfn(struct vm_area_struct *vma, unsigned long address) | 201 | mspec_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
202 | { | 202 | { |
203 | unsigned long paddr, maddr; | 203 | unsigned long paddr, maddr; |
204 | unsigned long pfn; | 204 | unsigned long pfn; |
205 | int index; | 205 | pgoff_t index = vmf->pgoff; |
206 | struct vma_data *vdata = vma->vm_private_data; | 206 | struct vma_data *vdata = vma->vm_private_data; |
207 | 207 | ||
208 | BUG_ON(address < vdata->vm_start || address >= vdata->vm_end); | ||
209 | index = (address - vdata->vm_start) >> PAGE_SHIFT; | ||
210 | maddr = (volatile unsigned long) vdata->maddr[index]; | 208 | maddr = (volatile unsigned long) vdata->maddr[index]; |
211 | if (maddr == 0) { | 209 | if (maddr == 0) { |
212 | maddr = uncached_alloc_page(numa_node_id(), 1); | 210 | maddr = uncached_alloc_page(numa_node_id(), 1); |
213 | if (maddr == 0) | 211 | if (maddr == 0) |
214 | return NOPFN_OOM; | 212 | return VM_FAULT_OOM; |
215 | 213 | ||
216 | spin_lock(&vdata->lock); | 214 | spin_lock(&vdata->lock); |
217 | if (vdata->maddr[index] == 0) { | 215 | if (vdata->maddr[index] == 0) { |
@@ -231,13 +229,20 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address) | |||
231 | 229 | ||
232 | pfn = paddr >> PAGE_SHIFT; | 230 | pfn = paddr >> PAGE_SHIFT; |
233 | 231 | ||
234 | return pfn; | 232 | /* |
233 | * vm_insert_pfn can fail with -EBUSY, but in that case it will | ||
234 | * be because another thread has installed the pte first, so it | ||
235 | * is no problem. | ||
236 | */ | ||
237 | vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn); | ||
238 | |||
239 | return VM_FAULT_NOPAGE; | ||
235 | } | 240 | } |
236 | 241 | ||
237 | static struct vm_operations_struct mspec_vm_ops = { | 242 | static struct vm_operations_struct mspec_vm_ops = { |
238 | .open = mspec_open, | 243 | .open = mspec_open, |
239 | .close = mspec_close, | 244 | .close = mspec_close, |
240 | .nopfn = mspec_nopfn | 245 | .fault = mspec_fault, |
241 | }; | 246 | }; |
242 | 247 | ||
243 | /* | 248 | /* |
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c index 50243fcd87e8..4f8d67fed292 100644 --- a/drivers/char/mwave/mwavedd.c +++ b/drivers/char/mwave/mwavedd.c | |||
@@ -86,8 +86,8 @@ module_param(mwave_uart_io, int, 0); | |||
86 | 86 | ||
87 | static int mwave_open(struct inode *inode, struct file *file); | 87 | static int mwave_open(struct inode *inode, struct file *file); |
88 | static int mwave_close(struct inode *inode, struct file *file); | 88 | static int mwave_close(struct inode *inode, struct file *file); |
89 | static int mwave_ioctl(struct inode *inode, struct file *filp, | 89 | static long mwave_ioctl(struct file *filp, unsigned int iocmd, |
90 | unsigned int iocmd, unsigned long ioarg); | 90 | unsigned long ioarg); |
91 | 91 | ||
92 | MWAVE_DEVICE_DATA mwave_s_mdd; | 92 | MWAVE_DEVICE_DATA mwave_s_mdd; |
93 | 93 | ||
@@ -119,16 +119,16 @@ static int mwave_close(struct inode *inode, struct file *file) | |||
119 | return retval; | 119 | return retval; |
120 | } | 120 | } |
121 | 121 | ||
122 | static int mwave_ioctl(struct inode *inode, struct file *file, | 122 | static long mwave_ioctl(struct file *file, unsigned int iocmd, |
123 | unsigned int iocmd, unsigned long ioarg) | 123 | unsigned long ioarg) |
124 | { | 124 | { |
125 | unsigned int retval = 0; | 125 | unsigned int retval = 0; |
126 | pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; | 126 | pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; |
127 | void __user *arg = (void __user *)ioarg; | 127 | void __user *arg = (void __user *)ioarg; |
128 | 128 | ||
129 | PRINTK_5(TRACE_MWAVE, | 129 | PRINTK_4(TRACE_MWAVE, |
130 | "mwavedd::mwave_ioctl, entry inode %p file %p cmd %x arg %x\n", | 130 | "mwavedd::mwave_ioctl, entry file %p cmd %x arg %x\n", |
131 | inode, file, iocmd, (int) ioarg); | 131 | file, iocmd, (int) ioarg); |
132 | 132 | ||
133 | switch (iocmd) { | 133 | switch (iocmd) { |
134 | 134 | ||
@@ -136,7 +136,9 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
136 | PRINTK_1(TRACE_MWAVE, | 136 | PRINTK_1(TRACE_MWAVE, |
137 | "mwavedd::mwave_ioctl, IOCTL_MW_RESET" | 137 | "mwavedd::mwave_ioctl, IOCTL_MW_RESET" |
138 | " calling tp3780I_ResetDSP\n"); | 138 | " calling tp3780I_ResetDSP\n"); |
139 | lock_kernel(); | ||
139 | retval = tp3780I_ResetDSP(&pDrvData->rBDData); | 140 | retval = tp3780I_ResetDSP(&pDrvData->rBDData); |
141 | unlock_kernel(); | ||
140 | PRINTK_2(TRACE_MWAVE, | 142 | PRINTK_2(TRACE_MWAVE, |
141 | "mwavedd::mwave_ioctl, IOCTL_MW_RESET" | 143 | "mwavedd::mwave_ioctl, IOCTL_MW_RESET" |
142 | " retval %x from tp3780I_ResetDSP\n", | 144 | " retval %x from tp3780I_ResetDSP\n", |
@@ -147,7 +149,9 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
147 | PRINTK_1(TRACE_MWAVE, | 149 | PRINTK_1(TRACE_MWAVE, |
148 | "mwavedd::mwave_ioctl, IOCTL_MW_RUN" | 150 | "mwavedd::mwave_ioctl, IOCTL_MW_RUN" |
149 | " calling tp3780I_StartDSP\n"); | 151 | " calling tp3780I_StartDSP\n"); |
152 | lock_kernel(); | ||
150 | retval = tp3780I_StartDSP(&pDrvData->rBDData); | 153 | retval = tp3780I_StartDSP(&pDrvData->rBDData); |
154 | unlock_kernel(); | ||
151 | PRINTK_2(TRACE_MWAVE, | 155 | PRINTK_2(TRACE_MWAVE, |
152 | "mwavedd::mwave_ioctl, IOCTL_MW_RUN" | 156 | "mwavedd::mwave_ioctl, IOCTL_MW_RUN" |
153 | " retval %x from tp3780I_StartDSP\n", | 157 | " retval %x from tp3780I_StartDSP\n", |
@@ -161,8 +165,10 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
161 | "mwavedd::mwave_ioctl," | 165 | "mwavedd::mwave_ioctl," |
162 | " IOCTL_MW_DSP_ABILITIES calling" | 166 | " IOCTL_MW_DSP_ABILITIES calling" |
163 | " tp3780I_QueryAbilities\n"); | 167 | " tp3780I_QueryAbilities\n"); |
168 | lock_kernel(); | ||
164 | retval = tp3780I_QueryAbilities(&pDrvData->rBDData, | 169 | retval = tp3780I_QueryAbilities(&pDrvData->rBDData, |
165 | &rAbilities); | 170 | &rAbilities); |
171 | unlock_kernel(); | ||
166 | PRINTK_2(TRACE_MWAVE, | 172 | PRINTK_2(TRACE_MWAVE, |
167 | "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" | 173 | "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" |
168 | " retval %x from tp3780I_QueryAbilities\n", | 174 | " retval %x from tp3780I_QueryAbilities\n", |
@@ -193,11 +199,13 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
193 | "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," | 199 | "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," |
194 | " size %lx, ioarg %lx pusBuffer %p\n", | 200 | " size %lx, ioarg %lx pusBuffer %p\n", |
195 | rReadData.ulDataLength, ioarg, pusBuffer); | 201 | rReadData.ulDataLength, ioarg, pusBuffer); |
202 | lock_kernel(); | ||
196 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, | 203 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, |
197 | iocmd, | 204 | iocmd, |
198 | pusBuffer, | 205 | pusBuffer, |
199 | rReadData.ulDataLength, | 206 | rReadData.ulDataLength, |
200 | rReadData.usDspAddress); | 207 | rReadData.usDspAddress); |
208 | unlock_kernel(); | ||
201 | } | 209 | } |
202 | break; | 210 | break; |
203 | 211 | ||
@@ -215,10 +223,12 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
215 | " size %lx, ioarg %lx pusBuffer %p\n", | 223 | " size %lx, ioarg %lx pusBuffer %p\n", |
216 | rReadData.ulDataLength / 2, ioarg, | 224 | rReadData.ulDataLength / 2, ioarg, |
217 | pusBuffer); | 225 | pusBuffer); |
226 | lock_kernel(); | ||
218 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, | 227 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, |
219 | iocmd, pusBuffer, | 228 | iocmd, pusBuffer, |
220 | rReadData.ulDataLength / 2, | 229 | rReadData.ulDataLength / 2, |
221 | rReadData.usDspAddress); | 230 | rReadData.usDspAddress); |
231 | unlock_kernel(); | ||
222 | } | 232 | } |
223 | break; | 233 | break; |
224 | 234 | ||
@@ -236,10 +246,12 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
236 | " size %lx, ioarg %lx pusBuffer %p\n", | 246 | " size %lx, ioarg %lx pusBuffer %p\n", |
237 | rWriteData.ulDataLength, ioarg, | 247 | rWriteData.ulDataLength, ioarg, |
238 | pusBuffer); | 248 | pusBuffer); |
249 | lock_kernel(); | ||
239 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, | 250 | retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, |
240 | iocmd, pusBuffer, | 251 | iocmd, pusBuffer, |
241 | rWriteData.ulDataLength, | 252 | rWriteData.ulDataLength, |
242 | rWriteData.usDspAddress); | 253 | rWriteData.usDspAddress); |
254 | unlock_kernel(); | ||
243 | } | 255 | } |
244 | break; | 256 | break; |
245 | 257 | ||
@@ -257,10 +269,12 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
257 | " size %lx, ioarg %lx pusBuffer %p\n", | 269 | " size %lx, ioarg %lx pusBuffer %p\n", |
258 | rWriteData.ulDataLength, ioarg, | 270 | rWriteData.ulDataLength, ioarg, |
259 | pusBuffer); | 271 | pusBuffer); |
272 | lock_kernel(); | ||
260 | retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, | 273 | retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, |
261 | iocmd, pusBuffer, | 274 | iocmd, pusBuffer, |
262 | rWriteData.ulDataLength, | 275 | rWriteData.ulDataLength, |
263 | rWriteData.usDspAddress); | 276 | rWriteData.usDspAddress); |
277 | unlock_kernel(); | ||
264 | } | 278 | } |
265 | break; | 279 | break; |
266 | 280 | ||
@@ -281,8 +295,10 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
281 | ipcnum); | 295 | ipcnum); |
282 | return -EINVAL; | 296 | return -EINVAL; |
283 | } | 297 | } |
298 | lock_kernel(); | ||
284 | pDrvData->IPCs[ipcnum].bIsHere = FALSE; | 299 | pDrvData->IPCs[ipcnum].bIsHere = FALSE; |
285 | pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; | 300 | pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; |
301 | unlock_kernel(); | ||
286 | 302 | ||
287 | PRINTK_2(TRACE_MWAVE, | 303 | PRINTK_2(TRACE_MWAVE, |
288 | "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" | 304 | "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" |
@@ -307,6 +323,7 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
307 | return -EINVAL; | 323 | return -EINVAL; |
308 | } | 324 | } |
309 | 325 | ||
326 | lock_kernel(); | ||
310 | if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { | 327 | if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { |
311 | DECLARE_WAITQUEUE(wait, current); | 328 | DECLARE_WAITQUEUE(wait, current); |
312 | 329 | ||
@@ -347,6 +364,7 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
347 | " processing\n", | 364 | " processing\n", |
348 | ipcnum); | 365 | ipcnum); |
349 | } | 366 | } |
367 | unlock_kernel(); | ||
350 | } | 368 | } |
351 | break; | 369 | break; |
352 | 370 | ||
@@ -365,19 +383,18 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
365 | ipcnum); | 383 | ipcnum); |
366 | return -EINVAL; | 384 | return -EINVAL; |
367 | } | 385 | } |
386 | lock_kernel(); | ||
368 | if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { | 387 | if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { |
369 | pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; | 388 | pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; |
370 | if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { | 389 | if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { |
371 | wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); | 390 | wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); |
372 | } | 391 | } |
373 | } | 392 | } |
393 | unlock_kernel(); | ||
374 | } | 394 | } |
375 | break; | 395 | break; |
376 | 396 | ||
377 | default: | 397 | default: |
378 | PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_ioctl:" | ||
379 | " Error: Unrecognized iocmd %x\n", | ||
380 | iocmd); | ||
381 | return -ENOTTY; | 398 | return -ENOTTY; |
382 | break; | 399 | break; |
383 | } /* switch */ | 400 | } /* switch */ |
@@ -460,7 +477,7 @@ static const struct file_operations mwave_fops = { | |||
460 | .owner = THIS_MODULE, | 477 | .owner = THIS_MODULE, |
461 | .read = mwave_read, | 478 | .read = mwave_read, |
462 | .write = mwave_write, | 479 | .write = mwave_write, |
463 | .ioctl = mwave_ioctl, | 480 | .unlocked_ioctl = mwave_ioctl, |
464 | .open = mwave_open, | 481 | .open = mwave_open, |
465 | .release = mwave_close | 482 | .release = mwave_close |
466 | }; | 483 | }; |
diff --git a/drivers/char/mwave/mwavedd.h b/drivers/char/mwave/mwavedd.h index 8eca61e0a19c..7e0d530e2e07 100644 --- a/drivers/char/mwave/mwavedd.h +++ b/drivers/char/mwave/mwavedd.h | |||
@@ -147,4 +147,6 @@ typedef struct _MWAVE_DEVICE_DATA { | |||
147 | 147 | ||
148 | } MWAVE_DEVICE_DATA, *pMWAVE_DEVICE_DATA; | 148 | } MWAVE_DEVICE_DATA, *pMWAVE_DEVICE_DATA; |
149 | 149 | ||
150 | extern MWAVE_DEVICE_DATA mwave_s_mdd; | ||
151 | |||
150 | #endif | 152 | #endif |
diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c index f282976daaac..c68969708068 100644 --- a/drivers/char/mwave/tp3780i.c +++ b/drivers/char/mwave/tp3780i.c | |||
@@ -57,8 +57,6 @@ | |||
57 | #include "3780i.h" | 57 | #include "3780i.h" |
58 | #include "mwavepub.h" | 58 | #include "mwavepub.h" |
59 | 59 | ||
60 | extern MWAVE_DEVICE_DATA mwave_s_mdd; | ||
61 | |||
62 | static unsigned short s_ausThinkpadIrqToField[16] = | 60 | static unsigned short s_ausThinkpadIrqToField[16] = |
63 | { 0xFFFF, 0xFFFF, 0xFFFF, 0x0001, 0x0002, 0x0003, 0xFFFF, 0x0004, | 61 | { 0xFFFF, 0xFFFF, 0xFFFF, 0x0001, 0x0002, 0x0003, 0xFFFF, 0x0004, |
64 | 0xFFFF, 0xFFFF, 0x0005, 0x0006, 0xFFFF, 0xFFFF, 0xFFFF, 0x0007 }; | 62 | 0xFFFF, 0xFFFF, 0x0005, 0x0006, 0xFFFF, 0xFFFF, 0xFFFF, 0x0007 }; |
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 4c756bbba948..e30575e87648 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -16,7 +16,6 @@ | |||
16 | * Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox | 16 | * Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox |
17 | * <alan@redhat.com>. The original 1.8 code is available on www.moxa.com. | 17 | * <alan@redhat.com>. The original 1.8 code is available on www.moxa.com. |
18 | * - Fixed x86_64 cleanness | 18 | * - Fixed x86_64 cleanness |
19 | * - Fixed sleep with spinlock held in mxser_send_break | ||
20 | */ | 19 | */ |
21 | 20 | ||
22 | #include <linux/module.h> | 21 | #include <linux/module.h> |
@@ -49,18 +48,12 @@ | |||
49 | 48 | ||
50 | #define MXSER_VERSION "2.0.4" /* 1.12 */ | 49 | #define MXSER_VERSION "2.0.4" /* 1.12 */ |
51 | #define MXSERMAJOR 174 | 50 | #define MXSERMAJOR 174 |
52 | #define MXSERCUMAJOR 175 | ||
53 | 51 | ||
54 | #define MXSER_BOARDS 4 /* Max. boards */ | 52 | #define MXSER_BOARDS 4 /* Max. boards */ |
55 | #define MXSER_PORTS_PER_BOARD 8 /* Max. ports per board */ | 53 | #define MXSER_PORTS_PER_BOARD 8 /* Max. ports per board */ |
56 | #define MXSER_PORTS (MXSER_BOARDS * MXSER_PORTS_PER_BOARD) | 54 | #define MXSER_PORTS (MXSER_BOARDS * MXSER_PORTS_PER_BOARD) |
57 | #define MXSER_ISR_PASS_LIMIT 100 | 55 | #define MXSER_ISR_PASS_LIMIT 100 |
58 | 56 | ||
59 | #define MXSER_ERR_IOADDR -1 | ||
60 | #define MXSER_ERR_IRQ -2 | ||
61 | #define MXSER_ERR_IRQ_CONFLIT -3 | ||
62 | #define MXSER_ERR_VECTOR -4 | ||
63 | |||
64 | /*CheckIsMoxaMust return value*/ | 57 | /*CheckIsMoxaMust return value*/ |
65 | #define MOXA_OTHER_UART 0x00 | 58 | #define MOXA_OTHER_UART 0x00 |
66 | #define MOXA_MUST_MU150_HWID 0x01 | 59 | #define MOXA_MUST_MU150_HWID 0x01 |
@@ -179,14 +172,15 @@ static struct pci_device_id mxser_pcibrds[] = { | |||
179 | }; | 172 | }; |
180 | MODULE_DEVICE_TABLE(pci, mxser_pcibrds); | 173 | MODULE_DEVICE_TABLE(pci, mxser_pcibrds); |
181 | 174 | ||
182 | static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 }; | 175 | static unsigned long ioaddr[MXSER_BOARDS]; |
183 | static int ttymajor = MXSERMAJOR; | 176 | static int ttymajor = MXSERMAJOR; |
184 | 177 | ||
185 | /* Variables for insmod */ | 178 | /* Variables for insmod */ |
186 | 179 | ||
187 | MODULE_AUTHOR("Casper Yang"); | 180 | MODULE_AUTHOR("Casper Yang"); |
188 | MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver"); | 181 | MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver"); |
189 | module_param_array(ioaddr, int, NULL, 0); | 182 | module_param_array(ioaddr, ulong, NULL, 0); |
183 | MODULE_PARM_DESC(ioaddr, "ISA io addresses to look for a moxa board"); | ||
190 | module_param(ttymajor, int, 0); | 184 | module_param(ttymajor, int, 0); |
191 | MODULE_LICENSE("GPL"); | 185 | MODULE_LICENSE("GPL"); |
192 | 186 | ||
@@ -196,7 +190,6 @@ struct mxser_log { | |||
196 | unsigned long txcnt[MXSER_PORTS]; | 190 | unsigned long txcnt[MXSER_PORTS]; |
197 | }; | 191 | }; |
198 | 192 | ||
199 | |||
200 | struct mxser_mon { | 193 | struct mxser_mon { |
201 | unsigned long rxcnt; | 194 | unsigned long rxcnt; |
202 | unsigned long txcnt; | 195 | unsigned long txcnt; |
@@ -287,19 +280,9 @@ struct mxser_mstatus { | |||
287 | int dcd; | 280 | int dcd; |
288 | }; | 281 | }; |
289 | 282 | ||
290 | static struct mxser_mstatus GMStatus[MXSER_PORTS]; | ||
291 | |||
292 | static int mxserBoardCAP[MXSER_BOARDS] = { | ||
293 | 0, 0, 0, 0 | ||
294 | /* 0x180, 0x280, 0x200, 0x320 */ | ||
295 | }; | ||
296 | |||
297 | static struct mxser_board mxser_boards[MXSER_BOARDS]; | 283 | static struct mxser_board mxser_boards[MXSER_BOARDS]; |
298 | static struct tty_driver *mxvar_sdriver; | 284 | static struct tty_driver *mxvar_sdriver; |
299 | static struct mxser_log mxvar_log; | 285 | static struct mxser_log mxvar_log; |
300 | static int mxvar_diagflag; | ||
301 | static unsigned char mxser_msr[MXSER_PORTS + 1]; | ||
302 | static struct mxser_mon_ext mon_data_ext; | ||
303 | static int mxser_set_baud_method[MXSER_PORTS + 1]; | 286 | static int mxser_set_baud_method[MXSER_PORTS + 1]; |
304 | 287 | ||
305 | static void mxser_enable_must_enchance_mode(unsigned long baseio) | 288 | static void mxser_enable_must_enchance_mode(unsigned long baseio) |
@@ -543,6 +526,7 @@ static void process_txrx_fifo(struct mxser_port *info) | |||
543 | 526 | ||
544 | static unsigned char mxser_get_msr(int baseaddr, int mode, int port) | 527 | static unsigned char mxser_get_msr(int baseaddr, int mode, int port) |
545 | { | 528 | { |
529 | static unsigned char mxser_msr[MXSER_PORTS + 1]; | ||
546 | unsigned char status = 0; | 530 | unsigned char status = 0; |
547 | 531 | ||
548 | status = inb(baseaddr + UART_MSR); | 532 | status = inb(baseaddr + UART_MSR); |
@@ -1319,13 +1303,9 @@ static void mxser_flush_chars(struct tty_struct *tty) | |||
1319 | struct mxser_port *info = tty->driver_data; | 1303 | struct mxser_port *info = tty->driver_data; |
1320 | unsigned long flags; | 1304 | unsigned long flags; |
1321 | 1305 | ||
1322 | if (info->xmit_cnt <= 0 || | 1306 | if (info->xmit_cnt <= 0 || tty->stopped || !info->port.xmit_buf || |
1323 | tty->stopped || | 1307 | (tty->hw_stopped && info->type != PORT_16550A && |
1324 | !info->port.xmit_buf || | 1308 | !info->board->chip_flag)) |
1325 | (tty->hw_stopped && | ||
1326 | (info->type != PORT_16550A) && | ||
1327 | (!info->board->chip_flag) | ||
1328 | )) | ||
1329 | return; | 1309 | return; |
1330 | 1310 | ||
1331 | spin_lock_irqsave(&info->slock, flags); | 1311 | spin_lock_irqsave(&info->slock, flags); |
@@ -1343,9 +1323,7 @@ static int mxser_write_room(struct tty_struct *tty) | |||
1343 | int ret; | 1323 | int ret; |
1344 | 1324 | ||
1345 | ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; | 1325 | ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; |
1346 | if (ret < 0) | 1326 | return ret < 0 ? 0 : ret; |
1347 | ret = 0; | ||
1348 | return ret; | ||
1349 | } | 1327 | } |
1350 | 1328 | ||
1351 | static int mxser_chars_in_buffer(struct tty_struct *tty) | 1329 | static int mxser_chars_in_buffer(struct tty_struct *tty) |
@@ -1634,6 +1612,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) | |||
1634 | 1612 | ||
1635 | switch (cmd) { | 1613 | switch (cmd) { |
1636 | case MOXA_GET_MAJOR: | 1614 | case MOXA_GET_MAJOR: |
1615 | printk(KERN_WARNING "mxser: '%s' uses deprecated ioctl %x, fix " | ||
1616 | "your userspace\n", current->comm, cmd); | ||
1637 | return put_user(ttymajor, (int __user *)argp); | 1617 | return put_user(ttymajor, (int __user *)argp); |
1638 | 1618 | ||
1639 | case MOXA_CHKPORTENABLE: | 1619 | case MOXA_CHKPORTENABLE: |
@@ -1651,62 +1631,60 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) | |||
1651 | ret = -EFAULT; | 1631 | ret = -EFAULT; |
1652 | unlock_kernel(); | 1632 | unlock_kernel(); |
1653 | return ret; | 1633 | return ret; |
1654 | case MOXA_GETMSTATUS: | 1634 | case MOXA_GETMSTATUS: { |
1635 | struct mxser_mstatus ms, __user *msu = argp; | ||
1655 | lock_kernel(); | 1636 | lock_kernel(); |
1656 | for (i = 0; i < MXSER_BOARDS; i++) | 1637 | for (i = 0; i < MXSER_BOARDS; i++) |
1657 | for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) { | 1638 | for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) { |
1658 | port = &mxser_boards[i].ports[j]; | 1639 | port = &mxser_boards[i].ports[j]; |
1640 | memset(&ms, 0, sizeof(ms)); | ||
1659 | 1641 | ||
1660 | GMStatus[i].ri = 0; | 1642 | if (!port->ioaddr) |
1661 | if (!port->ioaddr) { | 1643 | goto copy; |
1662 | GMStatus[i].dcd = 0; | ||
1663 | GMStatus[i].dsr = 0; | ||
1664 | GMStatus[i].cts = 0; | ||
1665 | continue; | ||
1666 | } | ||
1667 | 1644 | ||
1668 | if (!port->port.tty || !port->port.tty->termios) | 1645 | if (!port->port.tty || !port->port.tty->termios) |
1669 | GMStatus[i].cflag = | 1646 | ms.cflag = port->normal_termios.c_cflag; |
1670 | port->normal_termios.c_cflag; | ||
1671 | else | 1647 | else |
1672 | GMStatus[i].cflag = | 1648 | ms.cflag = port->port.tty->termios->c_cflag; |
1673 | port->port.tty->termios->c_cflag; | ||
1674 | 1649 | ||
1675 | status = inb(port->ioaddr + UART_MSR); | 1650 | status = inb(port->ioaddr + UART_MSR); |
1676 | if (status & 0x80 /*UART_MSR_DCD */ ) | 1651 | if (status & UART_MSR_DCD) |
1677 | GMStatus[i].dcd = 1; | 1652 | ms.dcd = 1; |
1678 | else | 1653 | if (status & UART_MSR_DSR) |
1679 | GMStatus[i].dcd = 0; | 1654 | ms.dsr = 1; |
1680 | 1655 | if (status & UART_MSR_CTS) | |
1681 | if (status & 0x20 /*UART_MSR_DSR */ ) | 1656 | ms.cts = 1; |
1682 | GMStatus[i].dsr = 1; | 1657 | copy: |
1683 | else | 1658 | if (copy_to_user(msu, &ms, sizeof(ms))) { |
1684 | GMStatus[i].dsr = 0; | 1659 | unlock_kernel(); |
1685 | 1660 | return -EFAULT; | |
1686 | 1661 | } | |
1687 | if (status & 0x10 /*UART_MSR_CTS */ ) | 1662 | msu++; |
1688 | GMStatus[i].cts = 1; | ||
1689 | else | ||
1690 | GMStatus[i].cts = 0; | ||
1691 | } | 1663 | } |
1692 | unlock_kernel(); | 1664 | unlock_kernel(); |
1693 | if (copy_to_user(argp, GMStatus, | ||
1694 | sizeof(struct mxser_mstatus) * MXSER_PORTS)) | ||
1695 | return -EFAULT; | ||
1696 | return 0; | 1665 | return 0; |
1666 | } | ||
1697 | case MOXA_ASPP_MON_EXT: { | 1667 | case MOXA_ASPP_MON_EXT: { |
1698 | int p, shiftbit; | 1668 | struct mxser_mon_ext *me; /* it's 2k, stack unfriendly */ |
1699 | unsigned long opmode; | 1669 | unsigned int cflag, iflag, p; |
1700 | unsigned cflag, iflag; | 1670 | u8 opmode; |
1671 | |||
1672 | me = kzalloc(sizeof(*me), GFP_KERNEL); | ||
1673 | if (!me) | ||
1674 | return -ENOMEM; | ||
1701 | 1675 | ||
1702 | lock_kernel(); | 1676 | lock_kernel(); |
1703 | for (i = 0; i < MXSER_BOARDS; i++) { | 1677 | for (i = 0, p = 0; i < MXSER_BOARDS; i++) { |
1704 | for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) { | 1678 | for (j = 0; j < MXSER_PORTS_PER_BOARD; j++, p++) { |
1679 | if (p >= ARRAY_SIZE(me->rx_cnt)) { | ||
1680 | i = MXSER_BOARDS; | ||
1681 | break; | ||
1682 | } | ||
1705 | port = &mxser_boards[i].ports[j]; | 1683 | port = &mxser_boards[i].ports[j]; |
1706 | if (!port->ioaddr) | 1684 | if (!port->ioaddr) |
1707 | continue; | 1685 | continue; |
1708 | 1686 | ||
1709 | status = mxser_get_msr(port->ioaddr, 0, i); | 1687 | status = mxser_get_msr(port->ioaddr, 0, p); |
1710 | 1688 | ||
1711 | if (status & UART_MSR_TERI) | 1689 | if (status & UART_MSR_TERI) |
1712 | port->icount.rng++; | 1690 | port->icount.rng++; |
@@ -1718,16 +1696,13 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) | |||
1718 | port->icount.cts++; | 1696 | port->icount.cts++; |
1719 | 1697 | ||
1720 | port->mon_data.modem_status = status; | 1698 | port->mon_data.modem_status = status; |
1721 | mon_data_ext.rx_cnt[i] = port->mon_data.rxcnt; | 1699 | me->rx_cnt[p] = port->mon_data.rxcnt; |
1722 | mon_data_ext.tx_cnt[i] = port->mon_data.txcnt; | 1700 | me->tx_cnt[p] = port->mon_data.txcnt; |
1723 | mon_data_ext.up_rxcnt[i] = | 1701 | me->up_rxcnt[p] = port->mon_data.up_rxcnt; |
1724 | port->mon_data.up_rxcnt; | 1702 | me->up_txcnt[p] = port->mon_data.up_txcnt; |
1725 | mon_data_ext.up_txcnt[i] = | 1703 | me->modem_status[p] = |
1726 | port->mon_data.up_txcnt; | ||
1727 | mon_data_ext.modem_status[i] = | ||
1728 | port->mon_data.modem_status; | 1704 | port->mon_data.modem_status; |
1729 | mon_data_ext.baudrate[i] = | 1705 | me->baudrate[p] = tty_get_baud_rate(port->port.tty); |
1730 | tty_get_baud_rate(port->port.tty); | ||
1731 | 1706 | ||
1732 | if (!port->port.tty || !port->port.tty->termios) { | 1707 | if (!port->port.tty || !port->port.tty->termios) { |
1733 | cflag = port->normal_termios.c_cflag; | 1708 | cflag = port->normal_termios.c_cflag; |
@@ -1737,40 +1712,31 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) | |||
1737 | iflag = port->port.tty->termios->c_iflag; | 1712 | iflag = port->port.tty->termios->c_iflag; |
1738 | } | 1713 | } |
1739 | 1714 | ||
1740 | mon_data_ext.databits[i] = cflag & CSIZE; | 1715 | me->databits[p] = cflag & CSIZE; |
1741 | 1716 | me->stopbits[p] = cflag & CSTOPB; | |
1742 | mon_data_ext.stopbits[i] = cflag & CSTOPB; | 1717 | me->parity[p] = cflag & (PARENB | PARODD | |
1743 | 1718 | CMSPAR); | |
1744 | mon_data_ext.parity[i] = | ||
1745 | cflag & (PARENB | PARODD | CMSPAR); | ||
1746 | |||
1747 | mon_data_ext.flowctrl[i] = 0x00; | ||
1748 | 1719 | ||
1749 | if (cflag & CRTSCTS) | 1720 | if (cflag & CRTSCTS) |
1750 | mon_data_ext.flowctrl[i] |= 0x03; | 1721 | me->flowctrl[p] |= 0x03; |
1751 | 1722 | ||
1752 | if (iflag & (IXON | IXOFF)) | 1723 | if (iflag & (IXON | IXOFF)) |
1753 | mon_data_ext.flowctrl[i] |= 0x0C; | 1724 | me->flowctrl[p] |= 0x0C; |
1754 | 1725 | ||
1755 | if (port->type == PORT_16550A) | 1726 | if (port->type == PORT_16550A) |
1756 | mon_data_ext.fifo[i] = 1; | 1727 | me->fifo[p] = 1; |
1757 | else | ||
1758 | mon_data_ext.fifo[i] = 0; | ||
1759 | 1728 | ||
1760 | p = i % 4; | 1729 | opmode = inb(port->opmode_ioaddr) >> |
1761 | shiftbit = p * 2; | 1730 | ((p % 4) * 2); |
1762 | opmode = inb(port->opmode_ioaddr) >> shiftbit; | ||
1763 | opmode &= OP_MODE_MASK; | 1731 | opmode &= OP_MODE_MASK; |
1764 | 1732 | me->iftype[p] = opmode; | |
1765 | mon_data_ext.iftype[i] = opmode; | ||
1766 | |||
1767 | } | 1733 | } |
1768 | } | 1734 | } |
1769 | unlock_kernel(); | 1735 | unlock_kernel(); |
1770 | if (copy_to_user(argp, &mon_data_ext, | 1736 | if (copy_to_user(argp, me, sizeof(*me))) |
1771 | sizeof(mon_data_ext))) | 1737 | ret = -EFAULT; |
1772 | return -EFAULT; | 1738 | kfree(me); |
1773 | return 0; | 1739 | return ret; |
1774 | } | 1740 | } |
1775 | default: | 1741 | default: |
1776 | return -ENOIOCTLCMD; | 1742 | return -ENOIOCTLCMD; |
@@ -1804,7 +1770,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, | |||
1804 | { | 1770 | { |
1805 | struct mxser_port *info = tty->driver_data; | 1771 | struct mxser_port *info = tty->driver_data; |
1806 | struct async_icount cnow; | 1772 | struct async_icount cnow; |
1807 | struct serial_icounter_struct __user *p_cuser; | ||
1808 | unsigned long flags; | 1773 | unsigned long flags; |
1809 | void __user *argp = (void __user *)arg; | 1774 | void __user *argp = (void __user *)arg; |
1810 | int retval; | 1775 | int retval; |
@@ -1884,30 +1849,26 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, | |||
1884 | * NB: both 1->0 and 0->1 transitions are counted except for | 1849 | * NB: both 1->0 and 0->1 transitions are counted except for |
1885 | * RI where only 0->1 is counted. | 1850 | * RI where only 0->1 is counted. |
1886 | */ | 1851 | */ |
1887 | case TIOCGICOUNT: | 1852 | case TIOCGICOUNT: { |
1853 | struct serial_icounter_struct icnt = { 0 }; | ||
1888 | spin_lock_irqsave(&info->slock, flags); | 1854 | spin_lock_irqsave(&info->slock, flags); |
1889 | cnow = info->icount; | 1855 | cnow = info->icount; |
1890 | spin_unlock_irqrestore(&info->slock, flags); | 1856 | spin_unlock_irqrestore(&info->slock, flags); |
1891 | p_cuser = argp; | 1857 | |
1892 | if (put_user(cnow.frame, &p_cuser->frame)) | 1858 | icnt.frame = cnow.frame; |
1893 | return -EFAULT; | 1859 | icnt.brk = cnow.brk; |
1894 | if (put_user(cnow.brk, &p_cuser->brk)) | 1860 | icnt.overrun = cnow.overrun; |
1895 | return -EFAULT; | 1861 | icnt.buf_overrun = cnow.buf_overrun; |
1896 | if (put_user(cnow.overrun, &p_cuser->overrun)) | 1862 | icnt.parity = cnow.parity; |
1897 | return -EFAULT; | 1863 | icnt.rx = cnow.rx; |
1898 | if (put_user(cnow.buf_overrun, &p_cuser->buf_overrun)) | 1864 | icnt.tx = cnow.tx; |
1899 | return -EFAULT; | 1865 | icnt.cts = cnow.cts; |
1900 | if (put_user(cnow.parity, &p_cuser->parity)) | 1866 | icnt.dsr = cnow.dsr; |
1901 | return -EFAULT; | 1867 | icnt.rng = cnow.rng; |
1902 | if (put_user(cnow.rx, &p_cuser->rx)) | 1868 | icnt.dcd = cnow.dcd; |
1903 | return -EFAULT; | 1869 | |
1904 | if (put_user(cnow.tx, &p_cuser->tx)) | 1870 | return copy_to_user(argp, &icnt, sizeof(icnt)) ? -EFAULT : 0; |
1905 | return -EFAULT; | 1871 | } |
1906 | put_user(cnow.cts, &p_cuser->cts); | ||
1907 | put_user(cnow.dsr, &p_cuser->dsr); | ||
1908 | put_user(cnow.rng, &p_cuser->rng); | ||
1909 | put_user(cnow.dcd, &p_cuser->dcd); | ||
1910 | return 0; | ||
1911 | case MOXA_HighSpeedOn: | 1872 | case MOXA_HighSpeedOn: |
1912 | return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); | 1873 | return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); |
1913 | case MOXA_SDS_RSTICOUNTER: | 1874 | case MOXA_SDS_RSTICOUNTER: |
@@ -2503,7 +2464,8 @@ static int __devinit mxser_initbrd(struct mxser_board *brd, | |||
2503 | unsigned int i; | 2464 | unsigned int i; |
2504 | int retval; | 2465 | int retval; |
2505 | 2466 | ||
2506 | printk(KERN_INFO "max. baud rate = %d bps.\n", brd->ports[0].max_baud); | 2467 | printk(KERN_INFO "mxser: max. baud rate = %d bps\n", |
2468 | brd->ports[0].max_baud); | ||
2507 | 2469 | ||
2508 | for (i = 0; i < brd->info->nports; i++) { | 2470 | for (i = 0; i < brd->info->nports; i++) { |
2509 | info = &brd->ports[i]; | 2471 | info = &brd->ports[i]; |
@@ -2586,28 +2548,32 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) | |||
2586 | irq = regs[9] & 0xF000; | 2548 | irq = regs[9] & 0xF000; |
2587 | irq = irq | (irq >> 4); | 2549 | irq = irq | (irq >> 4); |
2588 | if (irq != (regs[9] & 0xFF00)) | 2550 | if (irq != (regs[9] & 0xFF00)) |
2589 | return MXSER_ERR_IRQ_CONFLIT; | 2551 | goto err_irqconflict; |
2590 | } else if (brd->info->nports == 4) { | 2552 | } else if (brd->info->nports == 4) { |
2591 | irq = regs[9] & 0xF000; | 2553 | irq = regs[9] & 0xF000; |
2592 | irq = irq | (irq >> 4); | 2554 | irq = irq | (irq >> 4); |
2593 | irq = irq | (irq >> 8); | 2555 | irq = irq | (irq >> 8); |
2594 | if (irq != regs[9]) | 2556 | if (irq != regs[9]) |
2595 | return MXSER_ERR_IRQ_CONFLIT; | 2557 | goto err_irqconflict; |
2596 | } else if (brd->info->nports == 8) { | 2558 | } else if (brd->info->nports == 8) { |
2597 | irq = regs[9] & 0xF000; | 2559 | irq = regs[9] & 0xF000; |
2598 | irq = irq | (irq >> 4); | 2560 | irq = irq | (irq >> 4); |
2599 | irq = irq | (irq >> 8); | 2561 | irq = irq | (irq >> 8); |
2600 | if ((irq != regs[9]) || (irq != regs[10])) | 2562 | if ((irq != regs[9]) || (irq != regs[10])) |
2601 | return MXSER_ERR_IRQ_CONFLIT; | 2563 | goto err_irqconflict; |
2602 | } | 2564 | } |
2603 | 2565 | ||
2604 | if (!irq) | 2566 | if (!irq) { |
2605 | return MXSER_ERR_IRQ; | 2567 | printk(KERN_ERR "mxser: interrupt number unset\n"); |
2568 | return -EIO; | ||
2569 | } | ||
2606 | brd->irq = ((int)(irq & 0xF000) >> 12); | 2570 | brd->irq = ((int)(irq & 0xF000) >> 12); |
2607 | for (i = 0; i < 8; i++) | 2571 | for (i = 0; i < 8; i++) |
2608 | brd->ports[i].ioaddr = (int) regs[i + 1] & 0xFFF8; | 2572 | brd->ports[i].ioaddr = (int) regs[i + 1] & 0xFFF8; |
2609 | if ((regs[12] & 0x80) == 0) | 2573 | if ((regs[12] & 0x80) == 0) { |
2610 | return MXSER_ERR_VECTOR; | 2574 | printk(KERN_ERR "mxser: invalid interrupt vector\n"); |
2575 | return -EIO; | ||
2576 | } | ||
2611 | brd->vector = (int)regs[11]; /* interrupt vector */ | 2577 | brd->vector = (int)regs[11]; /* interrupt vector */ |
2612 | if (id == 1) | 2578 | if (id == 1) |
2613 | brd->vector_mask = 0x00FF; | 2579 | brd->vector_mask = 0x00FF; |
@@ -2634,13 +2600,26 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) | |||
2634 | else | 2600 | else |
2635 | brd->uart_type = PORT_16450; | 2601 | brd->uart_type = PORT_16450; |
2636 | if (!request_region(brd->ports[0].ioaddr, 8 * brd->info->nports, | 2602 | if (!request_region(brd->ports[0].ioaddr, 8 * brd->info->nports, |
2637 | "mxser(IO)")) | 2603 | "mxser(IO)")) { |
2638 | return MXSER_ERR_IOADDR; | 2604 | printk(KERN_ERR "mxser: can't request ports I/O region: " |
2605 | "0x%.8lx-0x%.8lx\n", | ||
2606 | brd->ports[0].ioaddr, brd->ports[0].ioaddr + | ||
2607 | 8 * brd->info->nports - 1); | ||
2608 | return -EIO; | ||
2609 | } | ||
2639 | if (!request_region(brd->vector, 1, "mxser(vector)")) { | 2610 | if (!request_region(brd->vector, 1, "mxser(vector)")) { |
2640 | release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); | 2611 | release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); |
2641 | return MXSER_ERR_VECTOR; | 2612 | printk(KERN_ERR "mxser: can't request interrupt vector region: " |
2613 | "0x%.8lx-0x%.8lx\n", | ||
2614 | brd->ports[0].ioaddr, brd->ports[0].ioaddr + | ||
2615 | 8 * brd->info->nports - 1); | ||
2616 | return -EIO; | ||
2642 | } | 2617 | } |
2643 | return brd->info->nports; | 2618 | return brd->info->nports; |
2619 | |||
2620 | err_irqconflict: | ||
2621 | printk(KERN_ERR "mxser: invalid interrupt number\n"); | ||
2622 | return -EIO; | ||
2644 | } | 2623 | } |
2645 | 2624 | ||
2646 | static int __devinit mxser_probe(struct pci_dev *pdev, | 2625 | static int __devinit mxser_probe(struct pci_dev *pdev, |
@@ -2657,20 +2636,20 @@ static int __devinit mxser_probe(struct pci_dev *pdev, | |||
2657 | break; | 2636 | break; |
2658 | 2637 | ||
2659 | if (i >= MXSER_BOARDS) { | 2638 | if (i >= MXSER_BOARDS) { |
2660 | printk(KERN_ERR "Too many Smartio/Industio family boards found " | 2639 | dev_err(&pdev->dev, "too many boards found (maximum %d), board " |
2661 | "(maximum %d), board not configured\n", MXSER_BOARDS); | 2640 | "not configured\n", MXSER_BOARDS); |
2662 | goto err; | 2641 | goto err; |
2663 | } | 2642 | } |
2664 | 2643 | ||
2665 | brd = &mxser_boards[i]; | 2644 | brd = &mxser_boards[i]; |
2666 | brd->idx = i * MXSER_PORTS_PER_BOARD; | 2645 | brd->idx = i * MXSER_PORTS_PER_BOARD; |
2667 | printk(KERN_INFO "Found MOXA %s board (BusNo=%d, DevNo=%d)\n", | 2646 | dev_info(&pdev->dev, "found MOXA %s board (BusNo=%d, DevNo=%d)\n", |
2668 | mxser_cards[ent->driver_data].name, | 2647 | mxser_cards[ent->driver_data].name, |
2669 | pdev->bus->number, PCI_SLOT(pdev->devfn)); | 2648 | pdev->bus->number, PCI_SLOT(pdev->devfn)); |
2670 | 2649 | ||
2671 | retval = pci_enable_device(pdev); | 2650 | retval = pci_enable_device(pdev); |
2672 | if (retval) { | 2651 | if (retval) { |
2673 | printk(KERN_ERR "Moxa SmartI/O PCI enable fail !\n"); | 2652 | dev_err(&pdev->dev, "PCI enable failed\n"); |
2674 | goto err; | 2653 | goto err; |
2675 | } | 2654 | } |
2676 | 2655 | ||
@@ -2772,11 +2751,8 @@ static struct pci_driver mxser_driver = { | |||
2772 | static int __init mxser_module_init(void) | 2751 | static int __init mxser_module_init(void) |
2773 | { | 2752 | { |
2774 | struct mxser_board *brd; | 2753 | struct mxser_board *brd; |
2775 | unsigned long cap; | 2754 | unsigned int b, i, m; |
2776 | unsigned int i, m, isaloop; | 2755 | int retval; |
2777 | int retval, b; | ||
2778 | |||
2779 | pr_debug("Loading module mxser ...\n"); | ||
2780 | 2756 | ||
2781 | mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1); | 2757 | mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1); |
2782 | if (!mxvar_sdriver) | 2758 | if (!mxvar_sdriver) |
@@ -2806,74 +2782,43 @@ static int __init mxser_module_init(void) | |||
2806 | goto err_put; | 2782 | goto err_put; |
2807 | } | 2783 | } |
2808 | 2784 | ||
2809 | mxvar_diagflag = 0; | ||
2810 | |||
2811 | m = 0; | ||
2812 | /* Start finding ISA boards here */ | 2785 | /* Start finding ISA boards here */ |
2813 | for (isaloop = 0; isaloop < 2; isaloop++) | 2786 | for (m = 0, b = 0; b < MXSER_BOARDS; b++) { |
2814 | for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) { | 2787 | if (!ioaddr[b]) |
2815 | if (!isaloop) | 2788 | continue; |
2816 | cap = mxserBoardCAP[b]; /* predefined */ | 2789 | |
2817 | else | 2790 | brd = &mxser_boards[m]; |
2818 | cap = ioaddr[b]; /* module param */ | 2791 | retval = mxser_get_ISA_conf(!ioaddr[b], brd); |
2819 | 2792 | if (retval <= 0) { | |
2820 | if (!cap) | 2793 | brd->info = NULL; |
2821 | continue; | 2794 | continue; |
2795 | } | ||
2822 | 2796 | ||
2823 | brd = &mxser_boards[m]; | 2797 | printk(KERN_INFO "mxser: found MOXA %s board (CAP=0x%lx)\n", |
2824 | retval = mxser_get_ISA_conf(cap, brd); | 2798 | brd->info->name, ioaddr[b]); |
2825 | |||
2826 | if (retval != 0) | ||
2827 | printk(KERN_INFO "Found MOXA %s board " | ||
2828 | "(CAP=0x%x)\n", | ||
2829 | brd->info->name, ioaddr[b]); | ||
2830 | |||
2831 | if (retval <= 0) { | ||
2832 | if (retval == MXSER_ERR_IRQ) | ||
2833 | printk(KERN_ERR "Invalid interrupt " | ||
2834 | "number, board not " | ||
2835 | "configured\n"); | ||
2836 | else if (retval == MXSER_ERR_IRQ_CONFLIT) | ||
2837 | printk(KERN_ERR "Invalid interrupt " | ||
2838 | "number, board not " | ||
2839 | "configured\n"); | ||
2840 | else if (retval == MXSER_ERR_VECTOR) | ||
2841 | printk(KERN_ERR "Invalid interrupt " | ||
2842 | "vector, board not " | ||
2843 | "configured\n"); | ||
2844 | else if (retval == MXSER_ERR_IOADDR) | ||
2845 | printk(KERN_ERR "Invalid I/O address, " | ||
2846 | "board not configured\n"); | ||
2847 | |||
2848 | brd->info = NULL; | ||
2849 | continue; | ||
2850 | } | ||
2851 | 2799 | ||
2852 | /* mxser_initbrd will hook ISR. */ | 2800 | /* mxser_initbrd will hook ISR. */ |
2853 | if (mxser_initbrd(brd, NULL) < 0) { | 2801 | if (mxser_initbrd(brd, NULL) < 0) { |
2854 | brd->info = NULL; | 2802 | brd->info = NULL; |
2855 | continue; | 2803 | continue; |
2856 | } | 2804 | } |
2857 | 2805 | ||
2858 | brd->idx = m * MXSER_PORTS_PER_BOARD; | 2806 | brd->idx = m * MXSER_PORTS_PER_BOARD; |
2859 | for (i = 0; i < brd->info->nports; i++) | 2807 | for (i = 0; i < brd->info->nports; i++) |
2860 | tty_register_device(mxvar_sdriver, brd->idx + i, | 2808 | tty_register_device(mxvar_sdriver, brd->idx + i, NULL); |
2861 | NULL); | ||
2862 | 2809 | ||
2863 | m++; | 2810 | m++; |
2864 | } | 2811 | } |
2865 | 2812 | ||
2866 | retval = pci_register_driver(&mxser_driver); | 2813 | retval = pci_register_driver(&mxser_driver); |
2867 | if (retval) { | 2814 | if (retval) { |
2868 | printk(KERN_ERR "Can't register pci driver\n"); | 2815 | printk(KERN_ERR "mxser: can't register pci driver\n"); |
2869 | if (!m) { | 2816 | if (!m) { |
2870 | retval = -ENODEV; | 2817 | retval = -ENODEV; |
2871 | goto err_unr; | 2818 | goto err_unr; |
2872 | } /* else: we have some ISA cards under control */ | 2819 | } /* else: we have some ISA cards under control */ |
2873 | } | 2820 | } |
2874 | 2821 | ||
2875 | pr_debug("Done.\n"); | ||
2876 | |||
2877 | return 0; | 2822 | return 0; |
2878 | err_unr: | 2823 | err_unr: |
2879 | tty_unregister_driver(mxvar_sdriver); | 2824 | tty_unregister_driver(mxvar_sdriver); |
@@ -2886,8 +2831,6 @@ static void __exit mxser_module_exit(void) | |||
2886 | { | 2831 | { |
2887 | unsigned int i, j; | 2832 | unsigned int i, j; |
2888 | 2833 | ||
2889 | pr_debug("Unloading module mxser ...\n"); | ||
2890 | |||
2891 | pci_unregister_driver(&mxser_driver); | 2834 | pci_unregister_driver(&mxser_driver); |
2892 | 2835 | ||
2893 | for (i = 0; i < MXSER_BOARDS; i++) /* ISA remains */ | 2836 | for (i = 0; i < MXSER_BOARDS; i++) /* ISA remains */ |
@@ -2901,8 +2844,6 @@ static void __exit mxser_module_exit(void) | |||
2901 | for (i = 0; i < MXSER_BOARDS; i++) | 2844 | for (i = 0; i < MXSER_BOARDS; i++) |
2902 | if (mxser_boards[i].info != NULL) | 2845 | if (mxser_boards[i].info != NULL) |
2903 | mxser_release_res(&mxser_boards[i], NULL, 1); | 2846 | mxser_release_res(&mxser_boards[i], NULL, 1); |
2904 | |||
2905 | pr_debug("Done.\n"); | ||
2906 | } | 2847 | } |
2907 | 2848 | ||
2908 | module_init(mxser_module_init); | 2849 | module_init(mxser_module_init); |
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c index ba012c2bdf7a..f9f72a211292 100644 --- a/drivers/char/nwflash.c +++ b/drivers/char/nwflash.c | |||
@@ -122,35 +122,20 @@ static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cm | |||
122 | static ssize_t flash_read(struct file *file, char __user *buf, size_t size, | 122 | static ssize_t flash_read(struct file *file, char __user *buf, size_t size, |
123 | loff_t *ppos) | 123 | loff_t *ppos) |
124 | { | 124 | { |
125 | unsigned long p = *ppos; | 125 | ssize_t ret; |
126 | unsigned int count = size; | ||
127 | int ret = 0; | ||
128 | 126 | ||
129 | if (flashdebug) | 127 | if (flashdebug) |
130 | printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, " | 128 | printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, " |
131 | "buffer=%p, count=0x%X.\n", p, buf, count); | 129 | "buffer=%p, count=0x%X.\n", p, buf, count); |
130 | /* | ||
131 | * We now lock against reads and writes. --rmk | ||
132 | */ | ||
133 | if (mutex_lock_interruptible(&nwflash_mutex)) | ||
134 | return -ERESTARTSYS; | ||
132 | 135 | ||
133 | if (count) | 136 | ret = simple_read_from_buffer(buf, size, ppos, FLASH_BASE, gbFlashSize); |
134 | ret = -ENXIO; | 137 | mutex_unlock(&nwflash_mutex); |
135 | |||
136 | if (p < gbFlashSize) { | ||
137 | if (count > gbFlashSize - p) | ||
138 | count = gbFlashSize - p; | ||
139 | 138 | ||
140 | /* | ||
141 | * We now lock against reads and writes. --rmk | ||
142 | */ | ||
143 | if (mutex_lock_interruptible(&nwflash_mutex)) | ||
144 | return -ERESTARTSYS; | ||
145 | |||
146 | ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count); | ||
147 | if (ret == 0) { | ||
148 | ret = count; | ||
149 | *ppos += count; | ||
150 | } else | ||
151 | ret = -EFAULT; | ||
152 | mutex_unlock(&nwflash_mutex); | ||
153 | } | ||
154 | return ret; | 139 | return ret; |
155 | } | 140 | } |
156 | 141 | ||
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 7af7a7e6b9c2..bee39fdfba73 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c | |||
@@ -67,7 +67,7 @@ | |||
67 | #include <linux/major.h> | 67 | #include <linux/major.h> |
68 | #include <linux/ppdev.h> | 68 | #include <linux/ppdev.h> |
69 | #include <linux/smp_lock.h> | 69 | #include <linux/smp_lock.h> |
70 | #include <asm/uaccess.h> | 70 | #include <linux/uaccess.h> |
71 | 71 | ||
72 | #define PP_VERSION "ppdev: user-space parallel port driver" | 72 | #define PP_VERSION "ppdev: user-space parallel port driver" |
73 | #define CHRDEV "ppdev" | 73 | #define CHRDEV "ppdev" |
@@ -328,10 +328,9 @@ static enum ieee1284_phase init_phase (int mode) | |||
328 | return IEEE1284_PH_FWD_IDLE; | 328 | return IEEE1284_PH_FWD_IDLE; |
329 | } | 329 | } |
330 | 330 | ||
331 | static int pp_ioctl(struct inode *inode, struct file *file, | 331 | static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
332 | unsigned int cmd, unsigned long arg) | ||
333 | { | 332 | { |
334 | unsigned int minor = iminor(inode); | 333 | unsigned int minor = iminor(file->f_path.dentry->d_inode); |
335 | struct pp_struct *pp = file->private_data; | 334 | struct pp_struct *pp = file->private_data; |
336 | struct parport * port; | 335 | struct parport * port; |
337 | void __user *argp = (void __user *)arg; | 336 | void __user *argp = (void __user *)arg; |
@@ -634,6 +633,15 @@ static int pp_ioctl(struct inode *inode, struct file *file, | |||
634 | return 0; | 633 | return 0; |
635 | } | 634 | } |
636 | 635 | ||
636 | static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
637 | { | ||
638 | long ret; | ||
639 | lock_kernel(); | ||
640 | ret = pp_do_ioctl(file, cmd, arg); | ||
641 | unlock_kernel(); | ||
642 | return ret; | ||
643 | } | ||
644 | |||
637 | static int pp_open (struct inode * inode, struct file * file) | 645 | static int pp_open (struct inode * inode, struct file * file) |
638 | { | 646 | { |
639 | unsigned int minor = iminor(inode); | 647 | unsigned int minor = iminor(inode); |
@@ -745,7 +753,7 @@ static const struct file_operations pp_fops = { | |||
745 | .read = pp_read, | 753 | .read = pp_read, |
746 | .write = pp_write, | 754 | .write = pp_write, |
747 | .poll = pp_poll, | 755 | .poll = pp_poll, |
748 | .ioctl = pp_ioctl, | 756 | .unlocked_ioctl = pp_ioctl, |
749 | .open = pp_open, | 757 | .open = pp_open, |
750 | .release = pp_release, | 758 | .release = pp_release, |
751 | }; | 759 | }; |
diff --git a/drivers/char/random.c b/drivers/char/random.c index 0cf98bd4f2d2..e0d0e371909c 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -236,6 +236,7 @@ | |||
236 | #include <linux/fs.h> | 236 | #include <linux/fs.h> |
237 | #include <linux/genhd.h> | 237 | #include <linux/genhd.h> |
238 | #include <linux/interrupt.h> | 238 | #include <linux/interrupt.h> |
239 | #include <linux/mm.h> | ||
239 | #include <linux/spinlock.h> | 240 | #include <linux/spinlock.h> |
240 | #include <linux/percpu.h> | 241 | #include <linux/percpu.h> |
241 | #include <linux/cryptohash.h> | 242 | #include <linux/cryptohash.h> |
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index 0cdfee152916..a8f68a3f14dd 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c | |||
@@ -179,7 +179,7 @@ static int rio_set_real_termios(void *ptr); | |||
179 | static void rio_hungup(void *ptr); | 179 | static void rio_hungup(void *ptr); |
180 | static void rio_close(void *ptr); | 180 | static void rio_close(void *ptr); |
181 | static int rio_chars_in_buffer(void *ptr); | 181 | static int rio_chars_in_buffer(void *ptr); |
182 | static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); | 182 | static long rio_fw_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); |
183 | static int rio_init_drivers(void); | 183 | static int rio_init_drivers(void); |
184 | 184 | ||
185 | static void my_hd(void *addr, int len); | 185 | static void my_hd(void *addr, int len); |
@@ -240,7 +240,7 @@ static struct real_driver rio_real_driver = { | |||
240 | 240 | ||
241 | static const struct file_operations rio_fw_fops = { | 241 | static const struct file_operations rio_fw_fops = { |
242 | .owner = THIS_MODULE, | 242 | .owner = THIS_MODULE, |
243 | .ioctl = rio_fw_ioctl, | 243 | .unlocked_ioctl = rio_fw_ioctl, |
244 | }; | 244 | }; |
245 | 245 | ||
246 | static struct miscdevice rio_fw_device = { | 246 | static struct miscdevice rio_fw_device = { |
@@ -560,13 +560,15 @@ static void rio_close(void *ptr) | |||
560 | 560 | ||
561 | 561 | ||
562 | 562 | ||
563 | static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) | 563 | static long rio_fw_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
564 | { | 564 | { |
565 | int rc = 0; | 565 | int rc = 0; |
566 | func_enter(); | 566 | func_enter(); |
567 | 567 | ||
568 | /* The "dev" argument isn't used. */ | 568 | /* The "dev" argument isn't used. */ |
569 | lock_kernel(); | ||
569 | rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); | 570 | rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); |
571 | unlock_kernel(); | ||
570 | 572 | ||
571 | func_exit(); | 573 | func_exit(); |
572 | return rc; | 574 | return rc; |
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index fa92a8af5a5a..dbefbb30ed44 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -78,9 +78,10 @@ | |||
78 | #include <linux/wait.h> | 78 | #include <linux/wait.h> |
79 | #include <linux/bcd.h> | 79 | #include <linux/bcd.h> |
80 | #include <linux/delay.h> | 80 | #include <linux/delay.h> |
81 | #include <linux/smp_lock.h> | ||
82 | #include <linux/uaccess.h> | ||
81 | 83 | ||
82 | #include <asm/current.h> | 84 | #include <asm/current.h> |
83 | #include <asm/uaccess.h> | ||
84 | #include <asm/system.h> | 85 | #include <asm/system.h> |
85 | 86 | ||
86 | #ifdef CONFIG_X86 | 87 | #ifdef CONFIG_X86 |
@@ -120,8 +121,6 @@ static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) | |||
120 | return 0; | 121 | return 0; |
121 | } | 122 | } |
122 | #endif | 123 | #endif |
123 | #else | ||
124 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); | ||
125 | #endif | 124 | #endif |
126 | 125 | ||
127 | /* | 126 | /* |
@@ -144,8 +143,7 @@ static DEFINE_TIMER(rtc_irq_timer, rtc_dropped_irq, 0, 0); | |||
144 | static ssize_t rtc_read(struct file *file, char __user *buf, | 143 | static ssize_t rtc_read(struct file *file, char __user *buf, |
145 | size_t count, loff_t *ppos); | 144 | size_t count, loff_t *ppos); |
146 | 145 | ||
147 | static int rtc_ioctl(struct inode *inode, struct file *file, | 146 | static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
148 | unsigned int cmd, unsigned long arg); | ||
149 | 147 | ||
150 | #ifdef RTC_IRQ | 148 | #ifdef RTC_IRQ |
151 | static unsigned int rtc_poll(struct file *file, poll_table *wait); | 149 | static unsigned int rtc_poll(struct file *file, poll_table *wait); |
@@ -719,10 +717,13 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel) | |||
719 | &wtime, sizeof wtime) ? -EFAULT : 0; | 717 | &wtime, sizeof wtime) ? -EFAULT : 0; |
720 | } | 718 | } |
721 | 719 | ||
722 | static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 720 | static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
723 | unsigned long arg) | ||
724 | { | 721 | { |
725 | return rtc_do_ioctl(cmd, arg, 0); | 722 | long ret; |
723 | lock_kernel(); | ||
724 | ret = rtc_do_ioctl(cmd, arg, 0); | ||
725 | unlock_kernel(); | ||
726 | return ret; | ||
726 | } | 727 | } |
727 | 728 | ||
728 | /* | 729 | /* |
@@ -915,7 +916,7 @@ static const struct file_operations rtc_fops = { | |||
915 | #ifdef RTC_IRQ | 916 | #ifdef RTC_IRQ |
916 | .poll = rtc_poll, | 917 | .poll = rtc_poll, |
917 | #endif | 918 | #endif |
918 | .ioctl = rtc_ioctl, | 919 | .unlocked_ioctl = rtc_ioctl, |
919 | .open = rtc_open, | 920 | .open = rtc_open, |
920 | .release = rtc_release, | 921 | .release = rtc_release, |
921 | .fasync = rtc_fasync, | 922 | .fasync = rtc_fasync, |
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index b976248e1072..19db1eb87c26 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -1256,7 +1256,6 @@ static int stl_tiocmset(struct tty_struct *tty, struct file *file, | |||
1256 | static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) | 1256 | static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) |
1257 | { | 1257 | { |
1258 | struct stlport *portp; | 1258 | struct stlport *portp; |
1259 | unsigned int ival; | ||
1260 | int rc; | 1259 | int rc; |
1261 | void __user *argp = (void __user *)arg; | 1260 | void __user *argp = (void __user *)arg; |
1262 | 1261 | ||
diff --git a/drivers/char/sx.c b/drivers/char/sx.c index 2162439bbe48..c385206f9db5 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c | |||
@@ -286,8 +286,8 @@ static void sx_close(void *ptr); | |||
286 | static int sx_chars_in_buffer(void *ptr); | 286 | static int sx_chars_in_buffer(void *ptr); |
287 | static int sx_init_board(struct sx_board *board); | 287 | static int sx_init_board(struct sx_board *board); |
288 | static int sx_init_portstructs(int nboards, int nports); | 288 | static int sx_init_portstructs(int nboards, int nports); |
289 | static int sx_fw_ioctl(struct inode *inode, struct file *filp, | 289 | static long sx_fw_ioctl(struct file *filp, unsigned int cmd, |
290 | unsigned int cmd, unsigned long arg); | 290 | unsigned long arg); |
291 | static int sx_init_drivers(void); | 291 | static int sx_init_drivers(void); |
292 | 292 | ||
293 | static struct tty_driver *sx_driver; | 293 | static struct tty_driver *sx_driver; |
@@ -396,7 +396,7 @@ static struct real_driver sx_real_driver = { | |||
396 | 396 | ||
397 | static const struct file_operations sx_fw_fops = { | 397 | static const struct file_operations sx_fw_fops = { |
398 | .owner = THIS_MODULE, | 398 | .owner = THIS_MODULE, |
399 | .ioctl = sx_fw_ioctl, | 399 | .unlocked_ioctl = sx_fw_ioctl, |
400 | }; | 400 | }; |
401 | 401 | ||
402 | static struct miscdevice sx_fw_device = { | 402 | static struct miscdevice sx_fw_device = { |
@@ -1686,10 +1686,10 @@ static int do_memtest_w(struct sx_board *board, int min, int max) | |||
1686 | } | 1686 | } |
1687 | #endif | 1687 | #endif |
1688 | 1688 | ||
1689 | static int sx_fw_ioctl(struct inode *inode, struct file *filp, | 1689 | static long sx_fw_ioctl(struct file *filp, unsigned int cmd, |
1690 | unsigned int cmd, unsigned long arg) | 1690 | unsigned long arg) |
1691 | { | 1691 | { |
1692 | int rc = 0; | 1692 | long rc = 0; |
1693 | int __user *descr = (int __user *)arg; | 1693 | int __user *descr = (int __user *)arg; |
1694 | int i; | 1694 | int i; |
1695 | static struct sx_board *board = NULL; | 1695 | static struct sx_board *board = NULL; |
@@ -1699,13 +1699,10 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp, | |||
1699 | 1699 | ||
1700 | func_enter(); | 1700 | func_enter(); |
1701 | 1701 | ||
1702 | #if 0 | 1702 | if (!capable(CAP_SYS_RAWIO)) |
1703 | /* Removed superuser check: Sysops can use the permissions on the device | ||
1704 | file to restrict access. Recommendation: Root only. (root.root 600) */ | ||
1705 | if (!capable(CAP_SYS_ADMIN)) { | ||
1706 | return -EPERM; | 1703 | return -EPERM; |
1707 | } | 1704 | |
1708 | #endif | 1705 | lock_kernel(); |
1709 | 1706 | ||
1710 | sx_dprintk(SX_DEBUG_FIRMWARE, "IOCTL %x: %lx\n", cmd, arg); | 1707 | sx_dprintk(SX_DEBUG_FIRMWARE, "IOCTL %x: %lx\n", cmd, arg); |
1711 | 1708 | ||
@@ -1720,19 +1717,23 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp, | |||
1720 | for (i = 0; i < SX_NBOARDS; i++) | 1717 | for (i = 0; i < SX_NBOARDS; i++) |
1721 | sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags); | 1718 | sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags); |
1722 | sx_dprintk(SX_DEBUG_FIRMWARE, "\n"); | 1719 | sx_dprintk(SX_DEBUG_FIRMWARE, "\n"); |
1720 | unlock_kernel(); | ||
1723 | return -EIO; | 1721 | return -EIO; |
1724 | } | 1722 | } |
1725 | 1723 | ||
1726 | switch (cmd) { | 1724 | switch (cmd) { |
1727 | case SXIO_SET_BOARD: | 1725 | case SXIO_SET_BOARD: |
1728 | sx_dprintk(SX_DEBUG_FIRMWARE, "set board to %ld\n", arg); | 1726 | sx_dprintk(SX_DEBUG_FIRMWARE, "set board to %ld\n", arg); |
1727 | rc = -EIO; | ||
1729 | if (arg >= SX_NBOARDS) | 1728 | if (arg >= SX_NBOARDS) |
1730 | return -EIO; | 1729 | break; |
1731 | sx_dprintk(SX_DEBUG_FIRMWARE, "not out of range\n"); | 1730 | sx_dprintk(SX_DEBUG_FIRMWARE, "not out of range\n"); |
1732 | if (!(boards[arg].flags & SX_BOARD_PRESENT)) | 1731 | if (!(boards[arg].flags & SX_BOARD_PRESENT)) |
1733 | return -EIO; | 1732 | break; |
1734 | sx_dprintk(SX_DEBUG_FIRMWARE, ".. and present!\n"); | 1733 | sx_dprintk(SX_DEBUG_FIRMWARE, ".. and present!\n"); |
1735 | board = &boards[arg]; | 1734 | board = &boards[arg]; |
1735 | rc = 0; | ||
1736 | /* FIXME: And this does ... nothing?? */ | ||
1736 | break; | 1737 | break; |
1737 | case SXIO_GET_TYPE: | 1738 | case SXIO_GET_TYPE: |
1738 | rc = -ENOENT; /* If we manage to miss one, return error. */ | 1739 | rc = -ENOENT; /* If we manage to miss one, return error. */ |
@@ -1746,7 +1747,7 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp, | |||
1746 | rc = SX_TYPE_SI; | 1747 | rc = SX_TYPE_SI; |
1747 | if (IS_EISA_BOARD(board)) | 1748 | if (IS_EISA_BOARD(board)) |
1748 | rc = SX_TYPE_SI; | 1749 | rc = SX_TYPE_SI; |
1749 | sx_dprintk(SX_DEBUG_FIRMWARE, "returning type= %d\n", rc); | 1750 | sx_dprintk(SX_DEBUG_FIRMWARE, "returning type= %ld\n", rc); |
1750 | break; | 1751 | break; |
1751 | case SXIO_DO_RAMTEST: | 1752 | case SXIO_DO_RAMTEST: |
1752 | if (sx_initialized) /* Already initialized: better not ramtest the board. */ | 1753 | if (sx_initialized) /* Already initialized: better not ramtest the board. */ |
@@ -1760,19 +1761,26 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp, | |||
1760 | rc = do_memtest(board, 0, 0x7ff8); | 1761 | rc = do_memtest(board, 0, 0x7ff8); |
1761 | /* if (!rc) rc = do_memtest_w (board, 0, 0x7ff8); */ | 1762 | /* if (!rc) rc = do_memtest_w (board, 0, 0x7ff8); */ |
1762 | } | 1763 | } |
1763 | sx_dprintk(SX_DEBUG_FIRMWARE, "returning memtest result= %d\n", | 1764 | sx_dprintk(SX_DEBUG_FIRMWARE, |
1764 | rc); | 1765 | "returning memtest result= %ld\n", rc); |
1765 | break; | 1766 | break; |
1766 | case SXIO_DOWNLOAD: | 1767 | case SXIO_DOWNLOAD: |
1767 | if (sx_initialized) /* Already initialized */ | 1768 | if (sx_initialized) {/* Already initialized */ |
1768 | return -EEXIST; | 1769 | rc = -EEXIST; |
1769 | if (!sx_reset(board)) | 1770 | break; |
1770 | return -EIO; | 1771 | } |
1772 | if (!sx_reset(board)) { | ||
1773 | rc = -EIO; | ||
1774 | break; | ||
1775 | } | ||
1771 | sx_dprintk(SX_DEBUG_INIT, "reset the board...\n"); | 1776 | sx_dprintk(SX_DEBUG_INIT, "reset the board...\n"); |
1772 | 1777 | ||
1773 | tmp = kmalloc(SX_CHUNK_SIZE, GFP_USER); | 1778 | tmp = kmalloc(SX_CHUNK_SIZE, GFP_USER); |
1774 | if (!tmp) | 1779 | if (!tmp) { |
1775 | return -ENOMEM; | 1780 | rc = -ENOMEM; |
1781 | break; | ||
1782 | } | ||
1783 | /* FIXME: check returns */ | ||
1776 | get_user(nbytes, descr++); | 1784 | get_user(nbytes, descr++); |
1777 | get_user(offset, descr++); | 1785 | get_user(offset, descr++); |
1778 | get_user(data, descr++); | 1786 | get_user(data, descr++); |
@@ -1782,7 +1790,8 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp, | |||
1782 | (i + SX_CHUNK_SIZE > nbytes) ? | 1790 | (i + SX_CHUNK_SIZE > nbytes) ? |
1783 | nbytes - i : SX_CHUNK_SIZE)) { | 1791 | nbytes - i : SX_CHUNK_SIZE)) { |
1784 | kfree(tmp); | 1792 | kfree(tmp); |
1785 | return -EFAULT; | 1793 | rc = -EFAULT; |
1794 | break; | ||
1786 | } | 1795 | } |
1787 | memcpy_toio(board->base2 + offset + i, tmp, | 1796 | memcpy_toio(board->base2 + offset + i, tmp, |
1788 | (i + SX_CHUNK_SIZE > nbytes) ? | 1797 | (i + SX_CHUNK_SIZE > nbytes) ? |
@@ -1798,13 +1807,17 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp, | |||
1798 | rc = sx_nports; | 1807 | rc = sx_nports; |
1799 | break; | 1808 | break; |
1800 | case SXIO_INIT: | 1809 | case SXIO_INIT: |
1801 | if (sx_initialized) /* Already initialized */ | 1810 | if (sx_initialized) { /* Already initialized */ |
1802 | return -EEXIST; | 1811 | rc = -EEXIST; |
1812 | break; | ||
1813 | } | ||
1803 | /* This is not allowed until all boards are initialized... */ | 1814 | /* This is not allowed until all boards are initialized... */ |
1804 | for (i = 0; i < SX_NBOARDS; i++) { | 1815 | for (i = 0; i < SX_NBOARDS; i++) { |
1805 | if ((boards[i].flags & SX_BOARD_PRESENT) && | 1816 | if ((boards[i].flags & SX_BOARD_PRESENT) && |
1806 | !(boards[i].flags & SX_BOARD_INITIALIZED)) | 1817 | !(boards[i].flags & SX_BOARD_INITIALIZED)) { |
1807 | return -EIO; | 1818 | rc = -EIO; |
1819 | break; | ||
1820 | } | ||
1808 | } | 1821 | } |
1809 | for (i = 0; i < SX_NBOARDS; i++) | 1822 | for (i = 0; i < SX_NBOARDS; i++) |
1810 | if (!(boards[i].flags & SX_BOARD_PRESENT)) | 1823 | if (!(boards[i].flags & SX_BOARD_PRESENT)) |
@@ -1832,10 +1845,10 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp, | |||
1832 | rc = sx_nports; | 1845 | rc = sx_nports; |
1833 | break; | 1846 | break; |
1834 | default: | 1847 | default: |
1835 | printk(KERN_WARNING "Unknown ioctl on firmware device (%x).\n", | 1848 | rc = -ENOTTY; |
1836 | cmd); | ||
1837 | break; | 1849 | break; |
1838 | } | 1850 | } |
1851 | unlock_kernel(); | ||
1839 | func_exit(); | 1852 | func_exit(); |
1840 | return rc; | 1853 | return rc; |
1841 | } | 1854 | } |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index fa48dba5ba5e..e1b46bc7e43c 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -1119,19 +1119,6 @@ int tty_hung_up_p(struct file *filp) | |||
1119 | 1119 | ||
1120 | EXPORT_SYMBOL(tty_hung_up_p); | 1120 | EXPORT_SYMBOL(tty_hung_up_p); |
1121 | 1121 | ||
1122 | /** | ||
1123 | * is_tty - checker whether file is a TTY | ||
1124 | * @filp: file handle that may be a tty | ||
1125 | * | ||
1126 | * Check if the file handle is a tty handle. | ||
1127 | */ | ||
1128 | |||
1129 | int is_tty(struct file *filp) | ||
1130 | { | ||
1131 | return filp->f_op->read == tty_read | ||
1132 | || filp->f_op->read == hung_up_tty_read; | ||
1133 | } | ||
1134 | |||
1135 | static void session_clear_tty(struct pid *session) | 1122 | static void session_clear_tty(struct pid *session) |
1136 | { | 1123 | { |
1137 | struct task_struct *p; | 1124 | struct task_struct *p; |
@@ -3593,7 +3580,6 @@ void proc_clear_tty(struct task_struct *p) | |||
3593 | p->signal->tty = NULL; | 3580 | p->signal->tty = NULL; |
3594 | spin_unlock_irq(&p->sighand->siglock); | 3581 | spin_unlock_irq(&p->sighand->siglock); |
3595 | } | 3582 | } |
3596 | EXPORT_SYMBOL(proc_clear_tty); | ||
3597 | 3583 | ||
3598 | /* Called under the sighand lock */ | 3584 | /* Called under the sighand lock */ |
3599 | 3585 | ||
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index dc17fe3a88bc..d0f4eb6fdb7f 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -46,6 +46,9 @@ static char *in, *inbuf; | |||
46 | /* The operations for our console. */ | 46 | /* The operations for our console. */ |
47 | static struct hv_ops virtio_cons; | 47 | static struct hv_ops virtio_cons; |
48 | 48 | ||
49 | /* The hvc device */ | ||
50 | static struct hvc_struct *hvc; | ||
51 | |||
49 | /*D:310 The put_chars() callback is pretty straightforward. | 52 | /*D:310 The put_chars() callback is pretty straightforward. |
50 | * | 53 | * |
51 | * We turn the characters into a scatter-gather list, add it to the output | 54 | * We turn the characters into a scatter-gather list, add it to the output |
@@ -134,6 +137,27 @@ int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)) | |||
134 | return hvc_instantiate(0, 0, &virtio_cons); | 137 | return hvc_instantiate(0, 0, &virtio_cons); |
135 | } | 138 | } |
136 | 139 | ||
140 | /* | ||
141 | * we support only one console, the hvc struct is a global var | ||
142 | * There is no need to do anything | ||
143 | */ | ||
144 | static int notifier_add_vio(struct hvc_struct *hp, int data) | ||
145 | { | ||
146 | hp->irq_requested = 1; | ||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | static void notifier_del_vio(struct hvc_struct *hp, int data) | ||
151 | { | ||
152 | hp->irq_requested = 0; | ||
153 | } | ||
154 | |||
155 | static void hvc_handle_input(struct virtqueue *vq) | ||
156 | { | ||
157 | if (hvc_poll(hvc)) | ||
158 | hvc_kick(); | ||
159 | } | ||
160 | |||
137 | /*D:370 Once we're further in boot, we get probed like any other virtio device. | 161 | /*D:370 Once we're further in boot, we get probed like any other virtio device. |
138 | * At this stage we set up the output virtqueue. | 162 | * At this stage we set up the output virtqueue. |
139 | * | 163 | * |
@@ -144,7 +168,6 @@ int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)) | |||
144 | static int __devinit virtcons_probe(struct virtio_device *dev) | 168 | static int __devinit virtcons_probe(struct virtio_device *dev) |
145 | { | 169 | { |
146 | int err; | 170 | int err; |
147 | struct hvc_struct *hvc; | ||
148 | 171 | ||
149 | vdev = dev; | 172 | vdev = dev; |
150 | 173 | ||
@@ -158,7 +181,7 @@ static int __devinit virtcons_probe(struct virtio_device *dev) | |||
158 | /* Find the input queue. */ | 181 | /* Find the input queue. */ |
159 | /* FIXME: This is why we want to wean off hvc: we do nothing | 182 | /* FIXME: This is why we want to wean off hvc: we do nothing |
160 | * when input comes in. */ | 183 | * when input comes in. */ |
161 | in_vq = vdev->config->find_vq(vdev, 0, NULL); | 184 | in_vq = vdev->config->find_vq(vdev, 0, hvc_handle_input); |
162 | if (IS_ERR(in_vq)) { | 185 | if (IS_ERR(in_vq)) { |
163 | err = PTR_ERR(in_vq); | 186 | err = PTR_ERR(in_vq); |
164 | goto free; | 187 | goto free; |
@@ -173,15 +196,18 @@ static int __devinit virtcons_probe(struct virtio_device *dev) | |||
173 | /* Start using the new console output. */ | 196 | /* Start using the new console output. */ |
174 | virtio_cons.get_chars = get_chars; | 197 | virtio_cons.get_chars = get_chars; |
175 | virtio_cons.put_chars = put_chars; | 198 | virtio_cons.put_chars = put_chars; |
199 | virtio_cons.notifier_add = notifier_add_vio; | ||
200 | virtio_cons.notifier_del = notifier_del_vio; | ||
176 | 201 | ||
177 | /* The first argument of hvc_alloc() is the virtual console number, so | 202 | /* The first argument of hvc_alloc() is the virtual console number, so |
178 | * we use zero. The second argument is the interrupt number; we | 203 | * we use zero. The second argument is the parameter for the |
179 | * currently leave this as zero: it would be better not to use the | 204 | * notification mechanism (like irq number). We currently leave this |
180 | * hvc mechanism and fix this (FIXME!). | 205 | * as zero, virtqueues have implicit notifications. |
181 | * | 206 | * |
182 | * The third argument is a "struct hv_ops" containing the put_chars() | 207 | * The third argument is a "struct hv_ops" containing the put_chars() |
183 | * and get_chars() pointers. The final argument is the output buffer | 208 | * get_chars(), notifier_add() and notifier_del() pointers. |
184 | * size: we can do any size, so we put PAGE_SIZE here. */ | 209 | * The final argument is the output buffer size: we can do any size, |
210 | * so we put PAGE_SIZE here. */ | ||
185 | hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE); | 211 | hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE); |
186 | if (IS_ERR(hvc)) { | 212 | if (IS_ERR(hvc)) { |
187 | err = PTR_ERR(hvc); | 213 | err = PTR_ERR(hvc); |
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index e32a076d5f1f..cb8c90da3934 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -261,7 +261,7 @@ static void notify_update(struct vc_data *vc) | |||
261 | #ifdef VT_BUF_VRAM_ONLY | 261 | #ifdef VT_BUF_VRAM_ONLY |
262 | #define DO_UPDATE(vc) 0 | 262 | #define DO_UPDATE(vc) 0 |
263 | #else | 263 | #else |
264 | #define DO_UPDATE(vc) CON_IS_VISIBLE(vc) | 264 | #define DO_UPDATE(vc) (CON_IS_VISIBLE(vc) && !console_blanked) |
265 | #endif | 265 | #endif |
266 | 266 | ||
267 | static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed) | 267 | static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed) |
@@ -2749,8 +2749,8 @@ static int con_open(struct tty_struct *tty, struct file *filp) | |||
2749 | tty->termios->c_iflag |= IUTF8; | 2749 | tty->termios->c_iflag |= IUTF8; |
2750 | else | 2750 | else |
2751 | tty->termios->c_iflag &= ~IUTF8; | 2751 | tty->termios->c_iflag &= ~IUTF8; |
2752 | release_console_sem(); | ||
2753 | vcs_make_sysfs(tty); | 2752 | vcs_make_sysfs(tty); |
2753 | release_console_sem(); | ||
2754 | return ret; | 2754 | return ret; |
2755 | } | 2755 | } |
2756 | } | 2756 | } |
@@ -2775,8 +2775,8 @@ static void con_close(struct tty_struct *tty, struct file *filp) | |||
2775 | if (vc) | 2775 | if (vc) |
2776 | vc->vc_tty = NULL; | 2776 | vc->vc_tty = NULL; |
2777 | tty->driver_data = NULL; | 2777 | tty->driver_data = NULL; |
2778 | release_console_sem(); | ||
2779 | vcs_remove_sysfs(tty); | 2778 | vcs_remove_sysfs(tty); |
2779 | release_console_sem(); | ||
2780 | mutex_unlock(&tty_mutex); | 2780 | mutex_unlock(&tty_mutex); |
2781 | /* | 2781 | /* |
2782 | * tty_mutex is released, but we still hold BKL, so there is | 2782 | * tty_mutex is released, but we still hold BKL, so there is |
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index 51966ccf4ea3..8bfee5fb7223 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c | |||
@@ -87,7 +87,6 @@ | |||
87 | #include <linux/mutex.h> | 87 | #include <linux/mutex.h> |
88 | #include <linux/smp_lock.h> | 88 | #include <linux/smp_lock.h> |
89 | #include <linux/sysctl.h> | 89 | #include <linux/sysctl.h> |
90 | #include <linux/version.h> | ||
91 | #include <linux/fs.h> | 90 | #include <linux/fs.h> |
92 | #include <linux/cdev.h> | 91 | #include <linux/cdev.h> |
93 | #include <linux/platform_device.h> | 92 | #include <linux/platform_device.h> |
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index 6e6c3c4aea6b..5a11e3cbcae2 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig | |||
@@ -123,6 +123,13 @@ config EDAC_I5000 | |||
123 | Support for error detection and correction the Intel | 123 | Support for error detection and correction the Intel |
124 | Greekcreek/Blackford chipsets. | 124 | Greekcreek/Blackford chipsets. |
125 | 125 | ||
126 | config EDAC_I5100 | ||
127 | tristate "Intel San Clemente MCH" | ||
128 | depends on EDAC_MM_EDAC && X86 && PCI | ||
129 | help | ||
130 | Support for error detection and correction the Intel | ||
131 | San Clemente MCH. | ||
132 | |||
126 | config EDAC_MPC85XX | 133 | config EDAC_MPC85XX |
127 | tristate "Freescale MPC85xx" | 134 | tristate "Freescale MPC85xx" |
128 | depends on EDAC_MM_EDAC && FSL_SOC && MPC85xx | 135 | depends on EDAC_MM_EDAC && FSL_SOC && MPC85xx |
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile index 83807731d4a9..e5e9104b5520 100644 --- a/drivers/edac/Makefile +++ b/drivers/edac/Makefile | |||
@@ -19,6 +19,7 @@ endif | |||
19 | 19 | ||
20 | obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o | 20 | obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o |
21 | obj-$(CONFIG_EDAC_I5000) += i5000_edac.o | 21 | obj-$(CONFIG_EDAC_I5000) += i5000_edac.o |
22 | obj-$(CONFIG_EDAC_I5100) += i5100_edac.o | ||
22 | obj-$(CONFIG_EDAC_E7XXX) += e7xxx_edac.o | 23 | obj-$(CONFIG_EDAC_E7XXX) += e7xxx_edac.o |
23 | obj-$(CONFIG_EDAC_E752X) += e752x_edac.o | 24 | obj-$(CONFIG_EDAC_E752X) += e752x_edac.o |
24 | obj-$(CONFIG_EDAC_I82443BXGX) += i82443bxgx_edac.o | 25 | obj-$(CONFIG_EDAC_I82443BXGX) += i82443bxgx_edac.o |
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c index c94a0eb492cb..facfdb1fa71c 100644 --- a/drivers/edac/e752x_edac.c +++ b/drivers/edac/e752x_edac.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #define E752X_REVISION " Ver: 2.0.2 " __DATE__ | 28 | #define E752X_REVISION " Ver: 2.0.2 " __DATE__ |
29 | #define EDAC_MOD_STR "e752x_edac" | 29 | #define EDAC_MOD_STR "e752x_edac" |
30 | 30 | ||
31 | static int report_non_memory_errors; | ||
31 | static int force_function_unhide; | 32 | static int force_function_unhide; |
32 | static int sysbus_parity = -1; | 33 | static int sysbus_parity = -1; |
33 | 34 | ||
@@ -117,7 +118,7 @@ static struct edac_pci_ctl_info *e752x_pci; | |||
117 | #define E752X_BUF_FERR 0x70 /* Memory buffer first error reg (8b) */ | 118 | #define E752X_BUF_FERR 0x70 /* Memory buffer first error reg (8b) */ |
118 | #define E752X_BUF_NERR 0x72 /* Memory buffer next error reg (8b) */ | 119 | #define E752X_BUF_NERR 0x72 /* Memory buffer next error reg (8b) */ |
119 | #define E752X_BUF_ERRMASK 0x74 /* Memory buffer error mask reg (8b) */ | 120 | #define E752X_BUF_ERRMASK 0x74 /* Memory buffer error mask reg (8b) */ |
120 | #define E752X_BUF_SMICMD 0x7A /* Memory buffer SMI command reg (8b) */ | 121 | #define E752X_BUF_SMICMD 0x7A /* Memory buffer SMI cmd reg (8b) */ |
121 | #define E752X_DRAM_FERR 0x80 /* DRAM first error register (16b) */ | 122 | #define E752X_DRAM_FERR 0x80 /* DRAM first error register (16b) */ |
122 | #define E752X_DRAM_NERR 0x82 /* DRAM next error register (16b) */ | 123 | #define E752X_DRAM_NERR 0x82 /* DRAM next error register (16b) */ |
123 | #define E752X_DRAM_ERRMASK 0x84 /* DRAM error mask register (8b) */ | 124 | #define E752X_DRAM_ERRMASK 0x84 /* DRAM error mask register (8b) */ |
@@ -127,7 +128,7 @@ static struct edac_pci_ctl_info *e752x_pci; | |||
127 | /* error address register (32b) */ | 128 | /* error address register (32b) */ |
128 | /* | 129 | /* |
129 | * 31 Reserved | 130 | * 31 Reserved |
130 | * 30:2 CE address (64 byte block 34:6) | 131 | * 30:2 CE address (64 byte block 34:6 |
131 | * 1 Reserved | 132 | * 1 Reserved |
132 | * 0 HiLoCS | 133 | * 0 HiLoCS |
133 | */ | 134 | */ |
@@ -147,11 +148,11 @@ static struct edac_pci_ctl_info *e752x_pci; | |||
147 | * 1 Reserved | 148 | * 1 Reserved |
148 | * 0 HiLoCS | 149 | * 0 HiLoCS |
149 | */ | 150 | */ |
150 | #define E752X_DRAM_SCRB_ADD 0xA8 /* DRAM first uncorrectable scrub memory */ | 151 | #define E752X_DRAM_SCRB_ADD 0xA8 /* DRAM 1st uncorrectable scrub mem */ |
151 | /* error address register (32b) */ | 152 | /* error address register (32b) */ |
152 | /* | 153 | /* |
153 | * 31 Reserved | 154 | * 31 Reserved |
154 | * 30:2 CE address (64 byte block 34:6) | 155 | * 30:2 CE address (64 byte block 34:6 |
155 | * 1 Reserved | 156 | * 1 Reserved |
156 | * 0 HiLoCS | 157 | * 0 HiLoCS |
157 | */ | 158 | */ |
@@ -394,9 +395,12 @@ static void do_process_ded_retry(struct mem_ctl_info *mci, u16 error, | |||
394 | struct e752x_pvt *pvt = (struct e752x_pvt *)mci->pvt_info; | 395 | struct e752x_pvt *pvt = (struct e752x_pvt *)mci->pvt_info; |
395 | 396 | ||
396 | error_1b = retry_add; | 397 | error_1b = retry_add; |
397 | page = error_1b >> (PAGE_SHIFT - 4); /* convert the addr to 4k page */ | 398 | page = error_1b >> (PAGE_SHIFT - 4); /* convert the addr to 4k page */ |
398 | row = pvt->mc_symmetric ? ((page >> 1) & 3) : /* chip select are bits 14 & 13 */ | 399 | |
400 | /* chip select are bits 14 & 13 */ | ||
401 | row = pvt->mc_symmetric ? ((page >> 1) & 3) : | ||
399 | edac_mc_find_csrow_by_page(mci, page); | 402 | edac_mc_find_csrow_by_page(mci, page); |
403 | |||
400 | e752x_mc_printk(mci, KERN_WARNING, | 404 | e752x_mc_printk(mci, KERN_WARNING, |
401 | "CE page 0x%lx, row %d : Memory read retry\n", | 405 | "CE page 0x%lx, row %d : Memory read retry\n", |
402 | (long unsigned int)page, row); | 406 | (long unsigned int)page, row); |
@@ -422,12 +426,21 @@ static inline void process_threshold_ce(struct mem_ctl_info *mci, u16 error, | |||
422 | } | 426 | } |
423 | 427 | ||
424 | static char *global_message[11] = { | 428 | static char *global_message[11] = { |
425 | "PCI Express C1", "PCI Express C", "PCI Express B1", | 429 | "PCI Express C1", |
426 | "PCI Express B", "PCI Express A1", "PCI Express A", | 430 | "PCI Express C", |
427 | "DMA Controler", "HUB or NS Interface", "System Bus", | 431 | "PCI Express B1", |
428 | "DRAM Controler", "Internal Buffer" | 432 | "PCI Express B", |
433 | "PCI Express A1", | ||
434 | "PCI Express A", | ||
435 | "DMA Controller", | ||
436 | "HUB or NS Interface", | ||
437 | "System Bus", | ||
438 | "DRAM Controller", /* 9th entry */ | ||
439 | "Internal Buffer" | ||
429 | }; | 440 | }; |
430 | 441 | ||
442 | #define DRAM_ENTRY 9 | ||
443 | |||
431 | static char *fatal_message[2] = { "Non-Fatal ", "Fatal " }; | 444 | static char *fatal_message[2] = { "Non-Fatal ", "Fatal " }; |
432 | 445 | ||
433 | static void do_global_error(int fatal, u32 errors) | 446 | static void do_global_error(int fatal, u32 errors) |
@@ -435,9 +448,16 @@ static void do_global_error(int fatal, u32 errors) | |||
435 | int i; | 448 | int i; |
436 | 449 | ||
437 | for (i = 0; i < 11; i++) { | 450 | for (i = 0; i < 11; i++) { |
438 | if (errors & (1 << i)) | 451 | if (errors & (1 << i)) { |
439 | e752x_printk(KERN_WARNING, "%sError %s\n", | 452 | /* If the error is from DRAM Controller OR |
440 | fatal_message[fatal], global_message[i]); | 453 | * we are to report ALL errors, then |
454 | * report the error | ||
455 | */ | ||
456 | if ((i == DRAM_ENTRY) || report_non_memory_errors) | ||
457 | e752x_printk(KERN_WARNING, "%sError %s\n", | ||
458 | fatal_message[fatal], | ||
459 | global_message[i]); | ||
460 | } | ||
441 | } | 461 | } |
442 | } | 462 | } |
443 | 463 | ||
@@ -1021,7 +1041,7 @@ static int e752x_get_devs(struct pci_dev *pdev, int dev_idx, | |||
1021 | struct pci_dev *dev; | 1041 | struct pci_dev *dev; |
1022 | 1042 | ||
1023 | pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL, | 1043 | pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL, |
1024 | pvt->dev_info->err_dev, pvt->bridge_ck); | 1044 | pvt->dev_info->err_dev, pvt->bridge_ck); |
1025 | 1045 | ||
1026 | if (pvt->bridge_ck == NULL) | 1046 | if (pvt->bridge_ck == NULL) |
1027 | pvt->bridge_ck = pci_scan_single_device(pdev->bus, | 1047 | pvt->bridge_ck = pci_scan_single_device(pdev->bus, |
@@ -1034,8 +1054,9 @@ static int e752x_get_devs(struct pci_dev *pdev, int dev_idx, | |||
1034 | return 1; | 1054 | return 1; |
1035 | } | 1055 | } |
1036 | 1056 | ||
1037 | dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev, | 1057 | dev = pci_get_device(PCI_VENDOR_ID_INTEL, |
1038 | NULL); | 1058 | e752x_devs[dev_idx].ctl_dev, |
1059 | NULL); | ||
1039 | 1060 | ||
1040 | if (dev == NULL) | 1061 | if (dev == NULL) |
1041 | goto fail; | 1062 | goto fail; |
@@ -1316,7 +1337,8 @@ MODULE_DESCRIPTION("MC support for Intel e752x/3100 memory controllers"); | |||
1316 | 1337 | ||
1317 | module_param(force_function_unhide, int, 0444); | 1338 | module_param(force_function_unhide, int, 0444); |
1318 | MODULE_PARM_DESC(force_function_unhide, "if BIOS sets Dev0:Fun1 up as hidden:" | 1339 | MODULE_PARM_DESC(force_function_unhide, "if BIOS sets Dev0:Fun1 up as hidden:" |
1319 | " 1=force unhide and hope BIOS doesn't fight driver for Dev0:Fun1 access"); | 1340 | " 1=force unhide and hope BIOS doesn't fight driver for " |
1341 | "Dev0:Fun1 access"); | ||
1320 | 1342 | ||
1321 | module_param(edac_op_state, int, 0444); | 1343 | module_param(edac_op_state, int, 0444); |
1322 | MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); | 1344 | MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); |
@@ -1324,3 +1346,6 @@ MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); | |||
1324 | module_param(sysbus_parity, int, 0444); | 1346 | module_param(sysbus_parity, int, 0444); |
1325 | MODULE_PARM_DESC(sysbus_parity, "0=disable system bus parity checking," | 1347 | MODULE_PARM_DESC(sysbus_parity, "0=disable system bus parity checking," |
1326 | " 1=enable system bus parity checking, default=auto-detect"); | 1348 | " 1=enable system bus parity checking, default=auto-detect"); |
1349 | module_param(report_non_memory_errors, int, 0644); | ||
1350 | MODULE_PARM_DESC(report_non_memory_errors, "0=disable non-memory error " | ||
1351 | "reporting, 1=enable non-memory error reporting"); | ||
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 021d18795145..ad218fe4942d 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -44,6 +44,25 @@ int edac_mc_get_poll_msec(void) | |||
44 | return edac_mc_poll_msec; | 44 | return edac_mc_poll_msec; |
45 | } | 45 | } |
46 | 46 | ||
47 | static int edac_set_poll_msec(const char *val, struct kernel_param *kp) | ||
48 | { | ||
49 | long l; | ||
50 | int ret; | ||
51 | |||
52 | if (!val) | ||
53 | return -EINVAL; | ||
54 | |||
55 | ret = strict_strtol(val, 0, &l); | ||
56 | if (ret == -EINVAL || ((int)l != l)) | ||
57 | return -EINVAL; | ||
58 | *((int *)kp->arg) = l; | ||
59 | |||
60 | /* notify edac_mc engine to reset the poll period */ | ||
61 | edac_mc_reset_delay_period(l); | ||
62 | |||
63 | return 0; | ||
64 | } | ||
65 | |||
47 | /* Parameter declarations for above */ | 66 | /* Parameter declarations for above */ |
48 | module_param(edac_mc_panic_on_ue, int, 0644); | 67 | module_param(edac_mc_panic_on_ue, int, 0644); |
49 | MODULE_PARM_DESC(edac_mc_panic_on_ue, "Panic on uncorrected error: 0=off 1=on"); | 68 | MODULE_PARM_DESC(edac_mc_panic_on_ue, "Panic on uncorrected error: 0=off 1=on"); |
@@ -53,7 +72,8 @@ MODULE_PARM_DESC(edac_mc_log_ue, | |||
53 | module_param(edac_mc_log_ce, int, 0644); | 72 | module_param(edac_mc_log_ce, int, 0644); |
54 | MODULE_PARM_DESC(edac_mc_log_ce, | 73 | MODULE_PARM_DESC(edac_mc_log_ce, |
55 | "Log correctable error to console: 0=off 1=on"); | 74 | "Log correctable error to console: 0=off 1=on"); |
56 | module_param(edac_mc_poll_msec, int, 0644); | 75 | module_param_call(edac_mc_poll_msec, edac_set_poll_msec, param_get_int, |
76 | &edac_mc_poll_msec, 0644); | ||
57 | MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds"); | 77 | MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds"); |
58 | 78 | ||
59 | /* | 79 | /* |
@@ -103,16 +123,6 @@ static const char *edac_caps[] = { | |||
103 | 123 | ||
104 | 124 | ||
105 | 125 | ||
106 | /* | ||
107 | * /sys/devices/system/edac/mc; | ||
108 | * data structures and methods | ||
109 | */ | ||
110 | static ssize_t memctrl_int_show(void *ptr, char *buffer) | ||
111 | { | ||
112 | int *value = (int *)ptr; | ||
113 | return sprintf(buffer, "%u\n", *value); | ||
114 | } | ||
115 | |||
116 | static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count) | 126 | static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count) |
117 | { | 127 | { |
118 | int *value = (int *)ptr; | 128 | int *value = (int *)ptr; |
@@ -123,23 +133,6 @@ static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count) | |||
123 | return count; | 133 | return count; |
124 | } | 134 | } |
125 | 135 | ||
126 | /* | ||
127 | * mc poll_msec time value | ||
128 | */ | ||
129 | static ssize_t poll_msec_int_store(void *ptr, const char *buffer, size_t count) | ||
130 | { | ||
131 | int *value = (int *)ptr; | ||
132 | |||
133 | if (isdigit(*buffer)) { | ||
134 | *value = simple_strtoul(buffer, NULL, 0); | ||
135 | |||
136 | /* notify edac_mc engine to reset the poll period */ | ||
137 | edac_mc_reset_delay_period(*value); | ||
138 | } | ||
139 | |||
140 | return count; | ||
141 | } | ||
142 | |||
143 | 136 | ||
144 | /* EDAC sysfs CSROW data structures and methods | 137 | /* EDAC sysfs CSROW data structures and methods |
145 | */ | 138 | */ |
@@ -185,7 +178,11 @@ static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data, | |||
185 | static ssize_t channel_dimm_label_show(struct csrow_info *csrow, | 178 | static ssize_t channel_dimm_label_show(struct csrow_info *csrow, |
186 | char *data, int channel) | 179 | char *data, int channel) |
187 | { | 180 | { |
188 | return snprintf(data, EDAC_MC_LABEL_LEN, "%s", | 181 | /* if field has not been initialized, there is nothing to send */ |
182 | if (!csrow->channels[channel].label[0]) | ||
183 | return 0; | ||
184 | |||
185 | return snprintf(data, EDAC_MC_LABEL_LEN, "%s\n", | ||
189 | csrow->channels[channel].label); | 186 | csrow->channels[channel].label); |
190 | } | 187 | } |
191 | 188 | ||
@@ -649,98 +646,10 @@ static struct kobj_type ktype_mci = { | |||
649 | .default_attrs = (struct attribute **)mci_attr, | 646 | .default_attrs = (struct attribute **)mci_attr, |
650 | }; | 647 | }; |
651 | 648 | ||
652 | /* show/store, tables, etc for the MC kset */ | ||
653 | |||
654 | |||
655 | struct memctrl_dev_attribute { | ||
656 | struct attribute attr; | ||
657 | void *value; | ||
658 | ssize_t(*show) (void *, char *); | ||
659 | ssize_t(*store) (void *, const char *, size_t); | ||
660 | }; | ||
661 | |||
662 | /* Set of show/store abstract level functions for memory control object */ | ||
663 | static ssize_t memctrl_dev_show(struct kobject *kobj, | ||
664 | struct attribute *attr, char *buffer) | ||
665 | { | ||
666 | struct memctrl_dev_attribute *memctrl_dev; | ||
667 | memctrl_dev = (struct memctrl_dev_attribute *)attr; | ||
668 | |||
669 | if (memctrl_dev->show) | ||
670 | return memctrl_dev->show(memctrl_dev->value, buffer); | ||
671 | |||
672 | return -EIO; | ||
673 | } | ||
674 | |||
675 | static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr, | ||
676 | const char *buffer, size_t count) | ||
677 | { | ||
678 | struct memctrl_dev_attribute *memctrl_dev; | ||
679 | memctrl_dev = (struct memctrl_dev_attribute *)attr; | ||
680 | |||
681 | if (memctrl_dev->store) | ||
682 | return memctrl_dev->store(memctrl_dev->value, buffer, count); | ||
683 | |||
684 | return -EIO; | ||
685 | } | ||
686 | |||
687 | static struct sysfs_ops memctrlfs_ops = { | ||
688 | .show = memctrl_dev_show, | ||
689 | .store = memctrl_dev_store | ||
690 | }; | ||
691 | |||
692 | #define MEMCTRL_ATTR(_name, _mode, _show, _store) \ | ||
693 | static struct memctrl_dev_attribute attr_##_name = { \ | ||
694 | .attr = {.name = __stringify(_name), .mode = _mode }, \ | ||
695 | .value = &_name, \ | ||
696 | .show = _show, \ | ||
697 | .store = _store, \ | ||
698 | }; | ||
699 | |||
700 | #define MEMCTRL_STRING_ATTR(_name, _data, _mode, _show, _store) \ | ||
701 | static struct memctrl_dev_attribute attr_##_name = { \ | ||
702 | .attr = {.name = __stringify(_name), .mode = _mode }, \ | ||
703 | .value = _data, \ | ||
704 | .show = _show, \ | ||
705 | .store = _store, \ | ||
706 | }; | ||
707 | |||
708 | /* csrow<id> control files */ | ||
709 | MEMCTRL_ATTR(edac_mc_panic_on_ue, | ||
710 | S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); | ||
711 | |||
712 | MEMCTRL_ATTR(edac_mc_log_ue, | ||
713 | S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); | ||
714 | |||
715 | MEMCTRL_ATTR(edac_mc_log_ce, | ||
716 | S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); | ||
717 | |||
718 | MEMCTRL_ATTR(edac_mc_poll_msec, | ||
719 | S_IRUGO | S_IWUSR, memctrl_int_show, poll_msec_int_store); | ||
720 | |||
721 | /* Base Attributes of the memory ECC object */ | ||
722 | static struct memctrl_dev_attribute *memctrl_attr[] = { | ||
723 | &attr_edac_mc_panic_on_ue, | ||
724 | &attr_edac_mc_log_ue, | ||
725 | &attr_edac_mc_log_ce, | ||
726 | &attr_edac_mc_poll_msec, | ||
727 | NULL, | ||
728 | }; | ||
729 | |||
730 | |||
731 | /* the ktype for the mc_kset internal kobj */ | ||
732 | static struct kobj_type ktype_mc_set_attribs = { | ||
733 | .sysfs_ops = &memctrlfs_ops, | ||
734 | .default_attrs = (struct attribute **)memctrl_attr, | ||
735 | }; | ||
736 | |||
737 | /* EDAC memory controller sysfs kset: | 649 | /* EDAC memory controller sysfs kset: |
738 | * /sys/devices/system/edac/mc | 650 | * /sys/devices/system/edac/mc |
739 | */ | 651 | */ |
740 | static struct kset mc_kset = { | 652 | static struct kset *mc_kset; |
741 | .kobj = {.ktype = &ktype_mc_set_attribs }, | ||
742 | }; | ||
743 | |||
744 | 653 | ||
745 | /* | 654 | /* |
746 | * edac_mc_register_sysfs_main_kobj | 655 | * edac_mc_register_sysfs_main_kobj |
@@ -771,7 +680,7 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci) | |||
771 | } | 680 | } |
772 | 681 | ||
773 | /* this instance become part of the mc_kset */ | 682 | /* this instance become part of the mc_kset */ |
774 | kobj_mci->kset = &mc_kset; | 683 | kobj_mci->kset = mc_kset; |
775 | 684 | ||
776 | /* register the mc<id> kobject to the mc_kset */ | 685 | /* register the mc<id> kobject to the mc_kset */ |
777 | err = kobject_init_and_add(kobj_mci, &ktype_mci, NULL, | 686 | err = kobject_init_and_add(kobj_mci, &ktype_mci, NULL, |
@@ -1001,12 +910,9 @@ int edac_sysfs_setup_mc_kset(void) | |||
1001 | } | 910 | } |
1002 | 911 | ||
1003 | /* Init the MC's kobject */ | 912 | /* Init the MC's kobject */ |
1004 | kobject_set_name(&mc_kset.kobj, "mc"); | 913 | mc_kset = kset_create_and_add("mc", NULL, &edac_class->kset.kobj); |
1005 | mc_kset.kobj.parent = &edac_class->kset.kobj; | 914 | if (!mc_kset) { |
1006 | 915 | err = -ENOMEM; | |
1007 | /* register the mc_kset */ | ||
1008 | err = kset_register(&mc_kset); | ||
1009 | if (err) { | ||
1010 | debugf1("%s() Failed to register '.../edac/mc'\n", __func__); | 916 | debugf1("%s() Failed to register '.../edac/mc'\n", __func__); |
1011 | goto fail_out; | 917 | goto fail_out; |
1012 | } | 918 | } |
@@ -1028,6 +934,6 @@ fail_out: | |||
1028 | */ | 934 | */ |
1029 | void edac_sysfs_teardown_mc_kset(void) | 935 | void edac_sysfs_teardown_mc_kset(void) |
1030 | { | 936 | { |
1031 | kset_unregister(&mc_kset); | 937 | kset_unregister(mc_kset); |
1032 | } | 938 | } |
1033 | 939 | ||
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c index 2c1fa1bb6df2..5c153dccc95e 100644 --- a/drivers/edac/edac_pci_sysfs.c +++ b/drivers/edac/edac_pci_sysfs.c | |||
@@ -28,7 +28,7 @@ static int edac_pci_poll_msec = 1000; /* one second workq period */ | |||
28 | static atomic_t pci_parity_count = ATOMIC_INIT(0); | 28 | static atomic_t pci_parity_count = ATOMIC_INIT(0); |
29 | static atomic_t pci_nonparity_count = ATOMIC_INIT(0); | 29 | static atomic_t pci_nonparity_count = ATOMIC_INIT(0); |
30 | 30 | ||
31 | static struct kobject edac_pci_top_main_kobj; | 31 | static struct kobject *edac_pci_top_main_kobj; |
32 | static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0); | 32 | static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0); |
33 | 33 | ||
34 | /* getter functions for the data variables */ | 34 | /* getter functions for the data variables */ |
@@ -83,7 +83,7 @@ static void edac_pci_instance_release(struct kobject *kobj) | |||
83 | pci = to_instance(kobj); | 83 | pci = to_instance(kobj); |
84 | 84 | ||
85 | /* decrement reference count on top main kobj */ | 85 | /* decrement reference count on top main kobj */ |
86 | kobject_put(&edac_pci_top_main_kobj); | 86 | kobject_put(edac_pci_top_main_kobj); |
87 | 87 | ||
88 | kfree(pci); /* Free the control struct */ | 88 | kfree(pci); /* Free the control struct */ |
89 | } | 89 | } |
@@ -166,7 +166,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx) | |||
166 | * track the number of PCI instances we have, and thus nest | 166 | * track the number of PCI instances we have, and thus nest |
167 | * properly on keeping the module loaded | 167 | * properly on keeping the module loaded |
168 | */ | 168 | */ |
169 | main_kobj = kobject_get(&edac_pci_top_main_kobj); | 169 | main_kobj = kobject_get(edac_pci_top_main_kobj); |
170 | if (!main_kobj) { | 170 | if (!main_kobj) { |
171 | err = -ENODEV; | 171 | err = -ENODEV; |
172 | goto error_out; | 172 | goto error_out; |
@@ -174,11 +174,11 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx) | |||
174 | 174 | ||
175 | /* And now register this new kobject under the main kobj */ | 175 | /* And now register this new kobject under the main kobj */ |
176 | err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance, | 176 | err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance, |
177 | &edac_pci_top_main_kobj, "pci%d", idx); | 177 | edac_pci_top_main_kobj, "pci%d", idx); |
178 | if (err != 0) { | 178 | if (err != 0) { |
179 | debugf2("%s() failed to register instance pci%d\n", | 179 | debugf2("%s() failed to register instance pci%d\n", |
180 | __func__, idx); | 180 | __func__, idx); |
181 | kobject_put(&edac_pci_top_main_kobj); | 181 | kobject_put(edac_pci_top_main_kobj); |
182 | goto error_out; | 182 | goto error_out; |
183 | } | 183 | } |
184 | 184 | ||
@@ -316,9 +316,10 @@ static struct edac_pci_dev_attribute *edac_pci_attr[] = { | |||
316 | */ | 316 | */ |
317 | static void edac_pci_release_main_kobj(struct kobject *kobj) | 317 | static void edac_pci_release_main_kobj(struct kobject *kobj) |
318 | { | 318 | { |
319 | |||
320 | debugf0("%s() here to module_put(THIS_MODULE)\n", __func__); | 319 | debugf0("%s() here to module_put(THIS_MODULE)\n", __func__); |
321 | 320 | ||
321 | kfree(kobj); | ||
322 | |||
322 | /* last reference to top EDAC PCI kobject has been removed, | 323 | /* last reference to top EDAC PCI kobject has been removed, |
323 | * NOW release our ref count on the core module | 324 | * NOW release our ref count on the core module |
324 | */ | 325 | */ |
@@ -369,8 +370,16 @@ static int edac_pci_main_kobj_setup(void) | |||
369 | goto decrement_count_fail; | 370 | goto decrement_count_fail; |
370 | } | 371 | } |
371 | 372 | ||
373 | edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL); | ||
374 | if (!edac_pci_top_main_kobj) { | ||
375 | debugf1("Failed to allocate\n"); | ||
376 | err = -ENOMEM; | ||
377 | goto kzalloc_fail; | ||
378 | } | ||
379 | |||
372 | /* Instanstiate the pci object */ | 380 | /* Instanstiate the pci object */ |
373 | err = kobject_init_and_add(&edac_pci_top_main_kobj, &ktype_edac_pci_main_kobj, | 381 | err = kobject_init_and_add(edac_pci_top_main_kobj, |
382 | &ktype_edac_pci_main_kobj, | ||
374 | &edac_class->kset.kobj, "pci"); | 383 | &edac_class->kset.kobj, "pci"); |
375 | if (err) { | 384 | if (err) { |
376 | debugf1("Failed to register '.../edac/pci'\n"); | 385 | debugf1("Failed to register '.../edac/pci'\n"); |
@@ -381,13 +390,16 @@ static int edac_pci_main_kobj_setup(void) | |||
381 | * for EDAC PCI, then edac_pci_main_kobj_teardown() | 390 | * for EDAC PCI, then edac_pci_main_kobj_teardown() |
382 | * must be used, for resources to be cleaned up properly | 391 | * must be used, for resources to be cleaned up properly |
383 | */ | 392 | */ |
384 | kobject_uevent(&edac_pci_top_main_kobj, KOBJ_ADD); | 393 | kobject_uevent(edac_pci_top_main_kobj, KOBJ_ADD); |
385 | debugf1("Registered '.../edac/pci' kobject\n"); | 394 | debugf1("Registered '.../edac/pci' kobject\n"); |
386 | 395 | ||
387 | return 0; | 396 | return 0; |
388 | 397 | ||
389 | /* Error unwind statck */ | 398 | /* Error unwind statck */ |
390 | kobject_init_and_add_fail: | 399 | kobject_init_and_add_fail: |
400 | kfree(edac_pci_top_main_kobj); | ||
401 | |||
402 | kzalloc_fail: | ||
391 | module_put(THIS_MODULE); | 403 | module_put(THIS_MODULE); |
392 | 404 | ||
393 | decrement_count_fail: | 405 | decrement_count_fail: |
@@ -414,7 +426,7 @@ static void edac_pci_main_kobj_teardown(void) | |||
414 | if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) { | 426 | if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) { |
415 | debugf0("%s() called kobject_put on main kobj\n", | 427 | debugf0("%s() called kobject_put on main kobj\n", |
416 | __func__); | 428 | __func__); |
417 | kobject_put(&edac_pci_top_main_kobj); | 429 | kobject_put(edac_pci_top_main_kobj); |
418 | } | 430 | } |
419 | } | 431 | } |
420 | 432 | ||
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c new file mode 100644 index 000000000000..22db05a67bfb --- /dev/null +++ b/drivers/edac/i5100_edac.c | |||
@@ -0,0 +1,981 @@ | |||
1 | /* | ||
2 | * Intel 5100 Memory Controllers kernel module | ||
3 | * | ||
4 | * This file may be distributed under the terms of the | ||
5 | * GNU General Public License. | ||
6 | * | ||
7 | * This module is based on the following document: | ||
8 | * | ||
9 | * Intel 5100X Chipset Memory Controller Hub (MCH) - Datasheet | ||
10 | * http://download.intel.com/design/chipsets/datashts/318378.pdf | ||
11 | * | ||
12 | */ | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/pci.h> | ||
16 | #include <linux/pci_ids.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/edac.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/mmzone.h> | ||
21 | |||
22 | #include "edac_core.h" | ||
23 | |||
24 | /* register addresses */ | ||
25 | |||
26 | /* device 16, func 1 */ | ||
27 | #define I5100_MC 0x40 /* Memory Control Register */ | ||
28 | #define I5100_MS 0x44 /* Memory Status Register */ | ||
29 | #define I5100_SPDDATA 0x48 /* Serial Presence Detect Status Reg */ | ||
30 | #define I5100_SPDCMD 0x4c /* Serial Presence Detect Command Reg */ | ||
31 | #define I5100_TOLM 0x6c /* Top of Low Memory */ | ||
32 | #define I5100_MIR0 0x80 /* Memory Interleave Range 0 */ | ||
33 | #define I5100_MIR1 0x84 /* Memory Interleave Range 1 */ | ||
34 | #define I5100_AMIR_0 0x8c /* Adjusted Memory Interleave Range 0 */ | ||
35 | #define I5100_AMIR_1 0x90 /* Adjusted Memory Interleave Range 1 */ | ||
36 | #define I5100_FERR_NF_MEM 0xa0 /* MC First Non Fatal Errors */ | ||
37 | #define I5100_FERR_NF_MEM_M16ERR_MASK (1 << 16) | ||
38 | #define I5100_FERR_NF_MEM_M15ERR_MASK (1 << 15) | ||
39 | #define I5100_FERR_NF_MEM_M14ERR_MASK (1 << 14) | ||
40 | #define I5100_FERR_NF_MEM_M12ERR_MASK (1 << 12) | ||
41 | #define I5100_FERR_NF_MEM_M11ERR_MASK (1 << 11) | ||
42 | #define I5100_FERR_NF_MEM_M10ERR_MASK (1 << 10) | ||
43 | #define I5100_FERR_NF_MEM_M6ERR_MASK (1 << 6) | ||
44 | #define I5100_FERR_NF_MEM_M5ERR_MASK (1 << 5) | ||
45 | #define I5100_FERR_NF_MEM_M4ERR_MASK (1 << 4) | ||
46 | #define I5100_FERR_NF_MEM_M1ERR_MASK 1 | ||
47 | #define I5100_FERR_NF_MEM_ANY_MASK \ | ||
48 | (I5100_FERR_NF_MEM_M16ERR_MASK | \ | ||
49 | I5100_FERR_NF_MEM_M15ERR_MASK | \ | ||
50 | I5100_FERR_NF_MEM_M14ERR_MASK | \ | ||
51 | I5100_FERR_NF_MEM_M12ERR_MASK | \ | ||
52 | I5100_FERR_NF_MEM_M11ERR_MASK | \ | ||
53 | I5100_FERR_NF_MEM_M10ERR_MASK | \ | ||
54 | I5100_FERR_NF_MEM_M6ERR_MASK | \ | ||
55 | I5100_FERR_NF_MEM_M5ERR_MASK | \ | ||
56 | I5100_FERR_NF_MEM_M4ERR_MASK | \ | ||
57 | I5100_FERR_NF_MEM_M1ERR_MASK) | ||
58 | #define I5100_NERR_NF_MEM 0xa4 /* MC Next Non-Fatal Errors */ | ||
59 | #define I5100_EMASK_MEM 0xa8 /* MC Error Mask Register */ | ||
60 | |||
61 | /* device 21 and 22, func 0 */ | ||
62 | #define I5100_MTR_0 0x154 /* Memory Technology Registers 0-3 */ | ||
63 | #define I5100_DMIR 0x15c /* DIMM Interleave Range */ | ||
64 | #define I5100_VALIDLOG 0x18c /* Valid Log Markers */ | ||
65 | #define I5100_NRECMEMA 0x190 /* Non-Recoverable Memory Error Log Reg A */ | ||
66 | #define I5100_NRECMEMB 0x194 /* Non-Recoverable Memory Error Log Reg B */ | ||
67 | #define I5100_REDMEMA 0x198 /* Recoverable Memory Data Error Log Reg A */ | ||
68 | #define I5100_REDMEMB 0x19c /* Recoverable Memory Data Error Log Reg B */ | ||
69 | #define I5100_RECMEMA 0x1a0 /* Recoverable Memory Error Log Reg A */ | ||
70 | #define I5100_RECMEMB 0x1a4 /* Recoverable Memory Error Log Reg B */ | ||
71 | #define I5100_MTR_4 0x1b0 /* Memory Technology Registers 4,5 */ | ||
72 | |||
73 | /* bit field accessors */ | ||
74 | |||
75 | static inline u32 i5100_mc_errdeten(u32 mc) | ||
76 | { | ||
77 | return mc >> 5 & 1; | ||
78 | } | ||
79 | |||
80 | static inline u16 i5100_spddata_rdo(u16 a) | ||
81 | { | ||
82 | return a >> 15 & 1; | ||
83 | } | ||
84 | |||
85 | static inline u16 i5100_spddata_sbe(u16 a) | ||
86 | { | ||
87 | return a >> 13 & 1; | ||
88 | } | ||
89 | |||
90 | static inline u16 i5100_spddata_busy(u16 a) | ||
91 | { | ||
92 | return a >> 12 & 1; | ||
93 | } | ||
94 | |||
95 | static inline u16 i5100_spddata_data(u16 a) | ||
96 | { | ||
97 | return a & ((1 << 8) - 1); | ||
98 | } | ||
99 | |||
100 | static inline u32 i5100_spdcmd_create(u32 dti, u32 ckovrd, u32 sa, u32 ba, | ||
101 | u32 data, u32 cmd) | ||
102 | { | ||
103 | return ((dti & ((1 << 4) - 1)) << 28) | | ||
104 | ((ckovrd & 1) << 27) | | ||
105 | ((sa & ((1 << 3) - 1)) << 24) | | ||
106 | ((ba & ((1 << 8) - 1)) << 16) | | ||
107 | ((data & ((1 << 8) - 1)) << 8) | | ||
108 | (cmd & 1); | ||
109 | } | ||
110 | |||
111 | static inline u16 i5100_tolm_tolm(u16 a) | ||
112 | { | ||
113 | return a >> 12 & ((1 << 4) - 1); | ||
114 | } | ||
115 | |||
116 | static inline u16 i5100_mir_limit(u16 a) | ||
117 | { | ||
118 | return a >> 4 & ((1 << 12) - 1); | ||
119 | } | ||
120 | |||
121 | static inline u16 i5100_mir_way1(u16 a) | ||
122 | { | ||
123 | return a >> 1 & 1; | ||
124 | } | ||
125 | |||
126 | static inline u16 i5100_mir_way0(u16 a) | ||
127 | { | ||
128 | return a & 1; | ||
129 | } | ||
130 | |||
131 | static inline u32 i5100_ferr_nf_mem_chan_indx(u32 a) | ||
132 | { | ||
133 | return a >> 28 & 1; | ||
134 | } | ||
135 | |||
136 | static inline u32 i5100_ferr_nf_mem_any(u32 a) | ||
137 | { | ||
138 | return a & I5100_FERR_NF_MEM_ANY_MASK; | ||
139 | } | ||
140 | |||
141 | static inline u32 i5100_nerr_nf_mem_any(u32 a) | ||
142 | { | ||
143 | return i5100_ferr_nf_mem_any(a); | ||
144 | } | ||
145 | |||
146 | static inline u32 i5100_dmir_limit(u32 a) | ||
147 | { | ||
148 | return a >> 16 & ((1 << 11) - 1); | ||
149 | } | ||
150 | |||
151 | static inline u32 i5100_dmir_rank(u32 a, u32 i) | ||
152 | { | ||
153 | return a >> (4 * i) & ((1 << 2) - 1); | ||
154 | } | ||
155 | |||
156 | static inline u16 i5100_mtr_present(u16 a) | ||
157 | { | ||
158 | return a >> 10 & 1; | ||
159 | } | ||
160 | |||
161 | static inline u16 i5100_mtr_ethrottle(u16 a) | ||
162 | { | ||
163 | return a >> 9 & 1; | ||
164 | } | ||
165 | |||
166 | static inline u16 i5100_mtr_width(u16 a) | ||
167 | { | ||
168 | return a >> 8 & 1; | ||
169 | } | ||
170 | |||
171 | static inline u16 i5100_mtr_numbank(u16 a) | ||
172 | { | ||
173 | return a >> 6 & 1; | ||
174 | } | ||
175 | |||
176 | static inline u16 i5100_mtr_numrow(u16 a) | ||
177 | { | ||
178 | return a >> 2 & ((1 << 2) - 1); | ||
179 | } | ||
180 | |||
181 | static inline u16 i5100_mtr_numcol(u16 a) | ||
182 | { | ||
183 | return a & ((1 << 2) - 1); | ||
184 | } | ||
185 | |||
186 | |||
187 | static inline u32 i5100_validlog_redmemvalid(u32 a) | ||
188 | { | ||
189 | return a >> 2 & 1; | ||
190 | } | ||
191 | |||
192 | static inline u32 i5100_validlog_recmemvalid(u32 a) | ||
193 | { | ||
194 | return a >> 1 & 1; | ||
195 | } | ||
196 | |||
197 | static inline u32 i5100_validlog_nrecmemvalid(u32 a) | ||
198 | { | ||
199 | return a & 1; | ||
200 | } | ||
201 | |||
202 | static inline u32 i5100_nrecmema_merr(u32 a) | ||
203 | { | ||
204 | return a >> 15 & ((1 << 5) - 1); | ||
205 | } | ||
206 | |||
207 | static inline u32 i5100_nrecmema_bank(u32 a) | ||
208 | { | ||
209 | return a >> 12 & ((1 << 3) - 1); | ||
210 | } | ||
211 | |||
212 | static inline u32 i5100_nrecmema_rank(u32 a) | ||
213 | { | ||
214 | return a >> 8 & ((1 << 3) - 1); | ||
215 | } | ||
216 | |||
217 | static inline u32 i5100_nrecmema_dm_buf_id(u32 a) | ||
218 | { | ||
219 | return a & ((1 << 8) - 1); | ||
220 | } | ||
221 | |||
222 | static inline u32 i5100_nrecmemb_cas(u32 a) | ||
223 | { | ||
224 | return a >> 16 & ((1 << 13) - 1); | ||
225 | } | ||
226 | |||
227 | static inline u32 i5100_nrecmemb_ras(u32 a) | ||
228 | { | ||
229 | return a & ((1 << 16) - 1); | ||
230 | } | ||
231 | |||
232 | static inline u32 i5100_redmemb_ecc_locator(u32 a) | ||
233 | { | ||
234 | return a & ((1 << 18) - 1); | ||
235 | } | ||
236 | |||
237 | static inline u32 i5100_recmema_merr(u32 a) | ||
238 | { | ||
239 | return i5100_nrecmema_merr(a); | ||
240 | } | ||
241 | |||
242 | static inline u32 i5100_recmema_bank(u32 a) | ||
243 | { | ||
244 | return i5100_nrecmema_bank(a); | ||
245 | } | ||
246 | |||
247 | static inline u32 i5100_recmema_rank(u32 a) | ||
248 | { | ||
249 | return i5100_nrecmema_rank(a); | ||
250 | } | ||
251 | |||
252 | static inline u32 i5100_recmema_dm_buf_id(u32 a) | ||
253 | { | ||
254 | return i5100_nrecmema_dm_buf_id(a); | ||
255 | } | ||
256 | |||
257 | static inline u32 i5100_recmemb_cas(u32 a) | ||
258 | { | ||
259 | return i5100_nrecmemb_cas(a); | ||
260 | } | ||
261 | |||
262 | static inline u32 i5100_recmemb_ras(u32 a) | ||
263 | { | ||
264 | return i5100_nrecmemb_ras(a); | ||
265 | } | ||
266 | |||
267 | /* some generic limits */ | ||
268 | #define I5100_MAX_RANKS_PER_CTLR 6 | ||
269 | #define I5100_MAX_CTLRS 2 | ||
270 | #define I5100_MAX_RANKS_PER_DIMM 4 | ||
271 | #define I5100_DIMM_ADDR_LINES (6 - 3) /* 64 bits / 8 bits per byte */ | ||
272 | #define I5100_MAX_DIMM_SLOTS_PER_CTLR 4 | ||
273 | #define I5100_MAX_RANK_INTERLEAVE 4 | ||
274 | #define I5100_MAX_DMIRS 5 | ||
275 | |||
276 | struct i5100_priv { | ||
277 | /* ranks on each dimm -- 0 maps to not present -- obtained via SPD */ | ||
278 | int dimm_numrank[I5100_MAX_CTLRS][I5100_MAX_DIMM_SLOTS_PER_CTLR]; | ||
279 | |||
280 | /* | ||
281 | * mainboard chip select map -- maps i5100 chip selects to | ||
282 | * DIMM slot chip selects. In the case of only 4 ranks per | ||
283 | * controller, the mapping is fairly obvious but not unique. | ||
284 | * we map -1 -> NC and assume both controllers use the same | ||
285 | * map... | ||
286 | * | ||
287 | */ | ||
288 | int dimm_csmap[I5100_MAX_DIMM_SLOTS_PER_CTLR][I5100_MAX_RANKS_PER_DIMM]; | ||
289 | |||
290 | /* memory interleave range */ | ||
291 | struct { | ||
292 | u64 limit; | ||
293 | unsigned way[2]; | ||
294 | } mir[I5100_MAX_CTLRS]; | ||
295 | |||
296 | /* adjusted memory interleave range register */ | ||
297 | unsigned amir[I5100_MAX_CTLRS]; | ||
298 | |||
299 | /* dimm interleave range */ | ||
300 | struct { | ||
301 | unsigned rank[I5100_MAX_RANK_INTERLEAVE]; | ||
302 | u64 limit; | ||
303 | } dmir[I5100_MAX_CTLRS][I5100_MAX_DMIRS]; | ||
304 | |||
305 | /* memory technology registers... */ | ||
306 | struct { | ||
307 | unsigned present; /* 0 or 1 */ | ||
308 | unsigned ethrottle; /* 0 or 1 */ | ||
309 | unsigned width; /* 4 or 8 bits */ | ||
310 | unsigned numbank; /* 2 or 3 lines */ | ||
311 | unsigned numrow; /* 13 .. 16 lines */ | ||
312 | unsigned numcol; /* 11 .. 12 lines */ | ||
313 | } mtr[I5100_MAX_CTLRS][I5100_MAX_RANKS_PER_CTLR]; | ||
314 | |||
315 | u64 tolm; /* top of low memory in bytes */ | ||
316 | unsigned ranksperctlr; /* number of ranks per controller */ | ||
317 | |||
318 | struct pci_dev *mc; /* device 16 func 1 */ | ||
319 | struct pci_dev *ch0mm; /* device 21 func 0 */ | ||
320 | struct pci_dev *ch1mm; /* device 22 func 0 */ | ||
321 | }; | ||
322 | |||
323 | /* map a rank/ctlr to a slot number on the mainboard */ | ||
324 | static int i5100_rank_to_slot(const struct mem_ctl_info *mci, | ||
325 | int ctlr, int rank) | ||
326 | { | ||
327 | const struct i5100_priv *priv = mci->pvt_info; | ||
328 | int i; | ||
329 | |||
330 | for (i = 0; i < I5100_MAX_DIMM_SLOTS_PER_CTLR; i++) { | ||
331 | int j; | ||
332 | const int numrank = priv->dimm_numrank[ctlr][i]; | ||
333 | |||
334 | for (j = 0; j < numrank; j++) | ||
335 | if (priv->dimm_csmap[i][j] == rank) | ||
336 | return i * 2 + ctlr; | ||
337 | } | ||
338 | |||
339 | return -1; | ||
340 | } | ||
341 | |||
342 | static const char *i5100_err_msg(unsigned err) | ||
343 | { | ||
344 | static const char *merrs[] = { | ||
345 | "unknown", /* 0 */ | ||
346 | "uncorrectable data ECC on replay", /* 1 */ | ||
347 | "unknown", /* 2 */ | ||
348 | "unknown", /* 3 */ | ||
349 | "aliased uncorrectable demand data ECC", /* 4 */ | ||
350 | "aliased uncorrectable spare-copy data ECC", /* 5 */ | ||
351 | "aliased uncorrectable patrol data ECC", /* 6 */ | ||
352 | "unknown", /* 7 */ | ||
353 | "unknown", /* 8 */ | ||
354 | "unknown", /* 9 */ | ||
355 | "non-aliased uncorrectable demand data ECC", /* 10 */ | ||
356 | "non-aliased uncorrectable spare-copy data ECC", /* 11 */ | ||
357 | "non-aliased uncorrectable patrol data ECC", /* 12 */ | ||
358 | "unknown", /* 13 */ | ||
359 | "correctable demand data ECC", /* 14 */ | ||
360 | "correctable spare-copy data ECC", /* 15 */ | ||
361 | "correctable patrol data ECC", /* 16 */ | ||
362 | "unknown", /* 17 */ | ||
363 | "SPD protocol error", /* 18 */ | ||
364 | "unknown", /* 19 */ | ||
365 | "spare copy initiated", /* 20 */ | ||
366 | "spare copy completed", /* 21 */ | ||
367 | }; | ||
368 | unsigned i; | ||
369 | |||
370 | for (i = 0; i < ARRAY_SIZE(merrs); i++) | ||
371 | if (1 << i & err) | ||
372 | return merrs[i]; | ||
373 | |||
374 | return "none"; | ||
375 | } | ||
376 | |||
377 | /* convert csrow index into a rank (per controller -- 0..5) */ | ||
378 | static int i5100_csrow_to_rank(const struct mem_ctl_info *mci, int csrow) | ||
379 | { | ||
380 | const struct i5100_priv *priv = mci->pvt_info; | ||
381 | |||
382 | return csrow % priv->ranksperctlr; | ||
383 | } | ||
384 | |||
385 | /* convert csrow index into a controller (0..1) */ | ||
386 | static int i5100_csrow_to_cntlr(const struct mem_ctl_info *mci, int csrow) | ||
387 | { | ||
388 | const struct i5100_priv *priv = mci->pvt_info; | ||
389 | |||
390 | return csrow / priv->ranksperctlr; | ||
391 | } | ||
392 | |||
393 | static unsigned i5100_rank_to_csrow(const struct mem_ctl_info *mci, | ||
394 | int ctlr, int rank) | ||
395 | { | ||
396 | const struct i5100_priv *priv = mci->pvt_info; | ||
397 | |||
398 | return ctlr * priv->ranksperctlr + rank; | ||
399 | } | ||
400 | |||
401 | static void i5100_handle_ce(struct mem_ctl_info *mci, | ||
402 | int ctlr, | ||
403 | unsigned bank, | ||
404 | unsigned rank, | ||
405 | unsigned long syndrome, | ||
406 | unsigned cas, | ||
407 | unsigned ras, | ||
408 | const char *msg) | ||
409 | { | ||
410 | const int csrow = i5100_rank_to_csrow(mci, ctlr, rank); | ||
411 | |||
412 | printk(KERN_ERR | ||
413 | "CE ctlr %d, bank %u, rank %u, syndrome 0x%lx, " | ||
414 | "cas %u, ras %u, csrow %u, label \"%s\": %s\n", | ||
415 | ctlr, bank, rank, syndrome, cas, ras, | ||
416 | csrow, mci->csrows[csrow].channels[0].label, msg); | ||
417 | |||
418 | mci->ce_count++; | ||
419 | mci->csrows[csrow].ce_count++; | ||
420 | mci->csrows[csrow].channels[0].ce_count++; | ||
421 | } | ||
422 | |||
423 | static void i5100_handle_ue(struct mem_ctl_info *mci, | ||
424 | int ctlr, | ||
425 | unsigned bank, | ||
426 | unsigned rank, | ||
427 | unsigned long syndrome, | ||
428 | unsigned cas, | ||
429 | unsigned ras, | ||
430 | const char *msg) | ||
431 | { | ||
432 | const int csrow = i5100_rank_to_csrow(mci, ctlr, rank); | ||
433 | |||
434 | printk(KERN_ERR | ||
435 | "UE ctlr %d, bank %u, rank %u, syndrome 0x%lx, " | ||
436 | "cas %u, ras %u, csrow %u, label \"%s\": %s\n", | ||
437 | ctlr, bank, rank, syndrome, cas, ras, | ||
438 | csrow, mci->csrows[csrow].channels[0].label, msg); | ||
439 | |||
440 | mci->ue_count++; | ||
441 | mci->csrows[csrow].ue_count++; | ||
442 | } | ||
443 | |||
444 | static void i5100_read_log(struct mem_ctl_info *mci, int ctlr, | ||
445 | u32 ferr, u32 nerr) | ||
446 | { | ||
447 | struct i5100_priv *priv = mci->pvt_info; | ||
448 | struct pci_dev *pdev = (ctlr) ? priv->ch1mm : priv->ch0mm; | ||
449 | u32 dw; | ||
450 | u32 dw2; | ||
451 | unsigned syndrome = 0; | ||
452 | unsigned ecc_loc = 0; | ||
453 | unsigned merr; | ||
454 | unsigned bank; | ||
455 | unsigned rank; | ||
456 | unsigned cas; | ||
457 | unsigned ras; | ||
458 | |||
459 | pci_read_config_dword(pdev, I5100_VALIDLOG, &dw); | ||
460 | |||
461 | if (i5100_validlog_redmemvalid(dw)) { | ||
462 | pci_read_config_dword(pdev, I5100_REDMEMA, &dw2); | ||
463 | syndrome = dw2; | ||
464 | pci_read_config_dword(pdev, I5100_REDMEMB, &dw2); | ||
465 | ecc_loc = i5100_redmemb_ecc_locator(dw2); | ||
466 | } | ||
467 | |||
468 | if (i5100_validlog_recmemvalid(dw)) { | ||
469 | const char *msg; | ||
470 | |||
471 | pci_read_config_dword(pdev, I5100_RECMEMA, &dw2); | ||
472 | merr = i5100_recmema_merr(dw2); | ||
473 | bank = i5100_recmema_bank(dw2); | ||
474 | rank = i5100_recmema_rank(dw2); | ||
475 | |||
476 | pci_read_config_dword(pdev, I5100_RECMEMB, &dw2); | ||
477 | cas = i5100_recmemb_cas(dw2); | ||
478 | ras = i5100_recmemb_ras(dw2); | ||
479 | |||
480 | /* FIXME: not really sure if this is what merr is... | ||
481 | */ | ||
482 | if (!merr) | ||
483 | msg = i5100_err_msg(ferr); | ||
484 | else | ||
485 | msg = i5100_err_msg(nerr); | ||
486 | |||
487 | i5100_handle_ce(mci, ctlr, bank, rank, syndrome, cas, ras, msg); | ||
488 | } | ||
489 | |||
490 | if (i5100_validlog_nrecmemvalid(dw)) { | ||
491 | const char *msg; | ||
492 | |||
493 | pci_read_config_dword(pdev, I5100_NRECMEMA, &dw2); | ||
494 | merr = i5100_nrecmema_merr(dw2); | ||
495 | bank = i5100_nrecmema_bank(dw2); | ||
496 | rank = i5100_nrecmema_rank(dw2); | ||
497 | |||
498 | pci_read_config_dword(pdev, I5100_NRECMEMB, &dw2); | ||
499 | cas = i5100_nrecmemb_cas(dw2); | ||
500 | ras = i5100_nrecmemb_ras(dw2); | ||
501 | |||
502 | /* FIXME: not really sure if this is what merr is... | ||
503 | */ | ||
504 | if (!merr) | ||
505 | msg = i5100_err_msg(ferr); | ||
506 | else | ||
507 | msg = i5100_err_msg(nerr); | ||
508 | |||
509 | i5100_handle_ue(mci, ctlr, bank, rank, syndrome, cas, ras, msg); | ||
510 | } | ||
511 | |||
512 | pci_write_config_dword(pdev, I5100_VALIDLOG, dw); | ||
513 | } | ||
514 | |||
515 | static void i5100_check_error(struct mem_ctl_info *mci) | ||
516 | { | ||
517 | struct i5100_priv *priv = mci->pvt_info; | ||
518 | u32 dw; | ||
519 | |||
520 | |||
521 | pci_read_config_dword(priv->mc, I5100_FERR_NF_MEM, &dw); | ||
522 | if (i5100_ferr_nf_mem_any(dw)) { | ||
523 | u32 dw2; | ||
524 | |||
525 | pci_read_config_dword(priv->mc, I5100_NERR_NF_MEM, &dw2); | ||
526 | if (dw2) | ||
527 | pci_write_config_dword(priv->mc, I5100_NERR_NF_MEM, | ||
528 | dw2); | ||
529 | pci_write_config_dword(priv->mc, I5100_FERR_NF_MEM, dw); | ||
530 | |||
531 | i5100_read_log(mci, i5100_ferr_nf_mem_chan_indx(dw), | ||
532 | i5100_ferr_nf_mem_any(dw), | ||
533 | i5100_nerr_nf_mem_any(dw2)); | ||
534 | } | ||
535 | } | ||
536 | |||
537 | static struct pci_dev *pci_get_device_func(unsigned vendor, | ||
538 | unsigned device, | ||
539 | unsigned func) | ||
540 | { | ||
541 | struct pci_dev *ret = NULL; | ||
542 | |||
543 | while (1) { | ||
544 | ret = pci_get_device(vendor, device, ret); | ||
545 | |||
546 | if (!ret) | ||
547 | break; | ||
548 | |||
549 | if (PCI_FUNC(ret->devfn) == func) | ||
550 | break; | ||
551 | } | ||
552 | |||
553 | return ret; | ||
554 | } | ||
555 | |||
556 | static unsigned long __devinit i5100_npages(struct mem_ctl_info *mci, | ||
557 | int csrow) | ||
558 | { | ||
559 | struct i5100_priv *priv = mci->pvt_info; | ||
560 | const unsigned ctlr_rank = i5100_csrow_to_rank(mci, csrow); | ||
561 | const unsigned ctlr = i5100_csrow_to_cntlr(mci, csrow); | ||
562 | unsigned addr_lines; | ||
563 | |||
564 | /* dimm present? */ | ||
565 | if (!priv->mtr[ctlr][ctlr_rank].present) | ||
566 | return 0ULL; | ||
567 | |||
568 | addr_lines = | ||
569 | I5100_DIMM_ADDR_LINES + | ||
570 | priv->mtr[ctlr][ctlr_rank].numcol + | ||
571 | priv->mtr[ctlr][ctlr_rank].numrow + | ||
572 | priv->mtr[ctlr][ctlr_rank].numbank; | ||
573 | |||
574 | return (unsigned long) | ||
575 | ((unsigned long long) (1ULL << addr_lines) / PAGE_SIZE); | ||
576 | } | ||
577 | |||
578 | static void __devinit i5100_init_mtr(struct mem_ctl_info *mci) | ||
579 | { | ||
580 | struct i5100_priv *priv = mci->pvt_info; | ||
581 | struct pci_dev *mms[2] = { priv->ch0mm, priv->ch1mm }; | ||
582 | int i; | ||
583 | |||
584 | for (i = 0; i < I5100_MAX_CTLRS; i++) { | ||
585 | int j; | ||
586 | struct pci_dev *pdev = mms[i]; | ||
587 | |||
588 | for (j = 0; j < I5100_MAX_RANKS_PER_CTLR; j++) { | ||
589 | const unsigned addr = | ||
590 | (j < 4) ? I5100_MTR_0 + j * 2 : | ||
591 | I5100_MTR_4 + (j - 4) * 2; | ||
592 | u16 w; | ||
593 | |||
594 | pci_read_config_word(pdev, addr, &w); | ||
595 | |||
596 | priv->mtr[i][j].present = i5100_mtr_present(w); | ||
597 | priv->mtr[i][j].ethrottle = i5100_mtr_ethrottle(w); | ||
598 | priv->mtr[i][j].width = 4 + 4 * i5100_mtr_width(w); | ||
599 | priv->mtr[i][j].numbank = 2 + i5100_mtr_numbank(w); | ||
600 | priv->mtr[i][j].numrow = 13 + i5100_mtr_numrow(w); | ||
601 | priv->mtr[i][j].numcol = 10 + i5100_mtr_numcol(w); | ||
602 | } | ||
603 | } | ||
604 | } | ||
605 | |||
606 | /* | ||
607 | * FIXME: make this into a real i2c adapter (so that dimm-decode | ||
608 | * will work)? | ||
609 | */ | ||
610 | static int i5100_read_spd_byte(const struct mem_ctl_info *mci, | ||
611 | u8 ch, u8 slot, u8 addr, u8 *byte) | ||
612 | { | ||
613 | struct i5100_priv *priv = mci->pvt_info; | ||
614 | u16 w; | ||
615 | unsigned long et; | ||
616 | |||
617 | pci_read_config_word(priv->mc, I5100_SPDDATA, &w); | ||
618 | if (i5100_spddata_busy(w)) | ||
619 | return -1; | ||
620 | |||
621 | pci_write_config_dword(priv->mc, I5100_SPDCMD, | ||
622 | i5100_spdcmd_create(0xa, 1, ch * 4 + slot, addr, | ||
623 | 0, 0)); | ||
624 | |||
625 | /* wait up to 100ms */ | ||
626 | et = jiffies + HZ / 10; | ||
627 | udelay(100); | ||
628 | while (1) { | ||
629 | pci_read_config_word(priv->mc, I5100_SPDDATA, &w); | ||
630 | if (!i5100_spddata_busy(w)) | ||
631 | break; | ||
632 | udelay(100); | ||
633 | } | ||
634 | |||
635 | if (!i5100_spddata_rdo(w) || i5100_spddata_sbe(w)) | ||
636 | return -1; | ||
637 | |||
638 | *byte = i5100_spddata_data(w); | ||
639 | |||
640 | return 0; | ||
641 | } | ||
642 | |||
643 | /* | ||
644 | * fill dimm chip select map | ||
645 | * | ||
646 | * FIXME: | ||
647 | * o only valid for 4 ranks per controller | ||
648 | * o not the only way to may chip selects to dimm slots | ||
649 | * o investigate if there is some way to obtain this map from the bios | ||
650 | */ | ||
651 | static void __devinit i5100_init_dimm_csmap(struct mem_ctl_info *mci) | ||
652 | { | ||
653 | struct i5100_priv *priv = mci->pvt_info; | ||
654 | int i; | ||
655 | |||
656 | WARN_ON(priv->ranksperctlr != 4); | ||
657 | |||
658 | for (i = 0; i < I5100_MAX_DIMM_SLOTS_PER_CTLR; i++) { | ||
659 | int j; | ||
660 | |||
661 | for (j = 0; j < I5100_MAX_RANKS_PER_DIMM; j++) | ||
662 | priv->dimm_csmap[i][j] = -1; /* default NC */ | ||
663 | } | ||
664 | |||
665 | /* only 2 chip selects per slot... */ | ||
666 | priv->dimm_csmap[0][0] = 0; | ||
667 | priv->dimm_csmap[0][1] = 3; | ||
668 | priv->dimm_csmap[1][0] = 1; | ||
669 | priv->dimm_csmap[1][1] = 2; | ||
670 | priv->dimm_csmap[2][0] = 2; | ||
671 | priv->dimm_csmap[3][0] = 3; | ||
672 | } | ||
673 | |||
674 | static void __devinit i5100_init_dimm_layout(struct pci_dev *pdev, | ||
675 | struct mem_ctl_info *mci) | ||
676 | { | ||
677 | struct i5100_priv *priv = mci->pvt_info; | ||
678 | int i; | ||
679 | |||
680 | for (i = 0; i < I5100_MAX_CTLRS; i++) { | ||
681 | int j; | ||
682 | |||
683 | for (j = 0; j < I5100_MAX_DIMM_SLOTS_PER_CTLR; j++) { | ||
684 | u8 rank; | ||
685 | |||
686 | if (i5100_read_spd_byte(mci, i, j, 5, &rank) < 0) | ||
687 | priv->dimm_numrank[i][j] = 0; | ||
688 | else | ||
689 | priv->dimm_numrank[i][j] = (rank & 3) + 1; | ||
690 | } | ||
691 | } | ||
692 | |||
693 | i5100_init_dimm_csmap(mci); | ||
694 | } | ||
695 | |||
696 | static void __devinit i5100_init_interleaving(struct pci_dev *pdev, | ||
697 | struct mem_ctl_info *mci) | ||
698 | { | ||
699 | u16 w; | ||
700 | u32 dw; | ||
701 | struct i5100_priv *priv = mci->pvt_info; | ||
702 | struct pci_dev *mms[2] = { priv->ch0mm, priv->ch1mm }; | ||
703 | int i; | ||
704 | |||
705 | pci_read_config_word(pdev, I5100_TOLM, &w); | ||
706 | priv->tolm = (u64) i5100_tolm_tolm(w) * 256 * 1024 * 1024; | ||
707 | |||
708 | pci_read_config_word(pdev, I5100_MIR0, &w); | ||
709 | priv->mir[0].limit = (u64) i5100_mir_limit(w) << 28; | ||
710 | priv->mir[0].way[1] = i5100_mir_way1(w); | ||
711 | priv->mir[0].way[0] = i5100_mir_way0(w); | ||
712 | |||
713 | pci_read_config_word(pdev, I5100_MIR1, &w); | ||
714 | priv->mir[1].limit = (u64) i5100_mir_limit(w) << 28; | ||
715 | priv->mir[1].way[1] = i5100_mir_way1(w); | ||
716 | priv->mir[1].way[0] = i5100_mir_way0(w); | ||
717 | |||
718 | pci_read_config_word(pdev, I5100_AMIR_0, &w); | ||
719 | priv->amir[0] = w; | ||
720 | pci_read_config_word(pdev, I5100_AMIR_1, &w); | ||
721 | priv->amir[1] = w; | ||
722 | |||
723 | for (i = 0; i < I5100_MAX_CTLRS; i++) { | ||
724 | int j; | ||
725 | |||
726 | for (j = 0; j < 5; j++) { | ||
727 | int k; | ||
728 | |||
729 | pci_read_config_dword(mms[i], I5100_DMIR + j * 4, &dw); | ||
730 | |||
731 | priv->dmir[i][j].limit = | ||
732 | (u64) i5100_dmir_limit(dw) << 28; | ||
733 | for (k = 0; k < I5100_MAX_RANKS_PER_DIMM; k++) | ||
734 | priv->dmir[i][j].rank[k] = | ||
735 | i5100_dmir_rank(dw, k); | ||
736 | } | ||
737 | } | ||
738 | |||
739 | i5100_init_mtr(mci); | ||
740 | } | ||
741 | |||
742 | static void __devinit i5100_init_csrows(struct mem_ctl_info *mci) | ||
743 | { | ||
744 | int i; | ||
745 | unsigned long total_pages = 0UL; | ||
746 | struct i5100_priv *priv = mci->pvt_info; | ||
747 | |||
748 | for (i = 0; i < mci->nr_csrows; i++) { | ||
749 | const unsigned long npages = i5100_npages(mci, i); | ||
750 | const unsigned cntlr = i5100_csrow_to_cntlr(mci, i); | ||
751 | const unsigned rank = i5100_csrow_to_rank(mci, i); | ||
752 | |||
753 | if (!npages) | ||
754 | continue; | ||
755 | |||
756 | /* | ||
757 | * FIXME: these two are totally bogus -- I don't see how to | ||
758 | * map them correctly to this structure... | ||
759 | */ | ||
760 | mci->csrows[i].first_page = total_pages; | ||
761 | mci->csrows[i].last_page = total_pages + npages - 1; | ||
762 | mci->csrows[i].page_mask = 0UL; | ||
763 | |||
764 | mci->csrows[i].nr_pages = npages; | ||
765 | mci->csrows[i].grain = 32; | ||
766 | mci->csrows[i].csrow_idx = i; | ||
767 | mci->csrows[i].dtype = | ||
768 | (priv->mtr[cntlr][rank].width == 4) ? DEV_X4 : DEV_X8; | ||
769 | mci->csrows[i].ue_count = 0; | ||
770 | mci->csrows[i].ce_count = 0; | ||
771 | mci->csrows[i].mtype = MEM_RDDR2; | ||
772 | mci->csrows[i].edac_mode = EDAC_SECDED; | ||
773 | mci->csrows[i].mci = mci; | ||
774 | mci->csrows[i].nr_channels = 1; | ||
775 | mci->csrows[i].channels[0].chan_idx = 0; | ||
776 | mci->csrows[i].channels[0].ce_count = 0; | ||
777 | mci->csrows[i].channels[0].csrow = mci->csrows + i; | ||
778 | snprintf(mci->csrows[i].channels[0].label, | ||
779 | sizeof(mci->csrows[i].channels[0].label), | ||
780 | "DIMM%u", i5100_rank_to_slot(mci, cntlr, rank)); | ||
781 | |||
782 | total_pages += npages; | ||
783 | } | ||
784 | } | ||
785 | |||
786 | static int __devinit i5100_init_one(struct pci_dev *pdev, | ||
787 | const struct pci_device_id *id) | ||
788 | { | ||
789 | int rc; | ||
790 | struct mem_ctl_info *mci; | ||
791 | struct i5100_priv *priv; | ||
792 | struct pci_dev *ch0mm, *ch1mm; | ||
793 | int ret = 0; | ||
794 | u32 dw; | ||
795 | int ranksperch; | ||
796 | |||
797 | if (PCI_FUNC(pdev->devfn) != 1) | ||
798 | return -ENODEV; | ||
799 | |||
800 | rc = pci_enable_device(pdev); | ||
801 | if (rc < 0) { | ||
802 | ret = rc; | ||
803 | goto bail; | ||
804 | } | ||
805 | |||
806 | /* ECC enabled? */ | ||
807 | pci_read_config_dword(pdev, I5100_MC, &dw); | ||
808 | if (!i5100_mc_errdeten(dw)) { | ||
809 | printk(KERN_INFO "i5100_edac: ECC not enabled.\n"); | ||
810 | ret = -ENODEV; | ||
811 | goto bail_pdev; | ||
812 | } | ||
813 | |||
814 | /* figure out how many ranks, from strapped state of 48GB_Mode input */ | ||
815 | pci_read_config_dword(pdev, I5100_MS, &dw); | ||
816 | ranksperch = !!(dw & (1 << 8)) * 2 + 4; | ||
817 | |||
818 | if (ranksperch != 4) { | ||
819 | /* FIXME: get 6 ranks / controller to work - need hw... */ | ||
820 | printk(KERN_INFO "i5100_edac: unsupported configuration.\n"); | ||
821 | ret = -ENODEV; | ||
822 | goto bail_pdev; | ||
823 | } | ||
824 | |||
825 | /* enable error reporting... */ | ||
826 | pci_read_config_dword(pdev, I5100_EMASK_MEM, &dw); | ||
827 | dw &= ~I5100_FERR_NF_MEM_ANY_MASK; | ||
828 | pci_write_config_dword(pdev, I5100_EMASK_MEM, dw); | ||
829 | |||
830 | /* device 21, func 0, Channel 0 Memory Map, Error Flag/Mask, etc... */ | ||
831 | ch0mm = pci_get_device_func(PCI_VENDOR_ID_INTEL, | ||
832 | PCI_DEVICE_ID_INTEL_5100_21, 0); | ||
833 | if (!ch0mm) { | ||
834 | ret = -ENODEV; | ||
835 | goto bail_pdev; | ||
836 | } | ||
837 | |||
838 | rc = pci_enable_device(ch0mm); | ||
839 | if (rc < 0) { | ||
840 | ret = rc; | ||
841 | goto bail_ch0; | ||
842 | } | ||
843 | |||
844 | /* device 22, func 0, Channel 1 Memory Map, Error Flag/Mask, etc... */ | ||
845 | ch1mm = pci_get_device_func(PCI_VENDOR_ID_INTEL, | ||
846 | PCI_DEVICE_ID_INTEL_5100_22, 0); | ||
847 | if (!ch1mm) { | ||
848 | ret = -ENODEV; | ||
849 | goto bail_disable_ch0; | ||
850 | } | ||
851 | |||
852 | rc = pci_enable_device(ch1mm); | ||
853 | if (rc < 0) { | ||
854 | ret = rc; | ||
855 | goto bail_ch1; | ||
856 | } | ||
857 | |||
858 | mci = edac_mc_alloc(sizeof(*priv), ranksperch * 2, 1, 0); | ||
859 | if (!mci) { | ||
860 | ret = -ENOMEM; | ||
861 | goto bail_disable_ch1; | ||
862 | } | ||
863 | |||
864 | mci->dev = &pdev->dev; | ||
865 | |||
866 | priv = mci->pvt_info; | ||
867 | priv->ranksperctlr = ranksperch; | ||
868 | priv->mc = pdev; | ||
869 | priv->ch0mm = ch0mm; | ||
870 | priv->ch1mm = ch1mm; | ||
871 | |||
872 | i5100_init_dimm_layout(pdev, mci); | ||
873 | i5100_init_interleaving(pdev, mci); | ||
874 | |||
875 | mci->mtype_cap = MEM_FLAG_FB_DDR2; | ||
876 | mci->edac_ctl_cap = EDAC_FLAG_SECDED; | ||
877 | mci->edac_cap = EDAC_FLAG_SECDED; | ||
878 | mci->mod_name = "i5100_edac.c"; | ||
879 | mci->mod_ver = "not versioned"; | ||
880 | mci->ctl_name = "i5100"; | ||
881 | mci->dev_name = pci_name(pdev); | ||
882 | mci->ctl_page_to_phys = NULL; | ||
883 | |||
884 | mci->edac_check = i5100_check_error; | ||
885 | |||
886 | i5100_init_csrows(mci); | ||
887 | |||
888 | /* this strange construction seems to be in every driver, dunno why */ | ||
889 | switch (edac_op_state) { | ||
890 | case EDAC_OPSTATE_POLL: | ||
891 | case EDAC_OPSTATE_NMI: | ||
892 | break; | ||
893 | default: | ||
894 | edac_op_state = EDAC_OPSTATE_POLL; | ||
895 | break; | ||
896 | } | ||
897 | |||
898 | if (edac_mc_add_mc(mci)) { | ||
899 | ret = -ENODEV; | ||
900 | goto bail_mc; | ||
901 | } | ||
902 | |||
903 | return ret; | ||
904 | |||
905 | bail_mc: | ||
906 | edac_mc_free(mci); | ||
907 | |||
908 | bail_disable_ch1: | ||
909 | pci_disable_device(ch1mm); | ||
910 | |||
911 | bail_ch1: | ||
912 | pci_dev_put(ch1mm); | ||
913 | |||
914 | bail_disable_ch0: | ||
915 | pci_disable_device(ch0mm); | ||
916 | |||
917 | bail_ch0: | ||
918 | pci_dev_put(ch0mm); | ||
919 | |||
920 | bail_pdev: | ||
921 | pci_disable_device(pdev); | ||
922 | |||
923 | bail: | ||
924 | return ret; | ||
925 | } | ||
926 | |||
927 | static void __devexit i5100_remove_one(struct pci_dev *pdev) | ||
928 | { | ||
929 | struct mem_ctl_info *mci; | ||
930 | struct i5100_priv *priv; | ||
931 | |||
932 | mci = edac_mc_del_mc(&pdev->dev); | ||
933 | |||
934 | if (!mci) | ||
935 | return; | ||
936 | |||
937 | priv = mci->pvt_info; | ||
938 | pci_disable_device(pdev); | ||
939 | pci_disable_device(priv->ch0mm); | ||
940 | pci_disable_device(priv->ch1mm); | ||
941 | pci_dev_put(priv->ch0mm); | ||
942 | pci_dev_put(priv->ch1mm); | ||
943 | |||
944 | edac_mc_free(mci); | ||
945 | } | ||
946 | |||
947 | static const struct pci_device_id i5100_pci_tbl[] __devinitdata = { | ||
948 | /* Device 16, Function 0, Channel 0 Memory Map, Error Flag/Mask, ... */ | ||
949 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5100_16) }, | ||
950 | { 0, } | ||
951 | }; | ||
952 | MODULE_DEVICE_TABLE(pci, i5100_pci_tbl); | ||
953 | |||
954 | static struct pci_driver i5100_driver = { | ||
955 | .name = KBUILD_BASENAME, | ||
956 | .probe = i5100_init_one, | ||
957 | .remove = __devexit_p(i5100_remove_one), | ||
958 | .id_table = i5100_pci_tbl, | ||
959 | }; | ||
960 | |||
961 | static int __init i5100_init(void) | ||
962 | { | ||
963 | int pci_rc; | ||
964 | |||
965 | pci_rc = pci_register_driver(&i5100_driver); | ||
966 | |||
967 | return (pci_rc < 0) ? pci_rc : 0; | ||
968 | } | ||
969 | |||
970 | static void __exit i5100_exit(void) | ||
971 | { | ||
972 | pci_unregister_driver(&i5100_driver); | ||
973 | } | ||
974 | |||
975 | module_init(i5100_init); | ||
976 | module_exit(i5100_exit); | ||
977 | |||
978 | MODULE_LICENSE("GPL"); | ||
979 | MODULE_AUTHOR | ||
980 | ("Arthur Jones <ajones@riverbed.com>"); | ||
981 | MODULE_DESCRIPTION("MC Driver for Intel I5100 memory controllers"); | ||
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c index d49361bfe670..2265d9ca1535 100644 --- a/drivers/edac/mpc85xx_edac.c +++ b/drivers/edac/mpc85xx_edac.c | |||
@@ -195,14 +195,15 @@ static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id) | |||
195 | return IRQ_HANDLED; | 195 | return IRQ_HANDLED; |
196 | } | 196 | } |
197 | 197 | ||
198 | static int __devinit mpc85xx_pci_err_probe(struct platform_device *pdev) | 198 | static int __devinit mpc85xx_pci_err_probe(struct of_device *op, |
199 | const struct of_device_id *match) | ||
199 | { | 200 | { |
200 | struct edac_pci_ctl_info *pci; | 201 | struct edac_pci_ctl_info *pci; |
201 | struct mpc85xx_pci_pdata *pdata; | 202 | struct mpc85xx_pci_pdata *pdata; |
202 | struct resource *r; | 203 | struct resource r; |
203 | int res = 0; | 204 | int res = 0; |
204 | 205 | ||
205 | if (!devres_open_group(&pdev->dev, mpc85xx_pci_err_probe, GFP_KERNEL)) | 206 | if (!devres_open_group(&op->dev, mpc85xx_pci_err_probe, GFP_KERNEL)) |
206 | return -ENOMEM; | 207 | return -ENOMEM; |
207 | 208 | ||
208 | pci = edac_pci_alloc_ctl_info(sizeof(*pdata), "mpc85xx_pci_err"); | 209 | pci = edac_pci_alloc_ctl_info(sizeof(*pdata), "mpc85xx_pci_err"); |
@@ -212,34 +213,37 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *pdev) | |||
212 | pdata = pci->pvt_info; | 213 | pdata = pci->pvt_info; |
213 | pdata->name = "mpc85xx_pci_err"; | 214 | pdata->name = "mpc85xx_pci_err"; |
214 | pdata->irq = NO_IRQ; | 215 | pdata->irq = NO_IRQ; |
215 | platform_set_drvdata(pdev, pci); | 216 | dev_set_drvdata(&op->dev, pci); |
216 | pci->dev = &pdev->dev; | 217 | pci->dev = &op->dev; |
217 | pci->mod_name = EDAC_MOD_STR; | 218 | pci->mod_name = EDAC_MOD_STR; |
218 | pci->ctl_name = pdata->name; | 219 | pci->ctl_name = pdata->name; |
219 | pci->dev_name = pdev->dev.bus_id; | 220 | pci->dev_name = op->dev.bus_id; |
220 | 221 | ||
221 | if (edac_op_state == EDAC_OPSTATE_POLL) | 222 | if (edac_op_state == EDAC_OPSTATE_POLL) |
222 | pci->edac_check = mpc85xx_pci_check; | 223 | pci->edac_check = mpc85xx_pci_check; |
223 | 224 | ||
224 | pdata->edac_idx = edac_pci_idx++; | 225 | pdata->edac_idx = edac_pci_idx++; |
225 | 226 | ||
226 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 227 | res = of_address_to_resource(op->node, 0, &r); |
227 | if (!r) { | 228 | if (res) { |
228 | printk(KERN_ERR "%s: Unable to get resource for " | 229 | printk(KERN_ERR "%s: Unable to get resource for " |
229 | "PCI err regs\n", __func__); | 230 | "PCI err regs\n", __func__); |
230 | goto err; | 231 | goto err; |
231 | } | 232 | } |
232 | 233 | ||
233 | if (!devm_request_mem_region(&pdev->dev, r->start, | 234 | /* we only need the error registers */ |
234 | r->end - r->start + 1, pdata->name)) { | 235 | r.start += 0xe00; |
236 | |||
237 | if (!devm_request_mem_region(&op->dev, r.start, | ||
238 | r.end - r.start + 1, pdata->name)) { | ||
235 | printk(KERN_ERR "%s: Error while requesting mem region\n", | 239 | printk(KERN_ERR "%s: Error while requesting mem region\n", |
236 | __func__); | 240 | __func__); |
237 | res = -EBUSY; | 241 | res = -EBUSY; |
238 | goto err; | 242 | goto err; |
239 | } | 243 | } |
240 | 244 | ||
241 | pdata->pci_vbase = devm_ioremap(&pdev->dev, r->start, | 245 | pdata->pci_vbase = devm_ioremap(&op->dev, r.start, |
242 | r->end - r->start + 1); | 246 | r.end - r.start + 1); |
243 | if (!pdata->pci_vbase) { | 247 | if (!pdata->pci_vbase) { |
244 | printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__); | 248 | printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__); |
245 | res = -ENOMEM; | 249 | res = -ENOMEM; |
@@ -266,14 +270,15 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *pdev) | |||
266 | } | 270 | } |
267 | 271 | ||
268 | if (edac_op_state == EDAC_OPSTATE_INT) { | 272 | if (edac_op_state == EDAC_OPSTATE_INT) { |
269 | pdata->irq = platform_get_irq(pdev, 0); | 273 | pdata->irq = irq_of_parse_and_map(op->node, 0); |
270 | res = devm_request_irq(&pdev->dev, pdata->irq, | 274 | res = devm_request_irq(&op->dev, pdata->irq, |
271 | mpc85xx_pci_isr, IRQF_DISABLED, | 275 | mpc85xx_pci_isr, IRQF_DISABLED, |
272 | "[EDAC] PCI err", pci); | 276 | "[EDAC] PCI err", pci); |
273 | if (res < 0) { | 277 | if (res < 0) { |
274 | printk(KERN_ERR | 278 | printk(KERN_ERR |
275 | "%s: Unable to requiest irq %d for " | 279 | "%s: Unable to requiest irq %d for " |
276 | "MPC85xx PCI err\n", __func__, pdata->irq); | 280 | "MPC85xx PCI err\n", __func__, pdata->irq); |
281 | irq_dispose_mapping(pdata->irq); | ||
277 | res = -ENODEV; | 282 | res = -ENODEV; |
278 | goto err2; | 283 | goto err2; |
279 | } | 284 | } |
@@ -282,23 +287,23 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *pdev) | |||
282 | pdata->irq); | 287 | pdata->irq); |
283 | } | 288 | } |
284 | 289 | ||
285 | devres_remove_group(&pdev->dev, mpc85xx_pci_err_probe); | 290 | devres_remove_group(&op->dev, mpc85xx_pci_err_probe); |
286 | debugf3("%s(): success\n", __func__); | 291 | debugf3("%s(): success\n", __func__); |
287 | printk(KERN_INFO EDAC_MOD_STR " PCI err registered\n"); | 292 | printk(KERN_INFO EDAC_MOD_STR " PCI err registered\n"); |
288 | 293 | ||
289 | return 0; | 294 | return 0; |
290 | 295 | ||
291 | err2: | 296 | err2: |
292 | edac_pci_del_device(&pdev->dev); | 297 | edac_pci_del_device(&op->dev); |
293 | err: | 298 | err: |
294 | edac_pci_free_ctl_info(pci); | 299 | edac_pci_free_ctl_info(pci); |
295 | devres_release_group(&pdev->dev, mpc85xx_pci_err_probe); | 300 | devres_release_group(&op->dev, mpc85xx_pci_err_probe); |
296 | return res; | 301 | return res; |
297 | } | 302 | } |
298 | 303 | ||
299 | static int mpc85xx_pci_err_remove(struct platform_device *pdev) | 304 | static int mpc85xx_pci_err_remove(struct of_device *op) |
300 | { | 305 | { |
301 | struct edac_pci_ctl_info *pci = platform_get_drvdata(pdev); | 306 | struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev); |
302 | struct mpc85xx_pci_pdata *pdata = pci->pvt_info; | 307 | struct mpc85xx_pci_pdata *pdata = pci->pvt_info; |
303 | 308 | ||
304 | debugf0("%s()\n", __func__); | 309 | debugf0("%s()\n", __func__); |
@@ -318,12 +323,26 @@ static int mpc85xx_pci_err_remove(struct platform_device *pdev) | |||
318 | return 0; | 323 | return 0; |
319 | } | 324 | } |
320 | 325 | ||
321 | static struct platform_driver mpc85xx_pci_err_driver = { | 326 | static struct of_device_id mpc85xx_pci_err_of_match[] = { |
327 | { | ||
328 | .compatible = "fsl,mpc8540-pcix", | ||
329 | }, | ||
330 | { | ||
331 | .compatible = "fsl,mpc8540-pci", | ||
332 | }, | ||
333 | {}, | ||
334 | }; | ||
335 | |||
336 | static struct of_platform_driver mpc85xx_pci_err_driver = { | ||
337 | .owner = THIS_MODULE, | ||
338 | .name = "mpc85xx_pci_err", | ||
339 | .match_table = mpc85xx_pci_err_of_match, | ||
322 | .probe = mpc85xx_pci_err_probe, | 340 | .probe = mpc85xx_pci_err_probe, |
323 | .remove = __devexit_p(mpc85xx_pci_err_remove), | 341 | .remove = __devexit_p(mpc85xx_pci_err_remove), |
324 | .driver = { | 342 | .driver = { |
325 | .name = "mpc85xx_pci_err", | 343 | .name = "mpc85xx_pci_err", |
326 | } | 344 | .owner = THIS_MODULE, |
345 | }, | ||
327 | }; | 346 | }; |
328 | 347 | ||
329 | #endif /* CONFIG_PCI */ | 348 | #endif /* CONFIG_PCI */ |
@@ -1002,7 +1021,7 @@ static int __init mpc85xx_mc_init(void) | |||
1002 | printk(KERN_WARNING EDAC_MOD_STR "L2 fails to register\n"); | 1021 | printk(KERN_WARNING EDAC_MOD_STR "L2 fails to register\n"); |
1003 | 1022 | ||
1004 | #ifdef CONFIG_PCI | 1023 | #ifdef CONFIG_PCI |
1005 | res = platform_driver_register(&mpc85xx_pci_err_driver); | 1024 | res = of_register_platform_driver(&mpc85xx_pci_err_driver); |
1006 | if (res) | 1025 | if (res) |
1007 | printk(KERN_WARNING EDAC_MOD_STR "PCI fails to register\n"); | 1026 | printk(KERN_WARNING EDAC_MOD_STR "PCI fails to register\n"); |
1008 | #endif | 1027 | #endif |
@@ -1025,7 +1044,7 @@ static void __exit mpc85xx_mc_exit(void) | |||
1025 | { | 1044 | { |
1026 | mtspr(SPRN_HID1, orig_hid1); | 1045 | mtspr(SPRN_HID1, orig_hid1); |
1027 | #ifdef CONFIG_PCI | 1046 | #ifdef CONFIG_PCI |
1028 | platform_driver_unregister(&mpc85xx_pci_err_driver); | 1047 | of_unregister_platform_driver(&mpc85xx_pci_err_driver); |
1029 | #endif | 1048 | #endif |
1030 | of_unregister_platform_driver(&mpc85xx_l2_err_driver); | 1049 | of_unregister_platform_driver(&mpc85xx_l2_err_driver); |
1031 | of_unregister_platform_driver(&mpc85xx_mc_err_driver); | 1050 | of_unregister_platform_driver(&mpc85xx_mc_err_driver); |
diff --git a/drivers/edac/mv64x60_edac.c b/drivers/edac/mv64x60_edac.c index bf071f140a05..083ce8d0c63d 100644 --- a/drivers/edac/mv64x60_edac.c +++ b/drivers/edac/mv64x60_edac.c | |||
@@ -71,6 +71,35 @@ static irqreturn_t mv64x60_pci_isr(int irq, void *dev_id) | |||
71 | return IRQ_HANDLED; | 71 | return IRQ_HANDLED; |
72 | } | 72 | } |
73 | 73 | ||
74 | /* | ||
75 | * Bit 0 of MV64x60_PCIx_ERR_MASK does not exist on the 64360 and because of | ||
76 | * errata FEr-#11 and FEr-##16 for the 64460, it should be 0 on that chip as | ||
77 | * well. IOW, don't set bit 0. | ||
78 | */ | ||
79 | |||
80 | /* Erratum FEr PCI-#16: clear bit 0 of PCI SERRn Mask reg. */ | ||
81 | static int __init mv64x60_pci_fixup(struct platform_device *pdev) | ||
82 | { | ||
83 | struct resource *r; | ||
84 | void __iomem *pci_serr; | ||
85 | |||
86 | r = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
87 | if (!r) { | ||
88 | printk(KERN_ERR "%s: Unable to get resource for " | ||
89 | "PCI err regs\n", __func__); | ||
90 | return -ENOENT; | ||
91 | } | ||
92 | |||
93 | pci_serr = ioremap(r->start, r->end - r->start + 1); | ||
94 | if (!pci_serr) | ||
95 | return -ENOMEM; | ||
96 | |||
97 | out_le32(pci_serr, in_le32(pci_serr) & ~0x1); | ||
98 | iounmap(pci_serr); | ||
99 | |||
100 | return 0; | ||
101 | } | ||
102 | |||
74 | static int __devinit mv64x60_pci_err_probe(struct platform_device *pdev) | 103 | static int __devinit mv64x60_pci_err_probe(struct platform_device *pdev) |
75 | { | 104 | { |
76 | struct edac_pci_ctl_info *pci; | 105 | struct edac_pci_ctl_info *pci; |
@@ -128,6 +157,12 @@ static int __devinit mv64x60_pci_err_probe(struct platform_device *pdev) | |||
128 | goto err; | 157 | goto err; |
129 | } | 158 | } |
130 | 159 | ||
160 | res = mv64x60_pci_fixup(pdev); | ||
161 | if (res < 0) { | ||
162 | printk(KERN_ERR "%s: PCI fixup failed\n", __func__); | ||
163 | goto err; | ||
164 | } | ||
165 | |||
131 | out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_CAUSE, 0); | 166 | out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_CAUSE, 0); |
132 | out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_MASK, 0); | 167 | out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_MASK, 0); |
133 | out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_MASK, | 168 | out_le32(pdata->pci_vbase + MV64X60_PCI_ERROR_MASK, |
@@ -612,7 +647,7 @@ static void get_total_mem(struct mv64x60_mc_pdata *pdata) | |||
612 | if (!np) | 647 | if (!np) |
613 | return; | 648 | return; |
614 | 649 | ||
615 | reg = get_property(np, "reg", NULL); | 650 | reg = of_get_property(np, "reg", NULL); |
616 | 651 | ||
617 | pdata->total_mem = reg[1]; | 652 | pdata->total_mem = reg[1]; |
618 | } | 653 | } |
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index 0b624e927a6f..c66817e7717b 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -152,20 +152,11 @@ static ssize_t smi_data_read(struct kobject *kobj, | |||
152 | struct bin_attribute *bin_attr, | 152 | struct bin_attribute *bin_attr, |
153 | char *buf, loff_t pos, size_t count) | 153 | char *buf, loff_t pos, size_t count) |
154 | { | 154 | { |
155 | size_t max_read; | ||
156 | ssize_t ret; | 155 | ssize_t ret; |
157 | 156 | ||
158 | mutex_lock(&smi_data_lock); | 157 | mutex_lock(&smi_data_lock); |
159 | 158 | ret = memory_read_from_buffer(buf, count, &pos, smi_data_buf, | |
160 | if (pos >= smi_data_buf_size) { | 159 | smi_data_buf_size); |
161 | ret = 0; | ||
162 | goto out; | ||
163 | } | ||
164 | |||
165 | max_read = smi_data_buf_size - pos; | ||
166 | ret = min(max_read, count); | ||
167 | memcpy(buf, smi_data_buf + pos, ret); | ||
168 | out: | ||
169 | mutex_unlock(&smi_data_lock); | 160 | mutex_unlock(&smi_data_lock); |
170 | return ret; | 161 | return ret; |
171 | } | 162 | } |
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c index 7430e218cda6..13946ebd77d6 100644 --- a/drivers/firmware/dell_rbu.c +++ b/drivers/firmware/dell_rbu.c | |||
@@ -507,11 +507,6 @@ static ssize_t read_packet_data(char *buffer, loff_t pos, size_t count) | |||
507 | 507 | ||
508 | static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) | 508 | static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) |
509 | { | 509 | { |
510 | unsigned char *ptemp = NULL; | ||
511 | size_t bytes_left = 0; | ||
512 | size_t data_length = 0; | ||
513 | ssize_t ret_count = 0; | ||
514 | |||
515 | /* check to see if we have something to return */ | 510 | /* check to see if we have something to return */ |
516 | if ((rbu_data.image_update_buffer == NULL) || | 511 | if ((rbu_data.image_update_buffer == NULL) || |
517 | (rbu_data.bios_image_size == 0)) { | 512 | (rbu_data.bios_image_size == 0)) { |
@@ -519,28 +514,11 @@ static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) | |||
519 | "bios_image_size %lu\n", | 514 | "bios_image_size %lu\n", |
520 | rbu_data.image_update_buffer, | 515 | rbu_data.image_update_buffer, |
521 | rbu_data.bios_image_size); | 516 | rbu_data.bios_image_size); |
522 | ret_count = -ENOMEM; | 517 | return -ENOMEM; |
523 | goto read_rbu_data_exit; | ||
524 | } | ||
525 | |||
526 | if (pos > rbu_data.bios_image_size) { | ||
527 | ret_count = 0; | ||
528 | goto read_rbu_data_exit; | ||
529 | } | 518 | } |
530 | 519 | ||
531 | bytes_left = rbu_data.bios_image_size - pos; | 520 | return memory_read_from_buffer(buffer, count, &pos, |
532 | data_length = min(bytes_left, count); | 521 | rbu_data.image_update_buffer, rbu_data.bios_image_size); |
533 | |||
534 | ptemp = rbu_data.image_update_buffer; | ||
535 | memcpy(buffer, (ptemp + pos), data_length); | ||
536 | |||
537 | if ((pos + count) > rbu_data.bios_image_size) | ||
538 | /* this was the last copy */ | ||
539 | ret_count = bytes_left; | ||
540 | else | ||
541 | ret_count = count; | ||
542 | read_rbu_data_exit: | ||
543 | return ret_count; | ||
544 | } | 522 | } |
545 | 523 | ||
546 | static ssize_t read_rbu_data(struct kobject *kobj, | 524 | static ssize_t read_rbu_data(struct kobject *kobj, |
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index fced1909cbba..dbd42d6c93a7 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -2,15 +2,40 @@ | |||
2 | # GPIO infrastructure and expanders | 2 | # GPIO infrastructure and expanders |
3 | # | 3 | # |
4 | 4 | ||
5 | config HAVE_GPIO_LIB | 5 | config ARCH_WANT_OPTIONAL_GPIOLIB |
6 | bool | 6 | bool |
7 | help | 7 | help |
8 | Select this config option from the architecture Kconfig, if | ||
9 | it is possible to use gpiolib on the architecture, but let the | ||
10 | user decide whether to actually build it or not. | ||
11 | Select this instead of ARCH_REQUIRE_GPIOLIB, if your architecture does | ||
12 | not depend on GPIOs being available, but rather let the user | ||
13 | decide whether he needs it or not. | ||
14 | |||
15 | config ARCH_REQUIRE_GPIOLIB | ||
16 | bool | ||
17 | select GPIOLIB | ||
18 | help | ||
8 | Platforms select gpiolib if they use this infrastructure | 19 | Platforms select gpiolib if they use this infrastructure |
9 | for all their GPIOs, usually starting with ones integrated | 20 | for all their GPIOs, usually starting with ones integrated |
10 | into SOC processors. | 21 | into SOC processors. |
22 | Selecting this from the architecture code will cause the gpiolib | ||
23 | code to always get built in. | ||
24 | |||
25 | |||
26 | |||
27 | menuconfig GPIOLIB | ||
28 | bool "GPIO Support" | ||
29 | depends on ARCH_WANT_OPTIONAL_GPIOLIB || ARCH_REQUIRE_GPIOLIB | ||
30 | select GENERIC_GPIO | ||
31 | help | ||
32 | This enables GPIO support through the generic GPIO library. | ||
33 | You only need to enable this, if you also want to enable | ||
34 | one or more of the GPIO expansion card drivers below. | ||
11 | 35 | ||
12 | menu "GPIO Support" | 36 | If unsure, say N. |
13 | depends on HAVE_GPIO_LIB | 37 | |
38 | if GPIOLIB | ||
14 | 39 | ||
15 | config DEBUG_GPIO | 40 | config DEBUG_GPIO |
16 | bool "Debug GPIO calls" | 41 | bool "Debug GPIO calls" |
@@ -23,10 +48,44 @@ config DEBUG_GPIO | |||
23 | slower. The diagnostics help catch the type of setup errors | 48 | slower. The diagnostics help catch the type of setup errors |
24 | that are most common when setting up new platforms or boards. | 49 | that are most common when setting up new platforms or boards. |
25 | 50 | ||
51 | config GPIO_SYSFS | ||
52 | bool "/sys/class/gpio/... (sysfs interface)" | ||
53 | depends on SYSFS && EXPERIMENTAL | ||
54 | help | ||
55 | Say Y here to add a sysfs interface for GPIOs. | ||
56 | |||
57 | This is mostly useful to work around omissions in a system's | ||
58 | kernel support. Those are common in custom and semicustom | ||
59 | hardware assembled using standard kernels with a minimum of | ||
60 | custom patches. In those cases, userspace code may import | ||
61 | a given GPIO from the kernel, if no kernel driver requested it. | ||
62 | |||
63 | Kernel drivers may also request that a particular GPIO be | ||
64 | exported to userspace; this can be useful when debugging. | ||
65 | |||
26 | # put expanders in the right section, in alphabetical order | 66 | # put expanders in the right section, in alphabetical order |
27 | 67 | ||
28 | comment "I2C GPIO expanders:" | 68 | comment "I2C GPIO expanders:" |
29 | 69 | ||
70 | config GPIO_MAX732X | ||
71 | tristate "MAX7319, MAX7320-7327 I2C Port Expanders" | ||
72 | depends on I2C | ||
73 | help | ||
74 | Say yes here to support the MAX7319, MAX7320-7327 series of I2C | ||
75 | Port Expanders. Each IO port on these chips has a fixed role of | ||
76 | Input (designated by 'I'), Push-Pull Output ('O'), or Open-Drain | ||
77 | Input and Output (designed by 'P'). The combinations are listed | ||
78 | below: | ||
79 | |||
80 | 8 bits: max7319 (8I), max7320 (8O), max7321 (8P), | ||
81 | max7322 (4I4O), max7323 (4P4O) | ||
82 | |||
83 | 16 bits: max7324 (8I8O), max7325 (8P8O), | ||
84 | max7326 (4I12O), max7327 (4P12O) | ||
85 | |||
86 | Board setup code must specify the model to use, and the start | ||
87 | number for these GPIOs. | ||
88 | |||
30 | config GPIO_PCA953X | 89 | config GPIO_PCA953X |
31 | tristate "PCA953x, PCA955x, and MAX7310 I/O ports" | 90 | tristate "PCA953x, PCA955x, and MAX7310 I/O ports" |
32 | depends on I2C | 91 | depends on I2C |
@@ -68,6 +127,24 @@ config GPIO_PCF857X | |||
68 | This driver provides an in-kernel interface to those GPIOs using | 127 | This driver provides an in-kernel interface to those GPIOs using |
69 | platform-neutral GPIO calls. | 128 | platform-neutral GPIO calls. |
70 | 129 | ||
130 | comment "PCI GPIO expanders:" | ||
131 | |||
132 | config GPIO_BT8XX | ||
133 | tristate "BT8XX GPIO abuser" | ||
134 | depends on PCI && VIDEO_BT848=n | ||
135 | help | ||
136 | The BT8xx frame grabber chip has 24 GPIO pins than can be abused | ||
137 | as a cheap PCI GPIO card. | ||
138 | |||
139 | This chip can be found on Miro, Hauppauge and STB TV-cards. | ||
140 | |||
141 | The card needs to be physically altered for using it as a | ||
142 | GPIO card. For more information on how to build a GPIO card | ||
143 | from a BT8xx TV card, see the documentation file at | ||
144 | Documentation/bt8xxgpio.txt | ||
145 | |||
146 | If unsure, say N. | ||
147 | |||
71 | comment "SPI GPIO expanders:" | 148 | comment "SPI GPIO expanders:" |
72 | 149 | ||
73 | config GPIO_MAX7301 | 150 | config GPIO_MAX7301 |
@@ -83,4 +160,4 @@ config GPIO_MCP23S08 | |||
83 | SPI driver for Microchip MCP23S08 I/O expander. This provides | 160 | SPI driver for Microchip MCP23S08 I/O expander. This provides |
84 | a GPIO interface supporting inputs and outputs. | 161 | a GPIO interface supporting inputs and outputs. |
85 | 162 | ||
86 | endmenu | 163 | endif |
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 16e796dc5410..01b4bbde1956 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -2,9 +2,11 @@ | |||
2 | 2 | ||
3 | ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG | 3 | ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG |
4 | 4 | ||
5 | obj-$(CONFIG_HAVE_GPIO_LIB) += gpiolib.o | 5 | obj-$(CONFIG_GPIOLIB) += gpiolib.o |
6 | 6 | ||
7 | obj-$(CONFIG_GPIO_MAX7301) += max7301.o | 7 | obj-$(CONFIG_GPIO_MAX7301) += max7301.o |
8 | obj-$(CONFIG_GPIO_MAX732X) += max732x.o | ||
8 | obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o | 9 | obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o |
9 | obj-$(CONFIG_GPIO_PCA953X) += pca953x.o | 10 | obj-$(CONFIG_GPIO_PCA953X) += pca953x.o |
10 | obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o | 11 | obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o |
12 | obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o | ||
diff --git a/drivers/gpio/bt8xxgpio.c b/drivers/gpio/bt8xxgpio.c new file mode 100644 index 000000000000..7a1168249dd5 --- /dev/null +++ b/drivers/gpio/bt8xxgpio.c | |||
@@ -0,0 +1,348 @@ | |||
1 | /* | ||
2 | |||
3 | bt8xx GPIO abuser | ||
4 | |||
5 | Copyright (C) 2008 Michael Buesch <mb@bu3sch.de> | ||
6 | |||
7 | Please do _only_ contact the people listed _above_ with issues related to this driver. | ||
8 | All the other people listed below are not related to this driver. Their names | ||
9 | are only here, because this driver is derived from the bt848 driver. | ||
10 | |||
11 | |||
12 | Derived from the bt848 driver: | ||
13 | |||
14 | Copyright (C) 1996,97,98 Ralph Metzler | ||
15 | & Marcus Metzler | ||
16 | (c) 1999-2002 Gerd Knorr | ||
17 | |||
18 | some v4l2 code lines are taken from Justin's bttv2 driver which is | ||
19 | (c) 2000 Justin Schoeman | ||
20 | |||
21 | V4L1 removal from: | ||
22 | (c) 2005-2006 Nickolay V. Shmyrev | ||
23 | |||
24 | Fixes to be fully V4L2 compliant by | ||
25 | (c) 2006 Mauro Carvalho Chehab | ||
26 | |||
27 | Cropping and overscan support | ||
28 | Copyright (C) 2005, 2006 Michael H. Schimek | ||
29 | Sponsored by OPQ Systems AB | ||
30 | |||
31 | This program is free software; you can redistribute it and/or modify | ||
32 | it under the terms of the GNU General Public License as published by | ||
33 | the Free Software Foundation; either version 2 of the License, or | ||
34 | (at your option) any later version. | ||
35 | |||
36 | This program is distributed in the hope that it will be useful, | ||
37 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
38 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
39 | GNU General Public License for more details. | ||
40 | |||
41 | You should have received a copy of the GNU General Public License | ||
42 | along with this program; if not, write to the Free Software | ||
43 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
44 | */ | ||
45 | |||
46 | #include <linux/module.h> | ||
47 | #include <linux/pci.h> | ||
48 | #include <linux/spinlock.h> | ||
49 | |||
50 | #include <asm/gpio.h> | ||
51 | |||
52 | /* Steal the hardware definitions from the bttv driver. */ | ||
53 | #include "../media/video/bt8xx/bt848.h" | ||
54 | |||
55 | |||
56 | #define BT8XXGPIO_NR_GPIOS 24 /* We have 24 GPIO pins */ | ||
57 | |||
58 | |||
59 | struct bt8xxgpio { | ||
60 | spinlock_t lock; | ||
61 | |||
62 | void __iomem *mmio; | ||
63 | struct pci_dev *pdev; | ||
64 | struct gpio_chip gpio; | ||
65 | |||
66 | #ifdef CONFIG_PM | ||
67 | u32 saved_outen; | ||
68 | u32 saved_data; | ||
69 | #endif | ||
70 | }; | ||
71 | |||
72 | #define bgwrite(dat, adr) writel((dat), bg->mmio+(adr)) | ||
73 | #define bgread(adr) readl(bg->mmio+(adr)) | ||
74 | |||
75 | |||
76 | static int modparam_gpiobase = -1/* dynamic */; | ||
77 | module_param_named(gpiobase, modparam_gpiobase, int, 0444); | ||
78 | MODULE_PARM_DESC(gpiobase, "The GPIO number base. -1 means dynamic, which is the default."); | ||
79 | |||
80 | |||
81 | static int bt8xxgpio_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) | ||
82 | { | ||
83 | struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio); | ||
84 | unsigned long flags; | ||
85 | u32 outen, data; | ||
86 | |||
87 | spin_lock_irqsave(&bg->lock, flags); | ||
88 | |||
89 | data = bgread(BT848_GPIO_DATA); | ||
90 | data &= ~(1 << nr); | ||
91 | bgwrite(data, BT848_GPIO_DATA); | ||
92 | |||
93 | outen = bgread(BT848_GPIO_OUT_EN); | ||
94 | outen &= ~(1 << nr); | ||
95 | bgwrite(outen, BT848_GPIO_OUT_EN); | ||
96 | |||
97 | spin_unlock_irqrestore(&bg->lock, flags); | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static int bt8xxgpio_gpio_get(struct gpio_chip *gpio, unsigned nr) | ||
103 | { | ||
104 | struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio); | ||
105 | unsigned long flags; | ||
106 | u32 val; | ||
107 | |||
108 | spin_lock_irqsave(&bg->lock, flags); | ||
109 | val = bgread(BT848_GPIO_DATA); | ||
110 | spin_unlock_irqrestore(&bg->lock, flags); | ||
111 | |||
112 | return !!(val & (1 << nr)); | ||
113 | } | ||
114 | |||
115 | static int bt8xxgpio_gpio_direction_output(struct gpio_chip *gpio, | ||
116 | unsigned nr, int val) | ||
117 | { | ||
118 | struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio); | ||
119 | unsigned long flags; | ||
120 | u32 outen, data; | ||
121 | |||
122 | spin_lock_irqsave(&bg->lock, flags); | ||
123 | |||
124 | outen = bgread(BT848_GPIO_OUT_EN); | ||
125 | outen |= (1 << nr); | ||
126 | bgwrite(outen, BT848_GPIO_OUT_EN); | ||
127 | |||
128 | data = bgread(BT848_GPIO_DATA); | ||
129 | if (val) | ||
130 | data |= (1 << nr); | ||
131 | else | ||
132 | data &= ~(1 << nr); | ||
133 | bgwrite(data, BT848_GPIO_DATA); | ||
134 | |||
135 | spin_unlock_irqrestore(&bg->lock, flags); | ||
136 | |||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | static void bt8xxgpio_gpio_set(struct gpio_chip *gpio, | ||
141 | unsigned nr, int val) | ||
142 | { | ||
143 | struct bt8xxgpio *bg = container_of(gpio, struct bt8xxgpio, gpio); | ||
144 | unsigned long flags; | ||
145 | u32 data; | ||
146 | |||
147 | spin_lock_irqsave(&bg->lock, flags); | ||
148 | |||
149 | data = bgread(BT848_GPIO_DATA); | ||
150 | if (val) | ||
151 | data |= (1 << nr); | ||
152 | else | ||
153 | data &= ~(1 << nr); | ||
154 | bgwrite(data, BT848_GPIO_DATA); | ||
155 | |||
156 | spin_unlock_irqrestore(&bg->lock, flags); | ||
157 | } | ||
158 | |||
159 | static void bt8xxgpio_gpio_setup(struct bt8xxgpio *bg) | ||
160 | { | ||
161 | struct gpio_chip *c = &bg->gpio; | ||
162 | |||
163 | c->label = bg->pdev->dev.bus_id; | ||
164 | c->owner = THIS_MODULE; | ||
165 | c->direction_input = bt8xxgpio_gpio_direction_input; | ||
166 | c->get = bt8xxgpio_gpio_get; | ||
167 | c->direction_output = bt8xxgpio_gpio_direction_output; | ||
168 | c->set = bt8xxgpio_gpio_set; | ||
169 | c->dbg_show = NULL; | ||
170 | c->base = modparam_gpiobase; | ||
171 | c->ngpio = BT8XXGPIO_NR_GPIOS; | ||
172 | c->can_sleep = 0; | ||
173 | } | ||
174 | |||
175 | static int bt8xxgpio_probe(struct pci_dev *dev, | ||
176 | const struct pci_device_id *pci_id) | ||
177 | { | ||
178 | struct bt8xxgpio *bg; | ||
179 | int err; | ||
180 | |||
181 | bg = kzalloc(sizeof(*bg), GFP_KERNEL); | ||
182 | if (!bg) | ||
183 | return -ENOMEM; | ||
184 | |||
185 | bg->pdev = dev; | ||
186 | spin_lock_init(&bg->lock); | ||
187 | |||
188 | err = pci_enable_device(dev); | ||
189 | if (err) { | ||
190 | printk(KERN_ERR "bt8xxgpio: Can't enable device.\n"); | ||
191 | goto err_freebg; | ||
192 | } | ||
193 | if (!request_mem_region(pci_resource_start(dev, 0), | ||
194 | pci_resource_len(dev, 0), | ||
195 | "bt8xxgpio")) { | ||
196 | printk(KERN_WARNING "bt8xxgpio: Can't request iomem (0x%llx).\n", | ||
197 | (unsigned long long)pci_resource_start(dev, 0)); | ||
198 | err = -EBUSY; | ||
199 | goto err_disable; | ||
200 | } | ||
201 | pci_set_master(dev); | ||
202 | pci_set_drvdata(dev, bg); | ||
203 | |||
204 | bg->mmio = ioremap(pci_resource_start(dev, 0), 0x1000); | ||
205 | if (!bg->mmio) { | ||
206 | printk(KERN_ERR "bt8xxgpio: ioremap() failed\n"); | ||
207 | err = -EIO; | ||
208 | goto err_release_mem; | ||
209 | } | ||
210 | |||
211 | /* Disable interrupts */ | ||
212 | bgwrite(0, BT848_INT_MASK); | ||
213 | |||
214 | /* gpio init */ | ||
215 | bgwrite(0, BT848_GPIO_DMA_CTL); | ||
216 | bgwrite(0, BT848_GPIO_REG_INP); | ||
217 | bgwrite(0, BT848_GPIO_OUT_EN); | ||
218 | |||
219 | bt8xxgpio_gpio_setup(bg); | ||
220 | err = gpiochip_add(&bg->gpio); | ||
221 | if (err) { | ||
222 | printk(KERN_ERR "bt8xxgpio: Failed to register GPIOs\n"); | ||
223 | goto err_release_mem; | ||
224 | } | ||
225 | |||
226 | printk(KERN_INFO "bt8xxgpio: Abusing BT8xx card for GPIOs %d to %d\n", | ||
227 | bg->gpio.base, bg->gpio.base + BT8XXGPIO_NR_GPIOS - 1); | ||
228 | |||
229 | return 0; | ||
230 | |||
231 | err_release_mem: | ||
232 | release_mem_region(pci_resource_start(dev, 0), | ||
233 | pci_resource_len(dev, 0)); | ||
234 | pci_set_drvdata(dev, NULL); | ||
235 | err_disable: | ||
236 | pci_disable_device(dev); | ||
237 | err_freebg: | ||
238 | kfree(bg); | ||
239 | |||
240 | return err; | ||
241 | } | ||
242 | |||
243 | static void bt8xxgpio_remove(struct pci_dev *pdev) | ||
244 | { | ||
245 | struct bt8xxgpio *bg = pci_get_drvdata(pdev); | ||
246 | |||
247 | gpiochip_remove(&bg->gpio); | ||
248 | |||
249 | bgwrite(0, BT848_INT_MASK); | ||
250 | bgwrite(~0x0, BT848_INT_STAT); | ||
251 | bgwrite(0x0, BT848_GPIO_OUT_EN); | ||
252 | |||
253 | iounmap(bg->mmio); | ||
254 | release_mem_region(pci_resource_start(pdev, 0), | ||
255 | pci_resource_len(pdev, 0)); | ||
256 | pci_disable_device(pdev); | ||
257 | |||
258 | pci_set_drvdata(pdev, NULL); | ||
259 | kfree(bg); | ||
260 | } | ||
261 | |||
262 | #ifdef CONFIG_PM | ||
263 | static int bt8xxgpio_suspend(struct pci_dev *pdev, pm_message_t state) | ||
264 | { | ||
265 | struct bt8xxgpio *bg = pci_get_drvdata(pdev); | ||
266 | unsigned long flags; | ||
267 | |||
268 | spin_lock_irqsave(&bg->lock, flags); | ||
269 | |||
270 | bg->saved_outen = bgread(BT848_GPIO_OUT_EN); | ||
271 | bg->saved_data = bgread(BT848_GPIO_DATA); | ||
272 | |||
273 | bgwrite(0, BT848_INT_MASK); | ||
274 | bgwrite(~0x0, BT848_INT_STAT); | ||
275 | bgwrite(0x0, BT848_GPIO_OUT_EN); | ||
276 | |||
277 | spin_unlock_irqrestore(&bg->lock, flags); | ||
278 | |||
279 | pci_save_state(pdev); | ||
280 | pci_disable_device(pdev); | ||
281 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | ||
282 | |||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | static int bt8xxgpio_resume(struct pci_dev *pdev) | ||
287 | { | ||
288 | struct bt8xxgpio *bg = pci_get_drvdata(pdev); | ||
289 | unsigned long flags; | ||
290 | int err; | ||
291 | |||
292 | pci_set_power_state(pdev, 0); | ||
293 | err = pci_enable_device(pdev); | ||
294 | if (err) | ||
295 | return err; | ||
296 | pci_restore_state(pdev); | ||
297 | |||
298 | spin_lock_irqsave(&bg->lock, flags); | ||
299 | |||
300 | bgwrite(0, BT848_INT_MASK); | ||
301 | bgwrite(0, BT848_GPIO_DMA_CTL); | ||
302 | bgwrite(0, BT848_GPIO_REG_INP); | ||
303 | bgwrite(bg->saved_outen, BT848_GPIO_OUT_EN); | ||
304 | bgwrite(bg->saved_data & bg->saved_outen, | ||
305 | BT848_GPIO_DATA); | ||
306 | |||
307 | spin_unlock_irqrestore(&bg->lock, flags); | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | #else | ||
312 | #define bt8xxgpio_suspend NULL | ||
313 | #define bt8xxgpio_resume NULL | ||
314 | #endif /* CONFIG_PM */ | ||
315 | |||
316 | static struct pci_device_id bt8xxgpio_pci_tbl[] = { | ||
317 | { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848) }, | ||
318 | { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849) }, | ||
319 | { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878) }, | ||
320 | { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT879) }, | ||
321 | { 0, }, | ||
322 | }; | ||
323 | MODULE_DEVICE_TABLE(pci, bt8xxgpio_pci_tbl); | ||
324 | |||
325 | static struct pci_driver bt8xxgpio_pci_driver = { | ||
326 | .name = "bt8xxgpio", | ||
327 | .id_table = bt8xxgpio_pci_tbl, | ||
328 | .probe = bt8xxgpio_probe, | ||
329 | .remove = bt8xxgpio_remove, | ||
330 | .suspend = bt8xxgpio_suspend, | ||
331 | .resume = bt8xxgpio_resume, | ||
332 | }; | ||
333 | |||
334 | static int bt8xxgpio_init(void) | ||
335 | { | ||
336 | return pci_register_driver(&bt8xxgpio_pci_driver); | ||
337 | } | ||
338 | module_init(bt8xxgpio_init) | ||
339 | |||
340 | static void bt8xxgpio_exit(void) | ||
341 | { | ||
342 | pci_unregister_driver(&bt8xxgpio_pci_driver); | ||
343 | } | ||
344 | module_exit(bt8xxgpio_exit) | ||
345 | |||
346 | MODULE_LICENSE("GPL"); | ||
347 | MODULE_AUTHOR("Michael Buesch"); | ||
348 | MODULE_DESCRIPTION("Abuse a BT8xx framegrabber card as generic GPIO card"); | ||
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index beaf6b3a37dc..8d2940517c99 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -2,8 +2,11 @@ | |||
2 | #include <linux/module.h> | 2 | #include <linux/module.h> |
3 | #include <linux/irq.h> | 3 | #include <linux/irq.h> |
4 | #include <linux/spinlock.h> | 4 | #include <linux/spinlock.h> |
5 | 5 | #include <linux/device.h> | |
6 | #include <asm/gpio.h> | 6 | #include <linux/err.h> |
7 | #include <linux/debugfs.h> | ||
8 | #include <linux/seq_file.h> | ||
9 | #include <linux/gpio.h> | ||
7 | 10 | ||
8 | 11 | ||
9 | /* Optional implementation infrastructure for GPIO interfaces. | 12 | /* Optional implementation infrastructure for GPIO interfaces. |
@@ -44,6 +47,8 @@ struct gpio_desc { | |||
44 | #define FLAG_REQUESTED 0 | 47 | #define FLAG_REQUESTED 0 |
45 | #define FLAG_IS_OUT 1 | 48 | #define FLAG_IS_OUT 1 |
46 | #define FLAG_RESERVED 2 | 49 | #define FLAG_RESERVED 2 |
50 | #define FLAG_EXPORT 3 /* protected by sysfs_lock */ | ||
51 | #define FLAG_SYSFS 4 /* exported via /sys/class/gpio/control */ | ||
47 | 52 | ||
48 | #ifdef CONFIG_DEBUG_FS | 53 | #ifdef CONFIG_DEBUG_FS |
49 | const char *label; | 54 | const char *label; |
@@ -151,6 +156,482 @@ err: | |||
151 | return ret; | 156 | return ret; |
152 | } | 157 | } |
153 | 158 | ||
159 | #ifdef CONFIG_GPIO_SYSFS | ||
160 | |||
161 | /* lock protects against unexport_gpio() being called while | ||
162 | * sysfs files are active. | ||
163 | */ | ||
164 | static DEFINE_MUTEX(sysfs_lock); | ||
165 | |||
166 | /* | ||
167 | * /sys/class/gpio/gpioN... only for GPIOs that are exported | ||
168 | * /direction | ||
169 | * * MAY BE OMITTED if kernel won't allow direction changes | ||
170 | * * is read/write as "in" or "out" | ||
171 | * * may also be written as "high" or "low", initializing | ||
172 | * output value as specified ("out" implies "low") | ||
173 | * /value | ||
174 | * * always readable, subject to hardware behavior | ||
175 | * * may be writable, as zero/nonzero | ||
176 | * | ||
177 | * REVISIT there will likely be an attribute for configuring async | ||
178 | * notifications, e.g. to specify polling interval or IRQ trigger type | ||
179 | * that would for example trigger a poll() on the "value". | ||
180 | */ | ||
181 | |||
182 | static ssize_t gpio_direction_show(struct device *dev, | ||
183 | struct device_attribute *attr, char *buf) | ||
184 | { | ||
185 | const struct gpio_desc *desc = dev_get_drvdata(dev); | ||
186 | ssize_t status; | ||
187 | |||
188 | mutex_lock(&sysfs_lock); | ||
189 | |||
190 | if (!test_bit(FLAG_EXPORT, &desc->flags)) | ||
191 | status = -EIO; | ||
192 | else | ||
193 | status = sprintf(buf, "%s\n", | ||
194 | test_bit(FLAG_IS_OUT, &desc->flags) | ||
195 | ? "out" : "in"); | ||
196 | |||
197 | mutex_unlock(&sysfs_lock); | ||
198 | return status; | ||
199 | } | ||
200 | |||
201 | static ssize_t gpio_direction_store(struct device *dev, | ||
202 | struct device_attribute *attr, const char *buf, size_t size) | ||
203 | { | ||
204 | const struct gpio_desc *desc = dev_get_drvdata(dev); | ||
205 | unsigned gpio = desc - gpio_desc; | ||
206 | ssize_t status; | ||
207 | |||
208 | mutex_lock(&sysfs_lock); | ||
209 | |||
210 | if (!test_bit(FLAG_EXPORT, &desc->flags)) | ||
211 | status = -EIO; | ||
212 | else if (sysfs_streq(buf, "high")) | ||
213 | status = gpio_direction_output(gpio, 1); | ||
214 | else if (sysfs_streq(buf, "out") || sysfs_streq(buf, "low")) | ||
215 | status = gpio_direction_output(gpio, 0); | ||
216 | else if (sysfs_streq(buf, "in")) | ||
217 | status = gpio_direction_input(gpio); | ||
218 | else | ||
219 | status = -EINVAL; | ||
220 | |||
221 | mutex_unlock(&sysfs_lock); | ||
222 | return status ? : size; | ||
223 | } | ||
224 | |||
225 | static const DEVICE_ATTR(direction, 0644, | ||
226 | gpio_direction_show, gpio_direction_store); | ||
227 | |||
228 | static ssize_t gpio_value_show(struct device *dev, | ||
229 | struct device_attribute *attr, char *buf) | ||
230 | { | ||
231 | const struct gpio_desc *desc = dev_get_drvdata(dev); | ||
232 | unsigned gpio = desc - gpio_desc; | ||
233 | ssize_t status; | ||
234 | |||
235 | mutex_lock(&sysfs_lock); | ||
236 | |||
237 | if (!test_bit(FLAG_EXPORT, &desc->flags)) | ||
238 | status = -EIO; | ||
239 | else | ||
240 | status = sprintf(buf, "%d\n", gpio_get_value_cansleep(gpio)); | ||
241 | |||
242 | mutex_unlock(&sysfs_lock); | ||
243 | return status; | ||
244 | } | ||
245 | |||
246 | static ssize_t gpio_value_store(struct device *dev, | ||
247 | struct device_attribute *attr, const char *buf, size_t size) | ||
248 | { | ||
249 | const struct gpio_desc *desc = dev_get_drvdata(dev); | ||
250 | unsigned gpio = desc - gpio_desc; | ||
251 | ssize_t status; | ||
252 | |||
253 | mutex_lock(&sysfs_lock); | ||
254 | |||
255 | if (!test_bit(FLAG_EXPORT, &desc->flags)) | ||
256 | status = -EIO; | ||
257 | else if (!test_bit(FLAG_IS_OUT, &desc->flags)) | ||
258 | status = -EPERM; | ||
259 | else { | ||
260 | long value; | ||
261 | |||
262 | status = strict_strtol(buf, 0, &value); | ||
263 | if (status == 0) { | ||
264 | gpio_set_value_cansleep(gpio, value != 0); | ||
265 | status = size; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | mutex_unlock(&sysfs_lock); | ||
270 | return status; | ||
271 | } | ||
272 | |||
273 | static /*const*/ DEVICE_ATTR(value, 0644, | ||
274 | gpio_value_show, gpio_value_store); | ||
275 | |||
276 | static const struct attribute *gpio_attrs[] = { | ||
277 | &dev_attr_direction.attr, | ||
278 | &dev_attr_value.attr, | ||
279 | NULL, | ||
280 | }; | ||
281 | |||
282 | static const struct attribute_group gpio_attr_group = { | ||
283 | .attrs = (struct attribute **) gpio_attrs, | ||
284 | }; | ||
285 | |||
286 | /* | ||
287 | * /sys/class/gpio/gpiochipN/ | ||
288 | * /base ... matching gpio_chip.base (N) | ||
289 | * /label ... matching gpio_chip.label | ||
290 | * /ngpio ... matching gpio_chip.ngpio | ||
291 | */ | ||
292 | |||
293 | static ssize_t chip_base_show(struct device *dev, | ||
294 | struct device_attribute *attr, char *buf) | ||
295 | { | ||
296 | const struct gpio_chip *chip = dev_get_drvdata(dev); | ||
297 | |||
298 | return sprintf(buf, "%d\n", chip->base); | ||
299 | } | ||
300 | static DEVICE_ATTR(base, 0444, chip_base_show, NULL); | ||
301 | |||
302 | static ssize_t chip_label_show(struct device *dev, | ||
303 | struct device_attribute *attr, char *buf) | ||
304 | { | ||
305 | const struct gpio_chip *chip = dev_get_drvdata(dev); | ||
306 | |||
307 | return sprintf(buf, "%s\n", chip->label ? : ""); | ||
308 | } | ||
309 | static DEVICE_ATTR(label, 0444, chip_label_show, NULL); | ||
310 | |||
311 | static ssize_t chip_ngpio_show(struct device *dev, | ||
312 | struct device_attribute *attr, char *buf) | ||
313 | { | ||
314 | const struct gpio_chip *chip = dev_get_drvdata(dev); | ||
315 | |||
316 | return sprintf(buf, "%u\n", chip->ngpio); | ||
317 | } | ||
318 | static DEVICE_ATTR(ngpio, 0444, chip_ngpio_show, NULL); | ||
319 | |||
320 | static const struct attribute *gpiochip_attrs[] = { | ||
321 | &dev_attr_base.attr, | ||
322 | &dev_attr_label.attr, | ||
323 | &dev_attr_ngpio.attr, | ||
324 | NULL, | ||
325 | }; | ||
326 | |||
327 | static const struct attribute_group gpiochip_attr_group = { | ||
328 | .attrs = (struct attribute **) gpiochip_attrs, | ||
329 | }; | ||
330 | |||
331 | /* | ||
332 | * /sys/class/gpio/export ... write-only | ||
333 | * integer N ... number of GPIO to export (full access) | ||
334 | * /sys/class/gpio/unexport ... write-only | ||
335 | * integer N ... number of GPIO to unexport | ||
336 | */ | ||
337 | static ssize_t export_store(struct class *class, const char *buf, size_t len) | ||
338 | { | ||
339 | long gpio; | ||
340 | int status; | ||
341 | |||
342 | status = strict_strtol(buf, 0, &gpio); | ||
343 | if (status < 0) | ||
344 | goto done; | ||
345 | |||
346 | /* No extra locking here; FLAG_SYSFS just signifies that the | ||
347 | * request and export were done by on behalf of userspace, so | ||
348 | * they may be undone on its behalf too. | ||
349 | */ | ||
350 | |||
351 | status = gpio_request(gpio, "sysfs"); | ||
352 | if (status < 0) | ||
353 | goto done; | ||
354 | |||
355 | status = gpio_export(gpio, true); | ||
356 | if (status < 0) | ||
357 | gpio_free(gpio); | ||
358 | else | ||
359 | set_bit(FLAG_SYSFS, &gpio_desc[gpio].flags); | ||
360 | |||
361 | done: | ||
362 | if (status) | ||
363 | pr_debug("%s: status %d\n", __func__, status); | ||
364 | return status ? : len; | ||
365 | } | ||
366 | |||
367 | static ssize_t unexport_store(struct class *class, const char *buf, size_t len) | ||
368 | { | ||
369 | long gpio; | ||
370 | int status; | ||
371 | |||
372 | status = strict_strtol(buf, 0, &gpio); | ||
373 | if (status < 0) | ||
374 | goto done; | ||
375 | |||
376 | status = -EINVAL; | ||
377 | |||
378 | /* reject bogus commands (gpio_unexport ignores them) */ | ||
379 | if (!gpio_is_valid(gpio)) | ||
380 | goto done; | ||
381 | |||
382 | /* No extra locking here; FLAG_SYSFS just signifies that the | ||
383 | * request and export were done by on behalf of userspace, so | ||
384 | * they may be undone on its behalf too. | ||
385 | */ | ||
386 | if (test_and_clear_bit(FLAG_SYSFS, &gpio_desc[gpio].flags)) { | ||
387 | status = 0; | ||
388 | gpio_free(gpio); | ||
389 | } | ||
390 | done: | ||
391 | if (status) | ||
392 | pr_debug("%s: status %d\n", __func__, status); | ||
393 | return status ? : len; | ||
394 | } | ||
395 | |||
396 | static struct class_attribute gpio_class_attrs[] = { | ||
397 | __ATTR(export, 0200, NULL, export_store), | ||
398 | __ATTR(unexport, 0200, NULL, unexport_store), | ||
399 | __ATTR_NULL, | ||
400 | }; | ||
401 | |||
402 | static struct class gpio_class = { | ||
403 | .name = "gpio", | ||
404 | .owner = THIS_MODULE, | ||
405 | |||
406 | .class_attrs = gpio_class_attrs, | ||
407 | }; | ||
408 | |||
409 | |||
410 | /** | ||
411 | * gpio_export - export a GPIO through sysfs | ||
412 | * @gpio: gpio to make available, already requested | ||
413 | * @direction_may_change: true if userspace may change gpio direction | ||
414 | * Context: arch_initcall or later | ||
415 | * | ||
416 | * When drivers want to make a GPIO accessible to userspace after they | ||
417 | * have requested it -- perhaps while debugging, or as part of their | ||
418 | * public interface -- they may use this routine. If the GPIO can | ||
419 | * change direction (some can't) and the caller allows it, userspace | ||
420 | * will see "direction" sysfs attribute which may be used to change | ||
421 | * the gpio's direction. A "value" attribute will always be provided. | ||
422 | * | ||
423 | * Returns zero on success, else an error. | ||
424 | */ | ||
425 | int gpio_export(unsigned gpio, bool direction_may_change) | ||
426 | { | ||
427 | unsigned long flags; | ||
428 | struct gpio_desc *desc; | ||
429 | int status = -EINVAL; | ||
430 | |||
431 | /* can't export until sysfs is available ... */ | ||
432 | if (!gpio_class.p) { | ||
433 | pr_debug("%s: called too early!\n", __func__); | ||
434 | return -ENOENT; | ||
435 | } | ||
436 | |||
437 | if (!gpio_is_valid(gpio)) | ||
438 | goto done; | ||
439 | |||
440 | mutex_lock(&sysfs_lock); | ||
441 | |||
442 | spin_lock_irqsave(&gpio_lock, flags); | ||
443 | desc = &gpio_desc[gpio]; | ||
444 | if (test_bit(FLAG_REQUESTED, &desc->flags) | ||
445 | && !test_bit(FLAG_EXPORT, &desc->flags)) { | ||
446 | status = 0; | ||
447 | if (!desc->chip->direction_input | ||
448 | || !desc->chip->direction_output) | ||
449 | direction_may_change = false; | ||
450 | } | ||
451 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
452 | |||
453 | if (status == 0) { | ||
454 | struct device *dev; | ||
455 | |||
456 | dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0), | ||
457 | desc, "gpio%d", gpio); | ||
458 | if (dev) { | ||
459 | if (direction_may_change) | ||
460 | status = sysfs_create_group(&dev->kobj, | ||
461 | &gpio_attr_group); | ||
462 | else | ||
463 | status = device_create_file(dev, | ||
464 | &dev_attr_value); | ||
465 | if (status != 0) | ||
466 | device_unregister(dev); | ||
467 | } else | ||
468 | status = -ENODEV; | ||
469 | if (status == 0) | ||
470 | set_bit(FLAG_EXPORT, &desc->flags); | ||
471 | } | ||
472 | |||
473 | mutex_unlock(&sysfs_lock); | ||
474 | |||
475 | done: | ||
476 | if (status) | ||
477 | pr_debug("%s: gpio%d status %d\n", __func__, gpio, status); | ||
478 | |||
479 | return status; | ||
480 | } | ||
481 | EXPORT_SYMBOL_GPL(gpio_export); | ||
482 | |||
483 | static int match_export(struct device *dev, void *data) | ||
484 | { | ||
485 | return dev_get_drvdata(dev) == data; | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * gpio_unexport - reverse effect of gpio_export() | ||
490 | * @gpio: gpio to make unavailable | ||
491 | * | ||
492 | * This is implicit on gpio_free(). | ||
493 | */ | ||
494 | void gpio_unexport(unsigned gpio) | ||
495 | { | ||
496 | struct gpio_desc *desc; | ||
497 | int status = -EINVAL; | ||
498 | |||
499 | if (!gpio_is_valid(gpio)) | ||
500 | goto done; | ||
501 | |||
502 | mutex_lock(&sysfs_lock); | ||
503 | |||
504 | desc = &gpio_desc[gpio]; | ||
505 | if (test_bit(FLAG_EXPORT, &desc->flags)) { | ||
506 | struct device *dev = NULL; | ||
507 | |||
508 | dev = class_find_device(&gpio_class, NULL, desc, match_export); | ||
509 | if (dev) { | ||
510 | clear_bit(FLAG_EXPORT, &desc->flags); | ||
511 | put_device(dev); | ||
512 | device_unregister(dev); | ||
513 | status = 0; | ||
514 | } else | ||
515 | status = -ENODEV; | ||
516 | } | ||
517 | |||
518 | mutex_unlock(&sysfs_lock); | ||
519 | done: | ||
520 | if (status) | ||
521 | pr_debug("%s: gpio%d status %d\n", __func__, gpio, status); | ||
522 | } | ||
523 | EXPORT_SYMBOL_GPL(gpio_unexport); | ||
524 | |||
525 | static int gpiochip_export(struct gpio_chip *chip) | ||
526 | { | ||
527 | int status; | ||
528 | struct device *dev; | ||
529 | |||
530 | /* Many systems register gpio chips for SOC support very early, | ||
531 | * before driver model support is available. In those cases we | ||
532 | * export this later, in gpiolib_sysfs_init() ... here we just | ||
533 | * verify that _some_ field of gpio_class got initialized. | ||
534 | */ | ||
535 | if (!gpio_class.p) | ||
536 | return 0; | ||
537 | |||
538 | /* use chip->base for the ID; it's already known to be unique */ | ||
539 | mutex_lock(&sysfs_lock); | ||
540 | dev = device_create(&gpio_class, chip->dev, MKDEV(0, 0), chip, | ||
541 | "gpiochip%d", chip->base); | ||
542 | if (dev) { | ||
543 | status = sysfs_create_group(&dev->kobj, | ||
544 | &gpiochip_attr_group); | ||
545 | } else | ||
546 | status = -ENODEV; | ||
547 | chip->exported = (status == 0); | ||
548 | mutex_unlock(&sysfs_lock); | ||
549 | |||
550 | if (status) { | ||
551 | unsigned long flags; | ||
552 | unsigned gpio; | ||
553 | |||
554 | spin_lock_irqsave(&gpio_lock, flags); | ||
555 | gpio = chip->base; | ||
556 | while (gpio_desc[gpio].chip == chip) | ||
557 | gpio_desc[gpio++].chip = NULL; | ||
558 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
559 | |||
560 | pr_debug("%s: chip %s status %d\n", __func__, | ||
561 | chip->label, status); | ||
562 | } | ||
563 | |||
564 | return status; | ||
565 | } | ||
566 | |||
567 | static void gpiochip_unexport(struct gpio_chip *chip) | ||
568 | { | ||
569 | int status; | ||
570 | struct device *dev; | ||
571 | |||
572 | mutex_lock(&sysfs_lock); | ||
573 | dev = class_find_device(&gpio_class, NULL, chip, match_export); | ||
574 | if (dev) { | ||
575 | put_device(dev); | ||
576 | device_unregister(dev); | ||
577 | chip->exported = 0; | ||
578 | status = 0; | ||
579 | } else | ||
580 | status = -ENODEV; | ||
581 | mutex_unlock(&sysfs_lock); | ||
582 | |||
583 | if (status) | ||
584 | pr_debug("%s: chip %s status %d\n", __func__, | ||
585 | chip->label, status); | ||
586 | } | ||
587 | |||
588 | static int __init gpiolib_sysfs_init(void) | ||
589 | { | ||
590 | int status; | ||
591 | unsigned long flags; | ||
592 | unsigned gpio; | ||
593 | |||
594 | status = class_register(&gpio_class); | ||
595 | if (status < 0) | ||
596 | return status; | ||
597 | |||
598 | /* Scan and register the gpio_chips which registered very | ||
599 | * early (e.g. before the class_register above was called). | ||
600 | * | ||
601 | * We run before arch_initcall() so chip->dev nodes can have | ||
602 | * registered, and so arch_initcall() can always gpio_export(). | ||
603 | */ | ||
604 | spin_lock_irqsave(&gpio_lock, flags); | ||
605 | for (gpio = 0; gpio < ARCH_NR_GPIOS; gpio++) { | ||
606 | struct gpio_chip *chip; | ||
607 | |||
608 | chip = gpio_desc[gpio].chip; | ||
609 | if (!chip || chip->exported) | ||
610 | continue; | ||
611 | |||
612 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
613 | status = gpiochip_export(chip); | ||
614 | spin_lock_irqsave(&gpio_lock, flags); | ||
615 | } | ||
616 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
617 | |||
618 | |||
619 | return status; | ||
620 | } | ||
621 | postcore_initcall(gpiolib_sysfs_init); | ||
622 | |||
623 | #else | ||
624 | static inline int gpiochip_export(struct gpio_chip *chip) | ||
625 | { | ||
626 | return 0; | ||
627 | } | ||
628 | |||
629 | static inline void gpiochip_unexport(struct gpio_chip *chip) | ||
630 | { | ||
631 | } | ||
632 | |||
633 | #endif /* CONFIG_GPIO_SYSFS */ | ||
634 | |||
154 | /** | 635 | /** |
155 | * gpiochip_add() - register a gpio_chip | 636 | * gpiochip_add() - register a gpio_chip |
156 | * @chip: the chip to register, with chip->base initialized | 637 | * @chip: the chip to register, with chip->base initialized |
@@ -160,6 +641,11 @@ err: | |||
160 | * because the chip->base is invalid or already associated with a | 641 | * because the chip->base is invalid or already associated with a |
161 | * different chip. Otherwise it returns zero as a success code. | 642 | * different chip. Otherwise it returns zero as a success code. |
162 | * | 643 | * |
644 | * When gpiochip_add() is called very early during boot, so that GPIOs | ||
645 | * can be freely used, the chip->dev device must be registered before | ||
646 | * the gpio framework's arch_initcall(). Otherwise sysfs initialization | ||
647 | * for GPIOs will fail rudely. | ||
648 | * | ||
163 | * If chip->base is negative, this requests dynamic assignment of | 649 | * If chip->base is negative, this requests dynamic assignment of |
164 | * a range of valid GPIOs. | 650 | * a range of valid GPIOs. |
165 | */ | 651 | */ |
@@ -182,7 +668,7 @@ int gpiochip_add(struct gpio_chip *chip) | |||
182 | base = gpiochip_find_base(chip->ngpio); | 668 | base = gpiochip_find_base(chip->ngpio); |
183 | if (base < 0) { | 669 | if (base < 0) { |
184 | status = base; | 670 | status = base; |
185 | goto fail_unlock; | 671 | goto unlock; |
186 | } | 672 | } |
187 | chip->base = base; | 673 | chip->base = base; |
188 | } | 674 | } |
@@ -197,12 +683,23 @@ int gpiochip_add(struct gpio_chip *chip) | |||
197 | if (status == 0) { | 683 | if (status == 0) { |
198 | for (id = base; id < base + chip->ngpio; id++) { | 684 | for (id = base; id < base + chip->ngpio; id++) { |
199 | gpio_desc[id].chip = chip; | 685 | gpio_desc[id].chip = chip; |
200 | gpio_desc[id].flags = 0; | 686 | |
687 | /* REVISIT: most hardware initializes GPIOs as | ||
688 | * inputs (often with pullups enabled) so power | ||
689 | * usage is minimized. Linux code should set the | ||
690 | * gpio direction first thing; but until it does, | ||
691 | * we may expose the wrong direction in sysfs. | ||
692 | */ | ||
693 | gpio_desc[id].flags = !chip->direction_input | ||
694 | ? (1 << FLAG_IS_OUT) | ||
695 | : 0; | ||
201 | } | 696 | } |
202 | } | 697 | } |
203 | 698 | ||
204 | fail_unlock: | 699 | unlock: |
205 | spin_unlock_irqrestore(&gpio_lock, flags); | 700 | spin_unlock_irqrestore(&gpio_lock, flags); |
701 | if (status == 0) | ||
702 | status = gpiochip_export(chip); | ||
206 | fail: | 703 | fail: |
207 | /* failures here can mean systems won't boot... */ | 704 | /* failures here can mean systems won't boot... */ |
208 | if (status) | 705 | if (status) |
@@ -239,6 +736,10 @@ int gpiochip_remove(struct gpio_chip *chip) | |||
239 | } | 736 | } |
240 | 737 | ||
241 | spin_unlock_irqrestore(&gpio_lock, flags); | 738 | spin_unlock_irqrestore(&gpio_lock, flags); |
739 | |||
740 | if (status == 0) | ||
741 | gpiochip_unexport(chip); | ||
742 | |||
242 | return status; | 743 | return status; |
243 | } | 744 | } |
244 | EXPORT_SYMBOL_GPL(gpiochip_remove); | 745 | EXPORT_SYMBOL_GPL(gpiochip_remove); |
@@ -296,6 +797,8 @@ void gpio_free(unsigned gpio) | |||
296 | return; | 797 | return; |
297 | } | 798 | } |
298 | 799 | ||
800 | gpio_unexport(gpio); | ||
801 | |||
299 | spin_lock_irqsave(&gpio_lock, flags); | 802 | spin_lock_irqsave(&gpio_lock, flags); |
300 | 803 | ||
301 | desc = &gpio_desc[gpio]; | 804 | desc = &gpio_desc[gpio]; |
@@ -534,10 +1037,6 @@ EXPORT_SYMBOL_GPL(gpio_set_value_cansleep); | |||
534 | 1037 | ||
535 | #ifdef CONFIG_DEBUG_FS | 1038 | #ifdef CONFIG_DEBUG_FS |
536 | 1039 | ||
537 | #include <linux/debugfs.h> | ||
538 | #include <linux/seq_file.h> | ||
539 | |||
540 | |||
541 | static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip) | 1040 | static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip) |
542 | { | 1041 | { |
543 | unsigned i; | 1042 | unsigned i; |
@@ -614,17 +1113,28 @@ static int gpiolib_show(struct seq_file *s, void *unused) | |||
614 | /* REVISIT this isn't locked against gpio_chip removal ... */ | 1113 | /* REVISIT this isn't locked against gpio_chip removal ... */ |
615 | 1114 | ||
616 | for (gpio = 0; gpio_is_valid(gpio); gpio++) { | 1115 | for (gpio = 0; gpio_is_valid(gpio); gpio++) { |
1116 | struct device *dev; | ||
1117 | |||
617 | if (chip == gpio_desc[gpio].chip) | 1118 | if (chip == gpio_desc[gpio].chip) |
618 | continue; | 1119 | continue; |
619 | chip = gpio_desc[gpio].chip; | 1120 | chip = gpio_desc[gpio].chip; |
620 | if (!chip) | 1121 | if (!chip) |
621 | continue; | 1122 | continue; |
622 | 1123 | ||
623 | seq_printf(s, "%sGPIOs %d-%d, %s%s:\n", | 1124 | seq_printf(s, "%sGPIOs %d-%d", |
624 | started ? "\n" : "", | 1125 | started ? "\n" : "", |
625 | chip->base, chip->base + chip->ngpio - 1, | 1126 | chip->base, chip->base + chip->ngpio - 1); |
626 | chip->label ? : "generic", | 1127 | dev = chip->dev; |
627 | chip->can_sleep ? ", can sleep" : ""); | 1128 | if (dev) |
1129 | seq_printf(s, ", %s/%s", | ||
1130 | dev->bus ? dev->bus->name : "no-bus", | ||
1131 | dev->bus_id); | ||
1132 | if (chip->label) | ||
1133 | seq_printf(s, ", %s", chip->label); | ||
1134 | if (chip->can_sleep) | ||
1135 | seq_printf(s, ", can sleep"); | ||
1136 | seq_printf(s, ":\n"); | ||
1137 | |||
628 | started = 1; | 1138 | started = 1; |
629 | if (chip->dbg_show) | 1139 | if (chip->dbg_show) |
630 | chip->dbg_show(s, chip); | 1140 | chip->dbg_show(s, chip); |
diff --git a/drivers/gpio/max732x.c b/drivers/gpio/max732x.c new file mode 100644 index 000000000000..b51c8135ca28 --- /dev/null +++ b/drivers/gpio/max732x.c | |||
@@ -0,0 +1,385 @@ | |||
1 | /* | ||
2 | * max732x.c - I2C Port Expander with 8/16 I/O | ||
3 | * | ||
4 | * Copyright (C) 2007 Marvell International Ltd. | ||
5 | * Copyright (C) 2008 Jack Ren <jack.ren@marvell.com> | ||
6 | * Copyright (C) 2008 Eric Miao <eric.miao@marvell.com> | ||
7 | * | ||
8 | * Derived from drivers/gpio/pca953x.c | ||
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; version 2 of the License. | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/gpio.h> | ||
20 | |||
21 | #include <linux/i2c.h> | ||
22 | #include <linux/i2c/max732x.h> | ||
23 | |||
24 | |||
25 | /* | ||
26 | * Each port of MAX732x (including MAX7319) falls into one of the | ||
27 | * following three types: | ||
28 | * | ||
29 | * - Push Pull Output | ||
30 | * - Input | ||
31 | * - Open Drain I/O | ||
32 | * | ||
33 | * designated by 'O', 'I' and 'P' individually according to MAXIM's | ||
34 | * datasheets. | ||
35 | * | ||
36 | * There are two groups of I/O ports, each group usually includes | ||
37 | * up to 8 I/O ports, and is accessed by a specific I2C address: | ||
38 | * | ||
39 | * - Group A : by I2C address 0b'110xxxx | ||
40 | * - Group B : by I2C address 0b'101xxxx | ||
41 | * | ||
42 | * where 'xxxx' is decided by the connections of pin AD2/AD0. The | ||
43 | * address used also affects the initial state of output signals. | ||
44 | * | ||
45 | * Within each group of ports, there are five known combinations of | ||
46 | * I/O ports: 4I4O, 4P4O, 8I, 8P, 8O, see the definitions below for | ||
47 | * the detailed organization of these ports. | ||
48 | * | ||
49 | * GPIO numbers start from 'gpio_base + 0' to 'gpio_base + 8/16', | ||
50 | * and GPIOs from GROUP_A are numbered before those from GROUP_B | ||
51 | * (if there are two groups). | ||
52 | * | ||
53 | * NOTE: MAX7328/MAX7329 are drop-in replacements for PCF8574/a, so | ||
54 | * they are not supported by this driver. | ||
55 | */ | ||
56 | |||
57 | #define PORT_NONE 0x0 /* '/' No Port */ | ||
58 | #define PORT_OUTPUT 0x1 /* 'O' Push-Pull, Output Only */ | ||
59 | #define PORT_INPUT 0x2 /* 'I' Input Only */ | ||
60 | #define PORT_OPENDRAIN 0x3 /* 'P' Open-Drain, I/O */ | ||
61 | |||
62 | #define IO_4I4O 0x5AA5 /* O7 O6 I5 I4 I3 I2 O1 O0 */ | ||
63 | #define IO_4P4O 0x5FF5 /* O7 O6 P5 P4 P3 P2 O1 O0 */ | ||
64 | #define IO_8I 0xAAAA /* I7 I6 I5 I4 I3 I2 I1 I0 */ | ||
65 | #define IO_8P 0xFFFF /* P7 P6 P5 P4 P3 P2 P1 P0 */ | ||
66 | #define IO_8O 0x5555 /* O7 O6 O5 O4 O3 O2 O1 O0 */ | ||
67 | |||
68 | #define GROUP_A(x) ((x) & 0xffff) /* I2C Addr: 0b'110xxxx */ | ||
69 | #define GROUP_B(x) ((x) << 16) /* I2C Addr: 0b'101xxxx */ | ||
70 | |||
71 | static const struct i2c_device_id max732x_id[] = { | ||
72 | { "max7319", GROUP_A(IO_8I) }, | ||
73 | { "max7320", GROUP_B(IO_8O) }, | ||
74 | { "max7321", GROUP_A(IO_8P) }, | ||
75 | { "max7322", GROUP_A(IO_4I4O) }, | ||
76 | { "max7323", GROUP_A(IO_4P4O) }, | ||
77 | { "max7324", GROUP_A(IO_8I) | GROUP_B(IO_8O) }, | ||
78 | { "max7325", GROUP_A(IO_8P) | GROUP_B(IO_8O) }, | ||
79 | { "max7326", GROUP_A(IO_4I4O) | GROUP_B(IO_8O) }, | ||
80 | { "max7327", GROUP_A(IO_4P4O) | GROUP_B(IO_8O) }, | ||
81 | { }, | ||
82 | }; | ||
83 | MODULE_DEVICE_TABLE(i2c, max732x_id); | ||
84 | |||
85 | struct max732x_chip { | ||
86 | struct gpio_chip gpio_chip; | ||
87 | |||
88 | struct i2c_client *client; /* "main" client */ | ||
89 | struct i2c_client *client_dummy; | ||
90 | struct i2c_client *client_group_a; | ||
91 | struct i2c_client *client_group_b; | ||
92 | |||
93 | unsigned int mask_group_a; | ||
94 | unsigned int dir_input; | ||
95 | unsigned int dir_output; | ||
96 | |||
97 | struct mutex lock; | ||
98 | uint8_t reg_out[2]; | ||
99 | }; | ||
100 | |||
101 | static int max732x_write(struct max732x_chip *chip, int group_a, uint8_t val) | ||
102 | { | ||
103 | struct i2c_client *client; | ||
104 | int ret; | ||
105 | |||
106 | client = group_a ? chip->client_group_a : chip->client_group_b; | ||
107 | ret = i2c_smbus_write_byte(client, val); | ||
108 | if (ret < 0) { | ||
109 | dev_err(&client->dev, "failed writing\n"); | ||
110 | return ret; | ||
111 | } | ||
112 | |||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | static int max732x_read(struct max732x_chip *chip, int group_a, uint8_t *val) | ||
117 | { | ||
118 | struct i2c_client *client; | ||
119 | int ret; | ||
120 | |||
121 | client = group_a ? chip->client_group_a : chip->client_group_b; | ||
122 | ret = i2c_smbus_read_byte(client); | ||
123 | if (ret < 0) { | ||
124 | dev_err(&client->dev, "failed reading\n"); | ||
125 | return ret; | ||
126 | } | ||
127 | |||
128 | *val = (uint8_t)ret; | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | static inline int is_group_a(struct max732x_chip *chip, unsigned off) | ||
133 | { | ||
134 | return (1u << off) & chip->mask_group_a; | ||
135 | } | ||
136 | |||
137 | static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) | ||
138 | { | ||
139 | struct max732x_chip *chip; | ||
140 | uint8_t reg_val; | ||
141 | int ret; | ||
142 | |||
143 | chip = container_of(gc, struct max732x_chip, gpio_chip); | ||
144 | |||
145 | ret = max732x_read(chip, is_group_a(chip, off), ®_val); | ||
146 | if (ret < 0) | ||
147 | return 0; | ||
148 | |||
149 | return reg_val & (1u << (off & 0x7)); | ||
150 | } | ||
151 | |||
152 | static void max732x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val) | ||
153 | { | ||
154 | struct max732x_chip *chip; | ||
155 | uint8_t reg_out, mask = 1u << (off & 0x7); | ||
156 | int ret; | ||
157 | |||
158 | chip = container_of(gc, struct max732x_chip, gpio_chip); | ||
159 | |||
160 | mutex_lock(&chip->lock); | ||
161 | |||
162 | reg_out = (off > 7) ? chip->reg_out[1] : chip->reg_out[0]; | ||
163 | reg_out = (val) ? reg_out | mask : reg_out & ~mask; | ||
164 | |||
165 | ret = max732x_write(chip, is_group_a(chip, off), reg_out); | ||
166 | if (ret < 0) | ||
167 | goto out; | ||
168 | |||
169 | /* update the shadow register then */ | ||
170 | if (off > 7) | ||
171 | chip->reg_out[1] = reg_out; | ||
172 | else | ||
173 | chip->reg_out[0] = reg_out; | ||
174 | out: | ||
175 | mutex_unlock(&chip->lock); | ||
176 | } | ||
177 | |||
178 | static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off) | ||
179 | { | ||
180 | struct max732x_chip *chip; | ||
181 | unsigned int mask = 1u << off; | ||
182 | |||
183 | chip = container_of(gc, struct max732x_chip, gpio_chip); | ||
184 | |||
185 | if ((mask & chip->dir_input) == 0) { | ||
186 | dev_dbg(&chip->client->dev, "%s port %d is output only\n", | ||
187 | chip->client->name, off); | ||
188 | return -EACCES; | ||
189 | } | ||
190 | |||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | static int max732x_gpio_direction_output(struct gpio_chip *gc, | ||
195 | unsigned off, int val) | ||
196 | { | ||
197 | struct max732x_chip *chip; | ||
198 | unsigned int mask = 1u << off; | ||
199 | |||
200 | chip = container_of(gc, struct max732x_chip, gpio_chip); | ||
201 | |||
202 | if ((mask & chip->dir_output) == 0) { | ||
203 | dev_dbg(&chip->client->dev, "%s port %d is input only\n", | ||
204 | chip->client->name, off); | ||
205 | return -EACCES; | ||
206 | } | ||
207 | |||
208 | max732x_gpio_set_value(gc, off, val); | ||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | static int __devinit max732x_setup_gpio(struct max732x_chip *chip, | ||
213 | const struct i2c_device_id *id, | ||
214 | unsigned gpio_start) | ||
215 | { | ||
216 | struct gpio_chip *gc = &chip->gpio_chip; | ||
217 | uint32_t id_data = id->driver_data; | ||
218 | int i, port = 0; | ||
219 | |||
220 | for (i = 0; i < 16; i++, id_data >>= 2) { | ||
221 | unsigned int mask = 1 << port; | ||
222 | |||
223 | switch (id_data & 0x3) { | ||
224 | case PORT_OUTPUT: | ||
225 | chip->dir_output |= mask; | ||
226 | break; | ||
227 | case PORT_INPUT: | ||
228 | chip->dir_input |= mask; | ||
229 | break; | ||
230 | case PORT_OPENDRAIN: | ||
231 | chip->dir_output |= mask; | ||
232 | chip->dir_input |= mask; | ||
233 | break; | ||
234 | default: | ||
235 | continue; | ||
236 | } | ||
237 | |||
238 | if (i < 8) | ||
239 | chip->mask_group_a |= mask; | ||
240 | port++; | ||
241 | } | ||
242 | |||
243 | if (chip->dir_input) | ||
244 | gc->direction_input = max732x_gpio_direction_input; | ||
245 | if (chip->dir_output) { | ||
246 | gc->direction_output = max732x_gpio_direction_output; | ||
247 | gc->set = max732x_gpio_set_value; | ||
248 | } | ||
249 | gc->get = max732x_gpio_get_value; | ||
250 | gc->can_sleep = 1; | ||
251 | |||
252 | gc->base = gpio_start; | ||
253 | gc->ngpio = port; | ||
254 | gc->label = chip->client->name; | ||
255 | gc->owner = THIS_MODULE; | ||
256 | |||
257 | return port; | ||
258 | } | ||
259 | |||
260 | static int __devinit max732x_probe(struct i2c_client *client, | ||
261 | const struct i2c_device_id *id) | ||
262 | { | ||
263 | struct max732x_platform_data *pdata; | ||
264 | struct max732x_chip *chip; | ||
265 | struct i2c_client *c; | ||
266 | uint16_t addr_a, addr_b; | ||
267 | int ret, nr_port; | ||
268 | |||
269 | pdata = client->dev.platform_data; | ||
270 | if (pdata == NULL) | ||
271 | return -ENODEV; | ||
272 | |||
273 | chip = kzalloc(sizeof(struct max732x_chip), GFP_KERNEL); | ||
274 | if (chip == NULL) | ||
275 | return -ENOMEM; | ||
276 | chip->client = client; | ||
277 | |||
278 | nr_port = max732x_setup_gpio(chip, id, pdata->gpio_base); | ||
279 | |||
280 | addr_a = (client->addr & 0x0f) | 0x60; | ||
281 | addr_b = (client->addr & 0x0f) | 0x50; | ||
282 | |||
283 | switch (client->addr & 0x70) { | ||
284 | case 0x60: | ||
285 | chip->client_group_a = client; | ||
286 | if (nr_port > 7) { | ||
287 | c = i2c_new_dummy(client->adapter, addr_b); | ||
288 | chip->client_group_b = chip->client_dummy = c; | ||
289 | } | ||
290 | break; | ||
291 | case 0x50: | ||
292 | chip->client_group_b = client; | ||
293 | if (nr_port > 7) { | ||
294 | c = i2c_new_dummy(client->adapter, addr_a); | ||
295 | chip->client_group_a = chip->client_dummy = c; | ||
296 | } | ||
297 | break; | ||
298 | default: | ||
299 | dev_err(&client->dev, "invalid I2C address specified %02x\n", | ||
300 | client->addr); | ||
301 | ret = -EINVAL; | ||
302 | goto out_failed; | ||
303 | } | ||
304 | |||
305 | mutex_init(&chip->lock); | ||
306 | |||
307 | max732x_read(chip, is_group_a(chip, 0), &chip->reg_out[0]); | ||
308 | if (nr_port > 7) | ||
309 | max732x_read(chip, is_group_a(chip, 8), &chip->reg_out[1]); | ||
310 | |||
311 | ret = gpiochip_add(&chip->gpio_chip); | ||
312 | if (ret) | ||
313 | goto out_failed; | ||
314 | |||
315 | if (pdata->setup) { | ||
316 | ret = pdata->setup(client, chip->gpio_chip.base, | ||
317 | chip->gpio_chip.ngpio, pdata->context); | ||
318 | if (ret < 0) | ||
319 | dev_warn(&client->dev, "setup failed, %d\n", ret); | ||
320 | } | ||
321 | |||
322 | i2c_set_clientdata(client, chip); | ||
323 | return 0; | ||
324 | |||
325 | out_failed: | ||
326 | kfree(chip); | ||
327 | return ret; | ||
328 | } | ||
329 | |||
330 | static int __devexit max732x_remove(struct i2c_client *client) | ||
331 | { | ||
332 | struct max732x_platform_data *pdata = client->dev.platform_data; | ||
333 | struct max732x_chip *chip = i2c_get_clientdata(client); | ||
334 | int ret; | ||
335 | |||
336 | if (pdata->teardown) { | ||
337 | ret = pdata->teardown(client, chip->gpio_chip.base, | ||
338 | chip->gpio_chip.ngpio, pdata->context); | ||
339 | if (ret < 0) { | ||
340 | dev_err(&client->dev, "%s failed, %d\n", | ||
341 | "teardown", ret); | ||
342 | return ret; | ||
343 | } | ||
344 | } | ||
345 | |||
346 | ret = gpiochip_remove(&chip->gpio_chip); | ||
347 | if (ret) { | ||
348 | dev_err(&client->dev, "%s failed, %d\n", | ||
349 | "gpiochip_remove()", ret); | ||
350 | return ret; | ||
351 | } | ||
352 | |||
353 | /* unregister any dummy i2c_client */ | ||
354 | if (chip->client_dummy) | ||
355 | i2c_unregister_device(chip->client_dummy); | ||
356 | |||
357 | kfree(chip); | ||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | static struct i2c_driver max732x_driver = { | ||
362 | .driver = { | ||
363 | .name = "max732x", | ||
364 | .owner = THIS_MODULE, | ||
365 | }, | ||
366 | .probe = max732x_probe, | ||
367 | .remove = __devexit_p(max732x_remove), | ||
368 | .id_table = max732x_id, | ||
369 | }; | ||
370 | |||
371 | static int __init max732x_init(void) | ||
372 | { | ||
373 | return i2c_add_driver(&max732x_driver); | ||
374 | } | ||
375 | module_init(max732x_init); | ||
376 | |||
377 | static void __exit max732x_exit(void) | ||
378 | { | ||
379 | i2c_del_driver(&max732x_driver); | ||
380 | } | ||
381 | module_exit(max732x_exit); | ||
382 | |||
383 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); | ||
384 | MODULE_DESCRIPTION("GPIO expander driver for MAX732X"); | ||
385 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/gpio/mcp23s08.c b/drivers/gpio/mcp23s08.c index 7f92fdd5f0e2..8a1b405fefda 100644 --- a/drivers/gpio/mcp23s08.c +++ b/drivers/gpio/mcp23s08.c | |||
@@ -40,15 +40,26 @@ struct mcp23s08 { | |||
40 | struct spi_device *spi; | 40 | struct spi_device *spi; |
41 | u8 addr; | 41 | u8 addr; |
42 | 42 | ||
43 | u8 cache[11]; | ||
43 | /* lock protects the cached values */ | 44 | /* lock protects the cached values */ |
44 | struct mutex lock; | 45 | struct mutex lock; |
45 | u8 cache[11]; | ||
46 | 46 | ||
47 | struct gpio_chip chip; | 47 | struct gpio_chip chip; |
48 | 48 | ||
49 | struct work_struct work; | 49 | struct work_struct work; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | /* A given spi_device can represent up to four mcp23s08 chips | ||
53 | * sharing the same chipselect but using different addresses | ||
54 | * (e.g. chips #0 and #3 might be populated, but not #1 or $2). | ||
55 | * Driver data holds all the per-chip data. | ||
56 | */ | ||
57 | struct mcp23s08_driver_data { | ||
58 | unsigned ngpio; | ||
59 | struct mcp23s08 *mcp[4]; | ||
60 | struct mcp23s08 chip[]; | ||
61 | }; | ||
62 | |||
52 | static int mcp23s08_read(struct mcp23s08 *mcp, unsigned reg) | 63 | static int mcp23s08_read(struct mcp23s08 *mcp, unsigned reg) |
53 | { | 64 | { |
54 | u8 tx[2], rx[1]; | 65 | u8 tx[2], rx[1]; |
@@ -208,25 +219,18 @@ done: | |||
208 | 219 | ||
209 | /*----------------------------------------------------------------------*/ | 220 | /*----------------------------------------------------------------------*/ |
210 | 221 | ||
211 | static int mcp23s08_probe(struct spi_device *spi) | 222 | static int mcp23s08_probe_one(struct spi_device *spi, unsigned addr, |
223 | unsigned base, unsigned pullups) | ||
212 | { | 224 | { |
213 | struct mcp23s08 *mcp; | 225 | struct mcp23s08_driver_data *data = spi_get_drvdata(spi); |
214 | struct mcp23s08_platform_data *pdata; | 226 | struct mcp23s08 *mcp = data->mcp[addr]; |
215 | int status; | 227 | int status; |
216 | int do_update = 0; | 228 | int do_update = 0; |
217 | 229 | ||
218 | pdata = spi->dev.platform_data; | ||
219 | if (!pdata || pdata->slave > 3 || !pdata->base) | ||
220 | return -ENODEV; | ||
221 | |||
222 | mcp = kzalloc(sizeof *mcp, GFP_KERNEL); | ||
223 | if (!mcp) | ||
224 | return -ENOMEM; | ||
225 | |||
226 | mutex_init(&mcp->lock); | 230 | mutex_init(&mcp->lock); |
227 | 231 | ||
228 | mcp->spi = spi; | 232 | mcp->spi = spi; |
229 | mcp->addr = 0x40 | (pdata->slave << 1); | 233 | mcp->addr = 0x40 | (addr << 1); |
230 | 234 | ||
231 | mcp->chip.label = "mcp23s08", | 235 | mcp->chip.label = "mcp23s08", |
232 | 236 | ||
@@ -236,26 +240,28 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
236 | mcp->chip.set = mcp23s08_set; | 240 | mcp->chip.set = mcp23s08_set; |
237 | mcp->chip.dbg_show = mcp23s08_dbg_show; | 241 | mcp->chip.dbg_show = mcp23s08_dbg_show; |
238 | 242 | ||
239 | mcp->chip.base = pdata->base; | 243 | mcp->chip.base = base; |
240 | mcp->chip.ngpio = 8; | 244 | mcp->chip.ngpio = 8; |
241 | mcp->chip.can_sleep = 1; | 245 | mcp->chip.can_sleep = 1; |
246 | mcp->chip.dev = &spi->dev; | ||
242 | mcp->chip.owner = THIS_MODULE; | 247 | mcp->chip.owner = THIS_MODULE; |
243 | 248 | ||
244 | spi_set_drvdata(spi, mcp); | 249 | /* verify MCP_IOCON.SEQOP = 0, so sequential reads work, |
245 | 250 | * and MCP_IOCON.HAEN = 1, so we work with all chips. | |
246 | /* verify MCP_IOCON.SEQOP = 0, so sequential reads work */ | 251 | */ |
247 | status = mcp23s08_read(mcp, MCP_IOCON); | 252 | status = mcp23s08_read(mcp, MCP_IOCON); |
248 | if (status < 0) | 253 | if (status < 0) |
249 | goto fail; | 254 | goto fail; |
250 | if (status & IOCON_SEQOP) { | 255 | if ((status & IOCON_SEQOP) || !(status & IOCON_HAEN)) { |
251 | status &= ~IOCON_SEQOP; | 256 | status &= ~IOCON_SEQOP; |
257 | status |= IOCON_HAEN; | ||
252 | status = mcp23s08_write(mcp, MCP_IOCON, (u8) status); | 258 | status = mcp23s08_write(mcp, MCP_IOCON, (u8) status); |
253 | if (status < 0) | 259 | if (status < 0) |
254 | goto fail; | 260 | goto fail; |
255 | } | 261 | } |
256 | 262 | ||
257 | /* configure ~100K pullups */ | 263 | /* configure ~100K pullups */ |
258 | status = mcp23s08_write(mcp, MCP_GPPU, pdata->pullups); | 264 | status = mcp23s08_write(mcp, MCP_GPPU, pullups); |
259 | if (status < 0) | 265 | if (status < 0) |
260 | goto fail; | 266 | goto fail; |
261 | 267 | ||
@@ -282,11 +288,58 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
282 | tx[1] = MCP_IPOL; | 288 | tx[1] = MCP_IPOL; |
283 | memcpy(&tx[2], &mcp->cache[MCP_IPOL], sizeof(tx) - 2); | 289 | memcpy(&tx[2], &mcp->cache[MCP_IPOL], sizeof(tx) - 2); |
284 | status = spi_write_then_read(mcp->spi, tx, sizeof tx, NULL, 0); | 290 | status = spi_write_then_read(mcp->spi, tx, sizeof tx, NULL, 0); |
285 | 291 | if (status < 0) | |
286 | /* FIXME check status... */ | 292 | goto fail; |
287 | } | 293 | } |
288 | 294 | ||
289 | status = gpiochip_add(&mcp->chip); | 295 | status = gpiochip_add(&mcp->chip); |
296 | fail: | ||
297 | if (status < 0) | ||
298 | dev_dbg(&spi->dev, "can't setup chip %d, --> %d\n", | ||
299 | addr, status); | ||
300 | return status; | ||
301 | } | ||
302 | |||
303 | static int mcp23s08_probe(struct spi_device *spi) | ||
304 | { | ||
305 | struct mcp23s08_platform_data *pdata; | ||
306 | unsigned addr; | ||
307 | unsigned chips = 0; | ||
308 | struct mcp23s08_driver_data *data; | ||
309 | int status; | ||
310 | unsigned base; | ||
311 | |||
312 | pdata = spi->dev.platform_data; | ||
313 | if (!pdata || !gpio_is_valid(pdata->base)) | ||
314 | return -ENODEV; | ||
315 | |||
316 | for (addr = 0; addr < 4; addr++) { | ||
317 | if (!pdata->chip[addr].is_present) | ||
318 | continue; | ||
319 | chips++; | ||
320 | } | ||
321 | if (!chips) | ||
322 | return -ENODEV; | ||
323 | |||
324 | data = kzalloc(sizeof *data + chips * sizeof(struct mcp23s08), | ||
325 | GFP_KERNEL); | ||
326 | if (!data) | ||
327 | return -ENOMEM; | ||
328 | spi_set_drvdata(spi, data); | ||
329 | |||
330 | base = pdata->base; | ||
331 | for (addr = 0; addr < 4; addr++) { | ||
332 | if (!pdata->chip[addr].is_present) | ||
333 | continue; | ||
334 | chips--; | ||
335 | data->mcp[addr] = &data->chip[chips]; | ||
336 | status = mcp23s08_probe_one(spi, addr, base, | ||
337 | pdata->chip[addr].pullups); | ||
338 | if (status < 0) | ||
339 | goto fail; | ||
340 | base += 8; | ||
341 | } | ||
342 | data->ngpio = base - pdata->base; | ||
290 | 343 | ||
291 | /* NOTE: these chips have a relatively sane IRQ framework, with | 344 | /* NOTE: these chips have a relatively sane IRQ framework, with |
292 | * per-signal masking and level/edge triggering. It's not yet | 345 | * per-signal masking and level/edge triggering. It's not yet |
@@ -294,8 +347,9 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
294 | */ | 347 | */ |
295 | 348 | ||
296 | if (pdata->setup) { | 349 | if (pdata->setup) { |
297 | status = pdata->setup(spi, mcp->chip.base, | 350 | status = pdata->setup(spi, |
298 | mcp->chip.ngpio, pdata->context); | 351 | pdata->base, data->ngpio, |
352 | pdata->context); | ||
299 | if (status < 0) | 353 | if (status < 0) |
300 | dev_dbg(&spi->dev, "setup --> %d\n", status); | 354 | dev_dbg(&spi->dev, "setup --> %d\n", status); |
301 | } | 355 | } |
@@ -303,19 +357,29 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
303 | return 0; | 357 | return 0; |
304 | 358 | ||
305 | fail: | 359 | fail: |
306 | kfree(mcp); | 360 | for (addr = 0; addr < 4; addr++) { |
361 | int tmp; | ||
362 | |||
363 | if (!data->mcp[addr]) | ||
364 | continue; | ||
365 | tmp = gpiochip_remove(&data->mcp[addr]->chip); | ||
366 | if (tmp < 0) | ||
367 | dev_err(&spi->dev, "%s --> %d\n", "remove", tmp); | ||
368 | } | ||
369 | kfree(data); | ||
307 | return status; | 370 | return status; |
308 | } | 371 | } |
309 | 372 | ||
310 | static int mcp23s08_remove(struct spi_device *spi) | 373 | static int mcp23s08_remove(struct spi_device *spi) |
311 | { | 374 | { |
312 | struct mcp23s08 *mcp = spi_get_drvdata(spi); | 375 | struct mcp23s08_driver_data *data = spi_get_drvdata(spi); |
313 | struct mcp23s08_platform_data *pdata = spi->dev.platform_data; | 376 | struct mcp23s08_platform_data *pdata = spi->dev.platform_data; |
377 | unsigned addr; | ||
314 | int status = 0; | 378 | int status = 0; |
315 | 379 | ||
316 | if (pdata->teardown) { | 380 | if (pdata->teardown) { |
317 | status = pdata->teardown(spi, | 381 | status = pdata->teardown(spi, |
318 | mcp->chip.base, mcp->chip.ngpio, | 382 | pdata->base, data->ngpio, |
319 | pdata->context); | 383 | pdata->context); |
320 | if (status < 0) { | 384 | if (status < 0) { |
321 | dev_err(&spi->dev, "%s --> %d\n", "teardown", status); | 385 | dev_err(&spi->dev, "%s --> %d\n", "teardown", status); |
@@ -323,11 +387,20 @@ static int mcp23s08_remove(struct spi_device *spi) | |||
323 | } | 387 | } |
324 | } | 388 | } |
325 | 389 | ||
326 | status = gpiochip_remove(&mcp->chip); | 390 | for (addr = 0; addr < 4; addr++) { |
391 | int tmp; | ||
392 | |||
393 | if (!data->mcp[addr]) | ||
394 | continue; | ||
395 | |||
396 | tmp = gpiochip_remove(&data->mcp[addr]->chip); | ||
397 | if (tmp < 0) { | ||
398 | dev_err(&spi->dev, "%s --> %d\n", "remove", tmp); | ||
399 | status = tmp; | ||
400 | } | ||
401 | } | ||
327 | if (status == 0) | 402 | if (status == 0) |
328 | kfree(mcp); | 403 | kfree(data); |
329 | else | ||
330 | dev_err(&spi->dev, "%s --> %d\n", "remove", status); | ||
331 | return status; | 404 | return status; |
332 | } | 405 | } |
333 | 406 | ||
@@ -355,4 +428,3 @@ static void __exit mcp23s08_exit(void) | |||
355 | module_exit(mcp23s08_exit); | 428 | module_exit(mcp23s08_exit); |
356 | 429 | ||
357 | MODULE_LICENSE("GPL"); | 430 | MODULE_LICENSE("GPL"); |
358 | |||
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index a380730b61ab..cc8468692ae0 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c | |||
@@ -188,6 +188,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) | |||
188 | gc->base = chip->gpio_start; | 188 | gc->base = chip->gpio_start; |
189 | gc->ngpio = gpios; | 189 | gc->ngpio = gpios; |
190 | gc->label = chip->client->name; | 190 | gc->label = chip->client->name; |
191 | gc->dev = &chip->client->dev; | ||
191 | gc->owner = THIS_MODULE; | 192 | gc->owner = THIS_MODULE; |
192 | } | 193 | } |
193 | 194 | ||
diff --git a/drivers/gpio/pcf857x.c b/drivers/gpio/pcf857x.c index d25d356c4f20..fc9c6ae739ee 100644 --- a/drivers/gpio/pcf857x.c +++ b/drivers/gpio/pcf857x.c | |||
@@ -200,6 +200,7 @@ static int pcf857x_probe(struct i2c_client *client, | |||
200 | 200 | ||
201 | gpio->chip.base = pdata->gpio_base; | 201 | gpio->chip.base = pdata->gpio_base; |
202 | gpio->chip.can_sleep = 1; | 202 | gpio->chip.can_sleep = 1; |
203 | gpio->chip.dev = &client->dev; | ||
203 | gpio->chip.owner = THIS_MODULE; | 204 | gpio->chip.owner = THIS_MODULE; |
204 | 205 | ||
205 | /* NOTE: the OnSemi jlc1562b is also largely compatible with | 206 | /* NOTE: the OnSemi jlc1562b is also largely compatible with |
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 50e0a4653741..a95cb9465d65 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -126,7 +126,7 @@ config ISP1301_OMAP | |||
126 | 126 | ||
127 | config TPS65010 | 127 | config TPS65010 |
128 | tristate "TPS6501x Power Management chips" | 128 | tristate "TPS6501x Power Management chips" |
129 | depends on HAVE_GPIO_LIB | 129 | depends on GPIOLIB |
130 | default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK | 130 | default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK |
131 | help | 131 | help |
132 | If you say yes here you get support for the TPS6501x series of | 132 | If you say yes here you get support for the TPS6501x series of |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 85949685191b..cf02e8fceb42 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -636,6 +636,8 @@ static int tps65010_probe(struct i2c_client *client, | |||
636 | tps->outmask = board->outmask; | 636 | tps->outmask = board->outmask; |
637 | 637 | ||
638 | tps->chip.label = client->name; | 638 | tps->chip.label = client->name; |
639 | tps->chip.dev = &client->dev; | ||
640 | tps->chip.owner = THIS_MODULE; | ||
639 | 641 | ||
640 | tps->chip.set = tps65010_gpio_set; | 642 | tps->chip.set = tps65010_gpio_set; |
641 | tps->chip.direction_output = tps65010_output; | 643 | tps->chip.direction_output = tps65010_output; |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 04d9c4d459d0..130ef64b44f7 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -314,7 +314,7 @@ comment "IDE chipset support/bugfixes" | |||
314 | 314 | ||
315 | config IDE_GENERIC | 315 | config IDE_GENERIC |
316 | tristate "generic/default IDE chipset support" | 316 | tristate "generic/default IDE chipset support" |
317 | depends on ALPHA || X86 || IA64 || M32R || MIPS || PPC32 | 317 | depends on ALPHA || X86 || IA64 || M32R || MIPS |
318 | help | 318 | help |
319 | If unsure, say N. | 319 | If unsure, say N. |
320 | 320 | ||
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index 5d414e301a5a..64e0ecdc4ed5 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -1,13 +1,6 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the kernel ata, atapi, and ide block device drivers. | ||
3 | # | ||
4 | # 12 September 2000, Bartlomiej Zolnierkiewicz <bkz@linux-ide.org> | ||
5 | # Rewritten to use lists instead of if-statements. | ||
6 | # | ||
7 | # Note : at this point, these files are compiled on all systems. | ||
8 | # In the future, some of these should be built conditionally. | ||
9 | # | ||
10 | # link order is important here | 2 | # link order is important here |
3 | # | ||
11 | 4 | ||
12 | EXTRA_CFLAGS += -Idrivers/ide | 5 | EXTRA_CFLAGS += -Idrivers/ide |
13 | 6 | ||
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index f575e8341aec..df4af4083954 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -710,8 +710,14 @@ static int __init icside_init(void) | |||
710 | return ecard_register_driver(&icside_driver); | 710 | return ecard_register_driver(&icside_driver); |
711 | } | 711 | } |
712 | 712 | ||
713 | static void __exit icside_exit(void); | ||
714 | { | ||
715 | ecard_unregister_driver(&icside_driver); | ||
716 | } | ||
717 | |||
713 | MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); | 718 | MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); |
714 | MODULE_LICENSE("GPL"); | 719 | MODULE_LICENSE("GPL"); |
715 | MODULE_DESCRIPTION("ICS IDE driver"); | 720 | MODULE_DESCRIPTION("ICS IDE driver"); |
716 | 721 | ||
717 | module_init(icside_init); | 722 | module_init(icside_init); |
723 | module_exit(icside_exit); | ||
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index 65bb4b8fd570..3e842d60eae9 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -82,6 +82,7 @@ static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { | |||
82 | {100, 120}, /* UDMA Mode 2 */ | 82 | {100, 120}, /* UDMA Mode 2 */ |
83 | {100, 90}, /* UDMA Mode 3 */ | 83 | {100, 90}, /* UDMA Mode 3 */ |
84 | {100, 60}, /* UDMA Mode 4 */ | 84 | {100, 60}, /* UDMA Mode 4 */ |
85 | {85, 40}, /* UDMA Mode 5 */ | ||
85 | }; | 86 | }; |
86 | 87 | ||
87 | static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, | 88 | static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, |
@@ -334,12 +335,11 @@ static const struct ide_port_ops palm_bk3710_ports_ops = { | |||
334 | .cable_detect = palm_bk3710_cable_detect, | 335 | .cable_detect = palm_bk3710_cable_detect, |
335 | }; | 336 | }; |
336 | 337 | ||
337 | static const struct ide_port_info __devinitdata palm_bk3710_port_info = { | 338 | static struct ide_port_info __devinitdata palm_bk3710_port_info = { |
338 | .init_dma = palm_bk3710_init_dma, | 339 | .init_dma = palm_bk3710_init_dma, |
339 | .port_ops = &palm_bk3710_ports_ops, | 340 | .port_ops = &palm_bk3710_ports_ops, |
340 | .host_flags = IDE_HFLAG_MMIO, | 341 | .host_flags = IDE_HFLAG_MMIO, |
341 | .pio_mask = ATA_PIO4, | 342 | .pio_mask = ATA_PIO4, |
342 | .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */ | ||
343 | .mwdma_mask = ATA_MWDMA2, | 343 | .mwdma_mask = ATA_MWDMA2, |
344 | }; | 344 | }; |
345 | 345 | ||
@@ -352,7 +352,7 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
352 | int i, rc; | 352 | int i, rc; |
353 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 353 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
354 | 354 | ||
355 | clk = clk_get(NULL, "IDECLK"); | 355 | clk = clk_get(&pdev->dev, "IDECLK"); |
356 | if (IS_ERR(clk)) | 356 | if (IS_ERR(clk)) |
357 | return -ENODEV; | 357 | return -ENODEV; |
358 | 358 | ||
@@ -392,6 +392,9 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
392 | hw.irq = irq->start; | 392 | hw.irq = irq->start; |
393 | hw.chipset = ide_palm3710; | 393 | hw.chipset = ide_palm3710; |
394 | 394 | ||
395 | palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 : | ||
396 | ATA_UDMA5; | ||
397 | |||
395 | rc = ide_host_add(&palm_bk3710_port_info, hws, NULL); | 398 | rc = ide_host_add(&palm_bk3710_port_info, hws, NULL); |
396 | if (rc) | 399 | if (rc) |
397 | goto out; | 400 | goto out; |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index 2bdd8b734afb..78d27d9ae430 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -95,7 +95,13 @@ static int __init rapide_init(void) | |||
95 | return ecard_register_driver(&rapide_driver); | 95 | return ecard_register_driver(&rapide_driver); |
96 | } | 96 | } |
97 | 97 | ||
98 | static void __exit rapide_exit(void) | ||
99 | { | ||
100 | ecard_unregister_driver(&rapide_driver); | ||
101 | } | ||
102 | |||
98 | MODULE_LICENSE("GPL"); | 103 | MODULE_LICENSE("GPL"); |
99 | MODULE_DESCRIPTION("Yellowstone RAPIDE driver"); | 104 | MODULE_DESCRIPTION("Yellowstone RAPIDE driver"); |
100 | 105 | ||
101 | module_init(rapide_init); | 106 | module_init(rapide_init); |
107 | module_exit(rapide_exit); | ||
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 4e73aeee4053..e617cf08aef6 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -57,23 +57,29 @@ static DEFINE_MUTEX(idecd_ref_mutex); | |||
57 | #define ide_cd_g(disk) \ | 57 | #define ide_cd_g(disk) \ |
58 | container_of((disk)->private_data, struct cdrom_info, driver) | 58 | container_of((disk)->private_data, struct cdrom_info, driver) |
59 | 59 | ||
60 | static void ide_cd_release(struct kref *); | ||
61 | |||
60 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) | 62 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) |
61 | { | 63 | { |
62 | struct cdrom_info *cd = NULL; | 64 | struct cdrom_info *cd = NULL; |
63 | 65 | ||
64 | mutex_lock(&idecd_ref_mutex); | 66 | mutex_lock(&idecd_ref_mutex); |
65 | cd = ide_cd_g(disk); | 67 | cd = ide_cd_g(disk); |
66 | if (cd) | 68 | if (cd) { |
67 | kref_get(&cd->kref); | 69 | kref_get(&cd->kref); |
70 | if (ide_device_get(cd->drive)) { | ||
71 | kref_put(&cd->kref, ide_cd_release); | ||
72 | cd = NULL; | ||
73 | } | ||
74 | } | ||
68 | mutex_unlock(&idecd_ref_mutex); | 75 | mutex_unlock(&idecd_ref_mutex); |
69 | return cd; | 76 | return cd; |
70 | } | 77 | } |
71 | 78 | ||
72 | static void ide_cd_release(struct kref *); | ||
73 | |||
74 | static void ide_cd_put(struct cdrom_info *cd) | 79 | static void ide_cd_put(struct cdrom_info *cd) |
75 | { | 80 | { |
76 | mutex_lock(&idecd_ref_mutex); | 81 | mutex_lock(&idecd_ref_mutex); |
82 | ide_device_put(cd->drive); | ||
77 | kref_put(&cd->kref, ide_cd_release); | 83 | kref_put(&cd->kref, ide_cd_release); |
78 | mutex_unlock(&idecd_ref_mutex); | 84 | mutex_unlock(&idecd_ref_mutex); |
79 | } | 85 | } |
@@ -1305,13 +1311,30 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | |||
1305 | 1311 | ||
1306 | stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0, | 1312 | stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0, |
1307 | REQ_QUIET); | 1313 | REQ_QUIET); |
1308 | if (stat == 0) { | 1314 | if (stat) |
1309 | *capacity = 1 + be32_to_cpu(capbuf.lba); | 1315 | return stat; |
1310 | *sectors_per_frame = | 1316 | |
1311 | be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; | 1317 | /* |
1318 | * Sanity check the given block size | ||
1319 | */ | ||
1320 | switch (capbuf.blocklen) { | ||
1321 | case __constant_cpu_to_be32(512): | ||
1322 | case __constant_cpu_to_be32(1024): | ||
1323 | case __constant_cpu_to_be32(2048): | ||
1324 | case __constant_cpu_to_be32(4096): | ||
1325 | break; | ||
1326 | default: | ||
1327 | printk(KERN_ERR "%s: weird block size %u\n", | ||
1328 | drive->name, capbuf.blocklen); | ||
1329 | printk(KERN_ERR "%s: default to 2kb block size\n", | ||
1330 | drive->name); | ||
1331 | capbuf.blocklen = __constant_cpu_to_be32(2048); | ||
1332 | break; | ||
1312 | } | 1333 | } |
1313 | 1334 | ||
1314 | return stat; | 1335 | *capacity = 1 + be32_to_cpu(capbuf.lba); |
1336 | *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; | ||
1337 | return 0; | ||
1315 | } | 1338 | } |
1316 | 1339 | ||
1317 | static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, | 1340 | static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index df5fe5756871..28d85b410f7c 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -56,23 +56,29 @@ static DEFINE_MUTEX(idedisk_ref_mutex); | |||
56 | #define ide_disk_g(disk) \ | 56 | #define ide_disk_g(disk) \ |
57 | container_of((disk)->private_data, struct ide_disk_obj, driver) | 57 | container_of((disk)->private_data, struct ide_disk_obj, driver) |
58 | 58 | ||
59 | static void ide_disk_release(struct kref *); | ||
60 | |||
59 | static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) | 61 | static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) |
60 | { | 62 | { |
61 | struct ide_disk_obj *idkp = NULL; | 63 | struct ide_disk_obj *idkp = NULL; |
62 | 64 | ||
63 | mutex_lock(&idedisk_ref_mutex); | 65 | mutex_lock(&idedisk_ref_mutex); |
64 | idkp = ide_disk_g(disk); | 66 | idkp = ide_disk_g(disk); |
65 | if (idkp) | 67 | if (idkp) { |
66 | kref_get(&idkp->kref); | 68 | kref_get(&idkp->kref); |
69 | if (ide_device_get(idkp->drive)) { | ||
70 | kref_put(&idkp->kref, ide_disk_release); | ||
71 | idkp = NULL; | ||
72 | } | ||
73 | } | ||
67 | mutex_unlock(&idedisk_ref_mutex); | 74 | mutex_unlock(&idedisk_ref_mutex); |
68 | return idkp; | 75 | return idkp; |
69 | } | 76 | } |
70 | 77 | ||
71 | static void ide_disk_release(struct kref *); | ||
72 | |||
73 | static void ide_disk_put(struct ide_disk_obj *idkp) | 78 | static void ide_disk_put(struct ide_disk_obj *idkp) |
74 | { | 79 | { |
75 | mutex_lock(&idedisk_ref_mutex); | 80 | mutex_lock(&idedisk_ref_mutex); |
81 | ide_device_put(idkp->drive); | ||
76 | kref_put(&idkp->kref, ide_disk_release); | 82 | kref_put(&idkp->kref, ide_disk_release); |
77 | mutex_unlock(&idedisk_ref_mutex); | 83 | mutex_unlock(&idedisk_ref_mutex); |
78 | } | 84 | } |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index be99d463dcc7..71c377a7bcf2 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -173,7 +173,7 @@ EXPORT_SYMBOL_GPL(ide_build_sglist); | |||
173 | int ide_build_dmatable (ide_drive_t *drive, struct request *rq) | 173 | int ide_build_dmatable (ide_drive_t *drive, struct request *rq) |
174 | { | 174 | { |
175 | ide_hwif_t *hwif = HWIF(drive); | 175 | ide_hwif_t *hwif = HWIF(drive); |
176 | unsigned int *table = hwif->dmatable_cpu; | 176 | __le32 *table = (__le32 *)hwif->dmatable_cpu; |
177 | unsigned int is_trm290 = (hwif->chipset == ide_trm290) ? 1 : 0; | 177 | unsigned int is_trm290 = (hwif->chipset == ide_trm290) ? 1 : 0; |
178 | unsigned int count = 0; | 178 | unsigned int count = 0; |
179 | int i; | 179 | int i; |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 3d8e6dd0f41e..ca11a26746f1 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -158,23 +158,29 @@ static DEFINE_MUTEX(idefloppy_ref_mutex); | |||
158 | #define ide_floppy_g(disk) \ | 158 | #define ide_floppy_g(disk) \ |
159 | container_of((disk)->private_data, struct ide_floppy_obj, driver) | 159 | container_of((disk)->private_data, struct ide_floppy_obj, driver) |
160 | 160 | ||
161 | static void idefloppy_cleanup_obj(struct kref *); | ||
162 | |||
161 | static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) | 163 | static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) |
162 | { | 164 | { |
163 | struct ide_floppy_obj *floppy = NULL; | 165 | struct ide_floppy_obj *floppy = NULL; |
164 | 166 | ||
165 | mutex_lock(&idefloppy_ref_mutex); | 167 | mutex_lock(&idefloppy_ref_mutex); |
166 | floppy = ide_floppy_g(disk); | 168 | floppy = ide_floppy_g(disk); |
167 | if (floppy) | 169 | if (floppy) { |
168 | kref_get(&floppy->kref); | 170 | kref_get(&floppy->kref); |
171 | if (ide_device_get(floppy->drive)) { | ||
172 | kref_put(&floppy->kref, idefloppy_cleanup_obj); | ||
173 | floppy = NULL; | ||
174 | } | ||
175 | } | ||
169 | mutex_unlock(&idefloppy_ref_mutex); | 176 | mutex_unlock(&idefloppy_ref_mutex); |
170 | return floppy; | 177 | return floppy; |
171 | } | 178 | } |
172 | 179 | ||
173 | static void idefloppy_cleanup_obj(struct kref *); | ||
174 | |||
175 | static void ide_floppy_put(struct ide_floppy_obj *floppy) | 180 | static void ide_floppy_put(struct ide_floppy_obj *floppy) |
176 | { | 181 | { |
177 | mutex_lock(&idefloppy_ref_mutex); | 182 | mutex_lock(&idefloppy_ref_mutex); |
183 | ide_device_put(floppy->drive); | ||
178 | kref_put(&floppy->kref, idefloppy_cleanup_obj); | 184 | kref_put(&floppy->kref, idefloppy_cleanup_obj); |
179 | mutex_unlock(&idefloppy_ref_mutex); | 185 | mutex_unlock(&idefloppy_ref_mutex); |
180 | } | 186 | } |
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 31d98fec775f..8fe8b5b9cf7d 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -20,6 +20,11 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/ide.h> | 21 | #include <linux/ide.h> |
22 | 22 | ||
23 | /* FIXME: convert m32r to use ide_platform host driver */ | ||
24 | #ifdef CONFIG_M32R | ||
25 | #include <asm/m32r.h> | ||
26 | #endif | ||
27 | |||
23 | #define DRV_NAME "ide_generic" | 28 | #define DRV_NAME "ide_generic" |
24 | 29 | ||
25 | static int probe_mask = 0x03; | 30 | static int probe_mask = 0x03; |
@@ -80,6 +85,21 @@ static int __init ide_generic_sysfs_init(void) | |||
80 | return 0; | 85 | return 0; |
81 | } | 86 | } |
82 | 87 | ||
88 | #if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \ | ||
89 | || defined(CONFIG_PLAT_OPSPUT) | ||
90 | static const u16 legacy_bases[] = { 0x1f0 }; | ||
91 | static const int legacy_irqs[] = { PLD_IRQ_CFIREQ }; | ||
92 | #elif defined(CONFIG_PLAT_MAPPI3) | ||
93 | static const u16 legacy_bases[] = { 0x1f0, 0x170 }; | ||
94 | static const int legacy_irqs[] = { PLD_IRQ_CFIREQ, PLD_IRQ_IDEIREQ }; | ||
95 | #elif defined(CONFIG_ALPHA) | ||
96 | static const u16 legacy_bases[] = { 0x1f0, 0x170, 0x1e8, 0x168 }; | ||
97 | static const int legacy_irqs[] = { 14, 15, 11, 10 }; | ||
98 | #else | ||
99 | static const u16 legacy_bases[] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 }; | ||
100 | static const int legacy_irqs[] = { 14, 15, 11, 10, 8, 12 }; | ||
101 | #endif | ||
102 | |||
83 | static int __init ide_generic_init(void) | 103 | static int __init ide_generic_init(void) |
84 | { | 104 | { |
85 | hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; | 105 | hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; |
@@ -87,11 +107,17 @@ static int __init ide_generic_init(void) | |||
87 | unsigned long io_addr; | 107 | unsigned long io_addr; |
88 | int i, rc; | 108 | int i, rc; |
89 | 109 | ||
110 | #ifdef CONFIG_MIPS | ||
111 | if (!ide_probe_legacy()) | ||
112 | return -ENODEV; | ||
113 | #endif | ||
90 | printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " | 114 | printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " |
91 | "parameter for probing all legacy ISA IDE ports\n"); | 115 | "parameter for probing all legacy ISA IDE ports\n"); |
92 | 116 | ||
93 | for (i = 0; i < MAX_HWIFS; i++) { | 117 | memset(hws, 0, sizeof(hw_regs_t *) * MAX_HWIFS); |
94 | io_addr = ide_default_io_base(i); | 118 | |
119 | for (i = 0; i < ARRAY_SIZE(legacy_bases); i++) { | ||
120 | io_addr = legacy_bases[i]; | ||
95 | 121 | ||
96 | hws[i] = NULL; | 122 | hws[i] = NULL; |
97 | 123 | ||
@@ -113,7 +139,11 @@ static int __init ide_generic_init(void) | |||
113 | 139 | ||
114 | memset(&hw[i], 0, sizeof(hw[i])); | 140 | memset(&hw[i], 0, sizeof(hw[i])); |
115 | ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206); | 141 | ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206); |
116 | hw[i].irq = ide_default_irq(io_addr); | 142 | #ifdef CONFIG_IA64 |
143 | hw[i].irq = isa_irq_to_vector(legacy_irqs[i]); | ||
144 | #else | ||
145 | hw[i].irq = legacy_irqs[i]; | ||
146 | #endif | ||
117 | hw[i].chipset = ide_generic; | 147 | hw[i].chipset = ide_generic; |
118 | 148 | ||
119 | hws[i] = &hw[i]; | 149 | hws[i] = &hw[i]; |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 07da5fb9eaff..8aae91764513 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -510,10 +510,8 @@ void ide_fixstring (u8 *s, const int bytecount, const int byteswap) | |||
510 | 510 | ||
511 | if (byteswap) { | 511 | if (byteswap) { |
512 | /* convert from big-endian to host byte order */ | 512 | /* convert from big-endian to host byte order */ |
513 | for (p = end ; p != s;) { | 513 | for (p = end ; p != s;) |
514 | unsigned short *pp = (unsigned short *) (p -= 2); | 514 | be16_to_cpus((u16 *)(p -= 2)); |
515 | *pp = ntohs(*pp); | ||
516 | } | ||
517 | } | 515 | } |
518 | /* strip leading blanks */ | 516 | /* strip leading blanks */ |
519 | while (s != end && *s == ' ') | 517 | while (s != end && *s == ' ') |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 4aa76c453755..994e41099b42 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -134,18 +134,6 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
134 | #endif | 134 | #endif |
135 | ide_fix_driveid(id); | 135 | ide_fix_driveid(id); |
136 | 136 | ||
137 | #if defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA) | ||
138 | /* | ||
139 | * EATA SCSI controllers do a hardware ATA emulation: | ||
140 | * Ignore them if there is a driver for them available. | ||
141 | */ | ||
142 | if ((id->model[0] == 'P' && id->model[1] == 'M') || | ||
143 | (id->model[0] == 'S' && id->model[1] == 'K')) { | ||
144 | printk("%s: EATA SCSI HBA %.10s\n", drive->name, id->model); | ||
145 | goto err_misc; | ||
146 | } | ||
147 | #endif /* CONFIG_SCSI_EATA || CONFIG_SCSI_EATA_PIO */ | ||
148 | |||
149 | /* | 137 | /* |
150 | * WIN_IDENTIFY returns little-endian info, | 138 | * WIN_IDENTIFY returns little-endian info, |
151 | * WIN_PIDENTIFY *usually* returns little-endian info. | 139 | * WIN_PIDENTIFY *usually* returns little-endian info. |
@@ -167,7 +155,8 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
167 | if (strstr(id->model, "E X A B Y T E N E S T")) | 155 | if (strstr(id->model, "E X A B Y T E N E S T")) |
168 | goto err_misc; | 156 | goto err_misc; |
169 | 157 | ||
170 | printk("%s: %s, ", drive->name, id->model); | 158 | printk(KERN_INFO "%s: %s, ", drive->name, id->model); |
159 | |||
171 | drive->present = 1; | 160 | drive->present = 1; |
172 | drive->dead = 0; | 161 | drive->dead = 0; |
173 | 162 | ||
@@ -176,16 +165,17 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
176 | */ | 165 | */ |
177 | if (cmd == WIN_PIDENTIFY) { | 166 | if (cmd == WIN_PIDENTIFY) { |
178 | u8 type = (id->config >> 8) & 0x1f; | 167 | u8 type = (id->config >> 8) & 0x1f; |
179 | printk("ATAPI "); | 168 | |
169 | printk(KERN_CONT "ATAPI "); | ||
180 | switch (type) { | 170 | switch (type) { |
181 | case ide_floppy: | 171 | case ide_floppy: |
182 | if (!strstr(id->model, "CD-ROM")) { | 172 | if (!strstr(id->model, "CD-ROM")) { |
183 | if (!strstr(id->model, "oppy") && | 173 | if (!strstr(id->model, "oppy") && |
184 | !strstr(id->model, "poyp") && | 174 | !strstr(id->model, "poyp") && |
185 | !strstr(id->model, "ZIP")) | 175 | !strstr(id->model, "ZIP")) |
186 | printk("cdrom or floppy?, assuming "); | 176 | printk(KERN_CONT "cdrom or floppy?, assuming "); |
187 | if (drive->media != ide_cdrom) { | 177 | if (drive->media != ide_cdrom) { |
188 | printk ("FLOPPY"); | 178 | printk(KERN_CONT "FLOPPY"); |
189 | drive->removable = 1; | 179 | drive->removable = 1; |
190 | break; | 180 | break; |
191 | } | 181 | } |
@@ -198,25 +188,25 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
198 | /* kludge for Apple PowerBook internal zip */ | 188 | /* kludge for Apple PowerBook internal zip */ |
199 | if (!strstr(id->model, "CD-ROM") && | 189 | if (!strstr(id->model, "CD-ROM") && |
200 | strstr(id->model, "ZIP")) { | 190 | strstr(id->model, "ZIP")) { |
201 | printk ("FLOPPY"); | 191 | printk(KERN_CONT "FLOPPY"); |
202 | type = ide_floppy; | 192 | type = ide_floppy; |
203 | break; | 193 | break; |
204 | } | 194 | } |
205 | #endif | 195 | #endif |
206 | printk ("CD/DVD-ROM"); | 196 | printk(KERN_CONT "CD/DVD-ROM"); |
207 | break; | 197 | break; |
208 | case ide_tape: | 198 | case ide_tape: |
209 | printk ("TAPE"); | 199 | printk(KERN_CONT "TAPE"); |
210 | break; | 200 | break; |
211 | case ide_optical: | 201 | case ide_optical: |
212 | printk ("OPTICAL"); | 202 | printk(KERN_CONT "OPTICAL"); |
213 | drive->removable = 1; | 203 | drive->removable = 1; |
214 | break; | 204 | break; |
215 | default: | 205 | default: |
216 | printk("UNKNOWN (type %d)", type); | 206 | printk(KERN_CONT "UNKNOWN (type %d)", type); |
217 | break; | 207 | break; |
218 | } | 208 | } |
219 | printk (" drive\n"); | 209 | printk(KERN_CONT " drive\n"); |
220 | drive->media = type; | 210 | drive->media = type; |
221 | /* an ATAPI device ignores DRDY */ | 211 | /* an ATAPI device ignores DRDY */ |
222 | drive->ready_stat = 0; | 212 | drive->ready_stat = 0; |
@@ -236,7 +226,9 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
236 | drive->removable = 1; | 226 | drive->removable = 1; |
237 | 227 | ||
238 | drive->media = ide_disk; | 228 | drive->media = ide_disk; |
239 | printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" ); | 229 | |
230 | printk(KERN_CONT "%s DISK drive\n", | ||
231 | (id->config == 0x848a) ? "CFA" : "ATA"); | ||
240 | 232 | ||
241 | return; | 233 | return; |
242 | 234 | ||
@@ -387,7 +379,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) | |||
387 | /* Mmmm.. multiple IRQs.. | 379 | /* Mmmm.. multiple IRQs.. |
388 | * don't know which was ours | 380 | * don't know which was ours |
389 | */ | 381 | */ |
390 | printk("%s: IRQ probe failed (0x%lx)\n", | 382 | printk(KERN_ERR "%s: IRQ probe failed (0x%lx)\n", |
391 | drive->name, cookie); | 383 | drive->name, cookie); |
392 | } | 384 | } |
393 | } | 385 | } |
@@ -456,7 +448,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
456 | return 4; | 448 | return 4; |
457 | } | 449 | } |
458 | #ifdef DEBUG | 450 | #ifdef DEBUG |
459 | printk("probing for %s: present=%d, media=%d, probetype=%s\n", | 451 | printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n", |
460 | drive->name, drive->present, drive->media, | 452 | drive->name, drive->present, drive->media, |
461 | (cmd == WIN_IDENTIFY) ? "ATA" : "ATAPI"); | 453 | (cmd == WIN_IDENTIFY) ? "ATA" : "ATAPI"); |
462 | #endif | 454 | #endif |
@@ -534,7 +526,8 @@ static void enable_nest (ide_drive_t *drive) | |||
534 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 526 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
535 | u8 stat; | 527 | u8 stat; |
536 | 528 | ||
537 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); | 529 | printk(KERN_INFO "%s: enabling %s -- ", hwif->name, drive->id->model); |
530 | |||
538 | SELECT_DRIVE(drive); | 531 | SELECT_DRIVE(drive); |
539 | msleep(50); | 532 | msleep(50); |
540 | tp_ops->exec_command(hwif, EXABYTE_ENABLE_NEST); | 533 | tp_ops->exec_command(hwif, EXABYTE_ENABLE_NEST); |
@@ -883,7 +876,7 @@ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match) | |||
883 | if (m && m->hwgroup && m->hwgroup != new->hwgroup) { | 876 | if (m && m->hwgroup && m->hwgroup != new->hwgroup) { |
884 | if (!new->hwgroup) | 877 | if (!new->hwgroup) |
885 | return; | 878 | return; |
886 | printk("%s: potential irq problem with %s and %s\n", | 879 | printk(KERN_WARNING "%s: potential IRQ problem with %s and %s\n", |
887 | hwif->name, new->name, m->name); | 880 | hwif->name, new->name, m->name); |
888 | } | 881 | } |
889 | if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */ | 882 | if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */ |
@@ -1142,17 +1135,17 @@ static int init_irq (ide_hwif_t *hwif) | |||
1142 | } | 1135 | } |
1143 | 1136 | ||
1144 | #if !defined(__mc68000__) | 1137 | #if !defined(__mc68000__) |
1145 | printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, | 1138 | printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, |
1146 | io_ports->data_addr, io_ports->status_addr, | 1139 | io_ports->data_addr, io_ports->status_addr, |
1147 | io_ports->ctl_addr, hwif->irq); | 1140 | io_ports->ctl_addr, hwif->irq); |
1148 | #else | 1141 | #else |
1149 | printk("%s at 0x%08lx on irq %d", hwif->name, | 1142 | printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name, |
1150 | io_ports->data_addr, hwif->irq); | 1143 | io_ports->data_addr, hwif->irq); |
1151 | #endif /* __mc68000__ */ | 1144 | #endif /* __mc68000__ */ |
1152 | if (match) | 1145 | if (match) |
1153 | printk(" (%sed with %s)", | 1146 | printk(KERN_CONT " (%sed with %s)", |
1154 | hwif->sharing_irq ? "shar" : "serializ", match->name); | 1147 | hwif->sharing_irq ? "shar" : "serializ", match->name); |
1155 | printk("\n"); | 1148 | printk(KERN_CONT "\n"); |
1156 | 1149 | ||
1157 | mutex_unlock(&ide_cfg_mtx); | 1150 | mutex_unlock(&ide_cfg_mtx); |
1158 | return 0; | 1151 | return 0; |
@@ -1287,7 +1280,7 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1287 | if (!hwif->irq) { | 1280 | if (!hwif->irq) { |
1288 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); | 1281 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); |
1289 | if (!hwif->irq) { | 1282 | if (!hwif->irq) { |
1290 | printk("%s: DISABLED, NO IRQ\n", hwif->name); | 1283 | printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name); |
1291 | return 0; | 1284 | return 0; |
1292 | } | 1285 | } |
1293 | } | 1286 | } |
@@ -1317,16 +1310,16 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1317 | */ | 1310 | */ |
1318 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); | 1311 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); |
1319 | if (!hwif->irq) { | 1312 | if (!hwif->irq) { |
1320 | printk("%s: Disabled unable to get IRQ %d.\n", | 1313 | printk(KERN_ERR "%s: disabled, unable to get IRQ %d\n", |
1321 | hwif->name, old_irq); | 1314 | hwif->name, old_irq); |
1322 | goto out; | 1315 | goto out; |
1323 | } | 1316 | } |
1324 | if (init_irq(hwif)) { | 1317 | if (init_irq(hwif)) { |
1325 | printk("%s: probed IRQ %d and default IRQ %d failed.\n", | 1318 | printk(KERN_ERR "%s: probed IRQ %d and default IRQ %d failed\n", |
1326 | hwif->name, old_irq, hwif->irq); | 1319 | hwif->name, old_irq, hwif->irq); |
1327 | goto out; | 1320 | goto out; |
1328 | } | 1321 | } |
1329 | printk("%s: probed IRQ %d failed, using default.\n", | 1322 | printk(KERN_WARNING "%s: probed IRQ %d failed, using default\n", |
1330 | hwif->name, hwif->irq); | 1323 | hwif->name, hwif->irq); |
1331 | 1324 | ||
1332 | done: | 1325 | done: |
@@ -1595,6 +1588,8 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d, | |||
1595 | 1588 | ||
1596 | ide_init_port_data(hwif, idx); | 1589 | ide_init_port_data(hwif, idx); |
1597 | 1590 | ||
1591 | hwif->host = host; | ||
1592 | |||
1598 | host->ports[i] = hwif; | 1593 | host->ports[i] = hwif; |
1599 | host->n_ports++; | 1594 | host->n_ports++; |
1600 | } | 1595 | } |
@@ -1604,6 +1599,12 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d, | |||
1604 | return NULL; | 1599 | return NULL; |
1605 | } | 1600 | } |
1606 | 1601 | ||
1602 | if (hws[0]) | ||
1603 | host->dev[0] = hws[0]->dev; | ||
1604 | |||
1605 | if (d) | ||
1606 | host->host_flags = d->host_flags; | ||
1607 | |||
1607 | return host; | 1608 | return host; |
1608 | } | 1609 | } |
1609 | EXPORT_SYMBOL_GPL(ide_host_alloc_all); | 1610 | EXPORT_SYMBOL_GPL(ide_host_alloc_all); |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 151c91e933da..f66c9c3f6fc6 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -105,7 +105,7 @@ static int proc_ide_read_identify | |||
105 | len = sprintf(page, "\n"); | 105 | len = sprintf(page, "\n"); |
106 | 106 | ||
107 | if (drive) { | 107 | if (drive) { |
108 | unsigned short *val = (unsigned short *) page; | 108 | __le16 *val = (__le16 *)page; |
109 | 109 | ||
110 | err = taskfile_lib_get_identify(drive, page); | 110 | err = taskfile_lib_get_identify(drive, page); |
111 | if (!err) { | 111 | if (!err) { |
@@ -113,7 +113,7 @@ static int proc_ide_read_identify | |||
113 | page = out; | 113 | page = out; |
114 | do { | 114 | do { |
115 | out += sprintf(out, "%04x%c", | 115 | out += sprintf(out, "%04x%c", |
116 | le16_to_cpu(*val), (++i & 7) ? ' ' : '\n'); | 116 | le16_to_cpup(val), (++i & 7) ? ' ' : '\n'); |
117 | val += 1; | 117 | val += 1; |
118 | } while (i < (SECTOR_WORDS * 2)); | 118 | } while (i < (SECTOR_WORDS * 2)); |
119 | len = out - page; | 119 | len = out - page; |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 6962ca4891a1..82c2afe4d28a 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -322,23 +322,29 @@ static struct class *idetape_sysfs_class; | |||
322 | #define ide_tape_g(disk) \ | 322 | #define ide_tape_g(disk) \ |
323 | container_of((disk)->private_data, struct ide_tape_obj, driver) | 323 | container_of((disk)->private_data, struct ide_tape_obj, driver) |
324 | 324 | ||
325 | static void ide_tape_release(struct kref *); | ||
326 | |||
325 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | 327 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) |
326 | { | 328 | { |
327 | struct ide_tape_obj *tape = NULL; | 329 | struct ide_tape_obj *tape = NULL; |
328 | 330 | ||
329 | mutex_lock(&idetape_ref_mutex); | 331 | mutex_lock(&idetape_ref_mutex); |
330 | tape = ide_tape_g(disk); | 332 | tape = ide_tape_g(disk); |
331 | if (tape) | 333 | if (tape) { |
332 | kref_get(&tape->kref); | 334 | kref_get(&tape->kref); |
335 | if (ide_device_get(tape->drive)) { | ||
336 | kref_put(&tape->kref, ide_tape_release); | ||
337 | tape = NULL; | ||
338 | } | ||
339 | } | ||
333 | mutex_unlock(&idetape_ref_mutex); | 340 | mutex_unlock(&idetape_ref_mutex); |
334 | return tape; | 341 | return tape; |
335 | } | 342 | } |
336 | 343 | ||
337 | static void ide_tape_release(struct kref *); | ||
338 | |||
339 | static void ide_tape_put(struct ide_tape_obj *tape) | 344 | static void ide_tape_put(struct ide_tape_obj *tape) |
340 | { | 345 | { |
341 | mutex_lock(&idetape_ref_mutex); | 346 | mutex_lock(&idetape_ref_mutex); |
347 | ide_device_put(tape->drive); | ||
342 | kref_put(&tape->kref, ide_tape_release); | 348 | kref_put(&tape->kref, ide_tape_release); |
343 | mutex_unlock(&idetape_ref_mutex); | 349 | mutex_unlock(&idetape_ref_mutex); |
344 | } | 350 | } |
@@ -649,10 +655,10 @@ static void ide_tape_callback(ide_drive_t *drive) | |||
649 | uptodate = 0; | 655 | uptodate = 0; |
650 | } else { | 656 | } else { |
651 | debug_log(DBG_SENSE, "Block Location - %u\n", | 657 | debug_log(DBG_SENSE, "Block Location - %u\n", |
652 | be32_to_cpu(*(u32 *)&readpos[4])); | 658 | be32_to_cpup((__be32 *)&readpos[4])); |
653 | 659 | ||
654 | tape->partition = readpos[1]; | 660 | tape->partition = readpos[1]; |
655 | tape->first_frame = be32_to_cpu(*(u32 *)&readpos[4]); | 661 | tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); |
656 | set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); | 662 | set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); |
657 | } | 663 | } |
658 | } | 664 | } |
@@ -2375,23 +2381,23 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
2375 | caps = pc.buf + 4 + pc.buf[3]; | 2381 | caps = pc.buf + 4 + pc.buf[3]; |
2376 | 2382 | ||
2377 | /* convert to host order and save for later use */ | 2383 | /* convert to host order and save for later use */ |
2378 | speed = be16_to_cpu(*(u16 *)&caps[14]); | 2384 | speed = be16_to_cpup((__be16 *)&caps[14]); |
2379 | max_speed = be16_to_cpu(*(u16 *)&caps[8]); | 2385 | max_speed = be16_to_cpup((__be16 *)&caps[8]); |
2380 | 2386 | ||
2381 | put_unaligned(max_speed, (u16 *)&caps[8]); | 2387 | *(u16 *)&caps[8] = max_speed; |
2382 | put_unaligned(be16_to_cpu(*(u16 *)&caps[12]), (u16 *)&caps[12]); | 2388 | *(u16 *)&caps[12] = be16_to_cpup((__be16 *)&caps[12]); |
2383 | put_unaligned(speed, (u16 *)&caps[14]); | 2389 | *(u16 *)&caps[14] = speed; |
2384 | put_unaligned(be16_to_cpu(*(u16 *)&caps[16]), (u16 *)&caps[16]); | 2390 | *(u16 *)&caps[16] = be16_to_cpup((__be16 *)&caps[16]); |
2385 | 2391 | ||
2386 | if (!speed) { | 2392 | if (!speed) { |
2387 | printk(KERN_INFO "ide-tape: %s: invalid tape speed " | 2393 | printk(KERN_INFO "ide-tape: %s: invalid tape speed " |
2388 | "(assuming 650KB/sec)\n", drive->name); | 2394 | "(assuming 650KB/sec)\n", drive->name); |
2389 | put_unaligned(650, (u16 *)&caps[14]); | 2395 | *(u16 *)&caps[14] = 650; |
2390 | } | 2396 | } |
2391 | if (!max_speed) { | 2397 | if (!max_speed) { |
2392 | printk(KERN_INFO "ide-tape: %s: invalid max_speed " | 2398 | printk(KERN_INFO "ide-tape: %s: invalid max_speed " |
2393 | "(assuming 650KB/sec)\n", drive->name); | 2399 | "(assuming 650KB/sec)\n", drive->name); |
2394 | put_unaligned(650, (u16 *)&caps[8]); | 2400 | *(u16 *)&caps[8] = 650; |
2395 | } | 2401 | } |
2396 | 2402 | ||
2397 | memcpy(&tape->caps, caps, 20); | 2403 | memcpy(&tape->caps, caps, 20); |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index aeddbbd69e86..7fb6f1c86272 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -126,7 +126,10 @@ EXPORT_SYMBOL_GPL(do_rw_taskfile); | |||
126 | static ide_startstop_t set_multmode_intr(ide_drive_t *drive) | 126 | static ide_startstop_t set_multmode_intr(ide_drive_t *drive) |
127 | { | 127 | { |
128 | ide_hwif_t *hwif = drive->hwif; | 128 | ide_hwif_t *hwif = drive->hwif; |
129 | u8 stat = hwif->tp_ops->read_status(hwif); | 129 | u8 stat; |
130 | |||
131 | local_irq_enable_in_hardirq(); | ||
132 | stat = hwif->tp_ops->read_status(hwif); | ||
130 | 133 | ||
131 | if (OK_STAT(stat, READY_STAT, BAD_STAT)) | 134 | if (OK_STAT(stat, READY_STAT, BAD_STAT)) |
132 | drive->mult_count = drive->mult_req; | 135 | drive->mult_count = drive->mult_req; |
@@ -147,6 +150,8 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive) | |||
147 | int retries = 5; | 150 | int retries = 5; |
148 | u8 stat; | 151 | u8 stat; |
149 | 152 | ||
153 | local_irq_enable_in_hardirq(); | ||
154 | |||
150 | while (1) { | 155 | while (1) { |
151 | stat = hwif->tp_ops->read_status(hwif); | 156 | stat = hwif->tp_ops->read_status(hwif); |
152 | if ((stat & BUSY_STAT) == 0 || retries-- == 0) | 157 | if ((stat & BUSY_STAT) == 0 || retries-- == 0) |
@@ -170,7 +175,10 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive) | |||
170 | static ide_startstop_t recal_intr(ide_drive_t *drive) | 175 | static ide_startstop_t recal_intr(ide_drive_t *drive) |
171 | { | 176 | { |
172 | ide_hwif_t *hwif = drive->hwif; | 177 | ide_hwif_t *hwif = drive->hwif; |
173 | u8 stat = hwif->tp_ops->read_status(hwif); | 178 | u8 stat; |
179 | |||
180 | local_irq_enable_in_hardirq(); | ||
181 | stat = hwif->tp_ops->read_status(hwif); | ||
174 | 182 | ||
175 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) | 183 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) |
176 | return ide_error(drive, "recal_intr", stat); | 184 | return ide_error(drive, "recal_intr", stat); |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 60f0ca66aa93..772451600e4d 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -618,6 +618,53 @@ set_val: | |||
618 | 618 | ||
619 | EXPORT_SYMBOL(generic_ide_ioctl); | 619 | EXPORT_SYMBOL(generic_ide_ioctl); |
620 | 620 | ||
621 | /** | ||
622 | * ide_device_get - get an additional reference to a ide_drive_t | ||
623 | * @drive: device to get a reference to | ||
624 | * | ||
625 | * Gets a reference to the ide_drive_t and increments the use count of the | ||
626 | * underlying LLDD module. | ||
627 | */ | ||
628 | int ide_device_get(ide_drive_t *drive) | ||
629 | { | ||
630 | struct device *host_dev; | ||
631 | struct module *module; | ||
632 | |||
633 | if (!get_device(&drive->gendev)) | ||
634 | return -ENXIO; | ||
635 | |||
636 | host_dev = drive->hwif->host->dev[0]; | ||
637 | module = host_dev ? host_dev->driver->owner : NULL; | ||
638 | |||
639 | if (module && !try_module_get(module)) { | ||
640 | put_device(&drive->gendev); | ||
641 | return -ENXIO; | ||
642 | } | ||
643 | |||
644 | return 0; | ||
645 | } | ||
646 | EXPORT_SYMBOL_GPL(ide_device_get); | ||
647 | |||
648 | /** | ||
649 | * ide_device_put - release a reference to a ide_drive_t | ||
650 | * @drive: device to release a reference on | ||
651 | * | ||
652 | * Release a reference to the ide_drive_t and decrements the use count of | ||
653 | * the underlying LLDD module. | ||
654 | */ | ||
655 | void ide_device_put(ide_drive_t *drive) | ||
656 | { | ||
657 | #ifdef CONFIG_MODULE_UNLOAD | ||
658 | struct device *host_dev = drive->hwif->host->dev[0]; | ||
659 | struct module *module = host_dev ? host_dev->driver->owner : NULL; | ||
660 | |||
661 | if (module) | ||
662 | module_put(module); | ||
663 | #endif | ||
664 | put_device(&drive->gendev); | ||
665 | } | ||
666 | EXPORT_SYMBOL_GPL(ide_device_put); | ||
667 | |||
621 | static int ide_bus_match(struct device *dev, struct device_driver *drv) | 668 | static int ide_bus_match(struct device *dev, struct device_driver *drv) |
622 | { | 669 | { |
623 | return 1; | 670 | return 1; |
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index dd5c467d8dd0..51ba085d7aa8 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
@@ -127,7 +127,7 @@ static int __init gayle_init(void) | |||
127 | unsigned long phys_base, res_start, res_n; | 127 | unsigned long phys_base, res_start, res_n; |
128 | unsigned long base, ctrlport, irqport; | 128 | unsigned long base, ctrlport, irqport; |
129 | ide_ack_intr_t *ack_intr; | 129 | ide_ack_intr_t *ack_intr; |
130 | int a4000, i; | 130 | int a4000, i, rc; |
131 | hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; | 131 | hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; |
132 | 132 | ||
133 | if (!MACH_IS_AMIGA) | 133 | if (!MACH_IS_AMIGA) |
@@ -179,7 +179,11 @@ found: | |||
179 | hws[i] = &hw[i]; | 179 | hws[i] = &hw[i]; |
180 | } | 180 | } |
181 | 181 | ||
182 | return ide_host_add(NULL, hws, NULL); | 182 | rc = ide_host_add(NULL, hws, NULL); |
183 | if (rc) | ||
184 | release_mem_region(res_start, res_n); | ||
185 | |||
186 | return rc; | ||
183 | } | 187 | } |
184 | 188 | ||
185 | module_init(gayle_init); | 189 | module_init(gayle_init); |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 7bc8fd59ea9e..98f7c95e39ed 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -3,34 +3,12 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | /* | 5 | /* |
6 | * | ||
7 | * Version 0.01 Initial version hacked out of ide.c | ||
8 | * | ||
9 | * Version 0.02 Added support for PIO modes, auto-tune | ||
10 | * | ||
11 | * Version 0.03 Some cleanups | ||
12 | * | ||
13 | * Version 0.05 PIO mode cycle timings auto-tune using bus-speed | ||
14 | * | ||
15 | * Version 0.06 Prefetch mode now defaults no OFF. To set | ||
16 | * prefetch mode OFF/ON use "hdparm -p8/-p9". | ||
17 | * Unmask irq is disabled when prefetch mode | ||
18 | * is enabled. | ||
19 | * | ||
20 | * Version 0.07 Trying to fix CD-ROM detection problem. | ||
21 | * "Prefetch" mode bit OFF for ide disks and | ||
22 | * ON for anything else. | ||
23 | * | ||
24 | * Version 0.08 Need to force prefetch for CDs and other non-disk | ||
25 | * devices. (not sure which devices exactly need | ||
26 | * prefetch) | ||
27 | * | ||
28 | * HT-6560B EIDE-controller support | 6 | * HT-6560B EIDE-controller support |
29 | * To activate controller support use kernel parameter "ide0=ht6560b". | 7 | * To activate controller support use kernel parameter "ide0=ht6560b". |
30 | * Use hdparm utility to enable PIO mode support. | 8 | * Use hdparm utility to enable PIO mode support. |
31 | * | 9 | * |
32 | * Author: Mikko Ala-Fossi <maf@iki.fi> | 10 | * Author: Mikko Ala-Fossi <maf@iki.fi> |
33 | * Jan Evert van Grootheest <janevert@caiway.nl> | 11 | * Jan Evert van Grootheest <j.e.van.grootheest@caiway.nl> |
34 | * | 12 | * |
35 | * Try: http://www.maf.iki.fi/~maf/ht6560b/ | 13 | * Try: http://www.maf.iki.fi/~maf/ht6560b/ |
36 | */ | 14 | */ |
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index fbc43e121e6b..e0c8fe7d9fea 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -13,6 +13,8 @@ | |||
13 | 13 | ||
14 | #include <asm/io.h> | 14 | #include <asm/io.h> |
15 | 15 | ||
16 | #define DRV_NAME "aec62xx" | ||
17 | |||
16 | struct chipset_bus_clock_list_entry { | 18 | struct chipset_bus_clock_list_entry { |
17 | u8 xfer_speed; | 19 | u8 xfer_speed; |
18 | u8 chipset_settings; | 20 | u8 chipset_settings; |
@@ -59,10 +61,6 @@ static const struct chipset_bus_clock_list_entry aec6xxx_34_base [] = { | |||
59 | { 0, 0x00, 0x00 } | 61 | { 0, 0x00, 0x00 } |
60 | }; | 62 | }; |
61 | 63 | ||
62 | #define BUSCLOCK(D) \ | ||
63 | ((struct chipset_bus_clock_list_entry *) pci_get_drvdata((D))) | ||
64 | |||
65 | |||
66 | /* | 64 | /* |
67 | * TO DO: active tuning and correction of cards without a bios. | 65 | * TO DO: active tuning and correction of cards without a bios. |
68 | */ | 66 | */ |
@@ -88,6 +86,8 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | |||
88 | { | 86 | { |
89 | ide_hwif_t *hwif = HWIF(drive); | 87 | ide_hwif_t *hwif = HWIF(drive); |
90 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 88 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
89 | struct ide_host *host = pci_get_drvdata(dev); | ||
90 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; | ||
91 | u16 d_conf = 0; | 91 | u16 d_conf = 0; |
92 | u8 ultra = 0, ultra_conf = 0; | 92 | u8 ultra = 0, ultra_conf = 0; |
93 | u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; | 93 | u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; |
@@ -96,7 +96,7 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | |||
96 | local_irq_save(flags); | 96 | local_irq_save(flags); |
97 | /* 0x40|(2*drive->dn): Active, 0x41|(2*drive->dn): Recovery */ | 97 | /* 0x40|(2*drive->dn): Active, 0x41|(2*drive->dn): Recovery */ |
98 | pci_read_config_word(dev, 0x40|(2*drive->dn), &d_conf); | 98 | pci_read_config_word(dev, 0x40|(2*drive->dn), &d_conf); |
99 | tmp0 = pci_bus_clock_list(speed, BUSCLOCK(dev)); | 99 | tmp0 = pci_bus_clock_list(speed, bus_clock); |
100 | d_conf = ((tmp0 & 0xf0) << 4) | (tmp0 & 0xf); | 100 | d_conf = ((tmp0 & 0xf0) << 4) | (tmp0 & 0xf); |
101 | pci_write_config_word(dev, 0x40|(2*drive->dn), d_conf); | 101 | pci_write_config_word(dev, 0x40|(2*drive->dn), d_conf); |
102 | 102 | ||
@@ -104,7 +104,7 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | |||
104 | tmp2 = 0x00; | 104 | tmp2 = 0x00; |
105 | pci_read_config_byte(dev, 0x54, &ultra); | 105 | pci_read_config_byte(dev, 0x54, &ultra); |
106 | tmp1 = ((0x00 << (2*drive->dn)) | (ultra & ~(3 << (2*drive->dn)))); | 106 | tmp1 = ((0x00 << (2*drive->dn)) | (ultra & ~(3 << (2*drive->dn)))); |
107 | ultra_conf = pci_bus_clock_list_ultra(speed, BUSCLOCK(dev)); | 107 | ultra_conf = pci_bus_clock_list_ultra(speed, bus_clock); |
108 | tmp2 = ((ultra_conf << (2*drive->dn)) | (tmp1 & ~(3 << (2*drive->dn)))); | 108 | tmp2 = ((ultra_conf << (2*drive->dn)) | (tmp1 & ~(3 << (2*drive->dn)))); |
109 | pci_write_config_byte(dev, 0x54, tmp2); | 109 | pci_write_config_byte(dev, 0x54, tmp2); |
110 | local_irq_restore(flags); | 110 | local_irq_restore(flags); |
@@ -114,6 +114,8 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) | |||
114 | { | 114 | { |
115 | ide_hwif_t *hwif = HWIF(drive); | 115 | ide_hwif_t *hwif = HWIF(drive); |
116 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 116 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
117 | struct ide_host *host = pci_get_drvdata(dev); | ||
118 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; | ||
117 | u8 unit = (drive->select.b.unit & 0x01); | 119 | u8 unit = (drive->select.b.unit & 0x01); |
118 | u8 tmp1 = 0, tmp2 = 0; | 120 | u8 tmp1 = 0, tmp2 = 0; |
119 | u8 ultra = 0, drive_conf = 0, ultra_conf = 0; | 121 | u8 ultra = 0, drive_conf = 0, ultra_conf = 0; |
@@ -122,12 +124,12 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) | |||
122 | local_irq_save(flags); | 124 | local_irq_save(flags); |
123 | /* high 4-bits: Active, low 4-bits: Recovery */ | 125 | /* high 4-bits: Active, low 4-bits: Recovery */ |
124 | pci_read_config_byte(dev, 0x40|drive->dn, &drive_conf); | 126 | pci_read_config_byte(dev, 0x40|drive->dn, &drive_conf); |
125 | drive_conf = pci_bus_clock_list(speed, BUSCLOCK(dev)); | 127 | drive_conf = pci_bus_clock_list(speed, bus_clock); |
126 | pci_write_config_byte(dev, 0x40|drive->dn, drive_conf); | 128 | pci_write_config_byte(dev, 0x40|drive->dn, drive_conf); |
127 | 129 | ||
128 | pci_read_config_byte(dev, (0x44|hwif->channel), &ultra); | 130 | pci_read_config_byte(dev, (0x44|hwif->channel), &ultra); |
129 | tmp1 = ((0x00 << (4*unit)) | (ultra & ~(7 << (4*unit)))); | 131 | tmp1 = ((0x00 << (4*unit)) | (ultra & ~(7 << (4*unit)))); |
130 | ultra_conf = pci_bus_clock_list_ultra(speed, BUSCLOCK(dev)); | 132 | ultra_conf = pci_bus_clock_list_ultra(speed, bus_clock); |
131 | tmp2 = ((ultra_conf << (4*unit)) | (tmp1 & ~(7 << (4*unit)))); | 133 | tmp2 = ((ultra_conf << (4*unit)) | (tmp1 & ~(7 << (4*unit)))); |
132 | pci_write_config_byte(dev, (0x44|hwif->channel), tmp2); | 134 | pci_write_config_byte(dev, (0x44|hwif->channel), tmp2); |
133 | local_irq_restore(flags); | 135 | local_irq_restore(flags); |
@@ -138,15 +140,8 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
138 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); | 140 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); |
139 | } | 141 | } |
140 | 142 | ||
141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) | 143 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev) |
142 | { | 144 | { |
143 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; | ||
144 | |||
145 | if (bus_speed <= 33) | ||
146 | pci_set_drvdata(dev, (void *) aec6xxx_33_base); | ||
147 | else | ||
148 | pci_set_drvdata(dev, (void *) aec6xxx_34_base); | ||
149 | |||
150 | /* These are necessary to get AEC6280 Macintosh cards to work */ | 145 | /* These are necessary to get AEC6280 Macintosh cards to work */ |
151 | if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) || | 146 | if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) || |
152 | (dev->device == PCI_DEVICE_ID_ARTOP_ATP865R)) { | 147 | (dev->device == PCI_DEVICE_ID_ARTOP_ATP865R)) { |
@@ -187,8 +182,8 @@ static const struct ide_port_ops atp86x_port_ops = { | |||
187 | }; | 182 | }; |
188 | 183 | ||
189 | static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | 184 | static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { |
190 | { /* 0 */ | 185 | { /* 0: AEC6210 */ |
191 | .name = "AEC6210", | 186 | .name = DRV_NAME, |
192 | .init_chipset = init_chipset_aec62xx, | 187 | .init_chipset = init_chipset_aec62xx, |
193 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 188 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
194 | .port_ops = &atp850_port_ops, | 189 | .port_ops = &atp850_port_ops, |
@@ -199,8 +194,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
199 | .pio_mask = ATA_PIO4, | 194 | .pio_mask = ATA_PIO4, |
200 | .mwdma_mask = ATA_MWDMA2, | 195 | .mwdma_mask = ATA_MWDMA2, |
201 | .udma_mask = ATA_UDMA2, | 196 | .udma_mask = ATA_UDMA2, |
202 | },{ /* 1 */ | 197 | }, |
203 | .name = "AEC6260", | 198 | { /* 1: AEC6260 */ |
199 | .name = DRV_NAME, | ||
204 | .init_chipset = init_chipset_aec62xx, | 200 | .init_chipset = init_chipset_aec62xx, |
205 | .port_ops = &atp86x_port_ops, | 201 | .port_ops = &atp86x_port_ops, |
206 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | | 202 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | |
@@ -208,8 +204,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
208 | .pio_mask = ATA_PIO4, | 204 | .pio_mask = ATA_PIO4, |
209 | .mwdma_mask = ATA_MWDMA2, | 205 | .mwdma_mask = ATA_MWDMA2, |
210 | .udma_mask = ATA_UDMA4, | 206 | .udma_mask = ATA_UDMA4, |
211 | },{ /* 2 */ | 207 | }, |
212 | .name = "AEC6260R", | 208 | { /* 2: AEC6260R */ |
209 | .name = DRV_NAME, | ||
213 | .init_chipset = init_chipset_aec62xx, | 210 | .init_chipset = init_chipset_aec62xx, |
214 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 211 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
215 | .port_ops = &atp86x_port_ops, | 212 | .port_ops = &atp86x_port_ops, |
@@ -218,8 +215,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
218 | .pio_mask = ATA_PIO4, | 215 | .pio_mask = ATA_PIO4, |
219 | .mwdma_mask = ATA_MWDMA2, | 216 | .mwdma_mask = ATA_MWDMA2, |
220 | .udma_mask = ATA_UDMA4, | 217 | .udma_mask = ATA_UDMA4, |
221 | },{ /* 3 */ | 218 | }, |
222 | .name = "AEC6280", | 219 | { /* 3: AEC6280 */ |
220 | .name = DRV_NAME, | ||
223 | .init_chipset = init_chipset_aec62xx, | 221 | .init_chipset = init_chipset_aec62xx, |
224 | .port_ops = &atp86x_port_ops, | 222 | .port_ops = &atp86x_port_ops, |
225 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 223 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
@@ -227,8 +225,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
227 | .pio_mask = ATA_PIO4, | 225 | .pio_mask = ATA_PIO4, |
228 | .mwdma_mask = ATA_MWDMA2, | 226 | .mwdma_mask = ATA_MWDMA2, |
229 | .udma_mask = ATA_UDMA5, | 227 | .udma_mask = ATA_UDMA5, |
230 | },{ /* 4 */ | 228 | }, |
231 | .name = "AEC6280R", | 229 | { /* 4: AEC6280R */ |
230 | .name = DRV_NAME, | ||
232 | .init_chipset = init_chipset_aec62xx, | 231 | .init_chipset = init_chipset_aec62xx, |
233 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 232 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
234 | .port_ops = &atp86x_port_ops, | 233 | .port_ops = &atp86x_port_ops, |
@@ -254,10 +253,17 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
254 | 253 | ||
255 | static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 254 | static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
256 | { | 255 | { |
256 | const struct chipset_bus_clock_list_entry *bus_clock; | ||
257 | struct ide_port_info d; | 257 | struct ide_port_info d; |
258 | u8 idx = id->driver_data; | 258 | u8 idx = id->driver_data; |
259 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; | ||
259 | int err; | 260 | int err; |
260 | 261 | ||
262 | if (bus_speed <= 33) | ||
263 | bus_clock = aec6xxx_33_base; | ||
264 | else | ||
265 | bus_clock = aec6xxx_34_base; | ||
266 | |||
261 | err = pci_enable_device(dev); | 267 | err = pci_enable_device(dev); |
262 | if (err) | 268 | if (err) |
263 | return err; | 269 | return err; |
@@ -268,18 +274,25 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi | |||
268 | unsigned long dma_base = pci_resource_start(dev, 4); | 274 | unsigned long dma_base = pci_resource_start(dev, 4); |
269 | 275 | ||
270 | if (inb(dma_base + 2) & 0x10) { | 276 | if (inb(dma_base + 2) & 0x10) { |
271 | d.name = (idx == 4) ? "AEC6880R" : "AEC6880"; | 277 | printk(KERN_INFO DRV_NAME " %s: AEC6880%s card detected" |
278 | "\n", pci_name(dev), (idx == 4) ? "R" : ""); | ||
272 | d.udma_mask = ATA_UDMA6; | 279 | d.udma_mask = ATA_UDMA6; |
273 | } | 280 | } |
274 | } | 281 | } |
275 | 282 | ||
276 | err = ide_setup_pci_device(dev, &d); | 283 | err = ide_pci_init_one(dev, &d, (void *)bus_clock); |
277 | if (err) | 284 | if (err) |
278 | pci_disable_device(dev); | 285 | pci_disable_device(dev); |
279 | 286 | ||
280 | return err; | 287 | return err; |
281 | } | 288 | } |
282 | 289 | ||
290 | static void __devexit aec62xx_remove(struct pci_dev *dev) | ||
291 | { | ||
292 | ide_pci_remove(dev); | ||
293 | pci_disable_device(dev); | ||
294 | } | ||
295 | |||
283 | static const struct pci_device_id aec62xx_pci_tbl[] = { | 296 | static const struct pci_device_id aec62xx_pci_tbl[] = { |
284 | { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF), 0 }, | 297 | { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF), 0 }, |
285 | { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP860), 1 }, | 298 | { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP860), 1 }, |
@@ -294,6 +307,7 @@ static struct pci_driver driver = { | |||
294 | .name = "AEC62xx_IDE", | 307 | .name = "AEC62xx_IDE", |
295 | .id_table = aec62xx_pci_tbl, | 308 | .id_table = aec62xx_pci_tbl, |
296 | .probe = aec62xx_init_one, | 309 | .probe = aec62xx_init_one, |
310 | .remove = aec62xx_remove, | ||
297 | }; | 311 | }; |
298 | 312 | ||
299 | static int __init aec62xx_ide_init(void) | 313 | static int __init aec62xx_ide_init(void) |
@@ -301,7 +315,13 @@ static int __init aec62xx_ide_init(void) | |||
301 | return ide_pci_register_driver(&driver); | 315 | return ide_pci_register_driver(&driver); |
302 | } | 316 | } |
303 | 317 | ||
318 | static void __exit aec62xx_ide_exit(void) | ||
319 | { | ||
320 | pci_unregister_driver(&driver); | ||
321 | } | ||
322 | |||
304 | module_init(aec62xx_ide_init); | 323 | module_init(aec62xx_ide_init); |
324 | module_exit(aec62xx_ide_exit); | ||
305 | 325 | ||
306 | MODULE_AUTHOR("Andre Hedrick"); | 326 | MODULE_AUTHOR("Andre Hedrick"); |
307 | MODULE_DESCRIPTION("PCI driver module for ARTOP AEC62xx IDE"); | 327 | MODULE_DESCRIPTION("PCI driver module for ARTOP AEC62xx IDE"); |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 5ef7817ac64f..b582687e0cd4 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -38,6 +38,8 @@ | |||
38 | 38 | ||
39 | #include <asm/io.h> | 39 | #include <asm/io.h> |
40 | 40 | ||
41 | #define DRV_NAME "alim15x3" | ||
42 | |||
41 | /* | 43 | /* |
42 | * Allow UDMA on M1543C-E chipset for WDC disks that ignore CRC checking | 44 | * Allow UDMA on M1543C-E chipset for WDC disks that ignore CRC checking |
43 | * (this is DANGEROUS and could result in data corruption). | 45 | * (this is DANGEROUS and could result in data corruption). |
@@ -207,13 +209,12 @@ static int ali15x3_dma_setup(ide_drive_t *drive) | |||
207 | /** | 209 | /** |
208 | * init_chipset_ali15x3 - Initialise an ALi IDE controller | 210 | * init_chipset_ali15x3 - Initialise an ALi IDE controller |
209 | * @dev: PCI device | 211 | * @dev: PCI device |
210 | * @name: Name of the controller | ||
211 | * | 212 | * |
212 | * This function initializes the ALI IDE controller and where | 213 | * This function initializes the ALI IDE controller and where |
213 | * appropriate also sets up the 1533 southbridge. | 214 | * appropriate also sets up the 1533 southbridge. |
214 | */ | 215 | */ |
215 | 216 | ||
216 | static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const char *name) | 217 | static unsigned int __devinit init_chipset_ali15x3(struct pci_dev *dev) |
217 | { | 218 | { |
218 | unsigned long flags; | 219 | unsigned long flags; |
219 | u8 tmpbyte; | 220 | u8 tmpbyte; |
@@ -515,7 +516,7 @@ static const struct ide_dma_ops ali_dma_ops = { | |||
515 | }; | 516 | }; |
516 | 517 | ||
517 | static const struct ide_port_info ali15x3_chipset __devinitdata = { | 518 | static const struct ide_port_info ali15x3_chipset __devinitdata = { |
518 | .name = "ALI15X3", | 519 | .name = DRV_NAME, |
519 | .init_chipset = init_chipset_ali15x3, | 520 | .init_chipset = init_chipset_ali15x3, |
520 | .init_hwif = init_hwif_ali15x3, | 521 | .init_hwif = init_hwif_ali15x3, |
521 | .init_dma = init_dma_ali15x3, | 522 | .init_dma = init_dma_ali15x3, |
@@ -565,7 +566,7 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev | |||
565 | if (idx == 0) | 566 | if (idx == 0) |
566 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | 567 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; |
567 | 568 | ||
568 | return ide_setup_pci_device(dev, &d); | 569 | return ide_pci_init_one(dev, &d, NULL); |
569 | } | 570 | } |
570 | 571 | ||
571 | 572 | ||
@@ -580,6 +581,7 @@ static struct pci_driver driver = { | |||
580 | .name = "ALI15x3_IDE", | 581 | .name = "ALI15x3_IDE", |
581 | .id_table = alim15x3_pci_tbl, | 582 | .id_table = alim15x3_pci_tbl, |
582 | .probe = alim15x3_init_one, | 583 | .probe = alim15x3_init_one, |
584 | .remove = ide_pci_remove, | ||
583 | }; | 585 | }; |
584 | 586 | ||
585 | static int __init ali15x3_ide_init(void) | 587 | static int __init ali15x3_ide_init(void) |
@@ -587,7 +589,13 @@ static int __init ali15x3_ide_init(void) | |||
587 | return ide_pci_register_driver(&driver); | 589 | return ide_pci_register_driver(&driver); |
588 | } | 590 | } |
589 | 591 | ||
592 | static void __exit ali15x3_ide_exit(void) | ||
593 | { | ||
594 | return pci_unregister_driver(&driver); | ||
595 | } | ||
596 | |||
590 | module_init(ali15x3_ide_init); | 597 | module_init(ali15x3_ide_init); |
598 | module_exit(ali15x3_ide_exit); | ||
591 | 599 | ||
592 | MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox"); | 600 | MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox"); |
593 | MODULE_DESCRIPTION("PCI driver module for ALi 15x3 IDE"); | 601 | MODULE_DESCRIPTION("PCI driver module for ALi 15x3 IDE"); |
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index ef7d971031ee..2cea7bf51a0f 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/ide.h> | 22 | #include <linux/ide.h> |
23 | 23 | ||
24 | #define DRV_NAME "amd74xx" | ||
25 | |||
24 | enum { | 26 | enum { |
25 | AMD_IDE_CONFIG = 0x41, | 27 | AMD_IDE_CONFIG = 0x41, |
26 | AMD_CABLE_DETECT = 0x42, | 28 | AMD_CABLE_DETECT = 0x42, |
@@ -110,15 +112,13 @@ static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
110 | amd_set_drive(drive, XFER_PIO_0 + pio); | 112 | amd_set_drive(drive, XFER_PIO_0 + pio); |
111 | } | 113 | } |
112 | 114 | ||
113 | static void __devinit amd7409_cable_detect(struct pci_dev *dev, | 115 | static void __devinit amd7409_cable_detect(struct pci_dev *dev) |
114 | const char *name) | ||
115 | { | 116 | { |
116 | /* no host side cable detection */ | 117 | /* no host side cable detection */ |
117 | amd_80w = 0x03; | 118 | amd_80w = 0x03; |
118 | } | 119 | } |
119 | 120 | ||
120 | static void __devinit amd7411_cable_detect(struct pci_dev *dev, | 121 | static void __devinit amd7411_cable_detect(struct pci_dev *dev) |
121 | const char *name) | ||
122 | { | 122 | { |
123 | int i; | 123 | int i; |
124 | u32 u = 0; | 124 | u32 u = 0; |
@@ -129,9 +129,9 @@ static void __devinit amd7411_cable_detect(struct pci_dev *dev, | |||
129 | amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); | 129 | amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); |
130 | for (i = 24; i >= 0; i -= 8) | 130 | for (i = 24; i >= 0; i -= 8) |
131 | if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { | 131 | if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { |
132 | printk(KERN_WARNING "%s: BIOS didn't set cable bits " | 132 | printk(KERN_WARNING DRV_NAME " %s: BIOS didn't set " |
133 | "correctly. Enabling workaround.\n", | 133 | "cable bits correctly. Enabling workaround.\n", |
134 | name); | 134 | pci_name(dev)); |
135 | amd_80w |= (1 << (1 - (i >> 4))); | 135 | amd_80w |= (1 << (1 - (i >> 4))); |
136 | } | 136 | } |
137 | } | 137 | } |
@@ -140,8 +140,7 @@ static void __devinit amd7411_cable_detect(struct pci_dev *dev, | |||
140 | * The initialization callback. Initialize drive independent registers. | 140 | * The initialization callback. Initialize drive independent registers. |
141 | */ | 141 | */ |
142 | 142 | ||
143 | static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | 143 | static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev) |
144 | const char *name) | ||
145 | { | 144 | { |
146 | u8 t = 0, offset = amd_offset(dev); | 145 | u8 t = 0, offset = amd_offset(dev); |
147 | 146 | ||
@@ -154,9 +153,9 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | |||
154 | ; /* no UDMA > 2 */ | 153 | ; /* no UDMA > 2 */ |
155 | else if (dev->vendor == PCI_VENDOR_ID_AMD && | 154 | else if (dev->vendor == PCI_VENDOR_ID_AMD && |
156 | dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) | 155 | dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) |
157 | amd7409_cable_detect(dev, name); | 156 | amd7409_cable_detect(dev); |
158 | else | 157 | else |
159 | amd7411_cable_detect(dev, name); | 158 | amd7411_cable_detect(dev); |
160 | 159 | ||
161 | /* | 160 | /* |
162 | * Take care of prefetch & postwrite. | 161 | * Take care of prefetch & postwrite. |
@@ -173,24 +172,6 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | |||
173 | t |= 0xf0; | 172 | t |= 0xf0; |
174 | pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); | 173 | pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); |
175 | 174 | ||
176 | /* | ||
177 | * Determine the system bus clock. | ||
178 | */ | ||
179 | |||
180 | amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; | ||
181 | |||
182 | switch (amd_clock) { | ||
183 | case 33000: amd_clock = 33333; break; | ||
184 | case 37000: amd_clock = 37500; break; | ||
185 | case 41000: amd_clock = 41666; break; | ||
186 | } | ||
187 | |||
188 | if (amd_clock < 20000 || amd_clock > 50000) { | ||
189 | printk(KERN_WARNING "%s: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", | ||
190 | name, amd_clock); | ||
191 | amd_clock = 33333; | ||
192 | } | ||
193 | |||
194 | return dev->irq; | 175 | return dev->irq; |
195 | } | 176 | } |
196 | 177 | ||
@@ -222,9 +203,9 @@ static const struct ide_port_ops amd_port_ops = { | |||
222 | IDE_HFLAG_IO_32BIT | \ | 203 | IDE_HFLAG_IO_32BIT | \ |
223 | IDE_HFLAG_UNMASK_IRQS) | 204 | IDE_HFLAG_UNMASK_IRQS) |
224 | 205 | ||
225 | #define DECLARE_AMD_DEV(name_str, swdma, udma) \ | 206 | #define DECLARE_AMD_DEV(swdma, udma) \ |
226 | { \ | 207 | { \ |
227 | .name = name_str, \ | 208 | .name = DRV_NAME, \ |
228 | .init_chipset = init_chipset_amd74xx, \ | 209 | .init_chipset = init_chipset_amd74xx, \ |
229 | .init_hwif = init_hwif_amd74xx, \ | 210 | .init_hwif = init_hwif_amd74xx, \ |
230 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ | 211 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ |
@@ -236,9 +217,9 @@ static const struct ide_port_ops amd_port_ops = { | |||
236 | .udma_mask = udma, \ | 217 | .udma_mask = udma, \ |
237 | } | 218 | } |
238 | 219 | ||
239 | #define DECLARE_NV_DEV(name_str, udma) \ | 220 | #define DECLARE_NV_DEV(udma) \ |
240 | { \ | 221 | { \ |
241 | .name = name_str, \ | 222 | .name = DRV_NAME, \ |
242 | .init_chipset = init_chipset_amd74xx, \ | 223 | .init_chipset = init_chipset_amd74xx, \ |
243 | .init_hwif = init_hwif_amd74xx, \ | 224 | .init_hwif = init_hwif_amd74xx, \ |
244 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ | 225 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ |
@@ -251,31 +232,15 @@ static const struct ide_port_ops amd_port_ops = { | |||
251 | } | 232 | } |
252 | 233 | ||
253 | static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { | 234 | static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { |
254 | /* 0 */ DECLARE_AMD_DEV("AMD7401", 0x00, ATA_UDMA2), | 235 | /* 0: AMD7401 */ DECLARE_AMD_DEV(0x00, ATA_UDMA2), |
255 | /* 1 */ DECLARE_AMD_DEV("AMD7409", ATA_SWDMA2, ATA_UDMA4), | 236 | /* 1: AMD7409 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA4), |
256 | /* 2 */ DECLARE_AMD_DEV("AMD7411", ATA_SWDMA2, ATA_UDMA5), | 237 | /* 2: AMD7411/7441 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5), |
257 | /* 3 */ DECLARE_AMD_DEV("AMD7441", ATA_SWDMA2, ATA_UDMA5), | 238 | /* 3: AMD8111 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA6), |
258 | /* 4 */ DECLARE_AMD_DEV("AMD8111", ATA_SWDMA2, ATA_UDMA6), | 239 | |
259 | 240 | /* 4: NFORCE */ DECLARE_NV_DEV(ATA_UDMA5), | |
260 | /* 5 */ DECLARE_NV_DEV("NFORCE", ATA_UDMA5), | 241 | /* 5: >= NFORCE2 */ DECLARE_NV_DEV(ATA_UDMA6), |
261 | /* 6 */ DECLARE_NV_DEV("NFORCE2", ATA_UDMA6), | 242 | |
262 | /* 7 */ DECLARE_NV_DEV("NFORCE2-U400R", ATA_UDMA6), | 243 | /* 6: AMD5536 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5), |
263 | /* 8 */ DECLARE_NV_DEV("NFORCE2-U400R-SATA", ATA_UDMA6), | ||
264 | /* 9 */ DECLARE_NV_DEV("NFORCE3-150", ATA_UDMA6), | ||
265 | /* 10 */ DECLARE_NV_DEV("NFORCE3-250", ATA_UDMA6), | ||
266 | /* 11 */ DECLARE_NV_DEV("NFORCE3-250-SATA", ATA_UDMA6), | ||
267 | /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2", ATA_UDMA6), | ||
268 | /* 13 */ DECLARE_NV_DEV("NFORCE-CK804", ATA_UDMA6), | ||
269 | /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04", ATA_UDMA6), | ||
270 | /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51", ATA_UDMA6), | ||
271 | /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55", ATA_UDMA6), | ||
272 | /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61", ATA_UDMA6), | ||
273 | /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65", ATA_UDMA6), | ||
274 | /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67", ATA_UDMA6), | ||
275 | /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73", ATA_UDMA6), | ||
276 | /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77", ATA_UDMA6), | ||
277 | |||
278 | /* 22 */ DECLARE_AMD_DEV("AMD5536", ATA_SWDMA2, ATA_UDMA5), | ||
279 | }; | 244 | }; |
280 | 245 | ||
281 | static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) | 246 | static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) |
@@ -292,47 +257,64 @@ static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_ | |||
292 | if (dev->revision <= 7) | 257 | if (dev->revision <= 7) |
293 | d.swdma_mask = 0; | 258 | d.swdma_mask = 0; |
294 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | 259 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; |
295 | } else if (idx == 4) { | 260 | } else if (idx == 3) { |
296 | if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD && | 261 | if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD && |
297 | dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) | 262 | dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) |
298 | d.udma_mask = ATA_UDMA5; | 263 | d.udma_mask = ATA_UDMA5; |
299 | } | 264 | } |
300 | 265 | ||
301 | printk(KERN_INFO "%s: %s (rev %02x) UDMA%s controller\n", | 266 | printk(KERN_INFO "%s %s: UDMA%s controller\n", |
302 | d.name, pci_name(dev), dev->revision, | 267 | d.name, pci_name(dev), amd_dma[fls(d.udma_mask) - 1]); |
303 | amd_dma[fls(d.udma_mask) - 1]); | 268 | |
269 | /* | ||
270 | * Determine the system bus clock. | ||
271 | */ | ||
272 | amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; | ||
273 | |||
274 | switch (amd_clock) { | ||
275 | case 33000: amd_clock = 33333; break; | ||
276 | case 37000: amd_clock = 37500; break; | ||
277 | case 41000: amd_clock = 41666; break; | ||
278 | } | ||
279 | |||
280 | if (amd_clock < 20000 || amd_clock > 50000) { | ||
281 | printk(KERN_WARNING "%s: User given PCI clock speed impossible" | ||
282 | " (%d), using 33 MHz instead.\n", | ||
283 | d.name, amd_clock); | ||
284 | amd_clock = 33333; | ||
285 | } | ||
304 | 286 | ||
305 | return ide_setup_pci_device(dev, &d); | 287 | return ide_pci_init_one(dev, &d, NULL); |
306 | } | 288 | } |
307 | 289 | ||
308 | static const struct pci_device_id amd74xx_pci_tbl[] = { | 290 | static const struct pci_device_id amd74xx_pci_tbl[] = { |
309 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 }, | 291 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 }, |
310 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 }, | 292 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 }, |
311 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 2 }, | 293 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 2 }, |
312 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 3 }, | 294 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 2 }, |
313 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 4 }, | 295 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 3 }, |
314 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 5 }, | 296 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 4 }, |
315 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 6 }, | 297 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 5 }, |
316 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 7 }, | 298 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 5 }, |
317 | #ifdef CONFIG_BLK_DEV_IDE_SATA | 299 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
318 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA), 8 }, | 300 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA), 5 }, |
319 | #endif | 301 | #endif |
320 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 9 }, | 302 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 5 }, |
321 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 10 }, | 303 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 5 }, |
322 | #ifdef CONFIG_BLK_DEV_IDE_SATA | 304 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
323 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA), 11 }, | 305 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA), 5 }, |
324 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2), 12 }, | 306 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2), 5 }, |
325 | #endif | 307 | #endif |
326 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 13 }, | 308 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 5 }, |
327 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 14 }, | 309 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 5 }, |
328 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 15 }, | 310 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 5 }, |
329 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 16 }, | 311 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 5 }, |
330 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 17 }, | 312 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 5 }, |
331 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 18 }, | 313 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 5 }, |
332 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 19 }, | 314 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 5 }, |
333 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 20 }, | 315 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 5 }, |
334 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 21 }, | 316 | { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 5 }, |
335 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 22 }, | 317 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 6 }, |
336 | { 0, }, | 318 | { 0, }, |
337 | }; | 319 | }; |
338 | MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); | 320 | MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); |
@@ -341,6 +323,7 @@ static struct pci_driver driver = { | |||
341 | .name = "AMD_IDE", | 323 | .name = "AMD_IDE", |
342 | .id_table = amd74xx_pci_tbl, | 324 | .id_table = amd74xx_pci_tbl, |
343 | .probe = amd74xx_probe, | 325 | .probe = amd74xx_probe, |
326 | .remove = ide_pci_remove, | ||
344 | }; | 327 | }; |
345 | 328 | ||
346 | static int __init amd74xx_ide_init(void) | 329 | static int __init amd74xx_ide_init(void) |
@@ -348,7 +331,13 @@ static int __init amd74xx_ide_init(void) | |||
348 | return ide_pci_register_driver(&driver); | 331 | return ide_pci_register_driver(&driver); |
349 | } | 332 | } |
350 | 333 | ||
334 | static void __exit amd74xx_ide_exit(void) | ||
335 | { | ||
336 | pci_unregister_driver(&driver); | ||
337 | } | ||
338 | |||
351 | module_init(amd74xx_ide_init); | 339 | module_init(amd74xx_ide_init); |
340 | module_exit(amd74xx_ide_exit); | ||
352 | 341 | ||
353 | MODULE_AUTHOR("Vojtech Pavlik"); | 342 | MODULE_AUTHOR("Vojtech Pavlik"); |
354 | MODULE_DESCRIPTION("AMD PCI IDE driver"); | 343 | MODULE_DESCRIPTION("AMD PCI IDE driver"); |
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index 8b637181681a..332f08f43b56 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
@@ -11,6 +11,8 @@ | |||
11 | #include <linux/ide.h> | 11 | #include <linux/ide.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | 13 | ||
14 | #define DRV_NAME "atiixp" | ||
15 | |||
14 | #define ATIIXP_IDE_PIO_TIMING 0x40 | 16 | #define ATIIXP_IDE_PIO_TIMING 0x40 |
15 | #define ATIIXP_IDE_MDMA_TIMING 0x44 | 17 | #define ATIIXP_IDE_MDMA_TIMING 0x44 |
16 | #define ATIIXP_IDE_PIO_CONTROL 0x48 | 18 | #define ATIIXP_IDE_PIO_CONTROL 0x48 |
@@ -137,16 +139,17 @@ static const struct ide_port_ops atiixp_port_ops = { | |||
137 | }; | 139 | }; |
138 | 140 | ||
139 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { | 141 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { |
140 | { /* 0 */ | 142 | { /* 0: IXP200/300/400/700 */ |
141 | .name = "ATIIXP", | 143 | .name = DRV_NAME, |
142 | .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, | 144 | .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, |
143 | .port_ops = &atiixp_port_ops, | 145 | .port_ops = &atiixp_port_ops, |
144 | .host_flags = IDE_HFLAG_LEGACY_IRQS, | 146 | .host_flags = IDE_HFLAG_LEGACY_IRQS, |
145 | .pio_mask = ATA_PIO4, | 147 | .pio_mask = ATA_PIO4, |
146 | .mwdma_mask = ATA_MWDMA2, | 148 | .mwdma_mask = ATA_MWDMA2, |
147 | .udma_mask = ATA_UDMA5, | 149 | .udma_mask = ATA_UDMA5, |
148 | },{ /* 1 */ | 150 | }, |
149 | .name = "SB600_PATA", | 151 | { /* 1: IXP600 */ |
152 | .name = DRV_NAME, | ||
150 | .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, | 153 | .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, |
151 | .port_ops = &atiixp_port_ops, | 154 | .port_ops = &atiixp_port_ops, |
152 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, | 155 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, |
@@ -167,7 +170,7 @@ static const struct ide_port_info atiixp_pci_info[] __devinitdata = { | |||
167 | 170 | ||
168 | static int __devinit atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 171 | static int __devinit atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
169 | { | 172 | { |
170 | return ide_setup_pci_device(dev, &atiixp_pci_info[id->driver_data]); | 173 | return ide_pci_init_one(dev, &atiixp_pci_info[id->driver_data], NULL); |
171 | } | 174 | } |
172 | 175 | ||
173 | static const struct pci_device_id atiixp_pci_tbl[] = { | 176 | static const struct pci_device_id atiixp_pci_tbl[] = { |
@@ -184,6 +187,7 @@ static struct pci_driver driver = { | |||
184 | .name = "ATIIXP_IDE", | 187 | .name = "ATIIXP_IDE", |
185 | .id_table = atiixp_pci_tbl, | 188 | .id_table = atiixp_pci_tbl, |
186 | .probe = atiixp_init_one, | 189 | .probe = atiixp_init_one, |
190 | .remove = ide_pci_remove, | ||
187 | }; | 191 | }; |
188 | 192 | ||
189 | static int __init atiixp_ide_init(void) | 193 | static int __init atiixp_ide_init(void) |
@@ -191,7 +195,13 @@ static int __init atiixp_ide_init(void) | |||
191 | return ide_pci_register_driver(&driver); | 195 | return ide_pci_register_driver(&driver); |
192 | } | 196 | } |
193 | 197 | ||
198 | static void __exit atiixp_ide_exit(void) | ||
199 | { | ||
200 | pci_unregister_driver(&driver); | ||
201 | } | ||
202 | |||
194 | module_init(atiixp_ide_init); | 203 | module_init(atiixp_ide_init); |
204 | module_exit(atiixp_ide_exit); | ||
195 | 205 | ||
196 | MODULE_AUTHOR("HUI YU"); | 206 | MODULE_AUTHOR("HUI YU"); |
197 | MODULE_DESCRIPTION("PCI driver module for ATI IXP IDE"); | 207 | MODULE_DESCRIPTION("PCI driver module for ATI IXP IDE"); |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index ce58bfcdb3c6..1360b4fa9fd3 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -19,6 +19,8 @@ | |||
19 | 19 | ||
20 | #include <asm/io.h> | 20 | #include <asm/io.h> |
21 | 21 | ||
22 | #define DRV_NAME "cmd64x" | ||
23 | |||
22 | #define CMD_DEBUG 0 | 24 | #define CMD_DEBUG 0 |
23 | 25 | ||
24 | #if CMD_DEBUG | 26 | #if CMD_DEBUG |
@@ -330,28 +332,10 @@ static int cmd646_1_dma_end(ide_drive_t *drive) | |||
330 | return (dma_stat & 7) != 4; | 332 | return (dma_stat & 7) != 4; |
331 | } | 333 | } |
332 | 334 | ||
333 | static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const char *name) | 335 | static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev) |
334 | { | 336 | { |
335 | u8 mrdmode = 0; | 337 | u8 mrdmode = 0; |
336 | 338 | ||
337 | if (dev->device == PCI_DEVICE_ID_CMD_646) { | ||
338 | |||
339 | switch (dev->revision) { | ||
340 | case 0x07: | ||
341 | case 0x05: | ||
342 | printk("%s: UltraDMA capable\n", name); | ||
343 | break; | ||
344 | case 0x03: | ||
345 | default: | ||
346 | printk("%s: MultiWord DMA force limited\n", name); | ||
347 | break; | ||
348 | case 0x01: | ||
349 | printk("%s: MultiWord DMA limited, " | ||
350 | "IRQ workaround enabled\n", name); | ||
351 | break; | ||
352 | } | ||
353 | } | ||
354 | |||
355 | /* Set a good latency timer and cache line size value. */ | 339 | /* Set a good latency timer and cache line size value. */ |
356 | (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); | 340 | (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); |
357 | /* FIXME: pci_set_master() to ensure a good latency timer value */ | 341 | /* FIXME: pci_set_master() to ensure a good latency timer value */ |
@@ -425,8 +409,8 @@ static const struct ide_dma_ops cmd648_dma_ops = { | |||
425 | }; | 409 | }; |
426 | 410 | ||
427 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | 411 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { |
428 | { /* 0 */ | 412 | { /* 0: CMD643 */ |
429 | .name = "CMD643", | 413 | .name = DRV_NAME, |
430 | .init_chipset = init_chipset_cmd64x, | 414 | .init_chipset = init_chipset_cmd64x, |
431 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, | 415 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, |
432 | .port_ops = &cmd64x_port_ops, | 416 | .port_ops = &cmd64x_port_ops, |
@@ -436,8 +420,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | |||
436 | .pio_mask = ATA_PIO5, | 420 | .pio_mask = ATA_PIO5, |
437 | .mwdma_mask = ATA_MWDMA2, | 421 | .mwdma_mask = ATA_MWDMA2, |
438 | .udma_mask = 0x00, /* no udma */ | 422 | .udma_mask = 0x00, /* no udma */ |
439 | },{ /* 1 */ | 423 | }, |
440 | .name = "CMD646", | 424 | { /* 1: CMD646 */ |
425 | .name = DRV_NAME, | ||
441 | .init_chipset = init_chipset_cmd64x, | 426 | .init_chipset = init_chipset_cmd64x, |
442 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 427 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
443 | .chipset = ide_cmd646, | 428 | .chipset = ide_cmd646, |
@@ -447,8 +432,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | |||
447 | .pio_mask = ATA_PIO5, | 432 | .pio_mask = ATA_PIO5, |
448 | .mwdma_mask = ATA_MWDMA2, | 433 | .mwdma_mask = ATA_MWDMA2, |
449 | .udma_mask = ATA_UDMA2, | 434 | .udma_mask = ATA_UDMA2, |
450 | },{ /* 2 */ | 435 | }, |
451 | .name = "CMD648", | 436 | { /* 2: CMD648 */ |
437 | .name = DRV_NAME, | ||
452 | .init_chipset = init_chipset_cmd64x, | 438 | .init_chipset = init_chipset_cmd64x, |
453 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 439 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
454 | .port_ops = &cmd64x_port_ops, | 440 | .port_ops = &cmd64x_port_ops, |
@@ -457,8 +443,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | |||
457 | .pio_mask = ATA_PIO5, | 443 | .pio_mask = ATA_PIO5, |
458 | .mwdma_mask = ATA_MWDMA2, | 444 | .mwdma_mask = ATA_MWDMA2, |
459 | .udma_mask = ATA_UDMA4, | 445 | .udma_mask = ATA_UDMA4, |
460 | },{ /* 3 */ | 446 | }, |
461 | .name = "CMD649", | 447 | { /* 3: CMD649 */ |
448 | .name = DRV_NAME, | ||
462 | .init_chipset = init_chipset_cmd64x, | 449 | .init_chipset = init_chipset_cmd64x, |
463 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 450 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
464 | .port_ops = &cmd64x_port_ops, | 451 | .port_ops = &cmd64x_port_ops, |
@@ -507,7 +494,7 @@ static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_devic | |||
507 | } | 494 | } |
508 | } | 495 | } |
509 | 496 | ||
510 | return ide_setup_pci_device(dev, &d); | 497 | return ide_pci_init_one(dev, &d, NULL); |
511 | } | 498 | } |
512 | 499 | ||
513 | static const struct pci_device_id cmd64x_pci_tbl[] = { | 500 | static const struct pci_device_id cmd64x_pci_tbl[] = { |
@@ -523,6 +510,7 @@ static struct pci_driver driver = { | |||
523 | .name = "CMD64x_IDE", | 510 | .name = "CMD64x_IDE", |
524 | .id_table = cmd64x_pci_tbl, | 511 | .id_table = cmd64x_pci_tbl, |
525 | .probe = cmd64x_init_one, | 512 | .probe = cmd64x_init_one, |
513 | .remove = ide_pci_remove, | ||
526 | }; | 514 | }; |
527 | 515 | ||
528 | static int __init cmd64x_ide_init(void) | 516 | static int __init cmd64x_ide_init(void) |
@@ -530,7 +518,13 @@ static int __init cmd64x_ide_init(void) | |||
530 | return ide_pci_register_driver(&driver); | 518 | return ide_pci_register_driver(&driver); |
531 | } | 519 | } |
532 | 520 | ||
521 | static void __exit cmd64x_ide_exit(void) | ||
522 | { | ||
523 | pci_unregister_driver(&driver); | ||
524 | } | ||
525 | |||
533 | module_init(cmd64x_ide_init); | 526 | module_init(cmd64x_ide_init); |
527 | module_exit(cmd64x_ide_exit); | ||
534 | 528 | ||
535 | MODULE_AUTHOR("Eddie Dost, David Miller, Andre Hedrick"); | 529 | MODULE_AUTHOR("Eddie Dost, David Miller, Andre Hedrick"); |
536 | MODULE_DESCRIPTION("PCI driver module for CMD64x IDE"); | 530 | MODULE_DESCRIPTION("PCI driver module for CMD64x IDE"); |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index b03d8ae947e6..c0364b287f17 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
@@ -41,6 +41,8 @@ | |||
41 | #include <linux/ide.h> | 41 | #include <linux/ide.h> |
42 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
43 | 43 | ||
44 | #define DRV_NAME "cs5520" | ||
45 | |||
44 | struct pio_clocks | 46 | struct pio_clocks |
45 | { | 47 | { |
46 | int address; | 48 | int address; |
@@ -92,18 +94,11 @@ static const struct ide_port_ops cs5520_port_ops = { | |||
92 | .set_dma_mode = cs5520_set_dma_mode, | 94 | .set_dma_mode = cs5520_set_dma_mode, |
93 | }; | 95 | }; |
94 | 96 | ||
95 | #define DECLARE_CS_DEV(name_str) \ | 97 | static const struct ide_port_info cyrix_chipset __devinitdata = { |
96 | { \ | 98 | .name = DRV_NAME, |
97 | .name = name_str, \ | 99 | .port_ops = &cs5520_port_ops, |
98 | .port_ops = &cs5520_port_ops, \ | 100 | .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_CS5520, |
99 | .host_flags = IDE_HFLAG_ISA_PORTS | \ | 101 | .pio_mask = ATA_PIO4, |
100 | IDE_HFLAG_CS5520, \ | ||
101 | .pio_mask = ATA_PIO4, \ | ||
102 | } | ||
103 | |||
104 | static const struct ide_port_info cyrix_chipsets[] __devinitdata = { | ||
105 | /* 0 */ DECLARE_CS_DEV("Cyrix 5510"), | ||
106 | /* 1 */ DECLARE_CS_DEV("Cyrix 5520") | ||
107 | }; | 102 | }; |
108 | 103 | ||
109 | /* | 104 | /* |
@@ -114,7 +109,7 @@ static const struct ide_port_info cyrix_chipsets[] __devinitdata = { | |||
114 | 109 | ||
115 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 110 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
116 | { | 111 | { |
117 | const struct ide_port_info *d = &cyrix_chipsets[id->driver_data]; | 112 | const struct ide_port_info *d = &cyrix_chipset; |
118 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | 113 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
119 | 114 | ||
120 | ide_setup_pci_noise(dev, d); | 115 | ide_setup_pci_noise(dev, d); |
@@ -128,7 +123,8 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic | |||
128 | } | 123 | } |
129 | pci_set_master(dev); | 124 | pci_set_master(dev); |
130 | if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) { | 125 | if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) { |
131 | printk(KERN_WARNING "cs5520: No suitable DMA available.\n"); | 126 | printk(KERN_WARNING "%s: No suitable DMA available.\n", |
127 | d->name); | ||
132 | return -ENODEV; | 128 | return -ENODEV; |
133 | } | 129 | } |
134 | 130 | ||
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index f5534c1ff349..f235db8c678b 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c | |||
@@ -22,6 +22,8 @@ | |||
22 | 22 | ||
23 | #include <asm/io.h> | 23 | #include <asm/io.h> |
24 | 24 | ||
25 | #define DRV_NAME "cs5530" | ||
26 | |||
25 | /* | 27 | /* |
26 | * Here are the standard PIO mode 0-4 timings for each "format". | 28 | * Here are the standard PIO mode 0-4 timings for each "format". |
27 | * Format-0 uses fast data reg timings, with slower command reg timings. | 29 | * Format-0 uses fast data reg timings, with slower command reg timings. |
@@ -127,12 +129,11 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
127 | /** | 129 | /** |
128 | * init_chipset_5530 - set up 5530 bridge | 130 | * init_chipset_5530 - set up 5530 bridge |
129 | * @dev: PCI device | 131 | * @dev: PCI device |
130 | * @name: device name | ||
131 | * | 132 | * |
132 | * Initialize the cs5530 bridge for reliable IDE DMA operation. | 133 | * Initialize the cs5530 bridge for reliable IDE DMA operation. |
133 | */ | 134 | */ |
134 | 135 | ||
135 | static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const char *name) | 136 | static unsigned int __devinit init_chipset_cs5530(struct pci_dev *dev) |
136 | { | 137 | { |
137 | struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; | 138 | struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; |
138 | 139 | ||
@@ -151,11 +152,11 @@ static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const ch | |||
151 | } | 152 | } |
152 | } | 153 | } |
153 | if (!master_0) { | 154 | if (!master_0) { |
154 | printk(KERN_ERR "%s: unable to locate PCI MASTER function\n", name); | 155 | printk(KERN_ERR DRV_NAME ": unable to locate PCI MASTER function\n"); |
155 | goto out; | 156 | goto out; |
156 | } | 157 | } |
157 | if (!cs5530_0) { | 158 | if (!cs5530_0) { |
158 | printk(KERN_ERR "%s: unable to locate CS5530 LEGACY function\n", name); | 159 | printk(KERN_ERR DRV_NAME ": unable to locate CS5530 LEGACY function\n"); |
159 | goto out; | 160 | goto out; |
160 | } | 161 | } |
161 | 162 | ||
@@ -243,7 +244,7 @@ static const struct ide_port_ops cs5530_port_ops = { | |||
243 | }; | 244 | }; |
244 | 245 | ||
245 | static const struct ide_port_info cs5530_chipset __devinitdata = { | 246 | static const struct ide_port_info cs5530_chipset __devinitdata = { |
246 | .name = "CS5530", | 247 | .name = DRV_NAME, |
247 | .init_chipset = init_chipset_cs5530, | 248 | .init_chipset = init_chipset_cs5530, |
248 | .init_hwif = init_hwif_cs5530, | 249 | .init_hwif = init_hwif_cs5530, |
249 | .port_ops = &cs5530_port_ops, | 250 | .port_ops = &cs5530_port_ops, |
@@ -256,7 +257,7 @@ static const struct ide_port_info cs5530_chipset __devinitdata = { | |||
256 | 257 | ||
257 | static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 258 | static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
258 | { | 259 | { |
259 | return ide_setup_pci_device(dev, &cs5530_chipset); | 260 | return ide_pci_init_one(dev, &cs5530_chipset, NULL); |
260 | } | 261 | } |
261 | 262 | ||
262 | static const struct pci_device_id cs5530_pci_tbl[] = { | 263 | static const struct pci_device_id cs5530_pci_tbl[] = { |
@@ -269,6 +270,7 @@ static struct pci_driver driver = { | |||
269 | .name = "CS5530 IDE", | 270 | .name = "CS5530 IDE", |
270 | .id_table = cs5530_pci_tbl, | 271 | .id_table = cs5530_pci_tbl, |
271 | .probe = cs5530_init_one, | 272 | .probe = cs5530_init_one, |
273 | .remove = ide_pci_remove, | ||
272 | }; | 274 | }; |
273 | 275 | ||
274 | static int __init cs5530_ide_init(void) | 276 | static int __init cs5530_ide_init(void) |
@@ -276,7 +278,13 @@ static int __init cs5530_ide_init(void) | |||
276 | return ide_pci_register_driver(&driver); | 278 | return ide_pci_register_driver(&driver); |
277 | } | 279 | } |
278 | 280 | ||
281 | static void __exit cs5530_ide_exit(void) | ||
282 | { | ||
283 | pci_unregister_driver(&driver); | ||
284 | } | ||
285 | |||
279 | module_init(cs5530_ide_init); | 286 | module_init(cs5530_ide_init); |
287 | module_exit(cs5530_ide_exit); | ||
280 | 288 | ||
281 | MODULE_AUTHOR("Mark Lord"); | 289 | MODULE_AUTHOR("Mark Lord"); |
282 | MODULE_DESCRIPTION("PCI driver module for Cyrix/NS 5530 IDE"); | 290 | MODULE_DESCRIPTION("PCI driver module for Cyrix/NS 5530 IDE"); |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index 5404fe4f701d..f7b50cdeefa6 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
@@ -26,6 +26,8 @@ | |||
26 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
27 | #include <linux/ide.h> | 27 | #include <linux/ide.h> |
28 | 28 | ||
29 | #define DRV_NAME "cs5535" | ||
30 | |||
29 | #define MSR_ATAC_BASE 0x51300000 | 31 | #define MSR_ATAC_BASE 0x51300000 |
30 | #define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0) | 32 | #define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0) |
31 | #define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01) | 33 | #define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01) |
@@ -169,7 +171,7 @@ static const struct ide_port_ops cs5535_port_ops = { | |||
169 | }; | 171 | }; |
170 | 172 | ||
171 | static const struct ide_port_info cs5535_chipset __devinitdata = { | 173 | static const struct ide_port_info cs5535_chipset __devinitdata = { |
172 | .name = "CS5535", | 174 | .name = DRV_NAME, |
173 | .port_ops = &cs5535_port_ops, | 175 | .port_ops = &cs5535_port_ops, |
174 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE, | 176 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE, |
175 | .pio_mask = ATA_PIO4, | 177 | .pio_mask = ATA_PIO4, |
@@ -180,7 +182,7 @@ static const struct ide_port_info cs5535_chipset __devinitdata = { | |||
180 | static int __devinit cs5535_init_one(struct pci_dev *dev, | 182 | static int __devinit cs5535_init_one(struct pci_dev *dev, |
181 | const struct pci_device_id *id) | 183 | const struct pci_device_id *id) |
182 | { | 184 | { |
183 | return ide_setup_pci_device(dev, &cs5535_chipset); | 185 | return ide_pci_init_one(dev, &cs5535_chipset, NULL); |
184 | } | 186 | } |
185 | 187 | ||
186 | static const struct pci_device_id cs5535_pci_tbl[] = { | 188 | static const struct pci_device_id cs5535_pci_tbl[] = { |
@@ -194,6 +196,7 @@ static struct pci_driver driver = { | |||
194 | .name = "CS5535_IDE", | 196 | .name = "CS5535_IDE", |
195 | .id_table = cs5535_pci_tbl, | 197 | .id_table = cs5535_pci_tbl, |
196 | .probe = cs5535_init_one, | 198 | .probe = cs5535_init_one, |
199 | .remove = ide_pci_remove, | ||
197 | }; | 200 | }; |
198 | 201 | ||
199 | static int __init cs5535_ide_init(void) | 202 | static int __init cs5535_ide_init(void) |
@@ -201,7 +204,13 @@ static int __init cs5535_ide_init(void) | |||
201 | return ide_pci_register_driver(&driver); | 204 | return ide_pci_register_driver(&driver); |
202 | } | 205 | } |
203 | 206 | ||
207 | static void __exit cs5535_ide_exit(void) | ||
208 | { | ||
209 | pci_unregister_driver(&driver); | ||
210 | } | ||
211 | |||
204 | module_init(cs5535_ide_init); | 212 | module_init(cs5535_ide_init); |
213 | module_exit(cs5535_ide_exit); | ||
205 | 214 | ||
206 | MODULE_AUTHOR("AMD"); | 215 | MODULE_AUTHOR("AMD"); |
207 | MODULE_DESCRIPTION("PCI driver module for AMD/NS CS5535 IDE"); | 216 | MODULE_DESCRIPTION("PCI driver module for AMD/NS CS5535 IDE"); |
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index e14ad5530fa4..bfae2f882f48 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -48,6 +48,8 @@ | |||
48 | 48 | ||
49 | #include <asm/io.h> | 49 | #include <asm/io.h> |
50 | 50 | ||
51 | #define DRV_NAME "cy82c693" | ||
52 | |||
51 | /* the current version */ | 53 | /* the current version */ |
52 | #define CY82_VERSION "CY82C693U driver v0.34 99-13-12 Andreas S. Krebs (akrebs@altavista.net)" | 54 | #define CY82_VERSION "CY82C693U driver v0.34 99-13-12 Andreas S. Krebs (akrebs@altavista.net)" |
53 | 55 | ||
@@ -330,7 +332,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
330 | /* | 332 | /* |
331 | * this function is called during init and is used to setup the cy82c693 chip | 333 | * this function is called during init and is used to setup the cy82c693 chip |
332 | */ | 334 | */ |
333 | static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const char *name) | 335 | static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev) |
334 | { | 336 | { |
335 | if (PCI_FUNC(dev->devfn) != 1) | 337 | if (PCI_FUNC(dev->devfn) != 1) |
336 | return 0; | 338 | return 0; |
@@ -349,8 +351,8 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c | |||
349 | data = inb(CY82_DATA_PORT); | 351 | data = inb(CY82_DATA_PORT); |
350 | 352 | ||
351 | #if CY82C693_DEBUG_INFO | 353 | #if CY82C693_DEBUG_INFO |
352 | printk(KERN_INFO "%s: Peripheral Configuration Register: 0x%X\n", | 354 | printk(KERN_INFO DRV_NAME ": Peripheral Configuration Register: 0x%X\n", |
353 | name, data); | 355 | data); |
354 | #endif /* CY82C693_DEBUG_INFO */ | 356 | #endif /* CY82C693_DEBUG_INFO */ |
355 | 357 | ||
356 | /* | 358 | /* |
@@ -371,8 +373,8 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c | |||
371 | outb(data, CY82_DATA_PORT); | 373 | outb(data, CY82_DATA_PORT); |
372 | 374 | ||
373 | #if CY82C693_DEBUG_INFO | 375 | #if CY82C693_DEBUG_INFO |
374 | printk(KERN_INFO "%s: New Peripheral Configuration Register: 0x%X\n", | 376 | printk(KERN_INFO ": New Peripheral Configuration Register: 0x%X\n", |
375 | name, data); | 377 | data); |
376 | #endif /* CY82C693_DEBUG_INFO */ | 378 | #endif /* CY82C693_DEBUG_INFO */ |
377 | 379 | ||
378 | #endif /* CY82C693_SETDMA_CLOCK */ | 380 | #endif /* CY82C693_SETDMA_CLOCK */ |
@@ -398,7 +400,7 @@ static const struct ide_port_ops cy82c693_port_ops = { | |||
398 | }; | 400 | }; |
399 | 401 | ||
400 | static const struct ide_port_info cy82c693_chipset __devinitdata = { | 402 | static const struct ide_port_info cy82c693_chipset __devinitdata = { |
401 | .name = "CY82C693", | 403 | .name = DRV_NAME, |
402 | .init_chipset = init_chipset_cy82c693, | 404 | .init_chipset = init_chipset_cy82c693, |
403 | .init_iops = init_iops_cy82c693, | 405 | .init_iops = init_iops_cy82c693, |
404 | .port_ops = &cy82c693_port_ops, | 406 | .port_ops = &cy82c693_port_ops, |
@@ -419,12 +421,22 @@ static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_dev | |||
419 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | 421 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
420 | PCI_FUNC(dev->devfn) == 1) { | 422 | PCI_FUNC(dev->devfn) == 1) { |
421 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); | 423 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); |
422 | ret = ide_setup_pci_devices(dev, dev2, &cy82c693_chipset); | 424 | ret = ide_pci_init_two(dev, dev2, &cy82c693_chipset, NULL); |
423 | /* We leak pci refs here but thats ok - we can't be unloaded */ | 425 | if (ret) |
426 | pci_dev_put(dev2); | ||
424 | } | 427 | } |
425 | return ret; | 428 | return ret; |
426 | } | 429 | } |
427 | 430 | ||
431 | static void __devexit cy82c693_remove(struct pci_dev *dev) | ||
432 | { | ||
433 | struct ide_host *host = pci_get_drvdata(dev); | ||
434 | struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL; | ||
435 | |||
436 | ide_pci_remove(dev); | ||
437 | pci_dev_put(dev2); | ||
438 | } | ||
439 | |||
428 | static const struct pci_device_id cy82c693_pci_tbl[] = { | 440 | static const struct pci_device_id cy82c693_pci_tbl[] = { |
429 | { PCI_VDEVICE(CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693), 0 }, | 441 | { PCI_VDEVICE(CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693), 0 }, |
430 | { 0, }, | 442 | { 0, }, |
@@ -435,6 +447,7 @@ static struct pci_driver driver = { | |||
435 | .name = "Cypress_IDE", | 447 | .name = "Cypress_IDE", |
436 | .id_table = cy82c693_pci_tbl, | 448 | .id_table = cy82c693_pci_tbl, |
437 | .probe = cy82c693_init_one, | 449 | .probe = cy82c693_init_one, |
450 | .remove = cy82c693_remove, | ||
438 | }; | 451 | }; |
439 | 452 | ||
440 | static int __init cy82c693_ide_init(void) | 453 | static int __init cy82c693_ide_init(void) |
@@ -442,7 +455,13 @@ static int __init cy82c693_ide_init(void) | |||
442 | return ide_pci_register_driver(&driver); | 455 | return ide_pci_register_driver(&driver); |
443 | } | 456 | } |
444 | 457 | ||
458 | static void __exit cy82c693_ide_exit(void) | ||
459 | { | ||
460 | pci_unregister_driver(&driver); | ||
461 | } | ||
462 | |||
445 | module_init(cy82c693_ide_init); | 463 | module_init(cy82c693_ide_init); |
464 | module_exit(cy82c693_ide_exit); | ||
446 | 465 | ||
447 | MODULE_AUTHOR("Andreas Krebs, Andre Hedrick"); | 466 | MODULE_AUTHOR("Andreas Krebs, Andre Hedrick"); |
448 | MODULE_DESCRIPTION("PCI driver module for the Cypress CY82C693 IDE"); | 467 | MODULE_DESCRIPTION("PCI driver module for the Cypress CY82C693 IDE"); |
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index 041720e22762..b07d4f4273b3 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/ide.h> | 27 | #include <linux/ide.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | 29 | ||
30 | #define DRV_NAME "ide_pci_generic" | ||
31 | |||
30 | static int ide_generic_all; /* Set to claim all devices */ | 32 | static int ide_generic_all; /* Set to claim all devices */ |
31 | 33 | ||
32 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); | 34 | module_param_named(all_generic_ide, ide_generic_all, bool, 0444); |
@@ -34,9 +36,9 @@ MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE st | |||
34 | 36 | ||
35 | #define IDE_HFLAGS_UMC (IDE_HFLAG_NO_DMA | IDE_HFLAG_FORCE_LEGACY_IRQS) | 37 | #define IDE_HFLAGS_UMC (IDE_HFLAG_NO_DMA | IDE_HFLAG_FORCE_LEGACY_IRQS) |
36 | 38 | ||
37 | #define DECLARE_GENERIC_PCI_DEV(name_str, extra_flags) \ | 39 | #define DECLARE_GENERIC_PCI_DEV(extra_flags) \ |
38 | { \ | 40 | { \ |
39 | .name = name_str, \ | 41 | .name = DRV_NAME, \ |
40 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \ | 42 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \ |
41 | extra_flags, \ | 43 | extra_flags, \ |
42 | .swdma_mask = ATA_SWDMA2, \ | 44 | .swdma_mask = ATA_SWDMA2, \ |
@@ -45,10 +47,11 @@ MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE st | |||
45 | } | 47 | } |
46 | 48 | ||
47 | static const struct ide_port_info generic_chipsets[] __devinitdata = { | 49 | static const struct ide_port_info generic_chipsets[] __devinitdata = { |
48 | /* 0 */ DECLARE_GENERIC_PCI_DEV("Unknown", 0), | 50 | /* 0: Unknown */ |
51 | DECLARE_GENERIC_PCI_DEV(0), | ||
49 | 52 | ||
50 | { /* 1 */ | 53 | { /* 1: NS87410 */ |
51 | .name = "NS87410", | 54 | .name = DRV_NAME, |
52 | .enablebits = { {0x43, 0x08, 0x08}, {0x47, 0x08, 0x08} }, | 55 | .enablebits = { {0x43, 0x08, 0x08}, {0x47, 0x08, 0x08} }, |
53 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, | 56 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, |
54 | .swdma_mask = ATA_SWDMA2, | 57 | .swdma_mask = ATA_SWDMA2, |
@@ -56,17 +59,15 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = { | |||
56 | .udma_mask = ATA_UDMA6, | 59 | .udma_mask = ATA_UDMA6, |
57 | }, | 60 | }, |
58 | 61 | ||
59 | /* 2 */ DECLARE_GENERIC_PCI_DEV("SAMURAI", 0), | 62 | /* 2: SAMURAI / HT6565 / HINT_IDE */ |
60 | /* 3 */ DECLARE_GENERIC_PCI_DEV("HT6565", 0), | 63 | DECLARE_GENERIC_PCI_DEV(0), |
61 | /* 4 */ DECLARE_GENERIC_PCI_DEV("UM8673F", IDE_HFLAGS_UMC), | 64 | /* 3: UM8673F / UM8886A / UM8886BF */ |
62 | /* 5 */ DECLARE_GENERIC_PCI_DEV("UM8886A", IDE_HFLAGS_UMC), | 65 | DECLARE_GENERIC_PCI_DEV(IDE_HFLAGS_UMC), |
63 | /* 6 */ DECLARE_GENERIC_PCI_DEV("UM8886BF", IDE_HFLAGS_UMC), | 66 | /* 4: VIA_IDE / OPTI621V / Piccolo010{2,3,5} */ |
64 | /* 7 */ DECLARE_GENERIC_PCI_DEV("HINT_IDE", 0), | 67 | DECLARE_GENERIC_PCI_DEV(IDE_HFLAG_NO_AUTODMA), |
65 | /* 8 */ DECLARE_GENERIC_PCI_DEV("VIA_IDE", IDE_HFLAG_NO_AUTODMA), | 68 | |
66 | /* 9 */ DECLARE_GENERIC_PCI_DEV("OPTI621V", IDE_HFLAG_NO_AUTODMA), | 69 | { /* 5: VIA8237SATA */ |
67 | 70 | .name = DRV_NAME, | |
68 | { /* 10 */ | ||
69 | .name = "VIA8237SATA", | ||
70 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 71 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
71 | IDE_HFLAG_OFF_BOARD, | 72 | IDE_HFLAG_OFF_BOARD, |
72 | .swdma_mask = ATA_SWDMA2, | 73 | .swdma_mask = ATA_SWDMA2, |
@@ -74,12 +75,8 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = { | |||
74 | .udma_mask = ATA_UDMA6, | 75 | .udma_mask = ATA_UDMA6, |
75 | }, | 76 | }, |
76 | 77 | ||
77 | /* 11 */ DECLARE_GENERIC_PCI_DEV("Piccolo0102", IDE_HFLAG_NO_AUTODMA), | 78 | { /* 6: Revolution */ |
78 | /* 12 */ DECLARE_GENERIC_PCI_DEV("Piccolo0103", IDE_HFLAG_NO_AUTODMA), | 79 | .name = DRV_NAME, |
79 | /* 13 */ DECLARE_GENERIC_PCI_DEV("Piccolo0105", IDE_HFLAG_NO_AUTODMA), | ||
80 | |||
81 | { /* 14 */ | ||
82 | .name = "Revolution", | ||
83 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | | 80 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | |
84 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 81 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
85 | IDE_HFLAG_OFF_BOARD, | 82 | IDE_HFLAG_OFF_BOARD, |
@@ -134,12 +131,12 @@ static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_devi | |||
134 | u16 command; | 131 | u16 command; |
135 | pci_read_config_word(dev, PCI_COMMAND, &command); | 132 | pci_read_config_word(dev, PCI_COMMAND, &command); |
136 | if (!(command & PCI_COMMAND_IO)) { | 133 | if (!(command & PCI_COMMAND_IO)) { |
137 | printk(KERN_INFO "Skipping disabled %s IDE " | 134 | printk(KERN_INFO "%s %s: skipping disabled " |
138 | "controller.\n", d->name); | 135 | "controller\n", d->name, pci_name(dev)); |
139 | goto out; | 136 | goto out; |
140 | } | 137 | } |
141 | } | 138 | } |
142 | ret = ide_setup_pci_device(dev, d); | 139 | ret = ide_pci_init_one(dev, d, NULL); |
143 | out: | 140 | out: |
144 | return ret; | 141 | return ret; |
145 | } | 142 | } |
@@ -147,20 +144,20 @@ out: | |||
147 | static const struct pci_device_id generic_pci_tbl[] = { | 144 | static const struct pci_device_id generic_pci_tbl[] = { |
148 | { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_87410), 1 }, | 145 | { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_87410), 1 }, |
149 | { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), 2 }, | 146 | { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), 2 }, |
150 | { PCI_VDEVICE(HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), 3 }, | 147 | { PCI_VDEVICE(HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), 2 }, |
151 | { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8673F), 4 }, | 148 | { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8673F), 3 }, |
152 | { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886A), 5 }, | 149 | { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886A), 3 }, |
153 | { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886BF), 6 }, | 150 | { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886BF), 3 }, |
154 | { PCI_VDEVICE(HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), 7 }, | 151 | { PCI_VDEVICE(HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), 2 }, |
155 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C561), 8 }, | 152 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C561), 4 }, |
156 | { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C558), 9 }, | 153 | { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C558), 4 }, |
157 | #ifdef CONFIG_BLK_DEV_IDE_SATA | 154 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
158 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 10 }, | 155 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 5 }, |
159 | #endif | 156 | #endif |
160 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO), 11 }, | 157 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO), 4 }, |
161 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 12 }, | 158 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 4 }, |
162 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 13 }, | 159 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 4 }, |
163 | { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 14 }, | 160 | { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 6 }, |
164 | /* | 161 | /* |
165 | * Must come last. If you add entries adjust | 162 | * Must come last. If you add entries adjust |
166 | * this table and generic_chipsets[] appropriately. | 163 | * this table and generic_chipsets[] appropriately. |
@@ -174,6 +171,7 @@ static struct pci_driver driver = { | |||
174 | .name = "PCI_IDE", | 171 | .name = "PCI_IDE", |
175 | .id_table = generic_pci_tbl, | 172 | .id_table = generic_pci_tbl, |
176 | .probe = generic_init_one, | 173 | .probe = generic_init_one, |
174 | .remove = ide_pci_remove, | ||
177 | }; | 175 | }; |
178 | 176 | ||
179 | static int __init generic_ide_init(void) | 177 | static int __init generic_ide_init(void) |
@@ -181,7 +179,13 @@ static int __init generic_ide_init(void) | |||
181 | return ide_pci_register_driver(&driver); | 179 | return ide_pci_register_driver(&driver); |
182 | } | 180 | } |
183 | 181 | ||
182 | static void __exit generic_ide_exit(void) | ||
183 | { | ||
184 | pci_unregister_driver(&driver); | ||
185 | } | ||
186 | |||
184 | module_init(generic_ide_init); | 187 | module_init(generic_ide_init); |
188 | module_exit(generic_ide_exit); | ||
185 | 189 | ||
186 | MODULE_AUTHOR("Andre Hedrick"); | 190 | MODULE_AUTHOR("Andre Hedrick"); |
187 | MODULE_DESCRIPTION("PCI driver module for generic PCI IDE"); | 191 | MODULE_DESCRIPTION("PCI driver module for generic PCI IDE"); |
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index 9e1d1c4741da..6009b0b9655d 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/ide.h> | 34 | #include <linux/ide.h> |
35 | 35 | ||
36 | #define DRV_NAME "hpt34x" | ||
37 | |||
36 | #define HPT343_DEBUG_DRIVE_INFO 0 | 38 | #define HPT343_DEBUG_DRIVE_INFO 0 |
37 | 39 | ||
38 | static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) | 40 | static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) |
@@ -77,7 +79,7 @@ static void hpt34x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
77 | */ | 79 | */ |
78 | #define HPT34X_PCI_INIT_REG 0x80 | 80 | #define HPT34X_PCI_INIT_REG 0x80 |
79 | 81 | ||
80 | static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const char *name) | 82 | static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev) |
81 | { | 83 | { |
82 | int i = 0; | 84 | int i = 0; |
83 | unsigned long hpt34xIoBase = pci_resource_start(dev, 4); | 85 | unsigned long hpt34xIoBase = pci_resource_start(dev, 4); |
@@ -126,15 +128,15 @@ static const struct ide_port_ops hpt34x_port_ops = { | |||
126 | IDE_HFLAG_NO_AUTODMA) | 128 | IDE_HFLAG_NO_AUTODMA) |
127 | 129 | ||
128 | static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { | 130 | static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { |
129 | { /* 0 */ | 131 | { /* 0: HPT343 */ |
130 | .name = "HPT343", | 132 | .name = DRV_NAME, |
131 | .init_chipset = init_chipset_hpt34x, | 133 | .init_chipset = init_chipset_hpt34x, |
132 | .port_ops = &hpt34x_port_ops, | 134 | .port_ops = &hpt34x_port_ops, |
133 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE, | 135 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE, |
134 | .pio_mask = ATA_PIO5, | 136 | .pio_mask = ATA_PIO5, |
135 | }, | 137 | }, |
136 | { /* 1 */ | 138 | { /* 1: HPT345 */ |
137 | .name = "HPT345", | 139 | .name = DRV_NAME, |
138 | .init_chipset = init_chipset_hpt34x, | 140 | .init_chipset = init_chipset_hpt34x, |
139 | .port_ops = &hpt34x_port_ops, | 141 | .port_ops = &hpt34x_port_ops, |
140 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, | 142 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, |
@@ -156,7 +158,7 @@ static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_devic | |||
156 | 158 | ||
157 | d = &hpt34x_chipsets[(pcicmd & PCI_COMMAND_MEMORY) ? 1 : 0]; | 159 | d = &hpt34x_chipsets[(pcicmd & PCI_COMMAND_MEMORY) ? 1 : 0]; |
158 | 160 | ||
159 | return ide_setup_pci_device(dev, d); | 161 | return ide_pci_init_one(dev, d, NULL); |
160 | } | 162 | } |
161 | 163 | ||
162 | static const struct pci_device_id hpt34x_pci_tbl[] = { | 164 | static const struct pci_device_id hpt34x_pci_tbl[] = { |
@@ -169,6 +171,7 @@ static struct pci_driver driver = { | |||
169 | .name = "HPT34x_IDE", | 171 | .name = "HPT34x_IDE", |
170 | .id_table = hpt34x_pci_tbl, | 172 | .id_table = hpt34x_pci_tbl, |
171 | .probe = hpt34x_init_one, | 173 | .probe = hpt34x_init_one, |
174 | .remove = ide_pci_remove, | ||
172 | }; | 175 | }; |
173 | 176 | ||
174 | static int __init hpt34x_ide_init(void) | 177 | static int __init hpt34x_ide_init(void) |
@@ -176,7 +179,13 @@ static int __init hpt34x_ide_init(void) | |||
176 | return ide_pci_register_driver(&driver); | 179 | return ide_pci_register_driver(&driver); |
177 | } | 180 | } |
178 | 181 | ||
182 | static void __exit hpt34x_ide_exit(void) | ||
183 | { | ||
184 | pci_unregister_driver(&driver); | ||
185 | } | ||
186 | |||
179 | module_init(hpt34x_ide_init); | 187 | module_init(hpt34x_ide_init); |
188 | module_exit(hpt34x_ide_exit); | ||
180 | 189 | ||
181 | MODULE_AUTHOR("Andre Hedrick"); | 190 | MODULE_AUTHOR("Andre Hedrick"); |
182 | MODULE_DESCRIPTION("PCI driver module for Highpoint 34x IDE"); | 191 | MODULE_DESCRIPTION("PCI driver module for Highpoint 34x IDE"); |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 1f1135ce7cd6..5271b246b88c 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -131,6 +131,8 @@ | |||
131 | #include <asm/uaccess.h> | 131 | #include <asm/uaccess.h> |
132 | #include <asm/io.h> | 132 | #include <asm/io.h> |
133 | 133 | ||
134 | #define DRV_NAME "hpt366" | ||
135 | |||
134 | /* various tuning parameters */ | 136 | /* various tuning parameters */ |
135 | #define HPT_RESET_STATE_ENGINE | 137 | #define HPT_RESET_STATE_ENGINE |
136 | #undef HPT_DELAY_INTERRUPT | 138 | #undef HPT_DELAY_INTERRUPT |
@@ -620,7 +622,8 @@ static u8 hpt3xx_udma_filter(ide_drive_t *drive) | |||
620 | { | 622 | { |
621 | ide_hwif_t *hwif = HWIF(drive); | 623 | ide_hwif_t *hwif = HWIF(drive); |
622 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 624 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
623 | struct hpt_info *info = pci_get_drvdata(dev); | 625 | struct ide_host *host = pci_get_drvdata(dev); |
626 | struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]); | ||
624 | u8 mask = hwif->ultra_mask; | 627 | u8 mask = hwif->ultra_mask; |
625 | 628 | ||
626 | switch (info->chip_type) { | 629 | switch (info->chip_type) { |
@@ -660,7 +663,8 @@ static u8 hpt3xx_mdma_filter(ide_drive_t *drive) | |||
660 | { | 663 | { |
661 | ide_hwif_t *hwif = HWIF(drive); | 664 | ide_hwif_t *hwif = HWIF(drive); |
662 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 665 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
663 | struct hpt_info *info = pci_get_drvdata(dev); | 666 | struct ide_host *host = pci_get_drvdata(dev); |
667 | struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]); | ||
664 | 668 | ||
665 | switch (info->chip_type) { | 669 | switch (info->chip_type) { |
666 | case HPT372 : | 670 | case HPT372 : |
@@ -694,8 +698,10 @@ static u32 get_speed_setting(u8 speed, struct hpt_info *info) | |||
694 | 698 | ||
695 | static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) | 699 | static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) |
696 | { | 700 | { |
697 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 701 | ide_hwif_t *hwif = drive->hwif; |
698 | struct hpt_info *info = pci_get_drvdata(dev); | 702 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
703 | struct ide_host *host = pci_get_drvdata(dev); | ||
704 | struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]); | ||
699 | struct hpt_timings *t = info->timings; | 705 | struct hpt_timings *t = info->timings; |
700 | u8 itr_addr = 0x40 + (drive->dn * 4); | 706 | u8 itr_addr = 0x40 + (drive->dn * 4); |
701 | u32 old_itr = 0; | 707 | u32 old_itr = 0; |
@@ -738,7 +744,8 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | |||
738 | { | 744 | { |
739 | ide_hwif_t *hwif = HWIF(drive); | 745 | ide_hwif_t *hwif = HWIF(drive); |
740 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 746 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
741 | struct hpt_info *info = pci_get_drvdata(dev); | 747 | struct ide_host *host = pci_get_drvdata(dev); |
748 | struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]); | ||
742 | 749 | ||
743 | if (drive->quirk_list) { | 750 | if (drive->quirk_list) { |
744 | if (info->chip_type >= HPT370) { | 751 | if (info->chip_type >= HPT370) { |
@@ -963,24 +970,16 @@ static int __devinit hpt37x_calibrate_dpll(struct pci_dev *dev, u16 f_low, u16 f | |||
963 | return 1; | 970 | return 1; |
964 | } | 971 | } |
965 | 972 | ||
966 | static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const char *name) | 973 | static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev) |
967 | { | 974 | { |
968 | struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL); | ||
969 | unsigned long io_base = pci_resource_start(dev, 4); | 975 | unsigned long io_base = pci_resource_start(dev, 4); |
976 | struct ide_host *host = pci_get_drvdata(dev); | ||
977 | struct hpt_info *info = host->host_priv + (&dev->dev == host->dev[1]); | ||
978 | const char *name = DRV_NAME; | ||
970 | u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */ | 979 | u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */ |
971 | u8 chip_type; | 980 | u8 chip_type; |
972 | enum ata_clock clock; | 981 | enum ata_clock clock; |
973 | 982 | ||
974 | if (info == NULL) { | ||
975 | printk(KERN_ERR "%s: out of memory!\n", name); | ||
976 | return -ENOMEM; | ||
977 | } | ||
978 | |||
979 | /* | ||
980 | * Copy everything from a static "template" structure | ||
981 | * to just allocated per-chip hpt_info structure. | ||
982 | */ | ||
983 | memcpy(info, pci_get_drvdata(dev), sizeof(struct hpt_info)); | ||
984 | chip_type = info->chip_type; | 983 | chip_type = info->chip_type; |
985 | 984 | ||
986 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); | 985 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); |
@@ -1048,8 +1047,8 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1048 | if ((temp & 0xFFFFF000) != 0xABCDE000) { | 1047 | if ((temp & 0xFFFFF000) != 0xABCDE000) { |
1049 | int i; | 1048 | int i; |
1050 | 1049 | ||
1051 | printk(KERN_WARNING "%s: no clock data saved by BIOS\n", | 1050 | printk(KERN_WARNING "%s %s: no clock data saved by " |
1052 | name); | 1051 | "BIOS\n", name, pci_name(dev)); |
1053 | 1052 | ||
1054 | /* Calculate the average value of f_CNT. */ | 1053 | /* Calculate the average value of f_CNT. */ |
1055 | for (temp = i = 0; i < 128; i++) { | 1054 | for (temp = i = 0; i < 128; i++) { |
@@ -1074,8 +1073,9 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1074 | else | 1073 | else |
1075 | pci_clk = 66; | 1074 | pci_clk = 66; |
1076 | 1075 | ||
1077 | printk(KERN_INFO "%s: DPLL base: %d MHz, f_CNT: %d, " | 1076 | printk(KERN_INFO "%s %s: DPLL base: %d MHz, f_CNT: %d, " |
1078 | "assuming %d MHz PCI\n", name, dpll_clk, f_cnt, pci_clk); | 1077 | "assuming %d MHz PCI\n", name, pci_name(dev), |
1078 | dpll_clk, f_cnt, pci_clk); | ||
1079 | } else { | 1079 | } else { |
1080 | u32 itr1 = 0; | 1080 | u32 itr1 = 0; |
1081 | 1081 | ||
@@ -1141,8 +1141,8 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | if (info->timings->clock_table[clock] == NULL) { | 1143 | if (info->timings->clock_table[clock] == NULL) { |
1144 | printk(KERN_ERR "%s: unknown bus timing!\n", name); | 1144 | printk(KERN_ERR "%s %s: unknown bus timing!\n", |
1145 | kfree(info); | 1145 | name, pci_name(dev)); |
1146 | return -EIO; | 1146 | return -EIO; |
1147 | } | 1147 | } |
1148 | 1148 | ||
@@ -1168,17 +1168,19 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1168 | f_low += adjust >> 1; | 1168 | f_low += adjust >> 1; |
1169 | } | 1169 | } |
1170 | if (adjust == 8) { | 1170 | if (adjust == 8) { |
1171 | printk(KERN_ERR "%s: DPLL did not stabilize!\n", name); | 1171 | printk(KERN_ERR "%s %s: DPLL did not stabilize!\n", |
1172 | kfree(info); | 1172 | name, pci_name(dev)); |
1173 | return -EIO; | 1173 | return -EIO; |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | printk("%s: using %d MHz DPLL clock\n", name, dpll_clk); | 1176 | printk(KERN_INFO "%s %s: using %d MHz DPLL clock\n", |
1177 | name, pci_name(dev), dpll_clk); | ||
1177 | } else { | 1178 | } else { |
1178 | /* Mark the fact that we're not using the DPLL. */ | 1179 | /* Mark the fact that we're not using the DPLL. */ |
1179 | dpll_clk = 0; | 1180 | dpll_clk = 0; |
1180 | 1181 | ||
1181 | printk("%s: using %d MHz PCI clock\n", name, pci_clk); | 1182 | printk(KERN_INFO "%s %s: using %d MHz PCI clock\n", |
1183 | name, pci_name(dev), pci_clk); | ||
1182 | } | 1184 | } |
1183 | 1185 | ||
1184 | /* Store the clock frequencies. */ | 1186 | /* Store the clock frequencies. */ |
@@ -1186,9 +1188,6 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1186 | info->pci_clk = pci_clk; | 1188 | info->pci_clk = pci_clk; |
1187 | info->clock = clock; | 1189 | info->clock = clock; |
1188 | 1190 | ||
1189 | /* Point to this chip's own instance of the hpt_info structure. */ | ||
1190 | pci_set_drvdata(dev, info); | ||
1191 | |||
1192 | if (chip_type >= HPT370) { | 1191 | if (chip_type >= HPT370) { |
1193 | u8 mcr1, mcr4; | 1192 | u8 mcr1, mcr4; |
1194 | 1193 | ||
@@ -1218,7 +1217,8 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
1218 | static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif) | 1217 | static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif) |
1219 | { | 1218 | { |
1220 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1219 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1221 | struct hpt_info *info = pci_get_drvdata(dev); | 1220 | struct ide_host *host = pci_get_drvdata(dev); |
1221 | struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]); | ||
1222 | u8 chip_type = info->chip_type; | 1222 | u8 chip_type = info->chip_type; |
1223 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; | 1223 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; |
1224 | 1224 | ||
@@ -1262,7 +1262,8 @@ static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif) | |||
1262 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | 1262 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) |
1263 | { | 1263 | { |
1264 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1264 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1265 | struct hpt_info *info = pci_get_drvdata(dev); | 1265 | struct ide_host *host = pci_get_drvdata(dev); |
1266 | struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]); | ||
1266 | int serialize = HPT_SERIALIZE_IO; | 1267 | int serialize = HPT_SERIALIZE_IO; |
1267 | u8 chip_type = info->chip_type; | 1268 | u8 chip_type = info->chip_type; |
1268 | u8 new_mcr, old_mcr = 0; | 1269 | u8 new_mcr, old_mcr = 0; |
@@ -1364,7 +1365,8 @@ static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) | |||
1364 | if (dev2->irq != dev->irq) { | 1365 | if (dev2->irq != dev->irq) { |
1365 | /* FIXME: we need a core pci_set_interrupt() */ | 1366 | /* FIXME: we need a core pci_set_interrupt() */ |
1366 | dev2->irq = dev->irq; | 1367 | dev2->irq = dev->irq; |
1367 | printk(KERN_INFO "HPT374: PCI config space interrupt fixed\n"); | 1368 | printk(KERN_INFO DRV_NAME " %s: PCI config space interrupt " |
1369 | "fixed\n", pci_name(dev2)); | ||
1368 | } | 1370 | } |
1369 | } | 1371 | } |
1370 | 1372 | ||
@@ -1399,8 +1401,8 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2) | |||
1399 | pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2); | 1401 | pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2); |
1400 | 1402 | ||
1401 | if (pin1 != pin2 && dev->irq == dev2->irq) { | 1403 | if (pin1 != pin2 && dev->irq == dev2->irq) { |
1402 | printk(KERN_INFO "HPT36x: onboard version of chipset, " | 1404 | printk(KERN_INFO DRV_NAME " %s: onboard version of chipset, " |
1403 | "pin1=%d pin2=%d\n", pin1, pin2); | 1405 | "pin1=%d pin2=%d\n", pci_name(dev), pin1, pin2); |
1404 | return 1; | 1406 | return 1; |
1405 | } | 1407 | } |
1406 | 1408 | ||
@@ -1455,8 +1457,8 @@ static const struct ide_dma_ops hpt36x_dma_ops = { | |||
1455 | }; | 1457 | }; |
1456 | 1458 | ||
1457 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | 1459 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { |
1458 | { /* 0 */ | 1460 | { /* 0: HPT36x */ |
1459 | .name = "HPT36x", | 1461 | .name = DRV_NAME, |
1460 | .init_chipset = init_chipset_hpt366, | 1462 | .init_chipset = init_chipset_hpt366, |
1461 | .init_hwif = init_hwif_hpt366, | 1463 | .init_hwif = init_hwif_hpt366, |
1462 | .init_dma = init_dma_hpt366, | 1464 | .init_dma = init_dma_hpt366, |
@@ -1472,53 +1474,9 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1472 | .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, | 1474 | .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, |
1473 | .pio_mask = ATA_PIO4, | 1475 | .pio_mask = ATA_PIO4, |
1474 | .mwdma_mask = ATA_MWDMA2, | 1476 | .mwdma_mask = ATA_MWDMA2, |
1475 | },{ /* 1 */ | 1477 | }, |
1476 | .name = "HPT372A", | 1478 | { /* 1: HPT3xx */ |
1477 | .init_chipset = init_chipset_hpt366, | 1479 | .name = DRV_NAME, |
1478 | .init_hwif = init_hwif_hpt366, | ||
1479 | .init_dma = init_dma_hpt366, | ||
1480 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | ||
1481 | .port_ops = &hpt3xx_port_ops, | ||
1482 | .dma_ops = &hpt37x_dma_ops, | ||
1483 | .host_flags = IDE_HFLAGS_HPT3XX, | ||
1484 | .pio_mask = ATA_PIO4, | ||
1485 | .mwdma_mask = ATA_MWDMA2, | ||
1486 | },{ /* 2 */ | ||
1487 | .name = "HPT302", | ||
1488 | .init_chipset = init_chipset_hpt366, | ||
1489 | .init_hwif = init_hwif_hpt366, | ||
1490 | .init_dma = init_dma_hpt366, | ||
1491 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | ||
1492 | .port_ops = &hpt3xx_port_ops, | ||
1493 | .dma_ops = &hpt37x_dma_ops, | ||
1494 | .host_flags = IDE_HFLAGS_HPT3XX, | ||
1495 | .pio_mask = ATA_PIO4, | ||
1496 | .mwdma_mask = ATA_MWDMA2, | ||
1497 | },{ /* 3 */ | ||
1498 | .name = "HPT371", | ||
1499 | .init_chipset = init_chipset_hpt366, | ||
1500 | .init_hwif = init_hwif_hpt366, | ||
1501 | .init_dma = init_dma_hpt366, | ||
1502 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | ||
1503 | .port_ops = &hpt3xx_port_ops, | ||
1504 | .dma_ops = &hpt37x_dma_ops, | ||
1505 | .host_flags = IDE_HFLAGS_HPT3XX, | ||
1506 | .pio_mask = ATA_PIO4, | ||
1507 | .mwdma_mask = ATA_MWDMA2, | ||
1508 | },{ /* 4 */ | ||
1509 | .name = "HPT374", | ||
1510 | .init_chipset = init_chipset_hpt366, | ||
1511 | .init_hwif = init_hwif_hpt366, | ||
1512 | .init_dma = init_dma_hpt366, | ||
1513 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | ||
1514 | .udma_mask = ATA_UDMA5, | ||
1515 | .port_ops = &hpt3xx_port_ops, | ||
1516 | .dma_ops = &hpt37x_dma_ops, | ||
1517 | .host_flags = IDE_HFLAGS_HPT3XX, | ||
1518 | .pio_mask = ATA_PIO4, | ||
1519 | .mwdma_mask = ATA_MWDMA2, | ||
1520 | },{ /* 5 */ | ||
1521 | .name = "HPT372N", | ||
1522 | .init_chipset = init_chipset_hpt366, | 1480 | .init_chipset = init_chipset_hpt366, |
1523 | .init_hwif = init_hwif_hpt366, | 1481 | .init_hwif = init_hwif_hpt366, |
1524 | .init_dma = init_dma_hpt366, | 1482 | .init_dma = init_dma_hpt366, |
@@ -1542,10 +1500,12 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1542 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 1500 | static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
1543 | { | 1501 | { |
1544 | const struct hpt_info *info = NULL; | 1502 | const struct hpt_info *info = NULL; |
1503 | struct hpt_info *dyn_info; | ||
1545 | struct pci_dev *dev2 = NULL; | 1504 | struct pci_dev *dev2 = NULL; |
1546 | struct ide_port_info d; | 1505 | struct ide_port_info d; |
1547 | u8 idx = id->driver_data; | 1506 | u8 idx = id->driver_data; |
1548 | u8 rev = dev->revision; | 1507 | u8 rev = dev->revision; |
1508 | int ret; | ||
1549 | 1509 | ||
1550 | if ((idx == 0 || idx == 4) && (PCI_FUNC(dev->devfn) & 1)) | 1510 | if ((idx == 0 || idx == 4) && (PCI_FUNC(dev->devfn) & 1)) |
1551 | return -ENODEV; | 1511 | return -ENODEV; |
@@ -1582,24 +1542,35 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1582 | break; | 1542 | break; |
1583 | } | 1543 | } |
1584 | 1544 | ||
1585 | d = hpt366_chipsets[idx]; | 1545 | printk(KERN_INFO DRV_NAME ": %s chipset detected\n", info->chip_name); |
1546 | |||
1547 | d = hpt366_chipsets[min_t(u8, idx, 1)]; | ||
1586 | 1548 | ||
1587 | d.name = info->chip_name; | ||
1588 | d.udma_mask = info->udma_mask; | 1549 | d.udma_mask = info->udma_mask; |
1589 | 1550 | ||
1590 | /* fixup ->dma_ops for HPT370/HPT370A */ | 1551 | /* fixup ->dma_ops for HPT370/HPT370A */ |
1591 | if (info == &hpt370 || info == &hpt370a) | 1552 | if (info == &hpt370 || info == &hpt370a) |
1592 | d.dma_ops = &hpt370_dma_ops; | 1553 | d.dma_ops = &hpt370_dma_ops; |
1593 | 1554 | ||
1594 | pci_set_drvdata(dev, (void *)info); | ||
1595 | |||
1596 | if (info == &hpt36x || info == &hpt374) | 1555 | if (info == &hpt36x || info == &hpt374) |
1597 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); | 1556 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); |
1598 | 1557 | ||
1599 | if (dev2) { | 1558 | dyn_info = kzalloc(sizeof(*dyn_info) * (dev2 ? 2 : 1), GFP_KERNEL); |
1600 | int ret; | 1559 | if (dyn_info == NULL) { |
1560 | printk(KERN_ERR "%s %s: out of memory!\n", | ||
1561 | d.name, pci_name(dev)); | ||
1562 | pci_dev_put(dev2); | ||
1563 | return -ENOMEM; | ||
1564 | } | ||
1565 | |||
1566 | /* | ||
1567 | * Copy everything from a static "template" structure | ||
1568 | * to just allocated per-chip hpt_info structure. | ||
1569 | */ | ||
1570 | memcpy(dyn_info, info, sizeof(*dyn_info)); | ||
1601 | 1571 | ||
1602 | pci_set_drvdata(dev2, (void *)info); | 1572 | if (dev2) { |
1573 | memcpy(dyn_info + 1, info, sizeof(*dyn_info)); | ||
1603 | 1574 | ||
1604 | if (info == &hpt374) | 1575 | if (info == &hpt374) |
1605 | hpt374_init(dev, dev2); | 1576 | hpt374_init(dev, dev2); |
@@ -1608,13 +1579,30 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1608 | d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE; | 1579 | d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE; |
1609 | } | 1580 | } |
1610 | 1581 | ||
1611 | ret = ide_setup_pci_devices(dev, dev2, &d); | 1582 | ret = ide_pci_init_two(dev, dev2, &d, dyn_info); |
1612 | if (ret < 0) | 1583 | if (ret < 0) { |
1613 | pci_dev_put(dev2); | 1584 | pci_dev_put(dev2); |
1585 | kfree(dyn_info); | ||
1586 | } | ||
1614 | return ret; | 1587 | return ret; |
1615 | } | 1588 | } |
1616 | 1589 | ||
1617 | return ide_setup_pci_device(dev, &d); | 1590 | ret = ide_pci_init_one(dev, &d, dyn_info); |
1591 | if (ret < 0) | ||
1592 | kfree(dyn_info); | ||
1593 | |||
1594 | return ret; | ||
1595 | } | ||
1596 | |||
1597 | static void __devexit hpt366_remove(struct pci_dev *dev) | ||
1598 | { | ||
1599 | struct ide_host *host = pci_get_drvdata(dev); | ||
1600 | struct ide_info *info = host->host_priv; | ||
1601 | struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL; | ||
1602 | |||
1603 | ide_pci_remove(dev); | ||
1604 | pci_dev_put(dev2); | ||
1605 | kfree(info); | ||
1618 | } | 1606 | } |
1619 | 1607 | ||
1620 | static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = { | 1608 | static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = { |
@@ -1632,6 +1620,7 @@ static struct pci_driver driver = { | |||
1632 | .name = "HPT366_IDE", | 1620 | .name = "HPT366_IDE", |
1633 | .id_table = hpt366_pci_tbl, | 1621 | .id_table = hpt366_pci_tbl, |
1634 | .probe = hpt366_init_one, | 1622 | .probe = hpt366_init_one, |
1623 | .remove = hpt366_remove, | ||
1635 | }; | 1624 | }; |
1636 | 1625 | ||
1637 | static int __init hpt366_ide_init(void) | 1626 | static int __init hpt366_ide_init(void) |
@@ -1639,7 +1628,13 @@ static int __init hpt366_ide_init(void) | |||
1639 | return ide_pci_register_driver(&driver); | 1628 | return ide_pci_register_driver(&driver); |
1640 | } | 1629 | } |
1641 | 1630 | ||
1631 | static void __exit hpt366_ide_exit(void) | ||
1632 | { | ||
1633 | pci_unregister_driver(&driver); | ||
1634 | } | ||
1635 | |||
1642 | module_init(hpt366_ide_init); | 1636 | module_init(hpt366_ide_init); |
1637 | module_exit(hpt366_ide_exit); | ||
1643 | 1638 | ||
1644 | MODULE_AUTHOR("Andre Hedrick"); | 1639 | MODULE_AUTHOR("Andre Hedrick"); |
1645 | MODULE_DESCRIPTION("PCI driver module for Highpoint HPT366 IDE"); | 1640 | MODULE_DESCRIPTION("PCI driver module for Highpoint HPT366 IDE"); |
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index 2b71bdf74e73..6eba8f188264 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <linux/ide.h> | 14 | #include <linux/ide.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | 16 | ||
17 | #define DRV_NAME "it8213" | ||
18 | |||
17 | /** | 19 | /** |
18 | * it8213_set_pio_mode - set host controller for PIO mode | 20 | * it8213_set_pio_mode - set host controller for PIO mode |
19 | * @drive: drive | 21 | * @drive: drive |
@@ -155,23 +157,17 @@ static const struct ide_port_ops it8213_port_ops = { | |||
155 | .cable_detect = it8213_cable_detect, | 157 | .cable_detect = it8213_cable_detect, |
156 | }; | 158 | }; |
157 | 159 | ||
158 | #define DECLARE_ITE_DEV(name_str) \ | 160 | static const struct ide_port_info it8213_chipset __devinitdata = { |
159 | { \ | 161 | .name = DRV_NAME, |
160 | .name = name_str, \ | 162 | .enablebits = { {0x41, 0x80, 0x80} }, |
161 | .enablebits = { {0x41, 0x80, 0x80} }, \ | 163 | .port_ops = &it8213_port_ops, |
162 | .port_ops = &it8213_port_ops, \ | 164 | .host_flags = IDE_HFLAG_SINGLE, |
163 | .host_flags = IDE_HFLAG_SINGLE, \ | 165 | .pio_mask = ATA_PIO4, |
164 | .pio_mask = ATA_PIO4, \ | 166 | .swdma_mask = ATA_SWDMA2_ONLY, |
165 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 167 | .mwdma_mask = ATA_MWDMA12_ONLY, |
166 | .mwdma_mask = ATA_MWDMA12_ONLY, \ | 168 | .udma_mask = ATA_UDMA6, |
167 | .udma_mask = ATA_UDMA6, \ | ||
168 | } | ||
169 | |||
170 | static const struct ide_port_info it8213_chipsets[] __devinitdata = { | ||
171 | /* 0 */ DECLARE_ITE_DEV("IT8213"), | ||
172 | }; | 169 | }; |
173 | 170 | ||
174 | |||
175 | /** | 171 | /** |
176 | * it8213_init_one - pci layer discovery entry | 172 | * it8213_init_one - pci layer discovery entry |
177 | * @dev: PCI device | 173 | * @dev: PCI device |
@@ -184,7 +180,7 @@ static const struct ide_port_info it8213_chipsets[] __devinitdata = { | |||
184 | 180 | ||
185 | static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 181 | static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
186 | { | 182 | { |
187 | return ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]); | 183 | return ide_pci_init_one(dev, &it8213_chipset, NULL); |
188 | } | 184 | } |
189 | 185 | ||
190 | static const struct pci_device_id it8213_pci_tbl[] = { | 186 | static const struct pci_device_id it8213_pci_tbl[] = { |
@@ -198,6 +194,7 @@ static struct pci_driver driver = { | |||
198 | .name = "ITE8213_IDE", | 194 | .name = "ITE8213_IDE", |
199 | .id_table = it8213_pci_tbl, | 195 | .id_table = it8213_pci_tbl, |
200 | .probe = it8213_init_one, | 196 | .probe = it8213_init_one, |
197 | .remove = ide_pci_remove, | ||
201 | }; | 198 | }; |
202 | 199 | ||
203 | static int __init it8213_ide_init(void) | 200 | static int __init it8213_ide_init(void) |
@@ -205,7 +202,13 @@ static int __init it8213_ide_init(void) | |||
205 | return ide_pci_register_driver(&driver); | 202 | return ide_pci_register_driver(&driver); |
206 | } | 203 | } |
207 | 204 | ||
205 | static void __exit it8213_ide_exit(void) | ||
206 | { | ||
207 | pci_unregister_driver(&driver); | ||
208 | } | ||
209 | |||
208 | module_init(it8213_ide_init); | 210 | module_init(it8213_ide_init); |
211 | module_exit(it8213_ide_exit); | ||
209 | 212 | ||
210 | MODULE_AUTHOR("Jack Lee, Alan Cox"); | 213 | MODULE_AUTHOR("Jack Lee, Alan Cox"); |
211 | MODULE_DESCRIPTION("PCI driver module for the ITE 8213"); | 214 | MODULE_DESCRIPTION("PCI driver module for the ITE 8213"); |
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index cbf647202994..e16a1d113a2a 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -67,6 +67,8 @@ | |||
67 | #include <linux/ide.h> | 67 | #include <linux/ide.h> |
68 | #include <linux/init.h> | 68 | #include <linux/init.h> |
69 | 69 | ||
70 | #define DRV_NAME "it821x" | ||
71 | |||
70 | struct it821x_dev | 72 | struct it821x_dev |
71 | { | 73 | { |
72 | unsigned int smart:1, /* Are we in smart raid mode */ | 74 | unsigned int smart:1, /* Are we in smart raid mode */ |
@@ -534,8 +536,9 @@ static struct ide_dma_ops it821x_pass_through_dma_ops = { | |||
534 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | 536 | static void __devinit init_hwif_it821x(ide_hwif_t *hwif) |
535 | { | 537 | { |
536 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 538 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
537 | struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev); | 539 | struct ide_host *host = pci_get_drvdata(dev); |
538 | struct it821x_dev *idev = itdevs[hwif->channel]; | 540 | struct it821x_dev *itdevs = host->host_priv; |
541 | struct it821x_dev *idev = itdevs + hwif->channel; | ||
539 | u8 conf; | 542 | u8 conf; |
540 | 543 | ||
541 | ide_set_hwifdata(hwif, idev); | 544 | ide_set_hwifdata(hwif, idev); |
@@ -568,7 +571,8 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
568 | idev->timing10 = 1; | 571 | idev->timing10 = 1; |
569 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 572 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |
570 | if (idev->smart == 0) | 573 | if (idev->smart == 0) |
571 | printk(KERN_WARNING "it821x: Revision 0x10, workarounds activated.\n"); | 574 | printk(KERN_WARNING DRV_NAME " %s: revision 0x10, " |
575 | "workarounds activated\n", pci_name(dev)); | ||
572 | } | 576 | } |
573 | 577 | ||
574 | if (idev->smart == 0) { | 578 | if (idev->smart == 0) { |
@@ -601,18 +605,20 @@ static void __devinit it8212_disable_raid(struct pci_dev *dev) | |||
601 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); | 605 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); |
602 | } | 606 | } |
603 | 607 | ||
604 | static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const char *name) | 608 | static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev) |
605 | { | 609 | { |
606 | u8 conf; | 610 | u8 conf; |
607 | static char *mode[2] = { "pass through", "smart" }; | 611 | static char *mode[2] = { "pass through", "smart" }; |
608 | 612 | ||
609 | /* Force the card into bypass mode if so requested */ | 613 | /* Force the card into bypass mode if so requested */ |
610 | if (it8212_noraid) { | 614 | if (it8212_noraid) { |
611 | printk(KERN_INFO "it8212: forcing bypass mode.\n"); | 615 | printk(KERN_INFO DRV_NAME " %s: forcing bypass mode\n", |
616 | pci_name(dev)); | ||
612 | it8212_disable_raid(dev); | 617 | it8212_disable_raid(dev); |
613 | } | 618 | } |
614 | pci_read_config_byte(dev, 0x50, &conf); | 619 | pci_read_config_byte(dev, 0x50, &conf); |
615 | printk(KERN_INFO "it821x: controller in %s mode.\n", mode[conf & 1]); | 620 | printk(KERN_INFO DRV_NAME " %s: controller in %s mode\n", |
621 | pci_name(dev), mode[conf & 1]); | ||
616 | return 0; | 622 | return 0; |
617 | } | 623 | } |
618 | 624 | ||
@@ -624,17 +630,12 @@ static const struct ide_port_ops it821x_port_ops = { | |||
624 | .cable_detect = it821x_cable_detect, | 630 | .cable_detect = it821x_cable_detect, |
625 | }; | 631 | }; |
626 | 632 | ||
627 | #define DECLARE_ITE_DEV(name_str) \ | 633 | static const struct ide_port_info it821x_chipset __devinitdata = { |
628 | { \ | 634 | .name = DRV_NAME, |
629 | .name = name_str, \ | 635 | .init_chipset = init_chipset_it821x, |
630 | .init_chipset = init_chipset_it821x, \ | 636 | .init_hwif = init_hwif_it821x, |
631 | .init_hwif = init_hwif_it821x, \ | 637 | .port_ops = &it821x_port_ops, |
632 | .port_ops = &it821x_port_ops, \ | 638 | .pio_mask = ATA_PIO4, |
633 | .pio_mask = ATA_PIO4, \ | ||
634 | } | ||
635 | |||
636 | static const struct ide_port_info it821x_chipsets[] __devinitdata = { | ||
637 | /* 0 */ DECLARE_ITE_DEV("IT8212"), | ||
638 | }; | 639 | }; |
639 | 640 | ||
640 | /** | 641 | /** |
@@ -648,23 +649,29 @@ static const struct ide_port_info it821x_chipsets[] __devinitdata = { | |||
648 | 649 | ||
649 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 650 | static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
650 | { | 651 | { |
651 | struct it821x_dev *itdevs[2] = { NULL, NULL} , *itdev; | 652 | struct it821x_dev *itdevs; |
652 | unsigned int i; | 653 | int rc; |
653 | |||
654 | for (i = 0; i < 2; i++) { | ||
655 | itdev = kzalloc(sizeof(*itdev), GFP_KERNEL); | ||
656 | if (itdev == NULL) { | ||
657 | kfree(itdevs[0]); | ||
658 | printk(KERN_ERR "it821x: out of memory\n"); | ||
659 | return -ENOMEM; | ||
660 | } | ||
661 | 654 | ||
662 | itdevs[i] = itdev; | 655 | itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL); |
656 | if (itdevs == NULL) { | ||
657 | printk(KERN_ERR DRV_NAME " %s: out of memory\n", pci_name(dev)); | ||
658 | return -ENOMEM; | ||
663 | } | 659 | } |
664 | 660 | ||
665 | pci_set_drvdata(dev, itdevs); | 661 | rc = ide_pci_init_one(dev, &it821x_chipset, itdevs); |
662 | if (rc) | ||
663 | kfree(itdevs); | ||
666 | 664 | ||
667 | return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); | 665 | return rc; |
666 | } | ||
667 | |||
668 | static void __devexit it821x_remove(struct pci_dev *dev) | ||
669 | { | ||
670 | struct ide_host *host = pci_get_drvdata(dev); | ||
671 | struct it821x_dev *itdevs = host->host_priv; | ||
672 | |||
673 | ide_pci_remove(dev); | ||
674 | kfree(itdevs); | ||
668 | } | 675 | } |
669 | 676 | ||
670 | static const struct pci_device_id it821x_pci_tbl[] = { | 677 | static const struct pci_device_id it821x_pci_tbl[] = { |
@@ -679,6 +686,7 @@ static struct pci_driver driver = { | |||
679 | .name = "ITE821x IDE", | 686 | .name = "ITE821x IDE", |
680 | .id_table = it821x_pci_tbl, | 687 | .id_table = it821x_pci_tbl, |
681 | .probe = it821x_init_one, | 688 | .probe = it821x_init_one, |
689 | .remove = it821x_remove, | ||
682 | }; | 690 | }; |
683 | 691 | ||
684 | static int __init it821x_ide_init(void) | 692 | static int __init it821x_ide_init(void) |
@@ -686,7 +694,13 @@ static int __init it821x_ide_init(void) | |||
686 | return ide_pci_register_driver(&driver); | 694 | return ide_pci_register_driver(&driver); |
687 | } | 695 | } |
688 | 696 | ||
697 | static void __exit it821x_ide_exit(void) | ||
698 | { | ||
699 | pci_unregister_driver(&driver); | ||
700 | } | ||
701 | |||
689 | module_init(it821x_ide_init); | 702 | module_init(it821x_ide_init); |
703 | module_exit(it821x_ide_exit); | ||
690 | 704 | ||
691 | module_param_named(noraid, it8212_noraid, int, S_IRUGO); | 705 | module_param_named(noraid, it8212_noraid, int, S_IRUGO); |
692 | MODULE_PARM_DESC(noraid, "Force card into bypass mode"); | 706 | MODULE_PARM_DESC(noraid, "Force card into bypass mode"); |
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index 96ef7394f283..545b6e172d9b 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c | |||
@@ -12,6 +12,8 @@ | |||
12 | #include <linux/ide.h> | 12 | #include <linux/ide.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | 14 | ||
15 | #define DRV_NAME "jmicron" | ||
16 | |||
15 | typedef enum { | 17 | typedef enum { |
16 | PORT_PATA0 = 0, | 18 | PORT_PATA0 = 0, |
17 | PORT_PATA1 = 1, | 19 | PORT_PATA1 = 1, |
@@ -102,7 +104,7 @@ static const struct ide_port_ops jmicron_port_ops = { | |||
102 | }; | 104 | }; |
103 | 105 | ||
104 | static const struct ide_port_info jmicron_chipset __devinitdata = { | 106 | static const struct ide_port_info jmicron_chipset __devinitdata = { |
105 | .name = "JMB", | 107 | .name = DRV_NAME, |
106 | .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, | 108 | .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, |
107 | .port_ops = &jmicron_port_ops, | 109 | .port_ops = &jmicron_port_ops, |
108 | .pio_mask = ATA_PIO5, | 110 | .pio_mask = ATA_PIO5, |
@@ -121,7 +123,7 @@ static const struct ide_port_info jmicron_chipset __devinitdata = { | |||
121 | 123 | ||
122 | static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 124 | static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
123 | { | 125 | { |
124 | return ide_setup_pci_device(dev, &jmicron_chipset); | 126 | return ide_pci_init_one(dev, &jmicron_chipset, NULL); |
125 | } | 127 | } |
126 | 128 | ||
127 | /* All JMB PATA controllers have and will continue to have the same | 129 | /* All JMB PATA controllers have and will continue to have the same |
@@ -152,6 +154,7 @@ static struct pci_driver driver = { | |||
152 | .name = "JMicron IDE", | 154 | .name = "JMicron IDE", |
153 | .id_table = jmicron_pci_tbl, | 155 | .id_table = jmicron_pci_tbl, |
154 | .probe = jmicron_init_one, | 156 | .probe = jmicron_init_one, |
157 | .remove = ide_pci_remove, | ||
155 | }; | 158 | }; |
156 | 159 | ||
157 | static int __init jmicron_ide_init(void) | 160 | static int __init jmicron_ide_init(void) |
@@ -159,7 +162,13 @@ static int __init jmicron_ide_init(void) | |||
159 | return ide_pci_register_driver(&driver); | 162 | return ide_pci_register_driver(&driver); |
160 | } | 163 | } |
161 | 164 | ||
165 | static void __exit jmicron_ide_exit(void) | ||
166 | { | ||
167 | pci_unregister_driver(&driver); | ||
168 | } | ||
169 | |||
162 | module_init(jmicron_ide_init); | 170 | module_init(jmicron_ide_init); |
171 | module_exit(jmicron_ide_exit); | ||
163 | 172 | ||
164 | MODULE_AUTHOR("Alan Cox"); | 173 | MODULE_AUTHOR("Alan Cox"); |
165 | MODULE_DESCRIPTION("PCI driver module for the JMicron in legacy modes"); | 174 | MODULE_DESCRIPTION("PCI driver module for the JMicron in legacy modes"); |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index 5cd2b32ff0ef..ffefcd15196c 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -19,6 +19,8 @@ | |||
19 | 19 | ||
20 | #include <asm/io.h> | 20 | #include <asm/io.h> |
21 | 21 | ||
22 | #define DRV_NAME "ns87415" | ||
23 | |||
22 | #ifdef CONFIG_SUPERIO | 24 | #ifdef CONFIG_SUPERIO |
23 | /* SUPERIO 87560 is a PoS chip that NatSem denies exists. | 25 | /* SUPERIO 87560 is a PoS chip that NatSem denies exists. |
24 | * Unfortunately, it's built-in on all Astro-based PA-RISC workstations | 26 | * Unfortunately, it's built-in on all Astro-based PA-RISC workstations |
@@ -305,7 +307,7 @@ static const struct ide_dma_ops ns87415_dma_ops = { | |||
305 | }; | 307 | }; |
306 | 308 | ||
307 | static const struct ide_port_info ns87415_chipset __devinitdata = { | 309 | static const struct ide_port_info ns87415_chipset __devinitdata = { |
308 | .name = "NS87415", | 310 | .name = DRV_NAME, |
309 | .init_hwif = init_hwif_ns87415, | 311 | .init_hwif = init_hwif_ns87415, |
310 | .port_ops = &ns87415_port_ops, | 312 | .port_ops = &ns87415_port_ops, |
311 | .dma_ops = &ns87415_dma_ops, | 313 | .dma_ops = &ns87415_dma_ops, |
@@ -324,7 +326,7 @@ static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_devi | |||
324 | d.tp_ops = &superio_tp_ops; | 326 | d.tp_ops = &superio_tp_ops; |
325 | } | 327 | } |
326 | #endif | 328 | #endif |
327 | return ide_setup_pci_device(dev, &d); | 329 | return ide_pci_init_one(dev, &d, NULL); |
328 | } | 330 | } |
329 | 331 | ||
330 | static const struct pci_device_id ns87415_pci_tbl[] = { | 332 | static const struct pci_device_id ns87415_pci_tbl[] = { |
@@ -337,6 +339,7 @@ static struct pci_driver driver = { | |||
337 | .name = "NS87415_IDE", | 339 | .name = "NS87415_IDE", |
338 | .id_table = ns87415_pci_tbl, | 340 | .id_table = ns87415_pci_tbl, |
339 | .probe = ns87415_init_one, | 341 | .probe = ns87415_init_one, |
342 | .remove = ide_pci_remove, | ||
340 | }; | 343 | }; |
341 | 344 | ||
342 | static int __init ns87415_ide_init(void) | 345 | static int __init ns87415_ide_init(void) |
@@ -344,7 +347,13 @@ static int __init ns87415_ide_init(void) | |||
344 | return ide_pci_register_driver(&driver); | 347 | return ide_pci_register_driver(&driver); |
345 | } | 348 | } |
346 | 349 | ||
350 | static void __exit ns87415_ide_exit(void) | ||
351 | { | ||
352 | pci_unregister_driver(&driver); | ||
353 | } | ||
354 | |||
347 | module_init(ns87415_ide_init); | 355 | module_init(ns87415_ide_init); |
356 | module_exit(ns87415_ide_exit); | ||
348 | 357 | ||
349 | MODULE_AUTHOR("Mark Lord, Eddie Dost, Andre Hedrick"); | 358 | MODULE_AUTHOR("Mark Lord, Eddie Dost, Andre Hedrick"); |
350 | MODULE_DESCRIPTION("PCI driver module for NS87415 IDE"); | 359 | MODULE_DESCRIPTION("PCI driver module for NS87415 IDE"); |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index 725c80508d90..e28e672ddafc 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
@@ -90,6 +90,8 @@ | |||
90 | 90 | ||
91 | #include <asm/io.h> | 91 | #include <asm/io.h> |
92 | 92 | ||
93 | #define DRV_NAME "opti621" | ||
94 | |||
93 | #define READ_REG 0 /* index of Read cycle timing register */ | 95 | #define READ_REG 0 /* index of Read cycle timing register */ |
94 | #define WRITE_REG 1 /* index of Write cycle timing register */ | 96 | #define WRITE_REG 1 /* index of Write cycle timing register */ |
95 | #define CNTRL_REG 3 /* index of Control register */ | 97 | #define CNTRL_REG 3 /* index of Control register */ |
@@ -200,7 +202,7 @@ static const struct ide_port_ops opti621_port_ops = { | |||
200 | }; | 202 | }; |
201 | 203 | ||
202 | static const struct ide_port_info opti621_chipset __devinitdata = { | 204 | static const struct ide_port_info opti621_chipset __devinitdata = { |
203 | .name = "OPTI621/X", | 205 | .name = DRV_NAME, |
204 | .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, | 206 | .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, |
205 | .port_ops = &opti621_port_ops, | 207 | .port_ops = &opti621_port_ops, |
206 | .host_flags = IDE_HFLAG_NO_DMA, | 208 | .host_flags = IDE_HFLAG_NO_DMA, |
@@ -209,7 +211,7 @@ static const struct ide_port_info opti621_chipset __devinitdata = { | |||
209 | 211 | ||
210 | static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 212 | static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
211 | { | 213 | { |
212 | return ide_setup_pci_device(dev, &opti621_chipset); | 214 | return ide_pci_init_one(dev, &opti621_chipset, NULL); |
213 | } | 215 | } |
214 | 216 | ||
215 | static const struct pci_device_id opti621_pci_tbl[] = { | 217 | static const struct pci_device_id opti621_pci_tbl[] = { |
@@ -223,6 +225,7 @@ static struct pci_driver driver = { | |||
223 | .name = "Opti621_IDE", | 225 | .name = "Opti621_IDE", |
224 | .id_table = opti621_pci_tbl, | 226 | .id_table = opti621_pci_tbl, |
225 | .probe = opti621_init_one, | 227 | .probe = opti621_init_one, |
228 | .remove = ide_pci_remove, | ||
226 | }; | 229 | }; |
227 | 230 | ||
228 | static int __init opti621_ide_init(void) | 231 | static int __init opti621_ide_init(void) |
@@ -230,7 +233,13 @@ static int __init opti621_ide_init(void) | |||
230 | return ide_pci_register_driver(&driver); | 233 | return ide_pci_register_driver(&driver); |
231 | } | 234 | } |
232 | 235 | ||
236 | static void __exit opti621_ide_exit(void) | ||
237 | { | ||
238 | pci_unregister_driver(&driver); | ||
239 | } | ||
240 | |||
233 | module_init(opti621_ide_init); | 241 | module_init(opti621_ide_init); |
242 | module_exit(opti621_ide_exit); | ||
234 | 243 | ||
235 | MODULE_AUTHOR("Jaromir Koutek, Jan Harkes, Mark Lord"); | 244 | MODULE_AUTHOR("Jaromir Koutek, Jan Harkes, Mark Lord"); |
236 | MODULE_DESCRIPTION("PCI driver module for Opti621 IDE"); | 245 | MODULE_DESCRIPTION("PCI driver module for Opti621 IDE"); |
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 070df8ab3b21..998615fa285f 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <asm/pci-bridge.h> | 31 | #include <asm/pci-bridge.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #define DRV_NAME "pdc202xx_new" | ||
35 | |||
34 | #undef DEBUG | 36 | #undef DEBUG |
35 | 37 | ||
36 | #ifdef DEBUG | 38 | #ifdef DEBUG |
@@ -324,8 +326,9 @@ static void __devinit apple_kiwi_init(struct pci_dev *pdev) | |||
324 | } | 326 | } |
325 | #endif /* CONFIG_PPC_PMAC */ | 327 | #endif /* CONFIG_PPC_PMAC */ |
326 | 328 | ||
327 | static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const char *name) | 329 | static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev) |
328 | { | 330 | { |
331 | const char *name = DRV_NAME; | ||
329 | unsigned long dma_base = pci_resource_start(dev, 4); | 332 | unsigned long dma_base = pci_resource_start(dev, 4); |
330 | unsigned long sec_dma_base = dma_base + 0x08; | 333 | unsigned long sec_dma_base = dma_base + 0x08; |
331 | long pll_input, pll_output, ratio; | 334 | long pll_input, pll_output, ratio; |
@@ -358,12 +361,13 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha | |||
358 | * registers setting. | 361 | * registers setting. |
359 | */ | 362 | */ |
360 | pll_input = detect_pll_input_clock(dma_base); | 363 | pll_input = detect_pll_input_clock(dma_base); |
361 | printk("%s: PLL input clock is %ld kHz\n", name, pll_input / 1000); | 364 | printk(KERN_INFO "%s %s: PLL input clock is %ld kHz\n", |
365 | name, pci_name(dev), pll_input / 1000); | ||
362 | 366 | ||
363 | /* Sanity check */ | 367 | /* Sanity check */ |
364 | if (unlikely(pll_input < 5000000L || pll_input > 70000000L)) { | 368 | if (unlikely(pll_input < 5000000L || pll_input > 70000000L)) { |
365 | printk(KERN_ERR "%s: Bad PLL input clock %ld Hz, giving up!\n", | 369 | printk(KERN_ERR "%s %s: Bad PLL input clock %ld Hz, giving up!" |
366 | name, pll_input); | 370 | "\n", name, pci_name(dev), pll_input); |
367 | goto out; | 371 | goto out; |
368 | } | 372 | } |
369 | 373 | ||
@@ -399,7 +403,8 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha | |||
399 | r = 0x00; | 403 | r = 0x00; |
400 | } else { | 404 | } else { |
401 | /* Invalid ratio */ | 405 | /* Invalid ratio */ |
402 | printk(KERN_ERR "%s: Bad ratio %ld, giving up!\n", name, ratio); | 406 | printk(KERN_ERR "%s %s: Bad ratio %ld, giving up!\n", |
407 | name, pci_name(dev), ratio); | ||
403 | goto out; | 408 | goto out; |
404 | } | 409 | } |
405 | 410 | ||
@@ -409,7 +414,8 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha | |||
409 | 414 | ||
410 | if (unlikely(f < 0 || f > 127)) { | 415 | if (unlikely(f < 0 || f > 127)) { |
411 | /* Invalid F */ | 416 | /* Invalid F */ |
412 | printk(KERN_ERR "%s: F[%d] invalid!\n", name, f); | 417 | printk(KERN_ERR "%s %s: F[%d] invalid!\n", |
418 | name, pci_name(dev), f); | ||
413 | goto out; | 419 | goto out; |
414 | } | 420 | } |
415 | 421 | ||
@@ -455,8 +461,8 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | |||
455 | 461 | ||
456 | if (dev2->irq != dev->irq) { | 462 | if (dev2->irq != dev->irq) { |
457 | dev2->irq = dev->irq; | 463 | dev2->irq = dev->irq; |
458 | printk(KERN_INFO "PDC20270: PCI config space " | 464 | printk(KERN_INFO DRV_NAME " %s: PCI config space " |
459 | "interrupt fixed\n"); | 465 | "interrupt fixed\n", pci_name(dev)); |
460 | } | 466 | } |
461 | 467 | ||
462 | return dev2; | 468 | return dev2; |
@@ -473,9 +479,9 @@ static const struct ide_port_ops pdcnew_port_ops = { | |||
473 | .cable_detect = pdcnew_cable_detect, | 479 | .cable_detect = pdcnew_cable_detect, |
474 | }; | 480 | }; |
475 | 481 | ||
476 | #define DECLARE_PDCNEW_DEV(name_str, udma) \ | 482 | #define DECLARE_PDCNEW_DEV(udma) \ |
477 | { \ | 483 | { \ |
478 | .name = name_str, \ | 484 | .name = DRV_NAME, \ |
479 | .init_chipset = init_chipset_pdcnew, \ | 485 | .init_chipset = init_chipset_pdcnew, \ |
480 | .port_ops = &pdcnew_port_ops, \ | 486 | .port_ops = &pdcnew_port_ops, \ |
481 | .host_flags = IDE_HFLAG_POST_SET_MODE | \ | 487 | .host_flags = IDE_HFLAG_POST_SET_MODE | \ |
@@ -487,13 +493,8 @@ static const struct ide_port_ops pdcnew_port_ops = { | |||
487 | } | 493 | } |
488 | 494 | ||
489 | static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { | 495 | static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { |
490 | /* 0 */ DECLARE_PDCNEW_DEV("PDC20268", ATA_UDMA5), | 496 | /* 0: PDC202{68,70} */ DECLARE_PDCNEW_DEV(ATA_UDMA5), |
491 | /* 1 */ DECLARE_PDCNEW_DEV("PDC20269", ATA_UDMA6), | 497 | /* 1: PDC202{69,71,75,76,77} */ DECLARE_PDCNEW_DEV(ATA_UDMA6), |
492 | /* 2 */ DECLARE_PDCNEW_DEV("PDC20270", ATA_UDMA5), | ||
493 | /* 3 */ DECLARE_PDCNEW_DEV("PDC20271", ATA_UDMA6), | ||
494 | /* 4 */ DECLARE_PDCNEW_DEV("PDC20275", ATA_UDMA6), | ||
495 | /* 5 */ DECLARE_PDCNEW_DEV("PDC20276", ATA_UDMA6), | ||
496 | /* 6 */ DECLARE_PDCNEW_DEV("PDC20277", ATA_UDMA6), | ||
497 | }; | 498 | }; |
498 | 499 | ||
499 | /** | 500 | /** |
@@ -507,13 +508,10 @@ static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { | |||
507 | 508 | ||
508 | static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 509 | static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
509 | { | 510 | { |
510 | const struct ide_port_info *d; | 511 | const struct ide_port_info *d = &pdcnew_chipsets[id->driver_data]; |
511 | struct pci_dev *bridge = dev->bus->self; | 512 | struct pci_dev *bridge = dev->bus->self; |
512 | u8 idx = id->driver_data; | ||
513 | |||
514 | d = &pdcnew_chipsets[idx]; | ||
515 | 513 | ||
516 | if (idx == 2 && bridge && | 514 | if (dev->device == PCI_DEVICE_ID_PROMISE_20270 && bridge && |
517 | bridge->vendor == PCI_VENDOR_ID_DEC && | 515 | bridge->vendor == PCI_VENDOR_ID_DEC && |
518 | bridge->device == PCI_DEVICE_ID_DEC_21150) { | 516 | bridge->device == PCI_DEVICE_ID_DEC_21150) { |
519 | struct pci_dev *dev2; | 517 | struct pci_dev *dev2; |
@@ -524,33 +522,42 @@ static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_de | |||
524 | dev2 = pdc20270_get_dev2(dev); | 522 | dev2 = pdc20270_get_dev2(dev); |
525 | 523 | ||
526 | if (dev2) { | 524 | if (dev2) { |
527 | int ret = ide_setup_pci_devices(dev, dev2, d); | 525 | int ret = ide_pci_init_two(dev, dev2, d, NULL); |
528 | if (ret < 0) | 526 | if (ret < 0) |
529 | pci_dev_put(dev2); | 527 | pci_dev_put(dev2); |
530 | return ret; | 528 | return ret; |
531 | } | 529 | } |
532 | } | 530 | } |
533 | 531 | ||
534 | if (idx == 5 && bridge && | 532 | if (dev->device == PCI_DEVICE_ID_PROMISE_20276 && bridge && |
535 | bridge->vendor == PCI_VENDOR_ID_INTEL && | 533 | bridge->vendor == PCI_VENDOR_ID_INTEL && |
536 | (bridge->device == PCI_DEVICE_ID_INTEL_I960 || | 534 | (bridge->device == PCI_DEVICE_ID_INTEL_I960 || |
537 | bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) { | 535 | bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) { |
538 | printk(KERN_INFO "PDC20276: attached to I2O RAID controller, " | 536 | printk(KERN_INFO DRV_NAME " %s: attached to I2O RAID controller," |
539 | "skipping\n"); | 537 | " skipping\n", pci_name(dev)); |
540 | return -ENODEV; | 538 | return -ENODEV; |
541 | } | 539 | } |
542 | 540 | ||
543 | return ide_setup_pci_device(dev, d); | 541 | return ide_pci_init_one(dev, d, NULL); |
542 | } | ||
543 | |||
544 | static void __devexit pdc202new_remove(struct pci_dev *dev) | ||
545 | { | ||
546 | struct ide_host *host = pci_get_drvdata(dev); | ||
547 | struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL; | ||
548 | |||
549 | ide_pci_remove(dev); | ||
550 | pci_dev_put(dev2); | ||
544 | } | 551 | } |
545 | 552 | ||
546 | static const struct pci_device_id pdc202new_pci_tbl[] = { | 553 | static const struct pci_device_id pdc202new_pci_tbl[] = { |
547 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20268), 0 }, | 554 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20268), 0 }, |
548 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20269), 1 }, | 555 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20269), 1 }, |
549 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20270), 2 }, | 556 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20270), 0 }, |
550 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20271), 3 }, | 557 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20271), 1 }, |
551 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20275), 4 }, | 558 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20275), 1 }, |
552 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20276), 5 }, | 559 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20276), 1 }, |
553 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20277), 6 }, | 560 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20277), 1 }, |
554 | { 0, }, | 561 | { 0, }, |
555 | }; | 562 | }; |
556 | MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl); | 563 | MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl); |
@@ -559,6 +566,7 @@ static struct pci_driver driver = { | |||
559 | .name = "Promise_IDE", | 566 | .name = "Promise_IDE", |
560 | .id_table = pdc202new_pci_tbl, | 567 | .id_table = pdc202new_pci_tbl, |
561 | .probe = pdc202new_init_one, | 568 | .probe = pdc202new_init_one, |
569 | .remove = pdc202new_remove, | ||
562 | }; | 570 | }; |
563 | 571 | ||
564 | static int __init pdc202new_ide_init(void) | 572 | static int __init pdc202new_ide_init(void) |
@@ -566,7 +574,13 @@ static int __init pdc202new_ide_init(void) | |||
566 | return ide_pci_register_driver(&driver); | 574 | return ide_pci_register_driver(&driver); |
567 | } | 575 | } |
568 | 576 | ||
577 | static void __exit pdc202new_ide_exit(void) | ||
578 | { | ||
579 | pci_unregister_driver(&driver); | ||
580 | } | ||
581 | |||
569 | module_init(pdc202new_ide_init); | 582 | module_init(pdc202new_ide_init); |
583 | module_exit(pdc202new_ide_exit); | ||
570 | 584 | ||
571 | MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); | 585 | MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); |
572 | MODULE_DESCRIPTION("PCI driver module for Promise PDC20268 and higher"); | 586 | MODULE_DESCRIPTION("PCI driver module for Promise PDC20268 and higher"); |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index e54dc653b8c4..6ff2def58da0 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
@@ -20,6 +20,8 @@ | |||
20 | 20 | ||
21 | #include <asm/io.h> | 21 | #include <asm/io.h> |
22 | 22 | ||
23 | #define DRV_NAME "pdc202xx_old" | ||
24 | |||
23 | #define PDC202XX_DEBUG_DRIVE_INFO 0 | 25 | #define PDC202XX_DEBUG_DRIVE_INFO 0 |
24 | 26 | ||
25 | static const char *pdc_quirk_drives[] = { | 27 | static const char *pdc_quirk_drives[] = { |
@@ -263,8 +265,7 @@ static void pdc202xx_dma_timeout(ide_drive_t *drive) | |||
263 | ide_dma_timeout(drive); | 265 | ide_dma_timeout(drive); |
264 | } | 266 | } |
265 | 267 | ||
266 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, | 268 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev) |
267 | const char *name) | ||
268 | { | 269 | { |
269 | unsigned long dmabase = pci_resource_start(dev, 4); | 270 | unsigned long dmabase = pci_resource_start(dev, 4); |
270 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; | 271 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; |
@@ -304,8 +305,8 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | |||
304 | if (irq != irq2) { | 305 | if (irq != irq2) { |
305 | pci_write_config_byte(dev, | 306 | pci_write_config_byte(dev, |
306 | (PCI_INTERRUPT_LINE)|0x80, irq); /* 0xbc */ | 307 | (PCI_INTERRUPT_LINE)|0x80, irq); /* 0xbc */ |
307 | printk(KERN_INFO "%s: PCI config space interrupt " | 308 | printk(KERN_INFO "%s %s: PCI config space interrupt " |
308 | "mirror fixed\n", name); | 309 | "mirror fixed\n", name, pci_name(dev)); |
309 | } | 310 | } |
310 | } | 311 | } |
311 | } | 312 | } |
@@ -350,9 +351,9 @@ static const struct ide_dma_ops pdc2026x_dma_ops = { | |||
350 | .dma_timeout = pdc202xx_dma_timeout, | 351 | .dma_timeout = pdc202xx_dma_timeout, |
351 | }; | 352 | }; |
352 | 353 | ||
353 | #define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ | 354 | #define DECLARE_PDC2026X_DEV(udma, extra_flags) \ |
354 | { \ | 355 | { \ |
355 | .name = name_str, \ | 356 | .name = DRV_NAME, \ |
356 | .init_chipset = init_chipset_pdc202xx, \ | 357 | .init_chipset = init_chipset_pdc202xx, \ |
357 | .port_ops = &pdc2026x_port_ops, \ | 358 | .port_ops = &pdc2026x_port_ops, \ |
358 | .dma_ops = &pdc2026x_dma_ops, \ | 359 | .dma_ops = &pdc2026x_dma_ops, \ |
@@ -363,8 +364,8 @@ static const struct ide_dma_ops pdc2026x_dma_ops = { | |||
363 | } | 364 | } |
364 | 365 | ||
365 | static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { | 366 | static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { |
366 | { /* 0 */ | 367 | { /* 0: PDC20246 */ |
367 | .name = "PDC20246", | 368 | .name = DRV_NAME, |
368 | .init_chipset = init_chipset_pdc202xx, | 369 | .init_chipset = init_chipset_pdc202xx, |
369 | .port_ops = &pdc20246_port_ops, | 370 | .port_ops = &pdc20246_port_ops, |
370 | .dma_ops = &pdc20246_dma_ops, | 371 | .dma_ops = &pdc20246_dma_ops, |
@@ -374,10 +375,10 @@ static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { | |||
374 | .udma_mask = ATA_UDMA2, | 375 | .udma_mask = ATA_UDMA2, |
375 | }, | 376 | }, |
376 | 377 | ||
377 | /* 1 */ DECLARE_PDC2026X_DEV("PDC20262", ATA_UDMA4, 0), | 378 | /* 1: PDC2026{2,3} */ |
378 | /* 2 */ DECLARE_PDC2026X_DEV("PDC20263", ATA_UDMA4, 0), | 379 | DECLARE_PDC2026X_DEV(ATA_UDMA4, 0), |
379 | /* 3 */ DECLARE_PDC2026X_DEV("PDC20265", ATA_UDMA5, IDE_HFLAG_RQSIZE_256), | 380 | /* 2: PDC2026{5,7} */ |
380 | /* 4 */ DECLARE_PDC2026X_DEV("PDC20267", ATA_UDMA5, IDE_HFLAG_RQSIZE_256), | 381 | DECLARE_PDC2026X_DEV(ATA_UDMA5, IDE_HFLAG_RQSIZE_256), |
381 | }; | 382 | }; |
382 | 383 | ||
383 | /** | 384 | /** |
@@ -396,31 +397,32 @@ static int __devinit pdc202xx_init_one(struct pci_dev *dev, const struct pci_dev | |||
396 | 397 | ||
397 | d = &pdc202xx_chipsets[idx]; | 398 | d = &pdc202xx_chipsets[idx]; |
398 | 399 | ||
399 | if (idx < 3) | 400 | if (idx < 2) |
400 | pdc202ata4_fixup_irq(dev, d->name); | 401 | pdc202ata4_fixup_irq(dev, d->name); |
401 | 402 | ||
402 | if (idx == 3) { | 403 | if (dev->vendor == PCI_DEVICE_ID_PROMISE_20265) { |
403 | struct pci_dev *bridge = dev->bus->self; | 404 | struct pci_dev *bridge = dev->bus->self; |
404 | 405 | ||
405 | if (bridge && | 406 | if (bridge && |
406 | bridge->vendor == PCI_VENDOR_ID_INTEL && | 407 | bridge->vendor == PCI_VENDOR_ID_INTEL && |
407 | (bridge->device == PCI_DEVICE_ID_INTEL_I960 || | 408 | (bridge->device == PCI_DEVICE_ID_INTEL_I960 || |
408 | bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) { | 409 | bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) { |
409 | printk(KERN_INFO "ide: Skipping Promise PDC20265 " | 410 | printk(KERN_INFO DRV_NAME " %s: skipping Promise " |
410 | "attached to I2O RAID controller\n"); | 411 | "PDC20265 attached to I2O RAID controller\n", |
412 | pci_name(dev)); | ||
411 | return -ENODEV; | 413 | return -ENODEV; |
412 | } | 414 | } |
413 | } | 415 | } |
414 | 416 | ||
415 | return ide_setup_pci_device(dev, d); | 417 | return ide_pci_init_one(dev, d, NULL); |
416 | } | 418 | } |
417 | 419 | ||
418 | static const struct pci_device_id pdc202xx_pci_tbl[] = { | 420 | static const struct pci_device_id pdc202xx_pci_tbl[] = { |
419 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20246), 0 }, | 421 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20246), 0 }, |
420 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20262), 1 }, | 422 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20262), 1 }, |
421 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20263), 2 }, | 423 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20263), 1 }, |
422 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20265), 3 }, | 424 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20265), 2 }, |
423 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20267), 4 }, | 425 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20267), 2 }, |
424 | { 0, }, | 426 | { 0, }, |
425 | }; | 427 | }; |
426 | MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl); | 428 | MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl); |
@@ -429,6 +431,7 @@ static struct pci_driver driver = { | |||
429 | .name = "Promise_Old_IDE", | 431 | .name = "Promise_Old_IDE", |
430 | .id_table = pdc202xx_pci_tbl, | 432 | .id_table = pdc202xx_pci_tbl, |
431 | .probe = pdc202xx_init_one, | 433 | .probe = pdc202xx_init_one, |
434 | .remove = ide_pci_remove, | ||
432 | }; | 435 | }; |
433 | 436 | ||
434 | static int __init pdc202xx_ide_init(void) | 437 | static int __init pdc202xx_ide_init(void) |
@@ -436,7 +439,13 @@ static int __init pdc202xx_ide_init(void) | |||
436 | return ide_pci_register_driver(&driver); | 439 | return ide_pci_register_driver(&driver); |
437 | } | 440 | } |
438 | 441 | ||
442 | static void __exit pdc202xx_ide_exit(void) | ||
443 | { | ||
444 | pci_unregister_driver(&driver); | ||
445 | } | ||
446 | |||
439 | module_init(pdc202xx_ide_init); | 447 | module_init(pdc202xx_ide_init); |
448 | module_exit(pdc202xx_ide_exit); | ||
440 | 449 | ||
441 | MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); | 450 | MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); |
442 | MODULE_DESCRIPTION("PCI driver module for older Promise IDE"); | 451 | MODULE_DESCRIPTION("PCI driver module for older Promise IDE"); |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index 0ce41b4dddaf..7fc3022dcf68 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -54,6 +54,8 @@ | |||
54 | 54 | ||
55 | #include <asm/io.h> | 55 | #include <asm/io.h> |
56 | 56 | ||
57 | #define DRV_NAME "piix" | ||
58 | |||
57 | static int no_piix_dma; | 59 | static int no_piix_dma; |
58 | 60 | ||
59 | /** | 61 | /** |
@@ -198,13 +200,12 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
198 | /** | 200 | /** |
199 | * init_chipset_ich - set up the ICH chipset | 201 | * init_chipset_ich - set up the ICH chipset |
200 | * @dev: PCI device to set up | 202 | * @dev: PCI device to set up |
201 | * @name: Name of the device | ||
202 | * | 203 | * |
203 | * Initialize the PCI device as required. For the ICH this turns | 204 | * Initialize the PCI device as required. For the ICH this turns |
204 | * out to be nice and simple. | 205 | * out to be nice and simple. |
205 | */ | 206 | */ |
206 | 207 | ||
207 | static unsigned int __devinit init_chipset_ich(struct pci_dev *dev, const char *name) | 208 | static unsigned int __devinit init_chipset_ich(struct pci_dev *dev) |
208 | { | 209 | { |
209 | u32 extra = 0; | 210 | u32 extra = 0; |
210 | 211 | ||
@@ -314,9 +315,9 @@ static const struct ide_port_ops piix_port_ops = { | |||
314 | #define IDE_HFLAGS_PIIX 0 | 315 | #define IDE_HFLAGS_PIIX 0 |
315 | #endif | 316 | #endif |
316 | 317 | ||
317 | #define DECLARE_PIIX_DEV(name_str, udma) \ | 318 | #define DECLARE_PIIX_DEV(udma) \ |
318 | { \ | 319 | { \ |
319 | .name = name_str, \ | 320 | .name = DRV_NAME, \ |
320 | .init_hwif = init_hwif_piix, \ | 321 | .init_hwif = init_hwif_piix, \ |
321 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ | 322 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ |
322 | .port_ops = &piix_port_ops, \ | 323 | .port_ops = &piix_port_ops, \ |
@@ -327,9 +328,9 @@ static const struct ide_port_ops piix_port_ops = { | |||
327 | .udma_mask = udma, \ | 328 | .udma_mask = udma, \ |
328 | } | 329 | } |
329 | 330 | ||
330 | #define DECLARE_ICH_DEV(name_str, udma) \ | 331 | #define DECLARE_ICH_DEV(udma) \ |
331 | { \ | 332 | { \ |
332 | .name = name_str, \ | 333 | .name = DRV_NAME, \ |
333 | .init_chipset = init_chipset_ich, \ | 334 | .init_chipset = init_chipset_ich, \ |
334 | .init_hwif = init_hwif_ich, \ | 335 | .init_hwif = init_hwif_ich, \ |
335 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ | 336 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ |
@@ -342,45 +343,31 @@ static const struct ide_port_ops piix_port_ops = { | |||
342 | } | 343 | } |
343 | 344 | ||
344 | static const struct ide_port_info piix_pci_info[] __devinitdata = { | 345 | static const struct ide_port_info piix_pci_info[] __devinitdata = { |
345 | /* 0 */ DECLARE_PIIX_DEV("PIIXa", 0x00), /* no udma */ | 346 | /* 0: MPIIX */ |
346 | /* 1 */ DECLARE_PIIX_DEV("PIIXb", 0x00), /* no udma */ | ||
347 | |||
348 | /* 2 */ | ||
349 | { /* | 347 | { /* |
350 | * MPIIX actually has only a single IDE channel mapped to | 348 | * MPIIX actually has only a single IDE channel mapped to |
351 | * the primary or secondary ports depending on the value | 349 | * the primary or secondary ports depending on the value |
352 | * of the bit 14 of the IDETIM register at offset 0x6c | 350 | * of the bit 14 of the IDETIM register at offset 0x6c |
353 | */ | 351 | */ |
354 | .name = "MPIIX", | 352 | .name = DRV_NAME, |
355 | .enablebits = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}}, | 353 | .enablebits = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}}, |
356 | .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_NO_DMA | | 354 | .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_NO_DMA | |
357 | IDE_HFLAGS_PIIX, | 355 | IDE_HFLAGS_PIIX, |
358 | .pio_mask = ATA_PIO4, | 356 | .pio_mask = ATA_PIO4, |
359 | /* This is a painful system best to let it self tune for now */ | 357 | /* This is a painful system best to let it self tune for now */ |
360 | }, | 358 | }, |
361 | 359 | /* 1: PIIXa/PIIXb/PIIX3 */ | |
362 | /* 3 */ DECLARE_PIIX_DEV("PIIX3", 0x00), /* no udma */ | 360 | DECLARE_PIIX_DEV(0x00), /* no udma */ |
363 | /* 4 */ DECLARE_PIIX_DEV("PIIX4", ATA_UDMA2), | 361 | /* 2: PIIX4 */ |
364 | /* 5 */ DECLARE_ICH_DEV("ICH0", ATA_UDMA2), | 362 | DECLARE_PIIX_DEV(ATA_UDMA2), |
365 | /* 6 */ DECLARE_PIIX_DEV("PIIX4", ATA_UDMA2), | 363 | /* 3: ICH0 */ |
366 | /* 7 */ DECLARE_ICH_DEV("ICH", ATA_UDMA4), | 364 | DECLARE_ICH_DEV(ATA_UDMA2), |
367 | /* 8 */ DECLARE_PIIX_DEV("PIIX4", ATA_UDMA4), | 365 | /* 4: ICH */ |
368 | /* 9 */ DECLARE_PIIX_DEV("PIIX4", ATA_UDMA2), | 366 | DECLARE_ICH_DEV(ATA_UDMA4), |
369 | /* 10 */ DECLARE_ICH_DEV("ICH2", ATA_UDMA5), | 367 | /* 5: PIIX4 */ |
370 | /* 11 */ DECLARE_ICH_DEV("ICH2M", ATA_UDMA5), | 368 | DECLARE_PIIX_DEV(ATA_UDMA4), |
371 | /* 12 */ DECLARE_ICH_DEV("ICH3M", ATA_UDMA5), | 369 | /* 6: ICH[2-7]/ICH[2-3]M/C-ICH/ICH5-SATA/ESB2/ICH8M */ |
372 | /* 13 */ DECLARE_ICH_DEV("ICH3", ATA_UDMA5), | 370 | DECLARE_ICH_DEV(ATA_UDMA5), |
373 | /* 14 */ DECLARE_ICH_DEV("ICH4", ATA_UDMA5), | ||
374 | /* 15 */ DECLARE_ICH_DEV("ICH5", ATA_UDMA5), | ||
375 | /* 16 */ DECLARE_ICH_DEV("C-ICH", ATA_UDMA5), | ||
376 | /* 17 */ DECLARE_ICH_DEV("ICH4", ATA_UDMA5), | ||
377 | /* 18 */ DECLARE_ICH_DEV("ICH5-SATA", ATA_UDMA5), | ||
378 | /* 19 */ DECLARE_ICH_DEV("ICH5", ATA_UDMA5), | ||
379 | /* 20 */ DECLARE_ICH_DEV("ICH6", ATA_UDMA5), | ||
380 | /* 21 */ DECLARE_ICH_DEV("ICH7", ATA_UDMA5), | ||
381 | /* 22 */ DECLARE_ICH_DEV("ICH4", ATA_UDMA5), | ||
382 | /* 23 */ DECLARE_ICH_DEV("ESB2", ATA_UDMA5), | ||
383 | /* 24 */ DECLARE_ICH_DEV("ICH8M", ATA_UDMA5), | ||
384 | }; | 371 | }; |
385 | 372 | ||
386 | /** | 373 | /** |
@@ -394,7 +381,7 @@ static const struct ide_port_info piix_pci_info[] __devinitdata = { | |||
394 | 381 | ||
395 | static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 382 | static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
396 | { | 383 | { |
397 | return ide_setup_pci_device(dev, &piix_pci_info[id->driver_data]); | 384 | return ide_pci_init_one(dev, &piix_pci_info[id->driver_data], NULL); |
398 | } | 385 | } |
399 | 386 | ||
400 | /** | 387 | /** |
@@ -421,39 +408,39 @@ static void __devinit piix_check_450nx(void) | |||
421 | no_piix_dma = 2; | 408 | no_piix_dma = 2; |
422 | } | 409 | } |
423 | if(no_piix_dma) | 410 | if(no_piix_dma) |
424 | printk(KERN_WARNING "piix: 450NX errata present, disabling IDE DMA.\n"); | 411 | printk(KERN_WARNING DRV_NAME ": 450NX errata present, disabling IDE DMA.\n"); |
425 | if(no_piix_dma == 2) | 412 | if(no_piix_dma == 2) |
426 | printk(KERN_WARNING "piix: A BIOS update may resolve this.\n"); | 413 | printk(KERN_WARNING DRV_NAME ": A BIOS update may resolve this.\n"); |
427 | } | 414 | } |
428 | 415 | ||
429 | static const struct pci_device_id piix_pci_tbl[] = { | 416 | static const struct pci_device_id piix_pci_tbl[] = { |
430 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_0), 0 }, | 417 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_0), 1 }, |
431 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_1), 1 }, | 418 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_1), 1 }, |
432 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), 2 }, | 419 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), 0 }, |
433 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371SB_1), 3 }, | 420 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371SB_1), 1 }, |
434 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371AB), 4 }, | 421 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371AB), 2 }, |
435 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AB_1), 5 }, | 422 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AB_1), 3 }, |
436 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82443MX_1), 6 }, | 423 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82443MX_1), 2 }, |
437 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AA_1), 7 }, | 424 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AA_1), 4 }, |
438 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82372FB_1), 8 }, | 425 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82372FB_1), 5 }, |
439 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82451NX), 9 }, | 426 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82451NX), 2 }, |
440 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_9), 10 }, | 427 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_9), 6 }, |
441 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_8), 11 }, | 428 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_8), 6 }, |
442 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_10), 12 }, | 429 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_10), 6 }, |
443 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_11), 13 }, | 430 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_11), 6 }, |
444 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_11), 14 }, | 431 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_11), 6 }, |
445 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_11), 15 }, | 432 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_11), 6 }, |
446 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801E_11), 16 }, | 433 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801E_11), 6 }, |
447 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_10), 17 }, | 434 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_10), 6 }, |
448 | #ifdef CONFIG_BLK_DEV_IDE_SATA | 435 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
449 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_1), 18 }, | 436 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_1), 6 }, |
450 | #endif | 437 | #endif |
451 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB_2), 19 }, | 438 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB_2), 6 }, |
452 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH6_19), 20 }, | 439 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH6_19), 6 }, |
453 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH7_21), 21 }, | 440 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH7_21), 6 }, |
454 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_1), 22 }, | 441 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_1), 6 }, |
455 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB2_18), 23 }, | 442 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB2_18), 6 }, |
456 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH8_6), 24 }, | 443 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH8_6), 6 }, |
457 | { 0, }, | 444 | { 0, }, |
458 | }; | 445 | }; |
459 | MODULE_DEVICE_TABLE(pci, piix_pci_tbl); | 446 | MODULE_DEVICE_TABLE(pci, piix_pci_tbl); |
@@ -462,6 +449,7 @@ static struct pci_driver driver = { | |||
462 | .name = "PIIX_IDE", | 449 | .name = "PIIX_IDE", |
463 | .id_table = piix_pci_tbl, | 450 | .id_table = piix_pci_tbl, |
464 | .probe = piix_init_one, | 451 | .probe = piix_init_one, |
452 | .remove = ide_pci_remove, | ||
465 | }; | 453 | }; |
466 | 454 | ||
467 | static int __init piix_ide_init(void) | 455 | static int __init piix_ide_init(void) |
@@ -470,7 +458,13 @@ static int __init piix_ide_init(void) | |||
470 | return ide_pci_register_driver(&driver); | 458 | return ide_pci_register_driver(&driver); |
471 | } | 459 | } |
472 | 460 | ||
461 | static void __exit piix_ide_exit(void) | ||
462 | { | ||
463 | pci_unregister_driver(&driver); | ||
464 | } | ||
465 | |||
473 | module_init(piix_ide_init); | 466 | module_init(piix_ide_init); |
467 | module_exit(piix_ide_exit); | ||
474 | 468 | ||
475 | MODULE_AUTHOR("Andre Hedrick, Andrzej Krzysztofowicz"); | 469 | MODULE_AUTHOR("Andre Hedrick, Andrzej Krzysztofowicz"); |
476 | MODULE_DESCRIPTION("PCI driver module for Intel PIIX IDE"); | 470 | MODULE_DESCRIPTION("PCI driver module for Intel PIIX IDE"); |
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c index 532154adba29..8d11ee838a2a 100644 --- a/drivers/ide/pci/rz1000.c +++ b/drivers/ide/pci/rz1000.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/ide.h> | 21 | #include <linux/ide.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | 23 | ||
24 | #define DRV_NAME "rz1000" | ||
25 | |||
24 | static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) | 26 | static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) |
25 | { | 27 | { |
26 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 28 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -40,7 +42,7 @@ static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) | |||
40 | } | 42 | } |
41 | 43 | ||
42 | static const struct ide_port_info rz1000_chipset __devinitdata = { | 44 | static const struct ide_port_info rz1000_chipset __devinitdata = { |
43 | .name = "RZ100x", | 45 | .name = DRV_NAME, |
44 | .init_hwif = init_hwif_rz1000, | 46 | .init_hwif = init_hwif_rz1000, |
45 | .chipset = ide_rz1000, | 47 | .chipset = ide_rz1000, |
46 | .host_flags = IDE_HFLAG_NO_DMA, | 48 | .host_flags = IDE_HFLAG_NO_DMA, |
@@ -48,7 +50,7 @@ static const struct ide_port_info rz1000_chipset __devinitdata = { | |||
48 | 50 | ||
49 | static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 51 | static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
50 | { | 52 | { |
51 | return ide_setup_pci_device(dev, &rz1000_chipset); | 53 | return ide_pci_init_one(dev, &rz1000_chipset, NULL); |
52 | } | 54 | } |
53 | 55 | ||
54 | static const struct pci_device_id rz1000_pci_tbl[] = { | 56 | static const struct pci_device_id rz1000_pci_tbl[] = { |
@@ -62,6 +64,7 @@ static struct pci_driver driver = { | |||
62 | .name = "RZ1000_IDE", | 64 | .name = "RZ1000_IDE", |
63 | .id_table = rz1000_pci_tbl, | 65 | .id_table = rz1000_pci_tbl, |
64 | .probe = rz1000_init_one, | 66 | .probe = rz1000_init_one, |
67 | .remove = ide_pci_remove, | ||
65 | }; | 68 | }; |
66 | 69 | ||
67 | static int __init rz1000_ide_init(void) | 70 | static int __init rz1000_ide_init(void) |
@@ -69,7 +72,13 @@ static int __init rz1000_ide_init(void) | |||
69 | return ide_pci_register_driver(&driver); | 72 | return ide_pci_register_driver(&driver); |
70 | } | 73 | } |
71 | 74 | ||
75 | static void __exit rz1000_ide_exit(void) | ||
76 | { | ||
77 | pci_unregister_driver(&driver); | ||
78 | } | ||
79 | |||
72 | module_init(rz1000_ide_init); | 80 | module_init(rz1000_ide_init); |
81 | module_exit(rz1000_ide_exit); | ||
73 | 82 | ||
74 | MODULE_AUTHOR("Andre Hedrick"); | 83 | MODULE_AUTHOR("Andre Hedrick"); |
75 | MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE"); | 84 | MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE"); |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 14c787b5d95f..8efaed16fea3 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -22,6 +22,8 @@ | |||
22 | 22 | ||
23 | #include <asm/io.h> | 23 | #include <asm/io.h> |
24 | 24 | ||
25 | #define DRV_NAME "sc1200" | ||
26 | |||
25 | #define SC1200_REV_A 0x00 | 27 | #define SC1200_REV_A 0x00 |
26 | #define SC1200_REV_B1 0x01 | 28 | #define SC1200_REV_B1 0x01 |
27 | #define SC1200_REV_B3 0x02 | 29 | #define SC1200_REV_B3 0x02 |
@@ -234,21 +236,11 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) | |||
234 | * we only save state when going from full power to less | 236 | * we only save state when going from full power to less |
235 | */ | 237 | */ |
236 | if (state.event == PM_EVENT_ON) { | 238 | if (state.event == PM_EVENT_ON) { |
237 | struct sc1200_saved_state *ss; | 239 | struct ide_host *host = pci_get_drvdata(dev); |
240 | struct sc1200_saved_state *ss = host->host_priv; | ||
238 | unsigned int r; | 241 | unsigned int r; |
239 | 242 | ||
240 | /* | 243 | /* |
241 | * allocate a permanent save area, if not already allocated | ||
242 | */ | ||
243 | ss = (struct sc1200_saved_state *)pci_get_drvdata(dev); | ||
244 | if (ss == NULL) { | ||
245 | ss = kmalloc(sizeof(*ss), GFP_KERNEL); | ||
246 | if (ss == NULL) | ||
247 | return -ENOMEM; | ||
248 | pci_set_drvdata(dev, ss); | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * save timing registers | 244 | * save timing registers |
253 | * (this may be unnecessary if BIOS also does it) | 245 | * (this may be unnecessary if BIOS also does it) |
254 | */ | 246 | */ |
@@ -263,7 +255,8 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) | |||
263 | 255 | ||
264 | static int sc1200_resume (struct pci_dev *dev) | 256 | static int sc1200_resume (struct pci_dev *dev) |
265 | { | 257 | { |
266 | struct sc1200_saved_state *ss; | 258 | struct ide_host *host = pci_get_drvdata(dev); |
259 | struct sc1200_saved_state *ss = host->host_priv; | ||
267 | unsigned int r; | 260 | unsigned int r; |
268 | int i; | 261 | int i; |
269 | 262 | ||
@@ -271,16 +264,12 @@ static int sc1200_resume (struct pci_dev *dev) | |||
271 | if (i) | 264 | if (i) |
272 | return i; | 265 | return i; |
273 | 266 | ||
274 | ss = (struct sc1200_saved_state *)pci_get_drvdata(dev); | ||
275 | |||
276 | /* | 267 | /* |
277 | * restore timing registers | 268 | * restore timing registers |
278 | * (this may be unnecessary if BIOS also does it) | 269 | * (this may be unnecessary if BIOS also does it) |
279 | */ | 270 | */ |
280 | if (ss) { | 271 | for (r = 0; r < 8; r++) |
281 | for (r = 0; r < 8; r++) | 272 | pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]); |
282 | pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]); | ||
283 | } | ||
284 | 273 | ||
285 | return 0; | 274 | return 0; |
286 | } | 275 | } |
@@ -304,7 +293,7 @@ static const struct ide_dma_ops sc1200_dma_ops = { | |||
304 | }; | 293 | }; |
305 | 294 | ||
306 | static const struct ide_port_info sc1200_chipset __devinitdata = { | 295 | static const struct ide_port_info sc1200_chipset __devinitdata = { |
307 | .name = "SC1200", | 296 | .name = DRV_NAME, |
308 | .port_ops = &sc1200_port_ops, | 297 | .port_ops = &sc1200_port_ops, |
309 | .dma_ops = &sc1200_dma_ops, | 298 | .dma_ops = &sc1200_dma_ops, |
310 | .host_flags = IDE_HFLAG_SERIALIZE | | 299 | .host_flags = IDE_HFLAG_SERIALIZE | |
@@ -317,7 +306,19 @@ static const struct ide_port_info sc1200_chipset __devinitdata = { | |||
317 | 306 | ||
318 | static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 307 | static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
319 | { | 308 | { |
320 | return ide_setup_pci_device(dev, &sc1200_chipset); | 309 | struct sc1200_saved_state *ss = NULL; |
310 | int rc; | ||
311 | |||
312 | #ifdef CONFIG_PM | ||
313 | ss = kmalloc(sizeof(*ss), GFP_KERNEL); | ||
314 | if (ss == NULL) | ||
315 | return -ENOMEM; | ||
316 | #endif | ||
317 | rc = ide_pci_init_one(dev, &sc1200_chipset, ss); | ||
318 | if (rc) | ||
319 | kfree(ss); | ||
320 | |||
321 | return rc; | ||
321 | } | 322 | } |
322 | 323 | ||
323 | static const struct pci_device_id sc1200_pci_tbl[] = { | 324 | static const struct pci_device_id sc1200_pci_tbl[] = { |
@@ -330,6 +331,7 @@ static struct pci_driver driver = { | |||
330 | .name = "SC1200_IDE", | 331 | .name = "SC1200_IDE", |
331 | .id_table = sc1200_pci_tbl, | 332 | .id_table = sc1200_pci_tbl, |
332 | .probe = sc1200_init_one, | 333 | .probe = sc1200_init_one, |
334 | .remove = ide_pci_remove, | ||
333 | #ifdef CONFIG_PM | 335 | #ifdef CONFIG_PM |
334 | .suspend = sc1200_suspend, | 336 | .suspend = sc1200_suspend, |
335 | .resume = sc1200_resume, | 337 | .resume = sc1200_resume, |
@@ -341,7 +343,13 @@ static int __init sc1200_ide_init(void) | |||
341 | return ide_pci_register_driver(&driver); | 343 | return ide_pci_register_driver(&driver); |
342 | } | 344 | } |
343 | 345 | ||
346 | static void __exit sc1200_ide_exit(void) | ||
347 | { | ||
348 | pci_unregister_driver(&driver); | ||
349 | } | ||
350 | |||
344 | module_init(sc1200_ide_init); | 351 | module_init(sc1200_ide_init); |
352 | module_exit(sc1200_ide_exit); | ||
345 | 353 | ||
346 | MODULE_AUTHOR("Mark Lord"); | 354 | MODULE_AUTHOR("Mark Lord"); |
347 | MODULE_DESCRIPTION("PCI driver module for NS SC1200 IDE"); | 355 | MODULE_DESCRIPTION("PCI driver module for NS SC1200 IDE"); |
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index 127ccb45e261..d173f2937722 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
@@ -38,6 +38,8 @@ | |||
38 | 38 | ||
39 | #include <asm/io.h> | 39 | #include <asm/io.h> |
40 | 40 | ||
41 | #define DRV_NAME "serverworks" | ||
42 | |||
41 | #define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */ | 43 | #define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */ |
42 | #define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */ | 44 | #define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */ |
43 | 45 | ||
@@ -172,7 +174,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
172 | pci_write_config_byte(dev, 0x54, ultra_enable); | 174 | pci_write_config_byte(dev, 0x54, ultra_enable); |
173 | } | 175 | } |
174 | 176 | ||
175 | static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const char *name) | 177 | static unsigned int __devinit init_chipset_svwks(struct pci_dev *dev) |
176 | { | 178 | { |
177 | unsigned int reg; | 179 | unsigned int reg; |
178 | u8 btr; | 180 | u8 btr; |
@@ -188,7 +190,8 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha | |||
188 | pci_read_config_dword(isa_dev, 0x64, ®); | 190 | pci_read_config_dword(isa_dev, 0x64, ®); |
189 | reg &= ~0x00002000; /* disable 600ns interrupt mask */ | 191 | reg &= ~0x00002000; /* disable 600ns interrupt mask */ |
190 | if(!(reg & 0x00004000)) | 192 | if(!(reg & 0x00004000)) |
191 | printk(KERN_DEBUG "%s: UDMA not BIOS enabled.\n", name); | 193 | printk(KERN_DEBUG DRV_NAME " %s: UDMA not BIOS " |
194 | "enabled.\n", pci_name(dev)); | ||
192 | reg |= 0x00004000; /* enable UDMA/33 support */ | 195 | reg |= 0x00004000; /* enable UDMA/33 support */ |
193 | pci_write_config_dword(isa_dev, 0x64, reg); | 196 | pci_write_config_dword(isa_dev, 0x64, reg); |
194 | } | 197 | } |
@@ -352,40 +355,44 @@ static const struct ide_port_ops svwks_port_ops = { | |||
352 | #define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS | 355 | #define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS |
353 | 356 | ||
354 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | 357 | static const struct ide_port_info serverworks_chipsets[] __devinitdata = { |
355 | { /* 0 */ | 358 | { /* 0: OSB4 */ |
356 | .name = "SvrWks OSB4", | 359 | .name = DRV_NAME, |
357 | .init_chipset = init_chipset_svwks, | 360 | .init_chipset = init_chipset_svwks, |
358 | .port_ops = &osb4_port_ops, | 361 | .port_ops = &osb4_port_ops, |
359 | .host_flags = IDE_HFLAGS_SVWKS, | 362 | .host_flags = IDE_HFLAGS_SVWKS, |
360 | .pio_mask = ATA_PIO4, | 363 | .pio_mask = ATA_PIO4, |
361 | .mwdma_mask = ATA_MWDMA2, | 364 | .mwdma_mask = ATA_MWDMA2, |
362 | .udma_mask = 0x00, /* UDMA is problematic on OSB4 */ | 365 | .udma_mask = 0x00, /* UDMA is problematic on OSB4 */ |
363 | },{ /* 1 */ | 366 | }, |
364 | .name = "SvrWks CSB5", | 367 | { /* 1: CSB5 */ |
368 | .name = DRV_NAME, | ||
365 | .init_chipset = init_chipset_svwks, | 369 | .init_chipset = init_chipset_svwks, |
366 | .port_ops = &svwks_port_ops, | 370 | .port_ops = &svwks_port_ops, |
367 | .host_flags = IDE_HFLAGS_SVWKS, | 371 | .host_flags = IDE_HFLAGS_SVWKS, |
368 | .pio_mask = ATA_PIO4, | 372 | .pio_mask = ATA_PIO4, |
369 | .mwdma_mask = ATA_MWDMA2, | 373 | .mwdma_mask = ATA_MWDMA2, |
370 | .udma_mask = ATA_UDMA5, | 374 | .udma_mask = ATA_UDMA5, |
371 | },{ /* 2 */ | 375 | }, |
372 | .name = "SvrWks CSB6", | 376 | { /* 2: CSB6 */ |
377 | .name = DRV_NAME, | ||
373 | .init_chipset = init_chipset_svwks, | 378 | .init_chipset = init_chipset_svwks, |
374 | .port_ops = &svwks_port_ops, | 379 | .port_ops = &svwks_port_ops, |
375 | .host_flags = IDE_HFLAGS_SVWKS, | 380 | .host_flags = IDE_HFLAGS_SVWKS, |
376 | .pio_mask = ATA_PIO4, | 381 | .pio_mask = ATA_PIO4, |
377 | .mwdma_mask = ATA_MWDMA2, | 382 | .mwdma_mask = ATA_MWDMA2, |
378 | .udma_mask = ATA_UDMA5, | 383 | .udma_mask = ATA_UDMA5, |
379 | },{ /* 3 */ | 384 | }, |
380 | .name = "SvrWks CSB6", | 385 | { /* 3: CSB6-2 */ |
386 | .name = DRV_NAME, | ||
381 | .init_chipset = init_chipset_svwks, | 387 | .init_chipset = init_chipset_svwks, |
382 | .port_ops = &svwks_port_ops, | 388 | .port_ops = &svwks_port_ops, |
383 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, | 389 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, |
384 | .pio_mask = ATA_PIO4, | 390 | .pio_mask = ATA_PIO4, |
385 | .mwdma_mask = ATA_MWDMA2, | 391 | .mwdma_mask = ATA_MWDMA2, |
386 | .udma_mask = ATA_UDMA5, | 392 | .udma_mask = ATA_UDMA5, |
387 | },{ /* 4 */ | 393 | }, |
388 | .name = "SvrWks HT1000", | 394 | { /* 4: HT1000 */ |
395 | .name = DRV_NAME, | ||
389 | .init_chipset = init_chipset_svwks, | 396 | .init_chipset = init_chipset_svwks, |
390 | .port_ops = &svwks_port_ops, | 397 | .port_ops = &svwks_port_ops, |
391 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, | 398 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, |
@@ -422,7 +429,7 @@ static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device | |||
422 | d.host_flags &= ~IDE_HFLAG_SINGLE; | 429 | d.host_flags &= ~IDE_HFLAG_SINGLE; |
423 | } | 430 | } |
424 | 431 | ||
425 | return ide_setup_pci_device(dev, &d); | 432 | return ide_pci_init_one(dev, &d, NULL); |
426 | } | 433 | } |
427 | 434 | ||
428 | static const struct pci_device_id svwks_pci_tbl[] = { | 435 | static const struct pci_device_id svwks_pci_tbl[] = { |
@@ -439,6 +446,7 @@ static struct pci_driver driver = { | |||
439 | .name = "Serverworks_IDE", | 446 | .name = "Serverworks_IDE", |
440 | .id_table = svwks_pci_tbl, | 447 | .id_table = svwks_pci_tbl, |
441 | .probe = svwks_init_one, | 448 | .probe = svwks_init_one, |
449 | .remove = ide_pci_remove, | ||
442 | }; | 450 | }; |
443 | 451 | ||
444 | static int __init svwks_ide_init(void) | 452 | static int __init svwks_ide_init(void) |
@@ -446,7 +454,13 @@ static int __init svwks_ide_init(void) | |||
446 | return ide_pci_register_driver(&driver); | 454 | return ide_pci_register_driver(&driver); |
447 | } | 455 | } |
448 | 456 | ||
457 | static void __exit svwks_ide_exit(void) | ||
458 | { | ||
459 | pci_unregister_driver(&driver); | ||
460 | } | ||
461 | |||
449 | module_init(svwks_ide_init); | 462 | module_init(svwks_ide_init); |
463 | module_exit(svwks_ide_exit); | ||
450 | 464 | ||
451 | MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick"); | 465 | MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick"); |
452 | MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE"); | 466 | MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE"); |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 5965a35d94ae..b8ad9ad6cf0d 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -44,6 +44,8 @@ | |||
44 | #include <linux/init.h> | 44 | #include <linux/init.h> |
45 | #include <linux/io.h> | 45 | #include <linux/io.h> |
46 | 46 | ||
47 | #define DRV_NAME "siimage" | ||
48 | |||
47 | /** | 49 | /** |
48 | * pdev_is_sata - check if device is SATA | 50 | * pdev_is_sata - check if device is SATA |
49 | * @pdev: PCI device to check | 51 | * @pdev: PCI device to check |
@@ -127,9 +129,10 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r) | |||
127 | 129 | ||
128 | static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr) | 130 | static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr) |
129 | { | 131 | { |
132 | struct ide_host *host = pci_get_drvdata(dev); | ||
130 | u8 tmp = 0; | 133 | u8 tmp = 0; |
131 | 134 | ||
132 | if (pci_get_drvdata(dev)) | 135 | if (host->host_priv) |
133 | tmp = readb((void __iomem *)addr); | 136 | tmp = readb((void __iomem *)addr); |
134 | else | 137 | else |
135 | pci_read_config_byte(dev, addr, &tmp); | 138 | pci_read_config_byte(dev, addr, &tmp); |
@@ -139,9 +142,10 @@ static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr) | |||
139 | 142 | ||
140 | static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr) | 143 | static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr) |
141 | { | 144 | { |
145 | struct ide_host *host = pci_get_drvdata(dev); | ||
142 | u16 tmp = 0; | 146 | u16 tmp = 0; |
143 | 147 | ||
144 | if (pci_get_drvdata(dev)) | 148 | if (host->host_priv) |
145 | tmp = readw((void __iomem *)addr); | 149 | tmp = readw((void __iomem *)addr); |
146 | else | 150 | else |
147 | pci_read_config_word(dev, addr, &tmp); | 151 | pci_read_config_word(dev, addr, &tmp); |
@@ -151,7 +155,9 @@ static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr) | |||
151 | 155 | ||
152 | static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr) | 156 | static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr) |
153 | { | 157 | { |
154 | if (pci_get_drvdata(dev)) | 158 | struct ide_host *host = pci_get_drvdata(dev); |
159 | |||
160 | if (host->host_priv) | ||
155 | writeb(val, (void __iomem *)addr); | 161 | writeb(val, (void __iomem *)addr); |
156 | else | 162 | else |
157 | pci_write_config_byte(dev, addr, val); | 163 | pci_write_config_byte(dev, addr, val); |
@@ -159,7 +165,9 @@ static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr) | |||
159 | 165 | ||
160 | static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr) | 166 | static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr) |
161 | { | 167 | { |
162 | if (pci_get_drvdata(dev)) | 168 | struct ide_host *host = pci_get_drvdata(dev); |
169 | |||
170 | if (host->host_priv) | ||
163 | writew(val, (void __iomem *)addr); | 171 | writew(val, (void __iomem *)addr); |
164 | else | 172 | else |
165 | pci_write_config_word(dev, addr, val); | 173 | pci_write_config_word(dev, addr, val); |
@@ -167,7 +175,9 @@ static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr) | |||
167 | 175 | ||
168 | static void sil_iowrite32(struct pci_dev *dev, u32 val, unsigned long addr) | 176 | static void sil_iowrite32(struct pci_dev *dev, u32 val, unsigned long addr) |
169 | { | 177 | { |
170 | if (pci_get_drvdata(dev)) | 178 | struct ide_host *host = pci_get_drvdata(dev); |
179 | |||
180 | if (host->host_priv) | ||
171 | writel(val, (void __iomem *)addr); | 181 | writel(val, (void __iomem *)addr); |
172 | else | 182 | else |
173 | pci_write_config_dword(dev, addr, val); | 183 | pci_write_config_dword(dev, addr, val); |
@@ -445,66 +455,24 @@ static void sil_sata_pre_reset(ide_drive_t *drive) | |||
445 | } | 455 | } |
446 | 456 | ||
447 | /** | 457 | /** |
448 | * setup_mmio_siimage - switch controller into MMIO mode | ||
449 | * @dev: PCI device we are configuring | ||
450 | * @name: device name | ||
451 | * | ||
452 | * Attempt to put the device into MMIO mode. There are some slight | ||
453 | * complications here with certain systems where the MMIO BAR isn't | ||
454 | * mapped, so we have to be sure that we can fall back to I/O. | ||
455 | */ | ||
456 | |||
457 | static unsigned int setup_mmio_siimage(struct pci_dev *dev, const char *name) | ||
458 | { | ||
459 | resource_size_t bar5 = pci_resource_start(dev, 5); | ||
460 | unsigned long barsize = pci_resource_len(dev, 5); | ||
461 | void __iomem *ioaddr; | ||
462 | |||
463 | /* | ||
464 | * Drop back to PIO if we can't map the MMIO. Some systems | ||
465 | * seem to get terminally confused in the PCI spaces. | ||
466 | */ | ||
467 | if (!request_mem_region(bar5, barsize, name)) { | ||
468 | printk(KERN_WARNING "siimage: IDE controller MMIO ports not " | ||
469 | "available.\n"); | ||
470 | return 0; | ||
471 | } | ||
472 | |||
473 | ioaddr = ioremap(bar5, barsize); | ||
474 | if (ioaddr == NULL) { | ||
475 | release_mem_region(bar5, barsize); | ||
476 | return 0; | ||
477 | } | ||
478 | |||
479 | pci_set_master(dev); | ||
480 | pci_set_drvdata(dev, (void *) ioaddr); | ||
481 | |||
482 | return 1; | ||
483 | } | ||
484 | |||
485 | /** | ||
486 | * init_chipset_siimage - set up an SI device | 458 | * init_chipset_siimage - set up an SI device |
487 | * @dev: PCI device | 459 | * @dev: PCI device |
488 | * @name: device name | ||
489 | * | 460 | * |
490 | * Perform the initial PCI set up for this device. Attempt to switch | 461 | * Perform the initial PCI set up for this device. Attempt to switch |
491 | * to 133 MHz clocking if the system isn't already set up to do it. | 462 | * to 133 MHz clocking if the system isn't already set up to do it. |
492 | */ | 463 | */ |
493 | 464 | ||
494 | static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, | 465 | static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev) |
495 | const char *name) | ||
496 | { | 466 | { |
467 | struct ide_host *host = pci_get_drvdata(dev); | ||
468 | void __iomem *ioaddr = host->host_priv; | ||
497 | unsigned long base, scsc_addr; | 469 | unsigned long base, scsc_addr; |
498 | void __iomem *ioaddr = NULL; | 470 | u8 rev = dev->revision, tmp; |
499 | u8 rev = dev->revision, tmp, BA5_EN; | ||
500 | 471 | ||
501 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, rev ? 1 : 255); | 472 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, rev ? 1 : 255); |
502 | 473 | ||
503 | pci_read_config_byte(dev, 0x8A, &BA5_EN); | 474 | if (ioaddr) |
504 | 475 | pci_set_master(dev); | |
505 | if ((BA5_EN & 0x01) || pci_resource_start(dev, 5)) | ||
506 | if (setup_mmio_siimage(dev, name)) | ||
507 | ioaddr = pci_get_drvdata(dev); | ||
508 | 476 | ||
509 | base = (unsigned long)ioaddr; | 477 | base = (unsigned long)ioaddr; |
510 | 478 | ||
@@ -571,7 +539,8 @@ static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, | |||
571 | { "== 100", "== 133", "== 2X PCI", "DISABLED!" }; | 539 | { "== 100", "== 133", "== 2X PCI", "DISABLED!" }; |
572 | 540 | ||
573 | tmp >>= 4; | 541 | tmp >>= 4; |
574 | printk(KERN_INFO "%s: BASE CLOCK %s\n", name, clk_str[tmp & 3]); | 542 | printk(KERN_INFO DRV_NAME " %s: BASE CLOCK %s\n", |
543 | pci_name(dev), clk_str[tmp & 3]); | ||
575 | } | 544 | } |
576 | 545 | ||
577 | return 0; | 546 | return 0; |
@@ -592,7 +561,8 @@ static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, | |||
592 | static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | 561 | static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) |
593 | { | 562 | { |
594 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 563 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
595 | void *addr = pci_get_drvdata(dev); | 564 | struct ide_host *host = pci_get_drvdata(dev); |
565 | void *addr = host->host_priv; | ||
596 | u8 ch = hwif->channel; | 566 | u8 ch = hwif->channel; |
597 | struct ide_io_ports *io_ports = &hwif->io_ports; | 567 | struct ide_io_ports *io_ports = &hwif->io_ports; |
598 | unsigned long base; | 568 | unsigned long base; |
@@ -691,16 +661,15 @@ static void __devinit sil_quirkproc(ide_drive_t *drive) | |||
691 | static void __devinit init_iops_siimage(ide_hwif_t *hwif) | 661 | static void __devinit init_iops_siimage(ide_hwif_t *hwif) |
692 | { | 662 | { |
693 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 663 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
664 | struct ide_host *host = pci_get_drvdata(dev); | ||
694 | 665 | ||
695 | hwif->hwif_data = NULL; | 666 | hwif->hwif_data = NULL; |
696 | 667 | ||
697 | /* Pessimal until we finish probing */ | 668 | /* Pessimal until we finish probing */ |
698 | hwif->rqsize = 15; | 669 | hwif->rqsize = 15; |
699 | 670 | ||
700 | if (pci_get_drvdata(dev) == NULL) | 671 | if (host->host_priv) |
701 | return; | 672 | init_mmio_iops_siimage(hwif); |
702 | |||
703 | init_mmio_iops_siimage(hwif); | ||
704 | } | 673 | } |
705 | 674 | ||
706 | /** | 675 | /** |
@@ -748,9 +717,9 @@ static const struct ide_dma_ops sil_dma_ops = { | |||
748 | .dma_lost_irq = ide_dma_lost_irq, | 717 | .dma_lost_irq = ide_dma_lost_irq, |
749 | }; | 718 | }; |
750 | 719 | ||
751 | #define DECLARE_SII_DEV(name_str, p_ops) \ | 720 | #define DECLARE_SII_DEV(p_ops) \ |
752 | { \ | 721 | { \ |
753 | .name = name_str, \ | 722 | .name = DRV_NAME, \ |
754 | .init_chipset = init_chipset_siimage, \ | 723 | .init_chipset = init_chipset_siimage, \ |
755 | .init_iops = init_iops_siimage, \ | 724 | .init_iops = init_iops_siimage, \ |
756 | .port_ops = p_ops, \ | 725 | .port_ops = p_ops, \ |
@@ -761,9 +730,8 @@ static const struct ide_dma_ops sil_dma_ops = { | |||
761 | } | 730 | } |
762 | 731 | ||
763 | static const struct ide_port_info siimage_chipsets[] __devinitdata = { | 732 | static const struct ide_port_info siimage_chipsets[] __devinitdata = { |
764 | /* 0 */ DECLARE_SII_DEV("SiI680", &sil_pata_port_ops), | 733 | /* 0: SiI680 */ DECLARE_SII_DEV(&sil_pata_port_ops), |
765 | /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA", &sil_sata_port_ops), | 734 | /* 1: SiI3112 */ DECLARE_SII_DEV(&sil_sata_port_ops) |
766 | /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA", &sil_sata_port_ops) | ||
767 | }; | 735 | }; |
768 | 736 | ||
769 | /** | 737 | /** |
@@ -778,8 +746,13 @@ static const struct ide_port_info siimage_chipsets[] __devinitdata = { | |||
778 | static int __devinit siimage_init_one(struct pci_dev *dev, | 746 | static int __devinit siimage_init_one(struct pci_dev *dev, |
779 | const struct pci_device_id *id) | 747 | const struct pci_device_id *id) |
780 | { | 748 | { |
749 | void __iomem *ioaddr = NULL; | ||
750 | resource_size_t bar5 = pci_resource_start(dev, 5); | ||
751 | unsigned long barsize = pci_resource_len(dev, 5); | ||
752 | int rc; | ||
781 | struct ide_port_info d; | 753 | struct ide_port_info d; |
782 | u8 idx = id->driver_data; | 754 | u8 idx = id->driver_data; |
755 | u8 BA5_EN; | ||
783 | 756 | ||
784 | d = siimage_chipsets[idx]; | 757 | d = siimage_chipsets[idx]; |
785 | 758 | ||
@@ -787,7 +760,7 @@ static int __devinit siimage_init_one(struct pci_dev *dev, | |||
787 | static int first = 1; | 760 | static int first = 1; |
788 | 761 | ||
789 | if (first) { | 762 | if (first) { |
790 | printk(KERN_INFO "siimage: For full SATA support you " | 763 | printk(KERN_INFO DRV_NAME ": For full SATA support you " |
791 | "should use the libata sata_sil module.\n"); | 764 | "should use the libata sata_sil module.\n"); |
792 | first = 0; | 765 | first = 0; |
793 | } | 766 | } |
@@ -795,14 +768,61 @@ static int __devinit siimage_init_one(struct pci_dev *dev, | |||
795 | d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 768 | d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |
796 | } | 769 | } |
797 | 770 | ||
798 | return ide_setup_pci_device(dev, &d); | 771 | rc = pci_enable_device(dev); |
772 | if (rc) | ||
773 | return rc; | ||
774 | |||
775 | pci_read_config_byte(dev, 0x8A, &BA5_EN); | ||
776 | if ((BA5_EN & 0x01) || bar5) { | ||
777 | /* | ||
778 | * Drop back to PIO if we can't map the MMIO. Some systems | ||
779 | * seem to get terminally confused in the PCI spaces. | ||
780 | */ | ||
781 | if (!request_mem_region(bar5, barsize, d.name)) { | ||
782 | printk(KERN_WARNING DRV_NAME " %s: MMIO ports not " | ||
783 | "available\n", pci_name(dev)); | ||
784 | } else { | ||
785 | ioaddr = ioremap(bar5, barsize); | ||
786 | if (ioaddr == NULL) | ||
787 | release_mem_region(bar5, barsize); | ||
788 | } | ||
789 | } | ||
790 | |||
791 | rc = ide_pci_init_one(dev, &d, ioaddr); | ||
792 | if (rc) { | ||
793 | if (ioaddr) { | ||
794 | iounmap(ioaddr); | ||
795 | release_mem_region(bar5, barsize); | ||
796 | } | ||
797 | pci_disable_device(dev); | ||
798 | } | ||
799 | |||
800 | return rc; | ||
801 | } | ||
802 | |||
803 | static void __devexit siimage_remove(struct pci_dev *dev) | ||
804 | { | ||
805 | struct ide_host *host = pci_get_drvdata(dev); | ||
806 | void __iomem *ioaddr = host->host_priv; | ||
807 | |||
808 | ide_pci_remove(dev); | ||
809 | |||
810 | if (ioaddr) { | ||
811 | resource_size_t bar5 = pci_resource_start(dev, 5); | ||
812 | unsigned long barsize = pci_resource_len(dev, 5); | ||
813 | |||
814 | iounmap(ioaddr); | ||
815 | release_mem_region(bar5, barsize); | ||
816 | } | ||
817 | |||
818 | pci_disable_device(dev); | ||
799 | } | 819 | } |
800 | 820 | ||
801 | static const struct pci_device_id siimage_pci_tbl[] = { | 821 | static const struct pci_device_id siimage_pci_tbl[] = { |
802 | { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), 0 }, | 822 | { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), 0 }, |
803 | #ifdef CONFIG_BLK_DEV_IDE_SATA | 823 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
804 | { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_3112), 1 }, | 824 | { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_3112), 1 }, |
805 | { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_1210SA), 2 }, | 825 | { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_1210SA), 1 }, |
806 | #endif | 826 | #endif |
807 | { 0, }, | 827 | { 0, }, |
808 | }; | 828 | }; |
@@ -812,6 +832,7 @@ static struct pci_driver driver = { | |||
812 | .name = "SiI_IDE", | 832 | .name = "SiI_IDE", |
813 | .id_table = siimage_pci_tbl, | 833 | .id_table = siimage_pci_tbl, |
814 | .probe = siimage_init_one, | 834 | .probe = siimage_init_one, |
835 | .remove = siimage_remove, | ||
815 | }; | 836 | }; |
816 | 837 | ||
817 | static int __init siimage_ide_init(void) | 838 | static int __init siimage_ide_init(void) |
@@ -819,7 +840,13 @@ static int __init siimage_ide_init(void) | |||
819 | return ide_pci_register_driver(&driver); | 840 | return ide_pci_register_driver(&driver); |
820 | } | 841 | } |
821 | 842 | ||
843 | static void __exit siimage_ide_exit(void) | ||
844 | { | ||
845 | pci_unregister_driver(&driver); | ||
846 | } | ||
847 | |||
822 | module_init(siimage_ide_init); | 848 | module_init(siimage_ide_init); |
849 | module_exit(siimage_ide_exit); | ||
823 | 850 | ||
824 | MODULE_AUTHOR("Andre Hedrick, Alan Cox"); | 851 | MODULE_AUTHOR("Andre Hedrick, Alan Cox"); |
825 | MODULE_DESCRIPTION("PCI driver module for SiI IDE"); | 852 | MODULE_DESCRIPTION("PCI driver module for SiI IDE"); |
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 2389945ca95d..cc95f90b53b7 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
@@ -52,6 +52,8 @@ | |||
52 | #include <linux/init.h> | 52 | #include <linux/init.h> |
53 | #include <linux/ide.h> | 53 | #include <linux/ide.h> |
54 | 54 | ||
55 | #define DRV_NAME "sis5513" | ||
56 | |||
55 | /* registers layout and init values are chipset family dependant */ | 57 | /* registers layout and init values are chipset family dependant */ |
56 | 58 | ||
57 | #define ATA_16 0x01 | 59 | #define ATA_16 0x01 |
@@ -380,8 +382,9 @@ static int __devinit sis_find_family(struct pci_dev *dev) | |||
380 | } | 382 | } |
381 | pci_dev_put(host); | 383 | pci_dev_put(host); |
382 | 384 | ||
383 | printk(KERN_INFO "SIS5513: %s %s controller\n", | 385 | printk(KERN_INFO DRV_NAME " %s: %s %s controller\n", |
384 | SiSHostChipInfo[i].name, chipset_capability[chipset_family]); | 386 | pci_name(dev), SiSHostChipInfo[i].name, |
387 | chipset_capability[chipset_family]); | ||
385 | } | 388 | } |
386 | 389 | ||
387 | if (!chipset_family) { /* Belongs to pci-quirks */ | 390 | if (!chipset_family) { /* Belongs to pci-quirks */ |
@@ -396,7 +399,8 @@ static int __devinit sis_find_family(struct pci_dev *dev) | |||
396 | pci_write_config_dword(dev, 0x54, idemisc); | 399 | pci_write_config_dword(dev, 0x54, idemisc); |
397 | 400 | ||
398 | if (trueid == 0x5518) { | 401 | if (trueid == 0x5518) { |
399 | printk(KERN_INFO "SIS5513: SiS 962/963 MuTIOL IDE UDMA133 controller\n"); | 402 | printk(KERN_INFO DRV_NAME " %s: SiS 962/963 MuTIOL IDE UDMA133 controller\n", |
403 | pci_name(dev)); | ||
400 | chipset_family = ATA_133; | 404 | chipset_family = ATA_133; |
401 | 405 | ||
402 | /* Check for 5513 compability mapping | 406 | /* Check for 5513 compability mapping |
@@ -405,7 +409,8 @@ static int __devinit sis_find_family(struct pci_dev *dev) | |||
405 | */ | 409 | */ |
406 | if ((idemisc & 0x40000000) == 0) { | 410 | if ((idemisc & 0x40000000) == 0) { |
407 | pci_write_config_dword(dev, 0x54, idemisc | 0x40000000); | 411 | pci_write_config_dword(dev, 0x54, idemisc | 0x40000000); |
408 | printk(KERN_INFO "SIS5513: Switching to 5513 register mapping\n"); | 412 | printk(KERN_INFO DRV_NAME " %s: Switching to 5513 register mapping\n", |
413 | pci_name(dev)); | ||
409 | } | 414 | } |
410 | } | 415 | } |
411 | } | 416 | } |
@@ -429,10 +434,12 @@ static int __devinit sis_find_family(struct pci_dev *dev) | |||
429 | pci_dev_put(lpc_bridge); | 434 | pci_dev_put(lpc_bridge); |
430 | 435 | ||
431 | if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) { | 436 | if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) { |
432 | printk(KERN_INFO "SIS5513: SiS 961B MuTIOL IDE UDMA133 controller\n"); | 437 | printk(KERN_INFO DRV_NAME " %s: SiS 961B MuTIOL IDE UDMA133 controller\n", |
438 | pci_name(dev)); | ||
433 | chipset_family = ATA_133a; | 439 | chipset_family = ATA_133a; |
434 | } else { | 440 | } else { |
435 | printk(KERN_INFO "SIS5513: SiS 961 MuTIOL IDE UDMA100 controller\n"); | 441 | printk(KERN_INFO DRV_NAME " %s: SiS 961 MuTIOL IDE UDMA100 controller\n", |
442 | pci_name(dev)); | ||
436 | chipset_family = ATA_100; | 443 | chipset_family = ATA_100; |
437 | } | 444 | } |
438 | } | 445 | } |
@@ -441,8 +448,7 @@ static int __devinit sis_find_family(struct pci_dev *dev) | |||
441 | return chipset_family; | 448 | return chipset_family; |
442 | } | 449 | } |
443 | 450 | ||
444 | static unsigned int __devinit init_chipset_sis5513(struct pci_dev *dev, | 451 | static unsigned int __devinit init_chipset_sis5513(struct pci_dev *dev) |
445 | const char *name) | ||
446 | { | 452 | { |
447 | /* Make general config ops here | 453 | /* Make general config ops here |
448 | 1/ tell IDE channels to operate in Compatibility mode only | 454 | 1/ tell IDE channels to operate in Compatibility mode only |
@@ -555,7 +561,7 @@ static const struct ide_port_ops sis_ata133_port_ops = { | |||
555 | }; | 561 | }; |
556 | 562 | ||
557 | static const struct ide_port_info sis5513_chipset __devinitdata = { | 563 | static const struct ide_port_info sis5513_chipset __devinitdata = { |
558 | .name = "SIS5513", | 564 | .name = DRV_NAME, |
559 | .init_chipset = init_chipset_sis5513, | 565 | .init_chipset = init_chipset_sis5513, |
560 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, | 566 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, |
561 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, | 567 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, |
@@ -583,7 +589,13 @@ static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_devi | |||
583 | 589 | ||
584 | d.udma_mask = udma_rates[chipset_family]; | 590 | d.udma_mask = udma_rates[chipset_family]; |
585 | 591 | ||
586 | return ide_setup_pci_device(dev, &d); | 592 | return ide_pci_init_one(dev, &d, NULL); |
593 | } | ||
594 | |||
595 | static void __devexit sis5513_remove(struct pci_dev *dev) | ||
596 | { | ||
597 | ide_pci_remove(dev); | ||
598 | pci_disable_device(dev); | ||
587 | } | 599 | } |
588 | 600 | ||
589 | static const struct pci_device_id sis5513_pci_tbl[] = { | 601 | static const struct pci_device_id sis5513_pci_tbl[] = { |
@@ -598,6 +610,7 @@ static struct pci_driver driver = { | |||
598 | .name = "SIS_IDE", | 610 | .name = "SIS_IDE", |
599 | .id_table = sis5513_pci_tbl, | 611 | .id_table = sis5513_pci_tbl, |
600 | .probe = sis5513_init_one, | 612 | .probe = sis5513_init_one, |
613 | .remove = sis5513_remove, | ||
601 | }; | 614 | }; |
602 | 615 | ||
603 | static int __init sis5513_ide_init(void) | 616 | static int __init sis5513_ide_init(void) |
@@ -605,7 +618,13 @@ static int __init sis5513_ide_init(void) | |||
605 | return ide_pci_register_driver(&driver); | 618 | return ide_pci_register_driver(&driver); |
606 | } | 619 | } |
607 | 620 | ||
621 | static void __exit sis5513_ide_exit(void) | ||
622 | { | ||
623 | pci_unregister_driver(&driver); | ||
624 | } | ||
625 | |||
608 | module_init(sis5513_ide_init); | 626 | module_init(sis5513_ide_init); |
627 | module_exit(sis5513_ide_exit); | ||
609 | 628 | ||
610 | MODULE_AUTHOR("Lionel Bouton, L C Chang, Andre Hedrick, Vojtech Pavlik"); | 629 | MODULE_AUTHOR("Lionel Bouton, L C Chang, Andre Hedrick, Vojtech Pavlik"); |
611 | MODULE_DESCRIPTION("PCI driver module for SIS IDE"); | 630 | MODULE_DESCRIPTION("PCI driver module for SIS IDE"); |
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index f82a6502c1b7..73905bcc08fb 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
@@ -23,6 +23,8 @@ | |||
23 | 23 | ||
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | 25 | ||
26 | #define DRV_NAME "sl82c105" | ||
27 | |||
26 | #undef DEBUG | 28 | #undef DEBUG |
27 | 29 | ||
28 | #ifdef DEBUG | 30 | #ifdef DEBUG |
@@ -270,7 +272,7 @@ static u8 sl82c105_bridge_revision(struct pci_dev *dev) | |||
270 | * channel 0 here at least, but channel 1 has to be enabled by | 272 | * channel 0 here at least, but channel 1 has to be enabled by |
271 | * firmware or arch code. We still set both to 16 bits mode. | 273 | * firmware or arch code. We still set both to 16 bits mode. |
272 | */ | 274 | */ |
273 | static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const char *msg) | 275 | static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev) |
274 | { | 276 | { |
275 | u32 val; | 277 | u32 val; |
276 | 278 | ||
@@ -301,7 +303,7 @@ static const struct ide_dma_ops sl82c105_dma_ops = { | |||
301 | }; | 303 | }; |
302 | 304 | ||
303 | static const struct ide_port_info sl82c105_chipset __devinitdata = { | 305 | static const struct ide_port_info sl82c105_chipset __devinitdata = { |
304 | .name = "W82C105", | 306 | .name = DRV_NAME, |
305 | .init_chipset = init_chipset_sl82c105, | 307 | .init_chipset = init_chipset_sl82c105, |
306 | .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, | 308 | .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, |
307 | .port_ops = &sl82c105_port_ops, | 309 | .port_ops = &sl82c105_port_ops, |
@@ -328,14 +330,14 @@ static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_dev | |||
328 | * Never ever EVER under any circumstances enable | 330 | * Never ever EVER under any circumstances enable |
329 | * DMA when the bridge is this old. | 331 | * DMA when the bridge is this old. |
330 | */ | 332 | */ |
331 | printk(KERN_INFO "W82C105_IDE: Winbond W83C553 bridge " | 333 | printk(KERN_INFO DRV_NAME ": Winbond W83C553 bridge " |
332 | "revision %d, BM-DMA disabled\n", rev); | 334 | "revision %d, BM-DMA disabled\n", rev); |
333 | d.dma_ops = NULL; | 335 | d.dma_ops = NULL; |
334 | d.mwdma_mask = 0; | 336 | d.mwdma_mask = 0; |
335 | d.host_flags &= ~IDE_HFLAG_SERIALIZE_DMA; | 337 | d.host_flags &= ~IDE_HFLAG_SERIALIZE_DMA; |
336 | } | 338 | } |
337 | 339 | ||
338 | return ide_setup_pci_device(dev, &d); | 340 | return ide_pci_init_one(dev, &d, NULL); |
339 | } | 341 | } |
340 | 342 | ||
341 | static const struct pci_device_id sl82c105_pci_tbl[] = { | 343 | static const struct pci_device_id sl82c105_pci_tbl[] = { |
@@ -348,6 +350,7 @@ static struct pci_driver driver = { | |||
348 | .name = "W82C105_IDE", | 350 | .name = "W82C105_IDE", |
349 | .id_table = sl82c105_pci_tbl, | 351 | .id_table = sl82c105_pci_tbl, |
350 | .probe = sl82c105_init_one, | 352 | .probe = sl82c105_init_one, |
353 | .remove = ide_pci_remove, | ||
351 | }; | 354 | }; |
352 | 355 | ||
353 | static int __init sl82c105_ide_init(void) | 356 | static int __init sl82c105_ide_init(void) |
@@ -355,7 +358,13 @@ static int __init sl82c105_ide_init(void) | |||
355 | return ide_pci_register_driver(&driver); | 358 | return ide_pci_register_driver(&driver); |
356 | } | 359 | } |
357 | 360 | ||
361 | static void __exit sl82c105_ide_exit(void) | ||
362 | { | ||
363 | pci_unregister_driver(&driver); | ||
364 | } | ||
365 | |||
358 | module_init(sl82c105_ide_init); | 366 | module_init(sl82c105_ide_init); |
367 | module_exit(sl82c105_ide_exit); | ||
359 | 368 | ||
360 | MODULE_DESCRIPTION("PCI driver module for W82C105 IDE"); | 369 | MODULE_DESCRIPTION("PCI driver module for W82C105 IDE"); |
361 | MODULE_LICENSE("GPL"); | 370 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index dae6e2c94d86..13d1fa491f26 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c | |||
@@ -15,6 +15,8 @@ | |||
15 | #include <linux/ide.h> | 15 | #include <linux/ide.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | 17 | ||
18 | #define DRV_NAME "slc90e66" | ||
19 | |||
18 | static DEFINE_SPINLOCK(slc90e66_lock); | 20 | static DEFINE_SPINLOCK(slc90e66_lock); |
19 | 21 | ||
20 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | 22 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) |
@@ -132,7 +134,7 @@ static const struct ide_port_ops slc90e66_port_ops = { | |||
132 | }; | 134 | }; |
133 | 135 | ||
134 | static const struct ide_port_info slc90e66_chipset __devinitdata = { | 136 | static const struct ide_port_info slc90e66_chipset __devinitdata = { |
135 | .name = "SLC90E66", | 137 | .name = DRV_NAME, |
136 | .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, | 138 | .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, |
137 | .port_ops = &slc90e66_port_ops, | 139 | .port_ops = &slc90e66_port_ops, |
138 | .host_flags = IDE_HFLAG_LEGACY_IRQS, | 140 | .host_flags = IDE_HFLAG_LEGACY_IRQS, |
@@ -144,7 +146,7 @@ static const struct ide_port_info slc90e66_chipset __devinitdata = { | |||
144 | 146 | ||
145 | static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 147 | static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
146 | { | 148 | { |
147 | return ide_setup_pci_device(dev, &slc90e66_chipset); | 149 | return ide_pci_init_one(dev, &slc90e66_chipset, NULL); |
148 | } | 150 | } |
149 | 151 | ||
150 | static const struct pci_device_id slc90e66_pci_tbl[] = { | 152 | static const struct pci_device_id slc90e66_pci_tbl[] = { |
@@ -157,6 +159,7 @@ static struct pci_driver driver = { | |||
157 | .name = "SLC90e66_IDE", | 159 | .name = "SLC90e66_IDE", |
158 | .id_table = slc90e66_pci_tbl, | 160 | .id_table = slc90e66_pci_tbl, |
159 | .probe = slc90e66_init_one, | 161 | .probe = slc90e66_init_one, |
162 | .remove = ide_pci_remove, | ||
160 | }; | 163 | }; |
161 | 164 | ||
162 | static int __init slc90e66_ide_init(void) | 165 | static int __init slc90e66_ide_init(void) |
@@ -164,7 +167,13 @@ static int __init slc90e66_ide_init(void) | |||
164 | return ide_pci_register_driver(&driver); | 167 | return ide_pci_register_driver(&driver); |
165 | } | 168 | } |
166 | 169 | ||
170 | static void __exit slc90e66_ide_exit(void) | ||
171 | { | ||
172 | pci_unregister_driver(&driver); | ||
173 | } | ||
174 | |||
167 | module_init(slc90e66_ide_init); | 175 | module_init(slc90e66_ide_init); |
176 | module_exit(slc90e66_ide_exit); | ||
168 | 177 | ||
169 | MODULE_AUTHOR("Andre Hedrick"); | 178 | MODULE_AUTHOR("Andre Hedrick"); |
170 | MODULE_DESCRIPTION("PCI driver module for SLC90E66 IDE"); | 179 | MODULE_DESCRIPTION("PCI driver module for SLC90E66 IDE"); |
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index 477e19790102..b1cb8a9ce5a9 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c | |||
@@ -11,6 +11,8 @@ | |||
11 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
12 | #include <linux/ide.h> | 12 | #include <linux/ide.h> |
13 | 13 | ||
14 | #define DRV_NAME "tc86c001" | ||
15 | |||
14 | static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed) | 16 | static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed) |
15 | { | 17 | { |
16 | ide_hwif_t *hwif = HWIF(drive); | 18 | ide_hwif_t *hwif = HWIF(drive); |
@@ -173,16 +175,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | |||
173 | hwif->rqsize = 0xffff; | 175 | hwif->rqsize = 0xffff; |
174 | } | 176 | } |
175 | 177 | ||
176 | static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, | ||
177 | const char *name) | ||
178 | { | ||
179 | int err = pci_request_region(dev, 5, name); | ||
180 | |||
181 | if (err) | ||
182 | printk(KERN_ERR "%s: system control regs already in use", name); | ||
183 | return err; | ||
184 | } | ||
185 | |||
186 | static const struct ide_port_ops tc86c001_port_ops = { | 178 | static const struct ide_port_ops tc86c001_port_ops = { |
187 | .set_pio_mode = tc86c001_set_pio_mode, | 179 | .set_pio_mode = tc86c001_set_pio_mode, |
188 | .set_dma_mode = tc86c001_set_mode, | 180 | .set_dma_mode = tc86c001_set_mode, |
@@ -201,8 +193,7 @@ static const struct ide_dma_ops tc86c001_dma_ops = { | |||
201 | }; | 193 | }; |
202 | 194 | ||
203 | static const struct ide_port_info tc86c001_chipset __devinitdata = { | 195 | static const struct ide_port_info tc86c001_chipset __devinitdata = { |
204 | .name = "TC86C001", | 196 | .name = DRV_NAME, |
205 | .init_chipset = init_chipset_tc86c001, | ||
206 | .init_hwif = init_hwif_tc86c001, | 197 | .init_hwif = init_hwif_tc86c001, |
207 | .port_ops = &tc86c001_port_ops, | 198 | .port_ops = &tc86c001_port_ops, |
208 | .dma_ops = &tc86c001_dma_ops, | 199 | .dma_ops = &tc86c001_dma_ops, |
@@ -215,7 +206,37 @@ static const struct ide_port_info tc86c001_chipset __devinitdata = { | |||
215 | static int __devinit tc86c001_init_one(struct pci_dev *dev, | 206 | static int __devinit tc86c001_init_one(struct pci_dev *dev, |
216 | const struct pci_device_id *id) | 207 | const struct pci_device_id *id) |
217 | { | 208 | { |
218 | return ide_setup_pci_device(dev, &tc86c001_chipset); | 209 | int rc; |
210 | |||
211 | rc = pci_enable_device(dev); | ||
212 | if (rc) | ||
213 | goto out; | ||
214 | |||
215 | rc = pci_request_region(dev, 5, DRV_NAME); | ||
216 | if (rc) { | ||
217 | printk(KERN_ERR DRV_NAME ": system control regs already in use"); | ||
218 | goto out_disable; | ||
219 | } | ||
220 | |||
221 | rc = ide_pci_init_one(dev, &tc86c001_chipset, NULL); | ||
222 | if (rc) | ||
223 | goto out_release; | ||
224 | |||
225 | goto out; | ||
226 | |||
227 | out_release: | ||
228 | pci_release_region(dev, 5); | ||
229 | out_disable: | ||
230 | pci_disable_device(dev); | ||
231 | out: | ||
232 | return rc; | ||
233 | } | ||
234 | |||
235 | static void __devexit tc86c001_remove(struct pci_dev *dev) | ||
236 | { | ||
237 | ide_pci_remove(dev); | ||
238 | pci_release_region(dev, 5); | ||
239 | pci_disable_device(dev); | ||
219 | } | 240 | } |
220 | 241 | ||
221 | static const struct pci_device_id tc86c001_pci_tbl[] = { | 242 | static const struct pci_device_id tc86c001_pci_tbl[] = { |
@@ -227,14 +248,22 @@ MODULE_DEVICE_TABLE(pci, tc86c001_pci_tbl); | |||
227 | static struct pci_driver driver = { | 248 | static struct pci_driver driver = { |
228 | .name = "TC86C001", | 249 | .name = "TC86C001", |
229 | .id_table = tc86c001_pci_tbl, | 250 | .id_table = tc86c001_pci_tbl, |
230 | .probe = tc86c001_init_one | 251 | .probe = tc86c001_init_one, |
252 | .remove = tc86c001_remove, | ||
231 | }; | 253 | }; |
232 | 254 | ||
233 | static int __init tc86c001_ide_init(void) | 255 | static int __init tc86c001_ide_init(void) |
234 | { | 256 | { |
235 | return ide_pci_register_driver(&driver); | 257 | return ide_pci_register_driver(&driver); |
236 | } | 258 | } |
259 | |||
260 | static void __exit tc86c001_ide_exit(void) | ||
261 | { | ||
262 | pci_unregister_driver(&driver); | ||
263 | } | ||
264 | |||
237 | module_init(tc86c001_ide_init); | 265 | module_init(tc86c001_ide_init); |
266 | module_exit(tc86c001_ide_exit); | ||
238 | 267 | ||
239 | MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); | 268 | MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); |
240 | MODULE_DESCRIPTION("PCI driver module for TC86C001 IDE"); | 269 | MODULE_DESCRIPTION("PCI driver module for TC86C001 IDE"); |
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index db65a558d4ec..b77ec35151b3 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/ide.h> | 33 | #include <linux/ide.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | 35 | ||
36 | #define DRV_NAME "triflex" | ||
37 | |||
36 | static void triflex_set_mode(ide_drive_t *drive, const u8 speed) | 38 | static void triflex_set_mode(ide_drive_t *drive, const u8 speed) |
37 | { | 39 | { |
38 | ide_hwif_t *hwif = HWIF(drive); | 40 | ide_hwif_t *hwif = HWIF(drive); |
@@ -93,7 +95,7 @@ static const struct ide_port_ops triflex_port_ops = { | |||
93 | }; | 95 | }; |
94 | 96 | ||
95 | static const struct ide_port_info triflex_device __devinitdata = { | 97 | static const struct ide_port_info triflex_device __devinitdata = { |
96 | .name = "TRIFLEX", | 98 | .name = DRV_NAME, |
97 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, | 99 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, |
98 | .port_ops = &triflex_port_ops, | 100 | .port_ops = &triflex_port_ops, |
99 | .pio_mask = ATA_PIO4, | 101 | .pio_mask = ATA_PIO4, |
@@ -104,7 +106,7 @@ static const struct ide_port_info triflex_device __devinitdata = { | |||
104 | static int __devinit triflex_init_one(struct pci_dev *dev, | 106 | static int __devinit triflex_init_one(struct pci_dev *dev, |
105 | const struct pci_device_id *id) | 107 | const struct pci_device_id *id) |
106 | { | 108 | { |
107 | return ide_setup_pci_device(dev, &triflex_device); | 109 | return ide_pci_init_one(dev, &triflex_device, NULL); |
108 | } | 110 | } |
109 | 111 | ||
110 | static const struct pci_device_id triflex_pci_tbl[] = { | 112 | static const struct pci_device_id triflex_pci_tbl[] = { |
@@ -117,6 +119,7 @@ static struct pci_driver driver = { | |||
117 | .name = "TRIFLEX_IDE", | 119 | .name = "TRIFLEX_IDE", |
118 | .id_table = triflex_pci_tbl, | 120 | .id_table = triflex_pci_tbl, |
119 | .probe = triflex_init_one, | 121 | .probe = triflex_init_one, |
122 | .remove = ide_pci_remove, | ||
120 | }; | 123 | }; |
121 | 124 | ||
122 | static int __init triflex_ide_init(void) | 125 | static int __init triflex_ide_init(void) |
@@ -124,7 +127,13 @@ static int __init triflex_ide_init(void) | |||
124 | return ide_pci_register_driver(&driver); | 127 | return ide_pci_register_driver(&driver); |
125 | } | 128 | } |
126 | 129 | ||
130 | static void __exit triflex_ide_exit(void) | ||
131 | { | ||
132 | pci_unregister_driver(&driver); | ||
133 | } | ||
134 | |||
127 | module_init(triflex_ide_init); | 135 | module_init(triflex_ide_init); |
136 | module_exit(triflex_ide_exit); | ||
128 | 137 | ||
129 | MODULE_AUTHOR("Torben Mathiasen"); | 138 | MODULE_AUTHOR("Torben Mathiasen"); |
130 | MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE"); | 139 | MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE"); |
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index a8a3138682ef..fd28b49977fd 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c | |||
@@ -141,6 +141,8 @@ | |||
141 | 141 | ||
142 | #include <asm/io.h> | 142 | #include <asm/io.h> |
143 | 143 | ||
144 | #define DRV_NAME "trm290" | ||
145 | |||
144 | static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma) | 146 | static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma) |
145 | { | 147 | { |
146 | ide_hwif_t *hwif = HWIF(drive); | 148 | ide_hwif_t *hwif = HWIF(drive); |
@@ -245,10 +247,10 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
245 | u8 reg = 0; | 247 | u8 reg = 0; |
246 | 248 | ||
247 | if ((dev->class & 5) && cfg_base) | 249 | if ((dev->class & 5) && cfg_base) |
248 | printk(KERN_INFO "TRM290: chip"); | 250 | printk(KERN_INFO DRV_NAME " %s: chip", pci_name(dev)); |
249 | else { | 251 | else { |
250 | cfg_base = 0x3df0; | 252 | cfg_base = 0x3df0; |
251 | printk(KERN_INFO "TRM290: using default"); | 253 | printk(KERN_INFO DRV_NAME " %s: using default", pci_name(dev)); |
252 | } | 254 | } |
253 | printk(KERN_CONT " config base at 0x%04x\n", cfg_base); | 255 | printk(KERN_CONT " config base at 0x%04x\n", cfg_base); |
254 | hwif->config_data = cfg_base; | 256 | hwif->config_data = cfg_base; |
@@ -325,7 +327,7 @@ static struct ide_dma_ops trm290_dma_ops = { | |||
325 | }; | 327 | }; |
326 | 328 | ||
327 | static const struct ide_port_info trm290_chipset __devinitdata = { | 329 | static const struct ide_port_info trm290_chipset __devinitdata = { |
328 | .name = "TRM290", | 330 | .name = DRV_NAME, |
329 | .init_hwif = init_hwif_trm290, | 331 | .init_hwif = init_hwif_trm290, |
330 | .chipset = ide_trm290, | 332 | .chipset = ide_trm290, |
331 | .port_ops = &trm290_port_ops, | 333 | .port_ops = &trm290_port_ops, |
@@ -340,7 +342,7 @@ static const struct ide_port_info trm290_chipset __devinitdata = { | |||
340 | 342 | ||
341 | static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 343 | static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
342 | { | 344 | { |
343 | return ide_setup_pci_device(dev, &trm290_chipset); | 345 | return ide_pci_init_one(dev, &trm290_chipset, NULL); |
344 | } | 346 | } |
345 | 347 | ||
346 | static const struct pci_device_id trm290_pci_tbl[] = { | 348 | static const struct pci_device_id trm290_pci_tbl[] = { |
@@ -353,6 +355,7 @@ static struct pci_driver driver = { | |||
353 | .name = "TRM290_IDE", | 355 | .name = "TRM290_IDE", |
354 | .id_table = trm290_pci_tbl, | 356 | .id_table = trm290_pci_tbl, |
355 | .probe = trm290_init_one, | 357 | .probe = trm290_init_one, |
358 | .remove = ide_pci_remove, | ||
356 | }; | 359 | }; |
357 | 360 | ||
358 | static int __init trm290_ide_init(void) | 361 | static int __init trm290_ide_init(void) |
@@ -360,7 +363,13 @@ static int __init trm290_ide_init(void) | |||
360 | return ide_pci_register_driver(&driver); | 363 | return ide_pci_register_driver(&driver); |
361 | } | 364 | } |
362 | 365 | ||
366 | static void __exit trm290_ide_exit(void) | ||
367 | { | ||
368 | pci_unregister_driver(&driver); | ||
369 | } | ||
370 | |||
363 | module_init(trm290_ide_init); | 371 | module_init(trm290_ide_init); |
372 | module_exit(trm290_ide_exit); | ||
364 | 373 | ||
365 | MODULE_AUTHOR("Mark Lord"); | 374 | MODULE_AUTHOR("Mark Lord"); |
366 | MODULE_DESCRIPTION("PCI driver module for Tekram TRM290 IDE"); | 375 | MODULE_DESCRIPTION("PCI driver module for Tekram TRM290 IDE"); |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index 09dc4803ef9d..454d2bf62dce 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -35,6 +35,8 @@ | |||
35 | #include <asm/processor.h> | 35 | #include <asm/processor.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #define DRV_NAME "via82cxxx" | ||
39 | |||
38 | #define VIA_IDE_ENABLE 0x40 | 40 | #define VIA_IDE_ENABLE 0x40 |
39 | #define VIA_IDE_CONFIG 0x41 | 41 | #define VIA_IDE_CONFIG 0x41 |
40 | #define VIA_FIFO_CONFIG 0x43 | 42 | #define VIA_FIFO_CONFIG 0x43 |
@@ -113,7 +115,8 @@ struct via82cxxx_dev | |||
113 | static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) | 115 | static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) |
114 | { | 116 | { |
115 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 117 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
116 | struct via82cxxx_dev *vdev = pci_get_drvdata(dev); | 118 | struct ide_host *host = pci_get_drvdata(dev); |
119 | struct via82cxxx_dev *vdev = host->host_priv; | ||
117 | u8 t; | 120 | u8 t; |
118 | 121 | ||
119 | if (~vdev->via_config->flags & VIA_BAD_AST) { | 122 | if (~vdev->via_config->flags & VIA_BAD_AST) { |
@@ -153,7 +156,8 @@ static void via_set_drive(ide_drive_t *drive, const u8 speed) | |||
153 | ide_hwif_t *hwif = drive->hwif; | 156 | ide_hwif_t *hwif = drive->hwif; |
154 | ide_drive_t *peer = hwif->drives + (~drive->dn & 1); | 157 | ide_drive_t *peer = hwif->drives + (~drive->dn & 1); |
155 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 158 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
156 | struct via82cxxx_dev *vdev = pci_get_drvdata(dev); | 159 | struct ide_host *host = pci_get_drvdata(dev); |
160 | struct via82cxxx_dev *vdev = host->host_priv; | ||
157 | struct ide_timing t, p; | 161 | struct ide_timing t, p; |
158 | unsigned int T, UT; | 162 | unsigned int T, UT; |
159 | 163 | ||
@@ -258,37 +262,19 @@ static void __devinit via_cable_detect(struct via82cxxx_dev *vdev, u32 u) | |||
258 | /** | 262 | /** |
259 | * init_chipset_via82cxxx - initialization handler | 263 | * init_chipset_via82cxxx - initialization handler |
260 | * @dev: PCI device | 264 | * @dev: PCI device |
261 | * @name: Name of interface | ||
262 | * | 265 | * |
263 | * The initialization callback. Here we determine the IDE chip type | 266 | * The initialization callback. Here we determine the IDE chip type |
264 | * and initialize its drive independent registers. | 267 | * and initialize its drive independent registers. |
265 | */ | 268 | */ |
266 | 269 | ||
267 | static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name) | 270 | static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev) |
268 | { | 271 | { |
269 | struct pci_dev *isa = NULL; | 272 | struct ide_host *host = pci_get_drvdata(dev); |
270 | struct via82cxxx_dev *vdev; | 273 | struct via82cxxx_dev *vdev = host->host_priv; |
271 | struct via_isa_bridge *via_config; | 274 | struct via_isa_bridge *via_config = vdev->via_config; |
272 | u8 t, v; | 275 | u8 t, v; |
273 | u32 u; | 276 | u32 u; |
274 | 277 | ||
275 | vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); | ||
276 | if (!vdev) { | ||
277 | printk(KERN_ERR "VP_IDE: out of memory :(\n"); | ||
278 | return -ENOMEM; | ||
279 | } | ||
280 | pci_set_drvdata(dev, vdev); | ||
281 | |||
282 | /* | ||
283 | * Find the ISA bridge to see how good the IDE is. | ||
284 | */ | ||
285 | vdev->via_config = via_config = via_config_find(&isa); | ||
286 | |||
287 | /* We checked this earlier so if it fails here deeep badness | ||
288 | is involved */ | ||
289 | |||
290 | BUG_ON(!via_config->id); | ||
291 | |||
292 | /* | 278 | /* |
293 | * Detect cable and configure Clk66 | 279 | * Detect cable and configure Clk66 |
294 | */ | 280 | */ |
@@ -334,39 +320,6 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const | |||
334 | 320 | ||
335 | pci_write_config_byte(dev, VIA_FIFO_CONFIG, t); | 321 | pci_write_config_byte(dev, VIA_FIFO_CONFIG, t); |
336 | 322 | ||
337 | /* | ||
338 | * Determine system bus clock. | ||
339 | */ | ||
340 | |||
341 | via_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; | ||
342 | |||
343 | switch (via_clock) { | ||
344 | case 33000: via_clock = 33333; break; | ||
345 | case 37000: via_clock = 37500; break; | ||
346 | case 41000: via_clock = 41666; break; | ||
347 | } | ||
348 | |||
349 | if (via_clock < 20000 || via_clock > 50000) { | ||
350 | printk(KERN_WARNING "VP_IDE: User given PCI clock speed " | ||
351 | "impossible (%d), using 33 MHz instead.\n", via_clock); | ||
352 | printk(KERN_WARNING "VP_IDE: Use ide0=ata66 if you want " | ||
353 | "to assume 80-wire cable.\n"); | ||
354 | via_clock = 33333; | ||
355 | } | ||
356 | |||
357 | /* | ||
358 | * Print the boot message. | ||
359 | */ | ||
360 | |||
361 | printk(KERN_INFO "VP_IDE: VIA %s (rev %02x) IDE %sDMA%s " | ||
362 | "controller on pci%s\n", | ||
363 | via_config->name, isa->revision, | ||
364 | via_config->udma_mask ? "U" : "MW", | ||
365 | via_dma[via_config->udma_mask ? | ||
366 | (fls(via_config->udma_mask) - 1) : 0], | ||
367 | pci_name(dev)); | ||
368 | |||
369 | pci_dev_put(isa); | ||
370 | return 0; | 323 | return 0; |
371 | } | 324 | } |
372 | 325 | ||
@@ -402,7 +355,8 @@ static int via_cable_override(struct pci_dev *pdev) | |||
402 | static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) | 355 | static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) |
403 | { | 356 | { |
404 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 357 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
405 | struct via82cxxx_dev *vdev = pci_get_drvdata(pdev); | 358 | struct ide_host *host = pci_get_drvdata(pdev); |
359 | struct via82cxxx_dev *vdev = host->host_priv; | ||
406 | 360 | ||
407 | if (via_cable_override(pdev)) | 361 | if (via_cable_override(pdev)) |
408 | return ATA_CBL_PATA40_SHORT; | 362 | return ATA_CBL_PATA40_SHORT; |
@@ -420,7 +374,7 @@ static const struct ide_port_ops via_port_ops = { | |||
420 | }; | 374 | }; |
421 | 375 | ||
422 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { | 376 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { |
423 | .name = "VP_IDE", | 377 | .name = DRV_NAME, |
424 | .init_chipset = init_chipset_via82cxxx, | 378 | .init_chipset = init_chipset_via82cxxx, |
425 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, | 379 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, |
426 | .port_ops = &via_port_ops, | 380 | .port_ops = &via_port_ops, |
@@ -436,6 +390,8 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
436 | { | 390 | { |
437 | struct pci_dev *isa = NULL; | 391 | struct pci_dev *isa = NULL; |
438 | struct via_isa_bridge *via_config; | 392 | struct via_isa_bridge *via_config; |
393 | struct via82cxxx_dev *vdev; | ||
394 | int rc; | ||
439 | u8 idx = id->driver_data; | 395 | u8 idx = id->driver_data; |
440 | struct ide_port_info d; | 396 | struct ide_port_info d; |
441 | 397 | ||
@@ -445,12 +401,42 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
445 | * Find the ISA bridge and check we know what it is. | 401 | * Find the ISA bridge and check we know what it is. |
446 | */ | 402 | */ |
447 | via_config = via_config_find(&isa); | 403 | via_config = via_config_find(&isa); |
448 | pci_dev_put(isa); | ||
449 | if (!via_config->id) { | 404 | if (!via_config->id) { |
450 | printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); | 405 | printk(KERN_WARNING DRV_NAME " %s: unknown chipset, skipping\n", |
406 | pci_name(dev)); | ||
451 | return -ENODEV; | 407 | return -ENODEV; |
452 | } | 408 | } |
453 | 409 | ||
410 | /* | ||
411 | * Print the boot message. | ||
412 | */ | ||
413 | printk(KERN_INFO DRV_NAME " %s: VIA %s (rev %02x) IDE %sDMA%s\n", | ||
414 | pci_name(dev), via_config->name, isa->revision, | ||
415 | via_config->udma_mask ? "U" : "MW", | ||
416 | via_dma[via_config->udma_mask ? | ||
417 | (fls(via_config->udma_mask) - 1) : 0]); | ||
418 | |||
419 | pci_dev_put(isa); | ||
420 | |||
421 | /* | ||
422 | * Determine system bus clock. | ||
423 | */ | ||
424 | via_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; | ||
425 | |||
426 | switch (via_clock) { | ||
427 | case 33000: via_clock = 33333; break; | ||
428 | case 37000: via_clock = 37500; break; | ||
429 | case 41000: via_clock = 41666; break; | ||
430 | } | ||
431 | |||
432 | if (via_clock < 20000 || via_clock > 50000) { | ||
433 | printk(KERN_WARNING DRV_NAME ": User given PCI clock speed " | ||
434 | "impossible (%d), using 33 MHz instead.\n", via_clock); | ||
435 | printk(KERN_WARNING DRV_NAME ": Use ide0=ata66 if you want " | ||
436 | "to assume 80-wire cable.\n"); | ||
437 | via_clock = 33333; | ||
438 | } | ||
439 | |||
454 | if (idx == 0) | 440 | if (idx == 0) |
455 | d.host_flags |= IDE_HFLAG_NO_AUTODMA; | 441 | d.host_flags |= IDE_HFLAG_NO_AUTODMA; |
456 | else | 442 | else |
@@ -466,7 +452,29 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
466 | 452 | ||
467 | d.udma_mask = via_config->udma_mask; | 453 | d.udma_mask = via_config->udma_mask; |
468 | 454 | ||
469 | return ide_setup_pci_device(dev, &d); | 455 | vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); |
456 | if (!vdev) { | ||
457 | printk(KERN_ERR DRV_NAME " %s: out of memory :(\n", | ||
458 | pci_name(dev)); | ||
459 | return -ENOMEM; | ||
460 | } | ||
461 | |||
462 | vdev->via_config = via_config; | ||
463 | |||
464 | rc = ide_pci_init_one(dev, &d, vdev); | ||
465 | if (rc) | ||
466 | kfree(vdev); | ||
467 | |||
468 | return rc; | ||
469 | } | ||
470 | |||
471 | static void __devexit via_remove(struct pci_dev *dev) | ||
472 | { | ||
473 | struct ide_host *host = pci_get_drvdata(dev); | ||
474 | struct via82cxxx_dev *vdev = host->host_priv; | ||
475 | |||
476 | ide_pci_remove(dev); | ||
477 | kfree(vdev); | ||
470 | } | 478 | } |
471 | 479 | ||
472 | static const struct pci_device_id via_pci_tbl[] = { | 480 | static const struct pci_device_id via_pci_tbl[] = { |
@@ -483,6 +491,7 @@ static struct pci_driver driver = { | |||
483 | .name = "VIA_IDE", | 491 | .name = "VIA_IDE", |
484 | .id_table = via_pci_tbl, | 492 | .id_table = via_pci_tbl, |
485 | .probe = via_init_one, | 493 | .probe = via_init_one, |
494 | .remove = via_remove, | ||
486 | }; | 495 | }; |
487 | 496 | ||
488 | static int __init via_ide_init(void) | 497 | static int __init via_ide_init(void) |
@@ -490,7 +499,13 @@ static int __init via_ide_init(void) | |||
490 | return ide_pci_register_driver(&driver); | 499 | return ide_pci_register_driver(&driver); |
491 | } | 500 | } |
492 | 501 | ||
502 | static void __exit via_ide_exit(void) | ||
503 | { | ||
504 | pci_unregister_driver(&driver); | ||
505 | } | ||
506 | |||
493 | module_init(via_ide_init); | 507 | module_init(via_ide_init); |
508 | module_exit(via_ide_exit); | ||
494 | 509 | ||
495 | MODULE_AUTHOR("Vojtech Pavlik, Michel Aubry, Jeff Garzik, Andre Hedrick"); | 510 | MODULE_AUTHOR("Vojtech Pavlik, Michel Aubry, Jeff Garzik, Andre Hedrick"); |
496 | MODULE_DESCRIPTION("PCI driver module for VIA IDE"); | 511 | MODULE_DESCRIPTION("PCI driver module for VIA IDE"); |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index b15cad58dc81..a8e9e8a69a52 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -39,17 +39,18 @@ static int ide_setup_pci_baseregs(struct pci_dev *dev, const char *name) | |||
39 | if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || | 39 | if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || |
40 | (progif & 5) != 5) { | 40 | (progif & 5) != 5) { |
41 | if ((progif & 0xa) != 0xa) { | 41 | if ((progif & 0xa) != 0xa) { |
42 | printk(KERN_INFO "%s: device not capable of full " | 42 | printk(KERN_INFO "%s %s: device not capable of full " |
43 | "native PCI mode\n", name); | 43 | "native PCI mode\n", name, pci_name(dev)); |
44 | return -EOPNOTSUPP; | 44 | return -EOPNOTSUPP; |
45 | } | 45 | } |
46 | printk("%s: placing both ports into native PCI mode\n", name); | 46 | printk(KERN_INFO "%s %s: placing both ports into native PCI " |
47 | "mode\n", name, pci_name(dev)); | ||
47 | (void) pci_write_config_byte(dev, PCI_CLASS_PROG, progif|5); | 48 | (void) pci_write_config_byte(dev, PCI_CLASS_PROG, progif|5); |
48 | if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || | 49 | if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || |
49 | (progif & 5) != 5) { | 50 | (progif & 5) != 5) { |
50 | printk(KERN_ERR "%s: rewrite of PROGIF failed, wanted " | 51 | printk(KERN_ERR "%s %s: rewrite of PROGIF failed, " |
51 | "0x%04x, got 0x%04x\n", | 52 | "wanted 0x%04x, got 0x%04x\n", |
52 | name, progif|5, progif); | 53 | name, pci_name(dev), progif | 5, progif); |
53 | return -EOPNOTSUPP; | 54 | return -EOPNOTSUPP; |
54 | } | 55 | } |
55 | } | 56 | } |
@@ -57,14 +58,14 @@ static int ide_setup_pci_baseregs(struct pci_dev *dev, const char *name) | |||
57 | } | 58 | } |
58 | 59 | ||
59 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 60 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
60 | static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) | 61 | static int ide_pci_clear_simplex(unsigned long dma_base, const char *name) |
61 | { | 62 | { |
62 | u8 dma_stat = inb(dma_base + 2); | 63 | u8 dma_stat = inb(dma_base + 2); |
63 | 64 | ||
64 | outb(dma_stat & 0x60, dma_base + 2); | 65 | outb(dma_stat & 0x60, dma_base + 2); |
65 | dma_stat = inb(dma_base + 2); | 66 | dma_stat = inb(dma_base + 2); |
66 | if (dma_stat & 0x80) | 67 | |
67 | printk(KERN_INFO "%s: simplex device: DMA forced\n", name); | 68 | return (dma_stat & 0x80) ? 1 : 0; |
68 | } | 69 | } |
69 | 70 | ||
70 | /** | 71 | /** |
@@ -91,7 +92,8 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
91 | dma_base = pci_resource_start(dev, baridx); | 92 | dma_base = pci_resource_start(dev, baridx); |
92 | 93 | ||
93 | if (dma_base == 0) { | 94 | if (dma_base == 0) { |
94 | printk(KERN_ERR "%s: DMA base is invalid\n", d->name); | 95 | printk(KERN_ERR "%s %s: DMA base is invalid\n", |
96 | d->name, pci_name(dev)); | ||
95 | return 0; | 97 | return 0; |
96 | } | 98 | } |
97 | } | 99 | } |
@@ -105,13 +107,16 @@ EXPORT_SYMBOL_GPL(ide_pci_dma_base); | |||
105 | 107 | ||
106 | int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d) | 108 | int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d) |
107 | { | 109 | { |
110 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
108 | u8 dma_stat; | 111 | u8 dma_stat; |
109 | 112 | ||
110 | if (d->host_flags & (IDE_HFLAG_MMIO | IDE_HFLAG_CS5520)) | 113 | if (d->host_flags & (IDE_HFLAG_MMIO | IDE_HFLAG_CS5520)) |
111 | goto out; | 114 | goto out; |
112 | 115 | ||
113 | if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { | 116 | if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { |
114 | ide_pci_clear_simplex(hwif->dma_base, d->name); | 117 | if (ide_pci_clear_simplex(hwif->dma_base, d->name)) |
118 | printk(KERN_INFO "%s %s: simplex device: DMA forced\n", | ||
119 | d->name, pci_name(dev)); | ||
115 | goto out; | 120 | goto out; |
116 | } | 121 | } |
117 | 122 | ||
@@ -127,7 +132,8 @@ int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
127 | */ | 132 | */ |
128 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); | 133 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); |
129 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { | 134 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { |
130 | printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); | 135 | printk(KERN_INFO "%s %s: simplex device: DMA disabled\n", |
136 | d->name, pci_name(dev)); | ||
131 | return -1; | 137 | return -1; |
132 | } | 138 | } |
133 | out: | 139 | out: |
@@ -149,8 +155,8 @@ int ide_pci_set_master(struct pci_dev *dev, const char *name) | |||
149 | 155 | ||
150 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || | 156 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || |
151 | (pcicmd & PCI_COMMAND_MASTER) == 0) { | 157 | (pcicmd & PCI_COMMAND_MASTER) == 0) { |
152 | printk(KERN_ERR "%s: error updating PCICMD on %s\n", | 158 | printk(KERN_ERR "%s %s: error updating PCICMD\n", |
153 | name, pci_name(dev)); | 159 | name, pci_name(dev)); |
154 | return -EIO; | 160 | return -EIO; |
155 | } | 161 | } |
156 | } | 162 | } |
@@ -162,9 +168,9 @@ EXPORT_SYMBOL_GPL(ide_pci_set_master); | |||
162 | 168 | ||
163 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) | 169 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) |
164 | { | 170 | { |
165 | printk(KERN_INFO "%s: IDE controller (0x%04x:0x%04x rev 0x%02x) at " | 171 | printk(KERN_INFO "%s %s: IDE controller (0x%04x:0x%04x rev 0x%02x)\n", |
166 | " PCI slot %s\n", d->name, dev->vendor, dev->device, | 172 | d->name, pci_name(dev), |
167 | dev->revision, pci_name(dev)); | 173 | dev->vendor, dev->device, dev->revision); |
168 | } | 174 | } |
169 | EXPORT_SYMBOL_GPL(ide_setup_pci_noise); | 175 | EXPORT_SYMBOL_GPL(ide_setup_pci_noise); |
170 | 176 | ||
@@ -189,11 +195,12 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | |||
189 | if (pci_enable_device(dev)) { | 195 | if (pci_enable_device(dev)) { |
190 | ret = pci_enable_device_io(dev); | 196 | ret = pci_enable_device_io(dev); |
191 | if (ret < 0) { | 197 | if (ret < 0) { |
192 | printk(KERN_WARNING "%s: (ide_setup_pci_device:) " | 198 | printk(KERN_WARNING "%s %s: couldn't enable device\n", |
193 | "Could not enable device.\n", d->name); | 199 | d->name, pci_name(dev)); |
194 | goto out; | 200 | goto out; |
195 | } | 201 | } |
196 | printk(KERN_WARNING "%s: BIOS configuration fixed.\n", d->name); | 202 | printk(KERN_WARNING "%s %s: BIOS configuration fixed\n", |
203 | d->name, pci_name(dev)); | ||
197 | } | 204 | } |
198 | 205 | ||
199 | /* | 206 | /* |
@@ -203,7 +210,8 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | |||
203 | */ | 210 | */ |
204 | ret = pci_set_dma_mask(dev, DMA_32BIT_MASK); | 211 | ret = pci_set_dma_mask(dev, DMA_32BIT_MASK); |
205 | if (ret < 0) { | 212 | if (ret < 0) { |
206 | printk(KERN_ERR "%s: can't set dma mask\n", d->name); | 213 | printk(KERN_ERR "%s %s: can't set DMA mask\n", |
214 | d->name, pci_name(dev)); | ||
207 | goto out; | 215 | goto out; |
208 | } | 216 | } |
209 | 217 | ||
@@ -221,7 +229,8 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | |||
221 | 229 | ||
222 | ret = pci_request_selected_regions(dev, bars, d->name); | 230 | ret = pci_request_selected_regions(dev, bars, d->name); |
223 | if (ret < 0) | 231 | if (ret < 0) |
224 | printk(KERN_ERR "%s: can't reserve resources\n", d->name); | 232 | printk(KERN_ERR "%s %s: can't reserve resources\n", |
233 | d->name, pci_name(dev)); | ||
225 | out: | 234 | out: |
226 | return ret; | 235 | return ret; |
227 | } | 236 | } |
@@ -247,15 +256,18 @@ static int ide_pci_configure(struct pci_dev *dev, const struct ide_port_info *d) | |||
247 | */ | 256 | */ |
248 | if (ide_setup_pci_baseregs(dev, d->name) || | 257 | if (ide_setup_pci_baseregs(dev, d->name) || |
249 | pci_write_config_word(dev, PCI_COMMAND, pcicmd | PCI_COMMAND_IO)) { | 258 | pci_write_config_word(dev, PCI_COMMAND, pcicmd | PCI_COMMAND_IO)) { |
250 | printk(KERN_INFO "%s: device disabled (BIOS)\n", d->name); | 259 | printk(KERN_INFO "%s %s: device disabled (BIOS)\n", |
260 | d->name, pci_name(dev)); | ||
251 | return -ENODEV; | 261 | return -ENODEV; |
252 | } | 262 | } |
253 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) { | 263 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) { |
254 | printk(KERN_ERR "%s: error accessing PCI regs\n", d->name); | 264 | printk(KERN_ERR "%s %s: error accessing PCI regs\n", |
265 | d->name, pci_name(dev)); | ||
255 | return -EIO; | 266 | return -EIO; |
256 | } | 267 | } |
257 | if (!(pcicmd & PCI_COMMAND_IO)) { | 268 | if (!(pcicmd & PCI_COMMAND_IO)) { |
258 | printk(KERN_ERR "%s: unable to enable IDE controller\n", d->name); | 269 | printk(KERN_ERR "%s %s: unable to enable IDE controller\n", |
270 | d->name, pci_name(dev)); | ||
259 | return -ENXIO; | 271 | return -ENXIO; |
260 | } | 272 | } |
261 | return 0; | 273 | return 0; |
@@ -311,8 +323,9 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, | |||
311 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { | 323 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { |
312 | if (ide_pci_check_iomem(dev, d, 2 * port) || | 324 | if (ide_pci_check_iomem(dev, d, 2 * port) || |
313 | ide_pci_check_iomem(dev, d, 2 * port + 1)) { | 325 | ide_pci_check_iomem(dev, d, 2 * port + 1)) { |
314 | printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported " | 326 | printk(KERN_ERR "%s %s: I/O baseregs (BIOS) are " |
315 | "as MEM for port %d!\n", d->name, port); | 327 | "reported as MEM for port %d!\n", |
328 | d->name, pci_name(dev), port); | ||
316 | return -EINVAL; | 329 | return -EINVAL; |
317 | } | 330 | } |
318 | 331 | ||
@@ -325,8 +338,8 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d, | |||
325 | } | 338 | } |
326 | 339 | ||
327 | if (!base || !ctl) { | 340 | if (!base || !ctl) { |
328 | printk(KERN_ERR "%s: bad PCI BARs for port %d, skipping\n", | 341 | printk(KERN_ERR "%s %s: bad PCI BARs for port %d, skipping\n", |
329 | d->name, port); | 342 | d->name, pci_name(dev), port); |
330 | return -EINVAL; | 343 | return -EINVAL; |
331 | } | 344 | } |
332 | 345 | ||
@@ -393,14 +406,14 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
393 | * @dev: PCI device | 406 | * @dev: PCI device |
394 | * @d: IDE port info | 407 | * @d: IDE port info |
395 | * @noisy: verbose flag | 408 | * @noisy: verbose flag |
396 | * @config: returned as 1 if we configured the hardware | ||
397 | * | 409 | * |
398 | * Set up the PCI and controller side of the IDE interface. This brings | 410 | * Set up the PCI and controller side of the IDE interface. This brings |
399 | * up the PCI side of the device, checks that the device is enabled | 411 | * up the PCI side of the device, checks that the device is enabled |
400 | * and enables it if need be | 412 | * and enables it if need be |
401 | */ | 413 | */ |
402 | 414 | ||
403 | static int ide_setup_pci_controller(struct pci_dev *dev, const struct ide_port_info *d, int noisy, int *config) | 415 | static int ide_setup_pci_controller(struct pci_dev *dev, |
416 | const struct ide_port_info *d, int noisy) | ||
404 | { | 417 | { |
405 | int ret; | 418 | int ret; |
406 | u16 pcicmd; | 419 | u16 pcicmd; |
@@ -414,15 +427,16 @@ static int ide_setup_pci_controller(struct pci_dev *dev, const struct ide_port_i | |||
414 | 427 | ||
415 | ret = pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | 428 | ret = pci_read_config_word(dev, PCI_COMMAND, &pcicmd); |
416 | if (ret < 0) { | 429 | if (ret < 0) { |
417 | printk(KERN_ERR "%s: error accessing PCI regs\n", d->name); | 430 | printk(KERN_ERR "%s %s: error accessing PCI regs\n", |
431 | d->name, pci_name(dev)); | ||
418 | goto out; | 432 | goto out; |
419 | } | 433 | } |
420 | if (!(pcicmd & PCI_COMMAND_IO)) { /* is device disabled? */ | 434 | if (!(pcicmd & PCI_COMMAND_IO)) { /* is device disabled? */ |
421 | ret = ide_pci_configure(dev, d); | 435 | ret = ide_pci_configure(dev, d); |
422 | if (ret < 0) | 436 | if (ret < 0) |
423 | goto out; | 437 | goto out; |
424 | *config = 1; | 438 | printk(KERN_INFO "%s %s: device enabled (Linux)\n", |
425 | printk(KERN_INFO "%s: device enabled (Linux)\n", d->name); | 439 | d->name, pci_name(dev)); |
426 | } | 440 | } |
427 | 441 | ||
428 | out: | 442 | out: |
@@ -461,7 +475,8 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, | |||
461 | 475 | ||
462 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || | 476 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || |
463 | (tmp & e->mask) != e->val)) { | 477 | (tmp & e->mask) != e->val)) { |
464 | printk(KERN_INFO "%s: IDE port disabled\n", d->name); | 478 | printk(KERN_INFO "%s %s: IDE port disabled\n", |
479 | d->name, pci_name(dev)); | ||
465 | continue; /* port not enabled */ | 480 | continue; /* port not enabled */ |
466 | } | 481 | } |
467 | 482 | ||
@@ -487,51 +502,35 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, | |||
487 | const struct ide_port_info *d, | 502 | const struct ide_port_info *d, |
488 | u8 noisy) | 503 | u8 noisy) |
489 | { | 504 | { |
490 | int tried_config = 0; | ||
491 | int pciirq, ret; | 505 | int pciirq, ret; |
492 | 506 | ||
493 | ret = ide_setup_pci_controller(dev, d, noisy, &tried_config); | ||
494 | if (ret < 0) | ||
495 | goto out; | ||
496 | |||
497 | /* | 507 | /* |
498 | * Can we trust the reported IRQ? | 508 | * Can we trust the reported IRQ? |
499 | */ | 509 | */ |
500 | pciirq = dev->irq; | 510 | pciirq = dev->irq; |
501 | 511 | ||
512 | /* | ||
513 | * This allows offboard ide-pci cards the enable a BIOS, | ||
514 | * verify interrupt settings of split-mirror pci-config | ||
515 | * space, place chipset into init-mode, and/or preserve | ||
516 | * an interrupt if the card is not native ide support. | ||
517 | */ | ||
518 | ret = d->init_chipset ? d->init_chipset(dev) : 0; | ||
519 | if (ret < 0) | ||
520 | goto out; | ||
521 | |||
502 | /* Is it an "IDE storage" device in non-PCI mode? */ | 522 | /* Is it an "IDE storage" device in non-PCI mode? */ |
503 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 5) != 5) { | 523 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 5) != 5) { |
504 | if (noisy) | 524 | if (noisy) |
505 | printk(KERN_INFO "%s: not 100%% native mode: " | 525 | printk(KERN_INFO "%s %s: not 100%% native mode: will " |
506 | "will probe irqs later\n", d->name); | 526 | "probe irqs later\n", d->name, pci_name(dev)); |
507 | /* | ||
508 | * This allows offboard ide-pci cards the enable a BIOS, | ||
509 | * verify interrupt settings of split-mirror pci-config | ||
510 | * space, place chipset into init-mode, and/or preserve | ||
511 | * an interrupt if the card is not native ide support. | ||
512 | */ | ||
513 | ret = d->init_chipset ? d->init_chipset(dev, d->name) : 0; | ||
514 | if (ret < 0) | ||
515 | goto out; | ||
516 | pciirq = ret; | 527 | pciirq = ret; |
517 | } else if (tried_config) { | 528 | } else if (!pciirq && noisy) { |
518 | if (noisy) | 529 | printk(KERN_WARNING "%s %s: bad irq (%d): will probe later\n", |
519 | printk(KERN_INFO "%s: will probe irqs later\n", d->name); | 530 | d->name, pci_name(dev), pciirq); |
520 | pciirq = 0; | 531 | } else if (noisy) { |
521 | } else if (!pciirq) { | 532 | printk(KERN_INFO "%s %s: 100%% native mode on irq %d\n", |
522 | if (noisy) | 533 | d->name, pci_name(dev), pciirq); |
523 | printk(KERN_WARNING "%s: bad irq (%d): will probe later\n", | ||
524 | d->name, pciirq); | ||
525 | pciirq = 0; | ||
526 | } else { | ||
527 | if (d->init_chipset) { | ||
528 | ret = d->init_chipset(dev, d->name); | ||
529 | if (ret < 0) | ||
530 | goto out; | ||
531 | } | ||
532 | if (noisy) | ||
533 | printk(KERN_INFO "%s: 100%% native mode on irq %d\n", | ||
534 | d->name, pciirq); | ||
535 | } | 534 | } |
536 | 535 | ||
537 | ret = pciirq; | 536 | ret = pciirq; |
@@ -539,32 +538,77 @@ out: | |||
539 | return ret; | 538 | return ret; |
540 | } | 539 | } |
541 | 540 | ||
542 | int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) | 541 | int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d, |
542 | void *priv) | ||
543 | { | 543 | { |
544 | struct ide_host *host; | ||
544 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | 545 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
545 | int ret; | 546 | int ret; |
546 | 547 | ||
547 | ret = do_ide_setup_pci_device(dev, d, 1); | 548 | ret = ide_setup_pci_controller(dev, d, 1); |
549 | if (ret < 0) | ||
550 | goto out; | ||
548 | 551 | ||
549 | if (ret >= 0) { | 552 | ide_pci_setup_ports(dev, d, 0, &hw[0], &hws[0]); |
550 | /* FIXME: silent failure can happen */ | ||
551 | ide_pci_setup_ports(dev, d, ret, &hw[0], &hws[0]); | ||
552 | 553 | ||
553 | ret = ide_host_add(d, hws, NULL); | 554 | host = ide_host_alloc(d, hws); |
555 | if (host == NULL) { | ||
556 | ret = -ENOMEM; | ||
557 | goto out; | ||
554 | } | 558 | } |
555 | 559 | ||
560 | host->dev[0] = &dev->dev; | ||
561 | |||
562 | host->host_priv = priv; | ||
563 | |||
564 | pci_set_drvdata(dev, host); | ||
565 | |||
566 | ret = do_ide_setup_pci_device(dev, d, 1); | ||
567 | if (ret < 0) | ||
568 | goto out; | ||
569 | |||
570 | /* fixup IRQ */ | ||
571 | hw[1].irq = hw[0].irq = ret; | ||
572 | |||
573 | ret = ide_host_register(host, d, hws); | ||
574 | if (ret) | ||
575 | ide_host_free(host); | ||
576 | out: | ||
556 | return ret; | 577 | return ret; |
557 | } | 578 | } |
558 | EXPORT_SYMBOL_GPL(ide_setup_pci_device); | 579 | EXPORT_SYMBOL_GPL(ide_pci_init_one); |
559 | 580 | ||
560 | int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | 581 | int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, |
561 | const struct ide_port_info *d) | 582 | const struct ide_port_info *d, void *priv) |
562 | { | 583 | { |
563 | struct pci_dev *pdev[] = { dev1, dev2 }; | 584 | struct pci_dev *pdev[] = { dev1, dev2 }; |
585 | struct ide_host *host; | ||
564 | int ret, i; | 586 | int ret, i; |
565 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; | 587 | hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; |
566 | 588 | ||
567 | for (i = 0; i < 2; i++) { | 589 | for (i = 0; i < 2; i++) { |
590 | ret = ide_setup_pci_controller(pdev[i], d, !i); | ||
591 | if (ret < 0) | ||
592 | goto out; | ||
593 | |||
594 | ide_pci_setup_ports(pdev[i], d, 0, &hw[i*2], &hws[i*2]); | ||
595 | } | ||
596 | |||
597 | host = ide_host_alloc(d, hws); | ||
598 | if (host == NULL) { | ||
599 | ret = -ENOMEM; | ||
600 | goto out; | ||
601 | } | ||
602 | |||
603 | host->dev[0] = &dev1->dev; | ||
604 | host->dev[1] = &dev2->dev; | ||
605 | |||
606 | host->host_priv = priv; | ||
607 | |||
608 | pci_set_drvdata(pdev[0], host); | ||
609 | pci_set_drvdata(pdev[1], host); | ||
610 | |||
611 | for (i = 0; i < 2; i++) { | ||
568 | ret = do_ide_setup_pci_device(pdev[i], d, !i); | 612 | ret = do_ide_setup_pci_device(pdev[i], d, !i); |
569 | 613 | ||
570 | /* | 614 | /* |
@@ -574,12 +618,44 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |||
574 | if (ret < 0) | 618 | if (ret < 0) |
575 | goto out; | 619 | goto out; |
576 | 620 | ||
577 | /* FIXME: silent failure can happen */ | 621 | /* fixup IRQ */ |
578 | ide_pci_setup_ports(pdev[i], d, ret, &hw[i*2], &hws[i*2]); | 622 | hw[i*2 + 1].irq = hw[i*2].irq = ret; |
579 | } | 623 | } |
580 | 624 | ||
581 | ret = ide_host_add(d, hws, NULL); | 625 | ret = ide_host_register(host, d, hws); |
626 | if (ret) | ||
627 | ide_host_free(host); | ||
582 | out: | 628 | out: |
583 | return ret; | 629 | return ret; |
584 | } | 630 | } |
585 | EXPORT_SYMBOL_GPL(ide_setup_pci_devices); | 631 | EXPORT_SYMBOL_GPL(ide_pci_init_two); |
632 | |||
633 | void ide_pci_remove(struct pci_dev *dev) | ||
634 | { | ||
635 | struct ide_host *host = pci_get_drvdata(dev); | ||
636 | struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL; | ||
637 | int bars; | ||
638 | |||
639 | if (host->host_flags & IDE_HFLAG_SINGLE) | ||
640 | bars = (1 << 2) - 1; | ||
641 | else | ||
642 | bars = (1 << 4) - 1; | ||
643 | |||
644 | if ((host->host_flags & IDE_HFLAG_NO_DMA) == 0) { | ||
645 | if (host->host_flags & IDE_HFLAG_CS5520) | ||
646 | bars |= (1 << 2); | ||
647 | else | ||
648 | bars |= (1 << 4); | ||
649 | } | ||
650 | |||
651 | ide_host_remove(host); | ||
652 | |||
653 | if (dev2) | ||
654 | pci_release_selected_regions(dev2, bars); | ||
655 | pci_release_selected_regions(dev, bars); | ||
656 | |||
657 | if (dev2) | ||
658 | pci_disable_device(dev2); | ||
659 | pci_disable_device(dev); | ||
660 | } | ||
661 | EXPORT_SYMBOL_GPL(ide_pci_remove); | ||
diff --git a/drivers/ieee1394/iso.c b/drivers/ieee1394/iso.c index 07ca35c98f96..1cf6487b65ba 100644 --- a/drivers/ieee1394/iso.c +++ b/drivers/ieee1394/iso.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/mm.h> | ||
14 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
15 | 16 | ||
16 | #include "hosts.h" | 17 | #include "hosts.h" |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index ae11d5cc74d0..e980ff3335db 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -168,6 +168,12 @@ struct cma_work { | |||
168 | struct rdma_cm_event event; | 168 | struct rdma_cm_event event; |
169 | }; | 169 | }; |
170 | 170 | ||
171 | struct cma_ndev_work { | ||
172 | struct work_struct work; | ||
173 | struct rdma_id_private *id; | ||
174 | struct rdma_cm_event event; | ||
175 | }; | ||
176 | |||
171 | union cma_ip_addr { | 177 | union cma_ip_addr { |
172 | struct in6_addr ip6; | 178 | struct in6_addr ip6; |
173 | struct { | 179 | struct { |
@@ -914,7 +920,10 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) | |||
914 | struct rdma_cm_event event; | 920 | struct rdma_cm_event event; |
915 | int ret = 0; | 921 | int ret = 0; |
916 | 922 | ||
917 | if (cma_disable_callback(id_priv, CMA_CONNECT)) | 923 | if ((ib_event->event != IB_CM_TIMEWAIT_EXIT && |
924 | cma_disable_callback(id_priv, CMA_CONNECT)) || | ||
925 | (ib_event->event == IB_CM_TIMEWAIT_EXIT && | ||
926 | cma_disable_callback(id_priv, CMA_DISCONNECT))) | ||
918 | return 0; | 927 | return 0; |
919 | 928 | ||
920 | memset(&event, 0, sizeof event); | 929 | memset(&event, 0, sizeof event); |
@@ -950,6 +959,8 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) | |||
950 | event.event = RDMA_CM_EVENT_DISCONNECTED; | 959 | event.event = RDMA_CM_EVENT_DISCONNECTED; |
951 | break; | 960 | break; |
952 | case IB_CM_TIMEWAIT_EXIT: | 961 | case IB_CM_TIMEWAIT_EXIT: |
962 | event.event = RDMA_CM_EVENT_TIMEWAIT_EXIT; | ||
963 | break; | ||
953 | case IB_CM_MRA_RECEIVED: | 964 | case IB_CM_MRA_RECEIVED: |
954 | /* ignore event */ | 965 | /* ignore event */ |
955 | goto out; | 966 | goto out; |
@@ -1598,6 +1609,30 @@ out: | |||
1598 | kfree(work); | 1609 | kfree(work); |
1599 | } | 1610 | } |
1600 | 1611 | ||
1612 | static void cma_ndev_work_handler(struct work_struct *_work) | ||
1613 | { | ||
1614 | struct cma_ndev_work *work = container_of(_work, struct cma_ndev_work, work); | ||
1615 | struct rdma_id_private *id_priv = work->id; | ||
1616 | int destroy = 0; | ||
1617 | |||
1618 | mutex_lock(&id_priv->handler_mutex); | ||
1619 | if (id_priv->state == CMA_DESTROYING || | ||
1620 | id_priv->state == CMA_DEVICE_REMOVAL) | ||
1621 | goto out; | ||
1622 | |||
1623 | if (id_priv->id.event_handler(&id_priv->id, &work->event)) { | ||
1624 | cma_exch(id_priv, CMA_DESTROYING); | ||
1625 | destroy = 1; | ||
1626 | } | ||
1627 | |||
1628 | out: | ||
1629 | mutex_unlock(&id_priv->handler_mutex); | ||
1630 | cma_deref_id(id_priv); | ||
1631 | if (destroy) | ||
1632 | rdma_destroy_id(&id_priv->id); | ||
1633 | kfree(work); | ||
1634 | } | ||
1635 | |||
1601 | static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms) | 1636 | static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms) |
1602 | { | 1637 | { |
1603 | struct rdma_route *route = &id_priv->id.route; | 1638 | struct rdma_route *route = &id_priv->id.route; |
@@ -2723,6 +2758,65 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) | |||
2723 | } | 2758 | } |
2724 | EXPORT_SYMBOL(rdma_leave_multicast); | 2759 | EXPORT_SYMBOL(rdma_leave_multicast); |
2725 | 2760 | ||
2761 | static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id_priv) | ||
2762 | { | ||
2763 | struct rdma_dev_addr *dev_addr; | ||
2764 | struct cma_ndev_work *work; | ||
2765 | |||
2766 | dev_addr = &id_priv->id.route.addr.dev_addr; | ||
2767 | |||
2768 | if ((dev_addr->src_dev == ndev) && | ||
2769 | memcmp(dev_addr->src_dev_addr, ndev->dev_addr, ndev->addr_len)) { | ||
2770 | printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n", | ||
2771 | ndev->name, &id_priv->id); | ||
2772 | work = kzalloc(sizeof *work, GFP_KERNEL); | ||
2773 | if (!work) | ||
2774 | return -ENOMEM; | ||
2775 | |||
2776 | INIT_WORK(&work->work, cma_ndev_work_handler); | ||
2777 | work->id = id_priv; | ||
2778 | work->event.event = RDMA_CM_EVENT_ADDR_CHANGE; | ||
2779 | atomic_inc(&id_priv->refcount); | ||
2780 | queue_work(cma_wq, &work->work); | ||
2781 | } | ||
2782 | |||
2783 | return 0; | ||
2784 | } | ||
2785 | |||
2786 | static int cma_netdev_callback(struct notifier_block *self, unsigned long event, | ||
2787 | void *ctx) | ||
2788 | { | ||
2789 | struct net_device *ndev = (struct net_device *)ctx; | ||
2790 | struct cma_device *cma_dev; | ||
2791 | struct rdma_id_private *id_priv; | ||
2792 | int ret = NOTIFY_DONE; | ||
2793 | |||
2794 | if (dev_net(ndev) != &init_net) | ||
2795 | return NOTIFY_DONE; | ||
2796 | |||
2797 | if (event != NETDEV_BONDING_FAILOVER) | ||
2798 | return NOTIFY_DONE; | ||
2799 | |||
2800 | if (!(ndev->flags & IFF_MASTER) || !(ndev->priv_flags & IFF_BONDING)) | ||
2801 | return NOTIFY_DONE; | ||
2802 | |||
2803 | mutex_lock(&lock); | ||
2804 | list_for_each_entry(cma_dev, &dev_list, list) | ||
2805 | list_for_each_entry(id_priv, &cma_dev->id_list, list) { | ||
2806 | ret = cma_netdev_change(ndev, id_priv); | ||
2807 | if (ret) | ||
2808 | goto out; | ||
2809 | } | ||
2810 | |||
2811 | out: | ||
2812 | mutex_unlock(&lock); | ||
2813 | return ret; | ||
2814 | } | ||
2815 | |||
2816 | static struct notifier_block cma_nb = { | ||
2817 | .notifier_call = cma_netdev_callback | ||
2818 | }; | ||
2819 | |||
2726 | static void cma_add_one(struct ib_device *device) | 2820 | static void cma_add_one(struct ib_device *device) |
2727 | { | 2821 | { |
2728 | struct cma_device *cma_dev; | 2822 | struct cma_device *cma_dev; |
@@ -2831,6 +2925,7 @@ static int cma_init(void) | |||
2831 | 2925 | ||
2832 | ib_sa_register_client(&sa_client); | 2926 | ib_sa_register_client(&sa_client); |
2833 | rdma_addr_register_client(&addr_client); | 2927 | rdma_addr_register_client(&addr_client); |
2928 | register_netdevice_notifier(&cma_nb); | ||
2834 | 2929 | ||
2835 | ret = ib_register_client(&cma_client); | 2930 | ret = ib_register_client(&cma_client); |
2836 | if (ret) | 2931 | if (ret) |
@@ -2838,6 +2933,7 @@ static int cma_init(void) | |||
2838 | return 0; | 2933 | return 0; |
2839 | 2934 | ||
2840 | err: | 2935 | err: |
2936 | unregister_netdevice_notifier(&cma_nb); | ||
2841 | rdma_addr_unregister_client(&addr_client); | 2937 | rdma_addr_unregister_client(&addr_client); |
2842 | ib_sa_unregister_client(&sa_client); | 2938 | ib_sa_unregister_client(&sa_client); |
2843 | destroy_workqueue(cma_wq); | 2939 | destroy_workqueue(cma_wq); |
@@ -2847,6 +2943,7 @@ err: | |||
2847 | static void cma_cleanup(void) | 2943 | static void cma_cleanup(void) |
2848 | { | 2944 | { |
2849 | ib_unregister_client(&cma_client); | 2945 | ib_unregister_client(&cma_client); |
2946 | unregister_netdevice_notifier(&cma_nb); | ||
2850 | rdma_addr_unregister_client(&addr_client); | 2947 | rdma_addr_unregister_client(&addr_client); |
2851 | ib_sa_unregister_client(&sa_client); | 2948 | ib_sa_unregister_client(&sa_client); |
2852 | destroy_workqueue(cma_wq); | 2949 | destroy_workqueue(cma_wq); |
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index 81c9195b512a..8f9509e1ebf7 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c | |||
@@ -942,8 +942,7 @@ static int iwcm_init_qp_init_attr(struct iwcm_id_private *cm_id_priv, | |||
942 | case IW_CM_STATE_CONN_RECV: | 942 | case IW_CM_STATE_CONN_RECV: |
943 | case IW_CM_STATE_ESTABLISHED: | 943 | case IW_CM_STATE_ESTABLISHED: |
944 | *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS; | 944 | *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS; |
945 | qp_attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE | | 945 | qp_attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE| |
946 | IB_ACCESS_REMOTE_WRITE| | ||
947 | IB_ACCESS_REMOTE_READ; | 946 | IB_ACCESS_REMOTE_READ; |
948 | ret = 0; | 947 | ret = 0; |
949 | break; | 948 | break; |
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 1341de793e51..7863a50d56f2 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c | |||
@@ -1064,7 +1064,8 @@ static void ib_sa_remove_one(struct ib_device *device) | |||
1064 | 1064 | ||
1065 | for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) { | 1065 | for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) { |
1066 | ib_unregister_mad_agent(sa_dev->port[i].agent); | 1066 | ib_unregister_mad_agent(sa_dev->port[i].agent); |
1067 | kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah); | 1067 | if (sa_dev->port[i].sm_ah) |
1068 | kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah); | ||
1068 | } | 1069 | } |
1069 | 1070 | ||
1070 | kfree(sa_dev); | 1071 | kfree(sa_dev); |
diff --git a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h index 1e9e99a13933..0b0618edd645 100644 --- a/drivers/infiniband/hw/ehca/ehca_classes.h +++ b/drivers/infiniband/hw/ehca/ehca_classes.h | |||
@@ -194,6 +194,7 @@ struct ehca_qp { | |||
194 | u32 packet_count; | 194 | u32 packet_count; |
195 | atomic_t nr_events; /* events seen */ | 195 | atomic_t nr_events; /* events seen */ |
196 | wait_queue_head_t wait_completion; | 196 | wait_queue_head_t wait_completion; |
197 | int mig_armed; | ||
197 | }; | 198 | }; |
198 | 199 | ||
199 | #define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ) | 200 | #define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ) |
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c index bc3b37d2070f..46288220cfbb 100644 --- a/drivers/infiniband/hw/ehca/ehca_hca.c +++ b/drivers/infiniband/hw/ehca/ehca_hca.c | |||
@@ -114,7 +114,9 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) | |||
114 | } | 114 | } |
115 | 115 | ||
116 | props->max_pkeys = 16; | 116 | props->max_pkeys = 16; |
117 | props->local_ca_ack_delay = min_t(u8, rblock->local_ca_ack_delay, 255); | 117 | /* Some FW versions say 0 here; insert sensible value in that case */ |
118 | props->local_ca_ack_delay = rblock->local_ca_ack_delay ? | ||
119 | min_t(u8, rblock->local_ca_ack_delay, 255) : 12; | ||
118 | props->max_raw_ipv6_qp = limit_uint(rblock->max_raw_ipv6_qp); | 120 | props->max_raw_ipv6_qp = limit_uint(rblock->max_raw_ipv6_qp); |
119 | props->max_raw_ethy_qp = limit_uint(rblock->max_raw_ethy_qp); | 121 | props->max_raw_ethy_qp = limit_uint(rblock->max_raw_ethy_qp); |
120 | props->max_mcast_grp = limit_uint(rblock->max_mcast_grp); | 122 | props->max_mcast_grp = limit_uint(rblock->max_mcast_grp); |
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c index 7a64aa9b51b6..cb55be04442c 100644 --- a/drivers/infiniband/hw/ehca/ehca_irq.c +++ b/drivers/infiniband/hw/ehca/ehca_irq.c | |||
@@ -178,6 +178,10 @@ static void dispatch_qp_event(struct ehca_shca *shca, struct ehca_qp *qp, | |||
178 | { | 178 | { |
179 | struct ib_event event; | 179 | struct ib_event event; |
180 | 180 | ||
181 | /* PATH_MIG without the QP ever having been armed is false alarm */ | ||
182 | if (event_type == IB_EVENT_PATH_MIG && !qp->mig_armed) | ||
183 | return; | ||
184 | |||
181 | event.device = &shca->ib_device; | 185 | event.device = &shca->ib_device; |
182 | event.event = event_type; | 186 | event.event = event_type; |
183 | 187 | ||
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c index 3f59587338ea..ea13efddf175 100644 --- a/drivers/infiniband/hw/ehca/ehca_qp.c +++ b/drivers/infiniband/hw/ehca/ehca_qp.c | |||
@@ -1460,6 +1460,8 @@ static int internal_modify_qp(struct ib_qp *ibqp, | |||
1460 | goto modify_qp_exit2; | 1460 | goto modify_qp_exit2; |
1461 | } | 1461 | } |
1462 | mqpcb->path_migration_state = attr->path_mig_state + 1; | 1462 | mqpcb->path_migration_state = attr->path_mig_state + 1; |
1463 | if (attr->path_mig_state == IB_MIG_REARM) | ||
1464 | my_qp->mig_armed = 1; | ||
1463 | update_mask |= | 1465 | update_mask |= |
1464 | EHCA_BMASK_SET(MQPCB_MASK_PATH_MIGRATION_STATE, 1); | 1466 | EHCA_BMASK_SET(MQPCB_MASK_PATH_MIGRATION_STATE, 1); |
1465 | } | 1467 | } |
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.c b/drivers/infiniband/hw/ehca/ipz_pt_fn.c index 661f8db62706..c3a328465431 100644 --- a/drivers/infiniband/hw/ehca/ipz_pt_fn.c +++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.c | |||
@@ -163,6 +163,7 @@ static int alloc_small_queue_page(struct ipz_queue *queue, struct ehca_pd *pd) | |||
163 | 163 | ||
164 | out: | 164 | out: |
165 | ehca_err(pd->ib_pd.device, "failed to allocate small queue page"); | 165 | ehca_err(pd->ib_pd.device, "failed to allocate small queue page"); |
166 | mutex_unlock(&pd->lock); | ||
166 | return 0; | 167 | return 0; |
167 | } | 168 | } |
168 | 169 | ||
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c index 299f20832ab6..0b191a4842ce 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c | |||
@@ -637,6 +637,7 @@ repoll: | |||
637 | case MLX4_OPCODE_SEND_IMM: | 637 | case MLX4_OPCODE_SEND_IMM: |
638 | wc->wc_flags |= IB_WC_WITH_IMM; | 638 | wc->wc_flags |= IB_WC_WITH_IMM; |
639 | case MLX4_OPCODE_SEND: | 639 | case MLX4_OPCODE_SEND: |
640 | case MLX4_OPCODE_SEND_INVAL: | ||
640 | wc->opcode = IB_WC_SEND; | 641 | wc->opcode = IB_WC_SEND; |
641 | break; | 642 | break; |
642 | case MLX4_OPCODE_RDMA_READ: | 643 | case MLX4_OPCODE_RDMA_READ: |
@@ -657,6 +658,12 @@ repoll: | |||
657 | case MLX4_OPCODE_LSO: | 658 | case MLX4_OPCODE_LSO: |
658 | wc->opcode = IB_WC_LSO; | 659 | wc->opcode = IB_WC_LSO; |
659 | break; | 660 | break; |
661 | case MLX4_OPCODE_FMR: | ||
662 | wc->opcode = IB_WC_FAST_REG_MR; | ||
663 | break; | ||
664 | case MLX4_OPCODE_LOCAL_INVAL: | ||
665 | wc->opcode = IB_WC_LOCAL_INV; | ||
666 | break; | ||
660 | } | 667 | } |
661 | } else { | 668 | } else { |
662 | wc->byte_len = be32_to_cpu(cqe->byte_cnt); | 669 | wc->byte_len = be32_to_cpu(cqe->byte_cnt); |
@@ -667,6 +674,11 @@ repoll: | |||
667 | wc->wc_flags = IB_WC_WITH_IMM; | 674 | wc->wc_flags = IB_WC_WITH_IMM; |
668 | wc->ex.imm_data = cqe->immed_rss_invalid; | 675 | wc->ex.imm_data = cqe->immed_rss_invalid; |
669 | break; | 676 | break; |
677 | case MLX4_RECV_OPCODE_SEND_INVAL: | ||
678 | wc->opcode = IB_WC_RECV; | ||
679 | wc->wc_flags = IB_WC_WITH_INVALIDATE; | ||
680 | wc->ex.invalidate_rkey = be32_to_cpu(cqe->immed_rss_invalid); | ||
681 | break; | ||
670 | case MLX4_RECV_OPCODE_SEND: | 682 | case MLX4_RECV_OPCODE_SEND: |
671 | wc->opcode = IB_WC_RECV; | 683 | wc->opcode = IB_WC_RECV; |
672 | wc->wc_flags = 0; | 684 | wc->wc_flags = 0; |
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index bcf50648fa18..38d6907ab521 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
@@ -104,6 +104,12 @@ static int mlx4_ib_query_device(struct ib_device *ibdev, | |||
104 | props->device_cap_flags |= IB_DEVICE_UD_IP_CSUM; | 104 | props->device_cap_flags |= IB_DEVICE_UD_IP_CSUM; |
105 | if (dev->dev->caps.max_gso_sz) | 105 | if (dev->dev->caps.max_gso_sz) |
106 | props->device_cap_flags |= IB_DEVICE_UD_TSO; | 106 | props->device_cap_flags |= IB_DEVICE_UD_TSO; |
107 | if (dev->dev->caps.bmme_flags & MLX4_BMME_FLAG_RESERVED_LKEY) | ||
108 | props->device_cap_flags |= IB_DEVICE_LOCAL_DMA_LKEY; | ||
109 | if ((dev->dev->caps.bmme_flags & MLX4_BMME_FLAG_LOCAL_INV) && | ||
110 | (dev->dev->caps.bmme_flags & MLX4_BMME_FLAG_REMOTE_INV) && | ||
111 | (dev->dev->caps.bmme_flags & MLX4_BMME_FLAG_FAST_REG_WR)) | ||
112 | props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; | ||
107 | 113 | ||
108 | props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) & | 114 | props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) & |
109 | 0xffffff; | 115 | 0xffffff; |
@@ -127,6 +133,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev, | |||
127 | props->max_srq = dev->dev->caps.num_srqs - dev->dev->caps.reserved_srqs; | 133 | props->max_srq = dev->dev->caps.num_srqs - dev->dev->caps.reserved_srqs; |
128 | props->max_srq_wr = dev->dev->caps.max_srq_wqes - 1; | 134 | props->max_srq_wr = dev->dev->caps.max_srq_wqes - 1; |
129 | props->max_srq_sge = dev->dev->caps.max_srq_sge; | 135 | props->max_srq_sge = dev->dev->caps.max_srq_sge; |
136 | props->max_fast_reg_page_list_len = PAGE_SIZE / sizeof (u64); | ||
130 | props->local_ca_ack_delay = dev->dev->caps.local_ca_ack_delay; | 137 | props->local_ca_ack_delay = dev->dev->caps.local_ca_ack_delay; |
131 | props->atomic_cap = dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_ATOMIC ? | 138 | props->atomic_cap = dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_ATOMIC ? |
132 | IB_ATOMIC_HCA : IB_ATOMIC_NONE; | 139 | IB_ATOMIC_HCA : IB_ATOMIC_NONE; |
@@ -565,6 +572,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) | |||
565 | strlcpy(ibdev->ib_dev.name, "mlx4_%d", IB_DEVICE_NAME_MAX); | 572 | strlcpy(ibdev->ib_dev.name, "mlx4_%d", IB_DEVICE_NAME_MAX); |
566 | ibdev->ib_dev.owner = THIS_MODULE; | 573 | ibdev->ib_dev.owner = THIS_MODULE; |
567 | ibdev->ib_dev.node_type = RDMA_NODE_IB_CA; | 574 | ibdev->ib_dev.node_type = RDMA_NODE_IB_CA; |
575 | ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey; | ||
568 | ibdev->ib_dev.phys_port_cnt = dev->caps.num_ports; | 576 | ibdev->ib_dev.phys_port_cnt = dev->caps.num_ports; |
569 | ibdev->ib_dev.num_comp_vectors = 1; | 577 | ibdev->ib_dev.num_comp_vectors = 1; |
570 | ibdev->ib_dev.dma_device = &dev->pdev->dev; | 578 | ibdev->ib_dev.dma_device = &dev->pdev->dev; |
@@ -627,6 +635,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) | |||
627 | ibdev->ib_dev.get_dma_mr = mlx4_ib_get_dma_mr; | 635 | ibdev->ib_dev.get_dma_mr = mlx4_ib_get_dma_mr; |
628 | ibdev->ib_dev.reg_user_mr = mlx4_ib_reg_user_mr; | 636 | ibdev->ib_dev.reg_user_mr = mlx4_ib_reg_user_mr; |
629 | ibdev->ib_dev.dereg_mr = mlx4_ib_dereg_mr; | 637 | ibdev->ib_dev.dereg_mr = mlx4_ib_dereg_mr; |
638 | ibdev->ib_dev.alloc_fast_reg_mr = mlx4_ib_alloc_fast_reg_mr; | ||
639 | ibdev->ib_dev.alloc_fast_reg_page_list = mlx4_ib_alloc_fast_reg_page_list; | ||
640 | ibdev->ib_dev.free_fast_reg_page_list = mlx4_ib_free_fast_reg_page_list; | ||
630 | ibdev->ib_dev.attach_mcast = mlx4_ib_mcg_attach; | 641 | ibdev->ib_dev.attach_mcast = mlx4_ib_mcg_attach; |
631 | ibdev->ib_dev.detach_mcast = mlx4_ib_mcg_detach; | 642 | ibdev->ib_dev.detach_mcast = mlx4_ib_mcg_detach; |
632 | ibdev->ib_dev.process_mad = mlx4_ib_process_mad; | 643 | ibdev->ib_dev.process_mad = mlx4_ib_process_mad; |
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h index c4cf5b69eefa..d26a91317d4d 100644 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h | |||
@@ -83,6 +83,11 @@ struct mlx4_ib_mr { | |||
83 | struct ib_umem *umem; | 83 | struct ib_umem *umem; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | struct mlx4_ib_fast_reg_page_list { | ||
87 | struct ib_fast_reg_page_list ibfrpl; | ||
88 | dma_addr_t map; | ||
89 | }; | ||
90 | |||
86 | struct mlx4_ib_fmr { | 91 | struct mlx4_ib_fmr { |
87 | struct ib_fmr ibfmr; | 92 | struct ib_fmr ibfmr; |
88 | struct mlx4_fmr mfmr; | 93 | struct mlx4_fmr mfmr; |
@@ -199,6 +204,11 @@ static inline struct mlx4_ib_mr *to_mmr(struct ib_mr *ibmr) | |||
199 | return container_of(ibmr, struct mlx4_ib_mr, ibmr); | 204 | return container_of(ibmr, struct mlx4_ib_mr, ibmr); |
200 | } | 205 | } |
201 | 206 | ||
207 | static inline struct mlx4_ib_fast_reg_page_list *to_mfrpl(struct ib_fast_reg_page_list *ibfrpl) | ||
208 | { | ||
209 | return container_of(ibfrpl, struct mlx4_ib_fast_reg_page_list, ibfrpl); | ||
210 | } | ||
211 | |||
202 | static inline struct mlx4_ib_fmr *to_mfmr(struct ib_fmr *ibfmr) | 212 | static inline struct mlx4_ib_fmr *to_mfmr(struct ib_fmr *ibfmr) |
203 | { | 213 | { |
204 | return container_of(ibfmr, struct mlx4_ib_fmr, ibfmr); | 214 | return container_of(ibfmr, struct mlx4_ib_fmr, ibfmr); |
@@ -239,6 +249,11 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, | |||
239 | u64 virt_addr, int access_flags, | 249 | u64 virt_addr, int access_flags, |
240 | struct ib_udata *udata); | 250 | struct ib_udata *udata); |
241 | int mlx4_ib_dereg_mr(struct ib_mr *mr); | 251 | int mlx4_ib_dereg_mr(struct ib_mr *mr); |
252 | struct ib_mr *mlx4_ib_alloc_fast_reg_mr(struct ib_pd *pd, | ||
253 | int max_page_list_len); | ||
254 | struct ib_fast_reg_page_list *mlx4_ib_alloc_fast_reg_page_list(struct ib_device *ibdev, | ||
255 | int page_list_len); | ||
256 | void mlx4_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list); | ||
242 | 257 | ||
243 | int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); | 258 | int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); |
244 | int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata); | 259 | int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata); |
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c index 68e92485fc76..db2086faa4ed 100644 --- a/drivers/infiniband/hw/mlx4/mr.c +++ b/drivers/infiniband/hw/mlx4/mr.c | |||
@@ -183,6 +183,76 @@ int mlx4_ib_dereg_mr(struct ib_mr *ibmr) | |||
183 | return 0; | 183 | return 0; |
184 | } | 184 | } |
185 | 185 | ||
186 | struct ib_mr *mlx4_ib_alloc_fast_reg_mr(struct ib_pd *pd, | ||
187 | int max_page_list_len) | ||
188 | { | ||
189 | struct mlx4_ib_dev *dev = to_mdev(pd->device); | ||
190 | struct mlx4_ib_mr *mr; | ||
191 | int err; | ||
192 | |||
193 | mr = kmalloc(sizeof *mr, GFP_KERNEL); | ||
194 | if (!mr) | ||
195 | return ERR_PTR(-ENOMEM); | ||
196 | |||
197 | err = mlx4_mr_alloc(dev->dev, to_mpd(pd)->pdn, 0, 0, 0, | ||
198 | max_page_list_len, 0, &mr->mmr); | ||
199 | if (err) | ||
200 | goto err_free; | ||
201 | |||
202 | err = mlx4_mr_enable(dev->dev, &mr->mmr); | ||
203 | if (err) | ||
204 | goto err_mr; | ||
205 | |||
206 | return &mr->ibmr; | ||
207 | |||
208 | err_mr: | ||
209 | mlx4_mr_free(dev->dev, &mr->mmr); | ||
210 | |||
211 | err_free: | ||
212 | kfree(mr); | ||
213 | return ERR_PTR(err); | ||
214 | } | ||
215 | |||
216 | struct ib_fast_reg_page_list *mlx4_ib_alloc_fast_reg_page_list(struct ib_device *ibdev, | ||
217 | int page_list_len) | ||
218 | { | ||
219 | struct mlx4_ib_dev *dev = to_mdev(ibdev); | ||
220 | struct mlx4_ib_fast_reg_page_list *mfrpl; | ||
221 | int size = page_list_len * sizeof (u64); | ||
222 | |||
223 | if (size > PAGE_SIZE) | ||
224 | return ERR_PTR(-EINVAL); | ||
225 | |||
226 | mfrpl = kmalloc(sizeof *mfrpl, GFP_KERNEL); | ||
227 | if (!mfrpl) | ||
228 | return ERR_PTR(-ENOMEM); | ||
229 | |||
230 | mfrpl->ibfrpl.page_list = dma_alloc_coherent(&dev->dev->pdev->dev, | ||
231 | size, &mfrpl->map, | ||
232 | GFP_KERNEL); | ||
233 | if (!mfrpl->ibfrpl.page_list) | ||
234 | goto err_free; | ||
235 | |||
236 | WARN_ON(mfrpl->map & 0x3f); | ||
237 | |||
238 | return &mfrpl->ibfrpl; | ||
239 | |||
240 | err_free: | ||
241 | kfree(mfrpl); | ||
242 | return ERR_PTR(-ENOMEM); | ||
243 | } | ||
244 | |||
245 | void mlx4_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list) | ||
246 | { | ||
247 | struct mlx4_ib_dev *dev = to_mdev(page_list->device); | ||
248 | struct mlx4_ib_fast_reg_page_list *mfrpl = to_mfrpl(page_list); | ||
249 | int size = page_list->max_page_list_len * sizeof (u64); | ||
250 | |||
251 | dma_free_coherent(&dev->dev->pdev->dev, size, page_list->page_list, | ||
252 | mfrpl->map); | ||
253 | kfree(mfrpl); | ||
254 | } | ||
255 | |||
186 | struct ib_fmr *mlx4_ib_fmr_alloc(struct ib_pd *pd, int acc, | 256 | struct ib_fmr *mlx4_ib_fmr_alloc(struct ib_pd *pd, int acc, |
187 | struct ib_fmr_attr *fmr_attr) | 257 | struct ib_fmr_attr *fmr_attr) |
188 | { | 258 | { |
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 89eb6cbe592e..02a99bc4442e 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c | |||
@@ -78,6 +78,9 @@ static const __be32 mlx4_ib_opcode[] = { | |||
78 | [IB_WR_RDMA_READ] = __constant_cpu_to_be32(MLX4_OPCODE_RDMA_READ), | 78 | [IB_WR_RDMA_READ] = __constant_cpu_to_be32(MLX4_OPCODE_RDMA_READ), |
79 | [IB_WR_ATOMIC_CMP_AND_SWP] = __constant_cpu_to_be32(MLX4_OPCODE_ATOMIC_CS), | 79 | [IB_WR_ATOMIC_CMP_AND_SWP] = __constant_cpu_to_be32(MLX4_OPCODE_ATOMIC_CS), |
80 | [IB_WR_ATOMIC_FETCH_AND_ADD] = __constant_cpu_to_be32(MLX4_OPCODE_ATOMIC_FA), | 80 | [IB_WR_ATOMIC_FETCH_AND_ADD] = __constant_cpu_to_be32(MLX4_OPCODE_ATOMIC_FA), |
81 | [IB_WR_SEND_WITH_INV] = __constant_cpu_to_be32(MLX4_OPCODE_SEND_INVAL), | ||
82 | [IB_WR_LOCAL_INV] = __constant_cpu_to_be32(MLX4_OPCODE_LOCAL_INVAL), | ||
83 | [IB_WR_FAST_REG_MR] = __constant_cpu_to_be32(MLX4_OPCODE_FMR), | ||
81 | }; | 84 | }; |
82 | 85 | ||
83 | static struct mlx4_ib_sqp *to_msqp(struct mlx4_ib_qp *mqp) | 86 | static struct mlx4_ib_sqp *to_msqp(struct mlx4_ib_qp *mqp) |
@@ -976,6 +979,10 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp, | |||
976 | context->pd = cpu_to_be32(to_mpd(ibqp->pd)->pdn); | 979 | context->pd = cpu_to_be32(to_mpd(ibqp->pd)->pdn); |
977 | context->params1 = cpu_to_be32(MLX4_IB_ACK_REQ_FREQ << 28); | 980 | context->params1 = cpu_to_be32(MLX4_IB_ACK_REQ_FREQ << 28); |
978 | 981 | ||
982 | /* Set "fast registration enabled" for all kernel QPs */ | ||
983 | if (!qp->ibqp.uobject) | ||
984 | context->params1 |= cpu_to_be32(1 << 11); | ||
985 | |||
979 | if (attr_mask & IB_QP_RNR_RETRY) { | 986 | if (attr_mask & IB_QP_RNR_RETRY) { |
980 | context->params1 |= cpu_to_be32(attr->rnr_retry << 13); | 987 | context->params1 |= cpu_to_be32(attr->rnr_retry << 13); |
981 | optpar |= MLX4_QP_OPTPAR_RNR_RETRY; | 988 | optpar |= MLX4_QP_OPTPAR_RNR_RETRY; |
@@ -1322,6 +1329,38 @@ static int mlx4_wq_overflow(struct mlx4_ib_wq *wq, int nreq, struct ib_cq *ib_cq | |||
1322 | return cur + nreq >= wq->max_post; | 1329 | return cur + nreq >= wq->max_post; |
1323 | } | 1330 | } |
1324 | 1331 | ||
1332 | static __be32 convert_access(int acc) | ||
1333 | { | ||
1334 | return (acc & IB_ACCESS_REMOTE_ATOMIC ? cpu_to_be32(MLX4_WQE_FMR_PERM_ATOMIC) : 0) | | ||
1335 | (acc & IB_ACCESS_REMOTE_WRITE ? cpu_to_be32(MLX4_WQE_FMR_PERM_REMOTE_WRITE) : 0) | | ||
1336 | (acc & IB_ACCESS_REMOTE_READ ? cpu_to_be32(MLX4_WQE_FMR_PERM_REMOTE_READ) : 0) | | ||
1337 | (acc & IB_ACCESS_LOCAL_WRITE ? cpu_to_be32(MLX4_WQE_FMR_PERM_LOCAL_WRITE) : 0) | | ||
1338 | cpu_to_be32(MLX4_WQE_FMR_PERM_LOCAL_READ); | ||
1339 | } | ||
1340 | |||
1341 | static void set_fmr_seg(struct mlx4_wqe_fmr_seg *fseg, struct ib_send_wr *wr) | ||
1342 | { | ||
1343 | struct mlx4_ib_fast_reg_page_list *mfrpl = to_mfrpl(wr->wr.fast_reg.page_list); | ||
1344 | |||
1345 | fseg->flags = convert_access(wr->wr.fast_reg.access_flags); | ||
1346 | fseg->mem_key = cpu_to_be32(wr->wr.fast_reg.rkey); | ||
1347 | fseg->buf_list = cpu_to_be64(mfrpl->map); | ||
1348 | fseg->start_addr = cpu_to_be64(wr->wr.fast_reg.iova_start); | ||
1349 | fseg->reg_len = cpu_to_be64(wr->wr.fast_reg.length); | ||
1350 | fseg->offset = 0; /* XXX -- is this just for ZBVA? */ | ||
1351 | fseg->page_size = cpu_to_be32(wr->wr.fast_reg.page_shift); | ||
1352 | fseg->reserved[0] = 0; | ||
1353 | fseg->reserved[1] = 0; | ||
1354 | } | ||
1355 | |||
1356 | static void set_local_inv_seg(struct mlx4_wqe_local_inval_seg *iseg, u32 rkey) | ||
1357 | { | ||
1358 | iseg->flags = 0; | ||
1359 | iseg->mem_key = cpu_to_be32(rkey); | ||
1360 | iseg->guest_id = 0; | ||
1361 | iseg->pa = 0; | ||
1362 | } | ||
1363 | |||
1325 | static __always_inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg, | 1364 | static __always_inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg, |
1326 | u64 remote_addr, u32 rkey) | 1365 | u64 remote_addr, u32 rkey) |
1327 | { | 1366 | { |
@@ -1395,7 +1434,7 @@ static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ib_sge *sg) | |||
1395 | dseg->addr = cpu_to_be64(sg->addr); | 1434 | dseg->addr = cpu_to_be64(sg->addr); |
1396 | } | 1435 | } |
1397 | 1436 | ||
1398 | static int build_lso_seg(struct mlx4_lso_seg *wqe, struct ib_send_wr *wr, | 1437 | static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_send_wr *wr, |
1399 | struct mlx4_ib_qp *qp, unsigned *lso_seg_len) | 1438 | struct mlx4_ib_qp *qp, unsigned *lso_seg_len) |
1400 | { | 1439 | { |
1401 | unsigned halign = ALIGN(sizeof *wqe + wr->wr.ud.hlen, 16); | 1440 | unsigned halign = ALIGN(sizeof *wqe + wr->wr.ud.hlen, 16); |
@@ -1423,6 +1462,21 @@ static int build_lso_seg(struct mlx4_lso_seg *wqe, struct ib_send_wr *wr, | |||
1423 | return 0; | 1462 | return 0; |
1424 | } | 1463 | } |
1425 | 1464 | ||
1465 | static __be32 send_ieth(struct ib_send_wr *wr) | ||
1466 | { | ||
1467 | switch (wr->opcode) { | ||
1468 | case IB_WR_SEND_WITH_IMM: | ||
1469 | case IB_WR_RDMA_WRITE_WITH_IMM: | ||
1470 | return wr->ex.imm_data; | ||
1471 | |||
1472 | case IB_WR_SEND_WITH_INV: | ||
1473 | return cpu_to_be32(wr->ex.invalidate_rkey); | ||
1474 | |||
1475 | default: | ||
1476 | return 0; | ||
1477 | } | ||
1478 | } | ||
1479 | |||
1426 | int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | 1480 | int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, |
1427 | struct ib_send_wr **bad_wr) | 1481 | struct ib_send_wr **bad_wr) |
1428 | { | 1482 | { |
@@ -1469,11 +1523,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1469 | MLX4_WQE_CTRL_TCP_UDP_CSUM) : 0) | | 1523 | MLX4_WQE_CTRL_TCP_UDP_CSUM) : 0) | |
1470 | qp->sq_signal_bits; | 1524 | qp->sq_signal_bits; |
1471 | 1525 | ||
1472 | if (wr->opcode == IB_WR_SEND_WITH_IMM || | 1526 | ctrl->imm = send_ieth(wr); |
1473 | wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) | ||
1474 | ctrl->imm = wr->ex.imm_data; | ||
1475 | else | ||
1476 | ctrl->imm = 0; | ||
1477 | 1527 | ||
1478 | wqe += sizeof *ctrl; | 1528 | wqe += sizeof *ctrl; |
1479 | size = sizeof *ctrl / 16; | 1529 | size = sizeof *ctrl / 16; |
@@ -1505,6 +1555,18 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
1505 | size += sizeof (struct mlx4_wqe_raddr_seg) / 16; | 1555 | size += sizeof (struct mlx4_wqe_raddr_seg) / 16; |
1506 | break; | 1556 | break; |
1507 | 1557 | ||
1558 | case IB_WR_LOCAL_INV: | ||
1559 | set_local_inv_seg(wqe, wr->ex.invalidate_rkey); | ||
1560 | wqe += sizeof (struct mlx4_wqe_local_inval_seg); | ||
1561 | size += sizeof (struct mlx4_wqe_local_inval_seg) / 16; | ||
1562 | break; | ||
1563 | |||
1564 | case IB_WR_FAST_REG_MR: | ||
1565 | set_fmr_seg(wqe, wr); | ||
1566 | wqe += sizeof (struct mlx4_wqe_fmr_seg); | ||
1567 | size += sizeof (struct mlx4_wqe_fmr_seg) / 16; | ||
1568 | break; | ||
1569 | |||
1508 | default: | 1570 | default: |
1509 | /* No extra segments required for sends */ | 1571 | /* No extra segments required for sends */ |
1510 | break; | 1572 | break; |
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index ee4d073c889f..252590116df5 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h | |||
@@ -202,6 +202,7 @@ struct mthca_pd_table { | |||
202 | 202 | ||
203 | struct mthca_buddy { | 203 | struct mthca_buddy { |
204 | unsigned long **bits; | 204 | unsigned long **bits; |
205 | int *num_free; | ||
205 | int max_order; | 206 | int max_order; |
206 | spinlock_t lock; | 207 | spinlock_t lock; |
207 | }; | 208 | }; |
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c index 8489b1e81c0f..882e6b735915 100644 --- a/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/drivers/infiniband/hw/mthca/mthca_mr.c | |||
@@ -89,23 +89,26 @@ static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order) | |||
89 | 89 | ||
90 | spin_lock(&buddy->lock); | 90 | spin_lock(&buddy->lock); |
91 | 91 | ||
92 | for (o = order; o <= buddy->max_order; ++o) { | 92 | for (o = order; o <= buddy->max_order; ++o) |
93 | m = 1 << (buddy->max_order - o); | 93 | if (buddy->num_free[o]) { |
94 | seg = find_first_bit(buddy->bits[o], m); | 94 | m = 1 << (buddy->max_order - o); |
95 | if (seg < m) | 95 | seg = find_first_bit(buddy->bits[o], m); |
96 | goto found; | 96 | if (seg < m) |
97 | } | 97 | goto found; |
98 | } | ||
98 | 99 | ||
99 | spin_unlock(&buddy->lock); | 100 | spin_unlock(&buddy->lock); |
100 | return -1; | 101 | return -1; |
101 | 102 | ||
102 | found: | 103 | found: |
103 | clear_bit(seg, buddy->bits[o]); | 104 | clear_bit(seg, buddy->bits[o]); |
105 | --buddy->num_free[o]; | ||
104 | 106 | ||
105 | while (o > order) { | 107 | while (o > order) { |
106 | --o; | 108 | --o; |
107 | seg <<= 1; | 109 | seg <<= 1; |
108 | set_bit(seg ^ 1, buddy->bits[o]); | 110 | set_bit(seg ^ 1, buddy->bits[o]); |
111 | ++buddy->num_free[o]; | ||
109 | } | 112 | } |
110 | 113 | ||
111 | spin_unlock(&buddy->lock); | 114 | spin_unlock(&buddy->lock); |
@@ -123,11 +126,13 @@ static void mthca_buddy_free(struct mthca_buddy *buddy, u32 seg, int order) | |||
123 | 126 | ||
124 | while (test_bit(seg ^ 1, buddy->bits[order])) { | 127 | while (test_bit(seg ^ 1, buddy->bits[order])) { |
125 | clear_bit(seg ^ 1, buddy->bits[order]); | 128 | clear_bit(seg ^ 1, buddy->bits[order]); |
129 | --buddy->num_free[order]; | ||
126 | seg >>= 1; | 130 | seg >>= 1; |
127 | ++order; | 131 | ++order; |
128 | } | 132 | } |
129 | 133 | ||
130 | set_bit(seg, buddy->bits[order]); | 134 | set_bit(seg, buddy->bits[order]); |
135 | ++buddy->num_free[order]; | ||
131 | 136 | ||
132 | spin_unlock(&buddy->lock); | 137 | spin_unlock(&buddy->lock); |
133 | } | 138 | } |
@@ -141,7 +146,9 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order) | |||
141 | 146 | ||
142 | buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *), | 147 | buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *), |
143 | GFP_KERNEL); | 148 | GFP_KERNEL); |
144 | if (!buddy->bits) | 149 | buddy->num_free = kzalloc((buddy->max_order + 1) * sizeof (int *), |
150 | GFP_KERNEL); | ||
151 | if (!buddy->bits || !buddy->num_free) | ||
145 | goto err_out; | 152 | goto err_out; |
146 | 153 | ||
147 | for (i = 0; i <= buddy->max_order; ++i) { | 154 | for (i = 0; i <= buddy->max_order; ++i) { |
@@ -154,6 +161,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order) | |||
154 | } | 161 | } |
155 | 162 | ||
156 | set_bit(0, buddy->bits[buddy->max_order]); | 163 | set_bit(0, buddy->bits[buddy->max_order]); |
164 | buddy->num_free[buddy->max_order] = 1; | ||
157 | 165 | ||
158 | return 0; | 166 | return 0; |
159 | 167 | ||
@@ -161,9 +169,10 @@ err_out_free: | |||
161 | for (i = 0; i <= buddy->max_order; ++i) | 169 | for (i = 0; i <= buddy->max_order; ++i) |
162 | kfree(buddy->bits[i]); | 170 | kfree(buddy->bits[i]); |
163 | 171 | ||
172 | err_out: | ||
164 | kfree(buddy->bits); | 173 | kfree(buddy->bits); |
174 | kfree(buddy->num_free); | ||
165 | 175 | ||
166 | err_out: | ||
167 | return -ENOMEM; | 176 | return -ENOMEM; |
168 | } | 177 | } |
169 | 178 | ||
@@ -175,6 +184,7 @@ static void mthca_buddy_cleanup(struct mthca_buddy *buddy) | |||
175 | kfree(buddy->bits[i]); | 184 | kfree(buddy->bits[i]); |
176 | 185 | ||
177 | kfree(buddy->bits); | 186 | kfree(buddy->bits); |
187 | kfree(buddy->num_free); | ||
178 | } | 188 | } |
179 | 189 | ||
180 | static u32 mthca_alloc_mtt_range(struct mthca_dev *dev, int order, | 190 | static u32 mthca_alloc_mtt_range(struct mthca_dev *dev, int order, |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 8be9ea0436e6..f51201b17bfd 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -548,7 +548,7 @@ static int path_rec_start(struct net_device *dev, | |||
548 | path_rec_completion, | 548 | path_rec_completion, |
549 | path, &path->query); | 549 | path, &path->query); |
550 | if (path->query_id < 0) { | 550 | if (path->query_id < 0) { |
551 | ipoib_warn(priv, "ib_sa_path_rec_get failed\n"); | 551 | ipoib_warn(priv, "ib_sa_path_rec_get failed: %d\n", path->query_id); |
552 | path->query = NULL; | 552 | path->query = NULL; |
553 | return path->query_id; | 553 | return path->query_id; |
554 | } | 554 | } |
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 3a917c1f796f..63462ecca147 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -483,6 +483,7 @@ static int iser_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *eve | |||
483 | break; | 483 | break; |
484 | case RDMA_CM_EVENT_DISCONNECTED: | 484 | case RDMA_CM_EVENT_DISCONNECTED: |
485 | case RDMA_CM_EVENT_DEVICE_REMOVAL: | 485 | case RDMA_CM_EVENT_DEVICE_REMOVAL: |
486 | case RDMA_CM_EVENT_ADDR_CHANGE: | ||
486 | iser_disconnected_handler(cma_id); | 487 | iser_disconnected_handler(cma_id); |
487 | break; | 488 | break; |
488 | default: | 489 | default: |
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index adbf29f0169d..71c1971abf80 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/semaphore.h> | ||
40 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
41 | #include <linux/pci_ids.h> | 42 | #include <linux/pci_ids.h> |
42 | 43 | ||
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index 49d8abfe38fe..daa9d4220331 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/proc_fs.h> | 44 | #include <linux/proc_fs.h> |
45 | #include <linux/poll.h> | 45 | #include <linux/poll.h> |
46 | #include <linux/rtc.h> | 46 | #include <linux/rtc.h> |
47 | #include <linux/semaphore.h> | ||
47 | 48 | ||
48 | MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); | 49 | MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); |
49 | MODULE_DESCRIPTION("HP i8042 SDC + MSM-58321 RTC Driver"); | 50 | MODULE_DESCRIPTION("HP i8042 SDC + MSM-58321 RTC Driver"); |
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 7b233a492ad5..0d395979b2d1 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c | |||
@@ -67,9 +67,9 @@ | |||
67 | #include <linux/module.h> | 67 | #include <linux/module.h> |
68 | #include <linux/ioport.h> | 68 | #include <linux/ioport.h> |
69 | #include <linux/time.h> | 69 | #include <linux/time.h> |
70 | #include <linux/semaphore.h> | ||
70 | #include <linux/slab.h> | 71 | #include <linux/slab.h> |
71 | #include <linux/hil.h> | 72 | #include <linux/hil.h> |
72 | #include <linux/semaphore.h> | ||
73 | #include <asm/io.h> | 73 | #include <asm/io.h> |
74 | #include <asm/system.h> | 74 | #include <asm/system.h> |
75 | 75 | ||
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c index 091deb9d1c47..c2bd97d29273 100644 --- a/drivers/isdn/gigaset/asyncdata.c +++ b/drivers/isdn/gigaset/asyncdata.c | |||
@@ -575,7 +575,8 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb) | |||
575 | else | 575 | else |
576 | skb = iraw_encode(skb, HW_HDR_LEN, 0); | 576 | skb = iraw_encode(skb, HW_HDR_LEN, 0); |
577 | if (!skb) { | 577 | if (!skb) { |
578 | err("unable to allocate memory for encoding!\n"); | 578 | dev_err(bcs->cs->dev, |
579 | "unable to allocate memory for encoding!\n"); | ||
579 | return -ENOMEM; | 580 | return -ENOMEM; |
580 | } | 581 | } |
581 | 582 | ||
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c index 5255b5e20e13..3f11910c7ccd 100644 --- a/drivers/isdn/gigaset/bas-gigaset.c +++ b/drivers/isdn/gigaset/bas-gigaset.c | |||
@@ -1050,10 +1050,9 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) | |||
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | /* retrieve block of data to send */ | 1052 | /* retrieve block of data to send */ |
1053 | ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf, | 1053 | rc = gigaset_isowbuf_getbytes(ubc->isooutbuf, ifd->length); |
1054 | ifd->length); | 1054 | if (rc < 0) { |
1055 | if (ifd->offset < 0) { | 1055 | if (rc == -EBUSY) { |
1056 | if (ifd->offset == -EBUSY) { | ||
1057 | gig_dbg(DEBUG_ISO, | 1056 | gig_dbg(DEBUG_ISO, |
1058 | "%s: buffer busy at frame %d", | 1057 | "%s: buffer busy at frame %d", |
1059 | __func__, nframe); | 1058 | __func__, nframe); |
@@ -1062,11 +1061,12 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) | |||
1062 | } else { | 1061 | } else { |
1063 | dev_err(ucx->bcs->cs->dev, | 1062 | dev_err(ucx->bcs->cs->dev, |
1064 | "%s: buffer error %d at frame %d\n", | 1063 | "%s: buffer error %d at frame %d\n", |
1065 | __func__, ifd->offset, nframe); | 1064 | __func__, rc, nframe); |
1066 | return ifd->offset; | 1065 | return rc; |
1067 | } | 1066 | } |
1068 | break; | 1067 | break; |
1069 | } | 1068 | } |
1069 | ifd->offset = rc; | ||
1070 | ucx->limit = ubc->isooutbuf->nextread; | 1070 | ucx->limit = ubc->isooutbuf->nextread; |
1071 | ifd->status = 0; | 1071 | ifd->status = 0; |
1072 | ifd->actual_length = 0; | 1072 | ifd->actual_length = 0; |
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index 827c32c16795..9d3ce7718e58 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -287,7 +287,7 @@ struct event_t *gigaset_add_event(struct cardstate *cs, | |||
287 | tail = cs->ev_tail; | 287 | tail = cs->ev_tail; |
288 | next = (tail + 1) % MAX_EVENTS; | 288 | next = (tail + 1) % MAX_EVENTS; |
289 | if (unlikely(next == cs->ev_head)) | 289 | if (unlikely(next == cs->ev_head)) |
290 | err("event queue full"); | 290 | dev_err(cs->dev, "event queue full\n"); |
291 | else { | 291 | else { |
292 | event = cs->events + tail; | 292 | event = cs->events + tail; |
293 | event->type = type; | 293 | event->type = type; |
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h index f365993161fc..003752954993 100644 --- a/drivers/isdn/gigaset/gigaset.h +++ b/drivers/isdn/gigaset/gigaset.h | |||
@@ -106,7 +106,6 @@ enum debuglevel { | |||
106 | #undef err | 106 | #undef err |
107 | #undef info | 107 | #undef info |
108 | #undef warn | 108 | #undef warn |
109 | #undef notice | ||
110 | 109 | ||
111 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ | 110 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ |
112 | format "\n" , ## arg) | 111 | format "\n" , ## arg) |
@@ -114,8 +113,6 @@ enum debuglevel { | |||
114 | format "\n" , ## arg) | 113 | format "\n" , ## arg) |
115 | #define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \ | 114 | #define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \ |
116 | format "\n" , ## arg) | 115 | format "\n" , ## arg) |
117 | #define notice(format, arg...) printk(KERN_NOTICE KBUILD_MODNAME ": " \ | ||
118 | format "\n" , ## arg) | ||
119 | 116 | ||
120 | #ifdef CONFIG_GIGASET_DEBUG | 117 | #ifdef CONFIG_GIGASET_DEBUG |
121 | 118 | ||
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c index 9e089f06a942..3c127a8cbaf2 100644 --- a/drivers/isdn/gigaset/i4l.c +++ b/drivers/isdn/gigaset/i4l.c | |||
@@ -46,7 +46,8 @@ static int writebuf_from_LL(int driverID, int channel, int ack, | |||
46 | return -ENODEV; | 46 | return -ENODEV; |
47 | } | 47 | } |
48 | if (channel < 0 || channel >= cs->channels) { | 48 | if (channel < 0 || channel >= cs->channels) { |
49 | err("%s: invalid channel ID (%d)", __func__, channel); | 49 | dev_err(cs->dev, "%s: invalid channel ID (%d)\n", |
50 | __func__, channel); | ||
50 | return -ENODEV; | 51 | return -ENODEV; |
51 | } | 52 | } |
52 | bcs = &cs->bcs[channel]; | 53 | bcs = &cs->bcs[channel]; |
@@ -58,11 +59,13 @@ static int writebuf_from_LL(int driverID, int channel, int ack, | |||
58 | 59 | ||
59 | if (!len) { | 60 | if (!len) { |
60 | if (ack) | 61 | if (ack) |
61 | notice("%s: not ACKing empty packet", __func__); | 62 | dev_notice(cs->dev, "%s: not ACKing empty packet\n", |
63 | __func__); | ||
62 | return 0; | 64 | return 0; |
63 | } | 65 | } |
64 | if (len > MAX_BUF_SIZE) { | 66 | if (len > MAX_BUF_SIZE) { |
65 | err("%s: packet too large (%d bytes)", __func__, len); | 67 | dev_err(cs->dev, "%s: packet too large (%d bytes)\n", |
68 | __func__, len); | ||
66 | return -EINVAL; | 69 | return -EINVAL; |
67 | } | 70 | } |
68 | 71 | ||
@@ -116,8 +119,7 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
116 | gigaset_debugdrivers(); | 119 | gigaset_debugdrivers(); |
117 | 120 | ||
118 | if (!cs) { | 121 | if (!cs) { |
119 | warn("LL tried to access unknown device with nr. %d", | 122 | err("%s: invalid driver ID (%d)", __func__, cntrl->driver); |
120 | cntrl->driver); | ||
121 | return -ENODEV; | 123 | return -ENODEV; |
122 | } | 124 | } |
123 | 125 | ||
@@ -126,7 +128,7 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
126 | gig_dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver: %d, arg: %ld)", | 128 | gig_dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver: %d, arg: %ld)", |
127 | cntrl->driver, cntrl->arg); | 129 | cntrl->driver, cntrl->arg); |
128 | 130 | ||
129 | warn("ISDN_CMD_IOCTL is not supported."); | 131 | dev_warn(cs->dev, "ISDN_CMD_IOCTL not supported\n"); |
130 | return -EINVAL; | 132 | return -EINVAL; |
131 | 133 | ||
132 | case ISDN_CMD_DIAL: | 134 | case ISDN_CMD_DIAL: |
@@ -138,22 +140,23 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
138 | cntrl->parm.setup.si1, cntrl->parm.setup.si2); | 140 | cntrl->parm.setup.si1, cntrl->parm.setup.si2); |
139 | 141 | ||
140 | if (cntrl->arg >= cs->channels) { | 142 | if (cntrl->arg >= cs->channels) { |
141 | err("ISDN_CMD_DIAL: invalid channel (%d)", | 143 | dev_err(cs->dev, |
142 | (int) cntrl->arg); | 144 | "ISDN_CMD_DIAL: invalid channel (%d)\n", |
145 | (int) cntrl->arg); | ||
143 | return -EINVAL; | 146 | return -EINVAL; |
144 | } | 147 | } |
145 | 148 | ||
146 | bcs = cs->bcs + cntrl->arg; | 149 | bcs = cs->bcs + cntrl->arg; |
147 | 150 | ||
148 | if (!gigaset_get_channel(bcs)) { | 151 | if (!gigaset_get_channel(bcs)) { |
149 | err("ISDN_CMD_DIAL: channel not free"); | 152 | dev_err(cs->dev, "ISDN_CMD_DIAL: channel not free\n"); |
150 | return -EBUSY; | 153 | return -EBUSY; |
151 | } | 154 | } |
152 | 155 | ||
153 | sp = kmalloc(sizeof *sp, GFP_ATOMIC); | 156 | sp = kmalloc(sizeof *sp, GFP_ATOMIC); |
154 | if (!sp) { | 157 | if (!sp) { |
155 | gigaset_free_channel(bcs); | 158 | gigaset_free_channel(bcs); |
156 | err("ISDN_CMD_DIAL: out of memory"); | 159 | dev_err(cs->dev, "ISDN_CMD_DIAL: out of memory\n"); |
157 | return -ENOMEM; | 160 | return -ENOMEM; |
158 | } | 161 | } |
159 | *sp = cntrl->parm.setup; | 162 | *sp = cntrl->parm.setup; |
@@ -173,8 +176,9 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
173 | gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD"); | 176 | gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD"); |
174 | 177 | ||
175 | if (cntrl->arg >= cs->channels) { | 178 | if (cntrl->arg >= cs->channels) { |
176 | err("ISDN_CMD_ACCEPTD: invalid channel (%d)", | 179 | dev_err(cs->dev, |
177 | (int) cntrl->arg); | 180 | "ISDN_CMD_ACCEPTD: invalid channel (%d)\n", |
181 | (int) cntrl->arg); | ||
178 | return -EINVAL; | 182 | return -EINVAL; |
179 | } | 183 | } |
180 | 184 | ||
@@ -196,8 +200,9 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
196 | (int) cntrl->arg); | 200 | (int) cntrl->arg); |
197 | 201 | ||
198 | if (cntrl->arg >= cs->channels) { | 202 | if (cntrl->arg >= cs->channels) { |
199 | err("ISDN_CMD_HANGUP: invalid channel (%u)", | 203 | dev_err(cs->dev, |
200 | (unsigned) cntrl->arg); | 204 | "ISDN_CMD_HANGUP: invalid channel (%d)\n", |
205 | (int) cntrl->arg); | ||
201 | return -EINVAL; | 206 | return -EINVAL; |
202 | } | 207 | } |
203 | 208 | ||
@@ -224,8 +229,9 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
224 | cntrl->arg & 0xff, (cntrl->arg >> 8)); | 229 | cntrl->arg & 0xff, (cntrl->arg >> 8)); |
225 | 230 | ||
226 | if ((cntrl->arg & 0xff) >= cs->channels) { | 231 | if ((cntrl->arg & 0xff) >= cs->channels) { |
227 | err("ISDN_CMD_SETL2: invalid channel (%u)", | 232 | dev_err(cs->dev, |
228 | (unsigned) cntrl->arg & 0xff); | 233 | "ISDN_CMD_SETL2: invalid channel (%d)\n", |
234 | (int) cntrl->arg & 0xff); | ||
229 | return -EINVAL; | 235 | return -EINVAL; |
230 | } | 236 | } |
231 | 237 | ||
@@ -244,14 +250,16 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
244 | cntrl->arg & 0xff, (cntrl->arg >> 8)); | 250 | cntrl->arg & 0xff, (cntrl->arg >> 8)); |
245 | 251 | ||
246 | if ((cntrl->arg & 0xff) >= cs->channels) { | 252 | if ((cntrl->arg & 0xff) >= cs->channels) { |
247 | err("ISDN_CMD_SETL3: invalid channel (%u)", | 253 | dev_err(cs->dev, |
248 | (unsigned) cntrl->arg & 0xff); | 254 | "ISDN_CMD_SETL3: invalid channel (%d)\n", |
255 | (int) cntrl->arg & 0xff); | ||
249 | return -EINVAL; | 256 | return -EINVAL; |
250 | } | 257 | } |
251 | 258 | ||
252 | if (cntrl->arg >> 8 != ISDN_PROTO_L3_TRANS) { | 259 | if (cntrl->arg >> 8 != ISDN_PROTO_L3_TRANS) { |
253 | err("ISDN_CMD_SETL3: invalid protocol %lu", | 260 | dev_err(cs->dev, |
254 | cntrl->arg >> 8); | 261 | "ISDN_CMD_SETL3: invalid protocol %lu\n", |
262 | cntrl->arg >> 8); | ||
255 | return -EINVAL; | 263 | return -EINVAL; |
256 | } | 264 | } |
257 | 265 | ||
@@ -262,8 +270,9 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
262 | case ISDN_CMD_ALERT: | 270 | case ISDN_CMD_ALERT: |
263 | gig_dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME | 271 | gig_dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME |
264 | if (cntrl->arg >= cs->channels) { | 272 | if (cntrl->arg >= cs->channels) { |
265 | err("ISDN_CMD_ALERT: invalid channel (%d)", | 273 | dev_err(cs->dev, |
266 | (int) cntrl->arg); | 274 | "ISDN_CMD_ALERT: invalid channel (%d)\n", |
275 | (int) cntrl->arg); | ||
267 | return -EINVAL; | 276 | return -EINVAL; |
268 | } | 277 | } |
269 | //bcs = cs->bcs + cntrl->arg; | 278 | //bcs = cs->bcs + cntrl->arg; |
@@ -295,7 +304,8 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
295 | gig_dbg(DEBUG_ANY, "ISDN_CMD_GETSIL"); | 304 | gig_dbg(DEBUG_ANY, "ISDN_CMD_GETSIL"); |
296 | break; | 305 | break; |
297 | default: | 306 | default: |
298 | err("unknown command %d from LL", cntrl->command); | 307 | dev_err(cs->dev, "unknown command %d from LL\n", |
308 | cntrl->command); | ||
299 | return -EINVAL; | 309 | return -EINVAL; |
300 | } | 310 | } |
301 | 311 | ||
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index af195b07c191..521951a898ec 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c | |||
@@ -197,7 +197,7 @@ static void if_close(struct tty_struct *tty, struct file *filp) | |||
197 | mutex_lock(&cs->mutex); | 197 | mutex_lock(&cs->mutex); |
198 | 198 | ||
199 | if (!cs->open_count) | 199 | if (!cs->open_count) |
200 | warn("%s: device not opened", __func__); | 200 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
201 | else { | 201 | else { |
202 | if (!--cs->open_count) { | 202 | if (!--cs->open_count) { |
203 | spin_lock_irqsave(&cs->lock, flags); | 203 | spin_lock_irqsave(&cs->lock, flags); |
@@ -232,7 +232,7 @@ static int if_ioctl(struct tty_struct *tty, struct file *file, | |||
232 | return -ERESTARTSYS; // FIXME -EINTR? | 232 | return -ERESTARTSYS; // FIXME -EINTR? |
233 | 233 | ||
234 | if (!cs->open_count) | 234 | if (!cs->open_count) |
235 | warn("%s: device not opened", __func__); | 235 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
236 | else { | 236 | else { |
237 | retval = 0; | 237 | retval = 0; |
238 | switch (cmd) { | 238 | switch (cmd) { |
@@ -364,9 +364,9 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count) | |||
364 | return -ERESTARTSYS; // FIXME -EINTR? | 364 | return -ERESTARTSYS; // FIXME -EINTR? |
365 | 365 | ||
366 | if (!cs->open_count) | 366 | if (!cs->open_count) |
367 | warn("%s: device not opened", __func__); | 367 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
368 | else if (cs->mstate != MS_LOCKED) { | 368 | else if (cs->mstate != MS_LOCKED) { |
369 | warn("can't write to unlocked device"); | 369 | dev_warn(cs->dev, "can't write to unlocked device\n"); |
370 | retval = -EBUSY; | 370 | retval = -EBUSY; |
371 | } else if (!cs->connected) { | 371 | } else if (!cs->connected) { |
372 | gig_dbg(DEBUG_ANY, "can't write to unplugged device"); | 372 | gig_dbg(DEBUG_ANY, "can't write to unplugged device"); |
@@ -398,9 +398,9 @@ static int if_write_room(struct tty_struct *tty) | |||
398 | return -ERESTARTSYS; // FIXME -EINTR? | 398 | return -ERESTARTSYS; // FIXME -EINTR? |
399 | 399 | ||
400 | if (!cs->open_count) | 400 | if (!cs->open_count) |
401 | warn("%s: device not opened", __func__); | 401 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
402 | else if (cs->mstate != MS_LOCKED) { | 402 | else if (cs->mstate != MS_LOCKED) { |
403 | warn("can't write to unlocked device"); | 403 | dev_warn(cs->dev, "can't write to unlocked device\n"); |
404 | retval = -EBUSY; | 404 | retval = -EBUSY; |
405 | } else if (!cs->connected) { | 405 | } else if (!cs->connected) { |
406 | gig_dbg(DEBUG_ANY, "can't write to unplugged device"); | 406 | gig_dbg(DEBUG_ANY, "can't write to unplugged device"); |
@@ -430,9 +430,9 @@ static int if_chars_in_buffer(struct tty_struct *tty) | |||
430 | return -ERESTARTSYS; // FIXME -EINTR? | 430 | return -ERESTARTSYS; // FIXME -EINTR? |
431 | 431 | ||
432 | if (!cs->open_count) | 432 | if (!cs->open_count) |
433 | warn("%s: device not opened", __func__); | 433 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
434 | else if (cs->mstate != MS_LOCKED) { | 434 | else if (cs->mstate != MS_LOCKED) { |
435 | warn("can't write to unlocked device"); | 435 | dev_warn(cs->dev, "can't write to unlocked device\n"); |
436 | retval = -EBUSY; | 436 | retval = -EBUSY; |
437 | } else if (!cs->connected) { | 437 | } else if (!cs->connected) { |
438 | gig_dbg(DEBUG_ANY, "can't write to unplugged device"); | 438 | gig_dbg(DEBUG_ANY, "can't write to unplugged device"); |
@@ -460,7 +460,7 @@ static void if_throttle(struct tty_struct *tty) | |||
460 | mutex_lock(&cs->mutex); | 460 | mutex_lock(&cs->mutex); |
461 | 461 | ||
462 | if (!cs->open_count) | 462 | if (!cs->open_count) |
463 | warn("%s: device not opened", __func__); | 463 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
464 | else { | 464 | else { |
465 | //FIXME | 465 | //FIXME |
466 | } | 466 | } |
@@ -483,7 +483,7 @@ static void if_unthrottle(struct tty_struct *tty) | |||
483 | mutex_lock(&cs->mutex); | 483 | mutex_lock(&cs->mutex); |
484 | 484 | ||
485 | if (!cs->open_count) | 485 | if (!cs->open_count) |
486 | warn("%s: device not opened", __func__); | 486 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
487 | else { | 487 | else { |
488 | //FIXME | 488 | //FIXME |
489 | } | 489 | } |
@@ -510,7 +510,7 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
510 | mutex_lock(&cs->mutex); | 510 | mutex_lock(&cs->mutex); |
511 | 511 | ||
512 | if (!cs->open_count) { | 512 | if (!cs->open_count) { |
513 | warn("%s: device not opened", __func__); | 513 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
514 | goto out; | 514 | goto out; |
515 | } | 515 | } |
516 | 516 | ||
@@ -623,7 +623,8 @@ void gigaset_if_init(struct cardstate *cs) | |||
623 | if (!IS_ERR(cs->tty_dev)) | 623 | if (!IS_ERR(cs->tty_dev)) |
624 | dev_set_drvdata(cs->tty_dev, cs); | 624 | dev_set_drvdata(cs->tty_dev, cs); |
625 | else { | 625 | else { |
626 | warn("could not register device to the tty subsystem"); | 626 | dev_warn(cs->dev, |
627 | "could not register device to the tty subsystem\n"); | ||
627 | cs->tty_dev = NULL; | 628 | cs->tty_dev = NULL; |
628 | } | 629 | } |
629 | mutex_unlock(&cs->mutex); | 630 | mutex_unlock(&cs->mutex); |
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c index 77d20ab0cd4d..4661830a49db 100644 --- a/drivers/isdn/gigaset/usb-gigaset.c +++ b/drivers/isdn/gigaset/usb-gigaset.c | |||
@@ -498,8 +498,9 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb) | |||
498 | 498 | ||
499 | if (status) { | 499 | if (status) { |
500 | ucs->busy = 0; | 500 | ucs->busy = 0; |
501 | err("could not submit urb (error %d)\n", | 501 | dev_err(cs->dev, |
502 | -status); | 502 | "could not submit urb (error %d)\n", |
503 | -status); | ||
503 | cb->len = 0; /* skip urb => remove cb+wakeup | 504 | cb->len = 0; /* skip urb => remove cb+wakeup |
504 | in next loop cycle */ | 505 | in next loop cycle */ |
505 | } | 506 | } |
@@ -670,7 +671,7 @@ static int write_modem(struct cardstate *cs) | |||
670 | spin_unlock_irqrestore(&cs->lock, flags); | 671 | spin_unlock_irqrestore(&cs->lock, flags); |
671 | 672 | ||
672 | if (ret) { | 673 | if (ret) { |
673 | err("could not submit urb (error %d)\n", -ret); | 674 | dev_err(cs->dev, "could not submit urb (error %d)\n", -ret); |
674 | ucs->busy = 0; | 675 | ucs->busy = 0; |
675 | } | 676 | } |
676 | 677 | ||
diff --git a/drivers/isdn/hisax/st5481.h b/drivers/isdn/hisax/st5481.h index 2044e7173ab4..cff7a6354334 100644 --- a/drivers/isdn/hisax/st5481.h +++ b/drivers/isdn/hisax/st5481.h | |||
@@ -220,7 +220,7 @@ enum { | |||
220 | #define ERR(format, arg...) \ | 220 | #define ERR(format, arg...) \ |
221 | printk(KERN_ERR "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) | 221 | printk(KERN_ERR "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) |
222 | 222 | ||
223 | #define WARN(format, arg...) \ | 223 | #define WARNING(format, arg...) \ |
224 | printk(KERN_WARNING "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) | 224 | printk(KERN_WARNING "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) |
225 | 225 | ||
226 | #define INFO(format, arg...) \ | 226 | #define INFO(format, arg...) \ |
@@ -412,7 +412,7 @@ struct st5481_adapter { | |||
412 | ({ \ | 412 | ({ \ |
413 | int status; \ | 413 | int status; \ |
414 | if ((status = usb_submit_urb(urb, mem_flags)) < 0) { \ | 414 | if ((status = usb_submit_urb(urb, mem_flags)) < 0) { \ |
415 | WARN("usb_submit_urb failed,status=%d", status); \ | 415 | WARNING("usb_submit_urb failed,status=%d", status); \ |
416 | } \ | 416 | } \ |
417 | status; \ | 417 | status; \ |
418 | }) | 418 | }) |
diff --git a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c index fa64115cd7c7..0074b600a0ef 100644 --- a/drivers/isdn/hisax/st5481_b.c +++ b/drivers/isdn/hisax/st5481_b.c | |||
@@ -180,7 +180,7 @@ static void usb_b_out_complete(struct urb *urb) | |||
180 | DBG(4,"urb killed status %d", urb->status); | 180 | DBG(4,"urb killed status %d", urb->status); |
181 | return; // Give up | 181 | return; // Give up |
182 | default: | 182 | default: |
183 | WARN("urb status %d",urb->status); | 183 | WARNING("urb status %d",urb->status); |
184 | if (b_out->busy == 0) { | 184 | if (b_out->busy == 0) { |
185 | st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL); | 185 | st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL); |
186 | } | 186 | } |
@@ -372,6 +372,6 @@ void st5481_b_l2l1(struct hisax_if *ifc, int pr, void *arg) | |||
372 | B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL); | 372 | B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL); |
373 | break; | 373 | break; |
374 | default: | 374 | default: |
375 | WARN("pr %#x\n", pr); | 375 | WARNING("pr %#x\n", pr); |
376 | } | 376 | } |
377 | } | 377 | } |
diff --git a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c index b8c4855cc889..077991c1cd05 100644 --- a/drivers/isdn/hisax/st5481_d.c +++ b/drivers/isdn/hisax/st5481_d.c | |||
@@ -389,7 +389,7 @@ static void usb_d_out_complete(struct urb *urb) | |||
389 | DBG(1,"urb killed status %d", urb->status); | 389 | DBG(1,"urb killed status %d", urb->status); |
390 | break; | 390 | break; |
391 | default: | 391 | default: |
392 | WARN("urb status %d",urb->status); | 392 | WARNING("urb status %d",urb->status); |
393 | if (d_out->busy == 0) { | 393 | if (d_out->busy == 0) { |
394 | st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter); | 394 | st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter); |
395 | } | 395 | } |
@@ -420,7 +420,7 @@ static void dout_start_xmit(struct FsmInst *fsm, int event, void *arg) | |||
420 | isdnhdlc_out_init(&d_out->hdlc_state, 1, 0); | 420 | isdnhdlc_out_init(&d_out->hdlc_state, 1, 0); |
421 | 421 | ||
422 | if (test_and_set_bit(buf_nr, &d_out->busy)) { | 422 | if (test_and_set_bit(buf_nr, &d_out->busy)) { |
423 | WARN("ep %d urb %d busy %#lx", EP_D_OUT, buf_nr, d_out->busy); | 423 | WARNING("ep %d urb %d busy %#lx", EP_D_OUT, buf_nr, d_out->busy); |
424 | return; | 424 | return; |
425 | } | 425 | } |
426 | urb = d_out->urb[buf_nr]; | 426 | urb = d_out->urb[buf_nr]; |
@@ -601,7 +601,7 @@ void st5481_d_l2l1(struct hisax_if *hisax_d_if, int pr, void *arg) | |||
601 | FsmEvent(&adapter->d_out.fsm, EV_DOUT_START_XMIT, NULL); | 601 | FsmEvent(&adapter->d_out.fsm, EV_DOUT_START_XMIT, NULL); |
602 | break; | 602 | break; |
603 | default: | 603 | default: |
604 | WARN("pr %#x\n", pr); | 604 | WARNING("pr %#x\n", pr); |
605 | break; | 605 | break; |
606 | } | 606 | } |
607 | } | 607 | } |
diff --git a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c index 427a8b0520f5..ec3c0e507669 100644 --- a/drivers/isdn/hisax/st5481_usb.c +++ b/drivers/isdn/hisax/st5481_usb.c | |||
@@ -66,7 +66,7 @@ static void usb_ctrl_msg(struct st5481_adapter *adapter, | |||
66 | struct ctrl_msg *ctrl_msg; | 66 | struct ctrl_msg *ctrl_msg; |
67 | 67 | ||
68 | if ((w_index = fifo_add(&ctrl->msg_fifo.f)) < 0) { | 68 | if ((w_index = fifo_add(&ctrl->msg_fifo.f)) < 0) { |
69 | WARN("control msg FIFO full"); | 69 | WARNING("control msg FIFO full"); |
70 | return; | 70 | return; |
71 | } | 71 | } |
72 | ctrl_msg = &ctrl->msg_fifo.data[w_index]; | 72 | ctrl_msg = &ctrl->msg_fifo.data[w_index]; |
@@ -139,7 +139,7 @@ static void usb_ctrl_complete(struct urb *urb) | |||
139 | DBG(1,"urb killed status %d", urb->status); | 139 | DBG(1,"urb killed status %d", urb->status); |
140 | return; // Give up | 140 | return; // Give up |
141 | default: | 141 | default: |
142 | WARN("urb status %d",urb->status); | 142 | WARNING("urb status %d",urb->status); |
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | } | 145 | } |
@@ -198,7 +198,7 @@ static void usb_int_complete(struct urb *urb) | |||
198 | DBG(2, "urb shutting down with status: %d", urb->status); | 198 | DBG(2, "urb shutting down with status: %d", urb->status); |
199 | return; | 199 | return; |
200 | default: | 200 | default: |
201 | WARN("nonzero urb status received: %d", urb->status); | 201 | WARNING("nonzero urb status received: %d", urb->status); |
202 | goto exit; | 202 | goto exit; |
203 | } | 203 | } |
204 | 204 | ||
@@ -235,7 +235,7 @@ static void usb_int_complete(struct urb *urb) | |||
235 | exit: | 235 | exit: |
236 | status = usb_submit_urb (urb, GFP_ATOMIC); | 236 | status = usb_submit_urb (urb, GFP_ATOMIC); |
237 | if (status) | 237 | if (status) |
238 | WARN("usb_submit_urb failed with result %d", status); | 238 | WARNING("usb_submit_urb failed with result %d", status); |
239 | } | 239 | } |
240 | 240 | ||
241 | /* ====================================================================== | 241 | /* ====================================================================== |
@@ -257,7 +257,7 @@ int st5481_setup_usb(struct st5481_adapter *adapter) | |||
257 | DBG(2,""); | 257 | DBG(2,""); |
258 | 258 | ||
259 | if ((status = usb_reset_configuration (dev)) < 0) { | 259 | if ((status = usb_reset_configuration (dev)) < 0) { |
260 | WARN("reset_configuration failed,status=%d",status); | 260 | WARNING("reset_configuration failed,status=%d",status); |
261 | return status; | 261 | return status; |
262 | } | 262 | } |
263 | 263 | ||
@@ -269,7 +269,7 @@ int st5481_setup_usb(struct st5481_adapter *adapter) | |||
269 | 269 | ||
270 | // Check if the config is sane | 270 | // Check if the config is sane |
271 | if ( altsetting->desc.bNumEndpoints != 7 ) { | 271 | if ( altsetting->desc.bNumEndpoints != 7 ) { |
272 | WARN("expecting 7 got %d endpoints!", altsetting->desc.bNumEndpoints); | 272 | WARNING("expecting 7 got %d endpoints!", altsetting->desc.bNumEndpoints); |
273 | return -EINVAL; | 273 | return -EINVAL; |
274 | } | 274 | } |
275 | 275 | ||
@@ -279,7 +279,7 @@ int st5481_setup_usb(struct st5481_adapter *adapter) | |||
279 | 279 | ||
280 | // Use alternative setting 3 on interface 0 to have 2B+D | 280 | // Use alternative setting 3 on interface 0 to have 2B+D |
281 | if ((status = usb_set_interface (dev, 0, 3)) < 0) { | 281 | if ((status = usb_set_interface (dev, 0, 3)) < 0) { |
282 | WARN("usb_set_interface failed,status=%d",status); | 282 | WARNING("usb_set_interface failed,status=%d",status); |
283 | return status; | 283 | return status; |
284 | } | 284 | } |
285 | 285 | ||
@@ -497,7 +497,7 @@ static void usb_in_complete(struct urb *urb) | |||
497 | DBG(1,"urb killed status %d", urb->status); | 497 | DBG(1,"urb killed status %d", urb->status); |
498 | return; // Give up | 498 | return; // Give up |
499 | default: | 499 | default: |
500 | WARN("urb status %d",urb->status); | 500 | WARNING("urb status %d",urb->status); |
501 | break; | 501 | break; |
502 | } | 502 | } |
503 | } | 503 | } |
@@ -523,7 +523,7 @@ static void usb_in_complete(struct urb *urb) | |||
523 | DBG(4,"count=%d",status); | 523 | DBG(4,"count=%d",status); |
524 | DBG_PACKET(0x400, in->rcvbuf, status); | 524 | DBG_PACKET(0x400, in->rcvbuf, status); |
525 | if (!(skb = dev_alloc_skb(status))) { | 525 | if (!(skb = dev_alloc_skb(status))) { |
526 | WARN("receive out of memory\n"); | 526 | WARNING("receive out of memory\n"); |
527 | break; | 527 | break; |
528 | } | 528 | } |
529 | memcpy(skb_put(skb, status), in->rcvbuf, status); | 529 | memcpy(skb_put(skb, status), in->rcvbuf, status); |
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 86a369bc57d6..9556262dda5a 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -103,6 +103,14 @@ config LEDS_HP6XX | |||
103 | This option enables led support for the handheld | 103 | This option enables led support for the handheld |
104 | HP Jornada 620/660/680/690. | 104 | HP Jornada 620/660/680/690. |
105 | 105 | ||
106 | config LEDS_PCA9532 | ||
107 | tristate "LED driver for PCA9532 dimmer" | ||
108 | depends on LEDS_CLASS && I2C && INPUT && EXPERIMENTAL | ||
109 | help | ||
110 | This option enables support for NXP pca9532 | ||
111 | led controller. It is generally only usefull | ||
112 | as a platform driver | ||
113 | |||
106 | config LEDS_GPIO | 114 | config LEDS_GPIO |
107 | tristate "LED Support for GPIO connected LEDs" | 115 | tristate "LED Support for GPIO connected LEDs" |
108 | depends on LEDS_CLASS && GENERIC_GPIO | 116 | depends on LEDS_CLASS && GENERIC_GPIO |
@@ -147,6 +155,14 @@ config LEDS_CLEVO_MAIL | |||
147 | To compile this driver as a module, choose M here: the | 155 | To compile this driver as a module, choose M here: the |
148 | module will be called leds-clevo-mail. | 156 | module will be called leds-clevo-mail. |
149 | 157 | ||
158 | config LEDS_PCA955X | ||
159 | tristate "LED Support for PCA955x I2C chips" | ||
160 | depends on LEDS_CLASS && I2C | ||
161 | help | ||
162 | This option enables support for LEDs connected to PCA955x | ||
163 | LED driver chips accessed via the I2C bus. Supported | ||
164 | devices include PCA9550, PCA9551, PCA9552, and PCA9553. | ||
165 | |||
150 | comment "LED Triggers" | 166 | comment "LED Triggers" |
151 | 167 | ||
152 | config LEDS_TRIGGERS | 168 | config LEDS_TRIGGERS |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 973d626f5f4a..ff7982b44565 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -16,11 +16,13 @@ obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o | |||
16 | obj-$(CONFIG_LEDS_H1940) += leds-h1940.o | 16 | obj-$(CONFIG_LEDS_H1940) += leds-h1940.o |
17 | obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o | 17 | obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o |
18 | obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o | 18 | obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o |
19 | obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o | ||
19 | obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o | 20 | obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o |
20 | obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o | 21 | obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o |
21 | obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o | 22 | obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o |
22 | obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o | 23 | obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o |
23 | obj-$(CONFIG_LEDS_FSG) += leds-fsg.o | 24 | obj-$(CONFIG_LEDS_FSG) += leds-fsg.o |
25 | obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o | ||
24 | 26 | ||
25 | # LED Triggers | 27 | # LED Triggers |
26 | obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o | 28 | obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o |
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 0f242b3f09b6..f910eaffe3a6 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c | |||
@@ -111,16 +111,17 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger) | |||
111 | flags); | 111 | flags); |
112 | if (led_cdev->trigger->deactivate) | 112 | if (led_cdev->trigger->deactivate) |
113 | led_cdev->trigger->deactivate(led_cdev); | 113 | led_cdev->trigger->deactivate(led_cdev); |
114 | led_cdev->trigger = NULL; | ||
114 | led_set_brightness(led_cdev, LED_OFF); | 115 | led_set_brightness(led_cdev, LED_OFF); |
115 | } | 116 | } |
116 | if (trigger) { | 117 | if (trigger) { |
117 | write_lock_irqsave(&trigger->leddev_list_lock, flags); | 118 | write_lock_irqsave(&trigger->leddev_list_lock, flags); |
118 | list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs); | 119 | list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs); |
119 | write_unlock_irqrestore(&trigger->leddev_list_lock, flags); | 120 | write_unlock_irqrestore(&trigger->leddev_list_lock, flags); |
121 | led_cdev->trigger = trigger; | ||
120 | if (trigger->activate) | 122 | if (trigger->activate) |
121 | trigger->activate(led_cdev); | 123 | trigger->activate(led_cdev); |
122 | } | 124 | } |
123 | led_cdev->trigger = trigger; | ||
124 | } | 125 | } |
125 | EXPORT_SYMBOL_GPL(led_trigger_set); | 126 | EXPORT_SYMBOL_GPL(led_trigger_set); |
126 | 127 | ||
diff --git a/drivers/leds/leds-atmel-pwm.c b/drivers/leds/leds-atmel-pwm.c index 28db6c1444ed..52297c3ab246 100644 --- a/drivers/leds/leds-atmel-pwm.c +++ b/drivers/leds/leds-atmel-pwm.c | |||
@@ -37,7 +37,7 @@ static int __init pwmled_probe(struct platform_device *pdev) | |||
37 | { | 37 | { |
38 | const struct gpio_led_platform_data *pdata; | 38 | const struct gpio_led_platform_data *pdata; |
39 | struct pwmled *leds; | 39 | struct pwmled *leds; |
40 | unsigned i; | 40 | int i; |
41 | int status; | 41 | int status; |
42 | 42 | ||
43 | pdata = pdev->dev.platform_data; | 43 | pdata = pdev->dev.platform_data; |
diff --git a/drivers/leds/leds-h1940.c b/drivers/leds/leds-h1940.c index bcec42230389..73c705021686 100644 --- a/drivers/leds/leds-h1940.c +++ b/drivers/leds/leds-h1940.c | |||
@@ -23,7 +23,8 @@ | |||
23 | /* | 23 | /* |
24 | * Green led. | 24 | * Green led. |
25 | */ | 25 | */ |
26 | void h1940_greenled_set(struct led_classdev *led_dev, enum led_brightness value) | 26 | static void h1940_greenled_set(struct led_classdev *led_dev, |
27 | enum led_brightness value) | ||
27 | { | 28 | { |
28 | switch (value) { | 29 | switch (value) { |
29 | case LED_HALF: | 30 | case LED_HALF: |
@@ -52,7 +53,8 @@ static struct led_classdev h1940_greenled = { | |||
52 | /* | 53 | /* |
53 | * Red led. | 54 | * Red led. |
54 | */ | 55 | */ |
55 | void h1940_redled_set(struct led_classdev *led_dev, enum led_brightness value) | 56 | static void h1940_redled_set(struct led_classdev *led_dev, |
57 | enum led_brightness value) | ||
56 | { | 58 | { |
57 | switch (value) { | 59 | switch (value) { |
58 | case LED_HALF: | 60 | case LED_HALF: |
@@ -82,7 +84,8 @@ static struct led_classdev h1940_redled = { | |||
82 | * Blue led. | 84 | * Blue led. |
83 | * (it can only be blue flashing led) | 85 | * (it can only be blue flashing led) |
84 | */ | 86 | */ |
85 | void h1940_blueled_set(struct led_classdev *led_dev, enum led_brightness value) | 87 | static void h1940_blueled_set(struct led_classdev *led_dev, |
88 | enum led_brightness value) | ||
86 | { | 89 | { |
87 | if (value) { | 90 | if (value) { |
88 | /* flashing Blue */ | 91 | /* flashing Blue */ |
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c new file mode 100644 index 000000000000..4064d4f6b33b --- /dev/null +++ b/drivers/leds/leds-pca9532.c | |||
@@ -0,0 +1,337 @@ | |||
1 | /* | ||
2 | * pca9532.c - 16-bit Led dimmer | ||
3 | * | ||
4 | * Copyright (C) 2008 Riku Voipio <riku.voipio@movial.fi> | ||
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; version 2 of the License. | ||
9 | * | ||
10 | * Datasheet: http://www.nxp.com/acrobat/datasheets/PCA9532_3.pdf | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/i2c.h> | ||
16 | #include <linux/leds.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/mutex.h> | ||
19 | #include <linux/leds-pca9532.h> | ||
20 | |||
21 | static const unsigned short normal_i2c[] = { /*0x60,*/ I2C_CLIENT_END}; | ||
22 | I2C_CLIENT_INSMOD_1(pca9532); | ||
23 | |||
24 | #define PCA9532_REG_PSC(i) (0x2+(i)*2) | ||
25 | #define PCA9532_REG_PWM(i) (0x3+(i)*2) | ||
26 | #define PCA9532_REG_LS0 0x6 | ||
27 | #define LED_REG(led) ((led>>2)+PCA9532_REG_LS0) | ||
28 | #define LED_NUM(led) (led & 0x3) | ||
29 | |||
30 | #define ldev_to_led(c) container_of(c, struct pca9532_led, ldev) | ||
31 | |||
32 | struct pca9532_data { | ||
33 | struct i2c_client *client; | ||
34 | struct pca9532_led leds[16]; | ||
35 | struct mutex update_lock; | ||
36 | struct input_dev *idev; | ||
37 | u8 pwm[2]; | ||
38 | u8 psc[2]; | ||
39 | }; | ||
40 | |||
41 | static int pca9532_probe(struct i2c_client *client, | ||
42 | const struct i2c_device_id *id); | ||
43 | static int pca9532_remove(struct i2c_client *client); | ||
44 | |||
45 | static const struct i2c_device_id pca9532_id[] = { | ||
46 | { "pca9532", 0 }, | ||
47 | { } | ||
48 | }; | ||
49 | |||
50 | MODULE_DEVICE_TABLE(i2c, pca9532_id); | ||
51 | |||
52 | static struct i2c_driver pca9532_driver = { | ||
53 | .driver = { | ||
54 | .name = "pca9532", | ||
55 | }, | ||
56 | .probe = pca9532_probe, | ||
57 | .remove = pca9532_remove, | ||
58 | .id_table = pca9532_id, | ||
59 | }; | ||
60 | |||
61 | /* We have two pwm/blinkers, but 16 possible leds to drive. Additionaly, | ||
62 | * the clever Thecus people are using one pwm to drive the beeper. So, | ||
63 | * as a compromise we average one pwm to the values requested by all | ||
64 | * leds that are not ON/OFF. | ||
65 | * */ | ||
66 | static int pca9532_setpwm(struct i2c_client *client, int pwm, int blink, | ||
67 | enum led_brightness value) | ||
68 | { | ||
69 | int a = 0, b = 0, i = 0; | ||
70 | struct pca9532_data *data = i2c_get_clientdata(client); | ||
71 | for (i = 0; i < 16; i++) { | ||
72 | if (data->leds[i].type == PCA9532_TYPE_LED && | ||
73 | data->leds[i].state == PCA9532_PWM0+pwm) { | ||
74 | a++; | ||
75 | b += data->leds[i].ldev.brightness; | ||
76 | } | ||
77 | } | ||
78 | if (a == 0) { | ||
79 | dev_err(&client->dev, | ||
80 | "fear of division by zero %d/%d, wanted %d\n", | ||
81 | b, a, value); | ||
82 | return -EINVAL; | ||
83 | } | ||
84 | b = b/a; | ||
85 | if (b > 0xFF) | ||
86 | return -EINVAL; | ||
87 | mutex_lock(&data->update_lock); | ||
88 | data->pwm[pwm] = b; | ||
89 | i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(pwm), | ||
90 | data->pwm[pwm]); | ||
91 | data->psc[pwm] = blink; | ||
92 | i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(pwm), | ||
93 | data->psc[pwm]); | ||
94 | mutex_unlock(&data->update_lock); | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | /* Set LED routing */ | ||
99 | static void pca9532_setled(struct pca9532_led *led) | ||
100 | { | ||
101 | struct i2c_client *client = led->client; | ||
102 | struct pca9532_data *data = i2c_get_clientdata(client); | ||
103 | char reg; | ||
104 | |||
105 | mutex_lock(&data->update_lock); | ||
106 | reg = i2c_smbus_read_byte_data(client, LED_REG(led->id)); | ||
107 | /* zero led bits */ | ||
108 | reg = reg & ~(0x3<<LED_NUM(led->id)*2); | ||
109 | /* set the new value */ | ||
110 | reg = reg | (led->state << LED_NUM(led->id)*2); | ||
111 | i2c_smbus_write_byte_data(client, LED_REG(led->id), reg); | ||
112 | mutex_unlock(&data->update_lock); | ||
113 | } | ||
114 | |||
115 | static void pca9532_set_brightness(struct led_classdev *led_cdev, | ||
116 | enum led_brightness value) | ||
117 | { | ||
118 | int err = 0; | ||
119 | struct pca9532_led *led = ldev_to_led(led_cdev); | ||
120 | |||
121 | if (value == LED_OFF) | ||
122 | led->state = PCA9532_OFF; | ||
123 | else if (value == LED_FULL) | ||
124 | led->state = PCA9532_ON; | ||
125 | else { | ||
126 | led->state = PCA9532_PWM0; /* Thecus: hardcode one pwm */ | ||
127 | err = pca9532_setpwm(led->client, 0, 0, value); | ||
128 | if (err) | ||
129 | return; /* XXX: led api doesn't allow error code? */ | ||
130 | } | ||
131 | pca9532_setled(led); | ||
132 | } | ||
133 | |||
134 | static int pca9532_set_blink(struct led_classdev *led_cdev, | ||
135 | unsigned long *delay_on, unsigned long *delay_off) | ||
136 | { | ||
137 | struct pca9532_led *led = ldev_to_led(led_cdev); | ||
138 | struct i2c_client *client = led->client; | ||
139 | int psc; | ||
140 | |||
141 | if (*delay_on == 0 && *delay_off == 0) { | ||
142 | /* led subsystem ask us for a blink rate */ | ||
143 | *delay_on = 1000; | ||
144 | *delay_off = 1000; | ||
145 | } | ||
146 | if (*delay_on != *delay_off || *delay_on > 1690 || *delay_on < 6) | ||
147 | return -EINVAL; | ||
148 | |||
149 | /* Thecus specific: only use PSC/PWM 0 */ | ||
150 | psc = (*delay_on * 152-1)/1000; | ||
151 | return pca9532_setpwm(client, 0, psc, led_cdev->brightness); | ||
152 | } | ||
153 | |||
154 | int pca9532_event(struct input_dev *dev, unsigned int type, unsigned int code, | ||
155 | int value) | ||
156 | { | ||
157 | struct pca9532_data *data = input_get_drvdata(dev); | ||
158 | |||
159 | if (type != EV_SND && (code != SND_BELL || code != SND_TONE)) | ||
160 | return -1; | ||
161 | |||
162 | /* XXX: allow different kind of beeps with psc/pwm modifications */ | ||
163 | if (value > 1 && value < 32767) | ||
164 | data->pwm[1] = 127; | ||
165 | else | ||
166 | data->pwm[1] = 0; | ||
167 | |||
168 | dev_info(&dev->dev, "setting beep to %d \n", data->pwm[1]); | ||
169 | mutex_lock(&data->update_lock); | ||
170 | i2c_smbus_write_byte_data(data->client, PCA9532_REG_PWM(1), | ||
171 | data->pwm[1]); | ||
172 | mutex_unlock(&data->update_lock); | ||
173 | |||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | static int pca9532_configure(struct i2c_client *client, | ||
178 | struct pca9532_data *data, struct pca9532_platform_data *pdata) | ||
179 | { | ||
180 | int i, err = 0; | ||
181 | |||
182 | for (i = 0; i < 2; i++) { | ||
183 | data->pwm[i] = pdata->pwm[i]; | ||
184 | data->psc[i] = pdata->psc[i]; | ||
185 | i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(i), | ||
186 | data->pwm[i]); | ||
187 | i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(i), | ||
188 | data->psc[i]); | ||
189 | } | ||
190 | |||
191 | for (i = 0; i < 16; i++) { | ||
192 | struct pca9532_led *led = &data->leds[i]; | ||
193 | struct pca9532_led *pled = &pdata->leds[i]; | ||
194 | led->client = client; | ||
195 | led->id = i; | ||
196 | led->type = pled->type; | ||
197 | switch (led->type) { | ||
198 | case PCA9532_TYPE_NONE: | ||
199 | break; | ||
200 | case PCA9532_TYPE_LED: | ||
201 | led->state = pled->state; | ||
202 | led->name = pled->name; | ||
203 | led->ldev.name = led->name; | ||
204 | led->ldev.brightness = LED_OFF; | ||
205 | led->ldev.brightness_set = pca9532_set_brightness; | ||
206 | led->ldev.blink_set = pca9532_set_blink; | ||
207 | if (led_classdev_register(&client->dev, | ||
208 | &led->ldev) < 0) { | ||
209 | dev_err(&client->dev, | ||
210 | "couldn't register LED %s\n", | ||
211 | led->name); | ||
212 | goto exit; | ||
213 | } | ||
214 | pca9532_setled(led); | ||
215 | break; | ||
216 | case PCA9532_TYPE_N2100_BEEP: | ||
217 | BUG_ON(data->idev); | ||
218 | led->state = PCA9532_PWM1; | ||
219 | pca9532_setled(led); | ||
220 | data->idev = input_allocate_device(); | ||
221 | if (data->idev == NULL) { | ||
222 | err = -ENOMEM; | ||
223 | goto exit; | ||
224 | } | ||
225 | data->idev->name = pled->name; | ||
226 | data->idev->phys = "i2c/pca9532"; | ||
227 | data->idev->id.bustype = BUS_HOST; | ||
228 | data->idev->id.vendor = 0x001f; | ||
229 | data->idev->id.product = 0x0001; | ||
230 | data->idev->id.version = 0x0100; | ||
231 | data->idev->evbit[0] = BIT_MASK(EV_SND); | ||
232 | data->idev->sndbit[0] = BIT_MASK(SND_BELL) | | ||
233 | BIT_MASK(SND_TONE); | ||
234 | data->idev->event = pca9532_event; | ||
235 | input_set_drvdata(data->idev, data); | ||
236 | err = input_register_device(data->idev); | ||
237 | if (err) { | ||
238 | input_free_device(data->idev); | ||
239 | data->idev = NULL; | ||
240 | goto exit; | ||
241 | } | ||
242 | break; | ||
243 | } | ||
244 | } | ||
245 | return 0; | ||
246 | |||
247 | exit: | ||
248 | if (i > 0) | ||
249 | for (i = i - 1; i >= 0; i--) | ||
250 | switch (data->leds[i].type) { | ||
251 | case PCA9532_TYPE_NONE: | ||
252 | break; | ||
253 | case PCA9532_TYPE_LED: | ||
254 | led_classdev_unregister(&data->leds[i].ldev); | ||
255 | break; | ||
256 | case PCA9532_TYPE_N2100_BEEP: | ||
257 | if (data->idev != NULL) { | ||
258 | input_unregister_device(data->idev); | ||
259 | input_free_device(data->idev); | ||
260 | data->idev = NULL; | ||
261 | } | ||
262 | break; | ||
263 | } | ||
264 | |||
265 | return err; | ||
266 | |||
267 | } | ||
268 | |||
269 | static int pca9532_probe(struct i2c_client *client, | ||
270 | const struct i2c_device_id *id) | ||
271 | { | ||
272 | struct pca9532_data *data = i2c_get_clientdata(client); | ||
273 | struct pca9532_platform_data *pca9532_pdata = client->dev.platform_data; | ||
274 | |||
275 | if (!i2c_check_functionality(client->adapter, | ||
276 | I2C_FUNC_SMBUS_BYTE_DATA)) | ||
277 | return -EIO; | ||
278 | |||
279 | data = kzalloc(sizeof(struct pca9532_data), GFP_KERNEL); | ||
280 | if (!data) | ||
281 | return -ENOMEM; | ||
282 | |||
283 | dev_info(&client->dev, "setting platform data\n"); | ||
284 | i2c_set_clientdata(client, data); | ||
285 | data->client = client; | ||
286 | mutex_init(&data->update_lock); | ||
287 | |||
288 | if (pca9532_pdata == NULL) | ||
289 | return -EIO; | ||
290 | |||
291 | pca9532_configure(client, data, pca9532_pdata); | ||
292 | return 0; | ||
293 | |||
294 | } | ||
295 | |||
296 | static int pca9532_remove(struct i2c_client *client) | ||
297 | { | ||
298 | struct pca9532_data *data = i2c_get_clientdata(client); | ||
299 | int i; | ||
300 | for (i = 0; i < 16; i++) | ||
301 | switch (data->leds[i].type) { | ||
302 | case PCA9532_TYPE_NONE: | ||
303 | break; | ||
304 | case PCA9532_TYPE_LED: | ||
305 | led_classdev_unregister(&data->leds[i].ldev); | ||
306 | break; | ||
307 | case PCA9532_TYPE_N2100_BEEP: | ||
308 | if (data->idev != NULL) { | ||
309 | input_unregister_device(data->idev); | ||
310 | input_free_device(data->idev); | ||
311 | data->idev = NULL; | ||
312 | } | ||
313 | break; | ||
314 | } | ||
315 | |||
316 | kfree(data); | ||
317 | i2c_set_clientdata(client, NULL); | ||
318 | return 0; | ||
319 | } | ||
320 | |||
321 | static int __init pca9532_init(void) | ||
322 | { | ||
323 | return i2c_add_driver(&pca9532_driver); | ||
324 | } | ||
325 | |||
326 | static void __exit pca9532_exit(void) | ||
327 | { | ||
328 | i2c_del_driver(&pca9532_driver); | ||
329 | } | ||
330 | |||
331 | MODULE_AUTHOR("Riku Voipio <riku.voipio@movial.fi>"); | ||
332 | MODULE_LICENSE("GPL"); | ||
333 | MODULE_DESCRIPTION("PCA 9532 LED dimmer"); | ||
334 | |||
335 | module_init(pca9532_init); | ||
336 | module_exit(pca9532_exit); | ||
337 | |||
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c new file mode 100644 index 000000000000..146c06972863 --- /dev/null +++ b/drivers/leds/leds-pca955x.c | |||
@@ -0,0 +1,384 @@ | |||
1 | /* | ||
2 | * Copyright 2007-2008 Extreme Engineering Solutions, Inc. | ||
3 | * | ||
4 | * Author: Nate Case <ncase@xes-inc.com> | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of version 2 of | ||
7 | * the GNU General Public License. See the file COPYING in the main | ||
8 | * directory of this archive for more details. | ||
9 | * | ||
10 | * LED driver for various PCA955x I2C LED drivers | ||
11 | * | ||
12 | * Supported devices: | ||
13 | * | ||
14 | * Device Description 7-bit slave address | ||
15 | * ------ ----------- ------------------- | ||
16 | * PCA9550 2-bit driver 0x60 .. 0x61 | ||
17 | * PCA9551 8-bit driver 0x60 .. 0x67 | ||
18 | * PCA9552 16-bit driver 0x60 .. 0x67 | ||
19 | * PCA9553/01 4-bit driver 0x62 | ||
20 | * PCA9553/02 4-bit driver 0x63 | ||
21 | * | ||
22 | * Philips PCA955x LED driver chips follow a register map as shown below: | ||
23 | * | ||
24 | * Control Register Description | ||
25 | * ---------------- ----------- | ||
26 | * 0x0 Input register 0 | ||
27 | * .. | ||
28 | * NUM_INPUT_REGS - 1 Last Input register X | ||
29 | * | ||
30 | * NUM_INPUT_REGS Frequency prescaler 0 | ||
31 | * NUM_INPUT_REGS + 1 PWM register 0 | ||
32 | * NUM_INPUT_REGS + 2 Frequency prescaler 1 | ||
33 | * NUM_INPUT_REGS + 3 PWM register 1 | ||
34 | * | ||
35 | * NUM_INPUT_REGS + 4 LED selector 0 | ||
36 | * NUM_INPUT_REGS + 4 | ||
37 | * + NUM_LED_REGS - 1 Last LED selector | ||
38 | * | ||
39 | * where NUM_INPUT_REGS and NUM_LED_REGS vary depending on how many | ||
40 | * bits the chip supports. | ||
41 | */ | ||
42 | |||
43 | #include <linux/module.h> | ||
44 | #include <linux/delay.h> | ||
45 | #include <linux/string.h> | ||
46 | #include <linux/ctype.h> | ||
47 | #include <linux/leds.h> | ||
48 | #include <linux/err.h> | ||
49 | #include <linux/i2c.h> | ||
50 | #include <linux/workqueue.h> | ||
51 | |||
52 | /* LED select registers determine the source that drives LED outputs */ | ||
53 | #define PCA955X_LS_LED_ON 0x0 /* Output LOW */ | ||
54 | #define PCA955X_LS_LED_OFF 0x1 /* Output HI-Z */ | ||
55 | #define PCA955X_LS_BLINK0 0x2 /* Blink at PWM0 rate */ | ||
56 | #define PCA955X_LS_BLINK1 0x3 /* Blink at PWM1 rate */ | ||
57 | |||
58 | enum pca955x_type { | ||
59 | pca9550, | ||
60 | pca9551, | ||
61 | pca9552, | ||
62 | pca9553, | ||
63 | }; | ||
64 | |||
65 | struct pca955x_chipdef { | ||
66 | int bits; | ||
67 | u8 slv_addr; /* 7-bit slave address mask */ | ||
68 | int slv_addr_shift; /* Number of bits to ignore */ | ||
69 | }; | ||
70 | |||
71 | static struct pca955x_chipdef pca955x_chipdefs[] = { | ||
72 | [pca9550] = { | ||
73 | .bits = 2, | ||
74 | .slv_addr = /* 110000x */ 0x60, | ||
75 | .slv_addr_shift = 1, | ||
76 | }, | ||
77 | [pca9551] = { | ||
78 | .bits = 8, | ||
79 | .slv_addr = /* 1100xxx */ 0x60, | ||
80 | .slv_addr_shift = 3, | ||
81 | }, | ||
82 | [pca9552] = { | ||
83 | .bits = 16, | ||
84 | .slv_addr = /* 1100xxx */ 0x60, | ||
85 | .slv_addr_shift = 3, | ||
86 | }, | ||
87 | [pca9553] = { | ||
88 | .bits = 4, | ||
89 | .slv_addr = /* 110001x */ 0x62, | ||
90 | .slv_addr_shift = 1, | ||
91 | }, | ||
92 | }; | ||
93 | |||
94 | static const struct i2c_device_id pca955x_id[] = { | ||
95 | { "pca9550", pca9550 }, | ||
96 | { "pca9551", pca9551 }, | ||
97 | { "pca9552", pca9552 }, | ||
98 | { "pca9553", pca9553 }, | ||
99 | { } | ||
100 | }; | ||
101 | MODULE_DEVICE_TABLE(i2c, pca955x_id); | ||
102 | |||
103 | struct pca955x_led { | ||
104 | struct pca955x_chipdef *chipdef; | ||
105 | struct i2c_client *client; | ||
106 | struct work_struct work; | ||
107 | spinlock_t lock; | ||
108 | enum led_brightness brightness; | ||
109 | struct led_classdev led_cdev; | ||
110 | int led_num; /* 0 .. 15 potentially */ | ||
111 | char name[32]; | ||
112 | }; | ||
113 | |||
114 | /* 8 bits per input register */ | ||
115 | static inline int pca95xx_num_input_regs(int bits) | ||
116 | { | ||
117 | return (bits + 7) / 8; | ||
118 | } | ||
119 | |||
120 | /* 4 bits per LED selector register */ | ||
121 | static inline int pca95xx_num_led_regs(int bits) | ||
122 | { | ||
123 | return (bits + 3) / 4; | ||
124 | } | ||
125 | |||
126 | /* | ||
127 | * Return an LED selector register value based on an existing one, with | ||
128 | * the appropriate 2-bit state value set for the given LED number (0-3). | ||
129 | */ | ||
130 | static inline u8 pca955x_ledsel(u8 oldval, int led_num, int state) | ||
131 | { | ||
132 | return (oldval & (~(0x3 << (led_num << 1)))) | | ||
133 | ((state & 0x3) << (led_num << 1)); | ||
134 | } | ||
135 | |||
136 | /* | ||
137 | * Write to frequency prescaler register, used to program the | ||
138 | * period of the PWM output. period = (PSCx + 1) / 38 | ||
139 | */ | ||
140 | static void pca955x_write_psc(struct i2c_client *client, int n, u8 val) | ||
141 | { | ||
142 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | ||
143 | |||
144 | i2c_smbus_write_byte_data(client, | ||
145 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 2*n, | ||
146 | val); | ||
147 | } | ||
148 | |||
149 | /* | ||
150 | * Write to PWM register, which determines the duty cycle of the | ||
151 | * output. LED is OFF when the count is less than the value of this | ||
152 | * register, and ON when it is greater. If PWMx == 0, LED is always OFF. | ||
153 | * | ||
154 | * Duty cycle is (256 - PWMx) / 256 | ||
155 | */ | ||
156 | static void pca955x_write_pwm(struct i2c_client *client, int n, u8 val) | ||
157 | { | ||
158 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | ||
159 | |||
160 | i2c_smbus_write_byte_data(client, | ||
161 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 1 + 2*n, | ||
162 | val); | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * Write to LED selector register, which determines the source that | ||
167 | * drives the LED output. | ||
168 | */ | ||
169 | static void pca955x_write_ls(struct i2c_client *client, int n, u8 val) | ||
170 | { | ||
171 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | ||
172 | |||
173 | i2c_smbus_write_byte_data(client, | ||
174 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n, | ||
175 | val); | ||
176 | } | ||
177 | |||
178 | /* | ||
179 | * Read the LED selector register, which determines the source that | ||
180 | * drives the LED output. | ||
181 | */ | ||
182 | static u8 pca955x_read_ls(struct i2c_client *client, int n) | ||
183 | { | ||
184 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | ||
185 | |||
186 | return (u8) i2c_smbus_read_byte_data(client, | ||
187 | pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n); | ||
188 | } | ||
189 | |||
190 | static void pca955x_led_work(struct work_struct *work) | ||
191 | { | ||
192 | struct pca955x_led *pca955x; | ||
193 | u8 ls; | ||
194 | int chip_ls; /* which LSx to use (0-3 potentially) */ | ||
195 | int ls_led; /* which set of bits within LSx to use (0-3) */ | ||
196 | |||
197 | pca955x = container_of(work, struct pca955x_led, work); | ||
198 | chip_ls = pca955x->led_num / 4; | ||
199 | ls_led = pca955x->led_num % 4; | ||
200 | |||
201 | ls = pca955x_read_ls(pca955x->client, chip_ls); | ||
202 | |||
203 | switch (pca955x->brightness) { | ||
204 | case LED_FULL: | ||
205 | ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_ON); | ||
206 | break; | ||
207 | case LED_OFF: | ||
208 | ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_OFF); | ||
209 | break; | ||
210 | case LED_HALF: | ||
211 | ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_BLINK0); | ||
212 | break; | ||
213 | default: | ||
214 | /* | ||
215 | * Use PWM1 for all other values. This has the unwanted | ||
216 | * side effect of making all LEDs on the chip share the | ||
217 | * same brightness level if set to a value other than | ||
218 | * OFF, HALF, or FULL. But, this is probably better than | ||
219 | * just turning off for all other values. | ||
220 | */ | ||
221 | pca955x_write_pwm(pca955x->client, 1, 255-pca955x->brightness); | ||
222 | ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_BLINK1); | ||
223 | break; | ||
224 | } | ||
225 | |||
226 | pca955x_write_ls(pca955x->client, chip_ls, ls); | ||
227 | } | ||
228 | |||
229 | void pca955x_led_set(struct led_classdev *led_cdev, enum led_brightness value) | ||
230 | { | ||
231 | struct pca955x_led *pca955x; | ||
232 | |||
233 | pca955x = container_of(led_cdev, struct pca955x_led, led_cdev); | ||
234 | |||
235 | spin_lock(&pca955x->lock); | ||
236 | pca955x->brightness = value; | ||
237 | |||
238 | /* | ||
239 | * Must use workqueue for the actual I/O since I2C operations | ||
240 | * can sleep. | ||
241 | */ | ||
242 | schedule_work(&pca955x->work); | ||
243 | |||
244 | spin_unlock(&pca955x->lock); | ||
245 | } | ||
246 | |||
247 | static int __devinit pca955x_probe(struct i2c_client *client, | ||
248 | const struct i2c_device_id *id) | ||
249 | { | ||
250 | struct pca955x_led *pca955x; | ||
251 | int i; | ||
252 | int err = -ENODEV; | ||
253 | struct pca955x_chipdef *chip; | ||
254 | struct i2c_adapter *adapter; | ||
255 | struct led_platform_data *pdata; | ||
256 | |||
257 | chip = &pca955x_chipdefs[id->driver_data]; | ||
258 | adapter = to_i2c_adapter(client->dev.parent); | ||
259 | pdata = client->dev.platform_data; | ||
260 | |||
261 | /* Make sure the slave address / chip type combo given is possible */ | ||
262 | if ((client->addr & ~((1 << chip->slv_addr_shift) - 1)) != | ||
263 | chip->slv_addr) { | ||
264 | dev_err(&client->dev, "invalid slave address %02x\n", | ||
265 | client->addr); | ||
266 | return -ENODEV; | ||
267 | } | ||
268 | |||
269 | printk(KERN_INFO "leds-pca955x: Using %s %d-bit LED driver at " | ||
270 | "slave address 0x%02x\n", | ||
271 | id->name, chip->bits, client->addr); | ||
272 | |||
273 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) | ||
274 | return -EIO; | ||
275 | |||
276 | if (pdata) { | ||
277 | if (pdata->num_leds != chip->bits) { | ||
278 | dev_err(&client->dev, "board info claims %d LEDs" | ||
279 | " on a %d-bit chip\n", | ||
280 | pdata->num_leds, chip->bits); | ||
281 | return -ENODEV; | ||
282 | } | ||
283 | } | ||
284 | |||
285 | for (i = 0; i < chip->bits; i++) { | ||
286 | pca955x = kzalloc(sizeof(struct pca955x_led), GFP_KERNEL); | ||
287 | if (!pca955x) { | ||
288 | err = -ENOMEM; | ||
289 | goto exit; | ||
290 | } | ||
291 | |||
292 | pca955x->chipdef = chip; | ||
293 | pca955x->client = client; | ||
294 | pca955x->led_num = i; | ||
295 | /* Platform data can specify LED names and default triggers */ | ||
296 | if (pdata) { | ||
297 | if (pdata->leds[i].name) | ||
298 | snprintf(pca955x->name, 32, "pca955x:%s", | ||
299 | pdata->leds[i].name); | ||
300 | if (pdata->leds[i].default_trigger) | ||
301 | pca955x->led_cdev.default_trigger = | ||
302 | pdata->leds[i].default_trigger; | ||
303 | } else { | ||
304 | snprintf(pca955x->name, 32, "pca955x:%d", i); | ||
305 | } | ||
306 | spin_lock_init(&pca955x->lock); | ||
307 | |||
308 | pca955x->led_cdev.name = pca955x->name; | ||
309 | pca955x->led_cdev.brightness_set = | ||
310 | pca955x_led_set; | ||
311 | |||
312 | /* | ||
313 | * Client data is a pointer to the _first_ pca955x_led | ||
314 | * struct | ||
315 | */ | ||
316 | if (i == 0) | ||
317 | i2c_set_clientdata(client, pca955x); | ||
318 | |||
319 | INIT_WORK(&(pca955x->work), pca955x_led_work); | ||
320 | |||
321 | led_classdev_register(&client->dev, &(pca955x->led_cdev)); | ||
322 | } | ||
323 | |||
324 | /* Turn off LEDs */ | ||
325 | for (i = 0; i < pca95xx_num_led_regs(chip->bits); i++) | ||
326 | pca955x_write_ls(client, i, 0x55); | ||
327 | |||
328 | /* PWM0 is used for half brightness or 50% duty cycle */ | ||
329 | pca955x_write_pwm(client, 0, 255-LED_HALF); | ||
330 | |||
331 | /* PWM1 is used for variable brightness, default to OFF */ | ||
332 | pca955x_write_pwm(client, 1, 0); | ||
333 | |||
334 | /* Set to fast frequency so we do not see flashing */ | ||
335 | pca955x_write_psc(client, 0, 0); | ||
336 | pca955x_write_psc(client, 1, 0); | ||
337 | |||
338 | return 0; | ||
339 | exit: | ||
340 | return err; | ||
341 | } | ||
342 | |||
343 | static int __devexit pca955x_remove(struct i2c_client *client) | ||
344 | { | ||
345 | struct pca955x_led *pca955x = i2c_get_clientdata(client); | ||
346 | int leds = pca955x->chipdef->bits; | ||
347 | int i; | ||
348 | |||
349 | for (i = 0; i < leds; i++) { | ||
350 | led_classdev_unregister(&(pca955x->led_cdev)); | ||
351 | cancel_work_sync(&(pca955x->work)); | ||
352 | kfree(pca955x); | ||
353 | pca955x = pca955x + 1; | ||
354 | } | ||
355 | |||
356 | return 0; | ||
357 | } | ||
358 | |||
359 | static struct i2c_driver pca955x_driver = { | ||
360 | .driver = { | ||
361 | .name = "leds-pca955x", | ||
362 | .owner = THIS_MODULE, | ||
363 | }, | ||
364 | .probe = pca955x_probe, | ||
365 | .remove = __devexit_p(pca955x_remove), | ||
366 | .id_table = pca955x_id, | ||
367 | }; | ||
368 | |||
369 | static int __init pca955x_leds_init(void) | ||
370 | { | ||
371 | return i2c_add_driver(&pca955x_driver); | ||
372 | } | ||
373 | |||
374 | static void __exit pca955x_leds_exit(void) | ||
375 | { | ||
376 | i2c_del_driver(&pca955x_driver); | ||
377 | } | ||
378 | |||
379 | module_init(pca955x_leds_init); | ||
380 | module_exit(pca955x_leds_exit); | ||
381 | |||
382 | MODULE_AUTHOR("Nate Case <ncase@xes-inc.com>"); | ||
383 | MODULE_DESCRIPTION("PCA955x LED driver"); | ||
384 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 1a8de57289eb..37344aaee22f 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -98,16 +98,20 @@ static u32 lg_get_features(struct virtio_device *vdev) | |||
98 | return features; | 98 | return features; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void lg_set_features(struct virtio_device *vdev, u32 features) | 101 | static void lg_finalize_features(struct virtio_device *vdev) |
102 | { | 102 | { |
103 | unsigned int i; | 103 | unsigned int i, bits; |
104 | struct lguest_device_desc *desc = to_lgdev(vdev)->desc; | 104 | struct lguest_device_desc *desc = to_lgdev(vdev)->desc; |
105 | /* Second half of bitmap is features we accept. */ | 105 | /* Second half of bitmap is features we accept. */ |
106 | u8 *out_features = lg_features(desc) + desc->feature_len; | 106 | u8 *out_features = lg_features(desc) + desc->feature_len; |
107 | 107 | ||
108 | /* Give virtio_ring a chance to accept features. */ | ||
109 | vring_transport_features(vdev); | ||
110 | |||
108 | memset(out_features, 0, desc->feature_len); | 111 | memset(out_features, 0, desc->feature_len); |
109 | for (i = 0; i < min(desc->feature_len * 8, 32); i++) { | 112 | bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; |
110 | if (features & (1 << i)) | 113 | for (i = 0; i < bits; i++) { |
114 | if (test_bit(i, vdev->features)) | ||
111 | out_features[i / 8] |= (1 << (i % 8)); | 115 | out_features[i / 8] |= (1 << (i % 8)); |
112 | } | 116 | } |
113 | } | 117 | } |
@@ -297,7 +301,7 @@ static void lg_del_vq(struct virtqueue *vq) | |||
297 | /* The ops structure which hooks everything together. */ | 301 | /* The ops structure which hooks everything together. */ |
298 | static struct virtio_config_ops lguest_config_ops = { | 302 | static struct virtio_config_ops lguest_config_ops = { |
299 | .get_features = lg_get_features, | 303 | .get_features = lg_get_features, |
300 | .set_features = lg_set_features, | 304 | .finalize_features = lg_finalize_features, |
301 | .get = lg_get, | 305 | .get = lg_get, |
302 | .set = lg_set, | 306 | .set = lg_set, |
303 | .get_status = lg_get_status, | 307 | .get_status = lg_get_status, |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-dvb.c b/drivers/media/video/pvrusb2/pvrusb2-dvb.c index 6ec4bf81fc7f..77b3c3385066 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-dvb.c +++ b/drivers/media/video/pvrusb2/pvrusb2-dvb.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <linux/kthread.h> | 21 | #include <linux/kthread.h> |
22 | #include <linux/freezer.h> | 22 | #include <linux/freezer.h> |
23 | #include <linux/mm.h> | ||
23 | #include "dvbdev.h" | 24 | #include "dvbdev.h" |
24 | #include "pvrusb2-debug.h" | 25 | #include "pvrusb2-debug.h" |
25 | #include "pvrusb2-hdw-internal.h" | 26 | #include "pvrusb2-hdw-internal.h" |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.c b/drivers/media/video/pvrusb2/pvrusb2-ioread.c index 05a1376405e7..b4824782d858 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-ioread.c +++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "pvrusb2-debug.h" | 22 | #include "pvrusb2-debug.h" |
23 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
24 | #include <linux/string.h> | 24 | #include <linux/string.h> |
25 | #include <linux/mm.h> | ||
25 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
26 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
27 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c index 7388d0cee3d4..5646a6a32939 100644 --- a/drivers/media/video/uvc/uvc_queue.c +++ b/drivers/media/video/uvc/uvc_queue.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/version.h> | 15 | #include <linux/version.h> |
16 | #include <linux/mm.h> | ||
16 | #include <linux/list.h> | 17 | #include <linux/list.h> |
17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
18 | #include <linux/usb.h> | 19 | #include <linux/usb.h> |
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index 0a88c44ace00..b7b05842cf28 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/moduleparam.h> | 18 | #include <linux/moduleparam.h> |
19 | #include <linux/mm.h> | ||
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
21 | 22 | ||
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index 489d7c5c4965..8774c670e668 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c | |||
@@ -243,29 +243,41 @@ static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry) | |||
243 | 243 | ||
244 | /* create user entries for this device */ | 244 | /* create user entries for this device */ |
245 | tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid); | 245 | tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid); |
246 | if (tmp && (tmp != i2o_dev)) | 246 | if (tmp && (tmp != i2o_dev)) { |
247 | sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj, | 247 | rc = sysfs_create_link(&i2o_dev->device.kobj, |
248 | "user"); | 248 | &tmp->device.kobj, "user"); |
249 | if (rc) | ||
250 | goto unreg_dev; | ||
251 | } | ||
249 | 252 | ||
250 | /* create user entries refering to this device */ | 253 | /* create user entries refering to this device */ |
251 | list_for_each_entry(tmp, &c->devices, list) | 254 | list_for_each_entry(tmp, &c->devices, list) |
252 | if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid) | 255 | if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid) |
253 | && (tmp != i2o_dev)) | 256 | && (tmp != i2o_dev)) { |
254 | sysfs_create_link(&tmp->device.kobj, | 257 | rc = sysfs_create_link(&tmp->device.kobj, |
255 | &i2o_dev->device.kobj, "user"); | 258 | &i2o_dev->device.kobj, "user"); |
259 | if (rc) | ||
260 | goto rmlink1; | ||
261 | } | ||
256 | 262 | ||
257 | /* create parent entries for this device */ | 263 | /* create parent entries for this device */ |
258 | tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); | 264 | tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); |
259 | if (tmp && (tmp != i2o_dev)) | 265 | if (tmp && (tmp != i2o_dev)) { |
260 | sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj, | 266 | rc = sysfs_create_link(&i2o_dev->device.kobj, |
261 | "parent"); | 267 | &tmp->device.kobj, "parent"); |
268 | if (rc) | ||
269 | goto rmlink1; | ||
270 | } | ||
262 | 271 | ||
263 | /* create parent entries refering to this device */ | 272 | /* create parent entries refering to this device */ |
264 | list_for_each_entry(tmp, &c->devices, list) | 273 | list_for_each_entry(tmp, &c->devices, list) |
265 | if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) | 274 | if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) |
266 | && (tmp != i2o_dev)) | 275 | && (tmp != i2o_dev)) { |
267 | sysfs_create_link(&tmp->device.kobj, | 276 | rc = sysfs_create_link(&tmp->device.kobj, |
268 | &i2o_dev->device.kobj, "parent"); | 277 | &i2o_dev->device.kobj, "parent"); |
278 | if (rc) | ||
279 | goto rmlink2; | ||
280 | } | ||
269 | 281 | ||
270 | i2o_driver_notify_device_add_all(i2o_dev); | 282 | i2o_driver_notify_device_add_all(i2o_dev); |
271 | 283 | ||
@@ -273,6 +285,24 @@ static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry) | |||
273 | 285 | ||
274 | return 0; | 286 | return 0; |
275 | 287 | ||
288 | rmlink2: | ||
289 | /* If link creating failed halfway, we loop whole list to cleanup. | ||
290 | * And we don't care wrong removing of link, because sysfs_remove_link | ||
291 | * will take care of it. | ||
292 | */ | ||
293 | list_for_each_entry(tmp, &c->devices, list) { | ||
294 | if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) | ||
295 | sysfs_remove_link(&tmp->device.kobj, "parent"); | ||
296 | } | ||
297 | sysfs_remove_link(&i2o_dev->device.kobj, "parent"); | ||
298 | rmlink1: | ||
299 | list_for_each_entry(tmp, &c->devices, list) | ||
300 | if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid) | ||
301 | sysfs_remove_link(&tmp->device.kobj, "user"); | ||
302 | sysfs_remove_link(&i2o_dev->device.kobj, "user"); | ||
303 | unreg_dev: | ||
304 | list_del(&i2o_dev->list); | ||
305 | device_unregister(&i2o_dev->device); | ||
276 | err: | 306 | err: |
277 | kfree(i2o_dev); | 307 | kfree(i2o_dev); |
278 | return rc; | 308 | return rc; |
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 9f93c29fed35..1f57a99fd968 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -19,6 +19,14 @@ config MFD_SM501 | |||
19 | interface. The device may be connected by PCI or local bus with | 19 | interface. The device may be connected by PCI or local bus with |
20 | varying functions enabled. | 20 | varying functions enabled. |
21 | 21 | ||
22 | config MFD_SM501_GPIO | ||
23 | bool "Export GPIO via GPIO layer" | ||
24 | depends on MFD_SM501 && HAVE_GPIO_LIB | ||
25 | ---help--- | ||
26 | This option uses the gpio library layer to export the 64 GPIO | ||
27 | lines on the SM501. The platform data is used to supply the | ||
28 | base number for the first GPIO line to register. | ||
29 | |||
22 | config MFD_ASIC3 | 30 | config MFD_ASIC3 |
23 | bool "Support for Compaq ASIC3" | 31 | bool "Support for Compaq ASIC3" |
24 | depends on GENERIC_HARDIRQS && HAVE_GPIO_LIB && ARM | 32 | depends on GENERIC_HARDIRQS && HAVE_GPIO_LIB && ARM |
@@ -28,7 +36,7 @@ config MFD_ASIC3 | |||
28 | 36 | ||
29 | config HTC_EGPIO | 37 | config HTC_EGPIO |
30 | bool "HTC EGPIO support" | 38 | bool "HTC EGPIO support" |
31 | depends on GENERIC_HARDIRQS && HAVE_GPIO_LIB && ARM | 39 | depends on GENERIC_HARDIRQS && GPIOLIB && ARM |
32 | help | 40 | help |
33 | This driver supports the CPLD egpio chip present on | 41 | This driver supports the CPLD egpio chip present on |
34 | several HTC phones. It provides basic support for input | 42 | several HTC phones. It provides basic support for input |
@@ -44,7 +52,7 @@ config HTC_PASIC3 | |||
44 | 52 | ||
45 | config MFD_TC6393XB | 53 | config MFD_TC6393XB |
46 | bool "Support Toshiba TC6393XB" | 54 | bool "Support Toshiba TC6393XB" |
47 | depends on HAVE_GPIO_LIB | 55 | depends on GPIOLIB |
48 | select MFD_CORE | 56 | select MFD_CORE |
49 | help | 57 | help |
50 | Support for Toshiba Mobile IO Controller TC6393XB | 58 | Support for Toshiba Mobile IO Controller TC6393XB |
diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c index 8872cc077519..6be43172dc65 100644 --- a/drivers/mfd/htc-egpio.c +++ b/drivers/mfd/htc-egpio.c | |||
@@ -318,6 +318,8 @@ static int __init egpio_probe(struct platform_device *pdev) | |||
318 | ei->chip[i].dev = &(pdev->dev); | 318 | ei->chip[i].dev = &(pdev->dev); |
319 | chip = &(ei->chip[i].chip); | 319 | chip = &(ei->chip[i].chip); |
320 | chip->label = "htc-egpio"; | 320 | chip->label = "htc-egpio"; |
321 | chip->dev = &pdev->dev; | ||
322 | chip->owner = THIS_MODULE; | ||
321 | chip->get = egpio_get; | 323 | chip->get = egpio_get; |
322 | chip->set = egpio_set; | 324 | chip->set = egpio_set; |
323 | chip->direction_input = egpio_direction_input; | 325 | chip->direction_input = egpio_direction_input; |
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c index 633cbba072f0..91b294dcc133 100644 --- a/drivers/mfd/htc-pasic3.c +++ b/drivers/mfd/htc-pasic3.c | |||
@@ -238,6 +238,8 @@ static int pasic3_remove(struct platform_device *pdev) | |||
238 | return 0; | 238 | return 0; |
239 | } | 239 | } |
240 | 240 | ||
241 | MODULE_ALIAS("platform:pasic3"); | ||
242 | |||
241 | static struct platform_driver pasic3_driver = { | 243 | static struct platform_driver pasic3_driver = { |
242 | .driver = { | 244 | .driver = { |
243 | .name = "pasic3", | 245 | .name = "pasic3", |
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index 1eab7cffceaa..b5272b5ce3fa 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c | |||
@@ -242,6 +242,8 @@ static int mcp_sa11x0_resume(struct platform_device *dev) | |||
242 | /* | 242 | /* |
243 | * The driver for the SA11x0 MCP port. | 243 | * The driver for the SA11x0 MCP port. |
244 | */ | 244 | */ |
245 | MODULE_ALIAS("platform:sa11x0-mcp"); | ||
246 | |||
245 | static struct platform_driver mcp_sa11x0_driver = { | 247 | static struct platform_driver mcp_sa11x0_driver = { |
246 | .probe = mcp_sa11x0_probe, | 248 | .probe = mcp_sa11x0_probe, |
247 | .remove = mcp_sa11x0_remove, | 249 | .remove = mcp_sa11x0_remove, |
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index d7d88ce053a6..0454be4266c1 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c | |||
@@ -36,7 +36,7 @@ static int mfd_add_device(struct platform_device *parent, | |||
36 | if (ret) | 36 | if (ret) |
37 | goto fail_device; | 37 | goto fail_device; |
38 | 38 | ||
39 | memzero(res, sizeof(res)); | 39 | memset(res, 0, sizeof(res)); |
40 | for (r = 0; r < cell->num_resources; r++) { | 40 | for (r = 0; r < cell->num_resources; r++) { |
41 | res[r].name = cell->resources[r].name; | 41 | res[r].name = cell->resources[r].name; |
42 | res[r].flags = cell->resources[r].flags; | 42 | res[r].flags = cell->resources[r].flags; |
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index 2fe64734d8af..7aebad4c06ff 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/device.h> | 19 | #include <linux/device.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
22 | #include <linux/i2c-gpio.h> | ||
22 | 23 | ||
23 | #include <linux/sm501.h> | 24 | #include <linux/sm501.h> |
24 | #include <linux/sm501-regs.h> | 25 | #include <linux/sm501-regs.h> |
@@ -31,10 +32,37 @@ struct sm501_device { | |||
31 | struct platform_device pdev; | 32 | struct platform_device pdev; |
32 | }; | 33 | }; |
33 | 34 | ||
35 | struct sm501_gpio; | ||
36 | |||
37 | #ifdef CONFIG_MFD_SM501_GPIO | ||
38 | #include <linux/gpio.h> | ||
39 | |||
40 | struct sm501_gpio_chip { | ||
41 | struct gpio_chip gpio; | ||
42 | struct sm501_gpio *ourgpio; /* to get back to parent. */ | ||
43 | void __iomem *regbase; | ||
44 | }; | ||
45 | |||
46 | struct sm501_gpio { | ||
47 | struct sm501_gpio_chip low; | ||
48 | struct sm501_gpio_chip high; | ||
49 | spinlock_t lock; | ||
50 | |||
51 | unsigned int registered : 1; | ||
52 | void __iomem *regs; | ||
53 | struct resource *regs_res; | ||
54 | }; | ||
55 | #else | ||
56 | struct sm501_gpio { | ||
57 | /* no gpio support, empty definition for sm501_devdata. */ | ||
58 | }; | ||
59 | #endif | ||
60 | |||
34 | struct sm501_devdata { | 61 | struct sm501_devdata { |
35 | spinlock_t reg_lock; | 62 | spinlock_t reg_lock; |
36 | struct mutex clock_lock; | 63 | struct mutex clock_lock; |
37 | struct list_head devices; | 64 | struct list_head devices; |
65 | struct sm501_gpio gpio; | ||
38 | 66 | ||
39 | struct device *dev; | 67 | struct device *dev; |
40 | struct resource *io_res; | 68 | struct resource *io_res; |
@@ -42,6 +70,7 @@ struct sm501_devdata { | |||
42 | struct resource *regs_claim; | 70 | struct resource *regs_claim; |
43 | struct sm501_platdata *platdata; | 71 | struct sm501_platdata *platdata; |
44 | 72 | ||
73 | |||
45 | unsigned int in_suspend; | 74 | unsigned int in_suspend; |
46 | unsigned long pm_misc; | 75 | unsigned long pm_misc; |
47 | 76 | ||
@@ -52,6 +81,7 @@ struct sm501_devdata { | |||
52 | unsigned int rev; | 81 | unsigned int rev; |
53 | }; | 82 | }; |
54 | 83 | ||
84 | |||
55 | #define MHZ (1000 * 1000) | 85 | #define MHZ (1000 * 1000) |
56 | 86 | ||
57 | #ifdef DEBUG | 87 | #ifdef DEBUG |
@@ -276,58 +306,6 @@ unsigned long sm501_modify_reg(struct device *dev, | |||
276 | 306 | ||
277 | EXPORT_SYMBOL_GPL(sm501_modify_reg); | 307 | EXPORT_SYMBOL_GPL(sm501_modify_reg); |
278 | 308 | ||
279 | unsigned long sm501_gpio_get(struct device *dev, | ||
280 | unsigned long gpio) | ||
281 | { | ||
282 | struct sm501_devdata *sm = dev_get_drvdata(dev); | ||
283 | unsigned long result; | ||
284 | unsigned long reg; | ||
285 | |||
286 | reg = (gpio > 32) ? SM501_GPIO_DATA_HIGH : SM501_GPIO_DATA_LOW; | ||
287 | result = readl(sm->regs + reg); | ||
288 | |||
289 | result >>= (gpio & 31); | ||
290 | return result & 1UL; | ||
291 | } | ||
292 | |||
293 | EXPORT_SYMBOL_GPL(sm501_gpio_get); | ||
294 | |||
295 | void sm501_gpio_set(struct device *dev, | ||
296 | unsigned long gpio, | ||
297 | unsigned int to, | ||
298 | unsigned int dir) | ||
299 | { | ||
300 | struct sm501_devdata *sm = dev_get_drvdata(dev); | ||
301 | |||
302 | unsigned long bit = 1 << (gpio & 31); | ||
303 | unsigned long base; | ||
304 | unsigned long save; | ||
305 | unsigned long val; | ||
306 | |||
307 | base = (gpio > 32) ? SM501_GPIO_DATA_HIGH : SM501_GPIO_DATA_LOW; | ||
308 | base += SM501_GPIO; | ||
309 | |||
310 | spin_lock_irqsave(&sm->reg_lock, save); | ||
311 | |||
312 | val = readl(sm->regs + base) & ~bit; | ||
313 | if (to) | ||
314 | val |= bit; | ||
315 | writel(val, sm->regs + base); | ||
316 | |||
317 | val = readl(sm->regs + SM501_GPIO_DDR_LOW) & ~bit; | ||
318 | if (dir) | ||
319 | val |= bit; | ||
320 | |||
321 | writel(val, sm->regs + SM501_GPIO_DDR_LOW); | ||
322 | sm501_sync_regs(sm); | ||
323 | |||
324 | spin_unlock_irqrestore(&sm->reg_lock, save); | ||
325 | |||
326 | } | ||
327 | |||
328 | EXPORT_SYMBOL_GPL(sm501_gpio_set); | ||
329 | |||
330 | |||
331 | /* sm501_unit_power | 309 | /* sm501_unit_power |
332 | * | 310 | * |
333 | * alters the power active gate to set specific units on or off | 311 | * alters the power active gate to set specific units on or off |
@@ -906,6 +884,313 @@ static int sm501_register_display(struct sm501_devdata *sm, | |||
906 | return sm501_register_device(sm, pdev); | 884 | return sm501_register_device(sm, pdev); |
907 | } | 885 | } |
908 | 886 | ||
887 | #ifdef CONFIG_MFD_SM501_GPIO | ||
888 | |||
889 | static inline struct sm501_gpio_chip *to_sm501_gpio(struct gpio_chip *gc) | ||
890 | { | ||
891 | return container_of(gc, struct sm501_gpio_chip, gpio); | ||
892 | } | ||
893 | |||
894 | static inline struct sm501_devdata *sm501_gpio_to_dev(struct sm501_gpio *gpio) | ||
895 | { | ||
896 | return container_of(gpio, struct sm501_devdata, gpio); | ||
897 | } | ||
898 | |||
899 | static int sm501_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
900 | |||
901 | { | ||
902 | struct sm501_gpio_chip *smgpio = to_sm501_gpio(chip); | ||
903 | unsigned long result; | ||
904 | |||
905 | result = readl(smgpio->regbase + SM501_GPIO_DATA_LOW); | ||
906 | result >>= offset; | ||
907 | |||
908 | return result & 1UL; | ||
909 | } | ||
910 | |||
911 | static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
912 | |||
913 | { | ||
914 | struct sm501_gpio_chip *smchip = to_sm501_gpio(chip); | ||
915 | struct sm501_gpio *smgpio = smchip->ourgpio; | ||
916 | unsigned long bit = 1 << offset; | ||
917 | void __iomem *regs = smchip->regbase; | ||
918 | unsigned long save; | ||
919 | unsigned long val; | ||
920 | |||
921 | dev_dbg(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d)\n", | ||
922 | __func__, chip, offset); | ||
923 | |||
924 | spin_lock_irqsave(&smgpio->lock, save); | ||
925 | |||
926 | val = readl(regs + SM501_GPIO_DATA_LOW) & ~bit; | ||
927 | if (value) | ||
928 | val |= bit; | ||
929 | writel(val, regs); | ||
930 | |||
931 | sm501_sync_regs(sm501_gpio_to_dev(smgpio)); | ||
932 | spin_unlock_irqrestore(&smgpio->lock, save); | ||
933 | } | ||
934 | |||
935 | static int sm501_gpio_input(struct gpio_chip *chip, unsigned offset) | ||
936 | { | ||
937 | struct sm501_gpio_chip *smchip = to_sm501_gpio(chip); | ||
938 | struct sm501_gpio *smgpio = smchip->ourgpio; | ||
939 | void __iomem *regs = smchip->regbase; | ||
940 | unsigned long bit = 1 << offset; | ||
941 | unsigned long save; | ||
942 | unsigned long ddr; | ||
943 | |||
944 | dev_info(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d)\n", | ||
945 | __func__, chip, offset); | ||
946 | |||
947 | spin_lock_irqsave(&smgpio->lock, save); | ||
948 | |||
949 | ddr = readl(regs + SM501_GPIO_DDR_LOW); | ||
950 | writel(ddr & ~bit, regs + SM501_GPIO_DDR_LOW); | ||
951 | |||
952 | sm501_sync_regs(sm501_gpio_to_dev(smgpio)); | ||
953 | spin_unlock_irqrestore(&smgpio->lock, save); | ||
954 | |||
955 | return 0; | ||
956 | } | ||
957 | |||
958 | static int sm501_gpio_output(struct gpio_chip *chip, | ||
959 | unsigned offset, int value) | ||
960 | { | ||
961 | struct sm501_gpio_chip *smchip = to_sm501_gpio(chip); | ||
962 | struct sm501_gpio *smgpio = smchip->ourgpio; | ||
963 | unsigned long bit = 1 << offset; | ||
964 | void __iomem *regs = smchip->regbase; | ||
965 | unsigned long save; | ||
966 | unsigned long val; | ||
967 | unsigned long ddr; | ||
968 | |||
969 | dev_dbg(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d,%d)\n", | ||
970 | __func__, chip, offset, value); | ||
971 | |||
972 | spin_lock_irqsave(&smgpio->lock, save); | ||
973 | |||
974 | val = readl(regs + SM501_GPIO_DATA_LOW); | ||
975 | if (value) | ||
976 | val |= bit; | ||
977 | else | ||
978 | val &= ~bit; | ||
979 | writel(val, regs); | ||
980 | |||
981 | ddr = readl(regs + SM501_GPIO_DDR_LOW); | ||
982 | writel(ddr | bit, regs + SM501_GPIO_DDR_LOW); | ||
983 | |||
984 | sm501_sync_regs(sm501_gpio_to_dev(smgpio)); | ||
985 | writel(val, regs + SM501_GPIO_DATA_LOW); | ||
986 | |||
987 | sm501_sync_regs(sm501_gpio_to_dev(smgpio)); | ||
988 | spin_unlock_irqrestore(&smgpio->lock, save); | ||
989 | |||
990 | return 0; | ||
991 | } | ||
992 | |||
993 | static struct gpio_chip gpio_chip_template = { | ||
994 | .ngpio = 32, | ||
995 | .direction_input = sm501_gpio_input, | ||
996 | .direction_output = sm501_gpio_output, | ||
997 | .set = sm501_gpio_set, | ||
998 | .get = sm501_gpio_get, | ||
999 | }; | ||
1000 | |||
1001 | static int __devinit sm501_gpio_register_chip(struct sm501_devdata *sm, | ||
1002 | struct sm501_gpio *gpio, | ||
1003 | struct sm501_gpio_chip *chip) | ||
1004 | { | ||
1005 | struct sm501_platdata *pdata = sm->platdata; | ||
1006 | struct gpio_chip *gchip = &chip->gpio; | ||
1007 | int base = pdata->gpio_base; | ||
1008 | |||
1009 | chip->gpio = gpio_chip_template; | ||
1010 | |||
1011 | if (chip == &gpio->high) { | ||
1012 | if (base > 0) | ||
1013 | base += 32; | ||
1014 | chip->regbase = gpio->regs + SM501_GPIO_DATA_HIGH; | ||
1015 | gchip->label = "SM501-HIGH"; | ||
1016 | } else { | ||
1017 | chip->regbase = gpio->regs + SM501_GPIO_DATA_LOW; | ||
1018 | gchip->label = "SM501-LOW"; | ||
1019 | } | ||
1020 | |||
1021 | gchip->base = base; | ||
1022 | chip->ourgpio = gpio; | ||
1023 | |||
1024 | return gpiochip_add(gchip); | ||
1025 | } | ||
1026 | |||
1027 | static int sm501_register_gpio(struct sm501_devdata *sm) | ||
1028 | { | ||
1029 | struct sm501_gpio *gpio = &sm->gpio; | ||
1030 | resource_size_t iobase = sm->io_res->start + SM501_GPIO; | ||
1031 | int ret; | ||
1032 | int tmp; | ||
1033 | |||
1034 | dev_dbg(sm->dev, "registering gpio block %08llx\n", | ||
1035 | (unsigned long long)iobase); | ||
1036 | |||
1037 | spin_lock_init(&gpio->lock); | ||
1038 | |||
1039 | gpio->regs_res = request_mem_region(iobase, 0x20, "sm501-gpio"); | ||
1040 | if (gpio->regs_res == NULL) { | ||
1041 | dev_err(sm->dev, "gpio: failed to request region\n"); | ||
1042 | return -ENXIO; | ||
1043 | } | ||
1044 | |||
1045 | gpio->regs = ioremap(iobase, 0x20); | ||
1046 | if (gpio->regs == NULL) { | ||
1047 | dev_err(sm->dev, "gpio: failed to remap registers\n"); | ||
1048 | ret = -ENXIO; | ||
1049 | goto err_claimed; | ||
1050 | } | ||
1051 | |||
1052 | /* Register both our chips. */ | ||
1053 | |||
1054 | ret = sm501_gpio_register_chip(sm, gpio, &gpio->low); | ||
1055 | if (ret) { | ||
1056 | dev_err(sm->dev, "failed to add low chip\n"); | ||
1057 | goto err_mapped; | ||
1058 | } | ||
1059 | |||
1060 | ret = sm501_gpio_register_chip(sm, gpio, &gpio->high); | ||
1061 | if (ret) { | ||
1062 | dev_err(sm->dev, "failed to add high chip\n"); | ||
1063 | goto err_low_chip; | ||
1064 | } | ||
1065 | |||
1066 | gpio->registered = 1; | ||
1067 | |||
1068 | return 0; | ||
1069 | |||
1070 | err_low_chip: | ||
1071 | tmp = gpiochip_remove(&gpio->low.gpio); | ||
1072 | if (tmp) { | ||
1073 | dev_err(sm->dev, "cannot remove low chip, cannot tidy up\n"); | ||
1074 | return ret; | ||
1075 | } | ||
1076 | |||
1077 | err_mapped: | ||
1078 | iounmap(gpio->regs); | ||
1079 | |||
1080 | err_claimed: | ||
1081 | release_resource(gpio->regs_res); | ||
1082 | kfree(gpio->regs_res); | ||
1083 | |||
1084 | return ret; | ||
1085 | } | ||
1086 | |||
1087 | static void sm501_gpio_remove(struct sm501_devdata *sm) | ||
1088 | { | ||
1089 | struct sm501_gpio *gpio = &sm->gpio; | ||
1090 | int ret; | ||
1091 | |||
1092 | if (!sm->gpio.registered) | ||
1093 | return; | ||
1094 | |||
1095 | ret = gpiochip_remove(&gpio->low.gpio); | ||
1096 | if (ret) | ||
1097 | dev_err(sm->dev, "cannot remove low chip, cannot tidy up\n"); | ||
1098 | |||
1099 | ret = gpiochip_remove(&gpio->high.gpio); | ||
1100 | if (ret) | ||
1101 | dev_err(sm->dev, "cannot remove high chip, cannot tidy up\n"); | ||
1102 | |||
1103 | iounmap(gpio->regs); | ||
1104 | release_resource(gpio->regs_res); | ||
1105 | kfree(gpio->regs_res); | ||
1106 | } | ||
1107 | |||
1108 | static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin) | ||
1109 | { | ||
1110 | struct sm501_gpio *gpio = &sm->gpio; | ||
1111 | int base = (pin < 32) ? gpio->low.gpio.base : gpio->high.gpio.base; | ||
1112 | |||
1113 | return (pin % 32) + base; | ||
1114 | } | ||
1115 | |||
1116 | static inline int sm501_gpio_isregistered(struct sm501_devdata *sm) | ||
1117 | { | ||
1118 | return sm->gpio.registered; | ||
1119 | } | ||
1120 | #else | ||
1121 | static inline int sm501_register_gpio(struct sm501_devdata *sm) | ||
1122 | { | ||
1123 | return 0; | ||
1124 | } | ||
1125 | |||
1126 | static inline void sm501_gpio_remove(struct sm501_devdata *sm) | ||
1127 | { | ||
1128 | } | ||
1129 | |||
1130 | static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin) | ||
1131 | { | ||
1132 | return -1; | ||
1133 | } | ||
1134 | |||
1135 | static inline int sm501_gpio_isregistered(struct sm501_devdata *sm) | ||
1136 | { | ||
1137 | return 0; | ||
1138 | } | ||
1139 | #endif | ||
1140 | |||
1141 | static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm, | ||
1142 | struct sm501_platdata_gpio_i2c *iic) | ||
1143 | { | ||
1144 | struct i2c_gpio_platform_data *icd; | ||
1145 | struct platform_device *pdev; | ||
1146 | |||
1147 | pdev = sm501_create_subdev(sm, "i2c-gpio", 0, | ||
1148 | sizeof(struct i2c_gpio_platform_data)); | ||
1149 | if (!pdev) | ||
1150 | return -ENOMEM; | ||
1151 | |||
1152 | icd = pdev->dev.platform_data; | ||
1153 | |||
1154 | /* We keep the pin_sda and pin_scl fields relative in case the | ||
1155 | * same platform data is passed to >1 SM501. | ||
1156 | */ | ||
1157 | |||
1158 | icd->sda_pin = sm501_gpio_pin2nr(sm, iic->pin_sda); | ||
1159 | icd->scl_pin = sm501_gpio_pin2nr(sm, iic->pin_scl); | ||
1160 | icd->timeout = iic->timeout; | ||
1161 | icd->udelay = iic->udelay; | ||
1162 | |||
1163 | /* note, we can't use either of the pin numbers, as the i2c-gpio | ||
1164 | * driver uses the platform.id field to generate the bus number | ||
1165 | * to register with the i2c core; The i2c core doesn't have enough | ||
1166 | * entries to deal with anything we currently use. | ||
1167 | */ | ||
1168 | |||
1169 | pdev->id = iic->bus_num; | ||
1170 | |||
1171 | dev_info(sm->dev, "registering i2c-%d: sda=%d (%d), scl=%d (%d)\n", | ||
1172 | iic->bus_num, | ||
1173 | icd->sda_pin, iic->pin_sda, icd->scl_pin, iic->pin_scl); | ||
1174 | |||
1175 | return sm501_register_device(sm, pdev); | ||
1176 | } | ||
1177 | |||
1178 | static int sm501_register_gpio_i2c(struct sm501_devdata *sm, | ||
1179 | struct sm501_platdata *pdata) | ||
1180 | { | ||
1181 | struct sm501_platdata_gpio_i2c *iic = pdata->gpio_i2c; | ||
1182 | int index; | ||
1183 | int ret; | ||
1184 | |||
1185 | for (index = 0; index < pdata->gpio_i2c_nr; index++, iic++) { | ||
1186 | ret = sm501_register_gpio_i2c_instance(sm, iic); | ||
1187 | if (ret < 0) | ||
1188 | return ret; | ||
1189 | } | ||
1190 | |||
1191 | return 0; | ||
1192 | } | ||
1193 | |||
909 | /* sm501_dbg_regs | 1194 | /* sm501_dbg_regs |
910 | * | 1195 | * |
911 | * Debug attribute to attach to parent device to show core registers | 1196 | * Debug attribute to attach to parent device to show core registers |
@@ -1013,6 +1298,7 @@ static unsigned int sm501_mem_local[] = { | |||
1013 | static int sm501_init_dev(struct sm501_devdata *sm) | 1298 | static int sm501_init_dev(struct sm501_devdata *sm) |
1014 | { | 1299 | { |
1015 | struct sm501_initdata *idata; | 1300 | struct sm501_initdata *idata; |
1301 | struct sm501_platdata *pdata; | ||
1016 | resource_size_t mem_avail; | 1302 | resource_size_t mem_avail; |
1017 | unsigned long dramctrl; | 1303 | unsigned long dramctrl; |
1018 | unsigned long devid; | 1304 | unsigned long devid; |
@@ -1051,7 +1337,9 @@ static int sm501_init_dev(struct sm501_devdata *sm) | |||
1051 | 1337 | ||
1052 | /* check to see if we have some device initialisation */ | 1338 | /* check to see if we have some device initialisation */ |
1053 | 1339 | ||
1054 | idata = sm->platdata ? sm->platdata->init : NULL; | 1340 | pdata = sm->platdata; |
1341 | idata = pdata ? pdata->init : NULL; | ||
1342 | |||
1055 | if (idata) { | 1343 | if (idata) { |
1056 | sm501_init_regs(sm, idata); | 1344 | sm501_init_regs(sm, idata); |
1057 | 1345 | ||
@@ -1059,6 +1347,15 @@ static int sm501_init_dev(struct sm501_devdata *sm) | |||
1059 | sm501_register_usbhost(sm, &mem_avail); | 1347 | sm501_register_usbhost(sm, &mem_avail); |
1060 | if (idata->devices & (SM501_USE_UART0 | SM501_USE_UART1)) | 1348 | if (idata->devices & (SM501_USE_UART0 | SM501_USE_UART1)) |
1061 | sm501_register_uart(sm, idata->devices); | 1349 | sm501_register_uart(sm, idata->devices); |
1350 | if (idata->devices & SM501_USE_GPIO) | ||
1351 | sm501_register_gpio(sm); | ||
1352 | } | ||
1353 | |||
1354 | if (pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) { | ||
1355 | if (!sm501_gpio_isregistered(sm)) | ||
1356 | dev_err(sm->dev, "no gpio available for i2c gpio.\n"); | ||
1357 | else | ||
1358 | sm501_register_gpio_i2c(sm, pdata); | ||
1062 | } | 1359 | } |
1063 | 1360 | ||
1064 | ret = sm501_check_clocks(sm); | 1361 | ret = sm501_check_clocks(sm); |
@@ -1138,8 +1435,31 @@ static int sm501_plat_probe(struct platform_device *dev) | |||
1138 | } | 1435 | } |
1139 | 1436 | ||
1140 | #ifdef CONFIG_PM | 1437 | #ifdef CONFIG_PM |
1438 | |||
1141 | /* power management support */ | 1439 | /* power management support */ |
1142 | 1440 | ||
1441 | static void sm501_set_power(struct sm501_devdata *sm, int on) | ||
1442 | { | ||
1443 | struct sm501_platdata *pd = sm->platdata; | ||
1444 | |||
1445 | if (pd == NULL) | ||
1446 | return; | ||
1447 | |||
1448 | if (pd->get_power) { | ||
1449 | if (pd->get_power(sm->dev) == on) { | ||
1450 | dev_dbg(sm->dev, "is already %d\n", on); | ||
1451 | return; | ||
1452 | } | ||
1453 | } | ||
1454 | |||
1455 | if (pd->set_power) { | ||
1456 | dev_dbg(sm->dev, "setting power to %d\n", on); | ||
1457 | |||
1458 | pd->set_power(sm->dev, on); | ||
1459 | sm501_mdelay(sm, 10); | ||
1460 | } | ||
1461 | } | ||
1462 | |||
1143 | static int sm501_plat_suspend(struct platform_device *pdev, pm_message_t state) | 1463 | static int sm501_plat_suspend(struct platform_device *pdev, pm_message_t state) |
1144 | { | 1464 | { |
1145 | struct sm501_devdata *sm = platform_get_drvdata(pdev); | 1465 | struct sm501_devdata *sm = platform_get_drvdata(pdev); |
@@ -1148,6 +1468,12 @@ static int sm501_plat_suspend(struct platform_device *pdev, pm_message_t state) | |||
1148 | sm->pm_misc = readl(sm->regs + SM501_MISC_CONTROL); | 1468 | sm->pm_misc = readl(sm->regs + SM501_MISC_CONTROL); |
1149 | 1469 | ||
1150 | sm501_dump_regs(sm); | 1470 | sm501_dump_regs(sm); |
1471 | |||
1472 | if (sm->platdata) { | ||
1473 | if (sm->platdata->flags & SM501_FLAG_SUSPEND_OFF) | ||
1474 | sm501_set_power(sm, 0); | ||
1475 | } | ||
1476 | |||
1151 | return 0; | 1477 | return 0; |
1152 | } | 1478 | } |
1153 | 1479 | ||
@@ -1155,6 +1481,8 @@ static int sm501_plat_resume(struct platform_device *pdev) | |||
1155 | { | 1481 | { |
1156 | struct sm501_devdata *sm = platform_get_drvdata(pdev); | 1482 | struct sm501_devdata *sm = platform_get_drvdata(pdev); |
1157 | 1483 | ||
1484 | sm501_set_power(sm, 1); | ||
1485 | |||
1158 | sm501_dump_regs(sm); | 1486 | sm501_dump_regs(sm); |
1159 | sm501_dump_gate(sm); | 1487 | sm501_dump_gate(sm); |
1160 | sm501_dump_clk(sm); | 1488 | sm501_dump_clk(sm); |
@@ -1229,6 +1557,7 @@ static struct sm501_platdata_fb sm501_fb_pdata = { | |||
1229 | static struct sm501_platdata sm501_pci_platdata = { | 1557 | static struct sm501_platdata sm501_pci_platdata = { |
1230 | .init = &sm501_pci_initdata, | 1558 | .init = &sm501_pci_initdata, |
1231 | .fb = &sm501_fb_pdata, | 1559 | .fb = &sm501_fb_pdata, |
1560 | .gpio_base = -1, | ||
1232 | }; | 1561 | }; |
1233 | 1562 | ||
1234 | static int sm501_pci_probe(struct pci_dev *dev, | 1563 | static int sm501_pci_probe(struct pci_dev *dev, |
@@ -1335,6 +1664,8 @@ static void sm501_dev_remove(struct sm501_devdata *sm) | |||
1335 | sm501_remove_sub(sm, smdev); | 1664 | sm501_remove_sub(sm, smdev); |
1336 | 1665 | ||
1337 | device_remove_file(sm->dev, &dev_attr_dbg_regs); | 1666 | device_remove_file(sm->dev, &dev_attr_dbg_regs); |
1667 | |||
1668 | sm501_gpio_remove(sm); | ||
1338 | } | 1669 | } |
1339 | 1670 | ||
1340 | static void sm501_pci_remove(struct pci_dev *dev) | 1671 | static void sm501_pci_remove(struct pci_dev *dev) |
@@ -1378,6 +1709,8 @@ static struct pci_driver sm501_pci_drv = { | |||
1378 | .remove = sm501_pci_remove, | 1709 | .remove = sm501_pci_remove, |
1379 | }; | 1710 | }; |
1380 | 1711 | ||
1712 | MODULE_ALIAS("platform:sm501"); | ||
1713 | |||
1381 | static struct platform_driver sm501_plat_drv = { | 1714 | static struct platform_driver sm501_plat_drv = { |
1382 | .driver = { | 1715 | .driver = { |
1383 | .name = "sm501", | 1716 | .name = "sm501", |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index ce67d973d349..321eb9134635 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -77,11 +77,13 @@ config IBM_ASM | |||
77 | for your IBM server. | 77 | for your IBM server. |
78 | 78 | ||
79 | config PHANTOM | 79 | config PHANTOM |
80 | tristate "Sensable PHANToM" | 80 | tristate "Sensable PHANToM (PCI)" |
81 | depends on PCI | 81 | depends on PCI |
82 | help | 82 | help |
83 | Say Y here if you want to build a driver for Sensable PHANToM device. | 83 | Say Y here if you want to build a driver for Sensable PHANToM device. |
84 | 84 | ||
85 | This driver is only for PCI PHANToMs. | ||
86 | |||
85 | If you choose to build module, its name will be phantom. If unsure, | 87 | If you choose to build module, its name will be phantom. If unsure, |
86 | say N here. | 88 | say N here. |
87 | 89 | ||
@@ -212,6 +214,18 @@ config TC1100_WMI | |||
212 | This is a driver for the WMI extensions (wireless and bluetooth power | 214 | This is a driver for the WMI extensions (wireless and bluetooth power |
213 | control) of the HP Compaq TC1100 tablet. | 215 | control) of the HP Compaq TC1100 tablet. |
214 | 216 | ||
217 | config HP_WMI | ||
218 | tristate "HP WMI extras" | ||
219 | depends on ACPI_WMI | ||
220 | depends on INPUT | ||
221 | depends on RFKILL | ||
222 | help | ||
223 | Say Y here if you want to support WMI-based hotkeys on HP laptops and | ||
224 | to read data from WMI such as docking or ambient light sensor state. | ||
225 | |||
226 | To compile this driver as a module, choose M here: the module will | ||
227 | be called hp-wmi. | ||
228 | |||
215 | config MSI_LAPTOP | 229 | config MSI_LAPTOP |
216 | tristate "MSI Laptop Extras" | 230 | tristate "MSI Laptop Extras" |
217 | depends on X86 | 231 | depends on X86 |
@@ -279,6 +293,8 @@ config THINKPAD_ACPI | |||
279 | select INPUT | 293 | select INPUT |
280 | select NEW_LEDS | 294 | select NEW_LEDS |
281 | select LEDS_CLASS | 295 | select LEDS_CLASS |
296 | select NET | ||
297 | select RFKILL | ||
282 | ---help--- | 298 | ---help--- |
283 | This is a driver for the IBM and Lenovo ThinkPad laptops. It adds | 299 | This is a driver for the IBM and Lenovo ThinkPad laptops. It adds |
284 | support for Fn-Fx key combinations, Bluetooth control, video | 300 | support for Fn-Fx key combinations, Bluetooth control, video |
@@ -422,6 +438,7 @@ config SGI_XP | |||
422 | 438 | ||
423 | config HP_ILO | 439 | config HP_ILO |
424 | tristate "Channel interface driver for HP iLO/iLO2 processor" | 440 | tristate "Channel interface driver for HP iLO/iLO2 processor" |
441 | depends on PCI | ||
425 | default n | 442 | default n |
426 | help | 443 | help |
427 | The channel interface driver allows applications to communicate | 444 | The channel interface driver allows applications to communicate |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 688fe76135e0..f5e273420c09 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -13,6 +13,7 @@ obj-$(CONFIG_ACER_WMI) += acer-wmi.o | |||
13 | obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o | 13 | obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o |
14 | obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o | 14 | obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o |
15 | obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o | 15 | obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o |
16 | obj-$(CONFIG_HP_WMI) += hp-wmi.o | ||
16 | obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o | 17 | obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o |
17 | obj-$(CONFIG_LKDTM) += lkdtm.o | 18 | obj-$(CONFIG_LKDTM) += lkdtm.o |
18 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o | 19 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o |
diff --git a/drivers/misc/atmel_pwm.c b/drivers/misc/atmel_pwm.c index 5b5a14dab3d3..6aa5294dfec4 100644 --- a/drivers/misc/atmel_pwm.c +++ b/drivers/misc/atmel_pwm.c | |||
@@ -211,8 +211,7 @@ int pwm_clk_alloc(unsigned prescale, unsigned div) | |||
211 | if ((mr & 0xffff) == 0) { | 211 | if ((mr & 0xffff) == 0) { |
212 | mr |= val; | 212 | mr |= val; |
213 | ret = PWM_CPR_CLKA; | 213 | ret = PWM_CPR_CLKA; |
214 | } | 214 | } else if ((mr & (0xffff << 16)) == 0) { |
215 | if ((mr & (0xffff << 16)) == 0) { | ||
216 | mr |= val << 16; | 215 | mr |= val << 16; |
217 | ret = PWM_CPR_CLKB; | 216 | ret = PWM_CPR_CLKB; |
218 | } | 217 | } |
diff --git a/drivers/misc/hp-wmi.c b/drivers/misc/hp-wmi.c new file mode 100644 index 000000000000..1dbcbcb323a2 --- /dev/null +++ b/drivers/misc/hp-wmi.c | |||
@@ -0,0 +1,494 @@ | |||
1 | /* | ||
2 | * HP WMI hotkeys | ||
3 | * | ||
4 | * Copyright (C) 2008 Red Hat <mjg@redhat.com> | ||
5 | * | ||
6 | * Portions based on wistron_btns.c: | ||
7 | * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> | ||
8 | * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> | ||
9 | * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> | ||
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, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/input.h> | ||
31 | #include <acpi/acpi_drivers.h> | ||
32 | #include <linux/platform_device.h> | ||
33 | #include <linux/acpi.h> | ||
34 | #include <linux/rfkill.h> | ||
35 | #include <linux/string.h> | ||
36 | |||
37 | MODULE_AUTHOR("Matthew Garrett <mjg59@srcf.ucam.org>"); | ||
38 | MODULE_DESCRIPTION("HP laptop WMI hotkeys driver"); | ||
39 | MODULE_LICENSE("GPL"); | ||
40 | |||
41 | MODULE_ALIAS("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C"); | ||
42 | MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); | ||
43 | |||
44 | #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" | ||
45 | #define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4" | ||
46 | |||
47 | #define HPWMI_DISPLAY_QUERY 0x1 | ||
48 | #define HPWMI_HDDTEMP_QUERY 0x2 | ||
49 | #define HPWMI_ALS_QUERY 0x3 | ||
50 | #define HPWMI_DOCK_QUERY 0x4 | ||
51 | #define HPWMI_WIRELESS_QUERY 0x5 | ||
52 | |||
53 | static int __init hp_wmi_bios_setup(struct platform_device *device); | ||
54 | static int __exit hp_wmi_bios_remove(struct platform_device *device); | ||
55 | |||
56 | struct bios_args { | ||
57 | u32 signature; | ||
58 | u32 command; | ||
59 | u32 commandtype; | ||
60 | u32 datasize; | ||
61 | u32 data; | ||
62 | }; | ||
63 | |||
64 | struct bios_return { | ||
65 | u32 sigpass; | ||
66 | u32 return_code; | ||
67 | u32 value; | ||
68 | }; | ||
69 | |||
70 | struct key_entry { | ||
71 | char type; /* See KE_* below */ | ||
72 | u8 code; | ||
73 | u16 keycode; | ||
74 | }; | ||
75 | |||
76 | enum { KE_KEY, KE_SW, KE_END }; | ||
77 | |||
78 | static struct key_entry hp_wmi_keymap[] = { | ||
79 | {KE_SW, 0x01, SW_DOCK}, | ||
80 | {KE_KEY, 0x02, KEY_BRIGHTNESSUP}, | ||
81 | {KE_KEY, 0x03, KEY_BRIGHTNESSDOWN}, | ||
82 | {KE_KEY, 0x04, KEY_HELP}, | ||
83 | {KE_END, 0} | ||
84 | }; | ||
85 | |||
86 | static struct input_dev *hp_wmi_input_dev; | ||
87 | static struct platform_device *hp_wmi_platform_dev; | ||
88 | |||
89 | static struct rfkill *wifi_rfkill; | ||
90 | static struct rfkill *bluetooth_rfkill; | ||
91 | static struct rfkill *wwan_rfkill; | ||
92 | |||
93 | static struct platform_driver hp_wmi_driver = { | ||
94 | .driver = { | ||
95 | .name = "hp-wmi", | ||
96 | .owner = THIS_MODULE, | ||
97 | }, | ||
98 | .probe = hp_wmi_bios_setup, | ||
99 | .remove = hp_wmi_bios_remove, | ||
100 | }; | ||
101 | |||
102 | static int hp_wmi_perform_query(int query, int write, int value) | ||
103 | { | ||
104 | struct bios_return bios_return; | ||
105 | acpi_status status; | ||
106 | union acpi_object *obj; | ||
107 | struct bios_args args = { | ||
108 | .signature = 0x55434553, | ||
109 | .command = write ? 0x2 : 0x1, | ||
110 | .commandtype = query, | ||
111 | .datasize = write ? 0x4 : 0, | ||
112 | .data = value, | ||
113 | }; | ||
114 | struct acpi_buffer input = { sizeof(struct bios_args), &args }; | ||
115 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
116 | |||
117 | status = wmi_evaluate_method(HPWMI_BIOS_GUID, 0, 0x3, &input, &output); | ||
118 | |||
119 | obj = output.pointer; | ||
120 | |||
121 | if (!obj || obj->type != ACPI_TYPE_BUFFER) | ||
122 | return -EINVAL; | ||
123 | |||
124 | bios_return = *((struct bios_return *)obj->buffer.pointer); | ||
125 | if (bios_return.return_code > 0) | ||
126 | return bios_return.return_code * -1; | ||
127 | else | ||
128 | return bios_return.value; | ||
129 | } | ||
130 | |||
131 | static int hp_wmi_display_state(void) | ||
132 | { | ||
133 | return hp_wmi_perform_query(HPWMI_DISPLAY_QUERY, 0, 0); | ||
134 | } | ||
135 | |||
136 | static int hp_wmi_hddtemp_state(void) | ||
137 | { | ||
138 | return hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, 0); | ||
139 | } | ||
140 | |||
141 | static int hp_wmi_als_state(void) | ||
142 | { | ||
143 | return hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, 0); | ||
144 | } | ||
145 | |||
146 | static int hp_wmi_dock_state(void) | ||
147 | { | ||
148 | return hp_wmi_perform_query(HPWMI_DOCK_QUERY, 0, 0); | ||
149 | } | ||
150 | |||
151 | static int hp_wmi_wifi_set(void *data, enum rfkill_state state) | ||
152 | { | ||
153 | if (state) | ||
154 | return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, 0x101); | ||
155 | else | ||
156 | return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, 0x100); | ||
157 | } | ||
158 | |||
159 | static int hp_wmi_bluetooth_set(void *data, enum rfkill_state state) | ||
160 | { | ||
161 | if (state) | ||
162 | return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, 0x202); | ||
163 | else | ||
164 | return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, 0x200); | ||
165 | } | ||
166 | |||
167 | static int hp_wmi_wwan_set(void *data, enum rfkill_state state) | ||
168 | { | ||
169 | if (state) | ||
170 | return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, 0x404); | ||
171 | else | ||
172 | return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, 0x400); | ||
173 | } | ||
174 | |||
175 | static int hp_wmi_wifi_state(void) | ||
176 | { | ||
177 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | ||
178 | |||
179 | if (wireless & 0x100) | ||
180 | return 1; | ||
181 | else | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | static int hp_wmi_bluetooth_state(void) | ||
186 | { | ||
187 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | ||
188 | |||
189 | if (wireless & 0x10000) | ||
190 | return 1; | ||
191 | else | ||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static int hp_wmi_wwan_state(void) | ||
196 | { | ||
197 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | ||
198 | |||
199 | if (wireless & 0x1000000) | ||
200 | return 1; | ||
201 | else | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static ssize_t show_display(struct device *dev, struct device_attribute *attr, | ||
206 | char *buf) | ||
207 | { | ||
208 | int value = hp_wmi_display_state(); | ||
209 | if (value < 0) | ||
210 | return -EINVAL; | ||
211 | return sprintf(buf, "%d\n", value); | ||
212 | } | ||
213 | |||
214 | static ssize_t show_hddtemp(struct device *dev, struct device_attribute *attr, | ||
215 | char *buf) | ||
216 | { | ||
217 | int value = hp_wmi_hddtemp_state(); | ||
218 | if (value < 0) | ||
219 | return -EINVAL; | ||
220 | return sprintf(buf, "%d\n", value); | ||
221 | } | ||
222 | |||
223 | static ssize_t show_als(struct device *dev, struct device_attribute *attr, | ||
224 | char *buf) | ||
225 | { | ||
226 | int value = hp_wmi_als_state(); | ||
227 | if (value < 0) | ||
228 | return -EINVAL; | ||
229 | return sprintf(buf, "%d\n", value); | ||
230 | } | ||
231 | |||
232 | static ssize_t show_dock(struct device *dev, struct device_attribute *attr, | ||
233 | char *buf) | ||
234 | { | ||
235 | int value = hp_wmi_dock_state(); | ||
236 | if (value < 0) | ||
237 | return -EINVAL; | ||
238 | return sprintf(buf, "%d\n", value); | ||
239 | } | ||
240 | |||
241 | static ssize_t set_als(struct device *dev, struct device_attribute *attr, | ||
242 | const char *buf, size_t count) | ||
243 | { | ||
244 | u32 tmp = simple_strtoul(buf, NULL, 10); | ||
245 | hp_wmi_perform_query(HPWMI_ALS_QUERY, 1, tmp); | ||
246 | return count; | ||
247 | } | ||
248 | |||
249 | static DEVICE_ATTR(display, S_IRUGO, show_display, NULL); | ||
250 | static DEVICE_ATTR(hddtemp, S_IRUGO, show_hddtemp, NULL); | ||
251 | static DEVICE_ATTR(als, S_IRUGO | S_IWUSR, show_als, set_als); | ||
252 | static DEVICE_ATTR(dock, S_IRUGO, show_dock, NULL); | ||
253 | |||
254 | static struct key_entry *hp_wmi_get_entry_by_scancode(int code) | ||
255 | { | ||
256 | struct key_entry *key; | ||
257 | |||
258 | for (key = hp_wmi_keymap; key->type != KE_END; key++) | ||
259 | if (code == key->code) | ||
260 | return key; | ||
261 | |||
262 | return NULL; | ||
263 | } | ||
264 | |||
265 | static struct key_entry *hp_wmi_get_entry_by_keycode(int keycode) | ||
266 | { | ||
267 | struct key_entry *key; | ||
268 | |||
269 | for (key = hp_wmi_keymap; key->type != KE_END; key++) | ||
270 | if (key->type == KE_KEY && keycode == key->keycode) | ||
271 | return key; | ||
272 | |||
273 | return NULL; | ||
274 | } | ||
275 | |||
276 | static int hp_wmi_getkeycode(struct input_dev *dev, int scancode, int *keycode) | ||
277 | { | ||
278 | struct key_entry *key = hp_wmi_get_entry_by_scancode(scancode); | ||
279 | |||
280 | if (key && key->type == KE_KEY) { | ||
281 | *keycode = key->keycode; | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | return -EINVAL; | ||
286 | } | ||
287 | |||
288 | static int hp_wmi_setkeycode(struct input_dev *dev, int scancode, int keycode) | ||
289 | { | ||
290 | struct key_entry *key; | ||
291 | int old_keycode; | ||
292 | |||
293 | if (keycode < 0 || keycode > KEY_MAX) | ||
294 | return -EINVAL; | ||
295 | |||
296 | key = hp_wmi_get_entry_by_scancode(scancode); | ||
297 | if (key && key->type == KE_KEY) { | ||
298 | old_keycode = key->keycode; | ||
299 | key->keycode = keycode; | ||
300 | set_bit(keycode, dev->keybit); | ||
301 | if (!hp_wmi_get_entry_by_keycode(old_keycode)) | ||
302 | clear_bit(old_keycode, dev->keybit); | ||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | return -EINVAL; | ||
307 | } | ||
308 | |||
309 | void hp_wmi_notify(u32 value, void *context) | ||
310 | { | ||
311 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
312 | static struct key_entry *key; | ||
313 | union acpi_object *obj; | ||
314 | |||
315 | wmi_get_event_data(value, &response); | ||
316 | |||
317 | obj = (union acpi_object *)response.pointer; | ||
318 | |||
319 | if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) { | ||
320 | int eventcode = *((u8 *) obj->buffer.pointer); | ||
321 | key = hp_wmi_get_entry_by_scancode(eventcode); | ||
322 | if (key) { | ||
323 | switch (key->type) { | ||
324 | case KE_KEY: | ||
325 | input_report_key(hp_wmi_input_dev, | ||
326 | key->keycode, 1); | ||
327 | input_sync(hp_wmi_input_dev); | ||
328 | input_report_key(hp_wmi_input_dev, | ||
329 | key->keycode, 0); | ||
330 | input_sync(hp_wmi_input_dev); | ||
331 | break; | ||
332 | case KE_SW: | ||
333 | input_report_switch(hp_wmi_input_dev, | ||
334 | key->keycode, | ||
335 | hp_wmi_dock_state()); | ||
336 | input_sync(hp_wmi_input_dev); | ||
337 | break; | ||
338 | } | ||
339 | } else if (eventcode == 0x5) { | ||
340 | if (wifi_rfkill) | ||
341 | wifi_rfkill->state = hp_wmi_wifi_state(); | ||
342 | if (bluetooth_rfkill) | ||
343 | bluetooth_rfkill->state = | ||
344 | hp_wmi_bluetooth_state(); | ||
345 | if (wwan_rfkill) | ||
346 | wwan_rfkill->state = hp_wmi_wwan_state(); | ||
347 | } else | ||
348 | printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", | ||
349 | eventcode); | ||
350 | } else | ||
351 | printk(KERN_INFO "HP WMI: Unknown response received\n"); | ||
352 | } | ||
353 | |||
354 | static int __init hp_wmi_input_setup(void) | ||
355 | { | ||
356 | struct key_entry *key; | ||
357 | int err; | ||
358 | |||
359 | hp_wmi_input_dev = input_allocate_device(); | ||
360 | |||
361 | hp_wmi_input_dev->name = "HP WMI hotkeys"; | ||
362 | hp_wmi_input_dev->phys = "wmi/input0"; | ||
363 | hp_wmi_input_dev->id.bustype = BUS_HOST; | ||
364 | hp_wmi_input_dev->getkeycode = hp_wmi_getkeycode; | ||
365 | hp_wmi_input_dev->setkeycode = hp_wmi_setkeycode; | ||
366 | |||
367 | for (key = hp_wmi_keymap; key->type != KE_END; key++) { | ||
368 | switch (key->type) { | ||
369 | case KE_KEY: | ||
370 | set_bit(EV_KEY, hp_wmi_input_dev->evbit); | ||
371 | set_bit(key->keycode, hp_wmi_input_dev->keybit); | ||
372 | break; | ||
373 | case KE_SW: | ||
374 | set_bit(EV_SW, hp_wmi_input_dev->evbit); | ||
375 | set_bit(key->keycode, hp_wmi_input_dev->swbit); | ||
376 | break; | ||
377 | } | ||
378 | } | ||
379 | |||
380 | err = input_register_device(hp_wmi_input_dev); | ||
381 | |||
382 | if (err) { | ||
383 | input_free_device(hp_wmi_input_dev); | ||
384 | return err; | ||
385 | } | ||
386 | |||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | static void cleanup_sysfs(struct platform_device *device) | ||
391 | { | ||
392 | device_remove_file(&device->dev, &dev_attr_display); | ||
393 | device_remove_file(&device->dev, &dev_attr_hddtemp); | ||
394 | device_remove_file(&device->dev, &dev_attr_als); | ||
395 | device_remove_file(&device->dev, &dev_attr_dock); | ||
396 | } | ||
397 | |||
398 | static int __init hp_wmi_bios_setup(struct platform_device *device) | ||
399 | { | ||
400 | int err; | ||
401 | |||
402 | err = device_create_file(&device->dev, &dev_attr_display); | ||
403 | if (err) | ||
404 | goto add_sysfs_error; | ||
405 | err = device_create_file(&device->dev, &dev_attr_hddtemp); | ||
406 | if (err) | ||
407 | goto add_sysfs_error; | ||
408 | err = device_create_file(&device->dev, &dev_attr_als); | ||
409 | if (err) | ||
410 | goto add_sysfs_error; | ||
411 | err = device_create_file(&device->dev, &dev_attr_dock); | ||
412 | if (err) | ||
413 | goto add_sysfs_error; | ||
414 | |||
415 | wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN); | ||
416 | wifi_rfkill->name = "hp-wifi"; | ||
417 | wifi_rfkill->state = hp_wmi_wifi_state(); | ||
418 | wifi_rfkill->toggle_radio = hp_wmi_wifi_set; | ||
419 | wifi_rfkill->user_claim_unsupported = 1; | ||
420 | |||
421 | bluetooth_rfkill = rfkill_allocate(&device->dev, | ||
422 | RFKILL_TYPE_BLUETOOTH); | ||
423 | bluetooth_rfkill->name = "hp-bluetooth"; | ||
424 | bluetooth_rfkill->state = hp_wmi_bluetooth_state(); | ||
425 | bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; | ||
426 | bluetooth_rfkill->user_claim_unsupported = 1; | ||
427 | |||
428 | wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WIMAX); | ||
429 | wwan_rfkill->name = "hp-wwan"; | ||
430 | wwan_rfkill->state = hp_wmi_wwan_state(); | ||
431 | wwan_rfkill->toggle_radio = hp_wmi_wwan_set; | ||
432 | wwan_rfkill->user_claim_unsupported = 1; | ||
433 | |||
434 | rfkill_register(wifi_rfkill); | ||
435 | rfkill_register(bluetooth_rfkill); | ||
436 | rfkill_register(wwan_rfkill); | ||
437 | |||
438 | return 0; | ||
439 | add_sysfs_error: | ||
440 | cleanup_sysfs(device); | ||
441 | return err; | ||
442 | } | ||
443 | |||
444 | static int __exit hp_wmi_bios_remove(struct platform_device *device) | ||
445 | { | ||
446 | cleanup_sysfs(device); | ||
447 | |||
448 | rfkill_unregister(wifi_rfkill); | ||
449 | rfkill_unregister(bluetooth_rfkill); | ||
450 | rfkill_unregister(wwan_rfkill); | ||
451 | |||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static int __init hp_wmi_init(void) | ||
456 | { | ||
457 | int err; | ||
458 | |||
459 | if (wmi_has_guid(HPWMI_EVENT_GUID)) { | ||
460 | err = wmi_install_notify_handler(HPWMI_EVENT_GUID, | ||
461 | hp_wmi_notify, NULL); | ||
462 | if (!err) | ||
463 | hp_wmi_input_setup(); | ||
464 | } | ||
465 | |||
466 | if (wmi_has_guid(HPWMI_BIOS_GUID)) { | ||
467 | err = platform_driver_register(&hp_wmi_driver); | ||
468 | if (err) | ||
469 | return 0; | ||
470 | hp_wmi_platform_dev = platform_device_alloc("hp-wmi", -1); | ||
471 | if (!hp_wmi_platform_dev) { | ||
472 | platform_driver_unregister(&hp_wmi_driver); | ||
473 | return 0; | ||
474 | } | ||
475 | platform_device_add(hp_wmi_platform_dev); | ||
476 | } | ||
477 | |||
478 | return 0; | ||
479 | } | ||
480 | |||
481 | static void __exit hp_wmi_exit(void) | ||
482 | { | ||
483 | if (wmi_has_guid(HPWMI_EVENT_GUID)) { | ||
484 | wmi_remove_notify_handler(HPWMI_EVENT_GUID); | ||
485 | input_unregister_device(hp_wmi_input_dev); | ||
486 | } | ||
487 | if (hp_wmi_platform_dev) { | ||
488 | platform_device_del(hp_wmi_platform_dev); | ||
489 | platform_driver_unregister(&hp_wmi_driver); | ||
490 | } | ||
491 | } | ||
492 | |||
493 | module_init(hp_wmi_init); | ||
494 | module_exit(hp_wmi_exit); | ||
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index 4ce3bdc2f959..daf585689ce3 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c | |||
@@ -563,6 +563,6 @@ module_init(phantom_init); | |||
563 | module_exit(phantom_exit); | 563 | module_exit(phantom_exit); |
564 | 564 | ||
565 | MODULE_AUTHOR("Jiri Slaby <jirislaby@gmail.com>"); | 565 | MODULE_AUTHOR("Jiri Slaby <jirislaby@gmail.com>"); |
566 | MODULE_DESCRIPTION("Sensable Phantom driver"); | 566 | MODULE_DESCRIPTION("Sensable Phantom driver (PCI devices)"); |
567 | MODULE_LICENSE("GPL"); | 567 | MODULE_LICENSE("GPL"); |
568 | MODULE_VERSION(PHANTOM_VERSION); | 568 | MODULE_VERSION(PHANTOM_VERSION); |
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index b5969298f3d3..d3eb7903c346 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * 02110-1301, USA. | 21 | * 02110-1301, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define TPACPI_VERSION "0.20" | 24 | #define TPACPI_VERSION "0.21" |
25 | #define TPACPI_SYSFS_VERSION 0x020200 | 25 | #define TPACPI_SYSFS_VERSION 0x020200 |
26 | 26 | ||
27 | /* | 27 | /* |
@@ -68,6 +68,7 @@ | |||
68 | #include <linux/hwmon-sysfs.h> | 68 | #include <linux/hwmon-sysfs.h> |
69 | #include <linux/input.h> | 69 | #include <linux/input.h> |
70 | #include <linux/leds.h> | 70 | #include <linux/leds.h> |
71 | #include <linux/rfkill.h> | ||
71 | #include <asm/uaccess.h> | 72 | #include <asm/uaccess.h> |
72 | 73 | ||
73 | #include <linux/dmi.h> | 74 | #include <linux/dmi.h> |
@@ -144,6 +145,12 @@ enum { | |||
144 | 145 | ||
145 | #define TPACPI_MAX_ACPI_ARGS 3 | 146 | #define TPACPI_MAX_ACPI_ARGS 3 |
146 | 147 | ||
148 | /* rfkill switches */ | ||
149 | enum { | ||
150 | TPACPI_RFK_BLUETOOTH_SW_ID = 0, | ||
151 | TPACPI_RFK_WWAN_SW_ID, | ||
152 | }; | ||
153 | |||
147 | /* Debugging */ | 154 | /* Debugging */ |
148 | #define TPACPI_LOG TPACPI_FILE ": " | 155 | #define TPACPI_LOG TPACPI_FILE ": " |
149 | #define TPACPI_ERR KERN_ERR TPACPI_LOG | 156 | #define TPACPI_ERR KERN_ERR TPACPI_LOG |
@@ -905,6 +912,43 @@ static int __init tpacpi_check_std_acpi_brightness_support(void) | |||
905 | return 0; | 912 | return 0; |
906 | } | 913 | } |
907 | 914 | ||
915 | static int __init tpacpi_new_rfkill(const unsigned int id, | ||
916 | struct rfkill **rfk, | ||
917 | const enum rfkill_type rfktype, | ||
918 | const char *name, | ||
919 | int (*toggle_radio)(void *, enum rfkill_state), | ||
920 | int (*get_state)(void *, enum rfkill_state *)) | ||
921 | { | ||
922 | int res; | ||
923 | enum rfkill_state initial_state; | ||
924 | |||
925 | *rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype); | ||
926 | if (!*rfk) { | ||
927 | printk(TPACPI_ERR | ||
928 | "failed to allocate memory for rfkill class\n"); | ||
929 | return -ENOMEM; | ||
930 | } | ||
931 | |||
932 | (*rfk)->name = name; | ||
933 | (*rfk)->get_state = get_state; | ||
934 | (*rfk)->toggle_radio = toggle_radio; | ||
935 | |||
936 | if (!get_state(NULL, &initial_state)) | ||
937 | (*rfk)->state = initial_state; | ||
938 | |||
939 | res = rfkill_register(*rfk); | ||
940 | if (res < 0) { | ||
941 | printk(TPACPI_ERR | ||
942 | "failed to register %s rfkill switch: %d\n", | ||
943 | name, res); | ||
944 | rfkill_free(*rfk); | ||
945 | *rfk = NULL; | ||
946 | return res; | ||
947 | } | ||
948 | |||
949 | return 0; | ||
950 | } | ||
951 | |||
908 | /************************************************************************* | 952 | /************************************************************************* |
909 | * thinkpad-acpi driver attributes | 953 | * thinkpad-acpi driver attributes |
910 | */ | 954 | */ |
@@ -1285,21 +1329,6 @@ static int hotkey_status_set(int status) | |||
1285 | return 0; | 1329 | return 0; |
1286 | } | 1330 | } |
1287 | 1331 | ||
1288 | static void tpacpi_input_send_radiosw(void) | ||
1289 | { | ||
1290 | int wlsw; | ||
1291 | |||
1292 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) { | ||
1293 | mutex_lock(&tpacpi_inputdev_send_mutex); | ||
1294 | |||
1295 | input_report_switch(tpacpi_inputdev, | ||
1296 | SW_RFKILL_ALL, !!wlsw); | ||
1297 | input_sync(tpacpi_inputdev); | ||
1298 | |||
1299 | mutex_unlock(&tpacpi_inputdev_send_mutex); | ||
1300 | } | ||
1301 | } | ||
1302 | |||
1303 | static void tpacpi_input_send_tabletsw(void) | 1332 | static void tpacpi_input_send_tabletsw(void) |
1304 | { | 1333 | { |
1305 | int state; | 1334 | int state; |
@@ -1921,6 +1950,30 @@ static struct attribute *hotkey_mask_attributes[] __initdata = { | |||
1921 | &dev_attr_hotkey_wakeup_hotunplug_complete.attr, | 1950 | &dev_attr_hotkey_wakeup_hotunplug_complete.attr, |
1922 | }; | 1951 | }; |
1923 | 1952 | ||
1953 | static void bluetooth_update_rfk(void); | ||
1954 | static void wan_update_rfk(void); | ||
1955 | static void tpacpi_send_radiosw_update(void) | ||
1956 | { | ||
1957 | int wlsw; | ||
1958 | |||
1959 | /* Sync these BEFORE sending any rfkill events */ | ||
1960 | if (tp_features.bluetooth) | ||
1961 | bluetooth_update_rfk(); | ||
1962 | if (tp_features.wan) | ||
1963 | wan_update_rfk(); | ||
1964 | |||
1965 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) { | ||
1966 | mutex_lock(&tpacpi_inputdev_send_mutex); | ||
1967 | |||
1968 | input_report_switch(tpacpi_inputdev, | ||
1969 | SW_RFKILL_ALL, !!wlsw); | ||
1970 | input_sync(tpacpi_inputdev); | ||
1971 | |||
1972 | mutex_unlock(&tpacpi_inputdev_send_mutex); | ||
1973 | } | ||
1974 | hotkey_radio_sw_notify_change(); | ||
1975 | } | ||
1976 | |||
1924 | static void hotkey_exit(void) | 1977 | static void hotkey_exit(void) |
1925 | { | 1978 | { |
1926 | #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL | 1979 | #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL |
@@ -2167,9 +2220,10 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
2167 | printk(TPACPI_INFO | 2220 | printk(TPACPI_INFO |
2168 | "radio switch found; radios are %s\n", | 2221 | "radio switch found; radios are %s\n", |
2169 | enabled(status, 0)); | 2222 | enabled(status, 0)); |
2223 | } | ||
2224 | if (tp_features.hotkey_wlsw) | ||
2170 | res = add_to_attr_set(hotkey_dev_attributes, | 2225 | res = add_to_attr_set(hotkey_dev_attributes, |
2171 | &dev_attr_hotkey_radio_sw.attr); | 2226 | &dev_attr_hotkey_radio_sw.attr); |
2172 | } | ||
2173 | 2227 | ||
2174 | /* For X41t, X60t, X61t Tablets... */ | 2228 | /* For X41t, X60t, X61t Tablets... */ |
2175 | if (!res && acpi_evalf(hkey_handle, &status, "MHKG", "qd")) { | 2229 | if (!res && acpi_evalf(hkey_handle, &status, "MHKG", "qd")) { |
@@ -2287,7 +2341,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
2287 | tpacpi_inputdev->close = &hotkey_inputdev_close; | 2341 | tpacpi_inputdev->close = &hotkey_inputdev_close; |
2288 | 2342 | ||
2289 | hotkey_poll_setup_safe(1); | 2343 | hotkey_poll_setup_safe(1); |
2290 | tpacpi_input_send_radiosw(); | 2344 | tpacpi_send_radiosw_update(); |
2291 | tpacpi_input_send_tabletsw(); | 2345 | tpacpi_input_send_tabletsw(); |
2292 | 2346 | ||
2293 | return 0; | 2347 | return 0; |
@@ -2419,8 +2473,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
2419 | case 7: | 2473 | case 7: |
2420 | /* 0x7000-0x7FFF: misc */ | 2474 | /* 0x7000-0x7FFF: misc */ |
2421 | if (tp_features.hotkey_wlsw && hkey == 0x7000) { | 2475 | if (tp_features.hotkey_wlsw && hkey == 0x7000) { |
2422 | tpacpi_input_send_radiosw(); | 2476 | tpacpi_send_radiosw_update(); |
2423 | hotkey_radio_sw_notify_change(); | ||
2424 | send_acpi_ev = 0; | 2477 | send_acpi_ev = 0; |
2425 | break; | 2478 | break; |
2426 | } | 2479 | } |
@@ -2463,8 +2516,7 @@ static void hotkey_resume(void) | |||
2463 | printk(TPACPI_ERR | 2516 | printk(TPACPI_ERR |
2464 | "error while trying to read hot key mask " | 2517 | "error while trying to read hot key mask " |
2465 | "from firmware\n"); | 2518 | "from firmware\n"); |
2466 | tpacpi_input_send_radiosw(); | 2519 | tpacpi_send_radiosw_update(); |
2467 | hotkey_radio_sw_notify_change(); | ||
2468 | hotkey_tablet_mode_notify_change(); | 2520 | hotkey_tablet_mode_notify_change(); |
2469 | hotkey_wakeup_reason_notify_change(); | 2521 | hotkey_wakeup_reason_notify_change(); |
2470 | hotkey_wakeup_hotunplug_complete_notify_change(); | 2522 | hotkey_wakeup_hotunplug_complete_notify_change(); |
@@ -2581,8 +2633,66 @@ enum { | |||
2581 | TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */ | 2633 | TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */ |
2582 | }; | 2634 | }; |
2583 | 2635 | ||
2584 | static int bluetooth_get_radiosw(void); | 2636 | static struct rfkill *tpacpi_bluetooth_rfkill; |
2585 | static int bluetooth_set_radiosw(int radio_on); | 2637 | |
2638 | static int bluetooth_get_radiosw(void) | ||
2639 | { | ||
2640 | int status; | ||
2641 | |||
2642 | if (!tp_features.bluetooth) | ||
2643 | return -ENODEV; | ||
2644 | |||
2645 | /* WLSW overrides bluetooth in firmware/hardware, reflect that */ | ||
2646 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status) | ||
2647 | return RFKILL_STATE_HARD_BLOCKED; | ||
2648 | |||
2649 | if (!acpi_evalf(hkey_handle, &status, "GBDC", "d")) | ||
2650 | return -EIO; | ||
2651 | |||
2652 | return ((status & TP_ACPI_BLUETOOTH_RADIOSSW) != 0) ? | ||
2653 | RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED; | ||
2654 | } | ||
2655 | |||
2656 | static void bluetooth_update_rfk(void) | ||
2657 | { | ||
2658 | int status; | ||
2659 | |||
2660 | if (!tpacpi_bluetooth_rfkill) | ||
2661 | return; | ||
2662 | |||
2663 | status = bluetooth_get_radiosw(); | ||
2664 | if (status < 0) | ||
2665 | return; | ||
2666 | rfkill_force_state(tpacpi_bluetooth_rfkill, status); | ||
2667 | } | ||
2668 | |||
2669 | static int bluetooth_set_radiosw(int radio_on, int update_rfk) | ||
2670 | { | ||
2671 | int status; | ||
2672 | |||
2673 | if (!tp_features.bluetooth) | ||
2674 | return -ENODEV; | ||
2675 | |||
2676 | /* WLSW overrides bluetooth in firmware/hardware, but there is no | ||
2677 | * reason to risk weird behaviour. */ | ||
2678 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status | ||
2679 | && radio_on) | ||
2680 | return -EPERM; | ||
2681 | |||
2682 | if (!acpi_evalf(hkey_handle, &status, "GBDC", "d")) | ||
2683 | return -EIO; | ||
2684 | if (radio_on) | ||
2685 | status |= TP_ACPI_BLUETOOTH_RADIOSSW; | ||
2686 | else | ||
2687 | status &= ~TP_ACPI_BLUETOOTH_RADIOSSW; | ||
2688 | if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) | ||
2689 | return -EIO; | ||
2690 | |||
2691 | if (update_rfk) | ||
2692 | bluetooth_update_rfk(); | ||
2693 | |||
2694 | return 0; | ||
2695 | } | ||
2586 | 2696 | ||
2587 | /* sysfs bluetooth enable ---------------------------------------------- */ | 2697 | /* sysfs bluetooth enable ---------------------------------------------- */ |
2588 | static ssize_t bluetooth_enable_show(struct device *dev, | 2698 | static ssize_t bluetooth_enable_show(struct device *dev, |
@@ -2595,7 +2705,8 @@ static ssize_t bluetooth_enable_show(struct device *dev, | |||
2595 | if (status < 0) | 2705 | if (status < 0) |
2596 | return status; | 2706 | return status; |
2597 | 2707 | ||
2598 | return snprintf(buf, PAGE_SIZE, "%d\n", status ? 1 : 0); | 2708 | return snprintf(buf, PAGE_SIZE, "%d\n", |
2709 | (status == RFKILL_STATE_UNBLOCKED) ? 1 : 0); | ||
2599 | } | 2710 | } |
2600 | 2711 | ||
2601 | static ssize_t bluetooth_enable_store(struct device *dev, | 2712 | static ssize_t bluetooth_enable_store(struct device *dev, |
@@ -2608,7 +2719,7 @@ static ssize_t bluetooth_enable_store(struct device *dev, | |||
2608 | if (parse_strtoul(buf, 1, &t)) | 2719 | if (parse_strtoul(buf, 1, &t)) |
2609 | return -EINVAL; | 2720 | return -EINVAL; |
2610 | 2721 | ||
2611 | res = bluetooth_set_radiosw(t); | 2722 | res = bluetooth_set_radiosw(t, 1); |
2612 | 2723 | ||
2613 | return (res) ? res : count; | 2724 | return (res) ? res : count; |
2614 | } | 2725 | } |
@@ -2628,6 +2739,31 @@ static const struct attribute_group bluetooth_attr_group = { | |||
2628 | .attrs = bluetooth_attributes, | 2739 | .attrs = bluetooth_attributes, |
2629 | }; | 2740 | }; |
2630 | 2741 | ||
2742 | static int tpacpi_bluetooth_rfk_get(void *data, enum rfkill_state *state) | ||
2743 | { | ||
2744 | int bts = bluetooth_get_radiosw(); | ||
2745 | |||
2746 | if (bts < 0) | ||
2747 | return bts; | ||
2748 | |||
2749 | *state = bts; | ||
2750 | return 0; | ||
2751 | } | ||
2752 | |||
2753 | static int tpacpi_bluetooth_rfk_set(void *data, enum rfkill_state state) | ||
2754 | { | ||
2755 | return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); | ||
2756 | } | ||
2757 | |||
2758 | static void bluetooth_exit(void) | ||
2759 | { | ||
2760 | if (tpacpi_bluetooth_rfkill) | ||
2761 | rfkill_unregister(tpacpi_bluetooth_rfkill); | ||
2762 | |||
2763 | sysfs_remove_group(&tpacpi_pdev->dev.kobj, | ||
2764 | &bluetooth_attr_group); | ||
2765 | } | ||
2766 | |||
2631 | static int __init bluetooth_init(struct ibm_init_struct *iibm) | 2767 | static int __init bluetooth_init(struct ibm_init_struct *iibm) |
2632 | { | 2768 | { |
2633 | int res; | 2769 | int res; |
@@ -2646,57 +2782,32 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm) | |||
2646 | str_supported(tp_features.bluetooth), | 2782 | str_supported(tp_features.bluetooth), |
2647 | status); | 2783 | status); |
2648 | 2784 | ||
2649 | if (tp_features.bluetooth) { | 2785 | if (tp_features.bluetooth && |
2650 | if (!(status & TP_ACPI_BLUETOOTH_HWPRESENT)) { | 2786 | !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) { |
2651 | /* no bluetooth hardware present in system */ | 2787 | /* no bluetooth hardware present in system */ |
2652 | tp_features.bluetooth = 0; | 2788 | tp_features.bluetooth = 0; |
2653 | dbg_printk(TPACPI_DBG_INIT, | 2789 | dbg_printk(TPACPI_DBG_INIT, |
2654 | "bluetooth hardware not installed\n"); | 2790 | "bluetooth hardware not installed\n"); |
2655 | } else { | ||
2656 | res = sysfs_create_group(&tpacpi_pdev->dev.kobj, | ||
2657 | &bluetooth_attr_group); | ||
2658 | if (res) | ||
2659 | return res; | ||
2660 | } | ||
2661 | } | 2791 | } |
2662 | 2792 | ||
2663 | return (tp_features.bluetooth)? 0 : 1; | ||
2664 | } | ||
2665 | |||
2666 | static void bluetooth_exit(void) | ||
2667 | { | ||
2668 | sysfs_remove_group(&tpacpi_pdev->dev.kobj, | ||
2669 | &bluetooth_attr_group); | ||
2670 | } | ||
2671 | |||
2672 | static int bluetooth_get_radiosw(void) | ||
2673 | { | ||
2674 | int status; | ||
2675 | |||
2676 | if (!tp_features.bluetooth) | 2793 | if (!tp_features.bluetooth) |
2677 | return -ENODEV; | 2794 | return 1; |
2678 | |||
2679 | if (!acpi_evalf(hkey_handle, &status, "GBDC", "d")) | ||
2680 | return -EIO; | ||
2681 | |||
2682 | return ((status & TP_ACPI_BLUETOOTH_RADIOSSW) != 0); | ||
2683 | } | ||
2684 | |||
2685 | static int bluetooth_set_radiosw(int radio_on) | ||
2686 | { | ||
2687 | int status; | ||
2688 | 2795 | ||
2689 | if (!tp_features.bluetooth) | 2796 | res = sysfs_create_group(&tpacpi_pdev->dev.kobj, |
2690 | return -ENODEV; | 2797 | &bluetooth_attr_group); |
2798 | if (res) | ||
2799 | return res; | ||
2691 | 2800 | ||
2692 | if (!acpi_evalf(hkey_handle, &status, "GBDC", "d")) | 2801 | res = tpacpi_new_rfkill(TPACPI_RFK_BLUETOOTH_SW_ID, |
2693 | return -EIO; | 2802 | &tpacpi_bluetooth_rfkill, |
2694 | if (radio_on) | 2803 | RFKILL_TYPE_BLUETOOTH, |
2695 | status |= TP_ACPI_BLUETOOTH_RADIOSSW; | 2804 | "tpacpi_bluetooth_sw", |
2696 | else | 2805 | tpacpi_bluetooth_rfk_set, |
2697 | status &= ~TP_ACPI_BLUETOOTH_RADIOSSW; | 2806 | tpacpi_bluetooth_rfk_get); |
2698 | if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) | 2807 | if (res) { |
2699 | return -EIO; | 2808 | bluetooth_exit(); |
2809 | return res; | ||
2810 | } | ||
2700 | 2811 | ||
2701 | return 0; | 2812 | return 0; |
2702 | } | 2813 | } |
@@ -2711,7 +2822,8 @@ static int bluetooth_read(char *p) | |||
2711 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 2822 | len += sprintf(p + len, "status:\t\tnot supported\n"); |
2712 | else { | 2823 | else { |
2713 | len += sprintf(p + len, "status:\t\t%s\n", | 2824 | len += sprintf(p + len, "status:\t\t%s\n", |
2714 | (status)? "enabled" : "disabled"); | 2825 | (status == RFKILL_STATE_UNBLOCKED) ? |
2826 | "enabled" : "disabled"); | ||
2715 | len += sprintf(p + len, "commands:\tenable, disable\n"); | 2827 | len += sprintf(p + len, "commands:\tenable, disable\n"); |
2716 | } | 2828 | } |
2717 | 2829 | ||
@@ -2727,9 +2839,9 @@ static int bluetooth_write(char *buf) | |||
2727 | 2839 | ||
2728 | while ((cmd = next_cmd(&buf))) { | 2840 | while ((cmd = next_cmd(&buf))) { |
2729 | if (strlencmp(cmd, "enable") == 0) { | 2841 | if (strlencmp(cmd, "enable") == 0) { |
2730 | bluetooth_set_radiosw(1); | 2842 | bluetooth_set_radiosw(1, 1); |
2731 | } else if (strlencmp(cmd, "disable") == 0) { | 2843 | } else if (strlencmp(cmd, "disable") == 0) { |
2732 | bluetooth_set_radiosw(0); | 2844 | bluetooth_set_radiosw(0, 1); |
2733 | } else | 2845 | } else |
2734 | return -EINVAL; | 2846 | return -EINVAL; |
2735 | } | 2847 | } |
@@ -2755,8 +2867,66 @@ enum { | |||
2755 | TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */ | 2867 | TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */ |
2756 | }; | 2868 | }; |
2757 | 2869 | ||
2758 | static int wan_get_radiosw(void); | 2870 | static struct rfkill *tpacpi_wan_rfkill; |
2759 | static int wan_set_radiosw(int radio_on); | 2871 | |
2872 | static int wan_get_radiosw(void) | ||
2873 | { | ||
2874 | int status; | ||
2875 | |||
2876 | if (!tp_features.wan) | ||
2877 | return -ENODEV; | ||
2878 | |||
2879 | /* WLSW overrides WWAN in firmware/hardware, reflect that */ | ||
2880 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status) | ||
2881 | return RFKILL_STATE_HARD_BLOCKED; | ||
2882 | |||
2883 | if (!acpi_evalf(hkey_handle, &status, "GWAN", "d")) | ||
2884 | return -EIO; | ||
2885 | |||
2886 | return ((status & TP_ACPI_WANCARD_RADIOSSW) != 0) ? | ||
2887 | RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED; | ||
2888 | } | ||
2889 | |||
2890 | static void wan_update_rfk(void) | ||
2891 | { | ||
2892 | int status; | ||
2893 | |||
2894 | if (!tpacpi_wan_rfkill) | ||
2895 | return; | ||
2896 | |||
2897 | status = wan_get_radiosw(); | ||
2898 | if (status < 0) | ||
2899 | return; | ||
2900 | rfkill_force_state(tpacpi_wan_rfkill, status); | ||
2901 | } | ||
2902 | |||
2903 | static int wan_set_radiosw(int radio_on, int update_rfk) | ||
2904 | { | ||
2905 | int status; | ||
2906 | |||
2907 | if (!tp_features.wan) | ||
2908 | return -ENODEV; | ||
2909 | |||
2910 | /* WLSW overrides bluetooth in firmware/hardware, but there is no | ||
2911 | * reason to risk weird behaviour. */ | ||
2912 | if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status | ||
2913 | && radio_on) | ||
2914 | return -EPERM; | ||
2915 | |||
2916 | if (!acpi_evalf(hkey_handle, &status, "GWAN", "d")) | ||
2917 | return -EIO; | ||
2918 | if (radio_on) | ||
2919 | status |= TP_ACPI_WANCARD_RADIOSSW; | ||
2920 | else | ||
2921 | status &= ~TP_ACPI_WANCARD_RADIOSSW; | ||
2922 | if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status)) | ||
2923 | return -EIO; | ||
2924 | |||
2925 | if (update_rfk) | ||
2926 | wan_update_rfk(); | ||
2927 | |||
2928 | return 0; | ||
2929 | } | ||
2760 | 2930 | ||
2761 | /* sysfs wan enable ---------------------------------------------------- */ | 2931 | /* sysfs wan enable ---------------------------------------------------- */ |
2762 | static ssize_t wan_enable_show(struct device *dev, | 2932 | static ssize_t wan_enable_show(struct device *dev, |
@@ -2769,7 +2939,8 @@ static ssize_t wan_enable_show(struct device *dev, | |||
2769 | if (status < 0) | 2939 | if (status < 0) |
2770 | return status; | 2940 | return status; |
2771 | 2941 | ||
2772 | return snprintf(buf, PAGE_SIZE, "%d\n", status ? 1 : 0); | 2942 | return snprintf(buf, PAGE_SIZE, "%d\n", |
2943 | (status == RFKILL_STATE_UNBLOCKED) ? 1 : 0); | ||
2773 | } | 2944 | } |
2774 | 2945 | ||
2775 | static ssize_t wan_enable_store(struct device *dev, | 2946 | static ssize_t wan_enable_store(struct device *dev, |
@@ -2782,7 +2953,7 @@ static ssize_t wan_enable_store(struct device *dev, | |||
2782 | if (parse_strtoul(buf, 1, &t)) | 2953 | if (parse_strtoul(buf, 1, &t)) |
2783 | return -EINVAL; | 2954 | return -EINVAL; |
2784 | 2955 | ||
2785 | res = wan_set_radiosw(t); | 2956 | res = wan_set_radiosw(t, 1); |
2786 | 2957 | ||
2787 | return (res) ? res : count; | 2958 | return (res) ? res : count; |
2788 | } | 2959 | } |
@@ -2802,6 +2973,31 @@ static const struct attribute_group wan_attr_group = { | |||
2802 | .attrs = wan_attributes, | 2973 | .attrs = wan_attributes, |
2803 | }; | 2974 | }; |
2804 | 2975 | ||
2976 | static int tpacpi_wan_rfk_get(void *data, enum rfkill_state *state) | ||
2977 | { | ||
2978 | int wans = wan_get_radiosw(); | ||
2979 | |||
2980 | if (wans < 0) | ||
2981 | return wans; | ||
2982 | |||
2983 | *state = wans; | ||
2984 | return 0; | ||
2985 | } | ||
2986 | |||
2987 | static int tpacpi_wan_rfk_set(void *data, enum rfkill_state state) | ||
2988 | { | ||
2989 | return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); | ||
2990 | } | ||
2991 | |||
2992 | static void wan_exit(void) | ||
2993 | { | ||
2994 | if (tpacpi_wan_rfkill) | ||
2995 | rfkill_unregister(tpacpi_wan_rfkill); | ||
2996 | |||
2997 | sysfs_remove_group(&tpacpi_pdev->dev.kobj, | ||
2998 | &wan_attr_group); | ||
2999 | } | ||
3000 | |||
2805 | static int __init wan_init(struct ibm_init_struct *iibm) | 3001 | static int __init wan_init(struct ibm_init_struct *iibm) |
2806 | { | 3002 | { |
2807 | int res; | 3003 | int res; |
@@ -2818,57 +3014,32 @@ static int __init wan_init(struct ibm_init_struct *iibm) | |||
2818 | str_supported(tp_features.wan), | 3014 | str_supported(tp_features.wan), |
2819 | status); | 3015 | status); |
2820 | 3016 | ||
2821 | if (tp_features.wan) { | 3017 | if (tp_features.wan && |
2822 | if (!(status & TP_ACPI_WANCARD_HWPRESENT)) { | 3018 | !(status & TP_ACPI_WANCARD_HWPRESENT)) { |
2823 | /* no wan hardware present in system */ | 3019 | /* no wan hardware present in system */ |
2824 | tp_features.wan = 0; | 3020 | tp_features.wan = 0; |
2825 | dbg_printk(TPACPI_DBG_INIT, | 3021 | dbg_printk(TPACPI_DBG_INIT, |
2826 | "wan hardware not installed\n"); | 3022 | "wan hardware not installed\n"); |
2827 | } else { | ||
2828 | res = sysfs_create_group(&tpacpi_pdev->dev.kobj, | ||
2829 | &wan_attr_group); | ||
2830 | if (res) | ||
2831 | return res; | ||
2832 | } | ||
2833 | } | 3023 | } |
2834 | 3024 | ||
2835 | return (tp_features.wan)? 0 : 1; | ||
2836 | } | ||
2837 | |||
2838 | static void wan_exit(void) | ||
2839 | { | ||
2840 | sysfs_remove_group(&tpacpi_pdev->dev.kobj, | ||
2841 | &wan_attr_group); | ||
2842 | } | ||
2843 | |||
2844 | static int wan_get_radiosw(void) | ||
2845 | { | ||
2846 | int status; | ||
2847 | |||
2848 | if (!tp_features.wan) | 3025 | if (!tp_features.wan) |
2849 | return -ENODEV; | 3026 | return 1; |
2850 | |||
2851 | if (!acpi_evalf(hkey_handle, &status, "GWAN", "d")) | ||
2852 | return -EIO; | ||
2853 | |||
2854 | return ((status & TP_ACPI_WANCARD_RADIOSSW) != 0); | ||
2855 | } | ||
2856 | |||
2857 | static int wan_set_radiosw(int radio_on) | ||
2858 | { | ||
2859 | int status; | ||
2860 | 3027 | ||
2861 | if (!tp_features.wan) | 3028 | res = sysfs_create_group(&tpacpi_pdev->dev.kobj, |
2862 | return -ENODEV; | 3029 | &wan_attr_group); |
3030 | if (res) | ||
3031 | return res; | ||
2863 | 3032 | ||
2864 | if (!acpi_evalf(hkey_handle, &status, "GWAN", "d")) | 3033 | res = tpacpi_new_rfkill(TPACPI_RFK_WWAN_SW_ID, |
2865 | return -EIO; | 3034 | &tpacpi_wan_rfkill, |
2866 | if (radio_on) | 3035 | RFKILL_TYPE_WWAN, |
2867 | status |= TP_ACPI_WANCARD_RADIOSSW; | 3036 | "tpacpi_wwan_sw", |
2868 | else | 3037 | tpacpi_wan_rfk_set, |
2869 | status &= ~TP_ACPI_WANCARD_RADIOSSW; | 3038 | tpacpi_wan_rfk_get); |
2870 | if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status)) | 3039 | if (res) { |
2871 | return -EIO; | 3040 | wan_exit(); |
3041 | return res; | ||
3042 | } | ||
2872 | 3043 | ||
2873 | return 0; | 3044 | return 0; |
2874 | } | 3045 | } |
@@ -2883,7 +3054,8 @@ static int wan_read(char *p) | |||
2883 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 3054 | len += sprintf(p + len, "status:\t\tnot supported\n"); |
2884 | else { | 3055 | else { |
2885 | len += sprintf(p + len, "status:\t\t%s\n", | 3056 | len += sprintf(p + len, "status:\t\t%s\n", |
2886 | (status)? "enabled" : "disabled"); | 3057 | (status == RFKILL_STATE_UNBLOCKED) ? |
3058 | "enabled" : "disabled"); | ||
2887 | len += sprintf(p + len, "commands:\tenable, disable\n"); | 3059 | len += sprintf(p + len, "commands:\tenable, disable\n"); |
2888 | } | 3060 | } |
2889 | 3061 | ||
@@ -2899,9 +3071,9 @@ static int wan_write(char *buf) | |||
2899 | 3071 | ||
2900 | while ((cmd = next_cmd(&buf))) { | 3072 | while ((cmd = next_cmd(&buf))) { |
2901 | if (strlencmp(cmd, "enable") == 0) { | 3073 | if (strlencmp(cmd, "enable") == 0) { |
2902 | wan_set_radiosw(1); | 3074 | wan_set_radiosw(1, 1); |
2903 | } else if (strlencmp(cmd, "disable") == 0) { | 3075 | } else if (strlencmp(cmd, "disable") == 0) { |
2904 | wan_set_radiosw(0); | 3076 | wan_set_radiosw(0, 1); |
2905 | } else | 3077 | } else |
2906 | return -EINVAL; | 3078 | return -EINVAL; |
2907 | } | 3079 | } |
@@ -6168,13 +6340,18 @@ err_out: | |||
6168 | 6340 | ||
6169 | /* Probing */ | 6341 | /* Probing */ |
6170 | 6342 | ||
6171 | static void __init get_thinkpad_model_data(struct thinkpad_id_data *tp) | 6343 | /* returns 0 - probe ok, or < 0 - probe error. |
6344 | * Probe ok doesn't mean thinkpad found. | ||
6345 | * On error, kfree() cleanup on tp->* is not performed, caller must do it */ | ||
6346 | static int __must_check __init get_thinkpad_model_data( | ||
6347 | struct thinkpad_id_data *tp) | ||
6172 | { | 6348 | { |
6173 | const struct dmi_device *dev = NULL; | 6349 | const struct dmi_device *dev = NULL; |
6174 | char ec_fw_string[18]; | 6350 | char ec_fw_string[18]; |
6351 | char const *s; | ||
6175 | 6352 | ||
6176 | if (!tp) | 6353 | if (!tp) |
6177 | return; | 6354 | return -EINVAL; |
6178 | 6355 | ||
6179 | memset(tp, 0, sizeof(*tp)); | 6356 | memset(tp, 0, sizeof(*tp)); |
6180 | 6357 | ||
@@ -6183,12 +6360,14 @@ static void __init get_thinkpad_model_data(struct thinkpad_id_data *tp) | |||
6183 | else if (dmi_name_in_vendors("LENOVO")) | 6360 | else if (dmi_name_in_vendors("LENOVO")) |
6184 | tp->vendor = PCI_VENDOR_ID_LENOVO; | 6361 | tp->vendor = PCI_VENDOR_ID_LENOVO; |
6185 | else | 6362 | else |
6186 | return; | 6363 | return 0; |
6187 | 6364 | ||
6188 | tp->bios_version_str = kstrdup(dmi_get_system_info(DMI_BIOS_VERSION), | 6365 | s = dmi_get_system_info(DMI_BIOS_VERSION); |
6189 | GFP_KERNEL); | 6366 | tp->bios_version_str = kstrdup(s, GFP_KERNEL); |
6367 | if (s && !tp->bios_version_str) | ||
6368 | return -ENOMEM; | ||
6190 | if (!tp->bios_version_str) | 6369 | if (!tp->bios_version_str) |
6191 | return; | 6370 | return 0; |
6192 | tp->bios_model = tp->bios_version_str[0] | 6371 | tp->bios_model = tp->bios_version_str[0] |
6193 | | (tp->bios_version_str[1] << 8); | 6372 | | (tp->bios_version_str[1] << 8); |
6194 | 6373 | ||
@@ -6207,21 +6386,27 @@ static void __init get_thinkpad_model_data(struct thinkpad_id_data *tp) | |||
6207 | ec_fw_string[strcspn(ec_fw_string, " ]")] = 0; | 6386 | ec_fw_string[strcspn(ec_fw_string, " ]")] = 0; |
6208 | 6387 | ||
6209 | tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); | 6388 | tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); |
6389 | if (!tp->ec_version_str) | ||
6390 | return -ENOMEM; | ||
6210 | tp->ec_model = ec_fw_string[0] | 6391 | tp->ec_model = ec_fw_string[0] |
6211 | | (ec_fw_string[1] << 8); | 6392 | | (ec_fw_string[1] << 8); |
6212 | break; | 6393 | break; |
6213 | } | 6394 | } |
6214 | } | 6395 | } |
6215 | 6396 | ||
6216 | tp->model_str = kstrdup(dmi_get_system_info(DMI_PRODUCT_VERSION), | 6397 | s = dmi_get_system_info(DMI_PRODUCT_VERSION); |
6217 | GFP_KERNEL); | 6398 | if (s && !strnicmp(s, "ThinkPad", 8)) { |
6218 | if (tp->model_str && strnicmp(tp->model_str, "ThinkPad", 8) != 0) { | 6399 | tp->model_str = kstrdup(s, GFP_KERNEL); |
6219 | kfree(tp->model_str); | 6400 | if (!tp->model_str) |
6220 | tp->model_str = NULL; | 6401 | return -ENOMEM; |
6221 | } | 6402 | } |
6222 | 6403 | ||
6223 | tp->nummodel_str = kstrdup(dmi_get_system_info(DMI_PRODUCT_NAME), | 6404 | s = dmi_get_system_info(DMI_PRODUCT_NAME); |
6224 | GFP_KERNEL); | 6405 | tp->nummodel_str = kstrdup(s, GFP_KERNEL); |
6406 | if (s && !tp->nummodel_str) | ||
6407 | return -ENOMEM; | ||
6408 | |||
6409 | return 0; | ||
6225 | } | 6410 | } |
6226 | 6411 | ||
6227 | static int __init probe_for_thinkpad(void) | 6412 | static int __init probe_for_thinkpad(void) |
@@ -6484,7 +6669,13 @@ static int __init thinkpad_acpi_module_init(void) | |||
6484 | 6669 | ||
6485 | /* Driver-level probe */ | 6670 | /* Driver-level probe */ |
6486 | 6671 | ||
6487 | get_thinkpad_model_data(&thinkpad_id); | 6672 | ret = get_thinkpad_model_data(&thinkpad_id); |
6673 | if (ret) { | ||
6674 | printk(TPACPI_ERR | ||
6675 | "unable to get DMI data: %d\n", ret); | ||
6676 | thinkpad_acpi_module_exit(); | ||
6677 | return ret; | ||
6678 | } | ||
6488 | ret = probe_for_thinkpad(); | 6679 | ret = probe_for_thinkpad(); |
6489 | if (ret) { | 6680 | if (ret) { |
6490 | thinkpad_acpi_module_exit(); | 6681 | thinkpad_acpi_module_exit(); |
diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c index c42f4b83f686..3fcf92130aa4 100644 --- a/drivers/mtd/maps/uclinux.c +++ b/drivers/mtd/maps/uclinux.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
18 | #include <linux/mm.h> | ||
18 | #include <linux/major.h> | 19 | #include <linux/major.h> |
19 | #include <linux/mtd/mtd.h> | 20 | #include <linux/mtd/mtd.h> |
20 | #include <linux/mtd/map.h> | 21 | #include <linux/mtd/map.h> |
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 869544b8c05c..9c0f56b3c518 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -4067,8 +4067,6 @@ static void e1000_netpoll(struct net_device *netdev) | |||
4067 | disable_irq(adapter->pdev->irq); | 4067 | disable_irq(adapter->pdev->irq); |
4068 | e1000_intr(adapter->pdev->irq, netdev); | 4068 | e1000_intr(adapter->pdev->irq, netdev); |
4069 | 4069 | ||
4070 | e1000_clean_tx_irq(adapter); | ||
4071 | |||
4072 | enable_irq(adapter->pdev->irq); | 4070 | enable_irq(adapter->pdev->irq); |
4073 | } | 4071 | } |
4074 | #endif | 4072 | #endif |
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 32a4f17d35fc..ecd5c71a7a8a 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -2,12 +2,6 @@ | |||
2 | * Fast Ethernet Controller (FEC) driver for Motorola MPC8xx. | 2 | * Fast Ethernet Controller (FEC) driver for Motorola MPC8xx. |
3 | * Copyright (c) 1997 Dan Malek (dmalek@jlc.net) | 3 | * Copyright (c) 1997 Dan Malek (dmalek@jlc.net) |
4 | * | 4 | * |
5 | * This version of the driver is specific to the FADS implementation, | ||
6 | * since the board contains control registers external to the processor | ||
7 | * for the control of the LevelOne LXT970 transceiver. The MPC860T manual | ||
8 | * describes connections using the internal parallel port I/O, which | ||
9 | * is basically all of Port D. | ||
10 | * | ||
11 | * Right now, I am very wasteful with the buffers. I allocate memory | 5 | * Right now, I am very wasteful with the buffers. I allocate memory |
12 | * pages and then divide them into 2K frame buffers. This way I know I | 6 | * pages and then divide them into 2K frame buffers. This way I know I |
13 | * have buffers large enough to hold one frame within one buffer descriptor. | 7 | * have buffers large enough to hold one frame within one buffer descriptor. |
@@ -49,17 +43,9 @@ | |||
49 | #include <asm/pgtable.h> | 43 | #include <asm/pgtable.h> |
50 | #include <asm/cacheflush.h> | 44 | #include <asm/cacheflush.h> |
51 | 45 | ||
52 | #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \ | ||
53 | defined(CONFIG_M5272) || defined(CONFIG_M528x) || \ | ||
54 | defined(CONFIG_M520x) || defined(CONFIG_M532x) | ||
55 | #include <asm/coldfire.h> | 46 | #include <asm/coldfire.h> |
56 | #include <asm/mcfsim.h> | 47 | #include <asm/mcfsim.h> |
57 | #include "fec.h" | 48 | #include "fec.h" |
58 | #else | ||
59 | #include <asm/8xx_immap.h> | ||
60 | #include <asm/mpc8xx.h> | ||
61 | #include "commproc.h" | ||
62 | #endif | ||
63 | 49 | ||
64 | #if defined(CONFIG_FEC2) | 50 | #if defined(CONFIG_FEC2) |
65 | #define FEC_MAX_PORTS 2 | 51 | #define FEC_MAX_PORTS 2 |
@@ -67,7 +53,7 @@ | |||
67 | #define FEC_MAX_PORTS 1 | 53 | #define FEC_MAX_PORTS 1 |
68 | #endif | 54 | #endif |
69 | 55 | ||
70 | #if defined(CONFIG_FADS) || defined(CONFIG_RPXCLASSIC) || defined(CONFIG_M5272) | 56 | #if defined(CONFIG_M5272) |
71 | #define HAVE_mii_link_interrupt | 57 | #define HAVE_mii_link_interrupt |
72 | #endif | 58 | #endif |
73 | 59 | ||
@@ -1235,14 +1221,9 @@ static phy_info_t const * const phy_info[] = { | |||
1235 | 1221 | ||
1236 | /* ------------------------------------------------------------------------- */ | 1222 | /* ------------------------------------------------------------------------- */ |
1237 | #ifdef HAVE_mii_link_interrupt | 1223 | #ifdef HAVE_mii_link_interrupt |
1238 | #ifdef CONFIG_RPXCLASSIC | ||
1239 | static void | ||
1240 | mii_link_interrupt(void *dev_id); | ||
1241 | #else | ||
1242 | static irqreturn_t | 1224 | static irqreturn_t |
1243 | mii_link_interrupt(int irq, void * dev_id); | 1225 | mii_link_interrupt(int irq, void * dev_id); |
1244 | #endif | 1226 | #endif |
1245 | #endif | ||
1246 | 1227 | ||
1247 | #if defined(CONFIG_M5272) | 1228 | #if defined(CONFIG_M5272) |
1248 | /* | 1229 | /* |
@@ -1795,24 +1776,6 @@ static void __inline__ fec_request_intrs(struct net_device *dev) | |||
1795 | 1776 | ||
1796 | if (request_8xxirq(FEC_INTERRUPT, fec_enet_interrupt, 0, "fec", dev) != 0) | 1777 | if (request_8xxirq(FEC_INTERRUPT, fec_enet_interrupt, 0, "fec", dev) != 0) |
1797 | panic("Could not allocate FEC IRQ!"); | 1778 | panic("Could not allocate FEC IRQ!"); |
1798 | |||
1799 | #ifdef CONFIG_RPXCLASSIC | ||
1800 | /* Make Port C, bit 15 an input that causes interrupts. | ||
1801 | */ | ||
1802 | immap->im_ioport.iop_pcpar &= ~0x0001; | ||
1803 | immap->im_ioport.iop_pcdir &= ~0x0001; | ||
1804 | immap->im_ioport.iop_pcso &= ~0x0001; | ||
1805 | immap->im_ioport.iop_pcint |= 0x0001; | ||
1806 | cpm_install_handler(CPMVEC_PIO_PC15, mii_link_interrupt, dev); | ||
1807 | |||
1808 | /* Make LEDS reflect Link status. | ||
1809 | */ | ||
1810 | *((uint *) RPX_CSR_ADDR) &= ~BCSR2_FETHLEDMODE; | ||
1811 | #endif | ||
1812 | #ifdef CONFIG_FADS | ||
1813 | if (request_8xxirq(SIU_IRQ2, mii_link_interrupt, 0, "mii", dev) != 0) | ||
1814 | panic("Could not allocate MII IRQ!"); | ||
1815 | #endif | ||
1816 | } | 1779 | } |
1817 | 1780 | ||
1818 | static void __inline__ fec_get_mac(struct net_device *dev) | 1781 | static void __inline__ fec_get_mac(struct net_device *dev) |
@@ -1821,16 +1784,6 @@ static void __inline__ fec_get_mac(struct net_device *dev) | |||
1821 | 1784 | ||
1822 | bd = (bd_t *)__res; | 1785 | bd = (bd_t *)__res; |
1823 | memcpy(dev->dev_addr, bd->bi_enetaddr, ETH_ALEN); | 1786 | memcpy(dev->dev_addr, bd->bi_enetaddr, ETH_ALEN); |
1824 | |||
1825 | #ifdef CONFIG_RPXCLASSIC | ||
1826 | /* The Embedded Planet boards have only one MAC address in | ||
1827 | * the EEPROM, but can have two Ethernet ports. For the | ||
1828 | * FEC port, we create another address by setting one of | ||
1829 | * the address bits above something that would have (up to | ||
1830 | * now) been allocated. | ||
1831 | */ | ||
1832 | dev->dev_adrd[3] |= 0x80; | ||
1833 | #endif | ||
1834 | } | 1787 | } |
1835 | 1788 | ||
1836 | static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep) | 1789 | static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep) |
@@ -2109,13 +2062,8 @@ mii_discover_phy(uint mii_reg, struct net_device *dev) | |||
2109 | /* This interrupt occurs when the PHY detects a link change. | 2062 | /* This interrupt occurs when the PHY detects a link change. |
2110 | */ | 2063 | */ |
2111 | #ifdef HAVE_mii_link_interrupt | 2064 | #ifdef HAVE_mii_link_interrupt |
2112 | #ifdef CONFIG_RPXCLASSIC | ||
2113 | static void | ||
2114 | mii_link_interrupt(void *dev_id) | ||
2115 | #else | ||
2116 | static irqreturn_t | 2065 | static irqreturn_t |
2117 | mii_link_interrupt(int irq, void * dev_id) | 2066 | mii_link_interrupt(int irq, void * dev_id) |
2118 | #endif | ||
2119 | { | 2067 | { |
2120 | struct net_device *dev = dev_id; | 2068 | struct net_device *dev = dev_id; |
2121 | struct fec_enet_private *fep = netdev_priv(dev); | 2069 | struct fec_enet_private *fep = netdev_priv(dev); |
diff --git a/drivers/net/mlx4/cmd.c b/drivers/net/mlx4/cmd.c index 70dff94a8bc6..04d5bc69a6f8 100644 --- a/drivers/net/mlx4/cmd.c +++ b/drivers/net/mlx4/cmd.c | |||
@@ -67,6 +67,8 @@ enum { | |||
67 | CMD_STAT_BAD_INDEX = 0x0a, | 67 | CMD_STAT_BAD_INDEX = 0x0a, |
68 | /* FW image corrupted: */ | 68 | /* FW image corrupted: */ |
69 | CMD_STAT_BAD_NVMEM = 0x0b, | 69 | CMD_STAT_BAD_NVMEM = 0x0b, |
70 | /* Error in ICM mapping (e.g. not enough auxiliary ICM pages to execute command): */ | ||
71 | CMD_STAT_ICM_ERROR = 0x0c, | ||
70 | /* Attempt to modify a QP/EE which is not in the presumed state: */ | 72 | /* Attempt to modify a QP/EE which is not in the presumed state: */ |
71 | CMD_STAT_BAD_QP_STATE = 0x10, | 73 | CMD_STAT_BAD_QP_STATE = 0x10, |
72 | /* Bad segment parameters (Address/Size): */ | 74 | /* Bad segment parameters (Address/Size): */ |
@@ -119,6 +121,7 @@ static int mlx4_status_to_errno(u8 status) | |||
119 | [CMD_STAT_BAD_RES_STATE] = -EBADF, | 121 | [CMD_STAT_BAD_RES_STATE] = -EBADF, |
120 | [CMD_STAT_BAD_INDEX] = -EBADF, | 122 | [CMD_STAT_BAD_INDEX] = -EBADF, |
121 | [CMD_STAT_BAD_NVMEM] = -EFAULT, | 123 | [CMD_STAT_BAD_NVMEM] = -EFAULT, |
124 | [CMD_STAT_ICM_ERROR] = -ENFILE, | ||
122 | [CMD_STAT_BAD_QP_STATE] = -EINVAL, | 125 | [CMD_STAT_BAD_QP_STATE] = -EINVAL, |
123 | [CMD_STAT_BAD_SEG_PARAM] = -EFAULT, | 126 | [CMD_STAT_BAD_SEG_PARAM] = -EFAULT, |
124 | [CMD_STAT_REG_BOUND] = -EBUSY, | 127 | [CMD_STAT_REG_BOUND] = -EBUSY, |
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c index e141a1513f07..ea3a09aaa844 100644 --- a/drivers/net/mlx4/eq.c +++ b/drivers/net/mlx4/eq.c | |||
@@ -33,6 +33,7 @@ | |||
33 | 33 | ||
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
36 | #include <linux/mm.h> | ||
36 | #include <linux/dma-mapping.h> | 37 | #include <linux/dma-mapping.h> |
37 | 38 | ||
38 | #include <linux/mlx4/cmd.h> | 39 | #include <linux/mlx4/cmd.h> |
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c index 2b5006b9be67..57278224ba1e 100644 --- a/drivers/net/mlx4/fw.c +++ b/drivers/net/mlx4/fw.c | |||
@@ -46,6 +46,10 @@ enum { | |||
46 | extern void __buggy_use_of_MLX4_GET(void); | 46 | extern void __buggy_use_of_MLX4_GET(void); |
47 | extern void __buggy_use_of_MLX4_PUT(void); | 47 | extern void __buggy_use_of_MLX4_PUT(void); |
48 | 48 | ||
49 | static int enable_qos; | ||
50 | module_param(enable_qos, bool, 0444); | ||
51 | MODULE_PARM_DESC(enable_qos, "Enable Quality of Service support in the HCA (default: off)"); | ||
52 | |||
49 | #define MLX4_GET(dest, source, offset) \ | 53 | #define MLX4_GET(dest, source, offset) \ |
50 | do { \ | 54 | do { \ |
51 | void *__p = (char *) (source) + (offset); \ | 55 | void *__p = (char *) (source) + (offset); \ |
@@ -198,7 +202,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
198 | #define QUERY_DEV_CAP_C_MPT_ENTRY_SZ_OFFSET 0x8e | 202 | #define QUERY_DEV_CAP_C_MPT_ENTRY_SZ_OFFSET 0x8e |
199 | #define QUERY_DEV_CAP_MTT_ENTRY_SZ_OFFSET 0x90 | 203 | #define QUERY_DEV_CAP_MTT_ENTRY_SZ_OFFSET 0x90 |
200 | #define QUERY_DEV_CAP_D_MPT_ENTRY_SZ_OFFSET 0x92 | 204 | #define QUERY_DEV_CAP_D_MPT_ENTRY_SZ_OFFSET 0x92 |
201 | #define QUERY_DEV_CAP_BMME_FLAGS_OFFSET 0x97 | 205 | #define QUERY_DEV_CAP_BMME_FLAGS_OFFSET 0x94 |
202 | #define QUERY_DEV_CAP_RSVD_LKEY_OFFSET 0x98 | 206 | #define QUERY_DEV_CAP_RSVD_LKEY_OFFSET 0x98 |
203 | #define QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET 0xa0 | 207 | #define QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET 0xa0 |
204 | 208 | ||
@@ -373,12 +377,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
373 | } | 377 | } |
374 | } | 378 | } |
375 | 379 | ||
376 | if (dev_cap->bmme_flags & 1) | 380 | mlx4_dbg(dev, "Base MM extensions: flags %08x, rsvd L_Key %08x\n", |
377 | mlx4_dbg(dev, "Base MM extensions: yes " | 381 | dev_cap->bmme_flags, dev_cap->reserved_lkey); |
378 | "(flags %d, rsvd L_Key %08x)\n", | ||
379 | dev_cap->bmme_flags, dev_cap->reserved_lkey); | ||
380 | else | ||
381 | mlx4_dbg(dev, "Base MM extensions: no\n"); | ||
382 | 382 | ||
383 | /* | 383 | /* |
384 | * Each UAR has 4 EQ doorbells; so if a UAR is reserved, then | 384 | * Each UAR has 4 EQ doorbells; so if a UAR is reserved, then |
@@ -737,6 +737,10 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param) | |||
737 | if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM) | 737 | if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM) |
738 | *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 3); | 738 | *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 3); |
739 | 739 | ||
740 | /* Enable QoS support if module parameter set */ | ||
741 | if (enable_qos) | ||
742 | *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 2); | ||
743 | |||
740 | /* QPC/EEC/CQC/EQC/RDMARC attributes */ | 744 | /* QPC/EEC/CQC/EQC/RDMARC attributes */ |
741 | 745 | ||
742 | MLX4_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET); | 746 | MLX4_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET); |
diff --git a/drivers/net/mlx4/fw.h b/drivers/net/mlx4/fw.h index a0e046c149b7..fbf0e22be122 100644 --- a/drivers/net/mlx4/fw.h +++ b/drivers/net/mlx4/fw.h | |||
@@ -98,7 +98,7 @@ struct mlx4_dev_cap { | |||
98 | int cmpt_entry_sz; | 98 | int cmpt_entry_sz; |
99 | int mtt_entry_sz; | 99 | int mtt_entry_sz; |
100 | int resize_srq; | 100 | int resize_srq; |
101 | u8 bmme_flags; | 101 | u32 bmme_flags; |
102 | u32 reserved_lkey; | 102 | u32 reserved_lkey; |
103 | u64 max_icm_sz; | 103 | u64 max_icm_sz; |
104 | int max_gso_sz; | 104 | int max_gso_sz; |
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c index d3736013fe9b..8e1d24cda1b0 100644 --- a/drivers/net/mlx4/main.c +++ b/drivers/net/mlx4/main.c | |||
@@ -158,6 +158,8 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
158 | dev->caps.max_msg_sz = dev_cap->max_msg_sz; | 158 | dev->caps.max_msg_sz = dev_cap->max_msg_sz; |
159 | dev->caps.page_size_cap = ~(u32) (dev_cap->min_page_sz - 1); | 159 | dev->caps.page_size_cap = ~(u32) (dev_cap->min_page_sz - 1); |
160 | dev->caps.flags = dev_cap->flags; | 160 | dev->caps.flags = dev_cap->flags; |
161 | dev->caps.bmme_flags = dev_cap->bmme_flags; | ||
162 | dev->caps.reserved_lkey = dev_cap->reserved_lkey; | ||
161 | dev->caps.stat_rate_support = dev_cap->stat_rate_support; | 163 | dev->caps.stat_rate_support = dev_cap->stat_rate_support; |
162 | dev->caps.max_gso_sz = dev_cap->max_gso_sz; | 164 | dev->caps.max_gso_sz = dev_cap->max_gso_sz; |
163 | 165 | ||
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index a4023c2dd050..78038499cff5 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h | |||
@@ -118,6 +118,7 @@ struct mlx4_bitmap { | |||
118 | 118 | ||
119 | struct mlx4_buddy { | 119 | struct mlx4_buddy { |
120 | unsigned long **bits; | 120 | unsigned long **bits; |
121 | unsigned int *num_free; | ||
121 | int max_order; | 122 | int max_order; |
122 | spinlock_t lock; | 123 | spinlock_t lock; |
123 | }; | 124 | }; |
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c index 03a9abcce524..a3c04c5f12c2 100644 --- a/drivers/net/mlx4/mr.c +++ b/drivers/net/mlx4/mr.c | |||
@@ -47,7 +47,7 @@ struct mlx4_mpt_entry { | |||
47 | __be32 flags; | 47 | __be32 flags; |
48 | __be32 qpn; | 48 | __be32 qpn; |
49 | __be32 key; | 49 | __be32 key; |
50 | __be32 pd; | 50 | __be32 pd_flags; |
51 | __be64 start; | 51 | __be64 start; |
52 | __be64 length; | 52 | __be64 length; |
53 | __be32 lkey; | 53 | __be32 lkey; |
@@ -61,11 +61,15 @@ struct mlx4_mpt_entry { | |||
61 | } __attribute__((packed)); | 61 | } __attribute__((packed)); |
62 | 62 | ||
63 | #define MLX4_MPT_FLAG_SW_OWNS (0xfUL << 28) | 63 | #define MLX4_MPT_FLAG_SW_OWNS (0xfUL << 28) |
64 | #define MLX4_MPT_FLAG_FREE (0x3UL << 28) | ||
64 | #define MLX4_MPT_FLAG_MIO (1 << 17) | 65 | #define MLX4_MPT_FLAG_MIO (1 << 17) |
65 | #define MLX4_MPT_FLAG_BIND_ENABLE (1 << 15) | 66 | #define MLX4_MPT_FLAG_BIND_ENABLE (1 << 15) |
66 | #define MLX4_MPT_FLAG_PHYSICAL (1 << 9) | 67 | #define MLX4_MPT_FLAG_PHYSICAL (1 << 9) |
67 | #define MLX4_MPT_FLAG_REGION (1 << 8) | 68 | #define MLX4_MPT_FLAG_REGION (1 << 8) |
68 | 69 | ||
70 | #define MLX4_MPT_PD_FLAG_FAST_REG (1 << 26) | ||
71 | #define MLX4_MPT_PD_FLAG_EN_INV (3 << 24) | ||
72 | |||
69 | #define MLX4_MTT_FLAG_PRESENT 1 | 73 | #define MLX4_MTT_FLAG_PRESENT 1 |
70 | 74 | ||
71 | #define MLX4_MPT_STATUS_SW 0xF0 | 75 | #define MLX4_MPT_STATUS_SW 0xF0 |
@@ -79,23 +83,26 @@ static u32 mlx4_buddy_alloc(struct mlx4_buddy *buddy, int order) | |||
79 | 83 | ||
80 | spin_lock(&buddy->lock); | 84 | spin_lock(&buddy->lock); |
81 | 85 | ||
82 | for (o = order; o <= buddy->max_order; ++o) { | 86 | for (o = order; o <= buddy->max_order; ++o) |
83 | m = 1 << (buddy->max_order - o); | 87 | if (buddy->num_free[o]) { |
84 | seg = find_first_bit(buddy->bits[o], m); | 88 | m = 1 << (buddy->max_order - o); |
85 | if (seg < m) | 89 | seg = find_first_bit(buddy->bits[o], m); |
86 | goto found; | 90 | if (seg < m) |
87 | } | 91 | goto found; |
92 | } | ||
88 | 93 | ||
89 | spin_unlock(&buddy->lock); | 94 | spin_unlock(&buddy->lock); |
90 | return -1; | 95 | return -1; |
91 | 96 | ||
92 | found: | 97 | found: |
93 | clear_bit(seg, buddy->bits[o]); | 98 | clear_bit(seg, buddy->bits[o]); |
99 | --buddy->num_free[o]; | ||
94 | 100 | ||
95 | while (o > order) { | 101 | while (o > order) { |
96 | --o; | 102 | --o; |
97 | seg <<= 1; | 103 | seg <<= 1; |
98 | set_bit(seg ^ 1, buddy->bits[o]); | 104 | set_bit(seg ^ 1, buddy->bits[o]); |
105 | ++buddy->num_free[o]; | ||
99 | } | 106 | } |
100 | 107 | ||
101 | spin_unlock(&buddy->lock); | 108 | spin_unlock(&buddy->lock); |
@@ -113,11 +120,13 @@ static void mlx4_buddy_free(struct mlx4_buddy *buddy, u32 seg, int order) | |||
113 | 120 | ||
114 | while (test_bit(seg ^ 1, buddy->bits[order])) { | 121 | while (test_bit(seg ^ 1, buddy->bits[order])) { |
115 | clear_bit(seg ^ 1, buddy->bits[order]); | 122 | clear_bit(seg ^ 1, buddy->bits[order]); |
123 | --buddy->num_free[order]; | ||
116 | seg >>= 1; | 124 | seg >>= 1; |
117 | ++order; | 125 | ++order; |
118 | } | 126 | } |
119 | 127 | ||
120 | set_bit(seg, buddy->bits[order]); | 128 | set_bit(seg, buddy->bits[order]); |
129 | ++buddy->num_free[order]; | ||
121 | 130 | ||
122 | spin_unlock(&buddy->lock); | 131 | spin_unlock(&buddy->lock); |
123 | } | 132 | } |
@@ -131,7 +140,9 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order) | |||
131 | 140 | ||
132 | buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *), | 141 | buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *), |
133 | GFP_KERNEL); | 142 | GFP_KERNEL); |
134 | if (!buddy->bits) | 143 | buddy->num_free = kzalloc((buddy->max_order + 1) * sizeof (int *), |
144 | GFP_KERNEL); | ||
145 | if (!buddy->bits || !buddy->num_free) | ||
135 | goto err_out; | 146 | goto err_out; |
136 | 147 | ||
137 | for (i = 0; i <= buddy->max_order; ++i) { | 148 | for (i = 0; i <= buddy->max_order; ++i) { |
@@ -143,6 +154,7 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order) | |||
143 | } | 154 | } |
144 | 155 | ||
145 | set_bit(0, buddy->bits[buddy->max_order]); | 156 | set_bit(0, buddy->bits[buddy->max_order]); |
157 | buddy->num_free[buddy->max_order] = 1; | ||
146 | 158 | ||
147 | return 0; | 159 | return 0; |
148 | 160 | ||
@@ -150,9 +162,10 @@ err_out_free: | |||
150 | for (i = 0; i <= buddy->max_order; ++i) | 162 | for (i = 0; i <= buddy->max_order; ++i) |
151 | kfree(buddy->bits[i]); | 163 | kfree(buddy->bits[i]); |
152 | 164 | ||
165 | err_out: | ||
153 | kfree(buddy->bits); | 166 | kfree(buddy->bits); |
167 | kfree(buddy->num_free); | ||
154 | 168 | ||
155 | err_out: | ||
156 | return -ENOMEM; | 169 | return -ENOMEM; |
157 | } | 170 | } |
158 | 171 | ||
@@ -164,6 +177,7 @@ static void mlx4_buddy_cleanup(struct mlx4_buddy *buddy) | |||
164 | kfree(buddy->bits[i]); | 177 | kfree(buddy->bits[i]); |
165 | 178 | ||
166 | kfree(buddy->bits); | 179 | kfree(buddy->bits); |
180 | kfree(buddy->num_free); | ||
167 | } | 181 | } |
168 | 182 | ||
169 | static u32 mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order) | 183 | static u32 mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order) |
@@ -314,21 +328,30 @@ int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr) | |||
314 | 328 | ||
315 | memset(mpt_entry, 0, sizeof *mpt_entry); | 329 | memset(mpt_entry, 0, sizeof *mpt_entry); |
316 | 330 | ||
317 | mpt_entry->flags = cpu_to_be32(MLX4_MPT_FLAG_SW_OWNS | | 331 | mpt_entry->flags = cpu_to_be32(MLX4_MPT_FLAG_MIO | |
318 | MLX4_MPT_FLAG_MIO | | ||
319 | MLX4_MPT_FLAG_REGION | | 332 | MLX4_MPT_FLAG_REGION | |
320 | mr->access); | 333 | mr->access); |
321 | 334 | ||
322 | mpt_entry->key = cpu_to_be32(key_to_hw_index(mr->key)); | 335 | mpt_entry->key = cpu_to_be32(key_to_hw_index(mr->key)); |
323 | mpt_entry->pd = cpu_to_be32(mr->pd); | 336 | mpt_entry->pd_flags = cpu_to_be32(mr->pd | MLX4_MPT_PD_FLAG_EN_INV); |
324 | mpt_entry->start = cpu_to_be64(mr->iova); | 337 | mpt_entry->start = cpu_to_be64(mr->iova); |
325 | mpt_entry->length = cpu_to_be64(mr->size); | 338 | mpt_entry->length = cpu_to_be64(mr->size); |
326 | mpt_entry->entity_size = cpu_to_be32(mr->mtt.page_shift); | 339 | mpt_entry->entity_size = cpu_to_be32(mr->mtt.page_shift); |
340 | |||
327 | if (mr->mtt.order < 0) { | 341 | if (mr->mtt.order < 0) { |
328 | mpt_entry->flags |= cpu_to_be32(MLX4_MPT_FLAG_PHYSICAL); | 342 | mpt_entry->flags |= cpu_to_be32(MLX4_MPT_FLAG_PHYSICAL); |
329 | mpt_entry->mtt_seg = 0; | 343 | mpt_entry->mtt_seg = 0; |
330 | } else | 344 | } else { |
331 | mpt_entry->mtt_seg = cpu_to_be64(mlx4_mtt_addr(dev, &mr->mtt)); | 345 | mpt_entry->mtt_seg = cpu_to_be64(mlx4_mtt_addr(dev, &mr->mtt)); |
346 | } | ||
347 | |||
348 | if (mr->mtt.order >= 0 && mr->mtt.page_shift == 0) { | ||
349 | /* fast register MR in free state */ | ||
350 | mpt_entry->flags |= cpu_to_be32(MLX4_MPT_FLAG_FREE); | ||
351 | mpt_entry->pd_flags |= cpu_to_be32(MLX4_MPT_PD_FLAG_FAST_REG); | ||
352 | } else { | ||
353 | mpt_entry->flags |= cpu_to_be32(MLX4_MPT_FLAG_SW_OWNS); | ||
354 | } | ||
332 | 355 | ||
333 | err = mlx4_SW2HW_MPT(dev, mailbox, | 356 | err = mlx4_SW2HW_MPT(dev, mailbox, |
334 | key_to_hw_index(mr->key) & (dev->caps.num_mpts - 1)); | 357 | key_to_hw_index(mr->key) & (dev->caps.num_mpts - 1)); |
diff --git a/drivers/net/mlx4/pd.c b/drivers/net/mlx4/pd.c index 3a93c5f0f7ab..aa616892d09c 100644 --- a/drivers/net/mlx4/pd.c +++ b/drivers/net/mlx4/pd.c | |||
@@ -91,6 +91,13 @@ EXPORT_SYMBOL_GPL(mlx4_uar_free); | |||
91 | 91 | ||
92 | int mlx4_init_uar_table(struct mlx4_dev *dev) | 92 | int mlx4_init_uar_table(struct mlx4_dev *dev) |
93 | { | 93 | { |
94 | if (dev->caps.num_uars <= 128) { | ||
95 | mlx4_err(dev, "Only %d UAR pages (need more than 128)\n", | ||
96 | dev->caps.num_uars); | ||
97 | mlx4_err(dev, "Increase firmware log2_uar_bar_megabytes?\n"); | ||
98 | return -ENODEV; | ||
99 | } | ||
100 | |||
94 | return mlx4_bitmap_init(&mlx4_priv(dev)->uar_table.bitmap, | 101 | return mlx4_bitmap_init(&mlx4_priv(dev)->uar_table.bitmap, |
95 | dev->caps.num_uars, dev->caps.num_uars - 1, | 102 | dev->caps.num_uars, dev->caps.num_uars - 1, |
96 | max(128, dev->caps.reserved_uars)); | 103 | max(128, dev->caps.reserved_uars)); |
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 711e4a8948e0..5257cf464f1a 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -1829,9 +1829,6 @@ static int sky2_down(struct net_device *dev) | |||
1829 | if (netif_msg_ifdown(sky2)) | 1829 | if (netif_msg_ifdown(sky2)) |
1830 | printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); | 1830 | printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); |
1831 | 1831 | ||
1832 | /* Stop more packets from being queued */ | ||
1833 | netif_stop_queue(dev); | ||
1834 | |||
1835 | /* Disable port IRQ */ | 1832 | /* Disable port IRQ */ |
1836 | imask = sky2_read32(hw, B0_IMSK); | 1833 | imask = sky2_read32(hw, B0_IMSK); |
1837 | imask &= ~portirq_msk[port]; | 1834 | imask &= ~portirq_msk[port]; |
@@ -1887,8 +1884,6 @@ static int sky2_down(struct net_device *dev) | |||
1887 | 1884 | ||
1888 | sky2_phy_power_down(hw, port); | 1885 | sky2_phy_power_down(hw, port); |
1889 | 1886 | ||
1890 | netif_carrier_off(dev); | ||
1891 | |||
1892 | /* turn off LED's */ | 1887 | /* turn off LED's */ |
1893 | sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); | 1888 | sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); |
1894 | 1889 | ||
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index c28d7cb2035b..0196a0df9021 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -19,6 +19,7 @@ | |||
19 | //#define DEBUG | 19 | //#define DEBUG |
20 | #include <linux/netdevice.h> | 20 | #include <linux/netdevice.h> |
21 | #include <linux/etherdevice.h> | 21 | #include <linux/etherdevice.h> |
22 | #include <linux/ethtool.h> | ||
22 | #include <linux/module.h> | 23 | #include <linux/module.h> |
23 | #include <linux/virtio.h> | 24 | #include <linux/virtio.h> |
24 | #include <linux/virtio_net.h> | 25 | #include <linux/virtio_net.h> |
@@ -54,9 +55,15 @@ struct virtnet_info | |||
54 | struct tasklet_struct tasklet; | 55 | struct tasklet_struct tasklet; |
55 | bool free_in_tasklet; | 56 | bool free_in_tasklet; |
56 | 57 | ||
58 | /* I like... big packets and I cannot lie! */ | ||
59 | bool big_packets; | ||
60 | |||
57 | /* Receive & send queues. */ | 61 | /* Receive & send queues. */ |
58 | struct sk_buff_head recv; | 62 | struct sk_buff_head recv; |
59 | struct sk_buff_head send; | 63 | struct sk_buff_head send; |
64 | |||
65 | /* Chain pages by the private ptr. */ | ||
66 | struct page *pages; | ||
60 | }; | 67 | }; |
61 | 68 | ||
62 | static inline struct virtio_net_hdr *skb_vnet_hdr(struct sk_buff *skb) | 69 | static inline struct virtio_net_hdr *skb_vnet_hdr(struct sk_buff *skb) |
@@ -69,6 +76,23 @@ static inline void vnet_hdr_to_sg(struct scatterlist *sg, struct sk_buff *skb) | |||
69 | sg_init_one(sg, skb_vnet_hdr(skb), sizeof(struct virtio_net_hdr)); | 76 | sg_init_one(sg, skb_vnet_hdr(skb), sizeof(struct virtio_net_hdr)); |
70 | } | 77 | } |
71 | 78 | ||
79 | static void give_a_page(struct virtnet_info *vi, struct page *page) | ||
80 | { | ||
81 | page->private = (unsigned long)vi->pages; | ||
82 | vi->pages = page; | ||
83 | } | ||
84 | |||
85 | static struct page *get_a_page(struct virtnet_info *vi, gfp_t gfp_mask) | ||
86 | { | ||
87 | struct page *p = vi->pages; | ||
88 | |||
89 | if (p) | ||
90 | vi->pages = (struct page *)p->private; | ||
91 | else | ||
92 | p = alloc_page(gfp_mask); | ||
93 | return p; | ||
94 | } | ||
95 | |||
72 | static void skb_xmit_done(struct virtqueue *svq) | 96 | static void skb_xmit_done(struct virtqueue *svq) |
73 | { | 97 | { |
74 | struct virtnet_info *vi = svq->vdev->priv; | 98 | struct virtnet_info *vi = svq->vdev->priv; |
@@ -88,6 +112,7 @@ static void receive_skb(struct net_device *dev, struct sk_buff *skb, | |||
88 | unsigned len) | 112 | unsigned len) |
89 | { | 113 | { |
90 | struct virtio_net_hdr *hdr = skb_vnet_hdr(skb); | 114 | struct virtio_net_hdr *hdr = skb_vnet_hdr(skb); |
115 | int err; | ||
91 | 116 | ||
92 | if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) { | 117 | if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) { |
93 | pr_debug("%s: short packet %i\n", dev->name, len); | 118 | pr_debug("%s: short packet %i\n", dev->name, len); |
@@ -95,10 +120,23 @@ static void receive_skb(struct net_device *dev, struct sk_buff *skb, | |||
95 | goto drop; | 120 | goto drop; |
96 | } | 121 | } |
97 | len -= sizeof(struct virtio_net_hdr); | 122 | len -= sizeof(struct virtio_net_hdr); |
98 | BUG_ON(len > MAX_PACKET_LEN); | ||
99 | 123 | ||
100 | skb_trim(skb, len); | 124 | if (len <= MAX_PACKET_LEN) { |
125 | unsigned int i; | ||
101 | 126 | ||
127 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) | ||
128 | give_a_page(dev->priv, skb_shinfo(skb)->frags[i].page); | ||
129 | skb->data_len = 0; | ||
130 | skb_shinfo(skb)->nr_frags = 0; | ||
131 | } | ||
132 | |||
133 | err = pskb_trim(skb, len); | ||
134 | if (err) { | ||
135 | pr_debug("%s: pskb_trim failed %i %d\n", dev->name, len, err); | ||
136 | dev->stats.rx_dropped++; | ||
137 | goto drop; | ||
138 | } | ||
139 | skb->truesize += skb->data_len; | ||
102 | dev->stats.rx_bytes += skb->len; | 140 | dev->stats.rx_bytes += skb->len; |
103 | dev->stats.rx_packets++; | 141 | dev->stats.rx_packets++; |
104 | 142 | ||
@@ -160,7 +198,7 @@ static void try_fill_recv(struct virtnet_info *vi) | |||
160 | { | 198 | { |
161 | struct sk_buff *skb; | 199 | struct sk_buff *skb; |
162 | struct scatterlist sg[2+MAX_SKB_FRAGS]; | 200 | struct scatterlist sg[2+MAX_SKB_FRAGS]; |
163 | int num, err; | 201 | int num, err, i; |
164 | 202 | ||
165 | sg_init_table(sg, 2+MAX_SKB_FRAGS); | 203 | sg_init_table(sg, 2+MAX_SKB_FRAGS); |
166 | for (;;) { | 204 | for (;;) { |
@@ -170,6 +208,24 @@ static void try_fill_recv(struct virtnet_info *vi) | |||
170 | 208 | ||
171 | skb_put(skb, MAX_PACKET_LEN); | 209 | skb_put(skb, MAX_PACKET_LEN); |
172 | vnet_hdr_to_sg(sg, skb); | 210 | vnet_hdr_to_sg(sg, skb); |
211 | |||
212 | if (vi->big_packets) { | ||
213 | for (i = 0; i < MAX_SKB_FRAGS; i++) { | ||
214 | skb_frag_t *f = &skb_shinfo(skb)->frags[i]; | ||
215 | f->page = get_a_page(vi, GFP_ATOMIC); | ||
216 | if (!f->page) | ||
217 | break; | ||
218 | |||
219 | f->page_offset = 0; | ||
220 | f->size = PAGE_SIZE; | ||
221 | |||
222 | skb->data_len += PAGE_SIZE; | ||
223 | skb->len += PAGE_SIZE; | ||
224 | |||
225 | skb_shinfo(skb)->nr_frags++; | ||
226 | } | ||
227 | } | ||
228 | |||
173 | num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; | 229 | num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; |
174 | skb_queue_head(&vi->recv, skb); | 230 | skb_queue_head(&vi->recv, skb); |
175 | 231 | ||
@@ -335,16 +391,11 @@ again: | |||
335 | free_old_xmit_skbs(vi); | 391 | free_old_xmit_skbs(vi); |
336 | 392 | ||
337 | /* If we has a buffer left over from last time, send it now. */ | 393 | /* If we has a buffer left over from last time, send it now. */ |
338 | if (unlikely(vi->last_xmit_skb)) { | 394 | if (unlikely(vi->last_xmit_skb) && |
339 | if (xmit_skb(vi, vi->last_xmit_skb) != 0) { | 395 | xmit_skb(vi, vi->last_xmit_skb) != 0) |
340 | /* Drop this skb: we only queue one. */ | 396 | goto stop_queue; |
341 | vi->dev->stats.tx_dropped++; | 397 | |
342 | kfree_skb(skb); | 398 | vi->last_xmit_skb = NULL; |
343 | skb = NULL; | ||
344 | goto stop_queue; | ||
345 | } | ||
346 | vi->last_xmit_skb = NULL; | ||
347 | } | ||
348 | 399 | ||
349 | /* Put new one in send queue and do transmit */ | 400 | /* Put new one in send queue and do transmit */ |
350 | if (likely(skb)) { | 401 | if (likely(skb)) { |
@@ -370,6 +421,11 @@ stop_queue: | |||
370 | netif_start_queue(dev); | 421 | netif_start_queue(dev); |
371 | goto again; | 422 | goto again; |
372 | } | 423 | } |
424 | if (skb) { | ||
425 | /* Drop this skb: we only queue one. */ | ||
426 | vi->dev->stats.tx_dropped++; | ||
427 | kfree_skb(skb); | ||
428 | } | ||
373 | goto done; | 429 | goto done; |
374 | } | 430 | } |
375 | 431 | ||
@@ -408,6 +464,22 @@ static int virtnet_close(struct net_device *dev) | |||
408 | return 0; | 464 | return 0; |
409 | } | 465 | } |
410 | 466 | ||
467 | static int virtnet_set_tx_csum(struct net_device *dev, u32 data) | ||
468 | { | ||
469 | struct virtnet_info *vi = netdev_priv(dev); | ||
470 | struct virtio_device *vdev = vi->vdev; | ||
471 | |||
472 | if (data && !virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) | ||
473 | return -ENOSYS; | ||
474 | |||
475 | return ethtool_op_set_tx_hw_csum(dev, data); | ||
476 | } | ||
477 | |||
478 | static struct ethtool_ops virtnet_ethtool_ops = { | ||
479 | .set_tx_csum = virtnet_set_tx_csum, | ||
480 | .set_sg = ethtool_op_set_sg, | ||
481 | }; | ||
482 | |||
411 | static int virtnet_probe(struct virtio_device *vdev) | 483 | static int virtnet_probe(struct virtio_device *vdev) |
412 | { | 484 | { |
413 | int err; | 485 | int err; |
@@ -427,6 +499,7 @@ static int virtnet_probe(struct virtio_device *vdev) | |||
427 | #ifdef CONFIG_NET_POLL_CONTROLLER | 499 | #ifdef CONFIG_NET_POLL_CONTROLLER |
428 | dev->poll_controller = virtnet_netpoll; | 500 | dev->poll_controller = virtnet_netpoll; |
429 | #endif | 501 | #endif |
502 | SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops); | ||
430 | SET_NETDEV_DEV(dev, &vdev->dev); | 503 | SET_NETDEV_DEV(dev, &vdev->dev); |
431 | 504 | ||
432 | /* Do we support "hardware" checksums? */ | 505 | /* Do we support "hardware" checksums? */ |
@@ -462,11 +535,18 @@ static int virtnet_probe(struct virtio_device *vdev) | |||
462 | vi->dev = dev; | 535 | vi->dev = dev; |
463 | vi->vdev = vdev; | 536 | vi->vdev = vdev; |
464 | vdev->priv = vi; | 537 | vdev->priv = vi; |
538 | vi->pages = NULL; | ||
465 | 539 | ||
466 | /* If they give us a callback when all buffers are done, we don't need | 540 | /* If they give us a callback when all buffers are done, we don't need |
467 | * the timer. */ | 541 | * the timer. */ |
468 | vi->free_in_tasklet = virtio_has_feature(vdev,VIRTIO_F_NOTIFY_ON_EMPTY); | 542 | vi->free_in_tasklet = virtio_has_feature(vdev,VIRTIO_F_NOTIFY_ON_EMPTY); |
469 | 543 | ||
544 | /* If we can receive ANY GSO packets, we must allocate large ones. */ | ||
545 | if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) | ||
546 | || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) | ||
547 | || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN)) | ||
548 | vi->big_packets = true; | ||
549 | |||
470 | /* We expect two virtqueues, receive then send. */ | 550 | /* We expect two virtqueues, receive then send. */ |
471 | vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done); | 551 | vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done); |
472 | if (IS_ERR(vi->rvq)) { | 552 | if (IS_ERR(vi->rvq)) { |
@@ -541,6 +621,10 @@ static void virtnet_remove(struct virtio_device *vdev) | |||
541 | vdev->config->del_vq(vi->svq); | 621 | vdev->config->del_vq(vi->svq); |
542 | vdev->config->del_vq(vi->rvq); | 622 | vdev->config->del_vq(vi->rvq); |
543 | unregister_netdev(vi->dev); | 623 | unregister_netdev(vi->dev); |
624 | |||
625 | while (vi->pages) | ||
626 | __free_pages(get_a_page(vi, GFP_KERNEL), 0); | ||
627 | |||
544 | free_netdev(vi->dev); | 628 | free_netdev(vi->dev); |
545 | } | 629 | } |
546 | 630 | ||
@@ -553,7 +637,9 @@ static unsigned int features[] = { | |||
553 | VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, | 637 | VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, |
554 | VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC, | 638 | VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC, |
555 | VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, | 639 | VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, |
556 | VIRTIO_NET_F_HOST_ECN, VIRTIO_F_NOTIFY_ON_EMPTY, | 640 | VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, |
641 | VIRTIO_NET_F_GUEST_ECN, /* We don't yet handle UFO input. */ | ||
642 | VIRTIO_F_NOTIFY_ON_EMPTY, | ||
557 | }; | 643 | }; |
558 | 644 | ||
559 | static struct virtio_driver virtio_net = { | 645 | static struct virtio_driver virtio_net = { |
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 3a7a11a75fb4..1d7ec3129349 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
@@ -4,7 +4,7 @@ config OF_DEVICE | |||
4 | 4 | ||
5 | config OF_GPIO | 5 | config OF_GPIO |
6 | def_bool y | 6 | def_bool y |
7 | depends on OF && PPC_OF && HAVE_GPIO_LIB | 7 | depends on OF && PPC_OF && GPIOLIB |
8 | help | 8 | help |
9 | OpenFirmware GPIO accessors | 9 | OpenFirmware GPIO accessors |
10 | 10 | ||
diff --git a/drivers/parport/parport_ax88796.c b/drivers/parport/parport_ax88796.c index 4ec220b2eae7..6938d2e9f18f 100644 --- a/drivers/parport/parport_ax88796.c +++ b/drivers/parport/parport_ax88796.c | |||
@@ -406,6 +406,8 @@ static int parport_ax88796_resume(struct platform_device *dev) | |||
406 | #define parport_ax88796_resume NULL | 406 | #define parport_ax88796_resume NULL |
407 | #endif | 407 | #endif |
408 | 408 | ||
409 | MODULE_ALIAS("platform:ax88796-pp"); | ||
410 | |||
409 | static struct platform_driver axdrv = { | 411 | static struct platform_driver axdrv = { |
410 | .driver = { | 412 | .driver = { |
411 | .name = "ax88796-pp", | 413 | .name = "ax88796-pp", |
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c index f941f609dbf3..8bf86ae2333f 100644 --- a/drivers/pci/dmar.c +++ b/drivers/pci/dmar.c | |||
@@ -317,10 +317,8 @@ int __init dmar_table_init(void) | |||
317 | return -ENODEV; | 317 | return -ENODEV; |
318 | } | 318 | } |
319 | 319 | ||
320 | if (list_empty(&dmar_rmrr_units)) { | 320 | if (list_empty(&dmar_rmrr_units)) |
321 | printk(KERN_INFO PREFIX "No RMRR found\n"); | 321 | printk(KERN_INFO PREFIX "No RMRR found\n"); |
322 | return -ENODEV; | ||
323 | } | ||
324 | 322 | ||
325 | return 0; | 323 | return 0; |
326 | } | 324 | } |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d00f0e0d8453..e9c356236d27 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1040,7 +1040,7 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state) | |||
1040 | * @dev: PCI device to handle. | 1040 | * @dev: PCI device to handle. |
1041 | * @state: PCI state from which device will issue PME#. | 1041 | * @state: PCI state from which device will issue PME#. |
1042 | */ | 1042 | */ |
1043 | static bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) | 1043 | bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) |
1044 | { | 1044 | { |
1045 | if (!dev->pm_cap) | 1045 | if (!dev->pm_cap) |
1046 | return false; | 1046 | return false; |
@@ -1123,17 +1123,10 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) | |||
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | /** | 1125 | /** |
1126 | * pci_prepare_to_sleep - prepare PCI device for system-wide transition into a sleep state | ||
1127 | * @dev: Device to handle. | ||
1128 | * | ||
1129 | * Choose the power state appropriate for the device depending on whether | ||
1130 | * it can wake up the system and/or is power manageable by the platform | ||
1131 | * (PCI_D3hot is the default) and put the device into that state. | ||
1132 | */ | 1126 | */ |
1133 | int pci_prepare_to_sleep(struct pci_dev *dev) | 1127 | pci_power_t pci_target_state(struct pci_dev *dev) |
1134 | { | 1128 | { |
1135 | pci_power_t target_state = PCI_D3hot; | 1129 | pci_power_t target_state = PCI_D3hot; |
1136 | int error; | ||
1137 | 1130 | ||
1138 | if (platform_pci_power_manageable(dev)) { | 1131 | if (platform_pci_power_manageable(dev)) { |
1139 | /* | 1132 | /* |
@@ -1160,7 +1153,7 @@ int pci_prepare_to_sleep(struct pci_dev *dev) | |||
1160 | * to generate PME#. | 1153 | * to generate PME#. |
1161 | */ | 1154 | */ |
1162 | if (!dev->pm_cap) | 1155 | if (!dev->pm_cap) |
1163 | return -EIO; | 1156 | return PCI_POWER_ERROR; |
1164 | 1157 | ||
1165 | if (dev->pme_support) { | 1158 | if (dev->pme_support) { |
1166 | while (target_state | 1159 | while (target_state |
@@ -1169,6 +1162,25 @@ int pci_prepare_to_sleep(struct pci_dev *dev) | |||
1169 | } | 1162 | } |
1170 | } | 1163 | } |
1171 | 1164 | ||
1165 | return target_state; | ||
1166 | } | ||
1167 | |||
1168 | /** | ||
1169 | * pci_prepare_to_sleep - prepare PCI device for system-wide transition into a sleep state | ||
1170 | * @dev: Device to handle. | ||
1171 | * | ||
1172 | * Choose the power state appropriate for the device depending on whether | ||
1173 | * it can wake up the system and/or is power manageable by the platform | ||
1174 | * (PCI_D3hot is the default) and put the device into that state. | ||
1175 | */ | ||
1176 | int pci_prepare_to_sleep(struct pci_dev *dev) | ||
1177 | { | ||
1178 | pci_power_t target_state = pci_target_state(dev); | ||
1179 | int error; | ||
1180 | |||
1181 | if (target_state == PCI_POWER_ERROR) | ||
1182 | return -EIO; | ||
1183 | |||
1172 | pci_enable_wake(dev, target_state, true); | 1184 | pci_enable_wake(dev, target_state, true); |
1173 | 1185 | ||
1174 | error = pci_set_power_state(dev, target_state); | 1186 | error = pci_set_power_state(dev, target_state); |
@@ -1918,7 +1930,9 @@ EXPORT_SYMBOL(pci_select_bars); | |||
1918 | EXPORT_SYMBOL(pci_set_power_state); | 1930 | EXPORT_SYMBOL(pci_set_power_state); |
1919 | EXPORT_SYMBOL(pci_save_state); | 1931 | EXPORT_SYMBOL(pci_save_state); |
1920 | EXPORT_SYMBOL(pci_restore_state); | 1932 | EXPORT_SYMBOL(pci_restore_state); |
1933 | EXPORT_SYMBOL(pci_pme_capable); | ||
1921 | EXPORT_SYMBOL(pci_enable_wake); | 1934 | EXPORT_SYMBOL(pci_enable_wake); |
1935 | EXPORT_SYMBOL(pci_target_state); | ||
1922 | EXPORT_SYMBOL(pci_prepare_to_sleep); | 1936 | EXPORT_SYMBOL(pci_prepare_to_sleep); |
1923 | EXPORT_SYMBOL(pci_back_from_sleep); | 1937 | EXPORT_SYMBOL(pci_back_from_sleep); |
1924 | EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state); | 1938 | EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state); |
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 4400dffbd93a..e1098c302c45 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c | |||
@@ -88,7 +88,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp | |||
88 | if ((pos & 3) && cnt > 2) { | 88 | if ((pos & 3) && cnt > 2) { |
89 | unsigned short val; | 89 | unsigned short val; |
90 | pci_user_read_config_word(dev, pos, &val); | 90 | pci_user_read_config_word(dev, pos, &val); |
91 | __put_user(cpu_to_le16(val), (unsigned short __user *) buf); | 91 | __put_user(cpu_to_le16(val), (__le16 __user *) buf); |
92 | buf += 2; | 92 | buf += 2; |
93 | pos += 2; | 93 | pos += 2; |
94 | cnt -= 2; | 94 | cnt -= 2; |
@@ -97,7 +97,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp | |||
97 | while (cnt >= 4) { | 97 | while (cnt >= 4) { |
98 | unsigned int val; | 98 | unsigned int val; |
99 | pci_user_read_config_dword(dev, pos, &val); | 99 | pci_user_read_config_dword(dev, pos, &val); |
100 | __put_user(cpu_to_le32(val), (unsigned int __user *) buf); | 100 | __put_user(cpu_to_le32(val), (__le32 __user *) buf); |
101 | buf += 4; | 101 | buf += 4; |
102 | pos += 4; | 102 | pos += 4; |
103 | cnt -= 4; | 103 | cnt -= 4; |
@@ -106,7 +106,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp | |||
106 | if (cnt >= 2) { | 106 | if (cnt >= 2) { |
107 | unsigned short val; | 107 | unsigned short val; |
108 | pci_user_read_config_word(dev, pos, &val); | 108 | pci_user_read_config_word(dev, pos, &val); |
109 | __put_user(cpu_to_le16(val), (unsigned short __user *) buf); | 109 | __put_user(cpu_to_le16(val), (__le16 __user *) buf); |
110 | buf += 2; | 110 | buf += 2; |
111 | pos += 2; | 111 | pos += 2; |
112 | cnt -= 2; | 112 | cnt -= 2; |
@@ -156,8 +156,8 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof | |||
156 | } | 156 | } |
157 | 157 | ||
158 | if ((pos & 3) && cnt > 2) { | 158 | if ((pos & 3) && cnt > 2) { |
159 | unsigned short val; | 159 | __le16 val; |
160 | __get_user(val, (unsigned short __user *) buf); | 160 | __get_user(val, (__le16 __user *) buf); |
161 | pci_user_write_config_word(dev, pos, le16_to_cpu(val)); | 161 | pci_user_write_config_word(dev, pos, le16_to_cpu(val)); |
162 | buf += 2; | 162 | buf += 2; |
163 | pos += 2; | 163 | pos += 2; |
@@ -165,8 +165,8 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof | |||
165 | } | 165 | } |
166 | 166 | ||
167 | while (cnt >= 4) { | 167 | while (cnt >= 4) { |
168 | unsigned int val; | 168 | __le32 val; |
169 | __get_user(val, (unsigned int __user *) buf); | 169 | __get_user(val, (__le32 __user *) buf); |
170 | pci_user_write_config_dword(dev, pos, le32_to_cpu(val)); | 170 | pci_user_write_config_dword(dev, pos, le32_to_cpu(val)); |
171 | buf += 4; | 171 | buf += 4; |
172 | pos += 4; | 172 | pos += 4; |
@@ -174,8 +174,8 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof | |||
174 | } | 174 | } |
175 | 175 | ||
176 | if (cnt >= 2) { | 176 | if (cnt >= 2) { |
177 | unsigned short val; | 177 | __le16 val; |
178 | __get_user(val, (unsigned short __user *) buf); | 178 | __get_user(val, (__le16 __user *) buf); |
179 | pci_user_write_config_word(dev, pos, le16_to_cpu(val)); | 179 | pci_user_write_config_word(dev, pos, le16_to_cpu(val)); |
180 | buf += 2; | 180 | buf += 2; |
181 | pos += 2; | 181 | pos += 2; |
diff --git a/drivers/pcmcia/electra_cf.c b/drivers/pcmcia/electra_cf.c index c21f9a9c3e3f..a34284b1482a 100644 --- a/drivers/pcmcia/electra_cf.c +++ b/drivers/pcmcia/electra_cf.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/mm.h> | ||
31 | #include <linux/vmalloc.h> | 32 | #include <linux/vmalloc.h> |
32 | #include <linux/of_platform.h> | 33 | #include <linux/of_platform.h> |
33 | 34 | ||
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c index 71be36f18709..308ddb201b66 100644 --- a/drivers/power/ds2760_battery.c +++ b/drivers/power/ds2760_battery.c | |||
@@ -433,6 +433,8 @@ static int ds2760_battery_resume(struct platform_device *pdev) | |||
433 | 433 | ||
434 | #endif /* CONFIG_PM */ | 434 | #endif /* CONFIG_PM */ |
435 | 435 | ||
436 | MODULE_ALIAS("platform:ds2760-battery"); | ||
437 | |||
436 | static struct platform_driver ds2760_battery_driver = { | 438 | static struct platform_driver ds2760_battery_driver = { |
437 | .driver = { | 439 | .driver = { |
438 | .name = "ds2760-battery", | 440 | .name = "ds2760-battery", |
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c index 82810b7bff9c..0471ec743ab9 100644 --- a/drivers/power/pda_power.c +++ b/drivers/power/pda_power.c | |||
@@ -362,6 +362,8 @@ static int pda_power_resume(struct platform_device *pdev) | |||
362 | #define pda_power_resume NULL | 362 | #define pda_power_resume NULL |
363 | #endif /* CONFIG_PM */ | 363 | #endif /* CONFIG_PM */ |
364 | 364 | ||
365 | MODULE_ALIAS("platform:pda-power"); | ||
366 | |||
365 | static struct platform_driver pda_power_pdrv = { | 367 | static struct platform_driver pda_power_pdrv = { |
366 | .driver = { | 368 | .driver = { |
367 | .name = "pda-power", | 369 | .name = "pda-power", |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index fc85bf2e4a97..90ab73825401 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -273,6 +273,25 @@ comment "SPI RTC drivers" | |||
273 | 273 | ||
274 | if SPI_MASTER | 274 | if SPI_MASTER |
275 | 275 | ||
276 | config RTC_DRV_M41T94 | ||
277 | tristate "ST M41T94" | ||
278 | help | ||
279 | If you say yes here you will get support for the | ||
280 | ST M41T94 SPI RTC chip. | ||
281 | |||
282 | This driver can also be built as a module. If so, the module | ||
283 | will be called rtc-m41t94. | ||
284 | |||
285 | config RTC_DRV_DS1305 | ||
286 | tristate "Dallas/Maxim DS1305/DS1306" | ||
287 | help | ||
288 | Select this driver to get support for the Dallas/Maxim DS1305 | ||
289 | and DS1306 real time clock chips. These support a trickle | ||
290 | charger, alarms, and NVRAM in addition to the clock. | ||
291 | |||
292 | This driver can also be built as a module. If so, the module | ||
293 | will be called rtc-ds1305. | ||
294 | |||
276 | config RTC_DRV_MAX6902 | 295 | config RTC_DRV_MAX6902 |
277 | tristate "Maxim MAX6902" | 296 | tristate "Maxim MAX6902" |
278 | help | 297 | help |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index b5d9d67df887..18622ef84cab 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -24,6 +24,7 @@ obj-$(CONFIG_RTC_DRV_BFIN) += rtc-bfin.o | |||
24 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o | 24 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o |
25 | obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o | 25 | obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o |
26 | obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o | 26 | obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o |
27 | obj-$(CONFIG_RTC_DRV_DS1305) += rtc-ds1305.o | ||
27 | obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o | 28 | obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o |
28 | obj-$(CONFIG_RTC_DRV_DS1374) += rtc-ds1374.o | 29 | obj-$(CONFIG_RTC_DRV_DS1374) += rtc-ds1374.o |
29 | obj-$(CONFIG_RTC_DRV_DS1511) += rtc-ds1511.o | 30 | obj-$(CONFIG_RTC_DRV_DS1511) += rtc-ds1511.o |
@@ -34,6 +35,7 @@ obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o | |||
34 | obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o | 35 | obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o |
35 | obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o | 36 | obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o |
36 | obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o | 37 | obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o |
38 | obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o | ||
37 | obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o | 39 | obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o |
38 | obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o | 40 | obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o |
39 | obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o | 41 | obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 9c3db934cc24..cd32d05db773 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -171,8 +171,10 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
171 | | BIN2BCD(tm.tm_mday) << 24 | 171 | | BIN2BCD(tm.tm_mday) << 24 |
172 | | AT91_RTC_DATEEN | AT91_RTC_MTHEN); | 172 | | AT91_RTC_DATEEN | AT91_RTC_MTHEN); |
173 | 173 | ||
174 | if (alrm->enabled) | 174 | if (alrm->enabled) { |
175 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_ALARM); | ||
175 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); | 176 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); |
177 | } | ||
176 | 178 | ||
177 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, | 179 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, |
178 | at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, | 180 | at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, |
@@ -191,28 +193,22 @@ static int at91_rtc_ioctl(struct device *dev, unsigned int cmd, | |||
191 | 193 | ||
192 | pr_debug("%s(): cmd=%08x, arg=%08lx.\n", __func__, cmd, arg); | 194 | pr_debug("%s(): cmd=%08x, arg=%08lx.\n", __func__, cmd, arg); |
193 | 195 | ||
196 | /* important: scrub old status before enabling IRQs */ | ||
194 | switch (cmd) { | 197 | switch (cmd) { |
195 | case RTC_AIE_OFF: /* alarm off */ | 198 | case RTC_AIE_OFF: /* alarm off */ |
196 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); | 199 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); |
197 | break; | 200 | break; |
198 | case RTC_AIE_ON: /* alarm on */ | 201 | case RTC_AIE_ON: /* alarm on */ |
202 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_ALARM); | ||
199 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); | 203 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); |
200 | break; | 204 | break; |
201 | case RTC_UIE_OFF: /* update off */ | 205 | case RTC_UIE_OFF: /* update off */ |
202 | case RTC_PIE_OFF: /* periodic off */ | ||
203 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_SECEV); | 206 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_SECEV); |
204 | break; | 207 | break; |
205 | case RTC_UIE_ON: /* update on */ | 208 | case RTC_UIE_ON: /* update on */ |
206 | case RTC_PIE_ON: /* periodic on */ | 209 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_SECEV); |
207 | at91_sys_write(AT91_RTC_IER, AT91_RTC_SECEV); | 210 | at91_sys_write(AT91_RTC_IER, AT91_RTC_SECEV); |
208 | break; | 211 | break; |
209 | case RTC_IRQP_READ: /* read periodic alarm frequency */ | ||
210 | ret = put_user(AT91_RTC_FREQ, (unsigned long *) arg); | ||
211 | break; | ||
212 | case RTC_IRQP_SET: /* set periodic alarm frequency */ | ||
213 | if (arg != AT91_RTC_FREQ) | ||
214 | ret = -EINVAL; | ||
215 | break; | ||
216 | default: | 212 | default: |
217 | ret = -ENOIOCTLCMD; | 213 | ret = -ENOIOCTLCMD; |
218 | break; | 214 | break; |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index d7bb9bac71df..6ea349aba3ba 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -36,25 +36,9 @@ | |||
36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/mod_devicetable.h> | 37 | #include <linux/mod_devicetable.h> |
38 | 38 | ||
39 | #ifdef CONFIG_HPET_EMULATE_RTC | ||
40 | #include <asm/hpet.h> | ||
41 | #endif | ||
42 | |||
43 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ | 39 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ |
44 | #include <asm-generic/rtc.h> | 40 | #include <asm-generic/rtc.h> |
45 | 41 | ||
46 | #ifndef CONFIG_HPET_EMULATE_RTC | ||
47 | #define is_hpet_enabled() 0 | ||
48 | #define hpet_set_alarm_time(hrs, min, sec) do { } while (0) | ||
49 | #define hpet_set_periodic_freq(arg) 0 | ||
50 | #define hpet_mask_rtc_irq_bit(arg) do { } while (0) | ||
51 | #define hpet_set_rtc_irq_bit(arg) do { } while (0) | ||
52 | #define hpet_rtc_timer_init() do { } while (0) | ||
53 | #define hpet_register_irq_handler(h) 0 | ||
54 | #define hpet_unregister_irq_handler(h) do { } while (0) | ||
55 | extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); | ||
56 | #endif | ||
57 | |||
58 | struct cmos_rtc { | 42 | struct cmos_rtc { |
59 | struct rtc_device *rtc; | 43 | struct rtc_device *rtc; |
60 | struct device *dev; | 44 | struct device *dev; |
@@ -93,6 +77,72 @@ static inline int is_intr(u8 rtc_intr) | |||
93 | 77 | ||
94 | /*----------------------------------------------------------------*/ | 78 | /*----------------------------------------------------------------*/ |
95 | 79 | ||
80 | /* Much modern x86 hardware has HPETs (10+ MHz timers) which, because | ||
81 | * many BIOS programmers don't set up "sane mode" IRQ routing, are mostly | ||
82 | * used in a broken "legacy replacement" mode. The breakage includes | ||
83 | * HPET #1 hijacking the IRQ for this RTC, and being unavailable for | ||
84 | * other (better) use. | ||
85 | * | ||
86 | * When that broken mode is in use, platform glue provides a partial | ||
87 | * emulation of hardware RTC IRQ facilities using HPET #1. We don't | ||
88 | * want to use HPET for anything except those IRQs though... | ||
89 | */ | ||
90 | #ifdef CONFIG_HPET_EMULATE_RTC | ||
91 | #include <asm/hpet.h> | ||
92 | #else | ||
93 | |||
94 | static inline int is_hpet_enabled(void) | ||
95 | { | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static inline int hpet_mask_rtc_irq_bit(unsigned long mask) | ||
100 | { | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static inline int hpet_set_rtc_irq_bit(unsigned long mask) | ||
105 | { | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static inline int | ||
110 | hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec) | ||
111 | { | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | static inline int hpet_set_periodic_freq(unsigned long freq) | ||
116 | { | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static inline int hpet_rtc_dropped_irq(void) | ||
121 | { | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | static inline int hpet_rtc_timer_init(void) | ||
126 | { | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | extern irq_handler_t hpet_rtc_interrupt; | ||
131 | |||
132 | static inline int hpet_register_irq_handler(irq_handler_t handler) | ||
133 | { | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static inline int hpet_unregister_irq_handler(irq_handler_t handler) | ||
138 | { | ||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | #endif | ||
143 | |||
144 | /*----------------------------------------------------------------*/ | ||
145 | |||
96 | static int cmos_read_time(struct device *dev, struct rtc_time *t) | 146 | static int cmos_read_time(struct device *dev, struct rtc_time *t) |
97 | { | 147 | { |
98 | /* REVISIT: if the clock has a "century" register, use | 148 | /* REVISIT: if the clock has a "century" register, use |
@@ -185,11 +235,56 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
185 | return 0; | 235 | return 0; |
186 | } | 236 | } |
187 | 237 | ||
238 | static void cmos_checkintr(struct cmos_rtc *cmos, unsigned char rtc_control) | ||
239 | { | ||
240 | unsigned char rtc_intr; | ||
241 | |||
242 | /* NOTE after changing RTC_xIE bits we always read INTR_FLAGS; | ||
243 | * allegedly some older rtcs need that to handle irqs properly | ||
244 | */ | ||
245 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | ||
246 | |||
247 | if (is_hpet_enabled()) | ||
248 | return; | ||
249 | |||
250 | rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | ||
251 | if (is_intr(rtc_intr)) | ||
252 | rtc_update_irq(cmos->rtc, 1, rtc_intr); | ||
253 | } | ||
254 | |||
255 | static void cmos_irq_enable(struct cmos_rtc *cmos, unsigned char mask) | ||
256 | { | ||
257 | unsigned char rtc_control; | ||
258 | |||
259 | /* flush any pending IRQ status, notably for update irqs, | ||
260 | * before we enable new IRQs | ||
261 | */ | ||
262 | rtc_control = CMOS_READ(RTC_CONTROL); | ||
263 | cmos_checkintr(cmos, rtc_control); | ||
264 | |||
265 | rtc_control |= mask; | ||
266 | CMOS_WRITE(rtc_control, RTC_CONTROL); | ||
267 | hpet_set_rtc_irq_bit(mask); | ||
268 | |||
269 | cmos_checkintr(cmos, rtc_control); | ||
270 | } | ||
271 | |||
272 | static void cmos_irq_disable(struct cmos_rtc *cmos, unsigned char mask) | ||
273 | { | ||
274 | unsigned char rtc_control; | ||
275 | |||
276 | rtc_control = CMOS_READ(RTC_CONTROL); | ||
277 | rtc_control &= ~mask; | ||
278 | CMOS_WRITE(rtc_control, RTC_CONTROL); | ||
279 | hpet_mask_rtc_irq_bit(mask); | ||
280 | |||
281 | cmos_checkintr(cmos, rtc_control); | ||
282 | } | ||
283 | |||
188 | static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | 284 | static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) |
189 | { | 285 | { |
190 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 286 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
191 | unsigned char mon, mday, hrs, min, sec; | 287 | unsigned char mon, mday, hrs, min, sec; |
192 | unsigned char rtc_control, rtc_intr; | ||
193 | 288 | ||
194 | if (!is_valid_irq(cmos->irq)) | 289 | if (!is_valid_irq(cmos->irq)) |
195 | return -EIO; | 290 | return -EIO; |
@@ -213,17 +308,10 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
213 | sec = t->time.tm_sec; | 308 | sec = t->time.tm_sec; |
214 | sec = (sec < 60) ? BIN2BCD(sec) : 0xff; | 309 | sec = (sec < 60) ? BIN2BCD(sec) : 0xff; |
215 | 310 | ||
216 | hpet_set_alarm_time(t->time.tm_hour, t->time.tm_min, t->time.tm_sec); | ||
217 | spin_lock_irq(&rtc_lock); | 311 | spin_lock_irq(&rtc_lock); |
218 | 312 | ||
219 | /* next rtc irq must not be from previous alarm setting */ | 313 | /* next rtc irq must not be from previous alarm setting */ |
220 | rtc_control = CMOS_READ(RTC_CONTROL); | 314 | cmos_irq_disable(cmos, RTC_AIE); |
221 | rtc_control &= ~RTC_AIE; | ||
222 | CMOS_WRITE(rtc_control, RTC_CONTROL); | ||
223 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | ||
224 | rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | ||
225 | if (is_intr(rtc_intr)) | ||
226 | rtc_update_irq(cmos->rtc, 1, rtc_intr); | ||
227 | 315 | ||
228 | /* update alarm */ | 316 | /* update alarm */ |
229 | CMOS_WRITE(hrs, RTC_HOURS_ALARM); | 317 | CMOS_WRITE(hrs, RTC_HOURS_ALARM); |
@@ -237,14 +325,13 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
237 | CMOS_WRITE(mon, cmos->mon_alrm); | 325 | CMOS_WRITE(mon, cmos->mon_alrm); |
238 | } | 326 | } |
239 | 327 | ||
240 | if (t->enabled) { | 328 | /* FIXME the HPET alarm glue currently ignores day_alrm |
241 | rtc_control |= RTC_AIE; | 329 | * and mon_alrm ... |
242 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 330 | */ |
243 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | 331 | hpet_set_alarm_time(t->time.tm_hour, t->time.tm_min, t->time.tm_sec); |
244 | rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | 332 | |
245 | if (is_intr(rtc_intr)) | 333 | if (t->enabled) |
246 | rtc_update_irq(cmos->rtc, 1, rtc_intr); | 334 | cmos_irq_enable(cmos, RTC_AIE); |
247 | } | ||
248 | 335 | ||
249 | spin_unlock_irq(&rtc_lock); | 336 | spin_unlock_irq(&rtc_lock); |
250 | 337 | ||
@@ -267,8 +354,8 @@ static int cmos_irq_set_freq(struct device *dev, int freq) | |||
267 | f = 16 - f; | 354 | f = 16 - f; |
268 | 355 | ||
269 | spin_lock_irqsave(&rtc_lock, flags); | 356 | spin_lock_irqsave(&rtc_lock, flags); |
270 | if (!hpet_set_periodic_freq(freq)) | 357 | hpet_set_periodic_freq(freq); |
271 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT); | 358 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT); |
272 | spin_unlock_irqrestore(&rtc_lock, flags); | 359 | spin_unlock_irqrestore(&rtc_lock, flags); |
273 | 360 | ||
274 | return 0; | 361 | return 0; |
@@ -277,26 +364,17 @@ static int cmos_irq_set_freq(struct device *dev, int freq) | |||
277 | static int cmos_irq_set_state(struct device *dev, int enabled) | 364 | static int cmos_irq_set_state(struct device *dev, int enabled) |
278 | { | 365 | { |
279 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 366 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
280 | unsigned char rtc_control, rtc_intr; | ||
281 | unsigned long flags; | 367 | unsigned long flags; |
282 | 368 | ||
283 | if (!is_valid_irq(cmos->irq)) | 369 | if (!is_valid_irq(cmos->irq)) |
284 | return -ENXIO; | 370 | return -ENXIO; |
285 | 371 | ||
286 | spin_lock_irqsave(&rtc_lock, flags); | 372 | spin_lock_irqsave(&rtc_lock, flags); |
287 | rtc_control = CMOS_READ(RTC_CONTROL); | ||
288 | 373 | ||
289 | if (enabled) | 374 | if (enabled) |
290 | rtc_control |= RTC_PIE; | 375 | cmos_irq_enable(cmos, RTC_PIE); |
291 | else | 376 | else |
292 | rtc_control &= ~RTC_PIE; | 377 | cmos_irq_disable(cmos, RTC_PIE); |
293 | |||
294 | CMOS_WRITE(rtc_control, RTC_CONTROL); | ||
295 | |||
296 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | ||
297 | rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | ||
298 | if (is_intr(rtc_intr)) | ||
299 | rtc_update_irq(cmos->rtc, 1, rtc_intr); | ||
300 | 378 | ||
301 | spin_unlock_irqrestore(&rtc_lock, flags); | 379 | spin_unlock_irqrestore(&rtc_lock, flags); |
302 | return 0; | 380 | return 0; |
@@ -308,7 +386,6 @@ static int | |||
308 | cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 386 | cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) |
309 | { | 387 | { |
310 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 388 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
311 | unsigned char rtc_control, rtc_intr; | ||
312 | unsigned long flags; | 389 | unsigned long flags; |
313 | 390 | ||
314 | switch (cmd) { | 391 | switch (cmd) { |
@@ -316,51 +393,29 @@ cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
316 | case RTC_AIE_ON: | 393 | case RTC_AIE_ON: |
317 | case RTC_UIE_OFF: | 394 | case RTC_UIE_OFF: |
318 | case RTC_UIE_ON: | 395 | case RTC_UIE_ON: |
319 | case RTC_PIE_OFF: | ||
320 | case RTC_PIE_ON: | ||
321 | if (!is_valid_irq(cmos->irq)) | 396 | if (!is_valid_irq(cmos->irq)) |
322 | return -EINVAL; | 397 | return -EINVAL; |
323 | break; | 398 | break; |
399 | /* PIE ON/OFF is handled by cmos_irq_set_state() */ | ||
324 | default: | 400 | default: |
325 | return -ENOIOCTLCMD; | 401 | return -ENOIOCTLCMD; |
326 | } | 402 | } |
327 | 403 | ||
328 | spin_lock_irqsave(&rtc_lock, flags); | 404 | spin_lock_irqsave(&rtc_lock, flags); |
329 | rtc_control = CMOS_READ(RTC_CONTROL); | ||
330 | switch (cmd) { | 405 | switch (cmd) { |
331 | case RTC_AIE_OFF: /* alarm off */ | 406 | case RTC_AIE_OFF: /* alarm off */ |
332 | rtc_control &= ~RTC_AIE; | 407 | cmos_irq_disable(cmos, RTC_AIE); |
333 | hpet_mask_rtc_irq_bit(RTC_AIE); | ||
334 | break; | 408 | break; |
335 | case RTC_AIE_ON: /* alarm on */ | 409 | case RTC_AIE_ON: /* alarm on */ |
336 | rtc_control |= RTC_AIE; | 410 | cmos_irq_enable(cmos, RTC_AIE); |
337 | hpet_set_rtc_irq_bit(RTC_AIE); | ||
338 | break; | 411 | break; |
339 | case RTC_UIE_OFF: /* update off */ | 412 | case RTC_UIE_OFF: /* update off */ |
340 | rtc_control &= ~RTC_UIE; | 413 | cmos_irq_disable(cmos, RTC_UIE); |
341 | hpet_mask_rtc_irq_bit(RTC_UIE); | ||
342 | break; | 414 | break; |
343 | case RTC_UIE_ON: /* update on */ | 415 | case RTC_UIE_ON: /* update on */ |
344 | rtc_control |= RTC_UIE; | 416 | cmos_irq_enable(cmos, RTC_UIE); |
345 | hpet_set_rtc_irq_bit(RTC_UIE); | ||
346 | break; | ||
347 | case RTC_PIE_OFF: /* periodic off */ | ||
348 | rtc_control &= ~RTC_PIE; | ||
349 | hpet_mask_rtc_irq_bit(RTC_PIE); | ||
350 | break; | ||
351 | case RTC_PIE_ON: /* periodic on */ | ||
352 | rtc_control |= RTC_PIE; | ||
353 | hpet_set_rtc_irq_bit(RTC_PIE); | ||
354 | break; | 417 | break; |
355 | } | 418 | } |
356 | if (!is_hpet_enabled()) | ||
357 | CMOS_WRITE(rtc_control, RTC_CONTROL); | ||
358 | |||
359 | rtc_intr = CMOS_READ(RTC_INTR_FLAGS); | ||
360 | rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | ||
361 | if (is_intr(rtc_intr)) | ||
362 | rtc_update_irq(cmos->rtc, 1, rtc_intr); | ||
363 | |||
364 | spin_unlock_irqrestore(&rtc_lock, flags); | 419 | spin_unlock_irqrestore(&rtc_lock, flags); |
365 | return 0; | 420 | return 0; |
366 | } | 421 | } |
@@ -502,27 +557,29 @@ static irqreturn_t cmos_interrupt(int irq, void *p) | |||
502 | u8 rtc_control; | 557 | u8 rtc_control; |
503 | 558 | ||
504 | spin_lock(&rtc_lock); | 559 | spin_lock(&rtc_lock); |
505 | /* | 560 | |
506 | * In this case it is HPET RTC interrupt handler | 561 | /* When the HPET interrupt handler calls us, the interrupt |
507 | * calling us, with the interrupt information | 562 | * status is passed as arg1 instead of the irq number. But |
508 | * passed as arg1, instead of irq. | 563 | * always clear irq status, even when HPET is in the way. |
564 | * | ||
565 | * Note that HPET and RTC are almost certainly out of phase, | ||
566 | * giving different IRQ status ... | ||
509 | */ | 567 | */ |
568 | irqstat = CMOS_READ(RTC_INTR_FLAGS); | ||
569 | rtc_control = CMOS_READ(RTC_CONTROL); | ||
510 | if (is_hpet_enabled()) | 570 | if (is_hpet_enabled()) |
511 | irqstat = (unsigned long)irq & 0xF0; | 571 | irqstat = (unsigned long)irq & 0xF0; |
512 | else { | 572 | irqstat &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; |
513 | irqstat = CMOS_READ(RTC_INTR_FLAGS); | ||
514 | rtc_control = CMOS_READ(RTC_CONTROL); | ||
515 | irqstat &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | ||
516 | } | ||
517 | 573 | ||
518 | /* All Linux RTC alarms should be treated as if they were oneshot. | 574 | /* All Linux RTC alarms should be treated as if they were oneshot. |
519 | * Similar code may be needed in system wakeup paths, in case the | 575 | * Similar code may be needed in system wakeup paths, in case the |
520 | * alarm woke the system. | 576 | * alarm woke the system. |
521 | */ | 577 | */ |
522 | if (irqstat & RTC_AIE) { | 578 | if (irqstat & RTC_AIE) { |
523 | rtc_control = CMOS_READ(RTC_CONTROL); | ||
524 | rtc_control &= ~RTC_AIE; | 579 | rtc_control &= ~RTC_AIE; |
525 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 580 | CMOS_WRITE(rtc_control, RTC_CONTROL); |
581 | hpet_mask_rtc_irq_bit(RTC_AIE); | ||
582 | |||
526 | CMOS_READ(RTC_INTR_FLAGS); | 583 | CMOS_READ(RTC_INTR_FLAGS); |
527 | } | 584 | } |
528 | spin_unlock(&rtc_lock); | 585 | spin_unlock(&rtc_lock); |
@@ -629,18 +686,13 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
629 | * do something about other clock frequencies. | 686 | * do something about other clock frequencies. |
630 | */ | 687 | */ |
631 | cmos_rtc.rtc->irq_freq = 1024; | 688 | cmos_rtc.rtc->irq_freq = 1024; |
632 | if (!hpet_set_periodic_freq(cmos_rtc.rtc->irq_freq)) | 689 | hpet_set_periodic_freq(cmos_rtc.rtc->irq_freq); |
633 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT); | 690 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT); |
691 | |||
692 | /* disable irqs */ | ||
693 | cmos_irq_disable(&cmos_rtc, RTC_PIE | RTC_AIE | RTC_UIE); | ||
634 | 694 | ||
635 | /* disable irqs. | ||
636 | * | ||
637 | * NOTE after changing RTC_xIE bits we always read INTR_FLAGS; | ||
638 | * allegedly some older rtcs need that to handle irqs properly | ||
639 | */ | ||
640 | rtc_control = CMOS_READ(RTC_CONTROL); | 695 | rtc_control = CMOS_READ(RTC_CONTROL); |
641 | rtc_control &= ~(RTC_PIE | RTC_AIE | RTC_UIE); | ||
642 | CMOS_WRITE(rtc_control, RTC_CONTROL); | ||
643 | CMOS_READ(RTC_INTR_FLAGS); | ||
644 | 696 | ||
645 | spin_unlock_irq(&rtc_lock); | 697 | spin_unlock_irq(&rtc_lock); |
646 | 698 | ||
@@ -687,7 +739,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
687 | goto cleanup2; | 739 | goto cleanup2; |
688 | } | 740 | } |
689 | 741 | ||
690 | pr_info("%s: alarms up to one %s%s\n", | 742 | pr_info("%s: alarms up to one %s%s%s\n", |
691 | cmos_rtc.rtc->dev.bus_id, | 743 | cmos_rtc.rtc->dev.bus_id, |
692 | is_valid_irq(rtc_irq) | 744 | is_valid_irq(rtc_irq) |
693 | ? (cmos_rtc.mon_alrm | 745 | ? (cmos_rtc.mon_alrm |
@@ -695,8 +747,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
695 | : (cmos_rtc.day_alrm | 747 | : (cmos_rtc.day_alrm |
696 | ? "month" : "day")) | 748 | ? "month" : "day")) |
697 | : "no", | 749 | : "no", |
698 | cmos_rtc.century ? ", y3k" : "" | 750 | cmos_rtc.century ? ", y3k" : "", |
699 | ); | 751 | is_hpet_enabled() ? ", hpet irqs" : ""); |
700 | 752 | ||
701 | return 0; | 753 | return 0; |
702 | 754 | ||
@@ -713,13 +765,8 @@ cleanup0: | |||
713 | 765 | ||
714 | static void cmos_do_shutdown(void) | 766 | static void cmos_do_shutdown(void) |
715 | { | 767 | { |
716 | unsigned char rtc_control; | ||
717 | |||
718 | spin_lock_irq(&rtc_lock); | 768 | spin_lock_irq(&rtc_lock); |
719 | rtc_control = CMOS_READ(RTC_CONTROL); | 769 | cmos_irq_disable(&cmos_rtc, RTC_IRQMASK); |
720 | rtc_control &= ~(RTC_PIE|RTC_AIE|RTC_UIE); | ||
721 | CMOS_WRITE(rtc_control, RTC_CONTROL); | ||
722 | CMOS_READ(RTC_INTR_FLAGS); | ||
723 | spin_unlock_irq(&rtc_lock); | 770 | spin_unlock_irq(&rtc_lock); |
724 | } | 771 | } |
725 | 772 | ||
@@ -760,17 +807,17 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg) | |||
760 | spin_lock_irq(&rtc_lock); | 807 | spin_lock_irq(&rtc_lock); |
761 | cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL); | 808 | cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL); |
762 | if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) { | 809 | if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) { |
763 | unsigned char irqstat; | 810 | unsigned char mask; |
764 | 811 | ||
765 | if (do_wake) | 812 | if (do_wake) |
766 | tmp &= ~(RTC_PIE|RTC_UIE); | 813 | mask = RTC_IRQMASK & ~RTC_AIE; |
767 | else | 814 | else |
768 | tmp &= ~(RTC_PIE|RTC_AIE|RTC_UIE); | 815 | mask = RTC_IRQMASK; |
816 | tmp &= ~mask; | ||
769 | CMOS_WRITE(tmp, RTC_CONTROL); | 817 | CMOS_WRITE(tmp, RTC_CONTROL); |
770 | irqstat = CMOS_READ(RTC_INTR_FLAGS); | 818 | hpet_mask_rtc_irq_bit(mask); |
771 | irqstat &= (tmp & RTC_IRQMASK) | RTC_IRQF; | 819 | |
772 | if (is_intr(irqstat)) | 820 | cmos_checkintr(cmos, tmp); |
773 | rtc_update_irq(cmos->rtc, 1, irqstat); | ||
774 | } | 821 | } |
775 | spin_unlock_irq(&rtc_lock); | 822 | spin_unlock_irq(&rtc_lock); |
776 | 823 | ||
@@ -796,7 +843,8 @@ static int cmos_resume(struct device *dev) | |||
796 | unsigned char tmp = cmos->suspend_ctrl; | 843 | unsigned char tmp = cmos->suspend_ctrl; |
797 | 844 | ||
798 | /* re-enable any irqs previously active */ | 845 | /* re-enable any irqs previously active */ |
799 | if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) { | 846 | if (tmp & RTC_IRQMASK) { |
847 | unsigned char mask; | ||
800 | 848 | ||
801 | if (cmos->enabled_wake) { | 849 | if (cmos->enabled_wake) { |
802 | if (cmos->wake_off) | 850 | if (cmos->wake_off) |
@@ -807,18 +855,28 @@ static int cmos_resume(struct device *dev) | |||
807 | } | 855 | } |
808 | 856 | ||
809 | spin_lock_irq(&rtc_lock); | 857 | spin_lock_irq(&rtc_lock); |
810 | CMOS_WRITE(tmp, RTC_CONTROL); | 858 | do { |
811 | tmp = CMOS_READ(RTC_INTR_FLAGS); | 859 | CMOS_WRITE(tmp, RTC_CONTROL); |
812 | tmp &= (cmos->suspend_ctrl & RTC_IRQMASK) | RTC_IRQF; | 860 | hpet_set_rtc_irq_bit(tmp & RTC_IRQMASK); |
813 | if (is_intr(tmp)) | 861 | |
814 | rtc_update_irq(cmos->rtc, 1, tmp); | 862 | mask = CMOS_READ(RTC_INTR_FLAGS); |
863 | mask &= (tmp & RTC_IRQMASK) | RTC_IRQF; | ||
864 | if (!is_hpet_enabled() || !is_intr(mask)) | ||
865 | break; | ||
866 | |||
867 | /* force one-shot behavior if HPET blocked | ||
868 | * the wake alarm's irq | ||
869 | */ | ||
870 | rtc_update_irq(cmos->rtc, 1, mask); | ||
871 | tmp &= ~RTC_AIE; | ||
872 | hpet_mask_rtc_irq_bit(RTC_AIE); | ||
873 | } while (mask & RTC_AIE); | ||
815 | spin_unlock_irq(&rtc_lock); | 874 | spin_unlock_irq(&rtc_lock); |
816 | } | 875 | } |
817 | 876 | ||
818 | pr_debug("%s: resume, ctrl %02x\n", | 877 | pr_debug("%s: resume, ctrl %02x\n", |
819 | cmos_rtc.rtc->dev.bus_id, | 878 | cmos_rtc.rtc->dev.bus_id, |
820 | cmos->suspend_ctrl); | 879 | tmp); |
821 | |||
822 | 880 | ||
823 | return 0; | 881 | return 0; |
824 | } | 882 | } |
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 0114a78b7cbb..0a870b7e5c32 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -209,7 +209,7 @@ static unsigned int rtc_dev_poll(struct file *file, poll_table *wait) | |||
209 | return (data != 0) ? (POLLIN | POLLRDNORM) : 0; | 209 | return (data != 0) ? (POLLIN | POLLRDNORM) : 0; |
210 | } | 210 | } |
211 | 211 | ||
212 | static int rtc_dev_ioctl(struct inode *inode, struct file *file, | 212 | static long rtc_dev_ioctl(struct file *file, |
213 | unsigned int cmd, unsigned long arg) | 213 | unsigned int cmd, unsigned long arg) |
214 | { | 214 | { |
215 | int err = 0; | 215 | int err = 0; |
@@ -219,6 +219,10 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file, | |||
219 | struct rtc_wkalrm alarm; | 219 | struct rtc_wkalrm alarm; |
220 | void __user *uarg = (void __user *) arg; | 220 | void __user *uarg = (void __user *) arg; |
221 | 221 | ||
222 | err = mutex_lock_interruptible(&rtc->ops_lock); | ||
223 | if (err) | ||
224 | return -EBUSY; | ||
225 | |||
222 | /* check that the calling task has appropriate permissions | 226 | /* check that the calling task has appropriate permissions |
223 | * for certain ioctls. doing this check here is useful | 227 | * for certain ioctls. doing this check here is useful |
224 | * to avoid duplicate code in each driver. | 228 | * to avoid duplicate code in each driver. |
@@ -227,26 +231,31 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file, | |||
227 | case RTC_EPOCH_SET: | 231 | case RTC_EPOCH_SET: |
228 | case RTC_SET_TIME: | 232 | case RTC_SET_TIME: |
229 | if (!capable(CAP_SYS_TIME)) | 233 | if (!capable(CAP_SYS_TIME)) |
230 | return -EACCES; | 234 | err = -EACCES; |
231 | break; | 235 | break; |
232 | 236 | ||
233 | case RTC_IRQP_SET: | 237 | case RTC_IRQP_SET: |
234 | if (arg > rtc->max_user_freq && !capable(CAP_SYS_RESOURCE)) | 238 | if (arg > rtc->max_user_freq && !capable(CAP_SYS_RESOURCE)) |
235 | return -EACCES; | 239 | err = -EACCES; |
236 | break; | 240 | break; |
237 | 241 | ||
238 | case RTC_PIE_ON: | 242 | case RTC_PIE_ON: |
239 | if (rtc->irq_freq > rtc->max_user_freq && | 243 | if (rtc->irq_freq > rtc->max_user_freq && |
240 | !capable(CAP_SYS_RESOURCE)) | 244 | !capable(CAP_SYS_RESOURCE)) |
241 | return -EACCES; | 245 | err = -EACCES; |
242 | break; | 246 | break; |
243 | } | 247 | } |
244 | 248 | ||
249 | if (err) | ||
250 | goto done; | ||
251 | |||
245 | /* try the driver's ioctl interface */ | 252 | /* try the driver's ioctl interface */ |
246 | if (ops->ioctl) { | 253 | if (ops->ioctl) { |
247 | err = ops->ioctl(rtc->dev.parent, cmd, arg); | 254 | err = ops->ioctl(rtc->dev.parent, cmd, arg); |
248 | if (err != -ENOIOCTLCMD) | 255 | if (err != -ENOIOCTLCMD) { |
256 | mutex_unlock(&rtc->ops_lock); | ||
249 | return err; | 257 | return err; |
258 | } | ||
250 | } | 259 | } |
251 | 260 | ||
252 | /* if the driver does not provide the ioctl interface | 261 | /* if the driver does not provide the ioctl interface |
@@ -265,15 +274,19 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file, | |||
265 | 274 | ||
266 | switch (cmd) { | 275 | switch (cmd) { |
267 | case RTC_ALM_READ: | 276 | case RTC_ALM_READ: |
277 | mutex_unlock(&rtc->ops_lock); | ||
278 | |||
268 | err = rtc_read_alarm(rtc, &alarm); | 279 | err = rtc_read_alarm(rtc, &alarm); |
269 | if (err < 0) | 280 | if (err < 0) |
270 | return err; | 281 | return err; |
271 | 282 | ||
272 | if (copy_to_user(uarg, &alarm.time, sizeof(tm))) | 283 | if (copy_to_user(uarg, &alarm.time, sizeof(tm))) |
273 | return -EFAULT; | 284 | err = -EFAULT; |
274 | break; | 285 | return err; |
275 | 286 | ||
276 | case RTC_ALM_SET: | 287 | case RTC_ALM_SET: |
288 | mutex_unlock(&rtc->ops_lock); | ||
289 | |||
277 | if (copy_from_user(&alarm.time, uarg, sizeof(tm))) | 290 | if (copy_from_user(&alarm.time, uarg, sizeof(tm))) |
278 | return -EFAULT; | 291 | return -EFAULT; |
279 | 292 | ||
@@ -321,24 +334,26 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file, | |||
321 | } | 334 | } |
322 | } | 335 | } |
323 | 336 | ||
324 | err = rtc_set_alarm(rtc, &alarm); | 337 | return rtc_set_alarm(rtc, &alarm); |
325 | break; | ||
326 | 338 | ||
327 | case RTC_RD_TIME: | 339 | case RTC_RD_TIME: |
340 | mutex_unlock(&rtc->ops_lock); | ||
341 | |||
328 | err = rtc_read_time(rtc, &tm); | 342 | err = rtc_read_time(rtc, &tm); |
329 | if (err < 0) | 343 | if (err < 0) |
330 | return err; | 344 | return err; |
331 | 345 | ||
332 | if (copy_to_user(uarg, &tm, sizeof(tm))) | 346 | if (copy_to_user(uarg, &tm, sizeof(tm))) |
333 | return -EFAULT; | 347 | err = -EFAULT; |
334 | break; | 348 | return err; |
335 | 349 | ||
336 | case RTC_SET_TIME: | 350 | case RTC_SET_TIME: |
351 | mutex_unlock(&rtc->ops_lock); | ||
352 | |||
337 | if (copy_from_user(&tm, uarg, sizeof(tm))) | 353 | if (copy_from_user(&tm, uarg, sizeof(tm))) |
338 | return -EFAULT; | 354 | return -EFAULT; |
339 | 355 | ||
340 | err = rtc_set_time(rtc, &tm); | 356 | return rtc_set_time(rtc, &tm); |
341 | break; | ||
342 | 357 | ||
343 | case RTC_PIE_ON: | 358 | case RTC_PIE_ON: |
344 | err = rtc_irq_set_state(rtc, NULL, 1); | 359 | err = rtc_irq_set_state(rtc, NULL, 1); |
@@ -376,34 +391,37 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file, | |||
376 | break; | 391 | break; |
377 | #endif | 392 | #endif |
378 | case RTC_WKALM_SET: | 393 | case RTC_WKALM_SET: |
394 | mutex_unlock(&rtc->ops_lock); | ||
379 | if (copy_from_user(&alarm, uarg, sizeof(alarm))) | 395 | if (copy_from_user(&alarm, uarg, sizeof(alarm))) |
380 | return -EFAULT; | 396 | return -EFAULT; |
381 | 397 | ||
382 | err = rtc_set_alarm(rtc, &alarm); | 398 | return rtc_set_alarm(rtc, &alarm); |
383 | break; | ||
384 | 399 | ||
385 | case RTC_WKALM_RD: | 400 | case RTC_WKALM_RD: |
401 | mutex_unlock(&rtc->ops_lock); | ||
386 | err = rtc_read_alarm(rtc, &alarm); | 402 | err = rtc_read_alarm(rtc, &alarm); |
387 | if (err < 0) | 403 | if (err < 0) |
388 | return err; | 404 | return err; |
389 | 405 | ||
390 | if (copy_to_user(uarg, &alarm, sizeof(alarm))) | 406 | if (copy_to_user(uarg, &alarm, sizeof(alarm))) |
391 | return -EFAULT; | 407 | err = -EFAULT; |
392 | break; | 408 | return err; |
393 | 409 | ||
394 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | 410 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL |
395 | case RTC_UIE_OFF: | 411 | case RTC_UIE_OFF: |
396 | clear_uie(rtc); | 412 | clear_uie(rtc); |
397 | return 0; | 413 | break; |
398 | 414 | ||
399 | case RTC_UIE_ON: | 415 | case RTC_UIE_ON: |
400 | return set_uie(rtc); | 416 | err = set_uie(rtc); |
401 | #endif | 417 | #endif |
402 | default: | 418 | default: |
403 | err = -ENOTTY; | 419 | err = -ENOTTY; |
404 | break; | 420 | break; |
405 | } | 421 | } |
406 | 422 | ||
423 | done: | ||
424 | mutex_unlock(&rtc->ops_lock); | ||
407 | return err; | 425 | return err; |
408 | } | 426 | } |
409 | 427 | ||
@@ -432,7 +450,7 @@ static const struct file_operations rtc_dev_fops = { | |||
432 | .llseek = no_llseek, | 450 | .llseek = no_llseek, |
433 | .read = rtc_dev_read, | 451 | .read = rtc_dev_read, |
434 | .poll = rtc_dev_poll, | 452 | .poll = rtc_dev_poll, |
435 | .ioctl = rtc_dev_ioctl, | 453 | .unlocked_ioctl = rtc_dev_ioctl, |
436 | .open = rtc_dev_open, | 454 | .open = rtc_dev_open, |
437 | .release = rtc_dev_release, | 455 | .release = rtc_dev_release, |
438 | .fasync = rtc_dev_fasync, | 456 | .fasync = rtc_dev_fasync, |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c new file mode 100644 index 000000000000..b91d02a3ace9 --- /dev/null +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -0,0 +1,847 @@ | |||
1 | /* | ||
2 | * rtc-ds1305.c -- driver for DS1305 and DS1306 SPI RTC chips | ||
3 | * | ||
4 | * Copyright (C) 2008 David Brownell | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/bcd.h> | ||
14 | #include <linux/rtc.h> | ||
15 | #include <linux/workqueue.h> | ||
16 | |||
17 | #include <linux/spi/spi.h> | ||
18 | #include <linux/spi/ds1305.h> | ||
19 | |||
20 | |||
21 | /* | ||
22 | * Registers ... mask DS1305_WRITE into register address to write, | ||
23 | * otherwise you're reading it. All non-bitmask values are BCD. | ||
24 | */ | ||
25 | #define DS1305_WRITE 0x80 | ||
26 | |||
27 | |||
28 | /* RTC date/time ... the main special cases are that we: | ||
29 | * - Need fancy "hours" encoding in 12hour mode | ||
30 | * - Don't rely on the "day-of-week" field (or tm_wday) | ||
31 | * - Are a 21st-century clock (2000 <= year < 2100) | ||
32 | */ | ||
33 | #define DS1305_RTC_LEN 7 /* bytes for RTC regs */ | ||
34 | |||
35 | #define DS1305_SEC 0x00 /* register addresses */ | ||
36 | #define DS1305_MIN 0x01 | ||
37 | #define DS1305_HOUR 0x02 | ||
38 | # define DS1305_HR_12 0x40 /* set == 12 hr mode */ | ||
39 | # define DS1305_HR_PM 0x20 /* set == PM (12hr mode) */ | ||
40 | #define DS1305_WDAY 0x03 | ||
41 | #define DS1305_MDAY 0x04 | ||
42 | #define DS1305_MON 0x05 | ||
43 | #define DS1305_YEAR 0x06 | ||
44 | |||
45 | |||
46 | /* The two alarms have only sec/min/hour/wday fields (ALM_LEN). | ||
47 | * DS1305_ALM_DISABLE disables a match field (some combos are bad). | ||
48 | * | ||
49 | * NOTE that since we don't use WDAY, we limit ourselves to alarms | ||
50 | * only one day into the future (vs potentially up to a week). | ||
51 | * | ||
52 | * NOTE ALSO that while we could generate once-a-second IRQs (UIE), we | ||
53 | * don't currently support them. We'd either need to do it only when | ||
54 | * no alarm is pending (not the standard model), or to use the second | ||
55 | * alarm (implying that this is a DS1305 not DS1306, *and* that either | ||
56 | * it's wired up a second IRQ we know, or that INTCN is set) | ||
57 | */ | ||
58 | #define DS1305_ALM_LEN 4 /* bytes for ALM regs */ | ||
59 | #define DS1305_ALM_DISABLE 0x80 | ||
60 | |||
61 | #define DS1305_ALM0(r) (0x07 + (r)) /* register addresses */ | ||
62 | #define DS1305_ALM1(r) (0x0b + (r)) | ||
63 | |||
64 | |||
65 | /* three control registers */ | ||
66 | #define DS1305_CONTROL_LEN 3 /* bytes of control regs */ | ||
67 | |||
68 | #define DS1305_CONTROL 0x0f /* register addresses */ | ||
69 | # define DS1305_nEOSC 0x80 /* low enables oscillator */ | ||
70 | # define DS1305_WP 0x40 /* write protect */ | ||
71 | # define DS1305_INTCN 0x04 /* clear == only int0 used */ | ||
72 | # define DS1306_1HZ 0x04 /* enable 1Hz output */ | ||
73 | # define DS1305_AEI1 0x02 /* enable ALM1 IRQ */ | ||
74 | # define DS1305_AEI0 0x01 /* enable ALM0 IRQ */ | ||
75 | #define DS1305_STATUS 0x10 | ||
76 | /* status has just AEIx bits, mirrored as IRQFx */ | ||
77 | #define DS1305_TRICKLE 0x11 | ||
78 | /* trickle bits are defined in <linux/spi/ds1305.h> */ | ||
79 | |||
80 | /* a bunch of NVRAM */ | ||
81 | #define DS1305_NVRAM_LEN 96 /* bytes of NVRAM */ | ||
82 | |||
83 | #define DS1305_NVRAM 0x20 /* register addresses */ | ||
84 | |||
85 | |||
86 | struct ds1305 { | ||
87 | struct spi_device *spi; | ||
88 | struct rtc_device *rtc; | ||
89 | |||
90 | struct work_struct work; | ||
91 | |||
92 | unsigned long flags; | ||
93 | #define FLAG_EXITING 0 | ||
94 | |||
95 | bool hr12; | ||
96 | u8 ctrl[DS1305_CONTROL_LEN]; | ||
97 | }; | ||
98 | |||
99 | |||
100 | /*----------------------------------------------------------------------*/ | ||
101 | |||
102 | /* | ||
103 | * Utilities ... tolerate 12-hour AM/PM notation in case of non-Linux | ||
104 | * software (like a bootloader) which may require it. | ||
105 | */ | ||
106 | |||
107 | static unsigned bcd2hour(u8 bcd) | ||
108 | { | ||
109 | if (bcd & DS1305_HR_12) { | ||
110 | unsigned hour = 0; | ||
111 | |||
112 | bcd &= ~DS1305_HR_12; | ||
113 | if (bcd & DS1305_HR_PM) { | ||
114 | hour = 12; | ||
115 | bcd &= ~DS1305_HR_PM; | ||
116 | } | ||
117 | hour += BCD2BIN(bcd); | ||
118 | return hour - 1; | ||
119 | } | ||
120 | return BCD2BIN(bcd); | ||
121 | } | ||
122 | |||
123 | static u8 hour2bcd(bool hr12, int hour) | ||
124 | { | ||
125 | if (hr12) { | ||
126 | hour++; | ||
127 | if (hour <= 12) | ||
128 | return DS1305_HR_12 | BIN2BCD(hour); | ||
129 | hour -= 12; | ||
130 | return DS1305_HR_12 | DS1305_HR_PM | BIN2BCD(hour); | ||
131 | } | ||
132 | return BIN2BCD(hour); | ||
133 | } | ||
134 | |||
135 | /*----------------------------------------------------------------------*/ | ||
136 | |||
137 | /* | ||
138 | * Interface to RTC framework | ||
139 | */ | ||
140 | |||
141 | #ifdef CONFIG_RTC_INTF_DEV | ||
142 | |||
143 | /* | ||
144 | * Context: caller holds rtc->ops_lock (to protect ds1305->ctrl) | ||
145 | */ | ||
146 | static int ds1305_ioctl(struct device *dev, unsigned cmd, unsigned long arg) | ||
147 | { | ||
148 | struct ds1305 *ds1305 = dev_get_drvdata(dev); | ||
149 | u8 buf[2]; | ||
150 | int status = -ENOIOCTLCMD; | ||
151 | |||
152 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | ||
153 | buf[1] = ds1305->ctrl[0]; | ||
154 | |||
155 | switch (cmd) { | ||
156 | case RTC_AIE_OFF: | ||
157 | status = 0; | ||
158 | if (!(buf[1] & DS1305_AEI0)) | ||
159 | goto done; | ||
160 | buf[1] &= ~DS1305_AEI0; | ||
161 | break; | ||
162 | |||
163 | case RTC_AIE_ON: | ||
164 | status = 0; | ||
165 | if (ds1305->ctrl[0] & DS1305_AEI0) | ||
166 | goto done; | ||
167 | buf[1] |= DS1305_AEI0; | ||
168 | break; | ||
169 | } | ||
170 | if (status == 0) { | ||
171 | status = spi_write_then_read(ds1305->spi, buf, sizeof buf, | ||
172 | NULL, 0); | ||
173 | if (status >= 0) | ||
174 | ds1305->ctrl[0] = buf[1]; | ||
175 | } | ||
176 | |||
177 | done: | ||
178 | return status; | ||
179 | } | ||
180 | |||
181 | #else | ||
182 | #define ds1305_ioctl NULL | ||
183 | #endif | ||
184 | |||
185 | /* | ||
186 | * Get/set of date and time is pretty normal. | ||
187 | */ | ||
188 | |||
189 | static int ds1305_get_time(struct device *dev, struct rtc_time *time) | ||
190 | { | ||
191 | struct ds1305 *ds1305 = dev_get_drvdata(dev); | ||
192 | u8 addr = DS1305_SEC; | ||
193 | u8 buf[DS1305_RTC_LEN]; | ||
194 | int status; | ||
195 | |||
196 | /* Use write-then-read to get all the date/time registers | ||
197 | * since dma from stack is nonportable | ||
198 | */ | ||
199 | status = spi_write_then_read(ds1305->spi, &addr, sizeof addr, | ||
200 | buf, sizeof buf); | ||
201 | if (status < 0) | ||
202 | return status; | ||
203 | |||
204 | dev_vdbg(dev, "%s: %02x %02x %02x, %02x %02x %02x %02x\n", | ||
205 | "read", buf[0], buf[1], buf[2], buf[3], | ||
206 | buf[4], buf[5], buf[6]); | ||
207 | |||
208 | /* Decode the registers */ | ||
209 | time->tm_sec = BCD2BIN(buf[DS1305_SEC]); | ||
210 | time->tm_min = BCD2BIN(buf[DS1305_MIN]); | ||
211 | time->tm_hour = bcd2hour(buf[DS1305_HOUR]); | ||
212 | time->tm_wday = buf[DS1305_WDAY] - 1; | ||
213 | time->tm_mday = BCD2BIN(buf[DS1305_MDAY]); | ||
214 | time->tm_mon = BCD2BIN(buf[DS1305_MON]) - 1; | ||
215 | time->tm_year = BCD2BIN(buf[DS1305_YEAR]) + 100; | ||
216 | |||
217 | dev_vdbg(dev, "%s secs=%d, mins=%d, " | ||
218 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | ||
219 | "read", time->tm_sec, time->tm_min, | ||
220 | time->tm_hour, time->tm_mday, | ||
221 | time->tm_mon, time->tm_year, time->tm_wday); | ||
222 | |||
223 | /* Time may not be set */ | ||
224 | return rtc_valid_tm(time); | ||
225 | } | ||
226 | |||
227 | static int ds1305_set_time(struct device *dev, struct rtc_time *time) | ||
228 | { | ||
229 | struct ds1305 *ds1305 = dev_get_drvdata(dev); | ||
230 | u8 buf[1 + DS1305_RTC_LEN]; | ||
231 | u8 *bp = buf; | ||
232 | |||
233 | dev_vdbg(dev, "%s secs=%d, mins=%d, " | ||
234 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | ||
235 | "write", time->tm_sec, time->tm_min, | ||
236 | time->tm_hour, time->tm_mday, | ||
237 | time->tm_mon, time->tm_year, time->tm_wday); | ||
238 | |||
239 | /* Write registers starting at the first time/date address. */ | ||
240 | *bp++ = DS1305_WRITE | DS1305_SEC; | ||
241 | |||
242 | *bp++ = BIN2BCD(time->tm_sec); | ||
243 | *bp++ = BIN2BCD(time->tm_min); | ||
244 | *bp++ = hour2bcd(ds1305->hr12, time->tm_hour); | ||
245 | *bp++ = (time->tm_wday < 7) ? (time->tm_wday + 1) : 1; | ||
246 | *bp++ = BIN2BCD(time->tm_mday); | ||
247 | *bp++ = BIN2BCD(time->tm_mon + 1); | ||
248 | *bp++ = BIN2BCD(time->tm_year - 100); | ||
249 | |||
250 | dev_dbg(dev, "%s: %02x %02x %02x, %02x %02x %02x %02x\n", | ||
251 | "write", buf[1], buf[2], buf[3], | ||
252 | buf[4], buf[5], buf[6], buf[7]); | ||
253 | |||
254 | /* use write-then-read since dma from stack is nonportable */ | ||
255 | return spi_write_then_read(ds1305->spi, buf, sizeof buf, | ||
256 | NULL, 0); | ||
257 | } | ||
258 | |||
259 | /* | ||
260 | * Get/set of alarm is a bit funky: | ||
261 | * | ||
262 | * - First there's the inherent raciness of getting the (partitioned) | ||
263 | * status of an alarm that could trigger while we're reading parts | ||
264 | * of that status. | ||
265 | * | ||
266 | * - Second there's its limited range (we could increase it a bit by | ||
267 | * relying on WDAY), which means it will easily roll over. | ||
268 | * | ||
269 | * - Third there's the choice of two alarms and alarm signals. | ||
270 | * Here we use ALM0 and expect that nINT0 (open drain) is used; | ||
271 | * that's the only real option for DS1306 runtime alarms, and is | ||
272 | * natural on DS1305. | ||
273 | * | ||
274 | * - Fourth, there's also ALM1, and a second interrupt signal: | ||
275 | * + On DS1305 ALM1 uses nINT1 (when INTCN=1) else nINT0; | ||
276 | * + On DS1306 ALM1 only uses INT1 (an active high pulse) | ||
277 | * and it won't work when VCC1 is active. | ||
278 | * | ||
279 | * So to be most general, we should probably set both alarms to the | ||
280 | * same value, letting ALM1 be the wakeup event source on DS1306 | ||
281 | * and handling several wiring options on DS1305. | ||
282 | * | ||
283 | * - Fifth, we support the polled mode (as well as possible; why not?) | ||
284 | * even when no interrupt line is wired to an IRQ. | ||
285 | */ | ||
286 | |||
287 | /* | ||
288 | * Context: caller holds rtc->ops_lock (to protect ds1305->ctrl) | ||
289 | */ | ||
290 | static int ds1305_get_alarm(struct device *dev, struct rtc_wkalrm *alm) | ||
291 | { | ||
292 | struct ds1305 *ds1305 = dev_get_drvdata(dev); | ||
293 | struct spi_device *spi = ds1305->spi; | ||
294 | u8 addr; | ||
295 | int status; | ||
296 | u8 buf[DS1305_ALM_LEN]; | ||
297 | |||
298 | /* Refresh control register cache BEFORE reading ALM0 registers, | ||
299 | * since reading alarm registers acks any pending IRQ. That | ||
300 | * makes returning "pending" status a bit of a lie, but that bit | ||
301 | * of EFI status is at best fragile anyway (given IRQ handlers). | ||
302 | */ | ||
303 | addr = DS1305_CONTROL; | ||
304 | status = spi_write_then_read(spi, &addr, sizeof addr, | ||
305 | ds1305->ctrl, sizeof ds1305->ctrl); | ||
306 | if (status < 0) | ||
307 | return status; | ||
308 | |||
309 | alm->enabled = !!(ds1305->ctrl[0] & DS1305_AEI0); | ||
310 | alm->pending = !!(ds1305->ctrl[1] & DS1305_AEI0); | ||
311 | |||
312 | /* get and check ALM0 registers */ | ||
313 | addr = DS1305_ALM0(DS1305_SEC); | ||
314 | status = spi_write_then_read(spi, &addr, sizeof addr, | ||
315 | buf, sizeof buf); | ||
316 | if (status < 0) | ||
317 | return status; | ||
318 | |||
319 | dev_vdbg(dev, "%s: %02x %02x %02x %02x\n", | ||
320 | "alm0 read", buf[DS1305_SEC], buf[DS1305_MIN], | ||
321 | buf[DS1305_HOUR], buf[DS1305_WDAY]); | ||
322 | |||
323 | if ((DS1305_ALM_DISABLE & buf[DS1305_SEC]) | ||
324 | || (DS1305_ALM_DISABLE & buf[DS1305_MIN]) | ||
325 | || (DS1305_ALM_DISABLE & buf[DS1305_HOUR])) | ||
326 | return -EIO; | ||
327 | |||
328 | /* Stuff these values into alm->time and let RTC framework code | ||
329 | * fill in the rest ... and also handle rollover to tomorrow when | ||
330 | * that's needed. | ||
331 | */ | ||
332 | alm->time.tm_sec = BCD2BIN(buf[DS1305_SEC]); | ||
333 | alm->time.tm_min = BCD2BIN(buf[DS1305_MIN]); | ||
334 | alm->time.tm_hour = bcd2hour(buf[DS1305_HOUR]); | ||
335 | alm->time.tm_mday = -1; | ||
336 | alm->time.tm_mon = -1; | ||
337 | alm->time.tm_year = -1; | ||
338 | /* next three fields are unused by Linux */ | ||
339 | alm->time.tm_wday = -1; | ||
340 | alm->time.tm_mday = -1; | ||
341 | alm->time.tm_isdst = -1; | ||
342 | |||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | /* | ||
347 | * Context: caller holds rtc->ops_lock (to protect ds1305->ctrl) | ||
348 | */ | ||
349 | static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | ||
350 | { | ||
351 | struct ds1305 *ds1305 = dev_get_drvdata(dev); | ||
352 | struct spi_device *spi = ds1305->spi; | ||
353 | unsigned long now, later; | ||
354 | struct rtc_time tm; | ||
355 | int status; | ||
356 | u8 buf[1 + DS1305_ALM_LEN]; | ||
357 | |||
358 | /* convert desired alarm to time_t */ | ||
359 | status = rtc_tm_to_time(&alm->time, &later); | ||
360 | if (status < 0) | ||
361 | return status; | ||
362 | |||
363 | /* Read current time as time_t */ | ||
364 | status = ds1305_get_time(dev, &tm); | ||
365 | if (status < 0) | ||
366 | return status; | ||
367 | status = rtc_tm_to_time(&tm, &now); | ||
368 | if (status < 0) | ||
369 | return status; | ||
370 | |||
371 | /* make sure alarm fires within the next 24 hours */ | ||
372 | if (later <= now) | ||
373 | return -EINVAL; | ||
374 | if ((later - now) > 24 * 60 * 60) | ||
375 | return -EDOM; | ||
376 | |||
377 | /* disable alarm if needed */ | ||
378 | if (ds1305->ctrl[0] & DS1305_AEI0) { | ||
379 | ds1305->ctrl[0] &= ~DS1305_AEI0; | ||
380 | |||
381 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | ||
382 | buf[1] = ds1305->ctrl[0]; | ||
383 | status = spi_write_then_read(ds1305->spi, buf, 2, NULL, 0); | ||
384 | if (status < 0) | ||
385 | return status; | ||
386 | } | ||
387 | |||
388 | /* write alarm */ | ||
389 | buf[0] = DS1305_WRITE | DS1305_ALM0(DS1305_SEC); | ||
390 | buf[1 + DS1305_SEC] = BIN2BCD(alm->time.tm_sec); | ||
391 | buf[1 + DS1305_MIN] = BIN2BCD(alm->time.tm_min); | ||
392 | buf[1 + DS1305_HOUR] = hour2bcd(ds1305->hr12, alm->time.tm_hour); | ||
393 | buf[1 + DS1305_WDAY] = DS1305_ALM_DISABLE; | ||
394 | |||
395 | dev_dbg(dev, "%s: %02x %02x %02x %02x\n", | ||
396 | "alm0 write", buf[1 + DS1305_SEC], buf[1 + DS1305_MIN], | ||
397 | buf[1 + DS1305_HOUR], buf[1 + DS1305_WDAY]); | ||
398 | |||
399 | status = spi_write_then_read(spi, buf, sizeof buf, NULL, 0); | ||
400 | if (status < 0) | ||
401 | return status; | ||
402 | |||
403 | /* enable alarm if requested */ | ||
404 | if (alm->enabled) { | ||
405 | ds1305->ctrl[0] |= DS1305_AEI0; | ||
406 | |||
407 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | ||
408 | buf[1] = ds1305->ctrl[0]; | ||
409 | status = spi_write_then_read(ds1305->spi, buf, 2, NULL, 0); | ||
410 | } | ||
411 | |||
412 | return status; | ||
413 | } | ||
414 | |||
415 | #ifdef CONFIG_PROC_FS | ||
416 | |||
417 | static int ds1305_proc(struct device *dev, struct seq_file *seq) | ||
418 | { | ||
419 | struct ds1305 *ds1305 = dev_get_drvdata(dev); | ||
420 | char *diodes = "no"; | ||
421 | char *resistors = ""; | ||
422 | |||
423 | /* ctrl[2] is treated as read-only; no locking needed */ | ||
424 | if ((ds1305->ctrl[2] & 0xf0) == DS1305_TRICKLE_MAGIC) { | ||
425 | switch (ds1305->ctrl[2] & 0x0c) { | ||
426 | case DS1305_TRICKLE_DS2: | ||
427 | diodes = "2 diodes, "; | ||
428 | break; | ||
429 | case DS1305_TRICKLE_DS1: | ||
430 | diodes = "1 diode, "; | ||
431 | break; | ||
432 | default: | ||
433 | goto done; | ||
434 | } | ||
435 | switch (ds1305->ctrl[2] & 0x03) { | ||
436 | case DS1305_TRICKLE_2K: | ||
437 | resistors = "2k Ohm"; | ||
438 | break; | ||
439 | case DS1305_TRICKLE_4K: | ||
440 | resistors = "4k Ohm"; | ||
441 | break; | ||
442 | case DS1305_TRICKLE_8K: | ||
443 | resistors = "8k Ohm"; | ||
444 | break; | ||
445 | default: | ||
446 | diodes = "no"; | ||
447 | break; | ||
448 | } | ||
449 | } | ||
450 | |||
451 | done: | ||
452 | return seq_printf(seq, | ||
453 | "trickle_charge\t: %s%s\n", | ||
454 | diodes, resistors); | ||
455 | } | ||
456 | |||
457 | #else | ||
458 | #define ds1305_proc NULL | ||
459 | #endif | ||
460 | |||
461 | static const struct rtc_class_ops ds1305_ops = { | ||
462 | .ioctl = ds1305_ioctl, | ||
463 | .read_time = ds1305_get_time, | ||
464 | .set_time = ds1305_set_time, | ||
465 | .read_alarm = ds1305_get_alarm, | ||
466 | .set_alarm = ds1305_set_alarm, | ||
467 | .proc = ds1305_proc, | ||
468 | }; | ||
469 | |||
470 | static void ds1305_work(struct work_struct *work) | ||
471 | { | ||
472 | struct ds1305 *ds1305 = container_of(work, struct ds1305, work); | ||
473 | struct mutex *lock = &ds1305->rtc->ops_lock; | ||
474 | struct spi_device *spi = ds1305->spi; | ||
475 | u8 buf[3]; | ||
476 | int status; | ||
477 | |||
478 | /* lock to protect ds1305->ctrl */ | ||
479 | mutex_lock(lock); | ||
480 | |||
481 | /* Disable the IRQ, and clear its status ... for now, we "know" | ||
482 | * that if more than one alarm is active, they're in sync. | ||
483 | * Note that reading ALM data registers also clears IRQ status. | ||
484 | */ | ||
485 | ds1305->ctrl[0] &= ~(DS1305_AEI1 | DS1305_AEI0); | ||
486 | ds1305->ctrl[1] = 0; | ||
487 | |||
488 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | ||
489 | buf[1] = ds1305->ctrl[0]; | ||
490 | buf[2] = 0; | ||
491 | |||
492 | status = spi_write_then_read(spi, buf, sizeof buf, | ||
493 | NULL, 0); | ||
494 | if (status < 0) | ||
495 | dev_dbg(&spi->dev, "clear irq --> %d\n", status); | ||
496 | |||
497 | mutex_unlock(lock); | ||
498 | |||
499 | if (!test_bit(FLAG_EXITING, &ds1305->flags)) | ||
500 | enable_irq(spi->irq); | ||
501 | |||
502 | /* rtc_update_irq() requires an IRQ-disabled context */ | ||
503 | local_irq_disable(); | ||
504 | rtc_update_irq(ds1305->rtc, 1, RTC_AF | RTC_IRQF); | ||
505 | local_irq_enable(); | ||
506 | } | ||
507 | |||
508 | /* | ||
509 | * This "real" IRQ handler hands off to a workqueue mostly to allow | ||
510 | * mutex locking for ds1305->ctrl ... unlike I2C, we could issue async | ||
511 | * I/O requests in IRQ context (to clear the IRQ status). | ||
512 | */ | ||
513 | static irqreturn_t ds1305_irq(int irq, void *p) | ||
514 | { | ||
515 | struct ds1305 *ds1305 = p; | ||
516 | |||
517 | disable_irq(irq); | ||
518 | schedule_work(&ds1305->work); | ||
519 | return IRQ_HANDLED; | ||
520 | } | ||
521 | |||
522 | /*----------------------------------------------------------------------*/ | ||
523 | |||
524 | /* | ||
525 | * Interface for NVRAM | ||
526 | */ | ||
527 | |||
528 | static void msg_init(struct spi_message *m, struct spi_transfer *x, | ||
529 | u8 *addr, size_t count, char *tx, char *rx) | ||
530 | { | ||
531 | spi_message_init(m); | ||
532 | memset(x, 0, 2 * sizeof(*x)); | ||
533 | |||
534 | x->tx_buf = addr; | ||
535 | x->len = 1; | ||
536 | spi_message_add_tail(x, m); | ||
537 | |||
538 | x++; | ||
539 | |||
540 | x->tx_buf = tx; | ||
541 | x->rx_buf = rx; | ||
542 | x->len = count; | ||
543 | spi_message_add_tail(x, m); | ||
544 | } | ||
545 | |||
546 | static ssize_t | ||
547 | ds1305_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | ||
548 | char *buf, loff_t off, size_t count) | ||
549 | { | ||
550 | struct spi_device *spi; | ||
551 | u8 addr; | ||
552 | struct spi_message m; | ||
553 | struct spi_transfer x[2]; | ||
554 | int status; | ||
555 | |||
556 | spi = container_of(kobj, struct spi_device, dev.kobj); | ||
557 | |||
558 | if (unlikely(off >= DS1305_NVRAM_LEN)) | ||
559 | return 0; | ||
560 | if (count >= DS1305_NVRAM_LEN) | ||
561 | count = DS1305_NVRAM_LEN; | ||
562 | if ((off + count) > DS1305_NVRAM_LEN) | ||
563 | count = DS1305_NVRAM_LEN - off; | ||
564 | if (unlikely(!count)) | ||
565 | return count; | ||
566 | |||
567 | addr = DS1305_NVRAM + off; | ||
568 | msg_init(&m, x, &addr, count, NULL, buf); | ||
569 | |||
570 | status = spi_sync(spi, &m); | ||
571 | if (status < 0) | ||
572 | dev_err(&spi->dev, "nvram %s error %d\n", "read", status); | ||
573 | return (status < 0) ? status : count; | ||
574 | } | ||
575 | |||
576 | static ssize_t | ||
577 | ds1305_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | ||
578 | char *buf, loff_t off, size_t count) | ||
579 | { | ||
580 | struct spi_device *spi; | ||
581 | u8 addr; | ||
582 | struct spi_message m; | ||
583 | struct spi_transfer x[2]; | ||
584 | int status; | ||
585 | |||
586 | spi = container_of(kobj, struct spi_device, dev.kobj); | ||
587 | |||
588 | if (unlikely(off >= DS1305_NVRAM_LEN)) | ||
589 | return -EFBIG; | ||
590 | if (count >= DS1305_NVRAM_LEN) | ||
591 | count = DS1305_NVRAM_LEN; | ||
592 | if ((off + count) > DS1305_NVRAM_LEN) | ||
593 | count = DS1305_NVRAM_LEN - off; | ||
594 | if (unlikely(!count)) | ||
595 | return count; | ||
596 | |||
597 | addr = (DS1305_WRITE | DS1305_NVRAM) + off; | ||
598 | msg_init(&m, x, &addr, count, buf, NULL); | ||
599 | |||
600 | status = spi_sync(spi, &m); | ||
601 | if (status < 0) | ||
602 | dev_err(&spi->dev, "nvram %s error %d\n", "write", status); | ||
603 | return (status < 0) ? status : count; | ||
604 | } | ||
605 | |||
606 | static struct bin_attribute nvram = { | ||
607 | .attr.name = "nvram", | ||
608 | .attr.mode = S_IRUGO | S_IWUSR, | ||
609 | .attr.owner = THIS_MODULE, | ||
610 | .read = ds1305_nvram_read, | ||
611 | .write = ds1305_nvram_write, | ||
612 | .size = DS1305_NVRAM_LEN, | ||
613 | }; | ||
614 | |||
615 | /*----------------------------------------------------------------------*/ | ||
616 | |||
617 | /* | ||
618 | * Interface to SPI stack | ||
619 | */ | ||
620 | |||
621 | static int __devinit ds1305_probe(struct spi_device *spi) | ||
622 | { | ||
623 | struct ds1305 *ds1305; | ||
624 | struct rtc_device *rtc; | ||
625 | int status; | ||
626 | u8 addr, value; | ||
627 | struct ds1305_platform_data *pdata = spi->dev.platform_data; | ||
628 | bool write_ctrl = false; | ||
629 | |||
630 | /* Sanity check board setup data. This may be hooked up | ||
631 | * in 3wire mode, but we don't care. Note that unless | ||
632 | * there's an inverter in place, this needs SPI_CS_HIGH! | ||
633 | */ | ||
634 | if ((spi->bits_per_word && spi->bits_per_word != 8) | ||
635 | || (spi->max_speed_hz > 2000000) | ||
636 | || !(spi->mode & SPI_CPHA)) | ||
637 | return -EINVAL; | ||
638 | |||
639 | /* set up driver data */ | ||
640 | ds1305 = kzalloc(sizeof *ds1305, GFP_KERNEL); | ||
641 | if (!ds1305) | ||
642 | return -ENOMEM; | ||
643 | ds1305->spi = spi; | ||
644 | spi_set_drvdata(spi, ds1305); | ||
645 | |||
646 | /* read and cache control registers */ | ||
647 | addr = DS1305_CONTROL; | ||
648 | status = spi_write_then_read(spi, &addr, sizeof addr, | ||
649 | ds1305->ctrl, sizeof ds1305->ctrl); | ||
650 | if (status < 0) { | ||
651 | dev_dbg(&spi->dev, "can't %s, %d\n", | ||
652 | "read", status); | ||
653 | goto fail0; | ||
654 | } | ||
655 | |||
656 | dev_dbg(&spi->dev, "ctrl %s: %02x %02x %02x\n", | ||
657 | "read", ds1305->ctrl[0], | ||
658 | ds1305->ctrl[1], ds1305->ctrl[2]); | ||
659 | |||
660 | /* Sanity check register values ... partially compensating for the | ||
661 | * fact that SPI has no device handshake. A pullup on MISO would | ||
662 | * make these tests fail; but not all systems will have one. If | ||
663 | * some register is neither 0x00 nor 0xff, a chip is likely there. | ||
664 | */ | ||
665 | if ((ds1305->ctrl[0] & 0x38) != 0 || (ds1305->ctrl[1] & 0xfc) != 0) { | ||
666 | dev_dbg(&spi->dev, "RTC chip is not present\n"); | ||
667 | status = -ENODEV; | ||
668 | goto fail0; | ||
669 | } | ||
670 | if (ds1305->ctrl[2] == 0) | ||
671 | dev_dbg(&spi->dev, "chip may not be present\n"); | ||
672 | |||
673 | /* enable writes if needed ... if we were paranoid it would | ||
674 | * make sense to enable them only when absolutely necessary. | ||
675 | */ | ||
676 | if (ds1305->ctrl[0] & DS1305_WP) { | ||
677 | u8 buf[2]; | ||
678 | |||
679 | ds1305->ctrl[0] &= ~DS1305_WP; | ||
680 | |||
681 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | ||
682 | buf[1] = ds1305->ctrl[0]; | ||
683 | status = spi_write_then_read(spi, buf, sizeof buf, NULL, 0); | ||
684 | |||
685 | dev_dbg(&spi->dev, "clear WP --> %d\n", status); | ||
686 | if (status < 0) | ||
687 | goto fail0; | ||
688 | } | ||
689 | |||
690 | /* on DS1305, maybe start oscillator; like most low power | ||
691 | * oscillators, it may take a second to stabilize | ||
692 | */ | ||
693 | if (ds1305->ctrl[0] & DS1305_nEOSC) { | ||
694 | ds1305->ctrl[0] &= ~DS1305_nEOSC; | ||
695 | write_ctrl = true; | ||
696 | dev_warn(&spi->dev, "SET TIME!\n"); | ||
697 | } | ||
698 | |||
699 | /* ack any pending IRQs */ | ||
700 | if (ds1305->ctrl[1]) { | ||
701 | ds1305->ctrl[1] = 0; | ||
702 | write_ctrl = true; | ||
703 | } | ||
704 | |||
705 | /* this may need one-time (re)init */ | ||
706 | if (pdata) { | ||
707 | /* maybe enable trickle charge */ | ||
708 | if (((ds1305->ctrl[2] & 0xf0) != DS1305_TRICKLE_MAGIC)) { | ||
709 | ds1305->ctrl[2] = DS1305_TRICKLE_MAGIC | ||
710 | | pdata->trickle; | ||
711 | write_ctrl = true; | ||
712 | } | ||
713 | |||
714 | /* on DS1306, configure 1 Hz signal */ | ||
715 | if (pdata->is_ds1306) { | ||
716 | if (pdata->en_1hz) { | ||
717 | if (!(ds1305->ctrl[0] & DS1306_1HZ)) { | ||
718 | ds1305->ctrl[0] |= DS1306_1HZ; | ||
719 | write_ctrl = true; | ||
720 | } | ||
721 | } else { | ||
722 | if (ds1305->ctrl[0] & DS1306_1HZ) { | ||
723 | ds1305->ctrl[0] &= ~DS1306_1HZ; | ||
724 | write_ctrl = true; | ||
725 | } | ||
726 | } | ||
727 | } | ||
728 | } | ||
729 | |||
730 | if (write_ctrl) { | ||
731 | u8 buf[4]; | ||
732 | |||
733 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | ||
734 | buf[1] = ds1305->ctrl[0]; | ||
735 | buf[2] = ds1305->ctrl[1]; | ||
736 | buf[3] = ds1305->ctrl[2]; | ||
737 | status = spi_write_then_read(spi, buf, sizeof buf, NULL, 0); | ||
738 | if (status < 0) { | ||
739 | dev_dbg(&spi->dev, "can't %s, %d\n", | ||
740 | "write", status); | ||
741 | goto fail0; | ||
742 | } | ||
743 | |||
744 | dev_dbg(&spi->dev, "ctrl %s: %02x %02x %02x\n", | ||
745 | "write", ds1305->ctrl[0], | ||
746 | ds1305->ctrl[1], ds1305->ctrl[2]); | ||
747 | } | ||
748 | |||
749 | /* see if non-Linux software set up AM/PM mode */ | ||
750 | addr = DS1305_HOUR; | ||
751 | status = spi_write_then_read(spi, &addr, sizeof addr, | ||
752 | &value, sizeof value); | ||
753 | if (status < 0) { | ||
754 | dev_dbg(&spi->dev, "read HOUR --> %d\n", status); | ||
755 | goto fail0; | ||
756 | } | ||
757 | |||
758 | ds1305->hr12 = (DS1305_HR_12 & value) != 0; | ||
759 | if (ds1305->hr12) | ||
760 | dev_dbg(&spi->dev, "AM/PM\n"); | ||
761 | |||
762 | /* register RTC ... from here on, ds1305->ctrl needs locking */ | ||
763 | rtc = rtc_device_register("ds1305", &spi->dev, | ||
764 | &ds1305_ops, THIS_MODULE); | ||
765 | if (IS_ERR(rtc)) { | ||
766 | status = PTR_ERR(rtc); | ||
767 | dev_dbg(&spi->dev, "register rtc --> %d\n", status); | ||
768 | goto fail0; | ||
769 | } | ||
770 | ds1305->rtc = rtc; | ||
771 | |||
772 | /* Maybe set up alarm IRQ; be ready to handle it triggering right | ||
773 | * away. NOTE that we don't share this. The signal is active low, | ||
774 | * and we can't ack it before a SPI message delay. We temporarily | ||
775 | * disable the IRQ until it's acked, which lets us work with more | ||
776 | * IRQ trigger modes (not all IRQ controllers can do falling edge). | ||
777 | */ | ||
778 | if (spi->irq) { | ||
779 | INIT_WORK(&ds1305->work, ds1305_work); | ||
780 | status = request_irq(spi->irq, ds1305_irq, | ||
781 | 0, dev_name(&rtc->dev), ds1305); | ||
782 | if (status < 0) { | ||
783 | dev_dbg(&spi->dev, "request_irq %d --> %d\n", | ||
784 | spi->irq, status); | ||
785 | goto fail1; | ||
786 | } | ||
787 | } | ||
788 | |||
789 | /* export NVRAM */ | ||
790 | status = sysfs_create_bin_file(&spi->dev.kobj, &nvram); | ||
791 | if (status < 0) { | ||
792 | dev_dbg(&spi->dev, "register nvram --> %d\n", status); | ||
793 | goto fail2; | ||
794 | } | ||
795 | |||
796 | return 0; | ||
797 | |||
798 | fail2: | ||
799 | free_irq(spi->irq, ds1305); | ||
800 | fail1: | ||
801 | rtc_device_unregister(rtc); | ||
802 | fail0: | ||
803 | kfree(ds1305); | ||
804 | return status; | ||
805 | } | ||
806 | |||
807 | static int __devexit ds1305_remove(struct spi_device *spi) | ||
808 | { | ||
809 | struct ds1305 *ds1305 = spi_get_drvdata(spi); | ||
810 | |||
811 | sysfs_remove_bin_file(&spi->dev.kobj, &nvram); | ||
812 | |||
813 | /* carefully shut down irq and workqueue, if present */ | ||
814 | if (spi->irq) { | ||
815 | set_bit(FLAG_EXITING, &ds1305->flags); | ||
816 | free_irq(spi->irq, ds1305); | ||
817 | flush_scheduled_work(); | ||
818 | } | ||
819 | |||
820 | rtc_device_unregister(ds1305->rtc); | ||
821 | spi_set_drvdata(spi, NULL); | ||
822 | kfree(ds1305); | ||
823 | return 0; | ||
824 | } | ||
825 | |||
826 | static struct spi_driver ds1305_driver = { | ||
827 | .driver.name = "rtc-ds1305", | ||
828 | .driver.owner = THIS_MODULE, | ||
829 | .probe = ds1305_probe, | ||
830 | .remove = __devexit_p(ds1305_remove), | ||
831 | /* REVISIT add suspend/resume */ | ||
832 | }; | ||
833 | |||
834 | static int __init ds1305_init(void) | ||
835 | { | ||
836 | return spi_register_driver(&ds1305_driver); | ||
837 | } | ||
838 | module_init(ds1305_init); | ||
839 | |||
840 | static void __exit ds1305_exit(void) | ||
841 | { | ||
842 | spi_unregister_driver(&ds1305_driver); | ||
843 | } | ||
844 | module_exit(ds1305_exit); | ||
845 | |||
846 | MODULE_DESCRIPTION("RTC driver for DS1305 and DS1306 chips"); | ||
847 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 0a19c06019be..24bc1689fc74 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -13,21 +13,21 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/module.h> | 16 | #include <linux/bcd.h> |
17 | #include <linux/i2c.h> | ||
17 | #include <linux/init.h> | 18 | #include <linux/init.h> |
18 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/module.h> | ||
21 | #include <linux/rtc.h> | ||
19 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
20 | #include <linux/smp_lock.h> | 23 | #include <linux/smp_lock.h> |
21 | #include <linux/string.h> | 24 | #include <linux/string.h> |
22 | #include <linux/i2c.h> | ||
23 | #include <linux/rtc.h> | ||
24 | #include <linux/bcd.h> | ||
25 | #ifdef CONFIG_RTC_DRV_M41T80_WDT | 25 | #ifdef CONFIG_RTC_DRV_M41T80_WDT |
26 | #include <linux/miscdevice.h> | ||
27 | #include <linux/watchdog.h> | ||
28 | #include <linux/reboot.h> | ||
29 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
30 | #include <linux/ioctl.h> | 27 | #include <linux/ioctl.h> |
28 | #include <linux/miscdevice.h> | ||
29 | #include <linux/reboot.h> | ||
30 | #include <linux/watchdog.h> | ||
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #define M41T80_REG_SSEC 0 | 33 | #define M41T80_REG_SSEC 0 |
@@ -631,14 +631,12 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
631 | return -EFAULT; | 631 | return -EFAULT; |
632 | 632 | ||
633 | if (rv & WDIOS_DISABLECARD) { | 633 | if (rv & WDIOS_DISABLECARD) { |
634 | printk(KERN_INFO | 634 | pr_info("rtc-m41t80: disable watchdog\n"); |
635 | "rtc-m41t80: disable watchdog\n"); | ||
636 | wdt_disable(); | 635 | wdt_disable(); |
637 | } | 636 | } |
638 | 637 | ||
639 | if (rv & WDIOS_ENABLECARD) { | 638 | if (rv & WDIOS_ENABLECARD) { |
640 | printk(KERN_INFO | 639 | pr_info("rtc-m41t80: enable watchdog\n"); |
641 | "rtc-m41t80: enable watchdog\n"); | ||
642 | wdt_ping(); | 640 | wdt_ping(); |
643 | } | 641 | } |
644 | 642 | ||
diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c new file mode 100644 index 000000000000..9b19499c829e --- /dev/null +++ b/drivers/rtc/rtc-m41t94.c | |||
@@ -0,0 +1,173 @@ | |||
1 | /* | ||
2 | * Driver for ST M41T94 SPI RTC | ||
3 | * | ||
4 | * Copyright (C) 2008 Kim B. Heino | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/rtc.h> | ||
15 | #include <linux/spi/spi.h> | ||
16 | #include <linux/bcd.h> | ||
17 | |||
18 | #define M41T94_REG_SECONDS 0x01 | ||
19 | #define M41T94_REG_MINUTES 0x02 | ||
20 | #define M41T94_REG_HOURS 0x03 | ||
21 | #define M41T94_REG_WDAY 0x04 | ||
22 | #define M41T94_REG_DAY 0x05 | ||
23 | #define M41T94_REG_MONTH 0x06 | ||
24 | #define M41T94_REG_YEAR 0x07 | ||
25 | #define M41T94_REG_HT 0x0c | ||
26 | |||
27 | #define M41T94_BIT_HALT 0x40 | ||
28 | #define M41T94_BIT_STOP 0x80 | ||
29 | #define M41T94_BIT_CB 0x40 | ||
30 | #define M41T94_BIT_CEB 0x80 | ||
31 | |||
32 | static int m41t94_set_time(struct device *dev, struct rtc_time *tm) | ||
33 | { | ||
34 | struct spi_device *spi = to_spi_device(dev); | ||
35 | u8 buf[8]; /* write cmd + 7 registers */ | ||
36 | |||
37 | dev_dbg(dev, "%s secs=%d, mins=%d, " | ||
38 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | ||
39 | "write", tm->tm_sec, tm->tm_min, | ||
40 | tm->tm_hour, tm->tm_mday, | ||
41 | tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
42 | |||
43 | buf[0] = 0x80 | M41T94_REG_SECONDS; /* write time + date */ | ||
44 | buf[M41T94_REG_SECONDS] = BIN2BCD(tm->tm_sec); | ||
45 | buf[M41T94_REG_MINUTES] = BIN2BCD(tm->tm_min); | ||
46 | buf[M41T94_REG_HOURS] = BIN2BCD(tm->tm_hour); | ||
47 | buf[M41T94_REG_WDAY] = BIN2BCD(tm->tm_wday + 1); | ||
48 | buf[M41T94_REG_DAY] = BIN2BCD(tm->tm_mday); | ||
49 | buf[M41T94_REG_MONTH] = BIN2BCD(tm->tm_mon + 1); | ||
50 | |||
51 | buf[M41T94_REG_HOURS] |= M41T94_BIT_CEB; | ||
52 | if (tm->tm_year >= 100) | ||
53 | buf[M41T94_REG_HOURS] |= M41T94_BIT_CB; | ||
54 | buf[M41T94_REG_YEAR] = BIN2BCD(tm->tm_year % 100); | ||
55 | |||
56 | return spi_write(spi, buf, 8); | ||
57 | } | ||
58 | |||
59 | static int m41t94_read_time(struct device *dev, struct rtc_time *tm) | ||
60 | { | ||
61 | struct spi_device *spi = to_spi_device(dev); | ||
62 | u8 buf[2]; | ||
63 | int ret, hour; | ||
64 | |||
65 | /* clear halt update bit */ | ||
66 | ret = spi_w8r8(spi, M41T94_REG_HT); | ||
67 | if (ret < 0) | ||
68 | return ret; | ||
69 | if (ret & M41T94_BIT_HALT) { | ||
70 | buf[0] = 0x80 | M41T94_REG_HT; | ||
71 | buf[1] = ret & ~M41T94_BIT_HALT; | ||
72 | spi_write(spi, buf, 2); | ||
73 | } | ||
74 | |||
75 | /* clear stop bit */ | ||
76 | ret = spi_w8r8(spi, M41T94_REG_SECONDS); | ||
77 | if (ret < 0) | ||
78 | return ret; | ||
79 | if (ret & M41T94_BIT_STOP) { | ||
80 | buf[0] = 0x80 | M41T94_REG_SECONDS; | ||
81 | buf[1] = ret & ~M41T94_BIT_STOP; | ||
82 | spi_write(spi, buf, 2); | ||
83 | } | ||
84 | |||
85 | tm->tm_sec = BCD2BIN(spi_w8r8(spi, M41T94_REG_SECONDS)); | ||
86 | tm->tm_min = BCD2BIN(spi_w8r8(spi, M41T94_REG_MINUTES)); | ||
87 | hour = spi_w8r8(spi, M41T94_REG_HOURS); | ||
88 | tm->tm_hour = BCD2BIN(hour & 0x3f); | ||
89 | tm->tm_wday = BCD2BIN(spi_w8r8(spi, M41T94_REG_WDAY)) - 1; | ||
90 | tm->tm_mday = BCD2BIN(spi_w8r8(spi, M41T94_REG_DAY)); | ||
91 | tm->tm_mon = BCD2BIN(spi_w8r8(spi, M41T94_REG_MONTH)) - 1; | ||
92 | tm->tm_year = BCD2BIN(spi_w8r8(spi, M41T94_REG_YEAR)); | ||
93 | if ((hour & M41T94_BIT_CB) || !(hour & M41T94_BIT_CEB)) | ||
94 | tm->tm_year += 100; | ||
95 | |||
96 | dev_dbg(dev, "%s secs=%d, mins=%d, " | ||
97 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | ||
98 | "read", tm->tm_sec, tm->tm_min, | ||
99 | tm->tm_hour, tm->tm_mday, | ||
100 | tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
101 | |||
102 | /* initial clock setting can be undefined */ | ||
103 | return rtc_valid_tm(tm); | ||
104 | } | ||
105 | |||
106 | static const struct rtc_class_ops m41t94_rtc_ops = { | ||
107 | .read_time = m41t94_read_time, | ||
108 | .set_time = m41t94_set_time, | ||
109 | }; | ||
110 | |||
111 | static struct spi_driver m41t94_driver; | ||
112 | |||
113 | static int __devinit m41t94_probe(struct spi_device *spi) | ||
114 | { | ||
115 | struct rtc_device *rtc; | ||
116 | int res; | ||
117 | |||
118 | spi->bits_per_word = 8; | ||
119 | spi_setup(spi); | ||
120 | |||
121 | res = spi_w8r8(spi, M41T94_REG_SECONDS); | ||
122 | if (res < 0) { | ||
123 | dev_err(&spi->dev, "not found.\n"); | ||
124 | return res; | ||
125 | } | ||
126 | |||
127 | rtc = rtc_device_register(m41t94_driver.driver.name, | ||
128 | &spi->dev, &m41t94_rtc_ops, THIS_MODULE); | ||
129 | if (IS_ERR(rtc)) | ||
130 | return PTR_ERR(rtc); | ||
131 | |||
132 | dev_set_drvdata(&spi->dev, rtc); | ||
133 | |||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static int __devexit m41t94_remove(struct spi_device *spi) | ||
138 | { | ||
139 | struct rtc_device *rtc = platform_get_drvdata(spi); | ||
140 | |||
141 | if (rtc) | ||
142 | rtc_device_unregister(rtc); | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | static struct spi_driver m41t94_driver = { | ||
148 | .driver = { | ||
149 | .name = "rtc-m41t94", | ||
150 | .bus = &spi_bus_type, | ||
151 | .owner = THIS_MODULE, | ||
152 | }, | ||
153 | .probe = m41t94_probe, | ||
154 | .remove = __devexit_p(m41t94_remove), | ||
155 | }; | ||
156 | |||
157 | static __init int m41t94_init(void) | ||
158 | { | ||
159 | return spi_register_driver(&m41t94_driver); | ||
160 | } | ||
161 | |||
162 | module_init(m41t94_init); | ||
163 | |||
164 | static __exit void m41t94_exit(void) | ||
165 | { | ||
166 | spi_unregister_driver(&m41t94_driver); | ||
167 | } | ||
168 | |||
169 | module_exit(m41t94_exit); | ||
170 | |||
171 | MODULE_AUTHOR("Kim B. Heino <Kim.Heino@bluegiga.com>"); | ||
172 | MODULE_DESCRIPTION("Driver for ST M41T94 SPI RTC"); | ||
173 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index eb23d8423f42..8876605d4d4b 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -92,18 +92,6 @@ | |||
92 | #define rtc_write(val, addr) omap_writeb(val, OMAP_RTC_BASE + (addr)) | 92 | #define rtc_write(val, addr) omap_writeb(val, OMAP_RTC_BASE + (addr)) |
93 | 93 | ||
94 | 94 | ||
95 | /* platform_bus isn't hotpluggable, so for static linkage it'd be safe | ||
96 | * to get rid of probe() and remove() code ... too bad the driver struct | ||
97 | * remembers probe(), that's about 25% of the runtime footprint!! | ||
98 | */ | ||
99 | #ifndef MODULE | ||
100 | #undef __devexit | ||
101 | #undef __devexit_p | ||
102 | #define __devexit __exit | ||
103 | #define __devexit_p __exit_p | ||
104 | #endif | ||
105 | |||
106 | |||
107 | /* we rely on the rtc framework to handle locking (rtc->ops_lock), | 95 | /* we rely on the rtc framework to handle locking (rtc->ops_lock), |
108 | * so the only other requirement is that register accesses which | 96 | * so the only other requirement is that register accesses which |
109 | * require BUSY to be clear are made with IRQs locally disabled | 97 | * require BUSY to be clear are made with IRQs locally disabled |
@@ -324,7 +312,7 @@ static struct rtc_class_ops omap_rtc_ops = { | |||
324 | static int omap_rtc_alarm; | 312 | static int omap_rtc_alarm; |
325 | static int omap_rtc_timer; | 313 | static int omap_rtc_timer; |
326 | 314 | ||
327 | static int __devinit omap_rtc_probe(struct platform_device *pdev) | 315 | static int __init omap_rtc_probe(struct platform_device *pdev) |
328 | { | 316 | { |
329 | struct resource *res, *mem; | 317 | struct resource *res, *mem; |
330 | struct rtc_device *rtc; | 318 | struct rtc_device *rtc; |
@@ -440,7 +428,7 @@ fail: | |||
440 | return -EIO; | 428 | return -EIO; |
441 | } | 429 | } |
442 | 430 | ||
443 | static int __devexit omap_rtc_remove(struct platform_device *pdev) | 431 | static int __exit omap_rtc_remove(struct platform_device *pdev) |
444 | { | 432 | { |
445 | struct rtc_device *rtc = platform_get_drvdata(pdev);; | 433 | struct rtc_device *rtc = platform_get_drvdata(pdev);; |
446 | 434 | ||
@@ -498,8 +486,7 @@ static void omap_rtc_shutdown(struct platform_device *pdev) | |||
498 | 486 | ||
499 | MODULE_ALIAS("platform:omap_rtc"); | 487 | MODULE_ALIAS("platform:omap_rtc"); |
500 | static struct platform_driver omap_rtc_driver = { | 488 | static struct platform_driver omap_rtc_driver = { |
501 | .probe = omap_rtc_probe, | 489 | .remove = __exit_p(omap_rtc_remove), |
502 | .remove = __devexit_p(omap_rtc_remove), | ||
503 | .suspend = omap_rtc_suspend, | 490 | .suspend = omap_rtc_suspend, |
504 | .resume = omap_rtc_resume, | 491 | .resume = omap_rtc_resume, |
505 | .shutdown = omap_rtc_shutdown, | 492 | .shutdown = omap_rtc_shutdown, |
@@ -511,7 +498,7 @@ static struct platform_driver omap_rtc_driver = { | |||
511 | 498 | ||
512 | static int __init rtc_init(void) | 499 | static int __init rtc_init(void) |
513 | { | 500 | { |
514 | return platform_driver_register(&omap_rtc_driver); | 501 | return platform_driver_probe(&omap_rtc_driver, omap_rtc_probe); |
515 | } | 502 | } |
516 | module_init(rtc_init); | 503 | module_init(rtc_init); |
517 | 504 | ||
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index 3d09d8f0b1f0..d388c662bf4b 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * drivers/rtc/rtc-pcf8583.c | 2 | * drivers/rtc/rtc-pcf8583.c |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Russell King | 4 | * Copyright (C) 2000 Russell King |
5 | * Copyright (C) 2008 Wolfram Sang & Juergen Beisert, Pengutronix | ||
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 2 as | 8 | * it under the terms of the GNU General Public License version 2 as |
@@ -14,7 +15,6 @@ | |||
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
15 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
16 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
17 | #include <linux/string.h> | ||
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
@@ -27,7 +27,6 @@ struct rtc_mem { | |||
27 | }; | 27 | }; |
28 | 28 | ||
29 | struct pcf8583 { | 29 | struct pcf8583 { |
30 | struct i2c_client client; | ||
31 | struct rtc_device *rtc; | 30 | struct rtc_device *rtc; |
32 | unsigned char ctrl; | 31 | unsigned char ctrl; |
33 | }; | 32 | }; |
@@ -40,10 +39,6 @@ struct pcf8583 { | |||
40 | #define CTRL_ALARM 0x02 | 39 | #define CTRL_ALARM 0x02 |
41 | #define CTRL_TIMER 0x01 | 40 | #define CTRL_TIMER 0x01 |
42 | 41 | ||
43 | static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; | ||
44 | |||
45 | /* Module parameters */ | ||
46 | I2C_CLIENT_INSMOD; | ||
47 | 42 | ||
48 | static struct i2c_driver pcf8583_driver; | 43 | static struct i2c_driver pcf8583_driver; |
49 | 44 | ||
@@ -269,106 +264,60 @@ static const struct rtc_class_ops pcf8583_rtc_ops = { | |||
269 | .set_time = pcf8583_rtc_set_time, | 264 | .set_time = pcf8583_rtc_set_time, |
270 | }; | 265 | }; |
271 | 266 | ||
272 | static int pcf8583_probe(struct i2c_adapter *adap, int addr, int kind); | 267 | static int pcf8583_probe(struct i2c_client *client, |
273 | 268 | const struct i2c_device_id *id) | |
274 | static int pcf8583_attach(struct i2c_adapter *adap) | ||
275 | { | ||
276 | return i2c_probe(adap, &addr_data, pcf8583_probe); | ||
277 | } | ||
278 | |||
279 | static int pcf8583_detach(struct i2c_client *client) | ||
280 | { | ||
281 | int err; | ||
282 | struct pcf8583 *pcf = i2c_get_clientdata(client); | ||
283 | struct rtc_device *rtc = pcf->rtc; | ||
284 | |||
285 | if (rtc) | ||
286 | rtc_device_unregister(rtc); | ||
287 | |||
288 | if ((err = i2c_detach_client(client))) | ||
289 | return err; | ||
290 | |||
291 | kfree(pcf); | ||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | static struct i2c_driver pcf8583_driver = { | ||
296 | .driver = { | ||
297 | .name = "pcf8583", | ||
298 | }, | ||
299 | .id = I2C_DRIVERID_PCF8583, | ||
300 | .attach_adapter = pcf8583_attach, | ||
301 | .detach_client = pcf8583_detach, | ||
302 | }; | ||
303 | |||
304 | static int pcf8583_probe(struct i2c_adapter *adap, int addr, int kind) | ||
305 | { | 269 | { |
306 | struct pcf8583 *pcf; | 270 | struct pcf8583 *pcf8583; |
307 | struct i2c_client *client; | ||
308 | struct rtc_device *rtc; | ||
309 | unsigned char buf[1], ad[1] = { 0 }; | ||
310 | int err; | 271 | int err; |
311 | struct i2c_msg msgs[2] = { | ||
312 | { | ||
313 | .addr = addr, | ||
314 | .flags = 0, | ||
315 | .len = 1, | ||
316 | .buf = ad, | ||
317 | }, { | ||
318 | .addr = addr, | ||
319 | .flags = I2C_M_RD, | ||
320 | .len = 1, | ||
321 | .buf = buf, | ||
322 | } | ||
323 | }; | ||
324 | 272 | ||
325 | if (!i2c_check_functionality(adap, I2C_FUNC_I2C)) | 273 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
326 | return 0; | 274 | return -ENODEV; |
327 | 275 | ||
328 | pcf = kzalloc(sizeof(*pcf), GFP_KERNEL); | 276 | pcf8583 = kzalloc(sizeof(struct pcf8583), GFP_KERNEL); |
329 | if (!pcf) | 277 | if (!pcf8583) |
330 | return -ENOMEM; | 278 | return -ENOMEM; |
331 | 279 | ||
332 | client = &pcf->client; | 280 | pcf8583->rtc = rtc_device_register(pcf8583_driver.driver.name, |
281 | &client->dev, &pcf8583_rtc_ops, THIS_MODULE); | ||
333 | 282 | ||
334 | client->addr = addr; | 283 | if (IS_ERR(pcf8583->rtc)) { |
335 | client->adapter = adap; | 284 | err = PTR_ERR(pcf8583->rtc); |
336 | client->driver = &pcf8583_driver; | ||
337 | |||
338 | strlcpy(client->name, pcf8583_driver.driver.name, I2C_NAME_SIZE); | ||
339 | |||
340 | if (i2c_transfer(client->adapter, msgs, 2) != 2) { | ||
341 | err = -EIO; | ||
342 | goto exit_kfree; | 285 | goto exit_kfree; |
343 | } | 286 | } |
344 | 287 | ||
345 | err = i2c_attach_client(client); | 288 | i2c_set_clientdata(client, pcf8583); |
346 | 289 | return 0; | |
347 | if (err) | ||
348 | goto exit_kfree; | ||
349 | |||
350 | rtc = rtc_device_register(pcf8583_driver.driver.name, &client->dev, | ||
351 | &pcf8583_rtc_ops, THIS_MODULE); | ||
352 | 290 | ||
353 | if (IS_ERR(rtc)) { | 291 | exit_kfree: |
354 | err = PTR_ERR(rtc); | 292 | kfree(pcf8583); |
355 | goto exit_detach; | 293 | return err; |
356 | } | 294 | } |
357 | 295 | ||
358 | pcf->rtc = rtc; | 296 | static int __devexit pcf8583_remove(struct i2c_client *client) |
359 | i2c_set_clientdata(client, pcf); | 297 | { |
360 | set_ctrl(client, buf[0]); | 298 | struct pcf8583 *pcf8583 = i2c_get_clientdata(client); |
361 | 299 | ||
300 | if (pcf8583->rtc) | ||
301 | rtc_device_unregister(pcf8583->rtc); | ||
302 | kfree(pcf8583); | ||
362 | return 0; | 303 | return 0; |
304 | } | ||
363 | 305 | ||
364 | exit_detach: | 306 | static const struct i2c_device_id pcf8583_id[] = { |
365 | i2c_detach_client(client); | 307 | { "pcf8583", 0 }, |
366 | 308 | { } | |
367 | exit_kfree: | 309 | }; |
368 | kfree(pcf); | 310 | MODULE_DEVICE_TABLE(i2c, pcf8583_id); |
369 | 311 | ||
370 | return err; | 312 | static struct i2c_driver pcf8583_driver = { |
371 | } | 313 | .driver = { |
314 | .name = "pcf8583", | ||
315 | .owner = THIS_MODULE, | ||
316 | }, | ||
317 | .probe = pcf8583_probe, | ||
318 | .remove = __devexit_p(pcf8583_remove), | ||
319 | .id_table = pcf8583_id, | ||
320 | }; | ||
372 | 321 | ||
373 | static __init int pcf8583_init(void) | 322 | static __init int pcf8583_init(void) |
374 | { | 323 | { |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index fed86e507fdf..54b1ebb01502 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -36,10 +36,8 @@ static struct resource *s3c_rtc_mem; | |||
36 | static void __iomem *s3c_rtc_base; | 36 | static void __iomem *s3c_rtc_base; |
37 | static int s3c_rtc_alarmno = NO_IRQ; | 37 | static int s3c_rtc_alarmno = NO_IRQ; |
38 | static int s3c_rtc_tickno = NO_IRQ; | 38 | static int s3c_rtc_tickno = NO_IRQ; |
39 | static int s3c_rtc_freq = 1; | ||
40 | 39 | ||
41 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); | 40 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); |
42 | static unsigned int tick_count; | ||
43 | 41 | ||
44 | /* IRQ Handlers */ | 42 | /* IRQ Handlers */ |
45 | 43 | ||
@@ -55,7 +53,7 @@ static irqreturn_t s3c_rtc_tickirq(int irq, void *id) | |||
55 | { | 53 | { |
56 | struct rtc_device *rdev = id; | 54 | struct rtc_device *rdev = id; |
57 | 55 | ||
58 | rtc_update_irq(rdev, tick_count++, RTC_PF | RTC_IRQF); | 56 | rtc_update_irq(rdev, 1, RTC_PF | RTC_IRQF); |
59 | return IRQ_HANDLED; | 57 | return IRQ_HANDLED; |
60 | } | 58 | } |
61 | 59 | ||
@@ -74,35 +72,37 @@ static void s3c_rtc_setaie(int to) | |||
74 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); | 72 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); |
75 | } | 73 | } |
76 | 74 | ||
77 | static void s3c_rtc_setpie(int to) | 75 | static int s3c_rtc_setpie(struct device *dev, int enabled) |
78 | { | 76 | { |
79 | unsigned int tmp; | 77 | unsigned int tmp; |
80 | 78 | ||
81 | pr_debug("%s: pie=%d\n", __func__, to); | 79 | pr_debug("%s: pie=%d\n", __func__, enabled); |
82 | 80 | ||
83 | spin_lock_irq(&s3c_rtc_pie_lock); | 81 | spin_lock_irq(&s3c_rtc_pie_lock); |
84 | tmp = readb(s3c_rtc_base + S3C2410_TICNT) & ~S3C2410_TICNT_ENABLE; | 82 | tmp = readb(s3c_rtc_base + S3C2410_TICNT) & ~S3C2410_TICNT_ENABLE; |
85 | 83 | ||
86 | if (to) | 84 | if (enabled) |
87 | tmp |= S3C2410_TICNT_ENABLE; | 85 | tmp |= S3C2410_TICNT_ENABLE; |
88 | 86 | ||
89 | writeb(tmp, s3c_rtc_base + S3C2410_TICNT); | 87 | writeb(tmp, s3c_rtc_base + S3C2410_TICNT); |
90 | spin_unlock_irq(&s3c_rtc_pie_lock); | 88 | spin_unlock_irq(&s3c_rtc_pie_lock); |
89 | |||
90 | return 0; | ||
91 | } | 91 | } |
92 | 92 | ||
93 | static void s3c_rtc_setfreq(int freq) | 93 | static int s3c_rtc_setfreq(struct device *dev, int freq) |
94 | { | 94 | { |
95 | unsigned int tmp; | 95 | unsigned int tmp; |
96 | 96 | ||
97 | spin_lock_irq(&s3c_rtc_pie_lock); | 97 | spin_lock_irq(&s3c_rtc_pie_lock); |
98 | tmp = readb(s3c_rtc_base + S3C2410_TICNT) & S3C2410_TICNT_ENABLE; | ||
99 | |||
100 | s3c_rtc_freq = freq; | ||
101 | 98 | ||
99 | tmp = readb(s3c_rtc_base + S3C2410_TICNT) & S3C2410_TICNT_ENABLE; | ||
102 | tmp |= (128 / freq)-1; | 100 | tmp |= (128 / freq)-1; |
103 | 101 | ||
104 | writeb(tmp, s3c_rtc_base + S3C2410_TICNT); | 102 | writeb(tmp, s3c_rtc_base + S3C2410_TICNT); |
105 | spin_unlock_irq(&s3c_rtc_pie_lock); | 103 | spin_unlock_irq(&s3c_rtc_pie_lock); |
104 | |||
105 | return 0; | ||
106 | } | 106 | } |
107 | 107 | ||
108 | /* Time read/write */ | 108 | /* Time read/write */ |
@@ -267,12 +267,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
267 | 267 | ||
268 | writeb(alrm_en, base + S3C2410_RTCALM); | 268 | writeb(alrm_en, base + S3C2410_RTCALM); |
269 | 269 | ||
270 | if (0) { | 270 | s3c_rtc_setaie(alrm->enabled); |
271 | alrm_en = readb(base + S3C2410_RTCALM); | ||
272 | alrm_en &= ~S3C2410_RTCALM_ALMEN; | ||
273 | writeb(alrm_en, base + S3C2410_RTCALM); | ||
274 | disable_irq_wake(s3c_rtc_alarmno); | ||
275 | } | ||
276 | 271 | ||
277 | if (alrm->enabled) | 272 | if (alrm->enabled) |
278 | enable_irq_wake(s3c_rtc_alarmno); | 273 | enable_irq_wake(s3c_rtc_alarmno); |
@@ -282,59 +277,12 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
282 | return 0; | 277 | return 0; |
283 | } | 278 | } |
284 | 279 | ||
285 | static int s3c_rtc_ioctl(struct device *dev, | ||
286 | unsigned int cmd, unsigned long arg) | ||
287 | { | ||
288 | unsigned int ret = -ENOIOCTLCMD; | ||
289 | |||
290 | switch (cmd) { | ||
291 | case RTC_AIE_OFF: | ||
292 | case RTC_AIE_ON: | ||
293 | s3c_rtc_setaie((cmd == RTC_AIE_ON) ? 1 : 0); | ||
294 | ret = 0; | ||
295 | break; | ||
296 | |||
297 | case RTC_PIE_OFF: | ||
298 | case RTC_PIE_ON: | ||
299 | tick_count = 0; | ||
300 | s3c_rtc_setpie((cmd == RTC_PIE_ON) ? 1 : 0); | ||
301 | ret = 0; | ||
302 | break; | ||
303 | |||
304 | case RTC_IRQP_READ: | ||
305 | ret = put_user(s3c_rtc_freq, (unsigned long __user *)arg); | ||
306 | break; | ||
307 | |||
308 | case RTC_IRQP_SET: | ||
309 | if (!is_power_of_2(arg)) { | ||
310 | ret = -EINVAL; | ||
311 | goto exit; | ||
312 | } | ||
313 | |||
314 | pr_debug("s3c2410_rtc: setting frequency %ld\n", arg); | ||
315 | |||
316 | s3c_rtc_setfreq(arg); | ||
317 | ret = 0; | ||
318 | break; | ||
319 | |||
320 | case RTC_UIE_ON: | ||
321 | case RTC_UIE_OFF: | ||
322 | ret = -EINVAL; | ||
323 | } | ||
324 | |||
325 | exit: | ||
326 | return ret; | ||
327 | } | ||
328 | |||
329 | static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) | 280 | static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) |
330 | { | 281 | { |
331 | unsigned int ticnt = readb(s3c_rtc_base + S3C2410_TICNT); | 282 | unsigned int ticnt = readb(s3c_rtc_base + S3C2410_TICNT); |
332 | 283 | ||
333 | seq_printf(seq, "periodic_IRQ\t: %s\n", | 284 | seq_printf(seq, "periodic_IRQ\t: %s\n", |
334 | (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" ); | 285 | (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" ); |
335 | |||
336 | seq_printf(seq, "periodic_freq\t: %d\n", s3c_rtc_freq); | ||
337 | |||
338 | return 0; | 286 | return 0; |
339 | } | 287 | } |
340 | 288 | ||
@@ -374,7 +322,7 @@ static void s3c_rtc_release(struct device *dev) | |||
374 | 322 | ||
375 | /* do not clear AIE here, it may be needed for wake */ | 323 | /* do not clear AIE here, it may be needed for wake */ |
376 | 324 | ||
377 | s3c_rtc_setpie(0); | 325 | s3c_rtc_setpie(dev, 0); |
378 | free_irq(s3c_rtc_alarmno, rtc_dev); | 326 | free_irq(s3c_rtc_alarmno, rtc_dev); |
379 | free_irq(s3c_rtc_tickno, rtc_dev); | 327 | free_irq(s3c_rtc_tickno, rtc_dev); |
380 | } | 328 | } |
@@ -382,11 +330,12 @@ static void s3c_rtc_release(struct device *dev) | |||
382 | static const struct rtc_class_ops s3c_rtcops = { | 330 | static const struct rtc_class_ops s3c_rtcops = { |
383 | .open = s3c_rtc_open, | 331 | .open = s3c_rtc_open, |
384 | .release = s3c_rtc_release, | 332 | .release = s3c_rtc_release, |
385 | .ioctl = s3c_rtc_ioctl, | ||
386 | .read_time = s3c_rtc_gettime, | 333 | .read_time = s3c_rtc_gettime, |
387 | .set_time = s3c_rtc_settime, | 334 | .set_time = s3c_rtc_settime, |
388 | .read_alarm = s3c_rtc_getalarm, | 335 | .read_alarm = s3c_rtc_getalarm, |
389 | .set_alarm = s3c_rtc_setalarm, | 336 | .set_alarm = s3c_rtc_setalarm, |
337 | .irq_set_freq = s3c_rtc_setfreq, | ||
338 | .irq_set_state = s3c_rtc_setpie, | ||
390 | .proc = s3c_rtc_proc, | 339 | .proc = s3c_rtc_proc, |
391 | }; | 340 | }; |
392 | 341 | ||
@@ -430,14 +379,14 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en) | |||
430 | } | 379 | } |
431 | } | 380 | } |
432 | 381 | ||
433 | static int s3c_rtc_remove(struct platform_device *dev) | 382 | static int __devexit s3c_rtc_remove(struct platform_device *dev) |
434 | { | 383 | { |
435 | struct rtc_device *rtc = platform_get_drvdata(dev); | 384 | struct rtc_device *rtc = platform_get_drvdata(dev); |
436 | 385 | ||
437 | platform_set_drvdata(dev, NULL); | 386 | platform_set_drvdata(dev, NULL); |
438 | rtc_device_unregister(rtc); | 387 | rtc_device_unregister(rtc); |
439 | 388 | ||
440 | s3c_rtc_setpie(0); | 389 | s3c_rtc_setpie(&dev->dev, 0); |
441 | s3c_rtc_setaie(0); | 390 | s3c_rtc_setaie(0); |
442 | 391 | ||
443 | iounmap(s3c_rtc_base); | 392 | iounmap(s3c_rtc_base); |
@@ -447,7 +396,7 @@ static int s3c_rtc_remove(struct platform_device *dev) | |||
447 | return 0; | 396 | return 0; |
448 | } | 397 | } |
449 | 398 | ||
450 | static int s3c_rtc_probe(struct platform_device *pdev) | 399 | static int __devinit s3c_rtc_probe(struct platform_device *pdev) |
451 | { | 400 | { |
452 | struct rtc_device *rtc; | 401 | struct rtc_device *rtc; |
453 | struct resource *res; | 402 | struct resource *res; |
@@ -504,7 +453,7 @@ static int s3c_rtc_probe(struct platform_device *pdev) | |||
504 | pr_debug("s3c2410_rtc: RTCCON=%02x\n", | 453 | pr_debug("s3c2410_rtc: RTCCON=%02x\n", |
505 | readb(s3c_rtc_base + S3C2410_RTCCON)); | 454 | readb(s3c_rtc_base + S3C2410_RTCCON)); |
506 | 455 | ||
507 | s3c_rtc_setfreq(s3c_rtc_freq); | 456 | s3c_rtc_setfreq(&pdev->dev, 1); |
508 | 457 | ||
509 | /* register RTC and exit */ | 458 | /* register RTC and exit */ |
510 | 459 | ||
@@ -560,7 +509,7 @@ static int s3c_rtc_resume(struct platform_device *pdev) | |||
560 | 509 | ||
561 | static struct platform_driver s3c2410_rtcdrv = { | 510 | static struct platform_driver s3c2410_rtcdrv = { |
562 | .probe = s3c_rtc_probe, | 511 | .probe = s3c_rtc_probe, |
563 | .remove = s3c_rtc_remove, | 512 | .remove = __devexit_p(s3c_rtc_remove), |
564 | .suspend = s3c_rtc_suspend, | 513 | .suspend = s3c_rtc_suspend, |
565 | .resume = s3c_rtc_resume, | 514 | .resume = s3c_rtc_resume, |
566 | .driver = { | 515 | .driver = { |
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index be9c70d0b193..884b635f028b 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for NEC VR4100 series Real Time Clock unit. | 2 | * Driver for NEC VR4100 series Real Time Clock unit. |
3 | * | 3 | * |
4 | * Copyright (C) 2003-2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | 4 | * Copyright (C) 2003-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 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 | 7 | * it under the terms of the GNU General Public License as published by |
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>"); | 35 | MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>"); |
36 | MODULE_DESCRIPTION("NEC VR4100 series RTC driver"); | 36 | MODULE_DESCRIPTION("NEC VR4100 series RTC driver"); |
37 | MODULE_LICENSE("GPL"); | 37 | MODULE_LICENSE("GPL v2"); |
38 | 38 | ||
39 | /* RTC 1 registers */ | 39 | /* RTC 1 registers */ |
40 | #define ETIMELREG 0x00 | 40 | #define ETIMELREG 0x00 |
@@ -82,7 +82,6 @@ static unsigned long epoch = 1970; /* Jan 1 1970 00:00:00 */ | |||
82 | 82 | ||
83 | static DEFINE_SPINLOCK(rtc_lock); | 83 | static DEFINE_SPINLOCK(rtc_lock); |
84 | static char rtc_name[] = "RTC"; | 84 | static char rtc_name[] = "RTC"; |
85 | static unsigned long periodic_frequency; | ||
86 | static unsigned long periodic_count; | 85 | static unsigned long periodic_count; |
87 | static unsigned int alarm_enabled; | 86 | static unsigned int alarm_enabled; |
88 | static int aie_irq = -1; | 87 | static int aie_irq = -1; |
@@ -207,10 +206,37 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
207 | return 0; | 206 | return 0; |
208 | } | 207 | } |
209 | 208 | ||
210 | static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 209 | static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq) |
211 | { | 210 | { |
212 | unsigned long count; | 211 | unsigned long count; |
213 | 212 | ||
213 | count = RTC_FREQUENCY; | ||
214 | do_div(count, freq); | ||
215 | |||
216 | periodic_count = count; | ||
217 | |||
218 | spin_lock_irq(&rtc_lock); | ||
219 | |||
220 | rtc1_write(RTCL1LREG, count); | ||
221 | rtc1_write(RTCL1HREG, count >> 16); | ||
222 | |||
223 | spin_unlock_irq(&rtc_lock); | ||
224 | |||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | static int vr41xx_rtc_irq_set_state(struct device *dev, int enabled) | ||
229 | { | ||
230 | if (enabled) | ||
231 | enable_irq(pie_irq); | ||
232 | else | ||
233 | disable_irq(pie_irq); | ||
234 | |||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
239 | { | ||
214 | switch (cmd) { | 240 | switch (cmd) { |
215 | case RTC_AIE_ON: | 241 | case RTC_AIE_ON: |
216 | spin_lock_irq(&rtc_lock); | 242 | spin_lock_irq(&rtc_lock); |
@@ -232,33 +258,6 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long | |||
232 | 258 | ||
233 | spin_unlock_irq(&rtc_lock); | 259 | spin_unlock_irq(&rtc_lock); |
234 | break; | 260 | break; |
235 | case RTC_PIE_ON: | ||
236 | enable_irq(pie_irq); | ||
237 | break; | ||
238 | case RTC_PIE_OFF: | ||
239 | disable_irq(pie_irq); | ||
240 | break; | ||
241 | case RTC_IRQP_READ: | ||
242 | return put_user(periodic_frequency, (unsigned long __user *)arg); | ||
243 | break; | ||
244 | case RTC_IRQP_SET: | ||
245 | if (arg > MAX_PERIODIC_RATE) | ||
246 | return -EINVAL; | ||
247 | |||
248 | periodic_frequency = arg; | ||
249 | |||
250 | count = RTC_FREQUENCY; | ||
251 | do_div(count, arg); | ||
252 | |||
253 | periodic_count = count; | ||
254 | |||
255 | spin_lock_irq(&rtc_lock); | ||
256 | |||
257 | rtc1_write(RTCL1LREG, count); | ||
258 | rtc1_write(RTCL1HREG, count >> 16); | ||
259 | |||
260 | spin_unlock_irq(&rtc_lock); | ||
261 | break; | ||
262 | case RTC_EPOCH_READ: | 261 | case RTC_EPOCH_READ: |
263 | return put_user(epoch, (unsigned long __user *)arg); | 262 | return put_user(epoch, (unsigned long __user *)arg); |
264 | case RTC_EPOCH_SET: | 263 | case RTC_EPOCH_SET: |
@@ -309,6 +308,8 @@ static const struct rtc_class_ops vr41xx_rtc_ops = { | |||
309 | .set_time = vr41xx_rtc_set_time, | 308 | .set_time = vr41xx_rtc_set_time, |
310 | .read_alarm = vr41xx_rtc_read_alarm, | 309 | .read_alarm = vr41xx_rtc_read_alarm, |
311 | .set_alarm = vr41xx_rtc_set_alarm, | 310 | .set_alarm = vr41xx_rtc_set_alarm, |
311 | .irq_set_freq = vr41xx_rtc_irq_set_freq, | ||
312 | .irq_set_state = vr41xx_rtc_irq_set_state, | ||
312 | }; | 313 | }; |
313 | 314 | ||
314 | static int __devinit rtc_probe(struct platform_device *pdev) | 315 | static int __devinit rtc_probe(struct platform_device *pdev) |
@@ -346,6 +347,8 @@ static int __devinit rtc_probe(struct platform_device *pdev) | |||
346 | goto err_iounmap_all; | 347 | goto err_iounmap_all; |
347 | } | 348 | } |
348 | 349 | ||
350 | rtc->max_user_freq = MAX_PERIODIC_RATE; | ||
351 | |||
349 | spin_lock_irq(&rtc_lock); | 352 | spin_lock_irq(&rtc_lock); |
350 | 353 | ||
351 | rtc1_write(ECMPLREG, 0); | 354 | rtc1_write(ECMPLREG, 0); |
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index 5ab34340919b..79954bd6bfa5 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/virtio.h> | 16 | #include <linux/virtio.h> |
17 | #include <linux/virtio_config.h> | 17 | #include <linux/virtio_config.h> |
18 | #include <linux/virtio_console.h> | ||
18 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
19 | #include <linux/virtio_ring.h> | 20 | #include <linux/virtio_ring.h> |
20 | #include <linux/pfn.h> | 21 | #include <linux/pfn.h> |
@@ -87,16 +88,20 @@ static u32 kvm_get_features(struct virtio_device *vdev) | |||
87 | return features; | 88 | return features; |
88 | } | 89 | } |
89 | 90 | ||
90 | static void kvm_set_features(struct virtio_device *vdev, u32 features) | 91 | static void kvm_finalize_features(struct virtio_device *vdev) |
91 | { | 92 | { |
92 | unsigned int i; | 93 | unsigned int i, bits; |
93 | struct kvm_device_desc *desc = to_kvmdev(vdev)->desc; | 94 | struct kvm_device_desc *desc = to_kvmdev(vdev)->desc; |
94 | /* Second half of bitmap is features we accept. */ | 95 | /* Second half of bitmap is features we accept. */ |
95 | u8 *out_features = kvm_vq_features(desc) + desc->feature_len; | 96 | u8 *out_features = kvm_vq_features(desc) + desc->feature_len; |
96 | 97 | ||
98 | /* Give virtio_ring a chance to accept features. */ | ||
99 | vring_transport_features(vdev); | ||
100 | |||
97 | memset(out_features, 0, desc->feature_len); | 101 | memset(out_features, 0, desc->feature_len); |
98 | for (i = 0; i < min(desc->feature_len * 8, 32); i++) { | 102 | bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; |
99 | if (features & (1 << i)) | 103 | for (i = 0; i < bits; i++) { |
104 | if (test_bit(i, vdev->features)) | ||
100 | out_features[i / 8] |= (1 << (i % 8)); | 105 | out_features[i / 8] |= (1 << (i % 8)); |
101 | } | 106 | } |
102 | } | 107 | } |
@@ -222,7 +227,7 @@ static void kvm_del_vq(struct virtqueue *vq) | |||
222 | */ | 227 | */ |
223 | static struct virtio_config_ops kvm_vq_configspace_ops = { | 228 | static struct virtio_config_ops kvm_vq_configspace_ops = { |
224 | .get_features = kvm_get_features, | 229 | .get_features = kvm_get_features, |
225 | .set_features = kvm_set_features, | 230 | .finalize_features = kvm_finalize_features, |
226 | .get = kvm_get, | 231 | .get = kvm_get, |
227 | .set = kvm_set, | 232 | .set = kvm_set, |
228 | .get_status = kvm_get_status, | 233 | .get_status = kvm_get_status, |
@@ -333,6 +338,25 @@ static int __init kvm_devices_init(void) | |||
333 | return 0; | 338 | return 0; |
334 | } | 339 | } |
335 | 340 | ||
341 | /* code for early console output with virtio_console */ | ||
342 | static __init int early_put_chars(u32 vtermno, const char *buf, int count) | ||
343 | { | ||
344 | char scratch[17]; | ||
345 | unsigned int len = count; | ||
346 | |||
347 | if (len > sizeof(scratch) - 1) | ||
348 | len = sizeof(scratch) - 1; | ||
349 | scratch[len] = '\0'; | ||
350 | memcpy(scratch, buf, len); | ||
351 | kvm_hypercall1(KVM_S390_VIRTIO_NOTIFY, __pa(scratch)); | ||
352 | return len; | ||
353 | } | ||
354 | |||
355 | void s390_virtio_console_init(void) | ||
356 | { | ||
357 | virtio_cons_early_init(early_put_chars); | ||
358 | } | ||
359 | |||
336 | /* | 360 | /* |
337 | * We do this after core stuff, but before the drivers. | 361 | * We do this after core stuff, but before the drivers. |
338 | */ | 362 | */ |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 538552495d48..b40a673985aa 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -101,8 +101,13 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk) | |||
101 | 101 | ||
102 | mutex_lock(&idescsi_ref_mutex); | 102 | mutex_lock(&idescsi_ref_mutex); |
103 | scsi = ide_scsi_g(disk); | 103 | scsi = ide_scsi_g(disk); |
104 | if (scsi) | 104 | if (scsi) { |
105 | scsi_host_get(scsi->host); | 105 | scsi_host_get(scsi->host); |
106 | if (ide_device_get(scsi->drive)) { | ||
107 | scsi_host_put(scsi->host); | ||
108 | scsi = NULL; | ||
109 | } | ||
110 | } | ||
106 | mutex_unlock(&idescsi_ref_mutex); | 111 | mutex_unlock(&idescsi_ref_mutex); |
107 | return scsi; | 112 | return scsi; |
108 | } | 113 | } |
@@ -110,6 +115,7 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk) | |||
110 | static void ide_scsi_put(struct ide_scsi_obj *scsi) | 115 | static void ide_scsi_put(struct ide_scsi_obj *scsi) |
111 | { | 116 | { |
112 | mutex_lock(&idescsi_ref_mutex); | 117 | mutex_lock(&idescsi_ref_mutex); |
118 | ide_device_put(scsi->drive); | ||
113 | scsi_host_put(scsi->host); | 119 | scsi_host_put(scsi->host); |
114 | mutex_unlock(&idescsi_ref_mutex); | 120 | mutex_unlock(&idescsi_ref_mutex); |
115 | } | 121 | } |
@@ -201,15 +207,15 @@ static int idescsi_check_condition(ide_drive_t *drive, | |||
201 | 207 | ||
202 | /* stuff a sense request in front of our current request */ | 208 | /* stuff a sense request in front of our current request */ |
203 | pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); | 209 | pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); |
204 | rq = kmalloc(sizeof(struct request), GFP_ATOMIC); | 210 | rq = blk_get_request(drive->queue, READ, GFP_ATOMIC); |
205 | buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); | 211 | buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); |
206 | if (!pc || !rq || !buf) { | 212 | if (!pc || !rq || !buf) { |
207 | kfree(buf); | 213 | kfree(buf); |
208 | kfree(rq); | 214 | if (rq) |
215 | blk_put_request(rq); | ||
209 | kfree(pc); | 216 | kfree(pc); |
210 | return -ENOMEM; | 217 | return -ENOMEM; |
211 | } | 218 | } |
212 | blk_rq_init(NULL, rq); | ||
213 | rq->special = (char *) pc; | 219 | rq->special = (char *) pc; |
214 | pc->rq = rq; | 220 | pc->rq = rq; |
215 | pc->buf = buf; | 221 | pc->buf = buf; |
@@ -226,6 +232,7 @@ static int idescsi_check_condition(ide_drive_t *drive, | |||
226 | ide_scsi_hex_dump(pc->c, 6); | 232 | ide_scsi_hex_dump(pc->c, 6); |
227 | } | 233 | } |
228 | rq->rq_disk = scsi->disk; | 234 | rq->rq_disk = scsi->disk; |
235 | rq->ref_count++; | ||
229 | memcpy(rq->cmd, pc->c, 12); | 236 | memcpy(rq->cmd, pc->c, 12); |
230 | ide_do_drive_cmd(drive, rq); | 237 | ide_do_drive_cmd(drive, rq); |
231 | return 0; | 238 | return 0; |
@@ -272,7 +279,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs) | |||
272 | SCSI_SENSE_BUFFERSIZE); | 279 | SCSI_SENSE_BUFFERSIZE); |
273 | kfree(pc->buf); | 280 | kfree(pc->buf); |
274 | kfree(pc); | 281 | kfree(pc); |
275 | kfree(rq); | 282 | blk_put_request(rq); |
276 | pc = opc; | 283 | pc = opc; |
277 | rq = pc->rq; | 284 | rq = pc->rq; |
278 | pc->scsi_cmd->result = (CHECK_CONDITION << 1) | | 285 | pc->scsi_cmd->result = (CHECK_CONDITION << 1) | |
@@ -303,7 +310,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs) | |||
303 | pc->done(pc->scsi_cmd); | 310 | pc->done(pc->scsi_cmd); |
304 | spin_unlock_irqrestore(host->host_lock, flags); | 311 | spin_unlock_irqrestore(host->host_lock, flags); |
305 | kfree(pc); | 312 | kfree(pc); |
306 | kfree(rq); | 313 | blk_put_request(rq); |
307 | scsi->pc = NULL; | 314 | scsi->pc = NULL; |
308 | return 0; | 315 | return 0; |
309 | } | 316 | } |
@@ -577,6 +584,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
577 | ide_drive_t *drive = scsi->drive; | 584 | ide_drive_t *drive = scsi->drive; |
578 | struct request *rq = NULL; | 585 | struct request *rq = NULL; |
579 | struct ide_atapi_pc *pc = NULL; | 586 | struct ide_atapi_pc *pc = NULL; |
587 | int write = cmd->sc_data_direction == DMA_TO_DEVICE; | ||
580 | 588 | ||
581 | if (!drive) { | 589 | if (!drive) { |
582 | scmd_printk (KERN_ERR, cmd, "drive not present\n"); | 590 | scmd_printk (KERN_ERR, cmd, "drive not present\n"); |
@@ -584,7 +592,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
584 | } | 592 | } |
585 | scsi = drive_to_idescsi(drive); | 593 | scsi = drive_to_idescsi(drive); |
586 | pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); | 594 | pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); |
587 | rq = kmalloc(sizeof(struct request), GFP_ATOMIC); | 595 | rq = blk_get_request(drive->queue, write, GFP_ATOMIC); |
588 | if (rq == NULL || pc == NULL) { | 596 | if (rq == NULL || pc == NULL) { |
589 | printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name); | 597 | printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name); |
590 | goto abort; | 598 | goto abort; |
@@ -614,17 +622,18 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
614 | } | 622 | } |
615 | } | 623 | } |
616 | 624 | ||
617 | blk_rq_init(NULL, rq); | ||
618 | rq->special = (char *) pc; | 625 | rq->special = (char *) pc; |
619 | rq->cmd_type = REQ_TYPE_SPECIAL; | 626 | rq->cmd_type = REQ_TYPE_SPECIAL; |
620 | spin_unlock_irq(host->host_lock); | 627 | spin_unlock_irq(host->host_lock); |
628 | rq->ref_count++; | ||
621 | memcpy(rq->cmd, pc->c, 12); | 629 | memcpy(rq->cmd, pc->c, 12); |
622 | blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); | 630 | blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); |
623 | spin_lock_irq(host->host_lock); | 631 | spin_lock_irq(host->host_lock); |
624 | return 0; | 632 | return 0; |
625 | abort: | 633 | abort: |
626 | kfree (pc); | 634 | kfree (pc); |
627 | kfree (rq); | 635 | if (rq) |
636 | blk_put_request(rq); | ||
628 | cmd->result = DID_ERROR << 16; | 637 | cmd->result = DID_ERROR << 16; |
629 | done(cmd); | 638 | done(cmd); |
630 | return 0; | 639 | return 0; |
@@ -672,7 +681,9 @@ static int idescsi_eh_abort (struct scsi_cmnd *cmd) | |||
672 | 681 | ||
673 | if (blk_sense_request(scsi->pc->rq)) | 682 | if (blk_sense_request(scsi->pc->rq)) |
674 | kfree(scsi->pc->buf); | 683 | kfree(scsi->pc->buf); |
675 | kfree(scsi->pc->rq); | 684 | /* we need to call blk_put_request twice. */ |
685 | blk_put_request(scsi->pc->rq); | ||
686 | blk_put_request(scsi->pc->rq); | ||
676 | kfree(scsi->pc); | 687 | kfree(scsi->pc); |
677 | scsi->pc = NULL; | 688 | scsi->pc = NULL; |
678 | 689 | ||
@@ -724,7 +735,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd) | |||
724 | kfree(scsi->pc->buf); | 735 | kfree(scsi->pc->buf); |
725 | kfree(scsi->pc); | 736 | kfree(scsi->pc); |
726 | scsi->pc = NULL; | 737 | scsi->pc = NULL; |
727 | kfree(req); | 738 | blk_put_request(req); |
728 | 739 | ||
729 | /* now nuke the drive queue */ | 740 | /* now nuke the drive queue */ |
730 | while ((req = elv_next_request(drive->queue))) { | 741 | while ((req = elv_next_request(drive->queue))) { |
diff --git a/drivers/scsi/sun_esp.c b/drivers/scsi/sun_esp.c index 2c87db98cdfb..f9cf70151366 100644 --- a/drivers/scsi/sun_esp.c +++ b/drivers/scsi/sun_esp.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/types.h> | 7 | #include <linux/types.h> |
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/mm.h> | ||
10 | #include <linux/init.h> | 11 | #include <linux/init.h> |
11 | 12 | ||
12 | #include <asm/irq.h> | 13 | #include <asm/irq.h> |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 27f34a9f9cb7..a97f1ae11f78 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -1293,7 +1293,18 @@ receive_chars(struct uart_8250_port *up, unsigned int *status) | |||
1293 | char flag; | 1293 | char flag; |
1294 | 1294 | ||
1295 | do { | 1295 | do { |
1296 | ch = serial_inp(up, UART_RX); | 1296 | if (likely(lsr & UART_LSR_DR)) |
1297 | ch = serial_inp(up, UART_RX); | ||
1298 | else | ||
1299 | /* | ||
1300 | * Intel 82571 has a Serial Over Lan device that will | ||
1301 | * set UART_LSR_BI without setting UART_LSR_DR when | ||
1302 | * it receives a break. To avoid reading from the | ||
1303 | * receive buffer without UART_LSR_DR bit set, we | ||
1304 | * just force the read character to be 0 | ||
1305 | */ | ||
1306 | ch = 0; | ||
1307 | |||
1297 | flag = TTY_NORMAL; | 1308 | flag = TTY_NORMAL; |
1298 | up->port.icount.rx++; | 1309 | up->port.icount.rx++; |
1299 | 1310 | ||
@@ -1342,7 +1353,7 @@ receive_chars(struct uart_8250_port *up, unsigned int *status) | |||
1342 | 1353 | ||
1343 | ignore_char: | 1354 | ignore_char: |
1344 | lsr = serial_inp(up, UART_LSR); | 1355 | lsr = serial_inp(up, UART_LSR); |
1345 | } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); | 1356 | } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); |
1346 | spin_unlock(&up->port.lock); | 1357 | spin_unlock(&up->port.lock); |
1347 | tty_flip_buffer_push(tty); | 1358 | tty_flip_buffer_push(tty); |
1348 | spin_lock(&up->port.lock); | 1359 | spin_lock(&up->port.lock); |
@@ -1425,7 +1436,7 @@ serial8250_handle_port(struct uart_8250_port *up) | |||
1425 | 1436 | ||
1426 | DEBUG_INTR("status = %x...", status); | 1437 | DEBUG_INTR("status = %x...", status); |
1427 | 1438 | ||
1428 | if (status & UART_LSR_DR) | 1439 | if (status & (UART_LSR_DR | UART_LSR_BI)) |
1429 | receive_chars(up, &status); | 1440 | receive_chars(up, &status); |
1430 | check_modem_status(up); | 1441 | check_modem_status(up); |
1431 | if (status & UART_LSR_THRE) | 1442 | if (status & UART_LSR_THRE) |
diff --git a/drivers/serial/8250_gsc.c b/drivers/serial/8250_gsc.c index 4eb7437a404a..0416ad3bc127 100644 --- a/drivers/serial/8250_gsc.c +++ b/drivers/serial/8250_gsc.c | |||
@@ -119,3 +119,5 @@ int __init probe_serial_gsc(void) | |||
119 | } | 119 | } |
120 | 120 | ||
121 | module_init(probe_serial_gsc); | 121 | module_init(probe_serial_gsc); |
122 | |||
123 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index 1b36087665a2..c2f23933155b 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c | |||
@@ -767,6 +767,9 @@ pci_default_setup(struct serial_private *priv, struct pciserial_board *board, | |||
767 | #define PCI_SUBDEVICE_ID_POCTAL232 0x0308 | 767 | #define PCI_SUBDEVICE_ID_POCTAL232 0x0308 |
768 | #define PCI_SUBDEVICE_ID_POCTAL422 0x0408 | 768 | #define PCI_SUBDEVICE_ID_POCTAL422 0x0408 |
769 | 769 | ||
770 | /* Unknown vendors/cards - this should not be in linux/pci_ids.h */ | ||
771 | #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 | ||
772 | |||
770 | /* | 773 | /* |
771 | * Master list of serial port init/setup/exit quirks. | 774 | * Master list of serial port init/setup/exit quirks. |
772 | * This does not describe the general nature of the port. | 775 | * This does not describe the general nature of the port. |
@@ -882,6 +885,15 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { | |||
882 | }, | 885 | }, |
883 | { | 886 | { |
884 | .vendor = PCI_VENDOR_ID_PLX, | 887 | .vendor = PCI_VENDOR_ID_PLX, |
888 | .device = PCI_DEVICE_ID_PLX_9050, | ||
889 | .subvendor = PCI_VENDOR_ID_PLX, | ||
890 | .subdevice = PCI_SUBDEVICE_ID_UNKNOWN_0x1584, | ||
891 | .init = pci_plx9050_init, | ||
892 | .setup = pci_default_setup, | ||
893 | .exit = __devexit_p(pci_plx9050_exit), | ||
894 | }, | ||
895 | { | ||
896 | .vendor = PCI_VENDOR_ID_PLX, | ||
885 | .device = PCI_DEVICE_ID_PLX_ROMULUS, | 897 | .device = PCI_DEVICE_ID_PLX_ROMULUS, |
886 | .subvendor = PCI_VENDOR_ID_PLX, | 898 | .subvendor = PCI_VENDOR_ID_PLX, |
887 | .subdevice = PCI_DEVICE_ID_PLX_ROMULUS, | 899 | .subdevice = PCI_DEVICE_ID_PLX_ROMULUS, |
@@ -2197,6 +2209,11 @@ static struct pci_device_id serial_pci_tbl[] = { | |||
2197 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_1077, | 2209 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_1077, |
2198 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 2210 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
2199 | pbn_b2_4_921600 }, | 2211 | pbn_b2_4_921600 }, |
2212 | /* Unknown card - subdevice 0x1584 */ | ||
2213 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, | ||
2214 | PCI_VENDOR_ID_PLX, | ||
2215 | PCI_SUBDEVICE_ID_UNKNOWN_0x1584, 0, 0, | ||
2216 | pbn_b0_4_115200 }, | ||
2200 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, | 2217 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, |
2201 | PCI_SUBVENDOR_ID_KEYSPAN, | 2218 | PCI_SUBVENDOR_ID_KEYSPAN, |
2202 | PCI_SUBDEVICE_ID_KEYSPAN_SX2, 0, 0, | 2219 | PCI_SUBDEVICE_ID_KEYSPAN_SX2, 0, 0, |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 8fc7451c0049..3b4a14e355c1 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -942,22 +942,6 @@ config SERIAL_IP22_ZILOG_CONSOLE | |||
942 | depends on SERIAL_IP22_ZILOG=y | 942 | depends on SERIAL_IP22_ZILOG=y |
943 | select SERIAL_CORE_CONSOLE | 943 | select SERIAL_CORE_CONSOLE |
944 | 944 | ||
945 | config V850E_UART | ||
946 | bool "NEC V850E on-chip UART support" | ||
947 | depends on V850E_MA1 || V850E_ME2 || V850E_TEG || V850E2_ANNA || V850E_AS85EP1 | ||
948 | select SERIAL_CORE | ||
949 | default y | ||
950 | |||
951 | config V850E_UARTB | ||
952 | bool | ||
953 | depends on V850E_UART && V850E_ME2 | ||
954 | default y | ||
955 | |||
956 | config V850E_UART_CONSOLE | ||
957 | bool "Use NEC V850E on-chip UART for console" | ||
958 | depends on V850E_UART | ||
959 | select SERIAL_CORE_CONSOLE | ||
960 | |||
961 | config SERIAL_SH_SCI | 945 | config SERIAL_SH_SCI |
962 | tristate "SuperH SCI(F) serial port support" | 946 | tristate "SuperH SCI(F) serial port support" |
963 | depends on SUPERH || H8300 | 947 | depends on SUPERH || H8300 |
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index 1ff80de177db..a4f86927a74b 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c | |||
@@ -435,10 +435,13 @@ static void cpm_uart_shutdown(struct uart_port *port) | |||
435 | } | 435 | } |
436 | 436 | ||
437 | /* Shut them really down and reinit buffer descriptors */ | 437 | /* Shut them really down and reinit buffer descriptors */ |
438 | if (IS_SMC(pinfo)) | 438 | if (IS_SMC(pinfo)) { |
439 | out_be16(&pinfo->smcup->smc_brkcr, 0); | ||
439 | cpm_line_cr_cmd(pinfo, CPM_CR_STOP_TX); | 440 | cpm_line_cr_cmd(pinfo, CPM_CR_STOP_TX); |
440 | else | 441 | } else { |
442 | out_be16(&pinfo->sccup->scc_brkcr, 0); | ||
441 | cpm_line_cr_cmd(pinfo, CPM_CR_GRA_STOP_TX); | 443 | cpm_line_cr_cmd(pinfo, CPM_CR_GRA_STOP_TX); |
444 | } | ||
442 | 445 | ||
443 | cpm_uart_initbd(pinfo); | 446 | cpm_uart_initbd(pinfo); |
444 | } | 447 | } |
@@ -554,9 +557,11 @@ static void cpm_uart_set_termios(struct uart_port *port, | |||
554 | * enables, because we want to put them back if they were | 557 | * enables, because we want to put them back if they were |
555 | * present. | 558 | * present. |
556 | */ | 559 | */ |
557 | prev_mode = in_be16(&smcp->smc_smcmr); | 560 | prev_mode = in_be16(&smcp->smc_smcmr) & (SMCMR_REN | SMCMR_TEN); |
558 | out_be16(&smcp->smc_smcmr, smcr_mk_clen(bits) | cval | SMCMR_SM_UART); | 561 | /* Output in *one* operation, so we don't interrupt RX/TX if they |
559 | setbits16(&smcp->smc_smcmr, (prev_mode & (SMCMR_REN | SMCMR_TEN))); | 562 | * were already enabled. */ |
563 | out_be16(&smcp->smc_smcmr, smcr_mk_clen(bits) | cval | | ||
564 | SMCMR_SM_UART | prev_mode); | ||
560 | } else { | 565 | } else { |
561 | out_be16(&sccp->scc_psmr, (sbits << 12) | scval); | 566 | out_be16(&sccp->scc_psmr, (sbits << 12) | scval); |
562 | } | 567 | } |
@@ -1198,12 +1203,14 @@ static int __init cpm_uart_console_setup(struct console *co, char *options) | |||
1198 | udbg_putc = NULL; | 1203 | udbg_putc = NULL; |
1199 | #endif | 1204 | #endif |
1200 | 1205 | ||
1201 | cpm_line_cr_cmd(pinfo, CPM_CR_STOP_TX); | ||
1202 | |||
1203 | if (IS_SMC(pinfo)) { | 1206 | if (IS_SMC(pinfo)) { |
1207 | out_be16(&pinfo->smcup->smc_brkcr, 0); | ||
1208 | cpm_line_cr_cmd(pinfo, CPM_CR_STOP_TX); | ||
1204 | clrbits8(&pinfo->smcp->smc_smcm, SMCM_RX | SMCM_TX); | 1209 | clrbits8(&pinfo->smcp->smc_smcm, SMCM_RX | SMCM_TX); |
1205 | clrbits16(&pinfo->smcp->smc_smcmr, SMCMR_REN | SMCMR_TEN); | 1210 | clrbits16(&pinfo->smcp->smc_smcmr, SMCMR_REN | SMCMR_TEN); |
1206 | } else { | 1211 | } else { |
1212 | out_be16(&pinfo->sccup->scc_brkcr, 0); | ||
1213 | cpm_line_cr_cmd(pinfo, CPM_CR_GRA_STOP_TX); | ||
1207 | clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_TX | UART_SCCM_RX); | 1214 | clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_TX | UART_SCCM_RX); |
1208 | clrbits32(&pinfo->sccp->scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT); | 1215 | clrbits32(&pinfo->sccp->scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT); |
1209 | } | 1216 | } |
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c index a81d2c2ff8a2..6042b87797a1 100644 --- a/drivers/serial/dz.c +++ b/drivers/serial/dz.c | |||
@@ -642,6 +642,26 @@ static void dz_set_termios(struct uart_port *uport, struct ktermios *termios, | |||
642 | spin_unlock_irqrestore(&dport->port.lock, flags); | 642 | spin_unlock_irqrestore(&dport->port.lock, flags); |
643 | } | 643 | } |
644 | 644 | ||
645 | /* | ||
646 | * Hack alert! | ||
647 | * Required solely so that the initial PROM-based console | ||
648 | * works undisturbed in parallel with this one. | ||
649 | */ | ||
650 | static void dz_pm(struct uart_port *uport, unsigned int state, | ||
651 | unsigned int oldstate) | ||
652 | { | ||
653 | struct dz_port *dport = to_dport(uport); | ||
654 | unsigned long flags; | ||
655 | |||
656 | spin_lock_irqsave(&dport->port.lock, flags); | ||
657 | if (state < 3) | ||
658 | dz_start_tx(&dport->port); | ||
659 | else | ||
660 | dz_stop_tx(&dport->port); | ||
661 | spin_unlock_irqrestore(&dport->port.lock, flags); | ||
662 | } | ||
663 | |||
664 | |||
645 | static const char *dz_type(struct uart_port *uport) | 665 | static const char *dz_type(struct uart_port *uport) |
646 | { | 666 | { |
647 | return "DZ"; | 667 | return "DZ"; |
@@ -738,6 +758,7 @@ static struct uart_ops dz_ops = { | |||
738 | .startup = dz_startup, | 758 | .startup = dz_startup, |
739 | .shutdown = dz_shutdown, | 759 | .shutdown = dz_shutdown, |
740 | .set_termios = dz_set_termios, | 760 | .set_termios = dz_set_termios, |
761 | .pm = dz_pm, | ||
741 | .type = dz_type, | 762 | .type = dz_type, |
742 | .release_port = dz_release_port, | 763 | .release_port = dz_release_port, |
743 | .request_port = dz_request_port, | 764 | .request_port = dz_request_port, |
@@ -861,7 +882,10 @@ static int __init dz_console_setup(struct console *co, char *options) | |||
861 | if (ret) | 882 | if (ret) |
862 | return ret; | 883 | return ret; |
863 | 884 | ||
885 | spin_lock_init(&dport->port.lock); /* For dz_pm(). */ | ||
886 | |||
864 | dz_reset(dport); | 887 | dz_reset(dport); |
888 | dz_pm(uport, 0, -1); | ||
865 | 889 | ||
866 | if (options) | 890 | if (options) |
867 | uart_parse_options(options, &baud, &parity, &bits, &flow); | 891 | uart_parse_options(options, &baud, &parity, &bits, &flow); |
diff --git a/drivers/serial/zs.c b/drivers/serial/zs.c index bd45b6230fd8..9e6a873f8203 100644 --- a/drivers/serial/zs.c +++ b/drivers/serial/zs.c | |||
@@ -787,7 +787,6 @@ static int zs_startup(struct uart_port *uport) | |||
787 | zport->regs[1] &= ~RxINT_MASK; | 787 | zport->regs[1] &= ~RxINT_MASK; |
788 | zport->regs[1] |= RxINT_ALL | TxINT_ENAB | EXT_INT_ENAB; | 788 | zport->regs[1] |= RxINT_ALL | TxINT_ENAB | EXT_INT_ENAB; |
789 | zport->regs[3] |= RxENABLE; | 789 | zport->regs[3] |= RxENABLE; |
790 | zport->regs[5] |= TxENAB; | ||
791 | zport->regs[15] |= BRKIE; | 790 | zport->regs[15] |= BRKIE; |
792 | write_zsreg(zport, R1, zport->regs[1]); | 791 | write_zsreg(zport, R1, zport->regs[1]); |
793 | write_zsreg(zport, R3, zport->regs[3]); | 792 | write_zsreg(zport, R3, zport->regs[3]); |
@@ -814,7 +813,6 @@ static void zs_shutdown(struct uart_port *uport) | |||
814 | 813 | ||
815 | spin_lock_irqsave(&scc->zlock, flags); | 814 | spin_lock_irqsave(&scc->zlock, flags); |
816 | 815 | ||
817 | zport->regs[5] &= ~TxENAB; | ||
818 | zport->regs[3] &= ~RxENABLE; | 816 | zport->regs[3] &= ~RxENABLE; |
819 | write_zsreg(zport, R5, zport->regs[5]); | 817 | write_zsreg(zport, R5, zport->regs[5]); |
820 | write_zsreg(zport, R3, zport->regs[3]); | 818 | write_zsreg(zport, R3, zport->regs[3]); |
@@ -959,6 +957,23 @@ static void zs_set_termios(struct uart_port *uport, struct ktermios *termios, | |||
959 | spin_unlock_irqrestore(&scc->zlock, flags); | 957 | spin_unlock_irqrestore(&scc->zlock, flags); |
960 | } | 958 | } |
961 | 959 | ||
960 | /* | ||
961 | * Hack alert! | ||
962 | * Required solely so that the initial PROM-based console | ||
963 | * works undisturbed in parallel with this one. | ||
964 | */ | ||
965 | static void zs_pm(struct uart_port *uport, unsigned int state, | ||
966 | unsigned int oldstate) | ||
967 | { | ||
968 | struct zs_port *zport = to_zport(uport); | ||
969 | |||
970 | if (state < 3) | ||
971 | zport->regs[5] |= TxENAB; | ||
972 | else | ||
973 | zport->regs[5] &= ~TxENAB; | ||
974 | write_zsreg(zport, R5, zport->regs[5]); | ||
975 | } | ||
976 | |||
962 | 977 | ||
963 | static const char *zs_type(struct uart_port *uport) | 978 | static const char *zs_type(struct uart_port *uport) |
964 | { | 979 | { |
@@ -1041,6 +1056,7 @@ static struct uart_ops zs_ops = { | |||
1041 | .startup = zs_startup, | 1056 | .startup = zs_startup, |
1042 | .shutdown = zs_shutdown, | 1057 | .shutdown = zs_shutdown, |
1043 | .set_termios = zs_set_termios, | 1058 | .set_termios = zs_set_termios, |
1059 | .pm = zs_pm, | ||
1044 | .type = zs_type, | 1060 | .type = zs_type, |
1045 | .release_port = zs_release_port, | 1061 | .release_port = zs_release_port, |
1046 | .request_port = zs_request_port, | 1062 | .request_port = zs_request_port, |
@@ -1190,6 +1206,7 @@ static int __init zs_console_setup(struct console *co, char *options) | |||
1190 | return ret; | 1206 | return ret; |
1191 | 1207 | ||
1192 | zs_reset(zport); | 1208 | zs_reset(zport); |
1209 | zs_pm(uport, 0, -1); | ||
1193 | 1210 | ||
1194 | if (options) | 1211 | if (options) |
1195 | uart_parse_options(options, &baud, &parity, &bits, &flow); | 1212 | uart_parse_options(options, &baud, &parity, &bits, &flow); |
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 66ec5d8808de..2303521b4f09 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -49,25 +49,26 @@ config SPI_MASTER | |||
49 | controller and the protocol drivers for the SPI slave chips | 49 | controller and the protocol drivers for the SPI slave chips |
50 | that are connected. | 50 | that are connected. |
51 | 51 | ||
52 | if SPI_MASTER | ||
53 | |||
52 | comment "SPI Master Controller Drivers" | 54 | comment "SPI Master Controller Drivers" |
53 | depends on SPI_MASTER | ||
54 | 55 | ||
55 | config SPI_ATMEL | 56 | config SPI_ATMEL |
56 | tristate "Atmel SPI Controller" | 57 | tristate "Atmel SPI Controller" |
57 | depends on (ARCH_AT91 || AVR32) && SPI_MASTER | 58 | depends on (ARCH_AT91 || AVR32) |
58 | help | 59 | help |
59 | This selects a driver for the Atmel SPI Controller, present on | 60 | This selects a driver for the Atmel SPI Controller, present on |
60 | many AT32 (AVR32) and AT91 (ARM) chips. | 61 | many AT32 (AVR32) and AT91 (ARM) chips. |
61 | 62 | ||
62 | config SPI_BFIN | 63 | config SPI_BFIN |
63 | tristate "SPI controller driver for ADI Blackfin5xx" | 64 | tristate "SPI controller driver for ADI Blackfin5xx" |
64 | depends on SPI_MASTER && BLACKFIN | 65 | depends on BLACKFIN |
65 | help | 66 | help |
66 | This is the SPI controller master driver for Blackfin 5xx processor. | 67 | This is the SPI controller master driver for Blackfin 5xx processor. |
67 | 68 | ||
68 | config SPI_AU1550 | 69 | config SPI_AU1550 |
69 | tristate "Au1550/Au12x0 SPI Controller" | 70 | tristate "Au1550/Au12x0 SPI Controller" |
70 | depends on SPI_MASTER && (SOC_AU1550 || SOC_AU1200) && EXPERIMENTAL | 71 | depends on (SOC_AU1550 || SOC_AU1200) && EXPERIMENTAL |
71 | select SPI_BITBANG | 72 | select SPI_BITBANG |
72 | help | 73 | help |
73 | If you say yes to this option, support will be included for the | 74 | If you say yes to this option, support will be included for the |
@@ -78,7 +79,6 @@ config SPI_AU1550 | |||
78 | 79 | ||
79 | config SPI_BITBANG | 80 | config SPI_BITBANG |
80 | tristate "Bitbanging SPI master" | 81 | tristate "Bitbanging SPI master" |
81 | depends on SPI_MASTER && EXPERIMENTAL | ||
82 | help | 82 | help |
83 | With a few GPIO pins, your system can bitbang the SPI protocol. | 83 | With a few GPIO pins, your system can bitbang the SPI protocol. |
84 | Select this to get SPI support through I/O pins (GPIO, parallel | 84 | Select this to get SPI support through I/O pins (GPIO, parallel |
@@ -92,7 +92,7 @@ config SPI_BITBANG | |||
92 | 92 | ||
93 | config SPI_BUTTERFLY | 93 | config SPI_BUTTERFLY |
94 | tristate "Parallel port adapter for AVR Butterfly (DEVELOPMENT)" | 94 | tristate "Parallel port adapter for AVR Butterfly (DEVELOPMENT)" |
95 | depends on SPI_MASTER && PARPORT && EXPERIMENTAL | 95 | depends on PARPORT |
96 | select SPI_BITBANG | 96 | select SPI_BITBANG |
97 | help | 97 | help |
98 | This uses a custom parallel port cable to connect to an AVR | 98 | This uses a custom parallel port cable to connect to an AVR |
@@ -102,14 +102,14 @@ config SPI_BUTTERFLY | |||
102 | 102 | ||
103 | config SPI_IMX | 103 | config SPI_IMX |
104 | tristate "Freescale iMX SPI controller" | 104 | tristate "Freescale iMX SPI controller" |
105 | depends on SPI_MASTER && ARCH_IMX && EXPERIMENTAL | 105 | depends on ARCH_IMX && EXPERIMENTAL |
106 | help | 106 | help |
107 | This enables using the Freescale iMX SPI controller in master | 107 | This enables using the Freescale iMX SPI controller in master |
108 | mode. | 108 | mode. |
109 | 109 | ||
110 | config SPI_LM70_LLP | 110 | config SPI_LM70_LLP |
111 | tristate "Parallel port adapter for LM70 eval board (DEVELOPMENT)" | 111 | tristate "Parallel port adapter for LM70 eval board (DEVELOPMENT)" |
112 | depends on SPI_MASTER && PARPORT && EXPERIMENTAL | 112 | depends on PARPORT && EXPERIMENTAL |
113 | select SPI_BITBANG | 113 | select SPI_BITBANG |
114 | help | 114 | help |
115 | This driver supports the NS LM70 LLP Evaluation Board, | 115 | This driver supports the NS LM70 LLP Evaluation Board, |
@@ -118,14 +118,14 @@ config SPI_LM70_LLP | |||
118 | 118 | ||
119 | config SPI_MPC52xx_PSC | 119 | config SPI_MPC52xx_PSC |
120 | tristate "Freescale MPC52xx PSC SPI controller" | 120 | tristate "Freescale MPC52xx PSC SPI controller" |
121 | depends on SPI_MASTER && PPC_MPC52xx && EXPERIMENTAL | 121 | depends on PPC_MPC52xx && EXPERIMENTAL |
122 | help | 122 | help |
123 | This enables using the Freescale MPC52xx Programmable Serial | 123 | This enables using the Freescale MPC52xx Programmable Serial |
124 | Controller in master SPI mode. | 124 | Controller in master SPI mode. |
125 | 125 | ||
126 | config SPI_MPC83xx | 126 | config SPI_MPC83xx |
127 | tristate "Freescale MPC83xx/QUICC Engine SPI controller" | 127 | tristate "Freescale MPC83xx/QUICC Engine SPI controller" |
128 | depends on SPI_MASTER && (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL | 128 | depends on (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL |
129 | help | 129 | help |
130 | This enables using the Freescale MPC83xx and QUICC Engine SPI | 130 | This enables using the Freescale MPC83xx and QUICC Engine SPI |
131 | controllers in master mode. | 131 | controllers in master mode. |
@@ -137,21 +137,21 @@ config SPI_MPC83xx | |||
137 | 137 | ||
138 | config SPI_OMAP_UWIRE | 138 | config SPI_OMAP_UWIRE |
139 | tristate "OMAP1 MicroWire" | 139 | tristate "OMAP1 MicroWire" |
140 | depends on SPI_MASTER && ARCH_OMAP1 | 140 | depends on ARCH_OMAP1 |
141 | select SPI_BITBANG | 141 | select SPI_BITBANG |
142 | help | 142 | help |
143 | This hooks up to the MicroWire controller on OMAP1 chips. | 143 | This hooks up to the MicroWire controller on OMAP1 chips. |
144 | 144 | ||
145 | config SPI_OMAP24XX | 145 | config SPI_OMAP24XX |
146 | tristate "McSPI driver for OMAP24xx/OMAP34xx" | 146 | tristate "McSPI driver for OMAP24xx/OMAP34xx" |
147 | depends on SPI_MASTER && (ARCH_OMAP24XX || ARCH_OMAP34XX) | 147 | depends on ARCH_OMAP24XX || ARCH_OMAP34XX |
148 | help | 148 | help |
149 | SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI | 149 | SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI |
150 | (McSPI) modules. | 150 | (McSPI) modules. |
151 | 151 | ||
152 | config SPI_PXA2XX | 152 | config SPI_PXA2XX |
153 | tristate "PXA2xx SSP SPI master" | 153 | tristate "PXA2xx SSP SPI master" |
154 | depends on SPI_MASTER && ARCH_PXA && EXPERIMENTAL | 154 | depends on ARCH_PXA && EXPERIMENTAL |
155 | select PXA_SSP | 155 | select PXA_SSP |
156 | help | 156 | help |
157 | This enables using a PXA2xx SSP port as a SPI master controller. | 157 | This enables using a PXA2xx SSP port as a SPI master controller. |
@@ -160,14 +160,14 @@ config SPI_PXA2XX | |||
160 | 160 | ||
161 | config SPI_S3C24XX | 161 | config SPI_S3C24XX |
162 | tristate "Samsung S3C24XX series SPI" | 162 | tristate "Samsung S3C24XX series SPI" |
163 | depends on SPI_MASTER && ARCH_S3C2410 && EXPERIMENTAL | 163 | depends on ARCH_S3C2410 && EXPERIMENTAL |
164 | select SPI_BITBANG | 164 | select SPI_BITBANG |
165 | help | 165 | help |
166 | SPI driver for Samsung S3C24XX series ARM SoCs | 166 | SPI driver for Samsung S3C24XX series ARM SoCs |
167 | 167 | ||
168 | config SPI_S3C24XX_GPIO | 168 | config SPI_S3C24XX_GPIO |
169 | tristate "Samsung S3C24XX series SPI by GPIO" | 169 | tristate "Samsung S3C24XX series SPI by GPIO" |
170 | depends on SPI_MASTER && ARCH_S3C2410 && EXPERIMENTAL | 170 | depends on ARCH_S3C2410 && EXPERIMENTAL |
171 | select SPI_BITBANG | 171 | select SPI_BITBANG |
172 | help | 172 | help |
173 | SPI driver for Samsung S3C24XX series ARM SoCs using | 173 | SPI driver for Samsung S3C24XX series ARM SoCs using |
@@ -177,20 +177,20 @@ config SPI_S3C24XX_GPIO | |||
177 | 177 | ||
178 | config SPI_SH_SCI | 178 | config SPI_SH_SCI |
179 | tristate "SuperH SCI SPI controller" | 179 | tristate "SuperH SCI SPI controller" |
180 | depends on SPI_MASTER && SUPERH | 180 | depends on SUPERH |
181 | select SPI_BITBANG | 181 | select SPI_BITBANG |
182 | help | 182 | help |
183 | SPI driver for SuperH SCI blocks. | 183 | SPI driver for SuperH SCI blocks. |
184 | 184 | ||
185 | config SPI_TXX9 | 185 | config SPI_TXX9 |
186 | tristate "Toshiba TXx9 SPI controller" | 186 | tristate "Toshiba TXx9 SPI controller" |
187 | depends on SPI_MASTER && GENERIC_GPIO && CPU_TX49XX | 187 | depends on GENERIC_GPIO && CPU_TX49XX |
188 | help | 188 | help |
189 | SPI driver for Toshiba TXx9 MIPS SoCs | 189 | SPI driver for Toshiba TXx9 MIPS SoCs |
190 | 190 | ||
191 | config SPI_XILINX | 191 | config SPI_XILINX |
192 | tristate "Xilinx SPI controller" | 192 | tristate "Xilinx SPI controller" |
193 | depends on SPI_MASTER && XILINX_VIRTEX && EXPERIMENTAL | 193 | depends on XILINX_VIRTEX && EXPERIMENTAL |
194 | select SPI_BITBANG | 194 | select SPI_BITBANG |
195 | help | 195 | help |
196 | This exposes the SPI controller IP from the Xilinx EDK. | 196 | This exposes the SPI controller IP from the Xilinx EDK. |
@@ -207,11 +207,10 @@ config SPI_XILINX | |||
207 | # being probably the most widely used ones. | 207 | # being probably the most widely used ones. |
208 | # | 208 | # |
209 | comment "SPI Protocol Masters" | 209 | comment "SPI Protocol Masters" |
210 | depends on SPI_MASTER | ||
211 | 210 | ||
212 | config SPI_AT25 | 211 | config SPI_AT25 |
213 | tristate "SPI EEPROMs from most vendors" | 212 | tristate "SPI EEPROMs from most vendors" |
214 | depends on SPI_MASTER && SYSFS | 213 | depends on SYSFS |
215 | help | 214 | help |
216 | Enable this driver to get read/write support to most SPI EEPROMs, | 215 | Enable this driver to get read/write support to most SPI EEPROMs, |
217 | after you configure the board init code to know about each eeprom | 216 | after you configure the board init code to know about each eeprom |
@@ -222,7 +221,7 @@ config SPI_AT25 | |||
222 | 221 | ||
223 | config SPI_SPIDEV | 222 | config SPI_SPIDEV |
224 | tristate "User mode SPI device driver support" | 223 | tristate "User mode SPI device driver support" |
225 | depends on SPI_MASTER && EXPERIMENTAL | 224 | depends on EXPERIMENTAL |
226 | help | 225 | help |
227 | This supports user mode SPI protocol drivers. | 226 | This supports user mode SPI protocol drivers. |
228 | 227 | ||
@@ -231,7 +230,7 @@ config SPI_SPIDEV | |||
231 | 230 | ||
232 | config SPI_TLE62X0 | 231 | config SPI_TLE62X0 |
233 | tristate "Infineon TLE62X0 (for power switching)" | 232 | tristate "Infineon TLE62X0 (for power switching)" |
234 | depends on SPI_MASTER && SYSFS | 233 | depends on SYSFS |
235 | help | 234 | help |
236 | SPI driver for Infineon TLE62X0 series line driver chips, | 235 | SPI driver for Infineon TLE62X0 series line driver chips, |
237 | such as the TLE6220, TLE6230 and TLE6240. This provides a | 236 | such as the TLE6220, TLE6230 and TLE6240. This provides a |
@@ -242,6 +241,8 @@ config SPI_TLE62X0 | |||
242 | # Add new SPI protocol masters in alphabetical order above this line | 241 | # Add new SPI protocol masters in alphabetical order above this line |
243 | # | 242 | # |
244 | 243 | ||
244 | endif # SPI_MASTER | ||
245 | |||
245 | # (slave support would go here) | 246 | # (slave support would go here) |
246 | 247 | ||
247 | endif # SPI | 248 | endif # SPI |
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c index 072c4a595334..9149689c79d9 100644 --- a/drivers/spi/au1550_spi.c +++ b/drivers/spi/au1550_spi.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/device.h> | 27 | #include <linux/device.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/resource.h> | ||
29 | #include <linux/spi/spi.h> | 30 | #include <linux/spi/spi.h> |
30 | #include <linux/spi/spi_bitbang.h> | 31 | #include <linux/spi/spi_bitbang.h> |
31 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
@@ -81,6 +82,7 @@ struct au1550_spi { | |||
81 | struct spi_master *master; | 82 | struct spi_master *master; |
82 | struct device *dev; | 83 | struct device *dev; |
83 | struct au1550_spi_info *pdata; | 84 | struct au1550_spi_info *pdata; |
85 | struct resource *ioarea; | ||
84 | }; | 86 | }; |
85 | 87 | ||
86 | 88 | ||
@@ -96,6 +98,8 @@ static dbdev_tab_t au1550_spi_mem_dbdev = | |||
96 | .dev_intpolarity = 0 | 98 | .dev_intpolarity = 0 |
97 | }; | 99 | }; |
98 | 100 | ||
101 | static int ddma_memid; /* id to above mem dma device */ | ||
102 | |||
99 | static void au1550_spi_bits_handlers_set(struct au1550_spi *hw, int bpw); | 103 | static void au1550_spi_bits_handlers_set(struct au1550_spi *hw, int bpw); |
100 | 104 | ||
101 | 105 | ||
@@ -480,9 +484,13 @@ static irqreturn_t au1550_spi_dma_irq_callback(struct au1550_spi *hw) | |||
480 | au1xxx_dbdma_reset(hw->dma_tx_ch); | 484 | au1xxx_dbdma_reset(hw->dma_tx_ch); |
481 | au1550_spi_reset_fifos(hw); | 485 | au1550_spi_reset_fifos(hw); |
482 | 486 | ||
483 | dev_err(hw->dev, | 487 | if (evnt == PSC_SPIEVNT_RO) |
484 | "Unexpected SPI error: event=0x%x stat=0x%x!\n", | 488 | dev_err(hw->dev, |
485 | evnt, stat); | 489 | "dma transfer: receive FIFO overflow!\n"); |
490 | else | ||
491 | dev_err(hw->dev, | ||
492 | "dma transfer: unexpected SPI error " | ||
493 | "(event=0x%x stat=0x%x)!\n", evnt, stat); | ||
486 | 494 | ||
487 | complete(&hw->master_done); | 495 | complete(&hw->master_done); |
488 | return IRQ_HANDLED; | 496 | return IRQ_HANDLED; |
@@ -592,17 +600,17 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw) | |||
592 | 600 | ||
593 | if ((evnt & (PSC_SPIEVNT_MM | PSC_SPIEVNT_RO | 601 | if ((evnt & (PSC_SPIEVNT_MM | PSC_SPIEVNT_RO |
594 | | PSC_SPIEVNT_RU | PSC_SPIEVNT_TO | 602 | | PSC_SPIEVNT_RU | PSC_SPIEVNT_TO |
595 | | PSC_SPIEVNT_TU | PSC_SPIEVNT_SD)) | 603 | | PSC_SPIEVNT_SD)) |
596 | != 0) { | 604 | != 0) { |
597 | dev_err(hw->dev, | ||
598 | "Unexpected SPI error: event=0x%x stat=0x%x!\n", | ||
599 | evnt, stat); | ||
600 | /* | 605 | /* |
601 | * due to an error we consider transfer as done, | 606 | * due to an error we consider transfer as done, |
602 | * so mask all events until before next transfer start | 607 | * so mask all events until before next transfer start |
603 | */ | 608 | */ |
604 | au1550_spi_mask_ack_all(hw); | 609 | au1550_spi_mask_ack_all(hw); |
605 | au1550_spi_reset_fifos(hw); | 610 | au1550_spi_reset_fifos(hw); |
611 | dev_err(hw->dev, | ||
612 | "pio transfer: unexpected SPI error " | ||
613 | "(event=0x%x stat=0x%x)!\n", evnt, stat); | ||
606 | complete(&hw->master_done); | 614 | complete(&hw->master_done); |
607 | return IRQ_HANDLED; | 615 | return IRQ_HANDLED; |
608 | } | 616 | } |
@@ -616,27 +624,50 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw) | |||
616 | stat = hw->regs->psc_spistat; | 624 | stat = hw->regs->psc_spistat; |
617 | au_sync(); | 625 | au_sync(); |
618 | 626 | ||
619 | if ((stat & PSC_SPISTAT_RE) == 0 && hw->rx_count < hw->len) { | 627 | /* |
628 | * Take care to not let the Rx FIFO overflow. | ||
629 | * | ||
630 | * We only write a byte if we have read one at least. Initially, | ||
631 | * the write fifo is full, so we should read from the read fifo | ||
632 | * first. | ||
633 | * In case we miss a word from the read fifo, we should get a | ||
634 | * RO event and should back out. | ||
635 | */ | ||
636 | if (!(stat & PSC_SPISTAT_RE) && hw->rx_count < hw->len) { | ||
620 | hw->rx_word(hw); | 637 | hw->rx_word(hw); |
621 | /* ack the receive request event */ | ||
622 | hw->regs->psc_spievent = PSC_SPIEVNT_RR; | ||
623 | au_sync(); | ||
624 | busy = 1; | 638 | busy = 1; |
625 | } | ||
626 | 639 | ||
627 | if ((stat & PSC_SPISTAT_TF) == 0 && hw->tx_count < hw->len) { | 640 | if (!(stat & PSC_SPISTAT_TF) && hw->tx_count < hw->len) |
628 | hw->tx_word(hw); | 641 | hw->tx_word(hw); |
629 | /* ack the transmit request event */ | ||
630 | hw->regs->psc_spievent = PSC_SPIEVNT_TR; | ||
631 | au_sync(); | ||
632 | busy = 1; | ||
633 | } | 642 | } |
634 | } while (busy); | 643 | } while (busy); |
635 | 644 | ||
636 | evnt = hw->regs->psc_spievent; | 645 | hw->regs->psc_spievent = PSC_SPIEVNT_RR | PSC_SPIEVNT_TR; |
637 | au_sync(); | 646 | au_sync(); |
638 | 647 | ||
639 | if (hw->rx_count >= hw->len || (evnt & PSC_SPIEVNT_MD) != 0) { | 648 | /* |
649 | * Restart the SPI transmission in case of a transmit underflow. | ||
650 | * This seems to work despite the notes in the Au1550 data book | ||
651 | * of Figure 8-4 with flowchart for SPI master operation: | ||
652 | * | ||
653 | * """Note 1: An XFR Error Interrupt occurs, unless masked, | ||
654 | * for any of the following events: Tx FIFO Underflow, | ||
655 | * Rx FIFO Overflow, or Multiple-master Error | ||
656 | * Note 2: In case of a Tx Underflow Error, all zeroes are | ||
657 | * transmitted.""" | ||
658 | * | ||
659 | * By simply restarting the spi transfer on Tx Underflow Error, | ||
660 | * we assume that spi transfer was paused instead of zeroes | ||
661 | * transmittion mentioned in the Note 2 of Au1550 data book. | ||
662 | */ | ||
663 | if (evnt & PSC_SPIEVNT_TU) { | ||
664 | hw->regs->psc_spievent = PSC_SPIEVNT_TU | PSC_SPIEVNT_MD; | ||
665 | au_sync(); | ||
666 | hw->regs->psc_spipcr = PSC_SPIPCR_MS; | ||
667 | au_sync(); | ||
668 | } | ||
669 | |||
670 | if (hw->rx_count >= hw->len) { | ||
640 | /* transfer completed successfully */ | 671 | /* transfer completed successfully */ |
641 | au1550_spi_mask_ack_all(hw); | 672 | au1550_spi_mask_ack_all(hw); |
642 | complete(&hw->master_done); | 673 | complete(&hw->master_done); |
@@ -725,6 +756,8 @@ static void __init au1550_spi_setup_psc_as_spi(struct au1550_spi *hw) | |||
725 | stat = hw->regs->psc_spistat; | 756 | stat = hw->regs->psc_spistat; |
726 | au_sync(); | 757 | au_sync(); |
727 | } while ((stat & PSC_SPISTAT_DR) == 0); | 758 | } while ((stat & PSC_SPISTAT_DR) == 0); |
759 | |||
760 | au1550_spi_reset_fifos(hw); | ||
728 | } | 761 | } |
729 | 762 | ||
730 | 763 | ||
@@ -732,6 +765,7 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
732 | { | 765 | { |
733 | struct au1550_spi *hw; | 766 | struct au1550_spi *hw; |
734 | struct spi_master *master; | 767 | struct spi_master *master; |
768 | struct resource *r; | ||
735 | int err = 0; | 769 | int err = 0; |
736 | 770 | ||
737 | master = spi_alloc_master(&pdev->dev, sizeof(struct au1550_spi)); | 771 | master = spi_alloc_master(&pdev->dev, sizeof(struct au1550_spi)); |
@@ -753,76 +787,64 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
753 | goto err_no_pdata; | 787 | goto err_no_pdata; |
754 | } | 788 | } |
755 | 789 | ||
756 | platform_set_drvdata(pdev, hw); | 790 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
757 | 791 | if (!r) { | |
758 | init_completion(&hw->master_done); | 792 | dev_err(&pdev->dev, "no IRQ\n"); |
759 | 793 | err = -ENODEV; | |
760 | hw->bitbang.master = hw->master; | 794 | goto err_no_iores; |
761 | hw->bitbang.setup_transfer = au1550_spi_setupxfer; | 795 | } |
762 | hw->bitbang.chipselect = au1550_spi_chipsel; | 796 | hw->irq = r->start; |
763 | hw->bitbang.master->setup = au1550_spi_setup; | 797 | |
764 | hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs; | 798 | hw->usedma = 0; |
799 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
800 | if (r) { | ||
801 | hw->dma_tx_id = r->start; | ||
802 | r = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
803 | if (r) { | ||
804 | hw->dma_rx_id = r->start; | ||
805 | if (usedma && ddma_memid) { | ||
806 | if (pdev->dev.dma_mask == NULL) | ||
807 | dev_warn(&pdev->dev, "no dma mask\n"); | ||
808 | else | ||
809 | hw->usedma = 1; | ||
810 | } | ||
811 | } | ||
812 | } | ||
765 | 813 | ||
766 | switch (hw->pdata->bus_num) { | 814 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
767 | case 0: | 815 | if (!r) { |
768 | hw->irq = AU1550_PSC0_INT; | 816 | dev_err(&pdev->dev, "no mmio resource\n"); |
769 | hw->regs = (volatile psc_spi_t *)PSC0_BASE_ADDR; | 817 | err = -ENODEV; |
770 | hw->dma_rx_id = DSCR_CMD0_PSC0_RX; | 818 | goto err_no_iores; |
771 | hw->dma_tx_id = DSCR_CMD0_PSC0_TX; | ||
772 | break; | ||
773 | case 1: | ||
774 | hw->irq = AU1550_PSC1_INT; | ||
775 | hw->regs = (volatile psc_spi_t *)PSC1_BASE_ADDR; | ||
776 | hw->dma_rx_id = DSCR_CMD0_PSC1_RX; | ||
777 | hw->dma_tx_id = DSCR_CMD0_PSC1_TX; | ||
778 | break; | ||
779 | case 2: | ||
780 | hw->irq = AU1550_PSC2_INT; | ||
781 | hw->regs = (volatile psc_spi_t *)PSC2_BASE_ADDR; | ||
782 | hw->dma_rx_id = DSCR_CMD0_PSC2_RX; | ||
783 | hw->dma_tx_id = DSCR_CMD0_PSC2_TX; | ||
784 | break; | ||
785 | case 3: | ||
786 | hw->irq = AU1550_PSC3_INT; | ||
787 | hw->regs = (volatile psc_spi_t *)PSC3_BASE_ADDR; | ||
788 | hw->dma_rx_id = DSCR_CMD0_PSC3_RX; | ||
789 | hw->dma_tx_id = DSCR_CMD0_PSC3_TX; | ||
790 | break; | ||
791 | default: | ||
792 | dev_err(&pdev->dev, "Wrong bus_num of SPI\n"); | ||
793 | err = -ENOENT; | ||
794 | goto err_no_pdata; | ||
795 | } | 819 | } |
796 | 820 | ||
797 | if (request_mem_region((unsigned long)hw->regs, sizeof(psc_spi_t), | 821 | hw->ioarea = request_mem_region(r->start, sizeof(psc_spi_t), |
798 | pdev->name) == NULL) { | 822 | pdev->name); |
823 | if (!hw->ioarea) { | ||
799 | dev_err(&pdev->dev, "Cannot reserve iomem region\n"); | 824 | dev_err(&pdev->dev, "Cannot reserve iomem region\n"); |
800 | err = -ENXIO; | 825 | err = -ENXIO; |
801 | goto err_no_iores; | 826 | goto err_no_iores; |
802 | } | 827 | } |
803 | 828 | ||
804 | 829 | hw->regs = (psc_spi_t __iomem *)ioremap(r->start, sizeof(psc_spi_t)); | |
805 | if (usedma) { | 830 | if (!hw->regs) { |
806 | if (pdev->dev.dma_mask == NULL) | 831 | dev_err(&pdev->dev, "cannot ioremap\n"); |
807 | dev_warn(&pdev->dev, "no dma mask\n"); | 832 | err = -ENXIO; |
808 | else | 833 | goto err_ioremap; |
809 | hw->usedma = 1; | ||
810 | } | 834 | } |
811 | 835 | ||
812 | if (hw->usedma) { | 836 | platform_set_drvdata(pdev, hw); |
813 | /* | 837 | |
814 | * create memory device with 8 bits dev_devwidth | 838 | init_completion(&hw->master_done); |
815 | * needed for proper byte ordering to spi fifo | 839 | |
816 | */ | 840 | hw->bitbang.master = hw->master; |
817 | int memid = au1xxx_ddma_add_device(&au1550_spi_mem_dbdev); | 841 | hw->bitbang.setup_transfer = au1550_spi_setupxfer; |
818 | if (!memid) { | 842 | hw->bitbang.chipselect = au1550_spi_chipsel; |
819 | dev_err(&pdev->dev, | 843 | hw->bitbang.master->setup = au1550_spi_setup; |
820 | "Cannot create dma 8 bit mem device\n"); | 844 | hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs; |
821 | err = -ENXIO; | ||
822 | goto err_dma_add_dev; | ||
823 | } | ||
824 | 845 | ||
825 | hw->dma_tx_ch = au1xxx_dbdma_chan_alloc(memid, | 846 | if (hw->usedma) { |
847 | hw->dma_tx_ch = au1xxx_dbdma_chan_alloc(ddma_memid, | ||
826 | hw->dma_tx_id, NULL, (void *)hw); | 848 | hw->dma_tx_id, NULL, (void *)hw); |
827 | if (hw->dma_tx_ch == 0) { | 849 | if (hw->dma_tx_ch == 0) { |
828 | dev_err(&pdev->dev, | 850 | dev_err(&pdev->dev, |
@@ -841,7 +863,7 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
841 | 863 | ||
842 | 864 | ||
843 | hw->dma_rx_ch = au1xxx_dbdma_chan_alloc(hw->dma_rx_id, | 865 | hw->dma_rx_ch = au1xxx_dbdma_chan_alloc(hw->dma_rx_id, |
844 | memid, NULL, (void *)hw); | 866 | ddma_memid, NULL, (void *)hw); |
845 | if (hw->dma_rx_ch == 0) { | 867 | if (hw->dma_rx_ch == 0) { |
846 | dev_err(&pdev->dev, | 868 | dev_err(&pdev->dev, |
847 | "Cannot allocate rx dma channel\n"); | 869 | "Cannot allocate rx dma channel\n"); |
@@ -874,7 +896,7 @@ static int __init au1550_spi_probe(struct platform_device *pdev) | |||
874 | goto err_no_irq; | 896 | goto err_no_irq; |
875 | } | 897 | } |
876 | 898 | ||
877 | master->bus_num = hw->pdata->bus_num; | 899 | master->bus_num = pdev->id; |
878 | master->num_chipselect = hw->pdata->num_chipselect; | 900 | master->num_chipselect = hw->pdata->num_chipselect; |
879 | 901 | ||
880 | /* | 902 | /* |
@@ -924,8 +946,11 @@ err_no_txdma_descr: | |||
924 | au1xxx_dbdma_chan_free(hw->dma_tx_ch); | 946 | au1xxx_dbdma_chan_free(hw->dma_tx_ch); |
925 | 947 | ||
926 | err_no_txdma: | 948 | err_no_txdma: |
927 | err_dma_add_dev: | 949 | iounmap((void __iomem *)hw->regs); |
928 | release_mem_region((unsigned long)hw->regs, sizeof(psc_spi_t)); | 950 | |
951 | err_ioremap: | ||
952 | release_resource(hw->ioarea); | ||
953 | kfree(hw->ioarea); | ||
929 | 954 | ||
930 | err_no_iores: | 955 | err_no_iores: |
931 | err_no_pdata: | 956 | err_no_pdata: |
@@ -944,7 +969,9 @@ static int __exit au1550_spi_remove(struct platform_device *pdev) | |||
944 | 969 | ||
945 | spi_bitbang_stop(&hw->bitbang); | 970 | spi_bitbang_stop(&hw->bitbang); |
946 | free_irq(hw->irq, hw); | 971 | free_irq(hw->irq, hw); |
947 | release_mem_region((unsigned long)hw->regs, sizeof(psc_spi_t)); | 972 | iounmap((void __iomem *)hw->regs); |
973 | release_resource(hw->ioarea); | ||
974 | kfree(hw->ioarea); | ||
948 | 975 | ||
949 | if (hw->usedma) { | 976 | if (hw->usedma) { |
950 | au1550_spi_dma_rxtmp_free(hw); | 977 | au1550_spi_dma_rxtmp_free(hw); |
@@ -971,12 +998,24 @@ static struct platform_driver au1550_spi_drv = { | |||
971 | 998 | ||
972 | static int __init au1550_spi_init(void) | 999 | static int __init au1550_spi_init(void) |
973 | { | 1000 | { |
1001 | /* | ||
1002 | * create memory device with 8 bits dev_devwidth | ||
1003 | * needed for proper byte ordering to spi fifo | ||
1004 | */ | ||
1005 | if (usedma) { | ||
1006 | ddma_memid = au1xxx_ddma_add_device(&au1550_spi_mem_dbdev); | ||
1007 | if (!ddma_memid) | ||
1008 | printk(KERN_ERR "au1550-spi: cannot add memory" | ||
1009 | "dbdma device\n"); | ||
1010 | } | ||
974 | return platform_driver_probe(&au1550_spi_drv, au1550_spi_probe); | 1011 | return platform_driver_probe(&au1550_spi_drv, au1550_spi_probe); |
975 | } | 1012 | } |
976 | module_init(au1550_spi_init); | 1013 | module_init(au1550_spi_init); |
977 | 1014 | ||
978 | static void __exit au1550_spi_exit(void) | 1015 | static void __exit au1550_spi_exit(void) |
979 | { | 1016 | { |
1017 | if (usedma && ddma_memid) | ||
1018 | au1xxx_ddma_del_device(ddma_memid); | ||
980 | platform_driver_unregister(&au1550_spi_drv); | 1019 | platform_driver_unregister(&au1550_spi_drv); |
981 | } | 1020 | } |
982 | module_exit(au1550_spi_exit); | 1021 | module_exit(au1550_spi_exit); |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 1771b2456bfa..ecca4a6a6f94 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -218,6 +218,8 @@ struct spi_device *spi_new_device(struct spi_master *master, | |||
218 | if (!spi_master_get(master)) | 218 | if (!spi_master_get(master)) |
219 | return NULL; | 219 | return NULL; |
220 | 220 | ||
221 | WARN_ON(strlen(chip->modalias) >= sizeof(proxy->modalias)); | ||
222 | |||
221 | proxy = kzalloc(sizeof *proxy, GFP_KERNEL); | 223 | proxy = kzalloc(sizeof *proxy, GFP_KERNEL); |
222 | if (!proxy) { | 224 | if (!proxy) { |
223 | dev_err(dev, "can't alloc dev for cs%d\n", | 225 | dev_err(dev, "can't alloc dev for cs%d\n", |
@@ -229,7 +231,7 @@ struct spi_device *spi_new_device(struct spi_master *master, | |||
229 | proxy->max_speed_hz = chip->max_speed_hz; | 231 | proxy->max_speed_hz = chip->max_speed_hz; |
230 | proxy->mode = chip->mode; | 232 | proxy->mode = chip->mode; |
231 | proxy->irq = chip->irq; | 233 | proxy->irq = chip->irq; |
232 | proxy->modalias = chip->modalias; | 234 | strlcpy(proxy->modalias, chip->modalias, sizeof(proxy->modalias)); |
233 | 235 | ||
234 | snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id, | 236 | snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id, |
235 | "%s.%u", master->dev.bus_id, | 237 | "%s.%u", master->dev.bus_id, |
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c index 6832da6f7109..070c6219e2d6 100644 --- a/drivers/spi/spi_mpc83xx.c +++ b/drivers/spi/spi_mpc83xx.c | |||
@@ -266,21 +266,24 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
266 | 266 | ||
267 | cs->hw_mode |= SPMODE_LEN(bits_per_word); | 267 | cs->hw_mode |= SPMODE_LEN(bits_per_word); |
268 | 268 | ||
269 | if ((mpc83xx_spi->spibrg / hz) >= 64) { | 269 | if ((mpc83xx_spi->spibrg / hz) > 64) { |
270 | pm = mpc83xx_spi->spibrg / (hz * 64) - 1; | 270 | pm = mpc83xx_spi->spibrg / (hz * 64); |
271 | if (pm > 0x0f) { | 271 | if (pm > 16) { |
272 | dev_err(&spi->dev, "Requested speed is too " | 272 | cs->hw_mode |= SPMODE_DIV16; |
273 | "low: %d Hz. Will use %d Hz instead.\n", | 273 | pm /= 16; |
274 | hz, mpc83xx_spi->spibrg / 1024); | 274 | if (pm > 16) { |
275 | pm = 0x0f; | 275 | dev_err(&spi->dev, "Requested speed is too " |
276 | "low: %d Hz. Will use %d Hz instead.\n", | ||
277 | hz, mpc83xx_spi->spibrg / 1024); | ||
278 | pm = 16; | ||
279 | } | ||
276 | } | 280 | } |
277 | cs->hw_mode |= SPMODE_PM(pm) | SPMODE_DIV16; | 281 | } else |
278 | } else { | ||
279 | pm = mpc83xx_spi->spibrg / (hz * 4); | 282 | pm = mpc83xx_spi->spibrg / (hz * 4); |
280 | if (pm) | 283 | if (pm) |
281 | pm--; | 284 | pm--; |
282 | cs->hw_mode |= SPMODE_PM(pm); | 285 | |
283 | } | 286 | cs->hw_mode |= SPMODE_PM(pm); |
284 | regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); | 287 | regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); |
285 | if (cs->hw_mode != regval) { | 288 | if (cs->hw_mode != regval) { |
286 | unsigned long flags; | 289 | unsigned long flags; |
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 2833fd772a24..e5e0cfed5e3b 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -228,7 +228,6 @@ static int spidev_message(struct spidev_data *spidev, | |||
228 | * We walk the array of user-provided transfers, using each one | 228 | * We walk the array of user-provided transfers, using each one |
229 | * to initialize a kernel version of the same transfer. | 229 | * to initialize a kernel version of the same transfer. |
230 | */ | 230 | */ |
231 | mutex_lock(&spidev->buf_lock); | ||
232 | buf = spidev->buffer; | 231 | buf = spidev->buffer; |
233 | total = 0; | 232 | total = 0; |
234 | for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers; | 233 | for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers; |
@@ -296,14 +295,12 @@ static int spidev_message(struct spidev_data *spidev, | |||
296 | status = total; | 295 | status = total; |
297 | 296 | ||
298 | done: | 297 | done: |
299 | mutex_unlock(&spidev->buf_lock); | ||
300 | kfree(k_xfers); | 298 | kfree(k_xfers); |
301 | return status; | 299 | return status; |
302 | } | 300 | } |
303 | 301 | ||
304 | static int | 302 | static long |
305 | spidev_ioctl(struct inode *inode, struct file *filp, | 303 | spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
306 | unsigned int cmd, unsigned long arg) | ||
307 | { | 304 | { |
308 | int err = 0; | 305 | int err = 0; |
309 | int retval = 0; | 306 | int retval = 0; |
@@ -341,6 +338,14 @@ spidev_ioctl(struct inode *inode, struct file *filp, | |||
341 | if (spi == NULL) | 338 | if (spi == NULL) |
342 | return -ESHUTDOWN; | 339 | return -ESHUTDOWN; |
343 | 340 | ||
341 | /* use the buffer lock here for triple duty: | ||
342 | * - prevent I/O (from us) so calling spi_setup() is safe; | ||
343 | * - prevent concurrent SPI_IOC_WR_* from morphing | ||
344 | * data fields while SPI_IOC_RD_* reads them; | ||
345 | * - SPI_IOC_MESSAGE needs the buffer locked "normally". | ||
346 | */ | ||
347 | mutex_lock(&spidev->buf_lock); | ||
348 | |||
344 | switch (cmd) { | 349 | switch (cmd) { |
345 | /* read requests */ | 350 | /* read requests */ |
346 | case SPI_IOC_RD_MODE: | 351 | case SPI_IOC_RD_MODE: |
@@ -456,6 +461,8 @@ spidev_ioctl(struct inode *inode, struct file *filp, | |||
456 | kfree(ioc); | 461 | kfree(ioc); |
457 | break; | 462 | break; |
458 | } | 463 | } |
464 | |||
465 | mutex_unlock(&spidev->buf_lock); | ||
459 | spi_dev_put(spi); | 466 | spi_dev_put(spi); |
460 | return retval; | 467 | return retval; |
461 | } | 468 | } |
@@ -533,7 +540,7 @@ static struct file_operations spidev_fops = { | |||
533 | */ | 540 | */ |
534 | .write = spidev_write, | 541 | .write = spidev_write, |
535 | .read = spidev_read, | 542 | .read = spidev_read, |
536 | .ioctl = spidev_ioctl, | 543 | .unlocked_ioctl = spidev_ioctl, |
537 | .open = spidev_open, | 544 | .open = spidev_open, |
538 | .release = spidev_release, | 545 | .release = spidev_release, |
539 | }; | 546 | }; |
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 113a0468ffcb..68d6f4988fb5 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c | |||
@@ -353,11 +353,12 @@ static int __init xilinx_spi_probe(struct platform_device *dev) | |||
353 | goto put_master; | 353 | goto put_master; |
354 | } | 354 | } |
355 | 355 | ||
356 | xspi->irq = platform_get_irq(dev, 0); | 356 | ret = platform_get_irq(dev, 0); |
357 | if (xspi->irq < 0) { | 357 | if (ret < 0) { |
358 | ret = -ENXIO; | 358 | ret = -ENXIO; |
359 | goto unmap_io; | 359 | goto unmap_io; |
360 | } | 360 | } |
361 | xspi->irq = ret; | ||
361 | 362 | ||
362 | master->bus_num = pdata->bus_num; | 363 | master->bus_num = pdata->bus_num; |
363 | master->num_chipselect = pdata->num_chipselect; | 364 | master->num_chipselect = pdata->num_chipselect; |
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c index 49cd9793404f..ec7aeb502d15 100644 --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c | |||
@@ -6095,15 +6095,15 @@ static int capabilities_check(IXJ *j, struct phone_capability *pcreq) | |||
6095 | return retval; | 6095 | return retval; |
6096 | } | 6096 | } |
6097 | 6097 | ||
6098 | static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg) | 6098 | static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg) |
6099 | { | 6099 | { |
6100 | IXJ_TONE ti; | 6100 | IXJ_TONE ti; |
6101 | IXJ_FILTER jf; | 6101 | IXJ_FILTER jf; |
6102 | IXJ_FILTER_RAW jfr; | 6102 | IXJ_FILTER_RAW jfr; |
6103 | void __user *argp = (void __user *)arg; | 6103 | void __user *argp = (void __user *)arg; |
6104 | 6104 | struct inode *inode = file_p->f_path.dentry->d_inode; | |
6105 | unsigned int raise, mant; | ||
6106 | unsigned int minor = iminor(inode); | 6105 | unsigned int minor = iminor(inode); |
6106 | unsigned int raise, mant; | ||
6107 | int board = NUM(inode); | 6107 | int board = NUM(inode); |
6108 | 6108 | ||
6109 | IXJ *j = get_ixj(NUM(inode)); | 6109 | IXJ *j = get_ixj(NUM(inode)); |
@@ -6661,6 +6661,15 @@ static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, | |||
6661 | return retval; | 6661 | return retval; |
6662 | } | 6662 | } |
6663 | 6663 | ||
6664 | static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg) | ||
6665 | { | ||
6666 | long ret; | ||
6667 | lock_kernel(); | ||
6668 | ret = do_ixj_ioctl(file_p, cmd, arg); | ||
6669 | unlock_kernel(); | ||
6670 | return ret; | ||
6671 | } | ||
6672 | |||
6664 | static int ixj_fasync(int fd, struct file *file_p, int mode) | 6673 | static int ixj_fasync(int fd, struct file *file_p, int mode) |
6665 | { | 6674 | { |
6666 | IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode)); | 6675 | IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode)); |
@@ -6674,7 +6683,7 @@ static const struct file_operations ixj_fops = | |||
6674 | .read = ixj_enhanced_read, | 6683 | .read = ixj_enhanced_read, |
6675 | .write = ixj_enhanced_write, | 6684 | .write = ixj_enhanced_write, |
6676 | .poll = ixj_poll, | 6685 | .poll = ixj_poll, |
6677 | .ioctl = ixj_ioctl, | 6686 | .unlocked_ioctl = ixj_ioctl, |
6678 | .release = ixj_release, | 6687 | .release = ixj_release, |
6679 | .fasync = ixj_fasync | 6688 | .fasync = ixj_fasync |
6680 | }; | 6689 | }; |
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h index a973f2a50fb9..c65d62295890 100644 --- a/drivers/usb/gadget/at91_udc.h +++ b/drivers/usb/gadget/at91_udc.h | |||
@@ -171,7 +171,7 @@ struct at91_request { | |||
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | #define ERR(stuff...) pr_err("udc: " stuff) | 173 | #define ERR(stuff...) pr_err("udc: " stuff) |
174 | #define WARN(stuff...) pr_warning("udc: " stuff) | 174 | #define WARNING(stuff...) pr_warning("udc: " stuff) |
175 | #define INFO(stuff...) pr_info("udc: " stuff) | 175 | #define INFO(stuff...) pr_info("udc: " stuff) |
176 | #define DBG(stuff...) pr_debug("udc: " stuff) | 176 | #define DBG(stuff...) pr_debug("udc: " stuff) |
177 | 177 | ||
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index d490d0289507..a39a4b940c33 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -170,7 +170,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) | |||
170 | * but if the controller isn't recognized at all then | 170 | * but if the controller isn't recognized at all then |
171 | * that assumption is a bit more likely to be wrong. | 171 | * that assumption is a bit more likely to be wrong. |
172 | */ | 172 | */ |
173 | WARN(cdev, "controller '%s' not recognized; trying %s\n", | 173 | WARNING(cdev, "controller '%s' not recognized; trying %s\n", |
174 | gadget->name, | 174 | gadget->name, |
175 | cdc_config_driver.label); | 175 | cdc_config_driver.label); |
176 | device_desc.bcdDevice = | 176 | device_desc.bcdDevice = |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index d7aaaa29b1e1..bcac2e68660d 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -293,7 +293,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
293 | * but if the controller isn't recognized at all then | 293 | * but if the controller isn't recognized at all then |
294 | * that assumption is a bit more likely to be wrong. | 294 | * that assumption is a bit more likely to be wrong. |
295 | */ | 295 | */ |
296 | WARN(cdev, "controller '%s' not recognized; trying %s\n", | 296 | WARNING(cdev, "controller '%s' not recognized; trying %s\n", |
297 | gadget->name, | 297 | gadget->name, |
298 | eth_config_driver.label); | 298 | eth_config_driver.label); |
299 | device_desc.bcdDevice = | 299 | device_desc.bcdDevice = |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 15c24edbb61a..ea2c31d18080 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -308,7 +308,7 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
308 | dev_vdbg(&(d)->gadget->dev , fmt , ## args) | 308 | dev_vdbg(&(d)->gadget->dev , fmt , ## args) |
309 | #define ERROR(d, fmt, args...) \ | 309 | #define ERROR(d, fmt, args...) \ |
310 | dev_err(&(d)->gadget->dev , fmt , ## args) | 310 | dev_err(&(d)->gadget->dev , fmt , ## args) |
311 | #define WARN(d, fmt, args...) \ | 311 | #define WARNING(d, fmt, args...) \ |
312 | dev_warn(&(d)->gadget->dev , fmt , ## args) | 312 | dev_warn(&(d)->gadget->dev , fmt , ## args) |
313 | #define INFO(d, fmt, args...) \ | 313 | #define INFO(d, fmt, args...) \ |
314 | dev_info(&(d)->gadget->dev , fmt , ## args) | 314 | dev_info(&(d)->gadget->dev , fmt , ## args) |
@@ -1091,7 +1091,7 @@ static int ep0_queue(struct fsg_dev *fsg) | |||
1091 | if (rc != 0 && rc != -ESHUTDOWN) { | 1091 | if (rc != 0 && rc != -ESHUTDOWN) { |
1092 | 1092 | ||
1093 | /* We can't do much more than wait for a reset */ | 1093 | /* We can't do much more than wait for a reset */ |
1094 | WARN(fsg, "error in submission: %s --> %d\n", | 1094 | WARNING(fsg, "error in submission: %s --> %d\n", |
1095 | fsg->ep0->name, rc); | 1095 | fsg->ep0->name, rc); |
1096 | } | 1096 | } |
1097 | return rc; | 1097 | return rc; |
@@ -1227,7 +1227,7 @@ static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
1227 | 1227 | ||
1228 | /* Save the command for later */ | 1228 | /* Save the command for later */ |
1229 | if (fsg->cbbuf_cmnd_size) | 1229 | if (fsg->cbbuf_cmnd_size) |
1230 | WARN(fsg, "CB[I] overwriting previous command\n"); | 1230 | WARNING(fsg, "CB[I] overwriting previous command\n"); |
1231 | fsg->cbbuf_cmnd_size = req->actual; | 1231 | fsg->cbbuf_cmnd_size = req->actual; |
1232 | memcpy(fsg->cbbuf_cmnd, req->buf, fsg->cbbuf_cmnd_size); | 1232 | memcpy(fsg->cbbuf_cmnd, req->buf, fsg->cbbuf_cmnd_size); |
1233 | 1233 | ||
@@ -1506,7 +1506,7 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, | |||
1506 | * submissions if DMA is enabled. */ | 1506 | * submissions if DMA is enabled. */ |
1507 | if (rc != -ESHUTDOWN && !(rc == -EOPNOTSUPP && | 1507 | if (rc != -ESHUTDOWN && !(rc == -EOPNOTSUPP && |
1508 | req->length == 0)) | 1508 | req->length == 0)) |
1509 | WARN(fsg, "error in submission: %s --> %d\n", | 1509 | WARNING(fsg, "error in submission: %s --> %d\n", |
1510 | ep->name, rc); | 1510 | ep->name, rc); |
1511 | } | 1511 | } |
1512 | } | 1512 | } |
@@ -2294,7 +2294,7 @@ static int halt_bulk_in_endpoint(struct fsg_dev *fsg) | |||
2294 | VDBG(fsg, "delayed bulk-in endpoint halt\n"); | 2294 | VDBG(fsg, "delayed bulk-in endpoint halt\n"); |
2295 | while (rc != 0) { | 2295 | while (rc != 0) { |
2296 | if (rc != -EAGAIN) { | 2296 | if (rc != -EAGAIN) { |
2297 | WARN(fsg, "usb_ep_set_halt -> %d\n", rc); | 2297 | WARNING(fsg, "usb_ep_set_halt -> %d\n", rc); |
2298 | rc = 0; | 2298 | rc = 0; |
2299 | break; | 2299 | break; |
2300 | } | 2300 | } |
@@ -2317,7 +2317,7 @@ static int wedge_bulk_in_endpoint(struct fsg_dev *fsg) | |||
2317 | VDBG(fsg, "delayed bulk-in endpoint wedge\n"); | 2317 | VDBG(fsg, "delayed bulk-in endpoint wedge\n"); |
2318 | while (rc != 0) { | 2318 | while (rc != 0) { |
2319 | if (rc != -EAGAIN) { | 2319 | if (rc != -EAGAIN) { |
2320 | WARN(fsg, "usb_ep_set_wedge -> %d\n", rc); | 2320 | WARNING(fsg, "usb_ep_set_wedge -> %d\n", rc); |
2321 | rc = 0; | 2321 | rc = 0; |
2322 | break; | 2322 | break; |
2323 | } | 2323 | } |
@@ -3755,7 +3755,7 @@ static int __init check_parameters(struct fsg_dev *fsg) | |||
3755 | if (gcnum >= 0) | 3755 | if (gcnum >= 0) |
3756 | mod_data.release = 0x0300 + gcnum; | 3756 | mod_data.release = 0x0300 + gcnum; |
3757 | else { | 3757 | else { |
3758 | WARN(fsg, "controller '%s' not recognized\n", | 3758 | WARNING(fsg, "controller '%s' not recognized\n", |
3759 | fsg->gadget->name); | 3759 | fsg->gadget->name); |
3760 | mod_data.release = 0x0399; | 3760 | mod_data.release = 0x0399; |
3761 | } | 3761 | } |
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index 1695382f30fe..1cfccf102a2d 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c | |||
@@ -1538,7 +1538,7 @@ static void dtd_complete_irq(struct fsl_udc *udc) | |||
1538 | 1538 | ||
1539 | /* If the ep is configured */ | 1539 | /* If the ep is configured */ |
1540 | if (curr_ep->name == NULL) { | 1540 | if (curr_ep->name == NULL) { |
1541 | WARN("Invalid EP?"); | 1541 | WARNING("Invalid EP?"); |
1542 | continue; | 1542 | continue; |
1543 | } | 1543 | } |
1544 | 1544 | ||
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index 98b1483ef6a5..6131752a38bc 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h | |||
@@ -552,7 +552,7 @@ static void dump_msg(const char *label, const u8 * buf, unsigned int length) | |||
552 | #endif | 552 | #endif |
553 | 553 | ||
554 | #define ERR(stuff...) pr_err("udc: " stuff) | 554 | #define ERR(stuff...) pr_err("udc: " stuff) |
555 | #define WARN(stuff...) pr_warning("udc: " stuff) | 555 | #define WARNING(stuff...) pr_warning("udc: " stuff) |
556 | #define INFO(stuff...) pr_info("udc: " stuff) | 556 | #define INFO(stuff...) pr_info("udc: " stuff) |
557 | 557 | ||
558 | /*-------------------------------------------------------------------------*/ | 558 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 7f4d4828e3aa..ea8651e3da1a 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -138,8 +138,6 @@ static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req); | |||
138 | dev_vdbg(&(d)->gadget->dev , fmt , ## args) | 138 | dev_vdbg(&(d)->gadget->dev , fmt , ## args) |
139 | #define ERROR(d, fmt, args...) \ | 139 | #define ERROR(d, fmt, args...) \ |
140 | dev_err(&(d)->gadget->dev , fmt , ## args) | 140 | dev_err(&(d)->gadget->dev , fmt , ## args) |
141 | #define WARN(d, fmt, args...) \ | ||
142 | dev_warn(&(d)->gadget->dev , fmt , ## args) | ||
143 | #define INFO(d, fmt, args...) \ | 141 | #define INFO(d, fmt, args...) \ |
144 | dev_info(&(d)->gadget->dev , fmt , ## args) | 142 | dev_info(&(d)->gadget->dev , fmt , ## args) |
145 | 143 | ||
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 48f1c63b7013..60aa04847b18 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -1768,7 +1768,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1768 | * usb_gadget_driver_{register,unregister}() must change. | 1768 | * usb_gadget_driver_{register,unregister}() must change. |
1769 | */ | 1769 | */ |
1770 | if (the_controller) { | 1770 | if (the_controller) { |
1771 | WARN(dev, "ignoring %s\n", pci_name(pdev)); | 1771 | WARNING(dev, "ignoring %s\n", pci_name(pdev)); |
1772 | return -EBUSY; | 1772 | return -EBUSY; |
1773 | } | 1773 | } |
1774 | if (!pdev->irq) { | 1774 | if (!pdev->irq) { |
diff --git a/drivers/usb/gadget/goku_udc.h b/drivers/usb/gadget/goku_udc.h index bc4eb1e0b507..566cb2319056 100644 --- a/drivers/usb/gadget/goku_udc.h +++ b/drivers/usb/gadget/goku_udc.h | |||
@@ -285,7 +285,7 @@ struct goku_udc { | |||
285 | 285 | ||
286 | #define ERROR(dev,fmt,args...) \ | 286 | #define ERROR(dev,fmt,args...) \ |
287 | xprintk(dev , KERN_ERR , fmt , ## args) | 287 | xprintk(dev , KERN_ERR , fmt , ## args) |
288 | #define WARN(dev,fmt,args...) \ | 288 | #define WARNING(dev,fmt,args...) \ |
289 | xprintk(dev , KERN_WARNING , fmt , ## args) | 289 | xprintk(dev , KERN_WARNING , fmt , ## args) |
290 | #define INFO(dev,fmt,args...) \ | 290 | #define INFO(dev,fmt,args...) \ |
291 | xprintk(dev , KERN_INFO , fmt , ## args) | 291 | xprintk(dev , KERN_INFO , fmt , ## args) |
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 04692d59fc1c..f4585d3e90d7 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -262,8 +262,6 @@ static const char *CHIP; | |||
262 | 262 | ||
263 | #define ERROR(dev,fmt,args...) \ | 263 | #define ERROR(dev,fmt,args...) \ |
264 | xprintk(dev , KERN_ERR , fmt , ## args) | 264 | xprintk(dev , KERN_ERR , fmt , ## args) |
265 | #define WARN(dev,fmt,args...) \ | ||
266 | xprintk(dev , KERN_WARNING , fmt , ## args) | ||
267 | #define INFO(dev,fmt,args...) \ | 265 | #define INFO(dev,fmt,args...) \ |
268 | xprintk(dev , KERN_INFO , fmt , ## args) | 266 | xprintk(dev , KERN_INFO , fmt , ## args) |
269 | 267 | ||
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index b67ab677af72..5cfb5ebf3881 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -1007,7 +1007,7 @@ static void scan_dma_completions (struct net2280_ep *ep) | |||
1007 | * 0122, and 0124; not all cases trigger the warning. | 1007 | * 0122, and 0124; not all cases trigger the warning. |
1008 | */ | 1008 | */ |
1009 | if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) { | 1009 | if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) { |
1010 | WARN (ep->dev, "%s lost packet sync!\n", | 1010 | WARNING (ep->dev, "%s lost packet sync!\n", |
1011 | ep->ep.name); | 1011 | ep->ep.name); |
1012 | req->req.status = -EOVERFLOW; | 1012 | req->req.status = -EOVERFLOW; |
1013 | } else if ((tmp = readl (&ep->regs->ep_avail)) != 0) { | 1013 | } else if ((tmp = readl (&ep->regs->ep_avail)) != 0) { |
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h index 1f2af398a9a4..81a71dbdc2c6 100644 --- a/drivers/usb/gadget/net2280.h +++ b/drivers/usb/gadget/net2280.h | |||
@@ -272,7 +272,7 @@ static inline void net2280_led_shutdown (struct net2280 *dev) | |||
272 | 272 | ||
273 | #define ERROR(dev,fmt,args...) \ | 273 | #define ERROR(dev,fmt,args...) \ |
274 | xprintk(dev , KERN_ERR , fmt , ## args) | 274 | xprintk(dev , KERN_ERR , fmt , ## args) |
275 | #define WARN(dev,fmt,args...) \ | 275 | #define WARNING(dev,fmt,args...) \ |
276 | xprintk(dev , KERN_WARNING , fmt , ## args) | 276 | xprintk(dev , KERN_WARNING , fmt , ## args) |
277 | #define INFO(dev,fmt,args...) \ | 277 | #define INFO(dev,fmt,args...) \ |
278 | xprintk(dev , KERN_INFO , fmt , ## args) | 278 | xprintk(dev , KERN_INFO , fmt , ## args) |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 4b79a8509e84..395bd1844482 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -1120,7 +1120,7 @@ static int omap_ep_set_halt(struct usb_ep *_ep, int value) | |||
1120 | status = -EINVAL; | 1120 | status = -EINVAL; |
1121 | else if (value) { | 1121 | else if (value) { |
1122 | if (ep->udc->ep0_set_config) { | 1122 | if (ep->udc->ep0_set_config) { |
1123 | WARN("error changing config?\n"); | 1123 | WARNING("error changing config?\n"); |
1124 | omap_writew(UDC_CLR_CFG, UDC_SYSCON2); | 1124 | omap_writew(UDC_CLR_CFG, UDC_SYSCON2); |
1125 | } | 1125 | } |
1126 | omap_writew(UDC_STALL_CMD, UDC_SYSCON2); | 1126 | omap_writew(UDC_STALL_CMD, UDC_SYSCON2); |
@@ -1764,7 +1764,7 @@ do_stall: | |||
1764 | u.r.bRequestType, u.r.bRequest, status); | 1764 | u.r.bRequestType, u.r.bRequest, status); |
1765 | if (udc->ep0_set_config) { | 1765 | if (udc->ep0_set_config) { |
1766 | if (udc->ep0_reset_config) | 1766 | if (udc->ep0_reset_config) |
1767 | WARN("error resetting config?\n"); | 1767 | WARNING("error resetting config?\n"); |
1768 | else | 1768 | else |
1769 | omap_writew(UDC_CLR_CFG, UDC_SYSCON2); | 1769 | omap_writew(UDC_CLR_CFG, UDC_SYSCON2); |
1770 | } | 1770 | } |
@@ -3076,7 +3076,7 @@ static int omap_udc_suspend(struct platform_device *dev, pm_message_t message) | |||
3076 | * which would prevent entry to deep sleep... | 3076 | * which would prevent entry to deep sleep... |
3077 | */ | 3077 | */ |
3078 | if ((devstat & UDC_ATT) != 0 && (devstat & UDC_SUS) == 0) { | 3078 | if ((devstat & UDC_ATT) != 0 && (devstat & UDC_SUS) == 0) { |
3079 | WARN("session active; suspend requires disconnect\n"); | 3079 | WARNING("session active; suspend requires disconnect\n"); |
3080 | omap_pullup(&udc->gadget, 0); | 3080 | omap_pullup(&udc->gadget, 0); |
3081 | } | 3081 | } |
3082 | 3082 | ||
diff --git a/drivers/usb/gadget/omap_udc.h b/drivers/usb/gadget/omap_udc.h index 8522bbb12278..29edc51b6b22 100644 --- a/drivers/usb/gadget/omap_udc.h +++ b/drivers/usb/gadget/omap_udc.h | |||
@@ -188,7 +188,7 @@ struct omap_udc { | |||
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | #define ERR(stuff...) pr_err("udc: " stuff) | 190 | #define ERR(stuff...) pr_err("udc: " stuff) |
191 | #define WARN(stuff...) pr_warning("udc: " stuff) | 191 | #define WARNING(stuff...) pr_warning("udc: " stuff) |
192 | #define INFO(stuff...) pr_info("udc: " stuff) | 192 | #define INFO(stuff...) pr_info("udc: " stuff) |
193 | #define DBG(stuff...) pr_debug("udc: " stuff) | 193 | #define DBG(stuff...) pr_debug("udc: " stuff) |
194 | 194 | ||
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 49cd9e145a9b..e0090085b78e 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -179,7 +179,7 @@ module_param(qlen, uint, S_IRUGO|S_IWUSR); | |||
179 | 179 | ||
180 | #define ERROR(dev, fmt, args...) \ | 180 | #define ERROR(dev, fmt, args...) \ |
181 | xprintk(dev, KERN_ERR, fmt, ## args) | 181 | xprintk(dev, KERN_ERR, fmt, ## args) |
182 | #define WARN(dev, fmt, args...) \ | 182 | #define WARNING(dev, fmt, args...) \ |
183 | xprintk(dev, KERN_WARNING, fmt, ## args) | 183 | xprintk(dev, KERN_WARNING, fmt, ## args) |
184 | #define INFO(dev, fmt, args...) \ | 184 | #define INFO(dev, fmt, args...) \ |
185 | xprintk(dev, KERN_INFO, fmt, ## args) | 185 | xprintk(dev, KERN_INFO, fmt, ## args) |
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 8fb0066609bb..7e6725d89976 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c | |||
@@ -342,7 +342,7 @@ pxa25x_ep_free_request (struct usb_ep *_ep, struct usb_request *_req) | |||
342 | struct pxa25x_request *req; | 342 | struct pxa25x_request *req; |
343 | 343 | ||
344 | req = container_of (_req, struct pxa25x_request, req); | 344 | req = container_of (_req, struct pxa25x_request, req); |
345 | WARN_ON (!list_empty (&req->queue)); | 345 | WARN_ON(!list_empty (&req->queue)); |
346 | kfree(req); | 346 | kfree(req); |
347 | } | 347 | } |
348 | 348 | ||
@@ -1556,7 +1556,7 @@ config_change: | |||
1556 | * tell us about config change events, | 1556 | * tell us about config change events, |
1557 | * so later ones may fail... | 1557 | * so later ones may fail... |
1558 | */ | 1558 | */ |
1559 | WARN("config change %02x fail %d?\n", | 1559 | WARNING("config change %02x fail %d?\n", |
1560 | u.r.bRequest, i); | 1560 | u.r.bRequest, i); |
1561 | return; | 1561 | return; |
1562 | /* TODO experiment: if has_cfr, | 1562 | /* TODO experiment: if has_cfr, |
@@ -2330,7 +2330,7 @@ static int pxa25x_udc_suspend(struct platform_device *dev, pm_message_t state) | |||
2330 | unsigned long flags; | 2330 | unsigned long flags; |
2331 | 2331 | ||
2332 | if (!udc->mach->gpio_pullup && !udc->mach->udc_command) | 2332 | if (!udc->mach->gpio_pullup && !udc->mach->udc_command) |
2333 | WARN("USB host won't detect disconnect!\n"); | 2333 | WARNING("USB host won't detect disconnect!\n"); |
2334 | udc->suspended = 1; | 2334 | udc->suspended = 1; |
2335 | 2335 | ||
2336 | local_irq_save(flags); | 2336 | local_irq_save(flags); |
diff --git a/drivers/usb/gadget/pxa25x_udc.h b/drivers/usb/gadget/pxa25x_udc.h index 4d11ece7c95f..c8a13215e02c 100644 --- a/drivers/usb/gadget/pxa25x_udc.h +++ b/drivers/usb/gadget/pxa25x_udc.h | |||
@@ -259,7 +259,7 @@ dump_state(struct pxa25x_udc *dev) | |||
259 | #define DBG(lvl, stuff...) do{if ((lvl) <= UDC_DEBUG) DMSG(stuff);}while(0) | 259 | #define DBG(lvl, stuff...) do{if ((lvl) <= UDC_DEBUG) DMSG(stuff);}while(0) |
260 | 260 | ||
261 | #define ERR(stuff...) pr_err("udc: " stuff) | 261 | #define ERR(stuff...) pr_err("udc: " stuff) |
262 | #define WARN(stuff...) pr_warning("udc: " stuff) | 262 | #define WARNING(stuff...) pr_warning("udc: " stuff) |
263 | #define INFO(stuff...) pr_info("udc: " stuff) | 263 | #define INFO(stuff...) pr_info("udc: " stuff) |
264 | 264 | ||
265 | 265 | ||
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c index 5458f43a8668..3791e6271903 100644 --- a/drivers/usb/gadget/u_ether.c +++ b/drivers/usb/gadget/u_ether.c | |||
@@ -116,7 +116,6 @@ static inline int qlen(struct usb_gadget *gadget) | |||
116 | #undef DBG | 116 | #undef DBG |
117 | #undef VDBG | 117 | #undef VDBG |
118 | #undef ERROR | 118 | #undef ERROR |
119 | #undef WARN | ||
120 | #undef INFO | 119 | #undef INFO |
121 | 120 | ||
122 | #define xprintk(d, level, fmt, args...) \ | 121 | #define xprintk(d, level, fmt, args...) \ |
@@ -140,8 +139,6 @@ static inline int qlen(struct usb_gadget *gadget) | |||
140 | 139 | ||
141 | #define ERROR(dev, fmt, args...) \ | 140 | #define ERROR(dev, fmt, args...) \ |
142 | xprintk(dev , KERN_ERR , fmt , ## args) | 141 | xprintk(dev , KERN_ERR , fmt , ## args) |
143 | #define WARN(dev, fmt, args...) \ | ||
144 | xprintk(dev , KERN_WARNING , fmt , ## args) | ||
145 | #define INFO(dev, fmt, args...) \ | 142 | #define INFO(dev, fmt, args...) \ |
146 | xprintk(dev , KERN_INFO , fmt , ## args) | 143 | xprintk(dev , KERN_INFO , fmt , ## args) |
147 | 144 | ||
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 31178e10cbbe..ce1ca0ba0515 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -882,7 +882,7 @@ static void isp116x_endpoint_disable(struct usb_hcd *hcd, | |||
882 | for (i = 0; i < 100 && !list_empty(&hep->urb_list); i++) | 882 | for (i = 0; i < 100 && !list_empty(&hep->urb_list); i++) |
883 | msleep(3); | 883 | msleep(3); |
884 | if (!list_empty(&hep->urb_list)) | 884 | if (!list_empty(&hep->urb_list)) |
885 | WARN("ep %p not empty?\n", ep); | 885 | WARNING("ep %p not empty?\n", ep); |
886 | 886 | ||
887 | kfree(ep); | 887 | kfree(ep); |
888 | hep->hcpriv = NULL; | 888 | hep->hcpriv = NULL; |
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h index 595b90a99848..aa211bafcff9 100644 --- a/drivers/usb/host/isp116x.h +++ b/drivers/usb/host/isp116x.h | |||
@@ -338,7 +338,7 @@ struct isp116x_ep { | |||
338 | #endif | 338 | #endif |
339 | 339 | ||
340 | #define ERR(stuff...) printk(KERN_ERR "116x: " stuff) | 340 | #define ERR(stuff...) printk(KERN_ERR "116x: " stuff) |
341 | #define WARN(stuff...) printk(KERN_WARNING "116x: " stuff) | 341 | #define WARNING(stuff...) printk(KERN_WARNING "116x: " stuff) |
342 | #define INFO(stuff...) printk(KERN_INFO "116x: " stuff) | 342 | #define INFO(stuff...) printk(KERN_INFO "116x: " stuff) |
343 | 343 | ||
344 | /* ------------------------------------------------- */ | 344 | /* ------------------------------------------------- */ |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 340d72da554a..8a74bbb57d08 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -1026,7 +1026,7 @@ sl811h_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep) | |||
1026 | if (!list_empty(&hep->urb_list)) | 1026 | if (!list_empty(&hep->urb_list)) |
1027 | msleep(3); | 1027 | msleep(3); |
1028 | if (!list_empty(&hep->urb_list)) | 1028 | if (!list_empty(&hep->urb_list)) |
1029 | WARN("ep %p not empty?\n", ep); | 1029 | WARNING("ep %p not empty?\n", ep); |
1030 | 1030 | ||
1031 | kfree(ep); | 1031 | kfree(ep); |
1032 | hep->hcpriv = NULL; | 1032 | hep->hcpriv = NULL; |
diff --git a/drivers/usb/host/sl811.h b/drivers/usb/host/sl811.h index 7690d98e42a7..b6b8c1f233dd 100644 --- a/drivers/usb/host/sl811.h +++ b/drivers/usb/host/sl811.h | |||
@@ -261,6 +261,6 @@ sl811_read_buf(struct sl811 *sl811, int addr, void *buf, size_t count) | |||
261 | #endif | 261 | #endif |
262 | 262 | ||
263 | #define ERR(stuff...) printk(KERN_ERR "sl811: " stuff) | 263 | #define ERR(stuff...) printk(KERN_ERR "sl811: " stuff) |
264 | #define WARN(stuff...) printk(KERN_WARNING "sl811: " stuff) | 264 | #define WARNING(stuff...) printk(KERN_WARNING "sl811: " stuff) |
265 | #define INFO(stuff...) printk(KERN_INFO "sl811: " stuff) | 265 | #define INFO(stuff...) printk(KERN_INFO "sl811: " stuff) |
266 | 266 | ||
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 054dedd28127..b358c4e1cf21 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -81,7 +81,7 @@ static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test) | |||
81 | 81 | ||
82 | #define ERROR(tdev, fmt, args...) \ | 82 | #define ERROR(tdev, fmt, args...) \ |
83 | dev_err(&(tdev)->intf->dev , fmt , ## args) | 83 | dev_err(&(tdev)->intf->dev , fmt , ## args) |
84 | #define WARN(tdev, fmt, args...) \ | 84 | #define WARNING(tdev, fmt, args...) \ |
85 | dev_warn(&(tdev)->intf->dev , fmt , ## args) | 85 | dev_warn(&(tdev)->intf->dev , fmt , ## args) |
86 | 86 | ||
87 | /*-------------------------------------------------------------------------*/ | 87 | /*-------------------------------------------------------------------------*/ |
@@ -1946,7 +1946,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1946 | 1946 | ||
1947 | status = get_endpoints (dev, intf); | 1947 | status = get_endpoints (dev, intf); |
1948 | if (status < 0) { | 1948 | if (status < 0) { |
1949 | WARN(dev, "couldn't get endpoints, %d\n", | 1949 | WARNING(dev, "couldn't get endpoints, %d\n", |
1950 | status); | 1950 | status); |
1951 | return status; | 1951 | return status; |
1952 | } | 1952 | } |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 9b887ef64ff1..70d135e0cc47 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -1658,6 +1658,32 @@ config FB_PM3 | |||
1658 | similar boards, 3DLabs Permedia3 Create!, Appian Jeronimo 2000 | 1658 | similar boards, 3DLabs Permedia3 Create!, Appian Jeronimo 2000 |
1659 | and maybe other boards. | 1659 | and maybe other boards. |
1660 | 1660 | ||
1661 | config FB_CARMINE | ||
1662 | tristate "Fujitsu carmine frame buffer support" | ||
1663 | depends on FB && PCI | ||
1664 | select FB_CFB_FILLRECT | ||
1665 | select FB_CFB_COPYAREA | ||
1666 | select FB_CFB_IMAGEBLIT | ||
1667 | help | ||
1668 | This is the frame buffer device driver for the Fujitsu Carmine chip. | ||
1669 | The driver provides two independent frame buffer devices. | ||
1670 | |||
1671 | choice | ||
1672 | depends on FB_CARMINE | ||
1673 | prompt "DRAM timing" | ||
1674 | default FB_CARMINE_DRAM_EVAL | ||
1675 | |||
1676 | config FB_CARMINE_DRAM_EVAL | ||
1677 | bool "Eval board timings" | ||
1678 | help | ||
1679 | Use timings which work on the eval card. | ||
1680 | |||
1681 | config CARMINE_DRAM_CUSTOM | ||
1682 | bool "Custom board timings" | ||
1683 | help | ||
1684 | Use custom board timings. | ||
1685 | endchoice | ||
1686 | |||
1661 | config FB_AU1100 | 1687 | config FB_AU1100 |
1662 | bool "Au1100 LCD Driver" | 1688 | bool "Au1100 LCD Driver" |
1663 | depends on (FB = y) && MIPS && SOC_AU1100 | 1689 | depends on (FB = y) && MIPS && SOC_AU1100 |
@@ -1840,6 +1866,16 @@ config FB_W100 | |||
1840 | 1866 | ||
1841 | If unsure, say N. | 1867 | If unsure, say N. |
1842 | 1868 | ||
1869 | config FB_SH_MOBILE_LCDC | ||
1870 | tristate "SuperH Mobile LCDC framebuffer support" | ||
1871 | depends on FB && SUPERH | ||
1872 | select FB_CFB_FILLRECT | ||
1873 | select FB_CFB_COPYAREA | ||
1874 | select FB_CFB_IMAGEBLIT | ||
1875 | default m | ||
1876 | ---help--- | ||
1877 | Frame buffer driver for the on-chip SH-Mobile LCD controller. | ||
1878 | |||
1843 | config FB_S3C2410 | 1879 | config FB_S3C2410 |
1844 | tristate "S3C2410 LCD framebuffer support" | 1880 | tristate "S3C2410 LCD framebuffer support" |
1845 | depends on FB && ARCH_S3C2410 | 1881 | depends on FB && ARCH_S3C2410 |
@@ -1951,6 +1987,23 @@ config FB_AM200EPD | |||
1951 | This enables support for the Metronome display controller used on | 1987 | This enables support for the Metronome display controller used on |
1952 | the E-Ink AM-200 EPD devkit. | 1988 | the E-Ink AM-200 EPD devkit. |
1953 | 1989 | ||
1990 | config FB_COBALT | ||
1991 | tristate "Cobalt server LCD frame buffer support" | ||
1992 | depends on FB && MIPS_COBALT | ||
1993 | |||
1994 | config FB_SH7760 | ||
1995 | bool "SH7760/SH7763 LCDC support" | ||
1996 | depends on FB && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763) | ||
1997 | select FB_CFB_FILLRECT | ||
1998 | select FB_CFB_COPYAREA | ||
1999 | select FB_CFB_IMAGEBLIT | ||
2000 | help | ||
2001 | Support for the SH7760/SH7763 integrated (D)STN/TFT LCD Controller. | ||
2002 | Supports display resolutions up to 1024x1024 pixel, grayscale and | ||
2003 | color operation, with depths ranging from 1 bpp to 8 bpp monochrome | ||
2004 | and 8, 15 or 16 bpp color; 90 degrees clockwise display rotation for | ||
2005 | panels <= 320 pixel horizontal resolution. | ||
2006 | |||
1954 | config FB_VIRTUAL | 2007 | config FB_VIRTUAL |
1955 | tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" | 2008 | tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" |
1956 | depends on FB | 2009 | depends on FB |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 04bca35403ff..0ebc1bfd2514 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -106,17 +106,22 @@ obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o | |||
106 | obj-$(CONFIG_FB_MAXINE) += maxinefb.o | 106 | obj-$(CONFIG_FB_MAXINE) += maxinefb.o |
107 | obj-$(CONFIG_FB_METRONOME) += metronomefb.o | 107 | obj-$(CONFIG_FB_METRONOME) += metronomefb.o |
108 | obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o | 108 | obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o |
109 | obj-$(CONFIG_FB_SH7760) += sh7760fb.o | ||
109 | obj-$(CONFIG_FB_IMX) += imxfb.o | 110 | obj-$(CONFIG_FB_IMX) += imxfb.o |
110 | obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o | 111 | obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o |
111 | obj-$(CONFIG_FB_FSL_DIU) += fsl-diu-fb.o | 112 | obj-$(CONFIG_FB_FSL_DIU) += fsl-diu-fb.o |
113 | obj-$(CONFIG_FB_COBALT) += cobalt_lcdfb.o | ||
112 | obj-$(CONFIG_FB_PNX4008_DUM) += pnx4008/ | 114 | obj-$(CONFIG_FB_PNX4008_DUM) += pnx4008/ |
113 | obj-$(CONFIG_FB_PNX4008_DUM_RGB) += pnx4008/ | 115 | obj-$(CONFIG_FB_PNX4008_DUM_RGB) += pnx4008/ |
114 | obj-$(CONFIG_FB_IBM_GXT4500) += gxt4500.o | 116 | obj-$(CONFIG_FB_IBM_GXT4500) += gxt4500.o |
115 | obj-$(CONFIG_FB_PS3) += ps3fb.o | 117 | obj-$(CONFIG_FB_PS3) += ps3fb.o |
116 | obj-$(CONFIG_FB_SM501) += sm501fb.o | 118 | obj-$(CONFIG_FB_SM501) += sm501fb.o |
117 | obj-$(CONFIG_FB_XILINX) += xilinxfb.o | 119 | obj-$(CONFIG_FB_XILINX) += xilinxfb.o |
120 | obj-$(CONFIG_FB_SH_MOBILE_LCDC) += sh_mobile_lcdcfb.o | ||
121 | obj-$(CONFIG_FB_SH7343VOU) += sh7343_voufb.o | ||
118 | obj-$(CONFIG_FB_OMAP) += omap/ | 122 | obj-$(CONFIG_FB_OMAP) += omap/ |
119 | obj-$(CONFIG_XEN_FBDEV_FRONTEND) += xen-fbfront.o | 123 | obj-$(CONFIG_XEN_FBDEV_FRONTEND) += xen-fbfront.o |
124 | obj-$(CONFIG_FB_CARMINE) += carminefb.o | ||
120 | 125 | ||
121 | # Platform or fallback drivers go here | 126 | # Platform or fallback drivers go here |
122 | obj-$(CONFIG_FB_UVESA) += uvesafb.o | 127 | obj-$(CONFIG_FB_UVESA) += uvesafb.o |
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c index eedb8285e32f..017233d0c481 100644 --- a/drivers/video/acornfb.c +++ b/drivers/video/acornfb.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/string.h> | 23 | #include <linux/string.h> |
24 | #include <linux/ctype.h> | 24 | #include <linux/ctype.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/mm.h> | ||
26 | #include <linux/init.h> | 27 | #include <linux/init.h> |
27 | #include <linux/fb.h> | 28 | #include <linux/fb.h> |
28 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c index 45c154ade9ca..b8e9a8682f2d 100644 --- a/drivers/video/amifb.c +++ b/drivers/video/amifb.c | |||
@@ -1136,7 +1136,6 @@ static int amifb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg | |||
1136 | * Interface to the low level console driver | 1136 | * Interface to the low level console driver |
1137 | */ | 1137 | */ |
1138 | 1138 | ||
1139 | int amifb_init(void); | ||
1140 | static void amifb_deinit(void); | 1139 | static void amifb_deinit(void); |
1141 | 1140 | ||
1142 | /* | 1141 | /* |
@@ -2048,13 +2047,16 @@ static void amifb_copyarea(struct fb_info *info, | |||
2048 | width = x2 - dx; | 2047 | width = x2 - dx; |
2049 | height = y2 - dy; | 2048 | height = y2 - dy; |
2050 | 2049 | ||
2050 | if (area->sx + dx < area->dx || area->sy + dy < area->dy) | ||
2051 | return; | ||
2052 | |||
2051 | /* update sx,sy */ | 2053 | /* update sx,sy */ |
2052 | sx = area->sx + (dx - area->dx); | 2054 | sx = area->sx + (dx - area->dx); |
2053 | sy = area->sy + (dy - area->dy); | 2055 | sy = area->sy + (dy - area->dy); |
2054 | 2056 | ||
2055 | /* the source must be completely inside the virtual screen */ | 2057 | /* the source must be completely inside the virtual screen */ |
2056 | if (sx < 0 || sy < 0 || (sx + width) > info->var.xres_virtual || | 2058 | if (sx + width > info->var.xres_virtual || |
2057 | (sy + height) > info->var.yres_virtual) | 2059 | sy + height > info->var.yres_virtual) |
2058 | return; | 2060 | return; |
2059 | 2061 | ||
2060 | if (dy > sy || (dy == sy && dx > sx)) { | 2062 | if (dy > sy || (dy == sy && dx > sx)) { |
@@ -2245,7 +2247,7 @@ static inline void chipfree(void) | |||
2245 | * Initialisation | 2247 | * Initialisation |
2246 | */ | 2248 | */ |
2247 | 2249 | ||
2248 | int __init amifb_init(void) | 2250 | static int __init amifb_init(void) |
2249 | { | 2251 | { |
2250 | int tag, i, err = 0; | 2252 | int tag, i, err = 0; |
2251 | u_long chipptr; | 2253 | u_long chipptr; |
@@ -3790,16 +3792,14 @@ static void ami_rebuild_copper(void) | |||
3790 | } | 3792 | } |
3791 | } | 3793 | } |
3792 | 3794 | ||
3793 | 3795 | static void __exit amifb_exit(void) | |
3794 | module_init(amifb_init); | ||
3795 | |||
3796 | #ifdef MODULE | ||
3797 | MODULE_LICENSE("GPL"); | ||
3798 | |||
3799 | void cleanup_module(void) | ||
3800 | { | 3796 | { |
3801 | unregister_framebuffer(&fb_info); | 3797 | unregister_framebuffer(&fb_info); |
3802 | amifb_deinit(); | 3798 | amifb_deinit(); |
3803 | amifb_video_off(); | 3799 | amifb_video_off(); |
3804 | } | 3800 | } |
3805 | #endif /* MODULE */ | 3801 | |
3802 | module_init(amifb_init); | ||
3803 | module_exit(amifb_exit); | ||
3804 | |||
3805 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c index fa55d356b535..77eb8b34fbfa 100644 --- a/drivers/video/atafb.c +++ b/drivers/video/atafb.c | |||
@@ -2593,13 +2593,16 @@ static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area) | |||
2593 | width = x2 - dx; | 2593 | width = x2 - dx; |
2594 | height = y2 - dy; | 2594 | height = y2 - dy; |
2595 | 2595 | ||
2596 | if (area->sx + dx < area->dx || area->sy + dy < area->dy) | ||
2597 | return; | ||
2598 | |||
2596 | /* update sx,sy */ | 2599 | /* update sx,sy */ |
2597 | sx = area->sx + (dx - area->dx); | 2600 | sx = area->sx + (dx - area->dx); |
2598 | sy = area->sy + (dy - area->dy); | 2601 | sy = area->sy + (dy - area->dy); |
2599 | 2602 | ||
2600 | /* the source must be completely inside the virtual screen */ | 2603 | /* the source must be completely inside the virtual screen */ |
2601 | if (sx < 0 || sy < 0 || (sx + width) > info->var.xres_virtual || | 2604 | if (sx + width > info->var.xres_virtual || |
2602 | (sy + height) > info->var.yres_virtual) | 2605 | sy + height > info->var.yres_virtual) |
2603 | return; | 2606 | return; |
2604 | 2607 | ||
2605 | if (dy > sy || (dy == sy && dx > sx)) { | 2608 | if (dy > sy || (dy == sy && dx > sx)) { |
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index b004036d4087..5b3a15dffb5f 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c | |||
@@ -256,6 +256,20 @@ static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo) | |||
256 | return 0; | 256 | return 0; |
257 | } | 257 | } |
258 | 258 | ||
259 | static const struct fb_videomode *atmel_lcdfb_choose_mode(struct fb_var_screeninfo *var, | ||
260 | struct fb_info *info) | ||
261 | { | ||
262 | struct fb_videomode varfbmode; | ||
263 | const struct fb_videomode *fbmode = NULL; | ||
264 | |||
265 | fb_var_to_videomode(&varfbmode, var); | ||
266 | fbmode = fb_find_nearest_mode(&varfbmode, &info->modelist); | ||
267 | if (fbmode) | ||
268 | fb_videomode_to_var(var, fbmode); | ||
269 | return fbmode; | ||
270 | } | ||
271 | |||
272 | |||
259 | /** | 273 | /** |
260 | * atmel_lcdfb_check_var - Validates a var passed in. | 274 | * atmel_lcdfb_check_var - Validates a var passed in. |
261 | * @var: frame buffer variable screen structure | 275 | * @var: frame buffer variable screen structure |
@@ -289,6 +303,15 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, | |||
289 | clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000; | 303 | clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000; |
290 | 304 | ||
291 | dev_dbg(dev, "%s:\n", __func__); | 305 | dev_dbg(dev, "%s:\n", __func__); |
306 | |||
307 | if (!(var->pixclock && var->bits_per_pixel)) { | ||
308 | /* choose a suitable mode if possible */ | ||
309 | if (!atmel_lcdfb_choose_mode(var, info)) { | ||
310 | dev_err(dev, "needed value not specified\n"); | ||
311 | return -EINVAL; | ||
312 | } | ||
313 | } | ||
314 | |||
292 | dev_dbg(dev, " resolution: %ux%u\n", var->xres, var->yres); | 315 | dev_dbg(dev, " resolution: %ux%u\n", var->xres, var->yres); |
293 | dev_dbg(dev, " pixclk: %lu KHz\n", PICOS2KHZ(var->pixclock)); | 316 | dev_dbg(dev, " pixclk: %lu KHz\n", PICOS2KHZ(var->pixclock)); |
294 | dev_dbg(dev, " bpp: %u\n", var->bits_per_pixel); | 317 | dev_dbg(dev, " bpp: %u\n", var->bits_per_pixel); |
@@ -299,6 +322,13 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, | |||
299 | return -EINVAL; | 322 | return -EINVAL; |
300 | } | 323 | } |
301 | 324 | ||
325 | /* Do not allow to have real resoulution larger than virtual */ | ||
326 | if (var->xres > var->xres_virtual) | ||
327 | var->xres_virtual = var->xres; | ||
328 | |||
329 | if (var->yres > var->yres_virtual) | ||
330 | var->yres_virtual = var->yres; | ||
331 | |||
302 | /* Force same alignment for each line */ | 332 | /* Force same alignment for each line */ |
303 | var->xres = (var->xres + 3) & ~3UL; | 333 | var->xres = (var->xres + 3) & ~3UL; |
304 | var->xres_virtual = (var->xres_virtual + 3) & ~3UL; | 334 | var->xres_virtual = (var->xres_virtual + 3) & ~3UL; |
@@ -379,6 +409,35 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, | |||
379 | return 0; | 409 | return 0; |
380 | } | 410 | } |
381 | 411 | ||
412 | /* | ||
413 | * LCD reset sequence | ||
414 | */ | ||
415 | static void atmel_lcdfb_reset(struct atmel_lcdfb_info *sinfo) | ||
416 | { | ||
417 | might_sleep(); | ||
418 | |||
419 | /* LCD power off */ | ||
420 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET); | ||
421 | |||
422 | /* wait for the LCDC core to become idle */ | ||
423 | while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY) | ||
424 | msleep(10); | ||
425 | |||
426 | /* DMA disable */ | ||
427 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); | ||
428 | |||
429 | /* wait for DMA engine to become idle */ | ||
430 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) | ||
431 | msleep(10); | ||
432 | |||
433 | /* LCD power on */ | ||
434 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, | ||
435 | (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET) | ATMEL_LCDC_PWR); | ||
436 | |||
437 | /* DMA enable */ | ||
438 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon); | ||
439 | } | ||
440 | |||
382 | /** | 441 | /** |
383 | * atmel_lcdfb_set_par - Alters the hardware state. | 442 | * atmel_lcdfb_set_par - Alters the hardware state. |
384 | * @info: frame buffer structure that represents a single frame buffer | 443 | * @info: frame buffer structure that represents a single frame buffer |
@@ -401,6 +460,8 @@ static int atmel_lcdfb_set_par(struct fb_info *info) | |||
401 | unsigned long clk_value_khz; | 460 | unsigned long clk_value_khz; |
402 | unsigned long bits_per_line; | 461 | unsigned long bits_per_line; |
403 | 462 | ||
463 | might_sleep(); | ||
464 | |||
404 | dev_dbg(info->device, "%s:\n", __func__); | 465 | dev_dbg(info->device, "%s:\n", __func__); |
405 | dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n", | 466 | dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n", |
406 | info->var.xres, info->var.yres, | 467 | info->var.xres, info->var.yres, |
@@ -511,6 +572,8 @@ static int atmel_lcdfb_set_par(struct fb_info *info) | |||
511 | 572 | ||
512 | /* Disable all interrupts */ | 573 | /* Disable all interrupts */ |
513 | lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL); | 574 | lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL); |
575 | /* Enable FIFO & DMA errors */ | ||
576 | lcdc_writel(sinfo, ATMEL_LCDC_IER, ATMEL_LCDC_UFLWI | ATMEL_LCDC_OWRI | ATMEL_LCDC_MERI); | ||
514 | 577 | ||
515 | /* ...wait for DMA engine to become idle... */ | 578 | /* ...wait for DMA engine to become idle... */ |
516 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) | 579 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) |
@@ -645,10 +708,26 @@ static irqreturn_t atmel_lcdfb_interrupt(int irq, void *dev_id) | |||
645 | u32 status; | 708 | u32 status; |
646 | 709 | ||
647 | status = lcdc_readl(sinfo, ATMEL_LCDC_ISR); | 710 | status = lcdc_readl(sinfo, ATMEL_LCDC_ISR); |
648 | lcdc_writel(sinfo, ATMEL_LCDC_IDR, status); | 711 | if (status & ATMEL_LCDC_UFLWI) { |
712 | dev_warn(info->device, "FIFO underflow %#x\n", status); | ||
713 | /* reset DMA and FIFO to avoid screen shifting */ | ||
714 | schedule_work(&sinfo->task); | ||
715 | } | ||
716 | lcdc_writel(sinfo, ATMEL_LCDC_ICR, status); | ||
649 | return IRQ_HANDLED; | 717 | return IRQ_HANDLED; |
650 | } | 718 | } |
651 | 719 | ||
720 | /* | ||
721 | * LCD controller task (to reset the LCD) | ||
722 | */ | ||
723 | static void atmel_lcdfb_task(struct work_struct *work) | ||
724 | { | ||
725 | struct atmel_lcdfb_info *sinfo = | ||
726 | container_of(work, struct atmel_lcdfb_info, task); | ||
727 | |||
728 | atmel_lcdfb_reset(sinfo); | ||
729 | } | ||
730 | |||
652 | static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo) | 731 | static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo) |
653 | { | 732 | { |
654 | struct fb_info *info = sinfo->info; | 733 | struct fb_info *info = sinfo->info; |
@@ -691,6 +770,7 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) | |||
691 | struct fb_info *info; | 770 | struct fb_info *info; |
692 | struct atmel_lcdfb_info *sinfo; | 771 | struct atmel_lcdfb_info *sinfo; |
693 | struct atmel_lcdfb_info *pdata_sinfo; | 772 | struct atmel_lcdfb_info *pdata_sinfo; |
773 | struct fb_videomode fbmode; | ||
694 | struct resource *regs = NULL; | 774 | struct resource *regs = NULL; |
695 | struct resource *map = NULL; | 775 | struct resource *map = NULL; |
696 | int ret; | 776 | int ret; |
@@ -824,6 +904,10 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) | |||
824 | goto unmap_mmio; | 904 | goto unmap_mmio; |
825 | } | 905 | } |
826 | 906 | ||
907 | /* Some operations on the LCDC might sleep and | ||
908 | * require a preemptible task context */ | ||
909 | INIT_WORK(&sinfo->task, atmel_lcdfb_task); | ||
910 | |||
827 | ret = atmel_lcdfb_init_fbinfo(sinfo); | 911 | ret = atmel_lcdfb_init_fbinfo(sinfo); |
828 | if (ret < 0) { | 912 | if (ret < 0) { |
829 | dev_err(dev, "init fbinfo failed: %d\n", ret); | 913 | dev_err(dev, "init fbinfo failed: %d\n", ret); |
@@ -853,6 +937,10 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) | |||
853 | goto free_cmap; | 937 | goto free_cmap; |
854 | } | 938 | } |
855 | 939 | ||
940 | /* add selected videomode to modelist */ | ||
941 | fb_var_to_videomode(&fbmode, &info->var); | ||
942 | fb_add_videomode(&fbmode, &info->modelist); | ||
943 | |||
856 | /* Power up the LCDC screen */ | 944 | /* Power up the LCDC screen */ |
857 | if (sinfo->atmel_lcdfb_power_control) | 945 | if (sinfo->atmel_lcdfb_power_control) |
858 | sinfo->atmel_lcdfb_power_control(1); | 946 | sinfo->atmel_lcdfb_power_control(1); |
@@ -866,6 +954,7 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) | |||
866 | free_cmap: | 954 | free_cmap: |
867 | fb_dealloc_cmap(&info->cmap); | 955 | fb_dealloc_cmap(&info->cmap); |
868 | unregister_irqs: | 956 | unregister_irqs: |
957 | cancel_work_sync(&sinfo->task); | ||
869 | free_irq(sinfo->irq_base, info); | 958 | free_irq(sinfo->irq_base, info); |
870 | unmap_mmio: | 959 | unmap_mmio: |
871 | exit_backlight(sinfo); | 960 | exit_backlight(sinfo); |
@@ -903,6 +992,7 @@ static int __exit atmel_lcdfb_remove(struct platform_device *pdev) | |||
903 | if (!sinfo) | 992 | if (!sinfo) |
904 | return 0; | 993 | return 0; |
905 | 994 | ||
995 | cancel_work_sync(&sinfo->task); | ||
906 | exit_backlight(sinfo); | 996 | exit_backlight(sinfo); |
907 | if (sinfo->atmel_lcdfb_power_control) | 997 | if (sinfo->atmel_lcdfb_power_control) |
908 | sinfo->atmel_lcdfb_power_control(0); | 998 | sinfo->atmel_lcdfb_power_control(0); |
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index 07b6addbb3c1..243ea4ab20c8 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c | |||
@@ -1339,10 +1339,8 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll, | |||
1339 | if (vclk * 12 < c.ppll_min) | 1339 | if (vclk * 12 < c.ppll_min) |
1340 | vclk = c.ppll_min/12; | 1340 | vclk = c.ppll_min/12; |
1341 | 1341 | ||
1342 | pll->post_divider = -1; | ||
1343 | |||
1344 | /* now, find an acceptable divider */ | 1342 | /* now, find an acceptable divider */ |
1345 | for (i = 0; i < sizeof(post_dividers); i++) { | 1343 | for (i = 0; i < ARRAY_SIZE(post_dividers); i++) { |
1346 | output_freq = post_dividers[i] * vclk; | 1344 | output_freq = post_dividers[i] * vclk; |
1347 | if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) { | 1345 | if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) { |
1348 | pll->post_divider = post_dividers[i]; | 1346 | pll->post_divider = post_dividers[i]; |
@@ -1350,7 +1348,7 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll, | |||
1350 | } | 1348 | } |
1351 | } | 1349 | } |
1352 | 1350 | ||
1353 | if (pll->post_divider < 0) | 1351 | if (i == ARRAY_SIZE(post_dividers)) |
1354 | return -EINVAL; | 1352 | return -EINVAL; |
1355 | 1353 | ||
1356 | /* calculate feedback divider */ | 1354 | /* calculate feedback divider */ |
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index bd4ac0bafecb..620ba8120368 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c | |||
@@ -424,7 +424,6 @@ static struct { | |||
424 | #endif /* CONFIG_FB_ATY_CT */ | 424 | #endif /* CONFIG_FB_ATY_CT */ |
425 | }; | 425 | }; |
426 | 426 | ||
427 | /* can not fail */ | ||
428 | static int __devinit correct_chipset(struct atyfb_par *par) | 427 | static int __devinit correct_chipset(struct atyfb_par *par) |
429 | { | 428 | { |
430 | u8 rev; | 429 | u8 rev; |
@@ -437,6 +436,9 @@ static int __devinit correct_chipset(struct atyfb_par *par) | |||
437 | if (par->pci_id == aty_chips[i].pci_id) | 436 | if (par->pci_id == aty_chips[i].pci_id) |
438 | break; | 437 | break; |
439 | 438 | ||
439 | if (i < 0) | ||
440 | return -ENODEV; | ||
441 | |||
440 | name = aty_chips[i].name; | 442 | name = aty_chips[i].name; |
441 | par->pll_limits.pll_max = aty_chips[i].pll; | 443 | par->pll_limits.pll_max = aty_chips[i].pll; |
442 | par->pll_limits.mclk = aty_chips[i].mclk; | 444 | par->pll_limits.mclk = aty_chips[i].mclk; |
@@ -2229,6 +2231,7 @@ static int __devinit aty_init(struct fb_info *info) | |||
2229 | const char *ramname = NULL, *xtal; | 2231 | const char *ramname = NULL, *xtal; |
2230 | int gtb_memsize, has_var = 0; | 2232 | int gtb_memsize, has_var = 0; |
2231 | struct fb_var_screeninfo var; | 2233 | struct fb_var_screeninfo var; |
2234 | int ret; | ||
2232 | 2235 | ||
2233 | init_waitqueue_head(&par->vblank.wait); | 2236 | init_waitqueue_head(&par->vblank.wait); |
2234 | spin_lock_init(&par->int_lock); | 2237 | spin_lock_init(&par->int_lock); |
@@ -2610,7 +2613,8 @@ static int __devinit aty_init(struct fb_info *info) | |||
2610 | var.yres_virtual = var.yres; | 2613 | var.yres_virtual = var.yres; |
2611 | } | 2614 | } |
2612 | 2615 | ||
2613 | if (atyfb_check_var(&var, info)) { | 2616 | ret = atyfb_check_var(&var, info); |
2617 | if (ret) { | ||
2614 | PRINTKE("can't set default video mode\n"); | 2618 | PRINTKE("can't set default video mode\n"); |
2615 | goto aty_init_exit; | 2619 | goto aty_init_exit; |
2616 | } | 2620 | } |
@@ -2621,10 +2625,12 @@ static int __devinit aty_init(struct fb_info *info) | |||
2621 | #endif /* CONFIG_FB_ATY_CT */ | 2625 | #endif /* CONFIG_FB_ATY_CT */ |
2622 | info->var = var; | 2626 | info->var = var; |
2623 | 2627 | ||
2624 | if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) | 2628 | ret = fb_alloc_cmap(&info->cmap, 256, 0); |
2629 | if (ret < 0) | ||
2625 | goto aty_init_exit; | 2630 | goto aty_init_exit; |
2626 | 2631 | ||
2627 | if (register_framebuffer(info) < 0) { | 2632 | ret = register_framebuffer(info); |
2633 | if (ret < 0) { | ||
2628 | fb_dealloc_cmap(&info->cmap); | 2634 | fb_dealloc_cmap(&info->cmap); |
2629 | goto aty_init_exit; | 2635 | goto aty_init_exit; |
2630 | } | 2636 | } |
@@ -2650,7 +2656,7 @@ aty_init_exit: | |||
2650 | par->mtrr_aper = -1; | 2656 | par->mtrr_aper = -1; |
2651 | } | 2657 | } |
2652 | #endif | 2658 | #endif |
2653 | return -1; | 2659 | return ret; |
2654 | } | 2660 | } |
2655 | 2661 | ||
2656 | static void aty_resume_chip(struct fb_info *info) | 2662 | static void aty_resume_chip(struct fb_info *info) |
@@ -2709,8 +2715,7 @@ static int atyfb_blank(int blank, struct fb_info *info) | |||
2709 | if (par->lock_blank || par->asleep) | 2715 | if (par->lock_blank || par->asleep) |
2710 | return 0; | 2716 | return 0; |
2711 | 2717 | ||
2712 | #ifdef CONFIG_FB_ATY_BACKLIGHT | 2718 | #ifdef CONFIG_FB_ATY_GENERIC_LCD |
2713 | #elif defined(CONFIG_FB_ATY_GENERIC_LCD) | ||
2714 | if (par->lcd_table && blank > FB_BLANK_NORMAL && | 2719 | if (par->lcd_table && blank > FB_BLANK_NORMAL && |
2715 | (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { | 2720 | (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { |
2716 | u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par); | 2721 | u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par); |
@@ -2739,8 +2744,7 @@ static int atyfb_blank(int blank, struct fb_info *info) | |||
2739 | } | 2744 | } |
2740 | aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par); | 2745 | aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par); |
2741 | 2746 | ||
2742 | #ifdef CONFIG_FB_ATY_BACKLIGHT | 2747 | #ifdef CONFIG_FB_ATY_GENERIC_LCD |
2743 | #elif defined(CONFIG_FB_ATY_GENERIC_LCD) | ||
2744 | if (par->lcd_table && blank <= FB_BLANK_NORMAL && | 2748 | if (par->lcd_table && blank <= FB_BLANK_NORMAL && |
2745 | (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { | 2749 | (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { |
2746 | u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par); | 2750 | u32 pm = aty_ld_lcd(POWER_MANAGEMENT, par); |
@@ -3331,7 +3335,7 @@ static int __devinit init_from_bios(struct atyfb_par *par) | |||
3331 | PRINTKE("no BIOS frequency table found, use parameters\n"); | 3335 | PRINTKE("no BIOS frequency table found, use parameters\n"); |
3332 | ret = -ENXIO; | 3336 | ret = -ENXIO; |
3333 | } | 3337 | } |
3334 | iounmap((void* __iomem )bios_base); | 3338 | iounmap((void __iomem *)bios_base); |
3335 | 3339 | ||
3336 | return ret; | 3340 | return ret; |
3337 | } | 3341 | } |
@@ -3418,14 +3422,7 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi | |||
3418 | struct fb_info *info; | 3422 | struct fb_info *info; |
3419 | struct resource *rp; | 3423 | struct resource *rp; |
3420 | struct atyfb_par *par; | 3424 | struct atyfb_par *par; |
3421 | int i, rc = -ENOMEM; | 3425 | int rc = -ENOMEM; |
3422 | |||
3423 | for (i = ARRAY_SIZE(aty_chips) - 1; i >= 0; i--) | ||
3424 | if (pdev->device == aty_chips[i].pci_id) | ||
3425 | break; | ||
3426 | |||
3427 | if (i < 0) | ||
3428 | return -ENODEV; | ||
3429 | 3426 | ||
3430 | /* Enable device in PCI config */ | 3427 | /* Enable device in PCI config */ |
3431 | if (pci_enable_device(pdev)) { | 3428 | if (pci_enable_device(pdev)) { |
@@ -3456,7 +3453,7 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi | |||
3456 | par = info->par; | 3453 | par = info->par; |
3457 | info->fix = atyfb_fix; | 3454 | info->fix = atyfb_fix; |
3458 | info->device = &pdev->dev; | 3455 | info->device = &pdev->dev; |
3459 | par->pci_id = aty_chips[i].pci_id; | 3456 | par->pci_id = pdev->device; |
3460 | par->res_start = res_start; | 3457 | par->res_start = res_start; |
3461 | par->res_size = res_size; | 3458 | par->res_size = res_size; |
3462 | par->irq = pdev->irq; | 3459 | par->irq = pdev->irq; |
@@ -3474,7 +3471,8 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi | |||
3474 | pci_set_drvdata(pdev, info); | 3471 | pci_set_drvdata(pdev, info); |
3475 | 3472 | ||
3476 | /* Init chip & register framebuffer */ | 3473 | /* Init chip & register framebuffer */ |
3477 | if (aty_init(info)) | 3474 | rc = aty_init(info); |
3475 | if (rc) | ||
3478 | goto err_release_io; | 3476 | goto err_release_io; |
3479 | 3477 | ||
3480 | #ifdef __sparc__ | 3478 | #ifdef __sparc__ |
@@ -3655,18 +3653,62 @@ static void __devexit atyfb_pci_remove(struct pci_dev *pdev) | |||
3655 | atyfb_remove(info); | 3653 | atyfb_remove(info); |
3656 | } | 3654 | } |
3657 | 3655 | ||
3658 | /* | ||
3659 | * This driver uses its own matching table. That will be more difficult | ||
3660 | * to fix, so for now, we just match against any ATI ID and let the | ||
3661 | * probe() function find out what's up. That also mean we don't have | ||
3662 | * a module ID table though. | ||
3663 | */ | ||
3664 | static struct pci_device_id atyfb_pci_tbl[] = { | 3656 | static struct pci_device_id atyfb_pci_tbl[] = { |
3665 | { PCI_VENDOR_ID_ATI, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | 3657 | #ifdef CONFIG_FB_ATY_GX |
3666 | PCI_BASE_CLASS_DISPLAY << 16, 0xff0000, 0 }, | 3658 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GX) }, |
3667 | { 0, } | 3659 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64CX) }, |
3660 | #endif /* CONFIG_FB_ATY_GX */ | ||
3661 | |||
3662 | #ifdef CONFIG_FB_ATY_CT | ||
3663 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64CT) }, | ||
3664 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64ET) }, | ||
3665 | |||
3666 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LT) }, | ||
3667 | |||
3668 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64VT) }, | ||
3669 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GT) }, | ||
3670 | |||
3671 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64VU) }, | ||
3672 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GU) }, | ||
3673 | |||
3674 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LG) }, | ||
3675 | |||
3676 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64VV) }, | ||
3677 | |||
3678 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GV) }, | ||
3679 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GW) }, | ||
3680 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GY) }, | ||
3681 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GZ) }, | ||
3682 | |||
3683 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GB) }, | ||
3684 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GD) }, | ||
3685 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GI) }, | ||
3686 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GP) }, | ||
3687 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GQ) }, | ||
3688 | |||
3689 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LB) }, | ||
3690 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LD) }, | ||
3691 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LI) }, | ||
3692 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LP) }, | ||
3693 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LQ) }, | ||
3694 | |||
3695 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GM) }, | ||
3696 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GN) }, | ||
3697 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GO) }, | ||
3698 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GL) }, | ||
3699 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GR) }, | ||
3700 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64GS) }, | ||
3701 | |||
3702 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LM) }, | ||
3703 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LN) }, | ||
3704 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LR) }, | ||
3705 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_CHIP_MACH64LS) }, | ||
3706 | #endif /* CONFIG_FB_ATY_CT */ | ||
3707 | { } | ||
3668 | }; | 3708 | }; |
3669 | 3709 | ||
3710 | MODULE_DEVICE_TABLE(pci, atyfb_pci_tbl); | ||
3711 | |||
3670 | static struct pci_driver atyfb_driver = { | 3712 | static struct pci_driver atyfb_driver = { |
3671 | .name = "atyfb", | 3713 | .name = "atyfb", |
3672 | .id_table = atyfb_pci_tbl, | 3714 | .id_table = atyfb_pci_tbl, |
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index 400e9264e456..652273e9f5f9 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c | |||
@@ -2098,15 +2098,7 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo) | |||
2098 | 2098 | ||
2099 | static ssize_t radeon_show_one_edid(char *buf, loff_t off, size_t count, const u8 *edid) | 2099 | static ssize_t radeon_show_one_edid(char *buf, loff_t off, size_t count, const u8 *edid) |
2100 | { | 2100 | { |
2101 | if (off > EDID_LENGTH) | 2101 | return memory_read_from_buffer(buf, count, &off, edid, EDID_LENGTH); |
2102 | return 0; | ||
2103 | |||
2104 | if (off + count > EDID_LENGTH) | ||
2105 | count = EDID_LENGTH - off; | ||
2106 | |||
2107 | memcpy(buf, edid + off, count); | ||
2108 | |||
2109 | return count; | ||
2110 | } | 2102 | } |
2111 | 2103 | ||
2112 | 2104 | ||
@@ -2161,6 +2153,7 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev, | |||
2161 | struct radeonfb_info *rinfo; | 2153 | struct radeonfb_info *rinfo; |
2162 | int ret; | 2154 | int ret; |
2163 | unsigned char c1, c2; | 2155 | unsigned char c1, c2; |
2156 | int err = 0; | ||
2164 | 2157 | ||
2165 | pr_debug("radeonfb_pci_register BEGIN\n"); | 2158 | pr_debug("radeonfb_pci_register BEGIN\n"); |
2166 | 2159 | ||
@@ -2340,9 +2333,14 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev, | |||
2340 | 2333 | ||
2341 | /* Register some sysfs stuff (should be done better) */ | 2334 | /* Register some sysfs stuff (should be done better) */ |
2342 | if (rinfo->mon1_EDID) | 2335 | if (rinfo->mon1_EDID) |
2343 | sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid1_attr); | 2336 | err |= sysfs_create_bin_file(&rinfo->pdev->dev.kobj, |
2337 | &edid1_attr); | ||
2344 | if (rinfo->mon2_EDID) | 2338 | if (rinfo->mon2_EDID) |
2345 | sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid2_attr); | 2339 | err |= sysfs_create_bin_file(&rinfo->pdev->dev.kobj, |
2340 | &edid2_attr); | ||
2341 | if (err) | ||
2342 | pr_warning("%s() Creating sysfs files failed, continuing\n", | ||
2343 | __func__); | ||
2346 | 2344 | ||
2347 | /* save current mode regs before we switch into the new one | 2345 | /* save current mode regs before we switch into the new one |
2348 | * so we can restore this upon __exit | 2346 | * so we can restore this upon __exit |
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 30bf7f2f1635..452b770d8cc9 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -36,6 +36,30 @@ config LCD_LTV350QV | |||
36 | 36 | ||
37 | The LTV350QV panel is present on all ATSTK1000 boards. | 37 | The LTV350QV panel is present on all ATSTK1000 boards. |
38 | 38 | ||
39 | config LCD_ILI9320 | ||
40 | tristate | ||
41 | depends on LCD_CLASS_DEVICE && BACKLIGHT_LCD_SUPPORT | ||
42 | default n | ||
43 | help | ||
44 | If you have a panel based on the ILI9320 controller chip | ||
45 | then say y to include a power driver for it. | ||
46 | |||
47 | config LCD_VGG2432A4 | ||
48 | tristate "VGG2432A4 LCM device support" | ||
49 | depends on BACKLIGHT_LCD_SUPPORT && LCD_CLASS_DEVICE && SPI_MASTER | ||
50 | select LCD_ILI9320 | ||
51 | default n | ||
52 | help | ||
53 | If you have a VGG2432A4 panel based on the ILI9320 controller chip | ||
54 | then say y to include a power driver for it. | ||
55 | |||
56 | config LCD_PLATFORM | ||
57 | tristate "Platform LCD controls" | ||
58 | depends on LCD_CLASS_DEVICE | ||
59 | help | ||
60 | This driver provides a platform-device registered LCD power | ||
61 | control interface. | ||
62 | |||
39 | # | 63 | # |
40 | # Backlight | 64 | # Backlight |
41 | # | 65 | # |
@@ -63,6 +87,18 @@ config BACKLIGHT_ATMEL_LCDC | |||
63 | If in doubt, it's safe to enable this option; it doesn't kick | 87 | If in doubt, it's safe to enable this option; it doesn't kick |
64 | in unless the board's description says it's wired that way. | 88 | in unless the board's description says it's wired that way. |
65 | 89 | ||
90 | config BACKLIGHT_ATMEL_PWM | ||
91 | tristate "Atmel PWM backlight control" | ||
92 | depends on BACKLIGHT_CLASS_DEVICE && ATMEL_PWM | ||
93 | default n | ||
94 | help | ||
95 | Say Y here if you want to use the PWM peripheral in Atmel AT91 and | ||
96 | AVR32 devices. This driver will need additional platform data to know | ||
97 | which PWM instance to use and how to configure it. | ||
98 | |||
99 | To compile this driver as a module, choose M here: the module will be | ||
100 | called atmel-pwm-bl. | ||
101 | |||
66 | config BACKLIGHT_CORGI | 102 | config BACKLIGHT_CORGI |
67 | tristate "Generic (aka Sharp Corgi) Backlight Driver" | 103 | tristate "Generic (aka Sharp Corgi) Backlight Driver" |
68 | depends on BACKLIGHT_CLASS_DEVICE | 104 | depends on BACKLIGHT_CLASS_DEVICE |
@@ -119,3 +155,12 @@ config BACKLIGHT_PWM | |||
119 | help | 155 | help |
120 | If you have a LCD backlight adjustable by PWM, say Y to enable | 156 | If you have a LCD backlight adjustable by PWM, say Y to enable |
121 | this driver. | 157 | this driver. |
158 | |||
159 | config BACKLIGHT_MBP_NVIDIA | ||
160 | tristate "MacBook Pro Nvidia Backlight Driver" | ||
161 | depends on BACKLIGHT_CLASS_DEVICE && X86 | ||
162 | default n | ||
163 | help | ||
164 | If you have an Apple Macbook Pro with Nvidia graphics hardware say Y | ||
165 | to enable a driver for its backlight | ||
166 | |||
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index b51a7cd12500..b405aace803f 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -1,9 +1,13 @@ | |||
1 | # Backlight & LCD drivers | 1 | # Backlight & LCD drivers |
2 | 2 | ||
3 | obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o | 3 | obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o |
4 | obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o | 4 | obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o |
5 | obj-$(CONFIG_LCD_ILI9320) += ili9320.o | ||
6 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o | ||
7 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o | ||
5 | 8 | ||
6 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o | 9 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o |
10 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o | ||
7 | obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o | 11 | obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o |
8 | obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o | 12 | obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o |
9 | obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o | 13 | obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o |
@@ -11,3 +15,5 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o | |||
11 | obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o | 15 | obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o |
12 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o | 16 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o |
13 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o | 17 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o |
18 | obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o | ||
19 | |||
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c new file mode 100644 index 000000000000..505c0823a105 --- /dev/null +++ b/drivers/video/backlight/atmel-pwm-bl.c | |||
@@ -0,0 +1,244 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2008 Atmel Corporation | ||
3 | * | ||
4 | * Backlight driver using Atmel PWM peripheral. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published by | ||
8 | * the Free Software Foundation. | ||
9 | */ | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/fb.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/gpio.h> | ||
17 | #include <linux/backlight.h> | ||
18 | #include <linux/atmel_pwm.h> | ||
19 | #include <linux/atmel-pwm-bl.h> | ||
20 | |||
21 | struct atmel_pwm_bl { | ||
22 | const struct atmel_pwm_bl_platform_data *pdata; | ||
23 | struct backlight_device *bldev; | ||
24 | struct platform_device *pdev; | ||
25 | struct pwm_channel pwmc; | ||
26 | int gpio_on; | ||
27 | }; | ||
28 | |||
29 | static int atmel_pwm_bl_set_intensity(struct backlight_device *bd) | ||
30 | { | ||
31 | struct atmel_pwm_bl *pwmbl = bl_get_data(bd); | ||
32 | int intensity = bd->props.brightness; | ||
33 | int pwm_duty; | ||
34 | |||
35 | if (bd->props.power != FB_BLANK_UNBLANK) | ||
36 | intensity = 0; | ||
37 | if (bd->props.fb_blank != FB_BLANK_UNBLANK) | ||
38 | intensity = 0; | ||
39 | |||
40 | if (pwmbl->pdata->pwm_active_low) | ||
41 | pwm_duty = pwmbl->pdata->pwm_duty_min + intensity; | ||
42 | else | ||
43 | pwm_duty = pwmbl->pdata->pwm_duty_max - intensity; | ||
44 | |||
45 | if (pwm_duty > pwmbl->pdata->pwm_duty_max) | ||
46 | pwm_duty = pwmbl->pdata->pwm_duty_max; | ||
47 | if (pwm_duty < pwmbl->pdata->pwm_duty_min) | ||
48 | pwm_duty = pwmbl->pdata->pwm_duty_min; | ||
49 | |||
50 | if (!intensity) { | ||
51 | if (pwmbl->gpio_on != -1) { | ||
52 | gpio_set_value(pwmbl->gpio_on, | ||
53 | 0 ^ pwmbl->pdata->on_active_low); | ||
54 | } | ||
55 | pwm_channel_writel(&pwmbl->pwmc, PWM_CUPD, pwm_duty); | ||
56 | pwm_channel_disable(&pwmbl->pwmc); | ||
57 | } else { | ||
58 | pwm_channel_enable(&pwmbl->pwmc); | ||
59 | pwm_channel_writel(&pwmbl->pwmc, PWM_CUPD, pwm_duty); | ||
60 | if (pwmbl->gpio_on != -1) { | ||
61 | gpio_set_value(pwmbl->gpio_on, | ||
62 | 1 ^ pwmbl->pdata->on_active_low); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | static int atmel_pwm_bl_get_intensity(struct backlight_device *bd) | ||
70 | { | ||
71 | struct atmel_pwm_bl *pwmbl = bl_get_data(bd); | ||
72 | u8 intensity; | ||
73 | |||
74 | if (pwmbl->pdata->pwm_active_low) { | ||
75 | intensity = pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY) - | ||
76 | pwmbl->pdata->pwm_duty_min; | ||
77 | } else { | ||
78 | intensity = pwmbl->pdata->pwm_duty_max - | ||
79 | pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY); | ||
80 | } | ||
81 | |||
82 | return intensity; | ||
83 | } | ||
84 | |||
85 | static int atmel_pwm_bl_init_pwm(struct atmel_pwm_bl *pwmbl) | ||
86 | { | ||
87 | unsigned long pwm_rate = pwmbl->pwmc.mck; | ||
88 | unsigned long prescale = DIV_ROUND_UP(pwm_rate, | ||
89 | (pwmbl->pdata->pwm_frequency * | ||
90 | pwmbl->pdata->pwm_compare_max)) - 1; | ||
91 | |||
92 | /* | ||
93 | * Prescale must be power of two and maximum 0xf in size because of | ||
94 | * hardware limit. PWM speed will be: | ||
95 | * PWM module clock speed / (2 ^ prescale). | ||
96 | */ | ||
97 | prescale = fls(prescale); | ||
98 | if (prescale > 0xf) | ||
99 | prescale = 0xf; | ||
100 | |||
101 | pwm_channel_writel(&pwmbl->pwmc, PWM_CMR, prescale); | ||
102 | pwm_channel_writel(&pwmbl->pwmc, PWM_CDTY, | ||
103 | pwmbl->pdata->pwm_duty_min + | ||
104 | pwmbl->bldev->props.brightness); | ||
105 | pwm_channel_writel(&pwmbl->pwmc, PWM_CPRD, | ||
106 | pwmbl->pdata->pwm_compare_max); | ||
107 | |||
108 | dev_info(&pwmbl->pdev->dev, "Atmel PWM backlight driver " | ||
109 | "(%lu Hz)\n", pwmbl->pwmc.mck / | ||
110 | pwmbl->pdata->pwm_compare_max / | ||
111 | (1 << prescale)); | ||
112 | |||
113 | return pwm_channel_enable(&pwmbl->pwmc); | ||
114 | } | ||
115 | |||
116 | static struct backlight_ops atmel_pwm_bl_ops = { | ||
117 | .get_brightness = atmel_pwm_bl_get_intensity, | ||
118 | .update_status = atmel_pwm_bl_set_intensity, | ||
119 | }; | ||
120 | |||
121 | static int atmel_pwm_bl_probe(struct platform_device *pdev) | ||
122 | { | ||
123 | const struct atmel_pwm_bl_platform_data *pdata; | ||
124 | struct backlight_device *bldev; | ||
125 | struct atmel_pwm_bl *pwmbl; | ||
126 | int retval; | ||
127 | |||
128 | pwmbl = kzalloc(sizeof(struct atmel_pwm_bl), GFP_KERNEL); | ||
129 | if (!pwmbl) | ||
130 | return -ENOMEM; | ||
131 | |||
132 | pwmbl->pdev = pdev; | ||
133 | |||
134 | pdata = pdev->dev.platform_data; | ||
135 | if (!pdata) { | ||
136 | retval = -ENODEV; | ||
137 | goto err_free_mem; | ||
138 | } | ||
139 | |||
140 | if (pdata->pwm_compare_max < pdata->pwm_duty_max || | ||
141 | pdata->pwm_duty_min > pdata->pwm_duty_max || | ||
142 | pdata->pwm_frequency == 0) { | ||
143 | retval = -EINVAL; | ||
144 | goto err_free_mem; | ||
145 | } | ||
146 | |||
147 | pwmbl->pdata = pdata; | ||
148 | pwmbl->gpio_on = pdata->gpio_on; | ||
149 | |||
150 | retval = pwm_channel_alloc(pdata->pwm_channel, &pwmbl->pwmc); | ||
151 | if (retval) | ||
152 | goto err_free_mem; | ||
153 | |||
154 | if (pwmbl->gpio_on != -1) { | ||
155 | retval = gpio_request(pwmbl->gpio_on, "gpio_atmel_pwm_bl"); | ||
156 | if (retval) { | ||
157 | pwmbl->gpio_on = -1; | ||
158 | goto err_free_pwm; | ||
159 | } | ||
160 | |||
161 | /* Turn display off by defatult. */ | ||
162 | retval = gpio_direction_output(pwmbl->gpio_on, | ||
163 | 0 ^ pdata->on_active_low); | ||
164 | if (retval) | ||
165 | goto err_free_gpio; | ||
166 | } | ||
167 | |||
168 | bldev = backlight_device_register("atmel-pwm-bl", | ||
169 | &pdev->dev, pwmbl, &atmel_pwm_bl_ops); | ||
170 | if (IS_ERR(bldev)) { | ||
171 | retval = PTR_ERR(bldev); | ||
172 | goto err_free_gpio; | ||
173 | } | ||
174 | |||
175 | pwmbl->bldev = bldev; | ||
176 | |||
177 | platform_set_drvdata(pdev, pwmbl); | ||
178 | |||
179 | /* Power up the backlight by default at middle intesity. */ | ||
180 | bldev->props.power = FB_BLANK_UNBLANK; | ||
181 | bldev->props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min; | ||
182 | bldev->props.brightness = bldev->props.max_brightness / 2; | ||
183 | |||
184 | retval = atmel_pwm_bl_init_pwm(pwmbl); | ||
185 | if (retval) | ||
186 | goto err_free_bl_dev; | ||
187 | |||
188 | atmel_pwm_bl_set_intensity(bldev); | ||
189 | |||
190 | return 0; | ||
191 | |||
192 | err_free_bl_dev: | ||
193 | platform_set_drvdata(pdev, NULL); | ||
194 | backlight_device_unregister(bldev); | ||
195 | err_free_gpio: | ||
196 | if (pwmbl->gpio_on != -1) | ||
197 | gpio_free(pwmbl->gpio_on); | ||
198 | err_free_pwm: | ||
199 | pwm_channel_free(&pwmbl->pwmc); | ||
200 | err_free_mem: | ||
201 | kfree(pwmbl); | ||
202 | return retval; | ||
203 | } | ||
204 | |||
205 | static int __exit atmel_pwm_bl_remove(struct platform_device *pdev) | ||
206 | { | ||
207 | struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev); | ||
208 | |||
209 | if (pwmbl->gpio_on != -1) { | ||
210 | gpio_set_value(pwmbl->gpio_on, 0); | ||
211 | gpio_free(pwmbl->gpio_on); | ||
212 | } | ||
213 | pwm_channel_disable(&pwmbl->pwmc); | ||
214 | pwm_channel_free(&pwmbl->pwmc); | ||
215 | backlight_device_unregister(pwmbl->bldev); | ||
216 | platform_set_drvdata(pdev, NULL); | ||
217 | kfree(pwmbl); | ||
218 | |||
219 | return 0; | ||
220 | } | ||
221 | |||
222 | static struct platform_driver atmel_pwm_bl_driver = { | ||
223 | .driver = { | ||
224 | .name = "atmel-pwm-bl", | ||
225 | }, | ||
226 | /* REVISIT add suspend() and resume() */ | ||
227 | .remove = __exit_p(atmel_pwm_bl_remove), | ||
228 | }; | ||
229 | |||
230 | static int __init atmel_pwm_bl_init(void) | ||
231 | { | ||
232 | return platform_driver_probe(&atmel_pwm_bl_driver, atmel_pwm_bl_probe); | ||
233 | } | ||
234 | module_init(atmel_pwm_bl_init); | ||
235 | |||
236 | static void __exit atmel_pwm_bl_exit(void) | ||
237 | { | ||
238 | platform_driver_unregister(&atmel_pwm_bl_driver); | ||
239 | } | ||
240 | module_exit(atmel_pwm_bl_exit); | ||
241 | |||
242 | MODULE_AUTHOR("Hans-Christian egtvedt <hans-christian.egtvedt@atmel.com>"); | ||
243 | MODULE_DESCRIPTION("Atmel PWM backlight driver"); | ||
244 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 39394757679c..fab0bc874b58 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
@@ -191,6 +191,7 @@ static struct device_attribute bl_device_attributes[] = { | |||
191 | * backlight_device class. | 191 | * backlight_device class. |
192 | * @name: the name of the new object(must be the same as the name of the | 192 | * @name: the name of the new object(must be the same as the name of the |
193 | * respective framebuffer device). | 193 | * respective framebuffer device). |
194 | * @parent: a pointer to the parent device | ||
194 | * @devdata: an optional pointer to be stored for private driver use. The | 195 | * @devdata: an optional pointer to be stored for private driver use. The |
195 | * methods may retrieve it by using bl_get_data(bd). | 196 | * methods may retrieve it by using bl_get_data(bd). |
196 | * @ops: the backlight operations structure. | 197 | * @ops: the backlight operations structure. |
diff --git a/drivers/video/backlight/ili9320.c b/drivers/video/backlight/ili9320.c new file mode 100644 index 000000000000..ba89b41b639c --- /dev/null +++ b/drivers/video/backlight/ili9320.c | |||
@@ -0,0 +1,330 @@ | |||
1 | /* drivers/video/backlight/ili9320.c | ||
2 | * | ||
3 | * ILI9320 LCD controller driver core. | ||
4 | * | ||
5 | * Copyright 2007 Simtec Electronics | ||
6 | * http://armlinux.simtec.co.uk/ | ||
7 | * Ben Dooks <ben@simtec.co.uk> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/delay.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/fb.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/lcd.h> | ||
19 | #include <linux/module.h> | ||
20 | |||
21 | #include <linux/spi/spi.h> | ||
22 | |||
23 | #include <video/ili9320.h> | ||
24 | |||
25 | #include "ili9320.h" | ||
26 | |||
27 | |||
28 | static inline int ili9320_write_spi(struct ili9320 *ili, | ||
29 | unsigned int reg, | ||
30 | unsigned int value) | ||
31 | { | ||
32 | struct ili9320_spi *spi = &ili->access.spi; | ||
33 | unsigned char *addr = spi->buffer_addr; | ||
34 | unsigned char *data = spi->buffer_data; | ||
35 | |||
36 | /* spi message consits of: | ||
37 | * first byte: ID and operation | ||
38 | */ | ||
39 | |||
40 | addr[0] = spi->id | ILI9320_SPI_INDEX | ILI9320_SPI_WRITE; | ||
41 | addr[1] = reg >> 8; | ||
42 | addr[2] = reg; | ||
43 | |||
44 | /* second message is the data to transfer */ | ||
45 | |||
46 | data[0] = spi->id | ILI9320_SPI_DATA | ILI9320_SPI_WRITE; | ||
47 | data[1] = value >> 8; | ||
48 | data[2] = value; | ||
49 | |||
50 | return spi_sync(spi->dev, &spi->message); | ||
51 | } | ||
52 | |||
53 | int ili9320_write(struct ili9320 *ili, unsigned int reg, unsigned int value) | ||
54 | { | ||
55 | dev_dbg(ili->dev, "write: reg=%02x, val=%04x\n", reg, value); | ||
56 | return ili->write(ili, reg, value); | ||
57 | } | ||
58 | |||
59 | EXPORT_SYMBOL_GPL(ili9320_write); | ||
60 | |||
61 | int ili9320_write_regs(struct ili9320 *ili, | ||
62 | struct ili9320_reg *values, | ||
63 | int nr_values) | ||
64 | { | ||
65 | int index; | ||
66 | int ret; | ||
67 | |||
68 | for (index = 0; index < nr_values; index++, values++) { | ||
69 | ret = ili9320_write(ili, values->address, values->value); | ||
70 | if (ret != 0) | ||
71 | return ret; | ||
72 | } | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | EXPORT_SYMBOL_GPL(ili9320_write_regs); | ||
78 | |||
79 | static void ili9320_reset(struct ili9320 *lcd) | ||
80 | { | ||
81 | struct ili9320_platdata *cfg = lcd->platdata; | ||
82 | |||
83 | cfg->reset(1); | ||
84 | mdelay(50); | ||
85 | |||
86 | cfg->reset(0); | ||
87 | mdelay(50); | ||
88 | |||
89 | cfg->reset(1); | ||
90 | mdelay(100); | ||
91 | } | ||
92 | |||
93 | static inline int ili9320_init_chip(struct ili9320 *lcd) | ||
94 | { | ||
95 | int ret; | ||
96 | |||
97 | ili9320_reset(lcd); | ||
98 | |||
99 | ret = lcd->client->init(lcd, lcd->platdata); | ||
100 | if (ret != 0) { | ||
101 | dev_err(lcd->dev, "failed to initialise display\n"); | ||
102 | return ret; | ||
103 | } | ||
104 | |||
105 | lcd->initialised = 1; | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static inline int ili9320_power_on(struct ili9320 *lcd) | ||
110 | { | ||
111 | if (!lcd->initialised) | ||
112 | ili9320_init_chip(lcd); | ||
113 | |||
114 | lcd->display1 |= (ILI9320_DISPLAY1_D(3) | ILI9320_DISPLAY1_BASEE); | ||
115 | ili9320_write(lcd, ILI9320_DISPLAY1, lcd->display1); | ||
116 | |||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static inline int ili9320_power_off(struct ili9320 *lcd) | ||
121 | { | ||
122 | lcd->display1 &= ~(ILI9320_DISPLAY1_D(3) | ILI9320_DISPLAY1_BASEE); | ||
123 | ili9320_write(lcd, ILI9320_DISPLAY1, lcd->display1); | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) | ||
129 | |||
130 | static int ili9320_power(struct ili9320 *lcd, int power) | ||
131 | { | ||
132 | int ret = 0; | ||
133 | |||
134 | dev_dbg(lcd->dev, "power %d => %d\n", lcd->power, power); | ||
135 | |||
136 | if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power)) | ||
137 | ret = ili9320_power_on(lcd); | ||
138 | else if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power)) | ||
139 | ret = ili9320_power_off(lcd); | ||
140 | |||
141 | if (ret == 0) | ||
142 | lcd->power = power; | ||
143 | else | ||
144 | dev_warn(lcd->dev, "failed to set power mode %d\n", power); | ||
145 | |||
146 | return ret; | ||
147 | } | ||
148 | |||
149 | static inline struct ili9320 *to_our_lcd(struct lcd_device *lcd) | ||
150 | { | ||
151 | return lcd_get_data(lcd); | ||
152 | } | ||
153 | |||
154 | static int ili9320_set_power(struct lcd_device *ld, int power) | ||
155 | { | ||
156 | struct ili9320 *lcd = to_our_lcd(ld); | ||
157 | |||
158 | return ili9320_power(lcd, power); | ||
159 | } | ||
160 | |||
161 | static int ili9320_get_power(struct lcd_device *ld) | ||
162 | { | ||
163 | struct ili9320 *lcd = to_our_lcd(ld); | ||
164 | |||
165 | return lcd->power; | ||
166 | } | ||
167 | |||
168 | static struct lcd_ops ili9320_ops = { | ||
169 | .get_power = ili9320_get_power, | ||
170 | .set_power = ili9320_set_power, | ||
171 | }; | ||
172 | |||
173 | static void __devinit ili9320_setup_spi(struct ili9320 *ili, | ||
174 | struct spi_device *dev) | ||
175 | { | ||
176 | struct ili9320_spi *spi = &ili->access.spi; | ||
177 | |||
178 | ili->write = ili9320_write_spi; | ||
179 | spi->dev = dev; | ||
180 | |||
181 | /* fill the two messages we are going to use to send the data | ||
182 | * with, the first the address followed by the data. The datasheet | ||
183 | * says they should be done as two distinct cycles of the SPI CS line. | ||
184 | */ | ||
185 | |||
186 | spi->xfer[0].tx_buf = spi->buffer_addr; | ||
187 | spi->xfer[1].tx_buf = spi->buffer_data; | ||
188 | spi->xfer[0].len = 3; | ||
189 | spi->xfer[1].len = 3; | ||
190 | spi->xfer[0].bits_per_word = 8; | ||
191 | spi->xfer[1].bits_per_word = 8; | ||
192 | spi->xfer[0].cs_change = 1; | ||
193 | |||
194 | spi_message_init(&spi->message); | ||
195 | spi_message_add_tail(&spi->xfer[0], &spi->message); | ||
196 | spi_message_add_tail(&spi->xfer[1], &spi->message); | ||
197 | } | ||
198 | |||
199 | int __devinit ili9320_probe_spi(struct spi_device *spi, | ||
200 | struct ili9320_client *client) | ||
201 | { | ||
202 | struct ili9320_platdata *cfg = spi->dev.platform_data; | ||
203 | struct device *dev = &spi->dev; | ||
204 | struct ili9320 *ili; | ||
205 | struct lcd_device *lcd; | ||
206 | int ret = 0; | ||
207 | |||
208 | /* verify we where given some information */ | ||
209 | |||
210 | if (cfg == NULL) { | ||
211 | dev_err(dev, "no platform data supplied\n"); | ||
212 | return -EINVAL; | ||
213 | } | ||
214 | |||
215 | if (cfg->hsize <= 0 || cfg->vsize <= 0 || cfg->reset == NULL) { | ||
216 | dev_err(dev, "invalid platform data supplied\n"); | ||
217 | return -EINVAL; | ||
218 | } | ||
219 | |||
220 | /* allocate and initialse our state */ | ||
221 | |||
222 | ili = kzalloc(sizeof(struct ili9320), GFP_KERNEL); | ||
223 | if (ili == NULL) { | ||
224 | dev_err(dev, "no memory for device\n"); | ||
225 | return -ENOMEM; | ||
226 | } | ||
227 | |||
228 | ili->access.spi.id = ILI9320_SPI_IDCODE | ILI9320_SPI_ID(1); | ||
229 | |||
230 | ili->dev = dev; | ||
231 | ili->client = client; | ||
232 | ili->power = FB_BLANK_POWERDOWN; | ||
233 | ili->platdata = cfg; | ||
234 | |||
235 | dev_set_drvdata(&spi->dev, ili); | ||
236 | |||
237 | ili9320_setup_spi(ili, spi); | ||
238 | |||
239 | lcd = lcd_device_register("ili9320", dev, ili, &ili9320_ops); | ||
240 | if (IS_ERR(lcd)) { | ||
241 | dev_err(dev, "failed to register lcd device\n"); | ||
242 | ret = PTR_ERR(lcd); | ||
243 | goto err_free; | ||
244 | } | ||
245 | |||
246 | ili->lcd = lcd; | ||
247 | |||
248 | dev_info(dev, "initialising %s\n", client->name); | ||
249 | |||
250 | ret = ili9320_power(ili, FB_BLANK_UNBLANK); | ||
251 | if (ret != 0) { | ||
252 | dev_err(dev, "failed to set lcd power state\n"); | ||
253 | goto err_unregister; | ||
254 | } | ||
255 | |||
256 | return 0; | ||
257 | |||
258 | err_unregister: | ||
259 | lcd_device_unregister(lcd); | ||
260 | |||
261 | err_free: | ||
262 | kfree(ili); | ||
263 | |||
264 | return ret; | ||
265 | } | ||
266 | |||
267 | EXPORT_SYMBOL_GPL(ili9320_probe_spi); | ||
268 | |||
269 | int __devexit ili9320_remove(struct ili9320 *ili) | ||
270 | { | ||
271 | ili9320_power(ili, FB_BLANK_POWERDOWN); | ||
272 | |||
273 | lcd_device_unregister(ili->lcd); | ||
274 | kfree(ili); | ||
275 | |||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | EXPORT_SYMBOL_GPL(ili9320_remove); | ||
280 | |||
281 | #ifdef CONFIG_PM | ||
282 | int ili9320_suspend(struct ili9320 *lcd, pm_message_t state) | ||
283 | { | ||
284 | int ret; | ||
285 | |||
286 | dev_dbg(lcd->dev, "%s: event %d\n", __func__, state.event); | ||
287 | |||
288 | if (state.event == PM_EVENT_SUSPEND) { | ||
289 | ret = ili9320_power(lcd, FB_BLANK_POWERDOWN); | ||
290 | |||
291 | if (lcd->platdata->suspend == ILI9320_SUSPEND_DEEP) { | ||
292 | ili9320_write(lcd, ILI9320_POWER1, lcd->power1 | | ||
293 | ILI9320_POWER1_SLP | | ||
294 | ILI9320_POWER1_DSTB); | ||
295 | lcd->initialised = 0; | ||
296 | } | ||
297 | |||
298 | return ret; | ||
299 | } | ||
300 | |||
301 | return 0; | ||
302 | } | ||
303 | |||
304 | EXPORT_SYMBOL_GPL(ili9320_suspend); | ||
305 | |||
306 | int ili9320_resume(struct ili9320 *lcd) | ||
307 | { | ||
308 | dev_info(lcd->dev, "resuming from power state %d\n", lcd->power); | ||
309 | |||
310 | if (lcd->platdata->suspend == ILI9320_SUSPEND_DEEP) { | ||
311 | ili9320_write(lcd, ILI9320_POWER1, 0x00); | ||
312 | } | ||
313 | |||
314 | return ili9320_power(lcd, FB_BLANK_UNBLANK); | ||
315 | } | ||
316 | |||
317 | EXPORT_SYMBOL_GPL(ili9320_resume); | ||
318 | #endif | ||
319 | |||
320 | /* Power down all displays on reboot, poweroff or halt */ | ||
321 | void ili9320_shutdown(struct ili9320 *lcd) | ||
322 | { | ||
323 | ili9320_power(lcd, FB_BLANK_POWERDOWN); | ||
324 | } | ||
325 | |||
326 | EXPORT_SYMBOL_GPL(ili9320_shutdown); | ||
327 | |||
328 | MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>"); | ||
329 | MODULE_DESCRIPTION("ILI9320 LCD Driver"); | ||
330 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/video/backlight/ili9320.h b/drivers/video/backlight/ili9320.h new file mode 100644 index 000000000000..e388eca7cac5 --- /dev/null +++ b/drivers/video/backlight/ili9320.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /* drivers/video/backlight/ili9320.h | ||
2 | * | ||
3 | * ILI9320 LCD controller driver core. | ||
4 | * | ||
5 | * Copyright 2007 Simtec Electronics | ||
6 | * Ben Dooks <ben@simtec.co.uk> | ||
7 | * | ||
8 | * http://armlinux.simtec.co.uk/ | ||
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 version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | /* Holder for register and value pairs. */ | ||
16 | struct ili9320_reg { | ||
17 | unsigned short address; | ||
18 | unsigned short value; | ||
19 | }; | ||
20 | |||
21 | struct ili9320; | ||
22 | |||
23 | struct ili9320_client { | ||
24 | const char *name; | ||
25 | int (*init)(struct ili9320 *ili, struct ili9320_platdata *cfg); | ||
26 | |||
27 | }; | ||
28 | /* Device attached via an SPI bus. */ | ||
29 | struct ili9320_spi { | ||
30 | struct spi_device *dev; | ||
31 | struct spi_message message; | ||
32 | struct spi_transfer xfer[2]; | ||
33 | |||
34 | unsigned char id; | ||
35 | unsigned char buffer_addr[4]; | ||
36 | unsigned char buffer_data[4]; | ||
37 | }; | ||
38 | |||
39 | /* ILI9320 device state. */ | ||
40 | struct ili9320 { | ||
41 | union { | ||
42 | struct ili9320_spi spi; /* SPI attachged device. */ | ||
43 | } access; /* Register access method. */ | ||
44 | |||
45 | struct device *dev; | ||
46 | struct lcd_device *lcd; /* LCD device we created. */ | ||
47 | struct ili9320_client *client; | ||
48 | struct ili9320_platdata *platdata; | ||
49 | |||
50 | int power; /* current power state. */ | ||
51 | int initialised; | ||
52 | |||
53 | unsigned short display1; | ||
54 | unsigned short power1; | ||
55 | |||
56 | int (*write)(struct ili9320 *ili, unsigned int reg, unsigned int val); | ||
57 | }; | ||
58 | |||
59 | |||
60 | /* ILI9320 register access routines */ | ||
61 | |||
62 | extern int ili9320_write(struct ili9320 *ili, | ||
63 | unsigned int reg, unsigned int value); | ||
64 | |||
65 | extern int ili9320_write_regs(struct ili9320 *ili, | ||
66 | struct ili9320_reg *values, | ||
67 | int nr_values); | ||
68 | |||
69 | /* Device probe */ | ||
70 | |||
71 | extern int ili9320_probe_spi(struct spi_device *spi, | ||
72 | struct ili9320_client *cli); | ||
73 | |||
74 | extern int ili9320_remove(struct ili9320 *lcd); | ||
75 | extern void ili9320_shutdown(struct ili9320 *lcd); | ||
76 | |||
77 | /* PM */ | ||
78 | |||
79 | extern int ili9320_suspend(struct ili9320 *lcd, pm_message_t state); | ||
80 | extern int ili9320_resume(struct ili9320 *lcd); | ||
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index 299fd318dd45..b15b2b84a6f7 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c | |||
@@ -33,7 +33,7 @@ static int fb_notifier_callback(struct notifier_block *self, | |||
33 | ld = container_of(self, struct lcd_device, fb_notif); | 33 | ld = container_of(self, struct lcd_device, fb_notif); |
34 | mutex_lock(&ld->ops_lock); | 34 | mutex_lock(&ld->ops_lock); |
35 | if (ld->ops) | 35 | if (ld->ops) |
36 | if (!ld->ops->check_fb || ld->ops->check_fb(evdata->info)) | 36 | if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) |
37 | ld->ops->set_power(ld, *(int *)evdata->data); | 37 | ld->ops->set_power(ld, *(int *)evdata->data); |
38 | mutex_unlock(&ld->ops_lock); | 38 | mutex_unlock(&ld->ops_lock); |
39 | return 0; | 39 | return 0; |
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c new file mode 100644 index 000000000000..385cba40ea87 --- /dev/null +++ b/drivers/video/backlight/mbp_nvidia_bl.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * Backlight Driver for Nvidia 8600 in Macbook Pro | ||
3 | * | ||
4 | * Copyright (c) Red Hat <mjg@redhat.com> | ||
5 | * Based on code from Pommed: | ||
6 | * Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch> | ||
7 | * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org> | ||
8 | * Copyright (C) 2007 Julien BLACHE <jb@jblache.org> | ||
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 version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | * This driver triggers SMIs which cause the firmware to change the | ||
15 | * backlight brightness. This is icky in many ways, but it's impractical to | ||
16 | * get at the firmware code in order to figure out what it's actually doing. | ||
17 | */ | ||
18 | |||
19 | #include <linux/module.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/backlight.h> | ||
24 | #include <linux/err.h> | ||
25 | #include <linux/dmi.h> | ||
26 | #include <linux/io.h> | ||
27 | |||
28 | static struct backlight_device *mbp_backlight_device; | ||
29 | |||
30 | static struct dmi_system_id __initdata mbp_device_table[] = { | ||
31 | { | ||
32 | .ident = "3,1", | ||
33 | .matches = { | ||
34 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | ||
35 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"), | ||
36 | }, | ||
37 | }, | ||
38 | { | ||
39 | .ident = "3,2", | ||
40 | .matches = { | ||
41 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | ||
42 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,2"), | ||
43 | }, | ||
44 | }, | ||
45 | { | ||
46 | .ident = "4,1", | ||
47 | .matches = { | ||
48 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | ||
49 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro4,1"), | ||
50 | }, | ||
51 | }, | ||
52 | { } | ||
53 | }; | ||
54 | |||
55 | static int mbp_send_intensity(struct backlight_device *bd) | ||
56 | { | ||
57 | int intensity = bd->props.brightness; | ||
58 | |||
59 | outb(0x04 | (intensity << 4), 0xb3); | ||
60 | outb(0xbf, 0xb2); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int mbp_get_intensity(struct backlight_device *bd) | ||
66 | { | ||
67 | outb(0x03, 0xb3); | ||
68 | outb(0xbf, 0xb2); | ||
69 | return inb(0xb3) >> 4; | ||
70 | } | ||
71 | |||
72 | static struct backlight_ops mbp_ops = { | ||
73 | .get_brightness = mbp_get_intensity, | ||
74 | .update_status = mbp_send_intensity, | ||
75 | }; | ||
76 | |||
77 | static int __init mbp_init(void) | ||
78 | { | ||
79 | if (!dmi_check_system(mbp_device_table)) | ||
80 | return -ENODEV; | ||
81 | |||
82 | if (!request_region(0xb2, 2, "Macbook Pro backlight")) | ||
83 | return -ENXIO; | ||
84 | |||
85 | mbp_backlight_device = backlight_device_register("mbp_backlight", | ||
86 | NULL, NULL, | ||
87 | &mbp_ops); | ||
88 | if (IS_ERR(mbp_backlight_device)) { | ||
89 | release_region(0xb2, 2); | ||
90 | return PTR_ERR(mbp_backlight_device); | ||
91 | } | ||
92 | |||
93 | mbp_backlight_device->props.max_brightness = 15; | ||
94 | mbp_backlight_device->props.brightness = | ||
95 | mbp_get_intensity(mbp_backlight_device); | ||
96 | backlight_update_status(mbp_backlight_device); | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static void __exit mbp_exit(void) | ||
102 | { | ||
103 | backlight_device_unregister(mbp_backlight_device); | ||
104 | |||
105 | release_region(0xb2, 2); | ||
106 | } | ||
107 | |||
108 | module_init(mbp_init); | ||
109 | module_exit(mbp_exit); | ||
110 | |||
111 | MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); | ||
112 | MODULE_DESCRIPTION("Nvidia-based Macbook Pro Backlight Driver"); | ||
113 | MODULE_LICENSE("GPL"); | ||
114 | MODULE_ALIAS("svnAppleInc.:pnMacBookPro3,1"); | ||
115 | MODULE_ALIAS("svnAppleInc.:pnMacBookPro3,2"); | ||
116 | MODULE_ALIAS("svnAppleInc.:pnMacBookPro4,1"); | ||
diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c new file mode 100644 index 000000000000..72d44dbfce82 --- /dev/null +++ b/drivers/video/backlight/platform_lcd.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* drivers/video/backlight/platform_lcd.c | ||
2 | * | ||
3 | * Copyright 2008 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * Generic platform-device LCD power control interface. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/fb.h> | ||
17 | #include <linux/backlight.h> | ||
18 | #include <linux/lcd.h> | ||
19 | |||
20 | #include <video/platform_lcd.h> | ||
21 | |||
22 | struct platform_lcd { | ||
23 | struct device *us; | ||
24 | struct lcd_device *lcd; | ||
25 | struct plat_lcd_data *pdata; | ||
26 | |||
27 | unsigned int power; | ||
28 | unsigned int suspended : 1; | ||
29 | }; | ||
30 | |||
31 | static inline struct platform_lcd *to_our_lcd(struct lcd_device *lcd) | ||
32 | { | ||
33 | return lcd_get_data(lcd); | ||
34 | } | ||
35 | |||
36 | static int platform_lcd_get_power(struct lcd_device *lcd) | ||
37 | { | ||
38 | struct platform_lcd *plcd = to_our_lcd(lcd); | ||
39 | |||
40 | return plcd->power; | ||
41 | } | ||
42 | |||
43 | static int platform_lcd_set_power(struct lcd_device *lcd, int power) | ||
44 | { | ||
45 | struct platform_lcd *plcd = to_our_lcd(lcd); | ||
46 | int lcd_power = 1; | ||
47 | |||
48 | if (power == FB_BLANK_POWERDOWN || plcd->suspended) | ||
49 | lcd_power = 0; | ||
50 | |||
51 | plcd->pdata->set_power(plcd->pdata, lcd_power); | ||
52 | plcd->power = power; | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | static int platform_lcd_match(struct lcd_device *lcd, struct fb_info *info) | ||
58 | { | ||
59 | struct platform_lcd *plcd = to_our_lcd(lcd); | ||
60 | struct plat_lcd_data *pdata = plcd->pdata; | ||
61 | |||
62 | if (pdata->match_fb) | ||
63 | return pdata->match_fb(pdata, info); | ||
64 | |||
65 | return plcd->us->parent == info->device; | ||
66 | } | ||
67 | |||
68 | static struct lcd_ops platform_lcd_ops = { | ||
69 | .get_power = platform_lcd_get_power, | ||
70 | .set_power = platform_lcd_set_power, | ||
71 | .check_fb = platform_lcd_match, | ||
72 | }; | ||
73 | |||
74 | static int __devinit platform_lcd_probe(struct platform_device *pdev) | ||
75 | { | ||
76 | struct plat_lcd_data *pdata; | ||
77 | struct platform_lcd *plcd; | ||
78 | struct device *dev = &pdev->dev; | ||
79 | int err; | ||
80 | |||
81 | pdata = pdev->dev.platform_data; | ||
82 | if (!pdata) { | ||
83 | dev_err(dev, "no platform data supplied\n"); | ||
84 | return -EINVAL; | ||
85 | } | ||
86 | |||
87 | plcd = kzalloc(sizeof(struct platform_lcd), GFP_KERNEL); | ||
88 | if (!plcd) { | ||
89 | dev_err(dev, "no memory for state\n"); | ||
90 | return -ENOMEM; | ||
91 | } | ||
92 | |||
93 | plcd->us = dev; | ||
94 | plcd->pdata = pdata; | ||
95 | plcd->lcd = lcd_device_register("platform-lcd", dev, | ||
96 | plcd, &platform_lcd_ops); | ||
97 | if (IS_ERR(plcd->lcd)) { | ||
98 | dev_err(dev, "cannot register lcd device\n"); | ||
99 | err = PTR_ERR(plcd->lcd); | ||
100 | goto err_mem; | ||
101 | } | ||
102 | |||
103 | platform_set_drvdata(pdev, plcd); | ||
104 | return 0; | ||
105 | |||
106 | err_mem: | ||
107 | kfree(plcd); | ||
108 | return err; | ||
109 | } | ||
110 | |||
111 | static int __devexit platform_lcd_remove(struct platform_device *pdev) | ||
112 | { | ||
113 | struct platform_lcd *plcd = platform_get_drvdata(pdev); | ||
114 | |||
115 | lcd_device_unregister(plcd->lcd); | ||
116 | kfree(plcd); | ||
117 | |||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | #ifdef CONFIG_PM | ||
122 | static int platform_lcd_suspend(struct platform_device *pdev, pm_message_t st) | ||
123 | { | ||
124 | struct platform_lcd *plcd = platform_get_drvdata(pdev); | ||
125 | |||
126 | plcd->suspended = 1; | ||
127 | platform_lcd_set_power(plcd->lcd, plcd->power); | ||
128 | |||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | static int platform_lcd_resume(struct platform_device *pdev) | ||
133 | { | ||
134 | struct platform_lcd *plcd = platform_get_drvdata(pdev); | ||
135 | |||
136 | plcd->suspended = 0; | ||
137 | platform_lcd_set_power(plcd->lcd, plcd->power); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | #else | ||
142 | #define platform_lcd_suspend NULL | ||
143 | #define platform_lcd_resume NULL | ||
144 | #endif | ||
145 | |||
146 | static struct platform_driver platform_lcd_driver = { | ||
147 | .driver = { | ||
148 | .name = "platform-lcd", | ||
149 | .owner = THIS_MODULE, | ||
150 | }, | ||
151 | .probe = platform_lcd_probe, | ||
152 | .remove = __devexit_p(platform_lcd_remove), | ||
153 | .suspend = platform_lcd_suspend, | ||
154 | .resume = platform_lcd_resume, | ||
155 | }; | ||
156 | |||
157 | static int __init platform_lcd_init(void) | ||
158 | { | ||
159 | return platform_driver_register(&platform_lcd_driver); | ||
160 | } | ||
161 | |||
162 | static void __exit platform_lcd_cleanup(void) | ||
163 | { | ||
164 | platform_driver_unregister(&platform_lcd_driver); | ||
165 | } | ||
166 | |||
167 | module_init(platform_lcd_init); | ||
168 | module_exit(platform_lcd_cleanup); | ||
169 | |||
170 | MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>"); | ||
171 | MODULE_LICENSE("GPL v2"); | ||
172 | MODULE_ALIAS("platform:platform-lcd"); | ||
diff --git a/drivers/video/backlight/vgg2432a4.c b/drivers/video/backlight/vgg2432a4.c new file mode 100644 index 000000000000..593c7687d54a --- /dev/null +++ b/drivers/video/backlight/vgg2432a4.c | |||
@@ -0,0 +1,284 @@ | |||
1 | /* drivers/video/backlight/vgg2432a4.c | ||
2 | * | ||
3 | * VGG2432A4 (ILI9320) LCD controller driver. | ||
4 | * | ||
5 | * Copyright 2007 Simtec Electronics | ||
6 | * http://armlinux.simtec.co.uk/ | ||
7 | * Ben Dooks <ben@simtec.co.uk> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/delay.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/fb.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/lcd.h> | ||
19 | #include <linux/module.h> | ||
20 | |||
21 | #include <linux/spi/spi.h> | ||
22 | |||
23 | #include <video/ili9320.h> | ||
24 | |||
25 | #include "ili9320.h" | ||
26 | |||
27 | /* Device initialisation sequences */ | ||
28 | |||
29 | static struct ili9320_reg vgg_init1[] = { | ||
30 | { | ||
31 | .address = ILI9320_POWER1, | ||
32 | .value = ILI9320_POWER1_AP(0) | ILI9320_POWER1_BT(0), | ||
33 | }, { | ||
34 | .address = ILI9320_POWER2, | ||
35 | .value = (ILI9320_POWER2_VC(7) | | ||
36 | ILI9320_POWER2_DC0(0) | ILI9320_POWER2_DC1(0)), | ||
37 | }, { | ||
38 | .address = ILI9320_POWER3, | ||
39 | .value = ILI9320_POWER3_VRH(0), | ||
40 | }, { | ||
41 | .address = ILI9320_POWER4, | ||
42 | .value = ILI9320_POWER4_VREOUT(0), | ||
43 | }, | ||
44 | }; | ||
45 | |||
46 | static struct ili9320_reg vgg_init2[] = { | ||
47 | { | ||
48 | .address = ILI9320_POWER1, | ||
49 | .value = (ILI9320_POWER1_AP(3) | ILI9320_POWER1_APE | | ||
50 | ILI9320_POWER1_BT(7) | ILI9320_POWER1_SAP), | ||
51 | }, { | ||
52 | .address = ILI9320_POWER2, | ||
53 | .value = ILI9320_POWER2_VC(7) | ILI9320_POWER2_DC0(3), | ||
54 | } | ||
55 | }; | ||
56 | |||
57 | static struct ili9320_reg vgg_gamma[] = { | ||
58 | { | ||
59 | .address = ILI9320_GAMMA1, | ||
60 | .value = 0x0000, | ||
61 | }, { | ||
62 | .address = ILI9320_GAMMA2, | ||
63 | .value = 0x0505, | ||
64 | }, { | ||
65 | .address = ILI9320_GAMMA3, | ||
66 | .value = 0x0004, | ||
67 | }, { | ||
68 | .address = ILI9320_GAMMA4, | ||
69 | .value = 0x0006, | ||
70 | }, { | ||
71 | .address = ILI9320_GAMMA5, | ||
72 | .value = 0x0707, | ||
73 | }, { | ||
74 | .address = ILI9320_GAMMA6, | ||
75 | .value = 0x0105, | ||
76 | }, { | ||
77 | .address = ILI9320_GAMMA7, | ||
78 | .value = 0x0002, | ||
79 | }, { | ||
80 | .address = ILI9320_GAMMA8, | ||
81 | .value = 0x0707, | ||
82 | }, { | ||
83 | .address = ILI9320_GAMMA9, | ||
84 | .value = 0x0704, | ||
85 | }, { | ||
86 | .address = ILI9320_GAMMA10, | ||
87 | .value = 0x807, | ||
88 | } | ||
89 | |||
90 | }; | ||
91 | |||
92 | static struct ili9320_reg vgg_init0[] = { | ||
93 | [0] = { | ||
94 | /* set direction and scan mode gate */ | ||
95 | .address = ILI9320_DRIVER, | ||
96 | .value = ILI9320_DRIVER_SS, | ||
97 | }, { | ||
98 | .address = ILI9320_DRIVEWAVE, | ||
99 | .value = (ILI9320_DRIVEWAVE_MUSTSET | | ||
100 | ILI9320_DRIVEWAVE_EOR | ILI9320_DRIVEWAVE_BC), | ||
101 | }, { | ||
102 | .address = ILI9320_ENTRYMODE, | ||
103 | .value = ILI9320_ENTRYMODE_ID(3) | ILI9320_ENTRYMODE_BGR, | ||
104 | }, { | ||
105 | .address = ILI9320_RESIZING, | ||
106 | .value = 0x0, | ||
107 | }, | ||
108 | }; | ||
109 | |||
110 | |||
111 | static int vgg2432a4_lcd_init(struct ili9320 *lcd, | ||
112 | struct ili9320_platdata *cfg) | ||
113 | { | ||
114 | unsigned int addr; | ||
115 | int ret; | ||
116 | |||
117 | /* Set VCore before anything else (VGG243237-6UFLWA) */ | ||
118 | ret = ili9320_write(lcd, 0x00e5, 0x8000); | ||
119 | if (ret) | ||
120 | goto err_initial; | ||
121 | |||
122 | /* Start the oscillator up before we can do anything else. */ | ||
123 | ret = ili9320_write(lcd, ILI9320_OSCILATION, ILI9320_OSCILATION_OSC); | ||
124 | if (ret) | ||
125 | goto err_initial; | ||
126 | |||
127 | /* must wait at-lesat 10ms after starting */ | ||
128 | mdelay(15); | ||
129 | |||
130 | ret = ili9320_write_regs(lcd, vgg_init0, ARRAY_SIZE(vgg_init0)); | ||
131 | if (ret != 0) | ||
132 | goto err_initial; | ||
133 | |||
134 | ili9320_write(lcd, ILI9320_DISPLAY2, cfg->display2); | ||
135 | ili9320_write(lcd, ILI9320_DISPLAY3, cfg->display3); | ||
136 | ili9320_write(lcd, ILI9320_DISPLAY4, cfg->display4); | ||
137 | |||
138 | ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1); | ||
139 | ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0); | ||
140 | ili9320_write(lcd, ILI9320_RGB_IF2, ILI9320_RGBIF2_DPL); | ||
141 | |||
142 | ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1)); | ||
143 | if (ret != 0) | ||
144 | goto err_vgg; | ||
145 | |||
146 | mdelay(300); | ||
147 | |||
148 | ret = ili9320_write_regs(lcd, vgg_init2, ARRAY_SIZE(vgg_init2)); | ||
149 | if (ret != 0) | ||
150 | goto err_vgg2; | ||
151 | |||
152 | mdelay(100); | ||
153 | |||
154 | ili9320_write(lcd, ILI9320_POWER3, 0x13c); | ||
155 | |||
156 | mdelay(100); | ||
157 | |||
158 | ili9320_write(lcd, ILI9320_POWER4, 0x1c00); | ||
159 | ili9320_write(lcd, ILI9320_POWER7, 0x000e); | ||
160 | |||
161 | mdelay(100); | ||
162 | |||
163 | ili9320_write(lcd, ILI9320_GRAM_HORIZ_ADDR, 0x00); | ||
164 | ili9320_write(lcd, ILI9320_GRAM_VERT_ADD, 0x00); | ||
165 | |||
166 | ret = ili9320_write_regs(lcd, vgg_gamma, ARRAY_SIZE(vgg_gamma)); | ||
167 | if (ret != 0) | ||
168 | goto err_vgg3; | ||
169 | |||
170 | ili9320_write(lcd, ILI9320_HORIZ_START, 0x0); | ||
171 | ili9320_write(lcd, ILI9320_HORIZ_END, cfg->hsize - 1); | ||
172 | ili9320_write(lcd, ILI9320_VERT_START, 0x0); | ||
173 | ili9320_write(lcd, ILI9320_VERT_END, cfg->vsize - 1); | ||
174 | |||
175 | ili9320_write(lcd, ILI9320_DRIVER2, | ||
176 | ILI9320_DRIVER2_NL(((cfg->vsize - 240) / 8) + 0x1D)); | ||
177 | |||
178 | ili9320_write(lcd, ILI9320_BASE_IMAGE, 0x1); | ||
179 | ili9320_write(lcd, ILI9320_VERT_SCROLL, 0x00); | ||
180 | |||
181 | for (addr = ILI9320_PARTIAL1_POSITION; addr <= ILI9320_PARTIAL2_END; | ||
182 | addr++) { | ||
183 | ili9320_write(lcd, addr, 0x0); | ||
184 | } | ||
185 | |||
186 | ili9320_write(lcd, ILI9320_INTERFACE1, 0x10); | ||
187 | ili9320_write(lcd, ILI9320_INTERFACE2, cfg->interface2); | ||
188 | ili9320_write(lcd, ILI9320_INTERFACE3, cfg->interface3); | ||
189 | ili9320_write(lcd, ILI9320_INTERFACE4, cfg->interface4); | ||
190 | ili9320_write(lcd, ILI9320_INTERFACE5, cfg->interface5); | ||
191 | ili9320_write(lcd, ILI9320_INTERFACE6, cfg->interface6); | ||
192 | |||
193 | lcd->display1 = (ILI9320_DISPLAY1_D(3) | ILI9320_DISPLAY1_DTE | | ||
194 | ILI9320_DISPLAY1_GON | ILI9320_DISPLAY1_BASEE | | ||
195 | 0x40); | ||
196 | |||
197 | ili9320_write(lcd, ILI9320_DISPLAY1, lcd->display1); | ||
198 | |||
199 | return 0; | ||
200 | |||
201 | err_vgg3: | ||
202 | err_vgg2: | ||
203 | err_vgg: | ||
204 | err_initial: | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | #ifdef CONFIG_PM | ||
209 | static int vgg2432a4_suspend(struct spi_device *spi, pm_message_t state) | ||
210 | { | ||
211 | return ili9320_suspend(dev_get_drvdata(&spi->dev), state); | ||
212 | } | ||
213 | |||
214 | static int vgg2432a4_resume(struct spi_device *spi) | ||
215 | { | ||
216 | return ili9320_resume(dev_get_drvdata(&spi->dev)); | ||
217 | } | ||
218 | #else | ||
219 | #define vgg2432a4_suspend NULL | ||
220 | #define vgg2432a4_resume NULL | ||
221 | #endif | ||
222 | |||
223 | static struct ili9320_client vgg2432a4_client = { | ||
224 | .name = "VGG2432A4", | ||
225 | .init = vgg2432a4_lcd_init, | ||
226 | }; | ||
227 | |||
228 | /* Device probe */ | ||
229 | |||
230 | static int __devinit vgg2432a4_probe(struct spi_device *spi) | ||
231 | { | ||
232 | int ret; | ||
233 | |||
234 | ret = ili9320_probe_spi(spi, &vgg2432a4_client); | ||
235 | if (ret != 0) { | ||
236 | dev_err(&spi->dev, "failed to initialise ili9320\n"); | ||
237 | return ret; | ||
238 | } | ||
239 | |||
240 | return 0; | ||
241 | } | ||
242 | |||
243 | static int __devexit vgg2432a4_remove(struct spi_device *spi) | ||
244 | { | ||
245 | return ili9320_remove(dev_get_drvdata(&spi->dev)); | ||
246 | } | ||
247 | |||
248 | static void vgg2432a4_shutdown(struct spi_device *spi) | ||
249 | { | ||
250 | ili9320_shutdown(dev_get_drvdata(&spi->dev)); | ||
251 | } | ||
252 | |||
253 | static struct spi_driver vgg2432a4_driver = { | ||
254 | .driver = { | ||
255 | .name = "VGG2432A4", | ||
256 | .owner = THIS_MODULE, | ||
257 | }, | ||
258 | .probe = vgg2432a4_probe, | ||
259 | .remove = __devexit_p(vgg2432a4_remove), | ||
260 | .shutdown = vgg2432a4_shutdown, | ||
261 | .suspend = vgg2432a4_suspend, | ||
262 | .resume = vgg2432a4_resume, | ||
263 | }; | ||
264 | |||
265 | /* Device driver initialisation */ | ||
266 | |||
267 | static int __init vgg2432a4_init(void) | ||
268 | { | ||
269 | return spi_register_driver(&vgg2432a4_driver); | ||
270 | } | ||
271 | |||
272 | static void __exit vgg2432a4_exit(void) | ||
273 | { | ||
274 | spi_unregister_driver(&vgg2432a4_driver); | ||
275 | } | ||
276 | |||
277 | module_init(vgg2432a4_init); | ||
278 | module_exit(vgg2432a4_exit); | ||
279 | |||
280 | MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>"); | ||
281 | MODULE_DESCRIPTION("VGG2432A4 LCD Driver"); | ||
282 | MODULE_LICENSE("GPL v2"); | ||
283 | |||
284 | |||
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c index 49834a67a623..940467aed13f 100644 --- a/drivers/video/bf54x-lq043fb.c +++ b/drivers/video/bf54x-lq043fb.c | |||
@@ -478,7 +478,7 @@ static int bfin_lcd_set_contrast(struct lcd_device *dev, int contrast) | |||
478 | return 0; | 478 | return 0; |
479 | } | 479 | } |
480 | 480 | ||
481 | static int bfin_lcd_check_fb(struct fb_info *fi) | 481 | static int bfin_lcd_check_fb(struct lcd_device *dev, struct fb_info *fi) |
482 | { | 482 | { |
483 | if (!fi || (fi == &bfin_bf54x_fb)) | 483 | if (!fi || (fi == &bfin_bf54x_fb)) |
484 | return 1; | 484 | return 1; |
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c index 135d6dd7e672..7d1b819e501c 100644 --- a/drivers/video/bfin-t350mcqb-fb.c +++ b/drivers/video/bfin-t350mcqb-fb.c | |||
@@ -396,7 +396,7 @@ static int bfin_lcd_set_contrast(struct lcd_device *dev, int contrast) | |||
396 | return 0; | 396 | return 0; |
397 | } | 397 | } |
398 | 398 | ||
399 | static int bfin_lcd_check_fb(struct fb_info *fi) | 399 | static int bfin_lcd_check_fb(struct lcd_device *dev, struct fb_info *fi) |
400 | { | 400 | { |
401 | if (!fi || (fi == &bfin_t350mcqb_fb)) | 401 | if (!fi || (fi == &bfin_t350mcqb_fb)) |
402 | return 1; | 402 | return 1; |
diff --git a/drivers/video/carminefb.c b/drivers/video/carminefb.c new file mode 100644 index 000000000000..e15bb447440a --- /dev/null +++ b/drivers/video/carminefb.c | |||
@@ -0,0 +1,790 @@ | |||
1 | /* | ||
2 | * Frame buffer driver for the Carmine GPU. | ||
3 | * | ||
4 | * The driver configures the GPU as follows | ||
5 | * - FB0 is display 0 with unique memory area | ||
6 | * - FB1 is display 1 with unique memory area | ||
7 | * - both display use 32 bit colors | ||
8 | */ | ||
9 | #include <linux/delay.h> | ||
10 | #include <linux/errno.h> | ||
11 | #include <linux/fb.h> | ||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/pci.h> | ||
14 | |||
15 | #include "carminefb.h" | ||
16 | #include "carminefb_regs.h" | ||
17 | |||
18 | #if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN) | ||
19 | #error "The endianness of the target host has not been defined." | ||
20 | #endif | ||
21 | |||
22 | /* | ||
23 | * The initial video mode can be supplied via two different ways: | ||
24 | * - as a string that is passed to fb_find_mode() (module option fb_mode_str) | ||
25 | * - as an integer that picks the video mode from carmine_modedb[] (module | ||
26 | * option fb_mode) | ||
27 | * | ||
28 | * If nothing is used than the initial video mode will be the | ||
29 | * CARMINEFB_DEFAULT_VIDEO_MODE member of the carmine_modedb[]. | ||
30 | */ | ||
31 | #define CARMINEFB_DEFAULT_VIDEO_MODE 1 | ||
32 | |||
33 | static unsigned int fb_mode = CARMINEFB_DEFAULT_VIDEO_MODE; | ||
34 | module_param(fb_mode, uint, 444); | ||
35 | MODULE_PARM_DESC(fb_mode, "Initial video mode as integer."); | ||
36 | |||
37 | static char *fb_mode_str; | ||
38 | module_param(fb_mode_str, charp, 444); | ||
39 | MODULE_PARM_DESC(fb_mode_str, "Initial video mode in characters."); | ||
40 | |||
41 | /* | ||
42 | * Carminefb displays: | ||
43 | * 0b000 None | ||
44 | * 0b001 Display 0 | ||
45 | * 0b010 Display 1 | ||
46 | */ | ||
47 | static int fb_displays = CARMINE_USE_DISPLAY0 | CARMINE_USE_DISPLAY1; | ||
48 | module_param(fb_displays, int, 444); | ||
49 | MODULE_PARM_DESC(fb_displays, "Bit mode, which displays are used"); | ||
50 | |||
51 | struct carmine_hw { | ||
52 | void __iomem *v_regs; | ||
53 | void __iomem *screen_mem; | ||
54 | struct fb_info *fb[MAX_DISPLAY]; | ||
55 | }; | ||
56 | |||
57 | struct carmine_resolution { | ||
58 | u32 htp; | ||
59 | u32 hsp; | ||
60 | u32 hsw; | ||
61 | u32 hdp; | ||
62 | u32 vtr; | ||
63 | u32 vsp; | ||
64 | u32 vsw; | ||
65 | u32 vdp; | ||
66 | u32 disp_mode; | ||
67 | }; | ||
68 | |||
69 | struct carmine_fb { | ||
70 | void __iomem *display_reg; | ||
71 | void __iomem *screen_base; | ||
72 | u32 smem_offset; | ||
73 | u32 cur_mode; | ||
74 | u32 new_mode; | ||
75 | struct carmine_resolution *res; | ||
76 | u32 pseudo_palette[16]; | ||
77 | }; | ||
78 | |||
79 | static struct fb_fix_screeninfo carminefb_fix __devinitdata = { | ||
80 | .id = "Carmine", | ||
81 | .type = FB_TYPE_PACKED_PIXELS, | ||
82 | .visual = FB_VISUAL_TRUECOLOR, | ||
83 | .accel = FB_ACCEL_NONE, | ||
84 | }; | ||
85 | |||
86 | static const struct fb_videomode carmine_modedb[] = { | ||
87 | { | ||
88 | .name = "640x480", | ||
89 | .xres = 640, | ||
90 | .yres = 480, | ||
91 | }, { | ||
92 | .name = "800x600", | ||
93 | .xres = 800, | ||
94 | .yres = 600, | ||
95 | }, | ||
96 | }; | ||
97 | |||
98 | static struct carmine_resolution car_modes[] = { | ||
99 | { | ||
100 | /* 640x480 */ | ||
101 | .htp = 800, | ||
102 | .hsp = 672, | ||
103 | .hsw = 96, | ||
104 | .hdp = 640, | ||
105 | .vtr = 525, | ||
106 | .vsp = 490, | ||
107 | .vsw = 2, | ||
108 | .vdp = 480, | ||
109 | .disp_mode = 0x1400, | ||
110 | }, | ||
111 | { | ||
112 | /* 800x600 */ | ||
113 | .htp = 1060, | ||
114 | .hsp = 864, | ||
115 | .hsw = 72, | ||
116 | .hdp = 800, | ||
117 | .vtr = 628, | ||
118 | .vsp = 601, | ||
119 | .vsw = 2, | ||
120 | .vdp = 600, | ||
121 | .disp_mode = 0x0d00, | ||
122 | } | ||
123 | }; | ||
124 | |||
125 | static int carmine_find_mode(const struct fb_var_screeninfo *var) | ||
126 | { | ||
127 | int i; | ||
128 | |||
129 | for (i = 0; i < ARRAY_SIZE(car_modes); i++) | ||
130 | if (car_modes[i].hdp == var->xres && | ||
131 | car_modes[i].vdp == var->yres) | ||
132 | return i; | ||
133 | return -EINVAL; | ||
134 | } | ||
135 | |||
136 | static void c_set_disp_reg(const struct carmine_fb *par, | ||
137 | u32 offset, u32 val) | ||
138 | { | ||
139 | writel(val, par->display_reg + offset); | ||
140 | } | ||
141 | |||
142 | static u32 c_get_disp_reg(const struct carmine_fb *par, | ||
143 | u32 offset) | ||
144 | { | ||
145 | return readl(par->display_reg + offset); | ||
146 | } | ||
147 | |||
148 | static void c_set_hw_reg(const struct carmine_hw *hw, | ||
149 | u32 offset, u32 val) | ||
150 | { | ||
151 | writel(val, hw->v_regs + offset); | ||
152 | } | ||
153 | |||
154 | static u32 c_get_hw_reg(const struct carmine_hw *hw, | ||
155 | u32 offset) | ||
156 | { | ||
157 | return readl(hw->v_regs + offset); | ||
158 | } | ||
159 | |||
160 | static int carmine_setcolreg(unsigned regno, unsigned red, unsigned green, | ||
161 | unsigned blue, unsigned transp, struct fb_info *info) | ||
162 | { | ||
163 | if (regno >= 16) | ||
164 | return 1; | ||
165 | |||
166 | red >>= 8; | ||
167 | green >>= 8; | ||
168 | blue >>= 8; | ||
169 | transp >>= 8; | ||
170 | |||
171 | ((u32 *)info->pseudo_palette)[regno] = be32_to_cpu(transp << 24 | | ||
172 | red << 0 | green << 8 | blue << 16); | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static int carmine_check_var(struct fb_var_screeninfo *var, | ||
177 | struct fb_info *info) | ||
178 | { | ||
179 | int ret; | ||
180 | |||
181 | ret = carmine_find_mode(var); | ||
182 | if (ret < 0) | ||
183 | return ret; | ||
184 | |||
185 | if (var->grayscale || var->rotate || var->nonstd) | ||
186 | return -EINVAL; | ||
187 | |||
188 | var->xres_virtual = var->xres; | ||
189 | var->yres_virtual = var->yres; | ||
190 | |||
191 | var->bits_per_pixel = 32; | ||
192 | |||
193 | #ifdef __BIG_ENDIAN | ||
194 | var->transp.offset = 24; | ||
195 | var->red.offset = 0; | ||
196 | var->green.offset = 8; | ||
197 | var->blue.offset = 16; | ||
198 | #else | ||
199 | var->transp.offset = 24; | ||
200 | var->red.offset = 16; | ||
201 | var->green.offset = 8; | ||
202 | var->blue.offset = 0; | ||
203 | #endif | ||
204 | |||
205 | var->red.length = 8; | ||
206 | var->green.length = 8; | ||
207 | var->blue.length = 8; | ||
208 | var->transp.length = 8; | ||
209 | |||
210 | var->red.msb_right = 0; | ||
211 | var->green.msb_right = 0; | ||
212 | var->blue.msb_right = 0; | ||
213 | var->transp.msb_right = 0; | ||
214 | return 0; | ||
215 | } | ||
216 | |||
217 | static void carmine_init_display_param(struct carmine_fb *par) | ||
218 | { | ||
219 | u32 width; | ||
220 | u32 height; | ||
221 | u32 param; | ||
222 | u32 window_size; | ||
223 | u32 soffset = par->smem_offset; | ||
224 | |||
225 | c_set_disp_reg(par, CARMINE_DISP_REG_C_TRANS, 0); | ||
226 | c_set_disp_reg(par, CARMINE_DISP_REG_MLMR_TRANS, 0); | ||
227 | c_set_disp_reg(par, CARMINE_DISP_REG_CURSOR_MODE, | ||
228 | CARMINE_CURSOR0_PRIORITY_MASK | | ||
229 | CARMINE_CURSOR1_PRIORITY_MASK | | ||
230 | CARMINE_CURSOR_CUTZ_MASK); | ||
231 | |||
232 | /* Set default cursor position */ | ||
233 | c_set_disp_reg(par, CARMINE_DISP_REG_CUR1_POS, 0 << 16 | 0); | ||
234 | c_set_disp_reg(par, CARMINE_DISP_REG_CUR2_POS, 0 << 16 | 0); | ||
235 | |||
236 | /* Set default display mode */ | ||
237 | c_set_disp_reg(par, CARMINE_DISP_REG_L0_EXT_MODE, CARMINE_WINDOW_MODE | | ||
238 | CARMINE_EXT_CMODE_DIRECT24_RGBA); | ||
239 | c_set_disp_reg(par, CARMINE_DISP_REG_L1_EXT_MODE, | ||
240 | CARMINE_EXT_CMODE_DIRECT24_RGBA); | ||
241 | c_set_disp_reg(par, CARMINE_DISP_REG_L2_EXT_MODE, CARMINE_EXTEND_MODE | | ||
242 | CARMINE_EXT_CMODE_DIRECT24_RGBA); | ||
243 | c_set_disp_reg(par, CARMINE_DISP_REG_L3_EXT_MODE, CARMINE_EXTEND_MODE | | ||
244 | CARMINE_EXT_CMODE_DIRECT24_RGBA); | ||
245 | c_set_disp_reg(par, CARMINE_DISP_REG_L4_EXT_MODE, CARMINE_EXTEND_MODE | | ||
246 | CARMINE_EXT_CMODE_DIRECT24_RGBA); | ||
247 | c_set_disp_reg(par, CARMINE_DISP_REG_L5_EXT_MODE, CARMINE_EXTEND_MODE | | ||
248 | CARMINE_EXT_CMODE_DIRECT24_RGBA); | ||
249 | c_set_disp_reg(par, CARMINE_DISP_REG_L6_EXT_MODE, CARMINE_EXTEND_MODE | | ||
250 | CARMINE_EXT_CMODE_DIRECT24_RGBA); | ||
251 | c_set_disp_reg(par, CARMINE_DISP_REG_L7_EXT_MODE, CARMINE_EXTEND_MODE | | ||
252 | CARMINE_EXT_CMODE_DIRECT24_RGBA); | ||
253 | |||
254 | /* Set default frame size to layer mode register */ | ||
255 | width = par->res->hdp * 4 / CARMINE_DISP_WIDTH_UNIT; | ||
256 | width = width << CARMINE_DISP_WIDTH_SHIFT; | ||
257 | |||
258 | height = par->res->vdp - 1; | ||
259 | param = width | height; | ||
260 | |||
261 | c_set_disp_reg(par, CARMINE_DISP_REG_L0_MODE_W_H, param); | ||
262 | c_set_disp_reg(par, CARMINE_DISP_REG_L1_WIDTH, width); | ||
263 | c_set_disp_reg(par, CARMINE_DISP_REG_L2_MODE_W_H, param); | ||
264 | c_set_disp_reg(par, CARMINE_DISP_REG_L3_MODE_W_H, param); | ||
265 | c_set_disp_reg(par, CARMINE_DISP_REG_L4_MODE_W_H, param); | ||
266 | c_set_disp_reg(par, CARMINE_DISP_REG_L5_MODE_W_H, param); | ||
267 | c_set_disp_reg(par, CARMINE_DISP_REG_L6_MODE_W_H, param); | ||
268 | c_set_disp_reg(par, CARMINE_DISP_REG_L7_MODE_W_H, param); | ||
269 | |||
270 | /* Set default pos and size */ | ||
271 | window_size = (par->res->vdp - 1) << CARMINE_DISP_WIN_H_SHIFT; | ||
272 | window_size |= par->res->hdp; | ||
273 | |||
274 | c_set_disp_reg(par, CARMINE_DISP_REG_L0_WIN_POS, 0); | ||
275 | c_set_disp_reg(par, CARMINE_DISP_REG_L0_WIN_SIZE, window_size); | ||
276 | c_set_disp_reg(par, CARMINE_DISP_REG_L1_WIN_POS, 0); | ||
277 | c_set_disp_reg(par, CARMINE_DISP_REG_L1_WIN_SIZE, window_size); | ||
278 | c_set_disp_reg(par, CARMINE_DISP_REG_L2_WIN_POS, 0); | ||
279 | c_set_disp_reg(par, CARMINE_DISP_REG_L2_WIN_SIZE, window_size); | ||
280 | c_set_disp_reg(par, CARMINE_DISP_REG_L3_WIN_POS, 0); | ||
281 | c_set_disp_reg(par, CARMINE_DISP_REG_L3_WIN_SIZE, window_size); | ||
282 | c_set_disp_reg(par, CARMINE_DISP_REG_L4_WIN_POS, 0); | ||
283 | c_set_disp_reg(par, CARMINE_DISP_REG_L4_WIN_SIZE, window_size); | ||
284 | c_set_disp_reg(par, CARMINE_DISP_REG_L5_WIN_POS, 0); | ||
285 | c_set_disp_reg(par, CARMINE_DISP_REG_L5_WIN_SIZE, window_size); | ||
286 | c_set_disp_reg(par, CARMINE_DISP_REG_L6_WIN_POS, 0); | ||
287 | c_set_disp_reg(par, CARMINE_DISP_REG_L6_WIN_SIZE, window_size); | ||
288 | c_set_disp_reg(par, CARMINE_DISP_REG_L7_WIN_POS, 0); | ||
289 | c_set_disp_reg(par, CARMINE_DISP_REG_L7_WIN_SIZE, window_size); | ||
290 | |||
291 | /* Set default origin address */ | ||
292 | c_set_disp_reg(par, CARMINE_DISP_REG_L0_ORG_ADR, soffset); | ||
293 | c_set_disp_reg(par, CARMINE_DISP_REG_L1_ORG_ADR, soffset); | ||
294 | c_set_disp_reg(par, CARMINE_DISP_REG_L2_ORG_ADR1, soffset); | ||
295 | c_set_disp_reg(par, CARMINE_DISP_REG_L3_ORG_ADR1, soffset); | ||
296 | c_set_disp_reg(par, CARMINE_DISP_REG_L4_ORG_ADR1, soffset); | ||
297 | c_set_disp_reg(par, CARMINE_DISP_REG_L5_ORG_ADR1, soffset); | ||
298 | c_set_disp_reg(par, CARMINE_DISP_REG_L6_ORG_ADR1, soffset); | ||
299 | c_set_disp_reg(par, CARMINE_DISP_REG_L7_ORG_ADR1, soffset); | ||
300 | |||
301 | /* Set default display address */ | ||
302 | c_set_disp_reg(par, CARMINE_DISP_REG_L0_DISP_ADR, soffset); | ||
303 | c_set_disp_reg(par, CARMINE_DISP_REG_L2_DISP_ADR1, soffset); | ||
304 | c_set_disp_reg(par, CARMINE_DISP_REG_L3_DISP_ADR1, soffset); | ||
305 | c_set_disp_reg(par, CARMINE_DISP_REG_L4_DISP_ADR1, soffset); | ||
306 | c_set_disp_reg(par, CARMINE_DISP_REG_L5_DISP_ADR1, soffset); | ||
307 | c_set_disp_reg(par, CARMINE_DISP_REG_L6_DISP_ADR0, soffset); | ||
308 | c_set_disp_reg(par, CARMINE_DISP_REG_L7_DISP_ADR0, soffset); | ||
309 | |||
310 | /* Set default display position */ | ||
311 | c_set_disp_reg(par, CARMINE_DISP_REG_L0_DISP_POS, 0); | ||
312 | c_set_disp_reg(par, CARMINE_DISP_REG_L2_DISP_POS, 0); | ||
313 | c_set_disp_reg(par, CARMINE_DISP_REG_L3_DISP_POS, 0); | ||
314 | c_set_disp_reg(par, CARMINE_DISP_REG_L4_DISP_POS, 0); | ||
315 | c_set_disp_reg(par, CARMINE_DISP_REG_L5_DISP_POS, 0); | ||
316 | c_set_disp_reg(par, CARMINE_DISP_REG_L6_DISP_POS, 0); | ||
317 | c_set_disp_reg(par, CARMINE_DISP_REG_L7_DISP_POS, 0); | ||
318 | |||
319 | /* Set default blend mode */ | ||
320 | c_set_disp_reg(par, CARMINE_DISP_REG_BLEND_MODE_L0, 0); | ||
321 | c_set_disp_reg(par, CARMINE_DISP_REG_BLEND_MODE_L1, 0); | ||
322 | c_set_disp_reg(par, CARMINE_DISP_REG_BLEND_MODE_L2, 0); | ||
323 | c_set_disp_reg(par, CARMINE_DISP_REG_BLEND_MODE_L3, 0); | ||
324 | c_set_disp_reg(par, CARMINE_DISP_REG_BLEND_MODE_L4, 0); | ||
325 | c_set_disp_reg(par, CARMINE_DISP_REG_BLEND_MODE_L5, 0); | ||
326 | c_set_disp_reg(par, CARMINE_DISP_REG_BLEND_MODE_L6, 0); | ||
327 | c_set_disp_reg(par, CARMINE_DISP_REG_BLEND_MODE_L7, 0); | ||
328 | |||
329 | /* default transparency mode */ | ||
330 | c_set_disp_reg(par, CARMINE_DISP_REG_L0_TRANS, 0); | ||
331 | c_set_disp_reg(par, CARMINE_DISP_REG_L1_TRANS, 0); | ||
332 | c_set_disp_reg(par, CARMINE_DISP_REG_L2_TRANS, 0); | ||
333 | c_set_disp_reg(par, CARMINE_DISP_REG_L3_TRANS, 0); | ||
334 | c_set_disp_reg(par, CARMINE_DISP_REG_L4_TRANS, 0); | ||
335 | c_set_disp_reg(par, CARMINE_DISP_REG_L5_TRANS, 0); | ||
336 | c_set_disp_reg(par, CARMINE_DISP_REG_L6_TRANS, 0); | ||
337 | c_set_disp_reg(par, CARMINE_DISP_REG_L7_TRANS, 0); | ||
338 | |||
339 | /* Set default read skip parameter */ | ||
340 | c_set_disp_reg(par, CARMINE_DISP_REG_L0RM, 0); | ||
341 | c_set_disp_reg(par, CARMINE_DISP_REG_L2RM, 0); | ||
342 | c_set_disp_reg(par, CARMINE_DISP_REG_L3RM, 0); | ||
343 | c_set_disp_reg(par, CARMINE_DISP_REG_L4RM, 0); | ||
344 | c_set_disp_reg(par, CARMINE_DISP_REG_L5RM, 0); | ||
345 | c_set_disp_reg(par, CARMINE_DISP_REG_L6RM, 0); | ||
346 | c_set_disp_reg(par, CARMINE_DISP_REG_L7RM, 0); | ||
347 | |||
348 | c_set_disp_reg(par, CARMINE_DISP_REG_L0PX, 0); | ||
349 | c_set_disp_reg(par, CARMINE_DISP_REG_L2PX, 0); | ||
350 | c_set_disp_reg(par, CARMINE_DISP_REG_L3PX, 0); | ||
351 | c_set_disp_reg(par, CARMINE_DISP_REG_L4PX, 0); | ||
352 | c_set_disp_reg(par, CARMINE_DISP_REG_L5PX, 0); | ||
353 | c_set_disp_reg(par, CARMINE_DISP_REG_L6PX, 0); | ||
354 | c_set_disp_reg(par, CARMINE_DISP_REG_L7PX, 0); | ||
355 | |||
356 | c_set_disp_reg(par, CARMINE_DISP_REG_L0PY, 0); | ||
357 | c_set_disp_reg(par, CARMINE_DISP_REG_L2PY, 0); | ||
358 | c_set_disp_reg(par, CARMINE_DISP_REG_L3PY, 0); | ||
359 | c_set_disp_reg(par, CARMINE_DISP_REG_L4PY, 0); | ||
360 | c_set_disp_reg(par, CARMINE_DISP_REG_L5PY, 0); | ||
361 | c_set_disp_reg(par, CARMINE_DISP_REG_L6PY, 0); | ||
362 | c_set_disp_reg(par, CARMINE_DISP_REG_L7PY, 0); | ||
363 | } | ||
364 | |||
365 | static void set_display_parameters(struct carmine_fb *par) | ||
366 | { | ||
367 | u32 mode; | ||
368 | u32 hdp, vdp, htp, hsp, hsw, vtr, vsp, vsw; | ||
369 | |||
370 | /* | ||
371 | * display timing. Parameters are decreased by one because hardware | ||
372 | * spec is 0 to (n - 1) | ||
373 | * */ | ||
374 | hdp = par->res->hdp - 1; | ||
375 | vdp = par->res->vdp - 1; | ||
376 | htp = par->res->htp - 1; | ||
377 | hsp = par->res->hsp - 1; | ||
378 | hsw = par->res->hsw - 1; | ||
379 | vtr = par->res->vtr - 1; | ||
380 | vsp = par->res->vsp - 1; | ||
381 | vsw = par->res->vsw - 1; | ||
382 | |||
383 | c_set_disp_reg(par, CARMINE_DISP_REG_H_TOTAL, | ||
384 | htp << CARMINE_DISP_HTP_SHIFT); | ||
385 | c_set_disp_reg(par, CARMINE_DISP_REG_H_PERIOD, | ||
386 | (hdp << CARMINE_DISP_HDB_SHIFT) | hdp); | ||
387 | c_set_disp_reg(par, CARMINE_DISP_REG_V_H_W_H_POS, | ||
388 | (vsw << CARMINE_DISP_VSW_SHIFT) | | ||
389 | (hsw << CARMINE_DISP_HSW_SHIFT) | | ||
390 | (hsp)); | ||
391 | c_set_disp_reg(par, CARMINE_DISP_REG_V_TOTAL, | ||
392 | vtr << CARMINE_DISP_VTR_SHIFT); | ||
393 | c_set_disp_reg(par, CARMINE_DISP_REG_V_PERIOD_POS, | ||
394 | (vdp << CARMINE_DISP_VDP_SHIFT) | vsp); | ||
395 | |||
396 | /* clock */ | ||
397 | mode = c_get_disp_reg(par, CARMINE_DISP_REG_DCM1); | ||
398 | mode = (mode & ~CARMINE_DISP_DCM_MASK) | | ||
399 | (par->res->disp_mode & CARMINE_DISP_DCM_MASK); | ||
400 | /* enable video output and layer 0 */ | ||
401 | mode |= CARMINE_DEN | CARMINE_L0E; | ||
402 | c_set_disp_reg(par, CARMINE_DISP_REG_DCM1, mode); | ||
403 | } | ||
404 | |||
405 | static int carmine_set_par(struct fb_info *info) | ||
406 | { | ||
407 | struct carmine_fb *par = info->par; | ||
408 | int ret; | ||
409 | |||
410 | ret = carmine_find_mode(&info->var); | ||
411 | if (ret < 0) | ||
412 | return ret; | ||
413 | |||
414 | par->new_mode = ret; | ||
415 | if (par->cur_mode != par->new_mode) { | ||
416 | |||
417 | par->cur_mode = par->new_mode; | ||
418 | par->res = &car_modes[par->new_mode]; | ||
419 | |||
420 | carmine_init_display_param(par); | ||
421 | set_display_parameters(par); | ||
422 | } | ||
423 | |||
424 | info->fix.line_length = info->var.xres * info->var.bits_per_pixel / 8; | ||
425 | return 0; | ||
426 | } | ||
427 | |||
428 | static int init_hardware(struct carmine_hw *hw) | ||
429 | { | ||
430 | u32 flags; | ||
431 | u32 loops; | ||
432 | u32 ret; | ||
433 | |||
434 | /* Initalize Carmine */ | ||
435 | /* Sets internal clock */ | ||
436 | c_set_hw_reg(hw, CARMINE_CTL_REG + CARMINE_CTL_REG_CLOCK_ENABLE, | ||
437 | CARMINE_DFLT_IP_CLOCK_ENABLE); | ||
438 | |||
439 | /* Video signal output is turned off */ | ||
440 | c_set_hw_reg(hw, CARMINE_DISP0_REG + CARMINE_DISP_REG_DCM1, 0); | ||
441 | c_set_hw_reg(hw, CARMINE_DISP1_REG + CARMINE_DISP_REG_DCM1, 0); | ||
442 | |||
443 | /* Software reset */ | ||
444 | c_set_hw_reg(hw, CARMINE_CTL_REG + CARMINE_CTL_REG_SOFTWARE_RESET, 1); | ||
445 | c_set_hw_reg(hw, CARMINE_CTL_REG + CARMINE_CTL_REG_SOFTWARE_RESET, 0); | ||
446 | |||
447 | /* I/O mode settings */ | ||
448 | flags = CARMINE_DFLT_IP_DCTL_IO_CONT1 << 16 | | ||
449 | CARMINE_DFLT_IP_DCTL_IO_CONT0; | ||
450 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_IOCONT1_IOCONT0, | ||
451 | flags); | ||
452 | |||
453 | /* DRAM initial sequence */ | ||
454 | flags = CARMINE_DFLT_IP_DCTL_MODE << 16 | CARMINE_DFLT_IP_DCTL_ADD; | ||
455 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_MODE_ADD, | ||
456 | flags); | ||
457 | |||
458 | flags = CARMINE_DFLT_IP_DCTL_SET_TIME1 << 16 | | ||
459 | CARMINE_DFLT_IP_DCTL_EMODE; | ||
460 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_SETTIME1_EMODE, | ||
461 | flags); | ||
462 | |||
463 | flags = CARMINE_DFLT_IP_DCTL_REFRESH << 16 | | ||
464 | CARMINE_DFLT_IP_DCTL_SET_TIME2; | ||
465 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_REFRESH_SETTIME2, | ||
466 | flags); | ||
467 | |||
468 | flags = CARMINE_DFLT_IP_DCTL_RESERVE2 << 16 | | ||
469 | CARMINE_DFLT_IP_DCTL_FIFO_DEPTH; | ||
470 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_RSV2_RSV1, flags); | ||
471 | |||
472 | flags = CARMINE_DFLT_IP_DCTL_DDRIF2 << 16 | CARMINE_DFLT_IP_DCTL_DDRIF1; | ||
473 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_DDRIF2_DDRIF1, | ||
474 | flags); | ||
475 | |||
476 | flags = CARMINE_DFLT_IP_DCTL_RESERVE0 << 16 | | ||
477 | CARMINE_DFLT_IP_DCTL_STATES; | ||
478 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_RSV0_STATES, | ||
479 | flags); | ||
480 | |||
481 | /* Executes DLL reset */ | ||
482 | if (CARMINE_DCTL_DLL_RESET) { | ||
483 | for (loops = 0; loops < CARMINE_DCTL_INIT_WAIT_LIMIT; loops++) { | ||
484 | |||
485 | ret = c_get_hw_reg(hw, CARMINE_DCTL_REG + | ||
486 | CARMINE_DCTL_REG_RSV0_STATES); | ||
487 | ret &= CARMINE_DCTL_REG_STATES_MASK; | ||
488 | if (!ret) | ||
489 | break; | ||
490 | |||
491 | mdelay(CARMINE_DCTL_INIT_WAIT_INTERVAL); | ||
492 | } | ||
493 | |||
494 | if (loops >= CARMINE_DCTL_INIT_WAIT_LIMIT) { | ||
495 | printk(KERN_ERR "DRAM init failed\n"); | ||
496 | return -EIO; | ||
497 | } | ||
498 | } | ||
499 | |||
500 | flags = CARMINE_DFLT_IP_DCTL_MODE_AFT_RST << 16 | | ||
501 | CARMINE_DFLT_IP_DCTL_ADD; | ||
502 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_MODE_ADD, flags); | ||
503 | |||
504 | flags = CARMINE_DFLT_IP_DCTL_RESERVE0 << 16 | | ||
505 | CARMINE_DFLT_IP_DCTL_STATES_AFT_RST; | ||
506 | c_set_hw_reg(hw, CARMINE_DCTL_REG + CARMINE_DCTL_REG_RSV0_STATES, | ||
507 | flags); | ||
508 | |||
509 | /* Initialize the write back register */ | ||
510 | c_set_hw_reg(hw, CARMINE_WB_REG + CARMINE_WB_REG_WBM, | ||
511 | CARMINE_WB_REG_WBM_DEFAULT); | ||
512 | |||
513 | /* Initialize the Kottos registers */ | ||
514 | c_set_hw_reg(hw, CARMINE_GRAPH_REG + CARMINE_GRAPH_REG_VRINTM, 0); | ||
515 | c_set_hw_reg(hw, CARMINE_GRAPH_REG + CARMINE_GRAPH_REG_VRERRM, 0); | ||
516 | |||
517 | /* Set DC offsets */ | ||
518 | c_set_hw_reg(hw, CARMINE_GRAPH_REG + CARMINE_GRAPH_REG_DC_OFFSET_PX, 0); | ||
519 | c_set_hw_reg(hw, CARMINE_GRAPH_REG + CARMINE_GRAPH_REG_DC_OFFSET_PY, 0); | ||
520 | c_set_hw_reg(hw, CARMINE_GRAPH_REG + CARMINE_GRAPH_REG_DC_OFFSET_LX, 0); | ||
521 | c_set_hw_reg(hw, CARMINE_GRAPH_REG + CARMINE_GRAPH_REG_DC_OFFSET_LY, 0); | ||
522 | c_set_hw_reg(hw, CARMINE_GRAPH_REG + CARMINE_GRAPH_REG_DC_OFFSET_TX, 0); | ||
523 | c_set_hw_reg(hw, CARMINE_GRAPH_REG + CARMINE_GRAPH_REG_DC_OFFSET_TY, 0); | ||
524 | return 0; | ||
525 | } | ||
526 | |||
527 | static struct fb_ops carminefb_ops = { | ||
528 | .owner = THIS_MODULE, | ||
529 | .fb_fillrect = cfb_fillrect, | ||
530 | .fb_copyarea = cfb_copyarea, | ||
531 | .fb_imageblit = cfb_imageblit, | ||
532 | |||
533 | .fb_check_var = carmine_check_var, | ||
534 | .fb_set_par = carmine_set_par, | ||
535 | .fb_setcolreg = carmine_setcolreg, | ||
536 | }; | ||
537 | |||
538 | static int alloc_carmine_fb(void __iomem *regs, void __iomem *smem_base, | ||
539 | int smem_offset, struct device *device, struct fb_info **rinfo) | ||
540 | { | ||
541 | int ret; | ||
542 | struct fb_info *info; | ||
543 | struct carmine_fb *par; | ||
544 | |||
545 | info = framebuffer_alloc(sizeof *par, device); | ||
546 | if (!info) | ||
547 | return -ENOMEM; | ||
548 | |||
549 | par = info->par; | ||
550 | par->display_reg = regs; | ||
551 | par->smem_offset = smem_offset; | ||
552 | |||
553 | info->screen_base = smem_base + smem_offset; | ||
554 | info->screen_size = CARMINE_DISPLAY_MEM; | ||
555 | info->fbops = &carminefb_ops; | ||
556 | |||
557 | info->fix = carminefb_fix; | ||
558 | info->pseudo_palette = par->pseudo_palette; | ||
559 | info->flags = FBINFO_DEFAULT; | ||
560 | |||
561 | ret = fb_alloc_cmap(&info->cmap, 256, 1); | ||
562 | if (ret < 0) | ||
563 | goto err_free_fb; | ||
564 | |||
565 | if (fb_mode > ARRAY_SIZE(carmine_modedb)) | ||
566 | fb_mode = CARMINEFB_DEFAULT_VIDEO_MODE; | ||
567 | |||
568 | par->cur_mode = par->new_mode = ~0; | ||
569 | |||
570 | ret = fb_find_mode(&info->var, info, fb_mode_str, carmine_modedb, | ||
571 | ARRAY_SIZE(carmine_modedb), | ||
572 | &carmine_modedb[fb_mode], 32); | ||
573 | if (!ret || ret == 4) { | ||
574 | ret = -EINVAL; | ||
575 | goto err_dealloc_cmap; | ||
576 | } | ||
577 | |||
578 | fb_videomode_to_modelist(carmine_modedb, ARRAY_SIZE(carmine_modedb), | ||
579 | &info->modelist); | ||
580 | |||
581 | ret = register_framebuffer(info); | ||
582 | if (ret < 0) | ||
583 | goto err_dealloc_cmap; | ||
584 | |||
585 | printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, | ||
586 | info->fix.id); | ||
587 | |||
588 | *rinfo = info; | ||
589 | return 0; | ||
590 | |||
591 | err_dealloc_cmap: | ||
592 | fb_dealloc_cmap(&info->cmap); | ||
593 | err_free_fb: | ||
594 | framebuffer_release(info); | ||
595 | return ret; | ||
596 | } | ||
597 | |||
598 | static void cleanup_fb_device(struct fb_info *info) | ||
599 | { | ||
600 | if (info) { | ||
601 | unregister_framebuffer(info); | ||
602 | fb_dealloc_cmap(&info->cmap); | ||
603 | framebuffer_release(info); | ||
604 | } | ||
605 | } | ||
606 | |||
607 | static int __devinit carminefb_probe(struct pci_dev *dev, | ||
608 | const struct pci_device_id *ent) | ||
609 | { | ||
610 | struct carmine_hw *hw; | ||
611 | struct device *device = &dev->dev; | ||
612 | struct fb_info *info; | ||
613 | int ret; | ||
614 | |||
615 | ret = pci_enable_device(dev); | ||
616 | if (ret) | ||
617 | return ret; | ||
618 | |||
619 | ret = -ENOMEM; | ||
620 | hw = kzalloc(sizeof *hw, GFP_KERNEL); | ||
621 | if (!hw) | ||
622 | goto err_enable_pci; | ||
623 | |||
624 | carminefb_fix.mmio_start = pci_resource_start(dev, CARMINE_CONFIG_BAR); | ||
625 | carminefb_fix.mmio_len = pci_resource_len(dev, CARMINE_CONFIG_BAR); | ||
626 | |||
627 | if (!request_mem_region(carminefb_fix.mmio_start, | ||
628 | carminefb_fix.mmio_len, | ||
629 | "carminefb regbase")) { | ||
630 | printk(KERN_ERR "carminefb: Can't reserve regbase.\n"); | ||
631 | ret = -EBUSY; | ||
632 | goto err_free_hw; | ||
633 | } | ||
634 | hw->v_regs = ioremap_nocache(carminefb_fix.mmio_start, | ||
635 | carminefb_fix.mmio_len); | ||
636 | if (!hw->v_regs) { | ||
637 | printk(KERN_ERR "carminefb: Can't remap %s register.\n", | ||
638 | carminefb_fix.id); | ||
639 | goto err_free_reg_mmio; | ||
640 | } | ||
641 | |||
642 | carminefb_fix.smem_start = pci_resource_start(dev, CARMINE_MEMORY_BAR); | ||
643 | carminefb_fix.smem_len = pci_resource_len(dev, CARMINE_MEMORY_BAR); | ||
644 | |||
645 | /* The memory area tends to be very large (256 MiB). Remap only what | ||
646 | * is required for that largest resolution to avoid remaps at run | ||
647 | * time | ||
648 | */ | ||
649 | if (carminefb_fix.smem_len > CARMINE_TOTAL_DIPLAY_MEM) | ||
650 | carminefb_fix.smem_len = CARMINE_TOTAL_DIPLAY_MEM; | ||
651 | |||
652 | else if (carminefb_fix.smem_len < CARMINE_TOTAL_DIPLAY_MEM) { | ||
653 | printk(KERN_ERR "carminefb: Memory bar is only %d bytes, %d " | ||
654 | "are required.", carminefb_fix.smem_len, | ||
655 | CARMINE_TOTAL_DIPLAY_MEM); | ||
656 | goto err_free_reg_mmio; | ||
657 | } | ||
658 | |||
659 | if (!request_mem_region(carminefb_fix.smem_start, | ||
660 | carminefb_fix.smem_len, "carminefb smem")) { | ||
661 | printk(KERN_ERR "carminefb: Can't reserve smem.\n"); | ||
662 | goto err_unmap_vregs; | ||
663 | } | ||
664 | |||
665 | hw->screen_mem = ioremap_nocache(carminefb_fix.smem_start, | ||
666 | carminefb_fix.smem_len); | ||
667 | if (!hw->screen_mem) { | ||
668 | printk(KERN_ERR "carmine: Can't ioremap smem area.\n"); | ||
669 | release_mem_region(carminefb_fix.smem_start, | ||
670 | carminefb_fix.smem_len); | ||
671 | goto err_reg_smem; | ||
672 | } | ||
673 | |||
674 | ret = init_hardware(hw); | ||
675 | if (ret) | ||
676 | goto err_unmap_screen; | ||
677 | |||
678 | info = NULL; | ||
679 | if (fb_displays & CARMINE_USE_DISPLAY0) { | ||
680 | ret = alloc_carmine_fb(hw->v_regs + CARMINE_DISP0_REG, | ||
681 | hw->screen_mem, CARMINE_DISPLAY_MEM * 0, | ||
682 | device, &info); | ||
683 | if (ret) | ||
684 | goto err_deinit_hw; | ||
685 | } | ||
686 | |||
687 | hw->fb[0] = info; | ||
688 | |||
689 | info = NULL; | ||
690 | if (fb_displays & CARMINE_USE_DISPLAY1) { | ||
691 | ret = alloc_carmine_fb(hw->v_regs + CARMINE_DISP1_REG, | ||
692 | hw->screen_mem, CARMINE_DISPLAY_MEM * 1, | ||
693 | device, &info); | ||
694 | if (ret) | ||
695 | goto err_cleanup_fb0; | ||
696 | } | ||
697 | |||
698 | hw->fb[1] = info; | ||
699 | info = NULL; | ||
700 | |||
701 | pci_set_drvdata(dev, hw); | ||
702 | return 0; | ||
703 | |||
704 | err_cleanup_fb0: | ||
705 | cleanup_fb_device(hw->fb[0]); | ||
706 | err_deinit_hw: | ||
707 | /* disable clock, etc */ | ||
708 | c_set_hw_reg(hw, CARMINE_CTL_REG + CARMINE_CTL_REG_CLOCK_ENABLE, 0); | ||
709 | err_unmap_screen: | ||
710 | iounmap(hw->screen_mem); | ||
711 | err_reg_smem: | ||
712 | release_mem_region(carminefb_fix.mmio_start, carminefb_fix.mmio_len); | ||
713 | err_unmap_vregs: | ||
714 | iounmap(hw->v_regs); | ||
715 | err_free_reg_mmio: | ||
716 | release_mem_region(carminefb_fix.mmio_start, carminefb_fix.mmio_len); | ||
717 | err_free_hw: | ||
718 | kfree(hw); | ||
719 | err_enable_pci: | ||
720 | pci_disable_device(dev); | ||
721 | return ret; | ||
722 | } | ||
723 | |||
724 | static void __devexit carminefb_remove(struct pci_dev *dev) | ||
725 | { | ||
726 | struct carmine_hw *hw = pci_get_drvdata(dev); | ||
727 | struct fb_fix_screeninfo fix; | ||
728 | int i; | ||
729 | |||
730 | /* in case we use only fb1 and not fb1 */ | ||
731 | if (hw->fb[0]) | ||
732 | fix = hw->fb[0]->fix; | ||
733 | else | ||
734 | fix = hw->fb[1]->fix; | ||
735 | |||
736 | /* deactivate display(s) and switch clocks */ | ||
737 | c_set_hw_reg(hw, CARMINE_DISP0_REG + CARMINE_DISP_REG_DCM1, 0); | ||
738 | c_set_hw_reg(hw, CARMINE_DISP1_REG + CARMINE_DISP_REG_DCM1, 0); | ||
739 | c_set_hw_reg(hw, CARMINE_CTL_REG + CARMINE_CTL_REG_CLOCK_ENABLE, 0); | ||
740 | |||
741 | for (i = 0; i < MAX_DISPLAY; i++) | ||
742 | cleanup_fb_device(hw->fb[i]); | ||
743 | |||
744 | iounmap(hw->screen_mem); | ||
745 | release_mem_region(fix.smem_start, fix.smem_len); | ||
746 | iounmap(hw->v_regs); | ||
747 | release_mem_region(fix.mmio_start, fix.mmio_len); | ||
748 | |||
749 | pci_set_drvdata(dev, NULL); | ||
750 | pci_disable_device(dev); | ||
751 | kfree(hw); | ||
752 | } | ||
753 | |||
754 | #define PCI_VENDOR_ID_FUJITU_LIMITED 0x10cf | ||
755 | static struct pci_device_id carmine_devices[] __devinitdata = { | ||
756 | { | ||
757 | PCI_DEVICE(PCI_VENDOR_ID_FUJITU_LIMITED, 0x202b)}, | ||
758 | {0, 0, 0, 0, 0, 0, 0} | ||
759 | }; | ||
760 | |||
761 | MODULE_DEVICE_TABLE(pci, carmine_devices); | ||
762 | |||
763 | static struct pci_driver carmine_pci_driver = { | ||
764 | .name = "carminefb", | ||
765 | .id_table = carmine_devices, | ||
766 | .probe = carminefb_probe, | ||
767 | .remove = __devexit_p(carminefb_remove), | ||
768 | }; | ||
769 | |||
770 | static int __init carminefb_init(void) | ||
771 | { | ||
772 | if (!(fb_displays & | ||
773 | (CARMINE_USE_DISPLAY0 | CARMINE_USE_DISPLAY1))) { | ||
774 | printk(KERN_ERR "If you disable both displays than you don't " | ||
775 | "need the driver at all\n"); | ||
776 | return -EINVAL; | ||
777 | } | ||
778 | return pci_register_driver(&carmine_pci_driver); | ||
779 | } | ||
780 | module_init(carminefb_init); | ||
781 | |||
782 | static void __exit carminefb_cleanup(void) | ||
783 | { | ||
784 | pci_unregister_driver(&carmine_pci_driver); | ||
785 | } | ||
786 | module_exit(carminefb_cleanup); | ||
787 | |||
788 | MODULE_AUTHOR("Sebastian Siewior <bigeasy@linutronix.de>"); | ||
789 | MODULE_DESCRIPTION("Framebuffer driver for Fujitsu Carmine based devices"); | ||
790 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/video/carminefb.h b/drivers/video/carminefb.h new file mode 100644 index 000000000000..05306de0c6b6 --- /dev/null +++ b/drivers/video/carminefb.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef CARMINE_CARMINE_H | ||
2 | #define CARMINE_CARMINE_H | ||
3 | |||
4 | #define CARMINE_MEMORY_BAR 2 | ||
5 | #define CARMINE_CONFIG_BAR 3 | ||
6 | |||
7 | #define MAX_DISPLAY 2 | ||
8 | #define CARMINE_DISPLAY_MEM (800 * 600 * 4) | ||
9 | #define CARMINE_TOTAL_DIPLAY_MEM (CARMINE_DISPLAY_MEM * MAX_DISPLAY) | ||
10 | |||
11 | #define CARMINE_USE_DISPLAY0 (1 << 0) | ||
12 | #define CARMINE_USE_DISPLAY1 (1 << 1) | ||
13 | |||
14 | /* | ||
15 | * This values work on the eval card. Custom boards may use different timings, | ||
16 | * here an example :) | ||
17 | */ | ||
18 | |||
19 | /* DRAM initialization values */ | ||
20 | #ifdef CONFIG_FB_CARMINE_DRAM_EVAL | ||
21 | |||
22 | #define CARMINE_DFLT_IP_CLOCK_ENABLE (0x03ff) | ||
23 | #define CARMINE_DFLT_IP_DCTL_ADD (0x05c3) | ||
24 | #define CARMINE_DFLT_IP_DCTL_MODE (0x0121) | ||
25 | #define CARMINE_DFLT_IP_DCTL_EMODE (0x8000) | ||
26 | #define CARMINE_DFLT_IP_DCTL_SET_TIME1 (0x4749) | ||
27 | #define CARMINE_DFLT_IP_DCTL_SET_TIME2 (0x2a22) | ||
28 | #define CARMINE_DFLT_IP_DCTL_REFRESH (0x0042) | ||
29 | #define CARMINE_DFLT_IP_DCTL_STATES (0x0003) | ||
30 | #define CARMINE_DFLT_IP_DCTL_RESERVE0 (0x0020) | ||
31 | #define CARMINE_DFLT_IP_DCTL_FIFO_DEPTH (0x000f) | ||
32 | #define CARMINE_DFLT_IP_DCTL_RESERVE2 (0x0000) | ||
33 | #define CARMINE_DFLT_IP_DCTL_DDRIF1 (0x6646) | ||
34 | #define CARMINE_DFLT_IP_DCTL_DDRIF2 (0x0055) | ||
35 | #define CARMINE_DFLT_IP_DCTL_MODE_AFT_RST (0x0021) | ||
36 | #define CARMINE_DFLT_IP_DCTL_STATES_AFT_RST (0x0002) | ||
37 | #define CARMINE_DFLT_IP_DCTL_IO_CONT0 (0x0555) | ||
38 | #define CARMINE_DFLT_IP_DCTL_IO_CONT1 (0x0555) | ||
39 | #define CARMINE_DCTL_DLL_RESET (1) | ||
40 | #endif | ||
41 | |||
42 | #ifdef CONFIG_CARMINE_DRAM_CUSTOM | ||
43 | |||
44 | #define CARMINE_DFLT_IP_CLOCK_ENABLE (0x03ff) | ||
45 | #define CARMINE_DFLT_IP_DCTL_ADD (0x03b2) | ||
46 | #define CARMINE_DFLT_IP_DCTL_MODE (0x0161) | ||
47 | #define CARMINE_DFLT_IP_DCTL_EMODE (0x8000) | ||
48 | #define CARMINE_DFLT_IP_DCTL_SET_TIME1 (0x2628) | ||
49 | #define CARMINE_DFLT_IP_DCTL_SET_TIME2 (0x1a09) | ||
50 | #define CARMINE_DFLT_IP_DCTL_REFRESH (0x00fe) | ||
51 | #define CARMINE_DFLT_IP_DCTL_STATES (0x0003) | ||
52 | #define CARMINE_DFLT_IP_DCTL_RESERVE0 (0x0020) | ||
53 | #define CARMINE_DFLT_IP_DCTL_FIFO_DEPTH (0x000f) | ||
54 | #define CARMINE_DFLT_IP_DCTL_RESERVE2 (0x0000) | ||
55 | #define CARMINE_DFLT_IP_DCTL_DDRIF1 (0x0646) | ||
56 | #define CARMINE_DFLT_IP_DCTL_DDRIF2 (0x55aa) | ||
57 | #define CARMINE_DFLT_IP_DCTL_MODE_AFT_RST (0x0061) | ||
58 | #define CARMINE_DFLT_IP_DCTL_STATES_AFT_RST (0x0002) | ||
59 | #define CARMINE_DFLT_IP_DCTL_IO_CONT0 (0x0555) | ||
60 | #define CARMINE_DFLT_IP_DCTL_IO_CONT1 (0x0555) | ||
61 | #define CARMINE_DCTL_DLL_RESET (1) | ||
62 | #endif | ||
63 | |||
64 | #endif | ||
diff --git a/drivers/video/carminefb_regs.h b/drivers/video/carminefb_regs.h new file mode 100644 index 000000000000..045215600b73 --- /dev/null +++ b/drivers/video/carminefb_regs.h | |||
@@ -0,0 +1,159 @@ | |||
1 | #ifndef _CARMINEFB_REGS_H | ||
2 | #define _CARMINEFB_REGS_H | ||
3 | |||
4 | #define CARMINE_OVERLAY_EXT_MODE (0x00000002) | ||
5 | #define CARMINE_GRAPH_REG (0x00000000) | ||
6 | #define CARMINE_DISP0_REG (0x00100000) | ||
7 | #define CARMINE_DISP1_REG (0x00140000) | ||
8 | #define CARMINE_WB_REG (0x00180000) | ||
9 | #define CARMINE_DCTL_REG (0x00300000) | ||
10 | #define CARMINE_CTL_REG (0x00400000) | ||
11 | #define CARMINE_WINDOW_MODE (0x00000001) | ||
12 | #define CARMINE_EXTEND_MODE (CARMINE_WINDOW_MODE | \ | ||
13 | CARMINE_OVERLAY_EXT_MODE) | ||
14 | #define CARMINE_L0E (1 << 16) | ||
15 | #define CARMINE_L2E (1 << 18) | ||
16 | #define CARMINE_DEN (1 << 31) | ||
17 | |||
18 | #define CARMINE_EXT_CMODE_DIRECT24_RGBA (0xC0000000) | ||
19 | #define CARMINE_DCTL_REG_MODE_ADD (0x00) | ||
20 | #define CARMINE_DCTL_REG_SETTIME1_EMODE (0x04) | ||
21 | #define CARMINE_DCTL_REG_REFRESH_SETTIME2 (0x08) | ||
22 | #define CARMINE_DCTL_REG_RSV0_STATES (0x0C) | ||
23 | #define CARMINE_DCTL_REG_RSV2_RSV1 (0x10) | ||
24 | #define CARMINE_DCTL_REG_DDRIF2_DDRIF1 (0x14) | ||
25 | #define CARMINE_DCTL_REG_IOCONT1_IOCONT0 (0x24) | ||
26 | #define CARMINE_DCTL_REG_STATES_MASK (0x000F) | ||
27 | #define CARMINE_DCTL_INIT_WAIT_INTERVAL (1) | ||
28 | #define CARMINE_DCTL_INIT_WAIT_LIMIT (5000) | ||
29 | #define CARMINE_WB_REG_WBM_DEFAULT (0x0001c020) | ||
30 | #define CARMINE_DISP_REG_L0RM (0x1880) | ||
31 | #define CARMINE_DISP_REG_L0PX (0x1884) | ||
32 | #define CARMINE_DISP_REG_L0PY (0x1888) | ||
33 | #define CARMINE_DISP_REG_L2RM (0x18A0) | ||
34 | #define CARMINE_DISP_REG_L2PX (0x18A4) | ||
35 | #define CARMINE_DISP_REG_L2PY (0x18A8) | ||
36 | #define CARMINE_DISP_REG_L3RM (0x18B0) | ||
37 | #define CARMINE_DISP_REG_L3PX (0x18B4) | ||
38 | #define CARMINE_DISP_REG_L3PY (0x18B8) | ||
39 | #define CARMINE_DISP_REG_L4RM (0x18C0) | ||
40 | #define CARMINE_DISP_REG_L4PX (0x18C4) | ||
41 | #define CARMINE_DISP_REG_L4PY (0x18C8) | ||
42 | #define CARMINE_DISP_REG_L5RM (0x18D0) | ||
43 | #define CARMINE_DISP_REG_L5PX (0x18D4) | ||
44 | #define CARMINE_DISP_REG_L5PY (0x18D8) | ||
45 | #define CARMINE_DISP_REG_L6RM (0x1924) | ||
46 | #define CARMINE_DISP_REG_L6PX (0x1928) | ||
47 | #define CARMINE_DISP_REG_L6PY (0x192C) | ||
48 | #define CARMINE_DISP_REG_L7RM (0x1964) | ||
49 | #define CARMINE_DISP_REG_L7PX (0x1968) | ||
50 | #define CARMINE_DISP_REG_L7PY (0x196C) | ||
51 | #define CARMINE_WB_REG_WBM (0x0004) | ||
52 | #define CARMINE_DISP_HTP_SHIFT (16) | ||
53 | #define CARMINE_DISP_HDB_SHIFT (16) | ||
54 | #define CARMINE_DISP_HSW_SHIFT (16) | ||
55 | #define CARMINE_DISP_VSW_SHIFT (24) | ||
56 | #define CARMINE_DISP_VTR_SHIFT (16) | ||
57 | #define CARMINE_DISP_VDP_SHIFT (16) | ||
58 | #define CARMINE_CURSOR_CUTZ_MASK (0x00000100) | ||
59 | #define CARMINE_CURSOR0_PRIORITY_MASK (0x00010000) | ||
60 | #define CARMINE_CURSOR1_PRIORITY_MASK (0x00020000) | ||
61 | #define CARMINE_DISP_WIDTH_SHIFT (16) | ||
62 | #define CARMINE_DISP_WIN_H_SHIFT (16) | ||
63 | #define CARMINE_DISP_REG_H_TOTAL (0x0004) | ||
64 | #define CARMINE_DISP_REG_H_PERIOD (0x0008) | ||
65 | #define CARMINE_DISP_REG_V_H_W_H_POS (0x000C) | ||
66 | #define CARMINE_DISP_REG_V_TOTAL (0x0010) | ||
67 | #define CARMINE_DISP_REG_V_PERIOD_POS (0x0014) | ||
68 | #define CARMINE_DISP_REG_L0_MODE_W_H (0x0020) | ||
69 | #define CARMINE_DISP_REG_L0_ORG_ADR (0x0024) | ||
70 | #define CARMINE_DISP_REG_L0_DISP_ADR (0x0028) | ||
71 | #define CARMINE_DISP_REG_L0_DISP_POS (0x002C) | ||
72 | #define CARMINE_DISP_REG_L1_WIDTH (0x0030) | ||
73 | #define CARMINE_DISP_REG_L1_ORG_ADR (0x0034) | ||
74 | #define CARMINE_DISP_REG_L2_MODE_W_H (0x0040) | ||
75 | #define CARMINE_DISP_REG_L2_ORG_ADR1 (0x0044) | ||
76 | #define CARMINE_DISP_REG_L2_DISP_ADR1 (0x0048) | ||
77 | #define CARMINE_DISP_REG_L2_DISP_POS (0x0054) | ||
78 | #define CARMINE_DISP_REG_L3_MODE_W_H (0x0058) | ||
79 | #define CARMINE_DISP_REG_L3_ORG_ADR1 (0x005C) | ||
80 | #define CARMINE_DISP_REG_L3_DISP_ADR1 (0x0060) | ||
81 | #define CARMINE_DISP_REG_L3_DISP_POS (0x006C) | ||
82 | #define CARMINE_DISP_REG_L4_MODE_W_H (0x0070) | ||
83 | #define CARMINE_DISP_REG_L4_ORG_ADR1 (0x0074) | ||
84 | #define CARMINE_DISP_REG_L4_DISP_ADR1 (0x0078) | ||
85 | #define CARMINE_DISP_REG_L4_DISP_POS (0x0084) | ||
86 | #define CARMINE_DISP_REG_L5_MODE_W_H (0x0088) | ||
87 | #define CARMINE_DISP_REG_L5_ORG_ADR1 (0x008C) | ||
88 | #define CARMINE_DISP_REG_L5_DISP_ADR1 (0x0090) | ||
89 | #define CARMINE_DISP_REG_L5_DISP_POS (0x009C) | ||
90 | #define CARMINE_DISP_REG_CURSOR_MODE (0x00A0) | ||
91 | #define CARMINE_DISP_REG_CUR1_POS (0x00A8) | ||
92 | #define CARMINE_DISP_REG_CUR2_POS (0x00B0) | ||
93 | #define CARMINE_DISP_REG_C_TRANS (0x00BC) | ||
94 | #define CARMINE_DISP_REG_MLMR_TRANS (0x00C0) | ||
95 | #define CARMINE_DISP_REG_L0_EXT_MODE (0x0110) | ||
96 | #define CARMINE_DISP_REG_L0_WIN_POS (0x0114) | ||
97 | #define CARMINE_DISP_REG_L0_WIN_SIZE (0x0118) | ||
98 | #define CARMINE_DISP_REG_L1_EXT_MODE (0x0120) | ||
99 | #define CARMINE_DISP_REG_L1_WIN_POS (0x0124) | ||
100 | #define CARMINE_DISP_REG_L1_WIN_SIZE (0x0128) | ||
101 | #define CARMINE_DISP_REG_L2_EXT_MODE (0x0130) | ||
102 | #define CARMINE_DISP_REG_L2_WIN_POS (0x0134) | ||
103 | #define CARMINE_DISP_REG_L2_WIN_SIZE (0x0138) | ||
104 | #define CARMINE_DISP_REG_L3_EXT_MODE (0x0140) | ||
105 | #define CARMINE_DISP_REG_L3_WIN_POS (0x0144) | ||
106 | #define CARMINE_DISP_REG_L3_WIN_SIZE (0x0148) | ||
107 | #define CARMINE_DISP_REG_L4_EXT_MODE (0x0150) | ||
108 | #define CARMINE_DISP_REG_L4_WIN_POS (0x0154) | ||
109 | #define CARMINE_DISP_REG_L4_WIN_SIZE (0x0158) | ||
110 | #define CARMINE_DISP_REG_L5_EXT_MODE (0x0160) | ||
111 | #define CARMINE_DISP_REG_L5_WIN_POS (0x0164) | ||
112 | #define CARMINE_DISP_REG_L5_WIN_SIZE (0x0168) | ||
113 | #define CARMINE_DISP_REG_L6_EXT_MODE (0x1918) | ||
114 | #define CARMINE_DISP_REG_L6_WIN_POS (0x191c) | ||
115 | #define CARMINE_DISP_REG_L6_WIN_SIZE (0x1920) | ||
116 | #define CARMINE_DISP_REG_L7_EXT_MODE (0x1958) | ||
117 | #define CARMINE_DISP_REG_L7_WIN_POS (0x195c) | ||
118 | #define CARMINE_DISP_REG_L7_WIN_SIZE (0x1960) | ||
119 | #define CARMINE_DISP_REG_BLEND_MODE_L0 (0x00B4) | ||
120 | #define CARMINE_DISP_REG_BLEND_MODE_L1 (0x0188) | ||
121 | #define CARMINE_DISP_REG_BLEND_MODE_L2 (0x018C) | ||
122 | #define CARMINE_DISP_REG_BLEND_MODE_L3 (0x0190) | ||
123 | #define CARMINE_DISP_REG_BLEND_MODE_L4 (0x0194) | ||
124 | #define CARMINE_DISP_REG_BLEND_MODE_L5 (0x0198) | ||
125 | #define CARMINE_DISP_REG_BLEND_MODE_L6 (0x1990) | ||
126 | #define CARMINE_DISP_REG_BLEND_MODE_L7 (0x1994) | ||
127 | #define CARMINE_DISP_REG_L0_TRANS (0x01A0) | ||
128 | #define CARMINE_DISP_REG_L1_TRANS (0x01A4) | ||
129 | #define CARMINE_DISP_REG_L2_TRANS (0x01A8) | ||
130 | #define CARMINE_DISP_REG_L3_TRANS (0x01AC) | ||
131 | #define CARMINE_DISP_REG_L4_TRANS (0x01B0) | ||
132 | #define CARMINE_DISP_REG_L5_TRANS (0x01B4) | ||
133 | #define CARMINE_DISP_REG_L6_TRANS (0x1998) | ||
134 | #define CARMINE_DISP_REG_L7_TRANS (0x199c) | ||
135 | #define CARMINE_EXTEND_MODE_MASK (0x00000003) | ||
136 | #define CARMINE_DISP_DCM_MASK (0x0000FFFF) | ||
137 | #define CARMINE_DISP_REG_DCM1 (0x0100) | ||
138 | #define CARMINE_DISP_WIDTH_UNIT (64) | ||
139 | #define CARMINE_DISP_REG_L6_MODE_W_H (0x1900) | ||
140 | #define CARMINE_DISP_REG_L6_ORG_ADR1 (0x1904) | ||
141 | #define CARMINE_DISP_REG_L6_DISP_ADR0 (0x1908) | ||
142 | #define CARMINE_DISP_REG_L6_DISP_POS (0x1914) | ||
143 | #define CARMINE_DISP_REG_L7_MODE_W_H (0x1940) | ||
144 | #define CARMINE_DISP_REG_L7_ORG_ADR1 (0x1944) | ||
145 | #define CARMINE_DISP_REG_L7_DISP_ADR0 (0x1948) | ||
146 | #define CARMINE_DISP_REG_L7_DISP_POS (0x1954) | ||
147 | #define CARMINE_CTL_REG_CLOCK_ENABLE (0x000C) | ||
148 | #define CARMINE_CTL_REG_SOFTWARE_RESET (0x0010) | ||
149 | #define CARMINE_CTL_REG_IST_MASK_ALL (0x07FFFFFF) | ||
150 | #define CARMINE_GRAPH_REG_VRINTM (0x00028064) | ||
151 | #define CARMINE_GRAPH_REG_VRERRM (0x0002806C) | ||
152 | #define CARMINE_GRAPH_REG_DC_OFFSET_PX (0x0004005C) | ||
153 | #define CARMINE_GRAPH_REG_DC_OFFSET_PY (0x00040060) | ||
154 | #define CARMINE_GRAPH_REG_DC_OFFSET_LX (0x00040064) | ||
155 | #define CARMINE_GRAPH_REG_DC_OFFSET_LY (0x00040068) | ||
156 | #define CARMINE_GRAPH_REG_DC_OFFSET_TX (0x0004006C) | ||
157 | #define CARMINE_GRAPH_REG_DC_OFFSET_TY (0x00040070) | ||
158 | |||
159 | #endif | ||
diff --git a/drivers/video/cobalt_lcdfb.c b/drivers/video/cobalt_lcdfb.c new file mode 100644 index 000000000000..7bad24ed04ef --- /dev/null +++ b/drivers/video/cobalt_lcdfb.c | |||
@@ -0,0 +1,371 @@ | |||
1 | /* | ||
2 | * Cobalt server LCD frame buffer driver. | ||
3 | * | ||
4 | * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | ||
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 | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/fb.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/ioport.h> | ||
25 | #include <linux/uaccess.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | |||
28 | /* | ||
29 | * Cursor position address | ||
30 | * \X 0 1 2 ... 14 15 | ||
31 | * Y+----+----+----+---+----+----+ | ||
32 | * 0|0x00|0x01|0x02|...|0x0e|0x0f| | ||
33 | * +----+----+----+---+----+----+ | ||
34 | * 1|0x40|0x41|0x42|...|0x4e|0x4f| | ||
35 | * +----+----+----+---+----+----+ | ||
36 | */ | ||
37 | #define LCD_DATA_REG_OFFSET 0x10 | ||
38 | #define LCD_XRES_MAX 16 | ||
39 | #define LCD_YRES_MAX 2 | ||
40 | #define LCD_CHARS_MAX 32 | ||
41 | |||
42 | #define LCD_CLEAR 0x01 | ||
43 | #define LCD_CURSOR_MOVE_HOME 0x02 | ||
44 | #define LCD_RESET 0x06 | ||
45 | #define LCD_OFF 0x08 | ||
46 | #define LCD_CURSOR_OFF 0x0c | ||
47 | #define LCD_CURSOR_BLINK_OFF 0x0e | ||
48 | #define LCD_CURSOR_ON 0x0f | ||
49 | #define LCD_ON LCD_CURSOR_ON | ||
50 | #define LCD_CURSOR_MOVE_LEFT 0x10 | ||
51 | #define LCD_CURSOR_MOVE_RIGHT 0x14 | ||
52 | #define LCD_DISPLAY_LEFT 0x18 | ||
53 | #define LCD_DISPLAY_RIGHT 0x1c | ||
54 | #define LCD_PRERESET 0x3f /* execute 4 times continuously */ | ||
55 | #define LCD_BUSY 0x80 | ||
56 | |||
57 | #define LCD_GRAPHIC_MODE 0x40 | ||
58 | #define LCD_TEXT_MODE 0x80 | ||
59 | #define LCD_CUR_POS_MASK 0x7f | ||
60 | |||
61 | #define LCD_CUR_POS(x) ((x) & LCD_CUR_POS_MASK) | ||
62 | #define LCD_TEXT_POS(x) ((x) | LCD_TEXT_MODE) | ||
63 | |||
64 | static inline void lcd_write_control(struct fb_info *info, u8 control) | ||
65 | { | ||
66 | writel((u32)control << 24, info->screen_base); | ||
67 | } | ||
68 | |||
69 | static inline u8 lcd_read_control(struct fb_info *info) | ||
70 | { | ||
71 | return readl(info->screen_base) >> 24; | ||
72 | } | ||
73 | |||
74 | static inline void lcd_write_data(struct fb_info *info, u8 data) | ||
75 | { | ||
76 | writel((u32)data << 24, info->screen_base + LCD_DATA_REG_OFFSET); | ||
77 | } | ||
78 | |||
79 | static inline u8 lcd_read_data(struct fb_info *info) | ||
80 | { | ||
81 | return readl(info->screen_base + LCD_DATA_REG_OFFSET) >> 24; | ||
82 | } | ||
83 | |||
84 | static int lcd_busy_wait(struct fb_info *info) | ||
85 | { | ||
86 | u8 val = 0; | ||
87 | int timeout = 10, retval = 0; | ||
88 | |||
89 | do { | ||
90 | val = lcd_read_control(info); | ||
91 | val &= LCD_BUSY; | ||
92 | if (val != LCD_BUSY) | ||
93 | break; | ||
94 | |||
95 | if (msleep_interruptible(1)) | ||
96 | return -EINTR; | ||
97 | |||
98 | timeout--; | ||
99 | } while (timeout); | ||
100 | |||
101 | if (val == LCD_BUSY) | ||
102 | retval = -EBUSY; | ||
103 | |||
104 | return retval; | ||
105 | } | ||
106 | |||
107 | static void lcd_clear(struct fb_info *info) | ||
108 | { | ||
109 | int i; | ||
110 | |||
111 | for (i = 0; i < 4; i++) { | ||
112 | udelay(150); | ||
113 | |||
114 | lcd_write_control(info, LCD_PRERESET); | ||
115 | } | ||
116 | |||
117 | udelay(150); | ||
118 | |||
119 | lcd_write_control(info, LCD_CLEAR); | ||
120 | |||
121 | udelay(150); | ||
122 | |||
123 | lcd_write_control(info, LCD_RESET); | ||
124 | } | ||
125 | |||
126 | static struct fb_fix_screeninfo cobalt_lcdfb_fix __initdata = { | ||
127 | .id = "cobalt-lcd", | ||
128 | .type = FB_TYPE_TEXT, | ||
129 | .type_aux = FB_AUX_TEXT_MDA, | ||
130 | .visual = FB_VISUAL_MONO01, | ||
131 | .line_length = LCD_XRES_MAX, | ||
132 | .accel = FB_ACCEL_NONE, | ||
133 | }; | ||
134 | |||
135 | static ssize_t cobalt_lcdfb_read(struct fb_info *info, char __user *buf, | ||
136 | size_t count, loff_t *ppos) | ||
137 | { | ||
138 | char src[LCD_CHARS_MAX]; | ||
139 | unsigned long pos; | ||
140 | int len, retval = 0; | ||
141 | |||
142 | pos = *ppos; | ||
143 | if (pos >= LCD_CHARS_MAX || count == 0) | ||
144 | return 0; | ||
145 | |||
146 | if (count > LCD_CHARS_MAX) | ||
147 | count = LCD_CHARS_MAX; | ||
148 | |||
149 | if (pos + count > LCD_CHARS_MAX) | ||
150 | count = LCD_CHARS_MAX - pos; | ||
151 | |||
152 | for (len = 0; len < count; len++) { | ||
153 | retval = lcd_busy_wait(info); | ||
154 | if (retval < 0) | ||
155 | break; | ||
156 | |||
157 | lcd_write_control(info, LCD_TEXT_POS(pos)); | ||
158 | |||
159 | retval = lcd_busy_wait(info); | ||
160 | if (retval < 0) | ||
161 | break; | ||
162 | |||
163 | src[len] = lcd_read_data(info); | ||
164 | if (pos == 0x0f) | ||
165 | pos = 0x40; | ||
166 | else | ||
167 | pos++; | ||
168 | } | ||
169 | |||
170 | if (retval < 0 && signal_pending(current)) | ||
171 | return -ERESTARTSYS; | ||
172 | |||
173 | if (copy_to_user(buf, src, len)) | ||
174 | return -EFAULT; | ||
175 | |||
176 | *ppos += len; | ||
177 | |||
178 | return len; | ||
179 | } | ||
180 | |||
181 | static ssize_t cobalt_lcdfb_write(struct fb_info *info, const char __user *buf, | ||
182 | size_t count, loff_t *ppos) | ||
183 | { | ||
184 | char dst[LCD_CHARS_MAX]; | ||
185 | unsigned long pos; | ||
186 | int len, retval = 0; | ||
187 | |||
188 | pos = *ppos; | ||
189 | if (pos >= LCD_CHARS_MAX || count == 0) | ||
190 | return 0; | ||
191 | |||
192 | if (count > LCD_CHARS_MAX) | ||
193 | count = LCD_CHARS_MAX; | ||
194 | |||
195 | if (pos + count > LCD_CHARS_MAX) | ||
196 | count = LCD_CHARS_MAX - pos; | ||
197 | |||
198 | if (copy_from_user(dst, buf, count)) | ||
199 | return -EFAULT; | ||
200 | |||
201 | for (len = 0; len < count; len++) { | ||
202 | retval = lcd_busy_wait(info); | ||
203 | if (retval < 0) | ||
204 | break; | ||
205 | |||
206 | lcd_write_control(info, LCD_TEXT_POS(pos)); | ||
207 | |||
208 | retval = lcd_busy_wait(info); | ||
209 | if (retval < 0) | ||
210 | break; | ||
211 | |||
212 | lcd_write_data(info, dst[len]); | ||
213 | if (pos == 0x0f) | ||
214 | pos = 0x40; | ||
215 | else | ||
216 | pos++; | ||
217 | } | ||
218 | |||
219 | if (retval < 0 && signal_pending(current)) | ||
220 | return -ERESTARTSYS; | ||
221 | |||
222 | *ppos += len; | ||
223 | |||
224 | return len; | ||
225 | } | ||
226 | |||
227 | static int cobalt_lcdfb_blank(int blank_mode, struct fb_info *info) | ||
228 | { | ||
229 | int retval; | ||
230 | |||
231 | retval = lcd_busy_wait(info); | ||
232 | if (retval < 0) | ||
233 | return retval; | ||
234 | |||
235 | switch (blank_mode) { | ||
236 | case FB_BLANK_UNBLANK: | ||
237 | lcd_write_control(info, LCD_ON); | ||
238 | break; | ||
239 | default: | ||
240 | lcd_write_control(info, LCD_OFF); | ||
241 | break; | ||
242 | } | ||
243 | |||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static int cobalt_lcdfb_cursor(struct fb_info *info, struct fb_cursor *cursor) | ||
248 | { | ||
249 | u32 x, y; | ||
250 | int retval; | ||
251 | |||
252 | switch (cursor->set) { | ||
253 | case FB_CUR_SETPOS: | ||
254 | x = cursor->image.dx; | ||
255 | y = cursor->image.dy; | ||
256 | if (x >= LCD_XRES_MAX || y >= LCD_YRES_MAX) | ||
257 | return -EINVAL; | ||
258 | |||
259 | retval = lcd_busy_wait(info); | ||
260 | if (retval < 0) | ||
261 | return retval; | ||
262 | |||
263 | lcd_write_control(info, | ||
264 | LCD_TEXT_POS(info->fix.line_length * y + x)); | ||
265 | break; | ||
266 | default: | ||
267 | return -EINVAL; | ||
268 | } | ||
269 | |||
270 | retval = lcd_busy_wait(info); | ||
271 | if (retval < 0) | ||
272 | return retval; | ||
273 | |||
274 | if (cursor->enable) | ||
275 | lcd_write_control(info, LCD_CURSOR_ON); | ||
276 | else | ||
277 | lcd_write_control(info, LCD_CURSOR_OFF); | ||
278 | |||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | static struct fb_ops cobalt_lcd_fbops = { | ||
283 | .owner = THIS_MODULE, | ||
284 | .fb_read = cobalt_lcdfb_read, | ||
285 | .fb_write = cobalt_lcdfb_write, | ||
286 | .fb_blank = cobalt_lcdfb_blank, | ||
287 | .fb_cursor = cobalt_lcdfb_cursor, | ||
288 | }; | ||
289 | |||
290 | static int __init cobalt_lcdfb_probe(struct platform_device *dev) | ||
291 | { | ||
292 | struct fb_info *info; | ||
293 | struct resource *res; | ||
294 | int retval; | ||
295 | |||
296 | info = framebuffer_alloc(0, &dev->dev); | ||
297 | if (!info) | ||
298 | return -ENOMEM; | ||
299 | |||
300 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
301 | if (!res) { | ||
302 | framebuffer_release(info); | ||
303 | return -EBUSY; | ||
304 | } | ||
305 | |||
306 | info->screen_size = res->end - res->start + 1; | ||
307 | info->screen_base = ioremap(res->start, info->screen_size); | ||
308 | info->fbops = &cobalt_lcd_fbops; | ||
309 | info->fix = cobalt_lcdfb_fix; | ||
310 | info->fix.smem_start = res->start; | ||
311 | info->fix.smem_len = info->screen_size; | ||
312 | info->pseudo_palette = NULL; | ||
313 | info->par = NULL; | ||
314 | info->flags = FBINFO_DEFAULT; | ||
315 | |||
316 | retval = register_framebuffer(info); | ||
317 | if (retval < 0) { | ||
318 | iounmap(info->screen_base); | ||
319 | framebuffer_release(info); | ||
320 | return retval; | ||
321 | } | ||
322 | |||
323 | platform_set_drvdata(dev, info); | ||
324 | |||
325 | lcd_clear(info); | ||
326 | |||
327 | printk(KERN_INFO "fb%d: Cobalt server LCD frame buffer device\n", | ||
328 | info->node); | ||
329 | |||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | static int __devexit cobalt_lcdfb_remove(struct platform_device *dev) | ||
334 | { | ||
335 | struct fb_info *info; | ||
336 | |||
337 | info = platform_get_drvdata(dev); | ||
338 | if (info) { | ||
339 | iounmap(info->screen_base); | ||
340 | unregister_framebuffer(info); | ||
341 | framebuffer_release(info); | ||
342 | } | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static struct platform_driver cobalt_lcdfb_driver = { | ||
348 | .probe = cobalt_lcdfb_probe, | ||
349 | .remove = __devexit_p(cobalt_lcdfb_remove), | ||
350 | .driver = { | ||
351 | .name = "cobalt-lcd", | ||
352 | .owner = THIS_MODULE, | ||
353 | }, | ||
354 | }; | ||
355 | |||
356 | static int __init cobalt_lcdfb_init(void) | ||
357 | { | ||
358 | return platform_driver_register(&cobalt_lcdfb_driver); | ||
359 | } | ||
360 | |||
361 | static void __exit cobalt_lcdfb_exit(void) | ||
362 | { | ||
363 | platform_driver_unregister(&cobalt_lcdfb_driver); | ||
364 | } | ||
365 | |||
366 | module_init(cobalt_lcdfb_init); | ||
367 | module_exit(cobalt_lcdfb_exit); | ||
368 | |||
369 | MODULE_LICENSE("GPL v2"); | ||
370 | MODULE_AUTHOR("Yoichi Yuasa"); | ||
371 | MODULE_DESCRIPTION("Cobalt server LCD frame buffer driver"); | ||
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 4be3b46c069b..3ccfa76d9b2a 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c | |||
@@ -107,9 +107,7 @@ static struct display fb_display[MAX_NR_CONSOLES]; | |||
107 | 107 | ||
108 | static signed char con2fb_map[MAX_NR_CONSOLES]; | 108 | static signed char con2fb_map[MAX_NR_CONSOLES]; |
109 | static signed char con2fb_map_boot[MAX_NR_CONSOLES]; | 109 | static signed char con2fb_map_boot[MAX_NR_CONSOLES]; |
110 | #ifndef MODULE | 110 | |
111 | static int logo_height; | ||
112 | #endif | ||
113 | static int logo_lines; | 111 | static int logo_lines; |
114 | /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO | 112 | /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO |
115 | enums. */ | 113 | enums. */ |
@@ -607,6 +605,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, | |||
607 | struct fbcon_ops *ops = info->fbcon_par; | 605 | struct fbcon_ops *ops = info->fbcon_par; |
608 | int cnt, erase = vc->vc_video_erase_char, step; | 606 | int cnt, erase = vc->vc_video_erase_char, step; |
609 | unsigned short *save = NULL, *r, *q; | 607 | unsigned short *save = NULL, *r, *q; |
608 | int logo_height; | ||
610 | 609 | ||
611 | if (info->flags & FBINFO_MODULE) { | 610 | if (info->flags & FBINFO_MODULE) { |
612 | logo_shown = FBCON_LOGO_DONTSHOW; | 611 | logo_shown = FBCON_LOGO_DONTSHOW; |
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h index 0135e0395456..de1b1365279b 100644 --- a/drivers/video/console/fbcon.h +++ b/drivers/video/console/fbcon.h | |||
@@ -92,7 +92,7 @@ struct fbcon_ops { | |||
92 | #define attr_fgcol(fgshift,s) \ | 92 | #define attr_fgcol(fgshift,s) \ |
93 | (((s) >> (fgshift)) & 0x0f) | 93 | (((s) >> (fgshift)) & 0x0f) |
94 | #define attr_bgcol(bgshift,s) \ | 94 | #define attr_bgcol(bgshift,s) \ |
95 | (((s) >> (bgshift)) & 0x0f) | 95 | (((s) >> (bgshift)) & 0x07) |
96 | 96 | ||
97 | /* Monochrome */ | 97 | /* Monochrome */ |
98 | #define attr_bold(s) \ | 98 | #define attr_bold(s) \ |
@@ -146,10 +146,8 @@ static inline int attr_col_ec(int shift, struct vc_data *vc, | |||
146 | return is_fg ? fg : bg; | 146 | return is_fg ? fg : bg; |
147 | } | 147 | } |
148 | 148 | ||
149 | #define attr_bgcol_ec(bgshift,vc,info) \ | 149 | #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0) |
150 | attr_col_ec(bgshift,vc,info,0); | 150 | #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1) |
151 | #define attr_fgcol_ec(fgshift,vc,info) \ | ||
152 | attr_col_ec(fgshift,vc,info,1); | ||
153 | 151 | ||
154 | /* Font */ | 152 | /* Font */ |
155 | #define REFCOUNT(fd) (((int *)(fd))[-1]) | 153 | #define REFCOUNT(fd) (((int *)(fd))[-1]) |
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index 38a296bbdfc9..9901064199bd 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c | |||
@@ -71,13 +71,15 @@ static char *mda_type_name; | |||
71 | 71 | ||
72 | /* console information */ | 72 | /* console information */ |
73 | 73 | ||
74 | static int mda_first_vc = 1; | 74 | static int mda_first_vc = 13; |
75 | static int mda_last_vc = 16; | 75 | static int mda_last_vc = 16; |
76 | 76 | ||
77 | static struct vc_data *mda_display_fg = NULL; | 77 | static struct vc_data *mda_display_fg = NULL; |
78 | 78 | ||
79 | module_param(mda_first_vc, int, 0); | 79 | module_param(mda_first_vc, int, 0); |
80 | MODULE_PARM_DESC(mda_first_vc, "First virtual console. Default: 13"); | ||
80 | module_param(mda_last_vc, int, 0); | 81 | module_param(mda_last_vc, int, 0); |
82 | MODULE_PARM_DESC(mda_last_vc, "Last virtual console. Default: 16"); | ||
81 | 83 | ||
82 | /* MDA register values | 84 | /* MDA register values |
83 | */ | 85 | */ |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 1cd5071e5362..5d84b3431098 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/device.h> | 35 | #include <linux/device.h> |
36 | #include <linux/efi.h> | 36 | #include <linux/efi.h> |
37 | #include <linux/fb.h> | 37 | #include <linux/fb.h> |
38 | #include <linux/major.h> | ||
38 | 39 | ||
39 | #include <asm/fb.h> | 40 | #include <asm/fb.h> |
40 | 41 | ||
@@ -848,9 +849,8 @@ int | |||
848 | fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var) | 849 | fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var) |
849 | { | 850 | { |
850 | struct fb_fix_screeninfo *fix = &info->fix; | 851 | struct fb_fix_screeninfo *fix = &info->fix; |
851 | int xoffset = var->xoffset; | 852 | unsigned int yres = info->var.yres; |
852 | int yoffset = var->yoffset; | 853 | int err = 0; |
853 | int err = 0, yres = info->var.yres; | ||
854 | 854 | ||
855 | if (var->yoffset > 0) { | 855 | if (var->yoffset > 0) { |
856 | if (var->vmode & FB_VMODE_YWRAP) { | 856 | if (var->vmode & FB_VMODE_YWRAP) { |
@@ -866,8 +866,8 @@ fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var) | |||
866 | (var->xoffset % fix->xpanstep))) | 866 | (var->xoffset % fix->xpanstep))) |
867 | err = -EINVAL; | 867 | err = -EINVAL; |
868 | 868 | ||
869 | if (err || !info->fbops->fb_pan_display || xoffset < 0 || | 869 | if (err || !info->fbops->fb_pan_display || |
870 | yoffset < 0 || var->yoffset + yres > info->var.yres_virtual || | 870 | var->yoffset + yres > info->var.yres_virtual || |
871 | var->xoffset + info->var.xres > info->var.xres_virtual) | 871 | var->xoffset + info->var.xres > info->var.xres_virtual) |
872 | return -EINVAL; | 872 | return -EINVAL; |
873 | 873 | ||
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c index 052e18058498..6a0aa180c266 100644 --- a/drivers/video/fbmon.c +++ b/drivers/video/fbmon.c | |||
@@ -879,7 +879,7 @@ int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var) | |||
879 | if (edid_is_timing_block(block)) { | 879 | if (edid_is_timing_block(block)) { |
880 | var->xres = var->xres_virtual = H_ACTIVE; | 880 | var->xres = var->xres_virtual = H_ACTIVE; |
881 | var->yres = var->yres_virtual = V_ACTIVE; | 881 | var->yres = var->yres_virtual = V_ACTIVE; |
882 | var->height = var->width = -1; | 882 | var->height = var->width = 0; |
883 | var->right_margin = H_SYNC_OFFSET; | 883 | var->right_margin = H_SYNC_OFFSET; |
884 | var->left_margin = (H_ACTIVE + H_BLANKING) - | 884 | var->left_margin = (H_ACTIVE + H_BLANKING) - |
885 | (H_ACTIVE + H_SYNC_OFFSET + H_SYNC_WIDTH); | 885 | (H_ACTIVE + H_SYNC_OFFSET + H_SYNC_WIDTH); |
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c index 09d7e22c6fef..9cd36c223d33 100644 --- a/drivers/video/fsl-diu-fb.c +++ b/drivers/video/fsl-diu-fb.c | |||
@@ -279,58 +279,42 @@ static struct diu_hw dr = { | |||
279 | 279 | ||
280 | static struct diu_pool pool; | 280 | static struct diu_pool pool; |
281 | 281 | ||
282 | /* To allocate memory for framebuffer. First try __get_free_pages(). If it | 282 | /** |
283 | * fails, try rh_alloc. The reason is __get_free_pages() cannot allocate | 283 | * fsl_diu_alloc - allocate memory for the DIU |
284 | * very large memory (more than 4MB). We don't want to allocate all memory | 284 | * @size: number of bytes to allocate |
285 | * in rheap since small memory allocation/deallocation will fragment the | 285 | * @param: returned physical address of memory |
286 | * rheap and make the furture large allocation fail. | 286 | * |
287 | * This function allocates a physically-contiguous block of memory. | ||
287 | */ | 288 | */ |
288 | 289 | static void *fsl_diu_alloc(size_t size, phys_addr_t *phys) | |
289 | static void *fsl_diu_alloc(unsigned long size, phys_addr_t *phys) | ||
290 | { | 290 | { |
291 | void *virt; | 291 | void *virt; |
292 | 292 | ||
293 | pr_debug("size=%lu\n", size); | 293 | pr_debug("size=%zu\n", size); |
294 | 294 | ||
295 | virt = (void *)__get_free_pages(GFP_DMA | __GFP_ZERO, get_order(size)); | 295 | virt = alloc_pages_exact(size, GFP_DMA | __GFP_ZERO); |
296 | if (virt) { | 296 | if (virt) { |
297 | *phys = virt_to_phys(virt); | 297 | *phys = virt_to_phys(virt); |
298 | pr_debug("virt %p, phys=%llx\n", virt, (uint64_t) *phys); | 298 | pr_debug("virt=%p phys=%llx\n", virt, |
299 | return virt; | 299 | (unsigned long long)*phys); |
300 | } | ||
301 | if (!diu_ops.diu_mem) { | ||
302 | printk(KERN_INFO "%s: no diu_mem." | ||
303 | " To reserve more memory, put 'diufb=15M' " | ||
304 | "in the command line\n", __func__); | ||
305 | return NULL; | ||
306 | } | ||
307 | |||
308 | virt = (void *)rh_alloc(&diu_ops.diu_rh_info, size, "DIU"); | ||
309 | if (virt) { | ||
310 | *phys = virt_to_bus(virt); | ||
311 | memset(virt, 0, size); | ||
312 | } | 300 | } |
313 | 301 | ||
314 | pr_debug("rh virt=%p phys=%llx\n", virt, (unsigned long long)*phys); | ||
315 | |||
316 | return virt; | 302 | return virt; |
317 | } | 303 | } |
318 | 304 | ||
319 | static void fsl_diu_free(void *p, unsigned long size) | 305 | /** |
306 | * fsl_diu_free - release DIU memory | ||
307 | * @virt: pointer returned by fsl_diu_alloc() | ||
308 | * @size: number of bytes allocated by fsl_diu_alloc() | ||
309 | * | ||
310 | * This function releases memory allocated by fsl_diu_alloc(). | ||
311 | */ | ||
312 | static void fsl_diu_free(void *virt, size_t size) | ||
320 | { | 313 | { |
321 | pr_debug("p=%p size=%lu\n", p, size); | 314 | pr_debug("virt=%p size=%zu\n", virt, size); |
322 | 315 | ||
323 | if (!p) | 316 | if (virt && size) |
324 | return; | 317 | free_pages_exact(virt, size); |
325 | |||
326 | if ((p >= diu_ops.diu_mem) && | ||
327 | (p < (diu_ops.diu_mem + diu_ops.diu_size))) { | ||
328 | pr_debug("rh\n"); | ||
329 | rh_free(&diu_ops.diu_rh_info, (unsigned long) p); | ||
330 | } else { | ||
331 | pr_debug("dma\n"); | ||
332 | free_pages((unsigned long)p, get_order(size)); | ||
333 | } | ||
334 | } | 318 | } |
335 | 319 | ||
336 | static int fsl_diu_enable_panel(struct fb_info *info) | 320 | static int fsl_diu_enable_panel(struct fb_info *info) |
diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h index 3b9416f4ee20..6a51448fd3f7 100644 --- a/drivers/video/geode/lxfb.h +++ b/drivers/video/geode/lxfb.h | |||
@@ -51,8 +51,6 @@ static inline unsigned int lx_get_pitch(unsigned int xres, int bpp) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | void lx_set_mode(struct fb_info *); | 53 | void lx_set_mode(struct fb_info *); |
54 | void lx_get_gamma(struct fb_info *, unsigned int *, int); | ||
55 | void lx_set_gamma(struct fb_info *, unsigned int *, int); | ||
56 | unsigned int lx_framebuffer_size(void); | 54 | unsigned int lx_framebuffer_size(void); |
57 | int lx_blank_display(struct fb_info *, int); | 55 | int lx_blank_display(struct fb_info *, int); |
58 | void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int, | 56 | void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int, |
diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c index aaef9165ec9b..b1cd49c99356 100644 --- a/drivers/video/geode/lxfb_ops.c +++ b/drivers/video/geode/lxfb_ops.c | |||
@@ -517,25 +517,25 @@ void lx_set_palette_reg(struct fb_info *info, unsigned regno, | |||
517 | int lx_blank_display(struct fb_info *info, int blank_mode) | 517 | int lx_blank_display(struct fb_info *info, int blank_mode) |
518 | { | 518 | { |
519 | struct lxfb_par *par = info->par; | 519 | struct lxfb_par *par = info->par; |
520 | u32 dcfg, fp_pm; | 520 | u32 dcfg, misc, fp_pm; |
521 | int blank, hsync, vsync, crt; | 521 | int blank, hsync, vsync; |
522 | 522 | ||
523 | /* CRT power saving modes. */ | 523 | /* CRT power saving modes. */ |
524 | switch (blank_mode) { | 524 | switch (blank_mode) { |
525 | case FB_BLANK_UNBLANK: | 525 | case FB_BLANK_UNBLANK: |
526 | blank = 0; hsync = 1; vsync = 1; crt = 1; | 526 | blank = 0; hsync = 1; vsync = 1; |
527 | break; | 527 | break; |
528 | case FB_BLANK_NORMAL: | 528 | case FB_BLANK_NORMAL: |
529 | blank = 1; hsync = 1; vsync = 1; crt = 1; | 529 | blank = 1; hsync = 1; vsync = 1; |
530 | break; | 530 | break; |
531 | case FB_BLANK_VSYNC_SUSPEND: | 531 | case FB_BLANK_VSYNC_SUSPEND: |
532 | blank = 1; hsync = 1; vsync = 0; crt = 1; | 532 | blank = 1; hsync = 1; vsync = 0; |
533 | break; | 533 | break; |
534 | case FB_BLANK_HSYNC_SUSPEND: | 534 | case FB_BLANK_HSYNC_SUSPEND: |
535 | blank = 1; hsync = 0; vsync = 1; crt = 1; | 535 | blank = 1; hsync = 0; vsync = 1; |
536 | break; | 536 | break; |
537 | case FB_BLANK_POWERDOWN: | 537 | case FB_BLANK_POWERDOWN: |
538 | blank = 1; hsync = 0; vsync = 0; crt = 0; | 538 | blank = 1; hsync = 0; vsync = 0; |
539 | break; | 539 | break; |
540 | default: | 540 | default: |
541 | return -EINVAL; | 541 | return -EINVAL; |
@@ -545,15 +545,23 @@ int lx_blank_display(struct fb_info *info, int blank_mode) | |||
545 | dcfg &= ~(VP_DCFG_DAC_BL_EN | VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN | | 545 | dcfg &= ~(VP_DCFG_DAC_BL_EN | VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN | |
546 | VP_DCFG_CRT_EN); | 546 | VP_DCFG_CRT_EN); |
547 | if (!blank) | 547 | if (!blank) |
548 | dcfg |= VP_DCFG_DAC_BL_EN; | 548 | dcfg |= VP_DCFG_DAC_BL_EN | VP_DCFG_CRT_EN; |
549 | if (hsync) | 549 | if (hsync) |
550 | dcfg |= VP_DCFG_HSYNC_EN; | 550 | dcfg |= VP_DCFG_HSYNC_EN; |
551 | if (vsync) | 551 | if (vsync) |
552 | dcfg |= VP_DCFG_VSYNC_EN; | 552 | dcfg |= VP_DCFG_VSYNC_EN; |
553 | if (crt) | 553 | |
554 | dcfg |= VP_DCFG_CRT_EN; | ||
555 | write_vp(par, VP_DCFG, dcfg); | 554 | write_vp(par, VP_DCFG, dcfg); |
556 | 555 | ||
556 | misc = read_vp(par, VP_MISC); | ||
557 | |||
558 | if (vsync && hsync) | ||
559 | misc &= ~VP_MISC_DACPWRDN; | ||
560 | else | ||
561 | misc |= VP_MISC_DACPWRDN; | ||
562 | |||
563 | write_vp(par, VP_MISC, misc); | ||
564 | |||
557 | /* Power on/off flat panel */ | 565 | /* Power on/off flat panel */ |
558 | 566 | ||
559 | if (par->output & OUTPUT_PANEL) { | 567 | if (par->output & OUTPUT_PANEL) { |
diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c index c18880d9db1f..0129c044f6d6 100644 --- a/drivers/video/hgafb.c +++ b/drivers/video/hgafb.c | |||
@@ -551,7 +551,7 @@ static struct fb_ops hgafb_ops = { | |||
551 | * Initialization | 551 | * Initialization |
552 | */ | 552 | */ |
553 | 553 | ||
554 | static int __init hgafb_probe(struct device *device) | 554 | static int __init hgafb_probe(struct platform_device *pdev) |
555 | { | 555 | { |
556 | struct fb_info *info; | 556 | struct fb_info *info; |
557 | 557 | ||
@@ -565,7 +565,7 @@ static int __init hgafb_probe(struct device *device) | |||
565 | printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n", | 565 | printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n", |
566 | hga_type_name, hga_vram_len/1024); | 566 | hga_type_name, hga_vram_len/1024); |
567 | 567 | ||
568 | info = framebuffer_alloc(0, NULL); | 568 | info = framebuffer_alloc(0, &pdev->dev); |
569 | if (!info) { | 569 | if (!info) { |
570 | iounmap(hga_vram); | 570 | iounmap(hga_vram); |
571 | return -ENOMEM; | 571 | return -ENOMEM; |
@@ -593,13 +593,13 @@ static int __init hgafb_probe(struct device *device) | |||
593 | 593 | ||
594 | printk(KERN_INFO "fb%d: %s frame buffer device\n", | 594 | printk(KERN_INFO "fb%d: %s frame buffer device\n", |
595 | info->node, info->fix.id); | 595 | info->node, info->fix.id); |
596 | dev_set_drvdata(device, info); | 596 | platform_set_drvdata(pdev, info); |
597 | return 0; | 597 | return 0; |
598 | } | 598 | } |
599 | 599 | ||
600 | static int hgafb_remove(struct device *device) | 600 | static int hgafb_remove(struct platform_device *pdev) |
601 | { | 601 | { |
602 | struct fb_info *info = dev_get_drvdata(device); | 602 | struct fb_info *info = platform_get_drvdata(pdev); |
603 | 603 | ||
604 | hga_txt_mode(); | 604 | hga_txt_mode(); |
605 | hga_clear_screen(); | 605 | hga_clear_screen(); |
@@ -620,16 +620,15 @@ static int hgafb_remove(struct device *device) | |||
620 | return 0; | 620 | return 0; |
621 | } | 621 | } |
622 | 622 | ||
623 | static struct device_driver hgafb_driver = { | 623 | static struct platform_driver hgafb_driver = { |
624 | .name = "hgafb", | ||
625 | .bus = &platform_bus_type, | ||
626 | .probe = hgafb_probe, | 624 | .probe = hgafb_probe, |
627 | .remove = hgafb_remove, | 625 | .remove = hgafb_remove, |
626 | .driver = { | ||
627 | .name = "hgafb", | ||
628 | }, | ||
628 | }; | 629 | }; |
629 | 630 | ||
630 | static struct platform_device hgafb_device = { | 631 | static struct platform_device *hgafb_device; |
631 | .name = "hgafb", | ||
632 | }; | ||
633 | 632 | ||
634 | static int __init hgafb_init(void) | 633 | static int __init hgafb_init(void) |
635 | { | 634 | { |
@@ -638,12 +637,15 @@ static int __init hgafb_init(void) | |||
638 | if (fb_get_options("hgafb", NULL)) | 637 | if (fb_get_options("hgafb", NULL)) |
639 | return -ENODEV; | 638 | return -ENODEV; |
640 | 639 | ||
641 | ret = driver_register(&hgafb_driver); | 640 | ret = platform_driver_register(&hgafb_driver); |
642 | 641 | ||
643 | if (!ret) { | 642 | if (!ret) { |
644 | ret = platform_device_register(&hgafb_device); | 643 | hgafb_device = platform_device_register_simple("hgafb", 0, NULL, 0); |
645 | if (ret) | 644 | |
646 | driver_unregister(&hgafb_driver); | 645 | if (IS_ERR(hgafb_device)) { |
646 | platform_driver_unregister(&hgafb_driver); | ||
647 | ret = PTR_ERR(hgafb_device); | ||
648 | } | ||
647 | } | 649 | } |
648 | 650 | ||
649 | return ret; | 651 | return ret; |
@@ -651,8 +653,8 @@ static int __init hgafb_init(void) | |||
651 | 653 | ||
652 | static void __exit hgafb_exit(void) | 654 | static void __exit hgafb_exit(void) |
653 | { | 655 | { |
654 | platform_device_unregister(&hgafb_device); | 656 | platform_device_unregister(hgafb_device); |
655 | driver_unregister(&hgafb_driver); | 657 | platform_driver_unregister(&hgafb_driver); |
656 | } | 658 | } |
657 | 659 | ||
658 | /* ------------------------------------------------------------------------- | 660 | /* ------------------------------------------------------------------------- |
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 94e4d3ac1a05..0c5a475c1cae 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/string.h> | 24 | #include <linux/string.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/mm.h> | ||
27 | #include <linux/fb.h> | 28 | #include <linux/fb.h> |
28 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
29 | #include <linux/init.h> | 30 | #include <linux/init.h> |
diff --git a/drivers/video/neofb.c b/drivers/video/neofb.c index 5246b0402d76..25172b2a2a94 100644 --- a/drivers/video/neofb.c +++ b/drivers/video/neofb.c | |||
@@ -201,7 +201,6 @@ static int neoFindMode(int xres, int yres, int depth) | |||
201 | * | 201 | * |
202 | * Determine the closest clock frequency to the one requested. | 202 | * Determine the closest clock frequency to the one requested. |
203 | */ | 203 | */ |
204 | #define REF_FREQ 0xe517 /* 14.31818 in 20.12 fixed point */ | ||
205 | #define MAX_N 127 | 204 | #define MAX_N 127 |
206 | #define MAX_D 31 | 205 | #define MAX_D 31 |
207 | #define MAX_F 1 | 206 | #define MAX_F 1 |
@@ -211,27 +210,24 @@ static void neoCalcVCLK(const struct fb_info *info, | |||
211 | { | 210 | { |
212 | int n, d, f; | 211 | int n, d, f; |
213 | int n_best = 0, d_best = 0, f_best = 0; | 212 | int n_best = 0, d_best = 0, f_best = 0; |
214 | long f_best_diff = (0x7ffff << 12); /* 20.12 */ | 213 | long f_best_diff = 0x7ffff; |
215 | long f_target = (freq << 12) / 1000; /* 20.12 */ | ||
216 | 214 | ||
217 | for (f = 0; f <= MAX_F; f++) | 215 | for (f = 0; f <= MAX_F; f++) |
218 | for (n = 0; n <= MAX_N; n++) | 216 | for (d = 0; d <= MAX_D; d++) |
219 | for (d = 0; d <= MAX_D; d++) { | 217 | for (n = 0; n <= MAX_N; n++) { |
220 | long f_out; /* 20.12 */ | 218 | long f_out; |
221 | long f_diff; /* 20.12 */ | 219 | long f_diff; |
222 | 220 | ||
223 | f_out = | 221 | f_out = ((14318 * (n + 1)) / (d + 1)) >> f; |
224 | ((((n + 1) << 12) / ((d + | 222 | f_diff = abs(f_out - freq); |
225 | 1) * | 223 | if (f_diff <= f_best_diff) { |
226 | (1 << f))) >> 12) | ||
227 | * REF_FREQ; | ||
228 | f_diff = abs(f_out - f_target); | ||
229 | if (f_diff < f_best_diff) { | ||
230 | f_best_diff = f_diff; | 224 | f_best_diff = f_diff; |
231 | n_best = n; | 225 | n_best = n; |
232 | d_best = d; | 226 | d_best = d; |
233 | f_best = f; | 227 | f_best = f; |
234 | } | 228 | } |
229 | if (f_out > freq) | ||
230 | break; | ||
235 | } | 231 | } |
236 | 232 | ||
237 | if (info->fix.accel == FB_ACCEL_NEOMAGIC_NM2200 || | 233 | if (info->fix.accel == FB_ACCEL_NEOMAGIC_NM2200 || |
@@ -248,11 +244,11 @@ static void neoCalcVCLK(const struct fb_info *info, | |||
248 | par->VCLK3Denominator = d_best; | 244 | par->VCLK3Denominator = d_best; |
249 | 245 | ||
250 | #ifdef NEOFB_DEBUG | 246 | #ifdef NEOFB_DEBUG |
251 | printk("neoVCLK: f:%d NumLow=%d NumHi=%d Den=%d Df=%d\n", | 247 | printk(KERN_DEBUG "neoVCLK: f:%ld NumLow=%d NumHi=%d Den=%d Df=%ld\n", |
252 | f_target >> 12, | 248 | freq, |
253 | par->VCLK3NumeratorLow, | 249 | par->VCLK3NumeratorLow, |
254 | par->VCLK3NumeratorHigh, | 250 | par->VCLK3NumeratorHigh, |
255 | par->VCLK3Denominator, f_best_diff >> 12); | 251 | par->VCLK3Denominator, f_best_diff); |
256 | #endif | 252 | #endif |
257 | } | 253 | } |
258 | 254 | ||
@@ -263,15 +259,20 @@ static void neoCalcVCLK(const struct fb_info *info, | |||
263 | */ | 259 | */ |
264 | 260 | ||
265 | static int vgaHWInit(const struct fb_var_screeninfo *var, | 261 | static int vgaHWInit(const struct fb_var_screeninfo *var, |
266 | const struct fb_info *info, | 262 | struct neofb_par *par) |
267 | struct neofb_par *par, struct xtimings *timings) | ||
268 | { | 263 | { |
264 | int hsync_end = var->xres + var->right_margin + var->hsync_len; | ||
265 | int htotal = (hsync_end + var->left_margin) >> 3; | ||
266 | int vsync_start = var->yres + var->lower_margin; | ||
267 | int vsync_end = vsync_start + var->vsync_len; | ||
268 | int vtotal = vsync_end + var->upper_margin; | ||
269 | |||
269 | par->MiscOutReg = 0x23; | 270 | par->MiscOutReg = 0x23; |
270 | 271 | ||
271 | if (!(timings->sync & FB_SYNC_HOR_HIGH_ACT)) | 272 | if (!(var->sync & FB_SYNC_HOR_HIGH_ACT)) |
272 | par->MiscOutReg |= 0x40; | 273 | par->MiscOutReg |= 0x40; |
273 | 274 | ||
274 | if (!(timings->sync & FB_SYNC_VERT_HIGH_ACT)) | 275 | if (!(var->sync & FB_SYNC_VERT_HIGH_ACT)) |
275 | par->MiscOutReg |= 0x80; | 276 | par->MiscOutReg |= 0x80; |
276 | 277 | ||
277 | /* | 278 | /* |
@@ -286,25 +287,25 @@ static int vgaHWInit(const struct fb_var_screeninfo *var, | |||
286 | /* | 287 | /* |
287 | * CRTC Controller | 288 | * CRTC Controller |
288 | */ | 289 | */ |
289 | par->CRTC[0] = (timings->HTotal >> 3) - 5; | 290 | par->CRTC[0] = htotal - 5; |
290 | par->CRTC[1] = (timings->HDisplay >> 3) - 1; | 291 | par->CRTC[1] = (var->xres >> 3) - 1; |
291 | par->CRTC[2] = (timings->HDisplay >> 3) - 1; | 292 | par->CRTC[2] = (var->xres >> 3) - 1; |
292 | par->CRTC[3] = (((timings->HTotal >> 3) - 1) & 0x1F) | 0x80; | 293 | par->CRTC[3] = ((htotal - 1) & 0x1F) | 0x80; |
293 | par->CRTC[4] = (timings->HSyncStart >> 3); | 294 | par->CRTC[4] = ((var->xres + var->right_margin) >> 3); |
294 | par->CRTC[5] = ((((timings->HTotal >> 3) - 1) & 0x20) << 2) | 295 | par->CRTC[5] = (((htotal - 1) & 0x20) << 2) |
295 | | (((timings->HSyncEnd >> 3)) & 0x1F); | 296 | | (((hsync_end >> 3)) & 0x1F); |
296 | par->CRTC[6] = (timings->VTotal - 2) & 0xFF; | 297 | par->CRTC[6] = (vtotal - 2) & 0xFF; |
297 | par->CRTC[7] = (((timings->VTotal - 2) & 0x100) >> 8) | 298 | par->CRTC[7] = (((vtotal - 2) & 0x100) >> 8) |
298 | | (((timings->VDisplay - 1) & 0x100) >> 7) | 299 | | (((var->yres - 1) & 0x100) >> 7) |
299 | | ((timings->VSyncStart & 0x100) >> 6) | 300 | | ((vsync_start & 0x100) >> 6) |
300 | | (((timings->VDisplay - 1) & 0x100) >> 5) | 301 | | (((var->yres - 1) & 0x100) >> 5) |
301 | | 0x10 | (((timings->VTotal - 2) & 0x200) >> 4) | 302 | | 0x10 | (((vtotal - 2) & 0x200) >> 4) |
302 | | (((timings->VDisplay - 1) & 0x200) >> 3) | 303 | | (((var->yres - 1) & 0x200) >> 3) |
303 | | ((timings->VSyncStart & 0x200) >> 2); | 304 | | ((vsync_start & 0x200) >> 2); |
304 | par->CRTC[8] = 0x00; | 305 | par->CRTC[8] = 0x00; |
305 | par->CRTC[9] = (((timings->VDisplay - 1) & 0x200) >> 4) | 0x40; | 306 | par->CRTC[9] = (((var->yres - 1) & 0x200) >> 4) | 0x40; |
306 | 307 | ||
307 | if (timings->dblscan) | 308 | if (var->vmode & FB_VMODE_DOUBLE) |
308 | par->CRTC[9] |= 0x80; | 309 | par->CRTC[9] |= 0x80; |
309 | 310 | ||
310 | par->CRTC[10] = 0x00; | 311 | par->CRTC[10] = 0x00; |
@@ -313,13 +314,13 @@ static int vgaHWInit(const struct fb_var_screeninfo *var, | |||
313 | par->CRTC[13] = 0x00; | 314 | par->CRTC[13] = 0x00; |
314 | par->CRTC[14] = 0x00; | 315 | par->CRTC[14] = 0x00; |
315 | par->CRTC[15] = 0x00; | 316 | par->CRTC[15] = 0x00; |
316 | par->CRTC[16] = timings->VSyncStart & 0xFF; | 317 | par->CRTC[16] = vsync_start & 0xFF; |
317 | par->CRTC[17] = (timings->VSyncEnd & 0x0F) | 0x20; | 318 | par->CRTC[17] = (vsync_end & 0x0F) | 0x20; |
318 | par->CRTC[18] = (timings->VDisplay - 1) & 0xFF; | 319 | par->CRTC[18] = (var->yres - 1) & 0xFF; |
319 | par->CRTC[19] = var->xres_virtual >> 4; | 320 | par->CRTC[19] = var->xres_virtual >> 4; |
320 | par->CRTC[20] = 0x00; | 321 | par->CRTC[20] = 0x00; |
321 | par->CRTC[21] = (timings->VDisplay - 1) & 0xFF; | 322 | par->CRTC[21] = (var->yres - 1) & 0xFF; |
322 | par->CRTC[22] = (timings->VTotal - 1) & 0xFF; | 323 | par->CRTC[22] = (vtotal - 1) & 0xFF; |
323 | par->CRTC[23] = 0xC3; | 324 | par->CRTC[23] = 0xC3; |
324 | par->CRTC[24] = 0xFF; | 325 | par->CRTC[24] = 0xFF; |
325 | 326 | ||
@@ -483,7 +484,8 @@ static inline int neo2200_sync(struct fb_info *info) | |||
483 | { | 484 | { |
484 | struct neofb_par *par = info->par; | 485 | struct neofb_par *par = info->par; |
485 | 486 | ||
486 | while (readl(&par->neo2200->bltStat) & 1); | 487 | while (readl(&par->neo2200->bltStat) & 1) |
488 | cpu_relax(); | ||
487 | return 0; | 489 | return 0; |
488 | } | 490 | } |
489 | 491 | ||
@@ -591,34 +593,14 @@ static int | |||
591 | neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | 593 | neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
592 | { | 594 | { |
593 | struct neofb_par *par = info->par; | 595 | struct neofb_par *par = info->par; |
594 | unsigned int pixclock = var->pixclock; | ||
595 | struct xtimings timings; | ||
596 | int memlen, vramlen; | 596 | int memlen, vramlen; |
597 | int mode_ok = 0; | 597 | int mode_ok = 0; |
598 | 598 | ||
599 | DBG("neofb_check_var"); | 599 | DBG("neofb_check_var"); |
600 | 600 | ||
601 | if (!pixclock) | 601 | if (PICOS2KHZ(var->pixclock) > par->maxClock) |
602 | pixclock = 10000; /* 10ns = 100MHz */ | ||
603 | timings.pixclock = 1000000000 / pixclock; | ||
604 | if (timings.pixclock < 1) | ||
605 | timings.pixclock = 1; | ||
606 | |||
607 | if (timings.pixclock > par->maxClock) | ||
608 | return -EINVAL; | 602 | return -EINVAL; |
609 | 603 | ||
610 | timings.dblscan = var->vmode & FB_VMODE_DOUBLE; | ||
611 | timings.interlaced = var->vmode & FB_VMODE_INTERLACED; | ||
612 | timings.HDisplay = var->xres; | ||
613 | timings.HSyncStart = timings.HDisplay + var->right_margin; | ||
614 | timings.HSyncEnd = timings.HSyncStart + var->hsync_len; | ||
615 | timings.HTotal = timings.HSyncEnd + var->left_margin; | ||
616 | timings.VDisplay = var->yres; | ||
617 | timings.VSyncStart = timings.VDisplay + var->lower_margin; | ||
618 | timings.VSyncEnd = timings.VSyncStart + var->vsync_len; | ||
619 | timings.VTotal = timings.VSyncEnd + var->upper_margin; | ||
620 | timings.sync = var->sync; | ||
621 | |||
622 | /* Is the mode larger than the LCD panel? */ | 604 | /* Is the mode larger than the LCD panel? */ |
623 | if (par->internal_display && | 605 | if (par->internal_display && |
624 | ((var->xres > par->NeoPanelWidth) || | 606 | ((var->xres > par->NeoPanelWidth) || |
@@ -759,11 +741,11 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
759 | static int neofb_set_par(struct fb_info *info) | 741 | static int neofb_set_par(struct fb_info *info) |
760 | { | 742 | { |
761 | struct neofb_par *par = info->par; | 743 | struct neofb_par *par = info->par; |
762 | struct xtimings timings; | ||
763 | unsigned char temp; | 744 | unsigned char temp; |
764 | int i, clock_hi = 0; | 745 | int i, clock_hi = 0; |
765 | int lcd_stretch; | 746 | int lcd_stretch; |
766 | int hoffset, voffset; | 747 | int hoffset, voffset; |
748 | int vsync_start, vtotal; | ||
767 | 749 | ||
768 | DBG("neofb_set_par"); | 750 | DBG("neofb_set_par"); |
769 | 751 | ||
@@ -771,28 +753,15 @@ static int neofb_set_par(struct fb_info *info) | |||
771 | 753 | ||
772 | vgaHWProtect(1); /* Blank the screen */ | 754 | vgaHWProtect(1); /* Blank the screen */ |
773 | 755 | ||
774 | timings.dblscan = info->var.vmode & FB_VMODE_DOUBLE; | 756 | vsync_start = info->var.yres + info->var.lower_margin; |
775 | timings.interlaced = info->var.vmode & FB_VMODE_INTERLACED; | 757 | vtotal = vsync_start + info->var.vsync_len + info->var.upper_margin; |
776 | timings.HDisplay = info->var.xres; | ||
777 | timings.HSyncStart = timings.HDisplay + info->var.right_margin; | ||
778 | timings.HSyncEnd = timings.HSyncStart + info->var.hsync_len; | ||
779 | timings.HTotal = timings.HSyncEnd + info->var.left_margin; | ||
780 | timings.VDisplay = info->var.yres; | ||
781 | timings.VSyncStart = timings.VDisplay + info->var.lower_margin; | ||
782 | timings.VSyncEnd = timings.VSyncStart + info->var.vsync_len; | ||
783 | timings.VTotal = timings.VSyncEnd + info->var.upper_margin; | ||
784 | timings.sync = info->var.sync; | ||
785 | timings.pixclock = PICOS2KHZ(info->var.pixclock); | ||
786 | |||
787 | if (timings.pixclock < 1) | ||
788 | timings.pixclock = 1; | ||
789 | 758 | ||
790 | /* | 759 | /* |
791 | * This will allocate the datastructure and initialize all of the | 760 | * This will allocate the datastructure and initialize all of the |
792 | * generic VGA registers. | 761 | * generic VGA registers. |
793 | */ | 762 | */ |
794 | 763 | ||
795 | if (vgaHWInit(&info->var, info, par, &timings)) | 764 | if (vgaHWInit(&info->var, par)) |
796 | return -EINVAL; | 765 | return -EINVAL; |
797 | 766 | ||
798 | /* | 767 | /* |
@@ -831,10 +800,10 @@ static int neofb_set_par(struct fb_info *info) | |||
831 | par->ExtCRTDispAddr = 0x10; | 800 | par->ExtCRTDispAddr = 0x10; |
832 | 801 | ||
833 | /* Vertical Extension */ | 802 | /* Vertical Extension */ |
834 | par->VerticalExt = (((timings.VTotal - 2) & 0x400) >> 10) | 803 | par->VerticalExt = (((vtotal - 2) & 0x400) >> 10) |
835 | | (((timings.VDisplay - 1) & 0x400) >> 9) | 804 | | (((info->var.yres - 1) & 0x400) >> 9) |
836 | | (((timings.VSyncStart) & 0x400) >> 8) | 805 | | (((vsync_start) & 0x400) >> 8) |
837 | | (((timings.VSyncStart) & 0x400) >> 7); | 806 | | (((vsync_start) & 0x400) >> 7); |
838 | 807 | ||
839 | /* Fast write bursts on unless disabled. */ | 808 | /* Fast write bursts on unless disabled. */ |
840 | if (par->pci_burst) | 809 | if (par->pci_burst) |
@@ -995,7 +964,7 @@ static int neofb_set_par(struct fb_info *info) | |||
995 | * Calculate the VCLK that most closely matches the requested dot | 964 | * Calculate the VCLK that most closely matches the requested dot |
996 | * clock. | 965 | * clock. |
997 | */ | 966 | */ |
998 | neoCalcVCLK(info, par, timings.pixclock); | 967 | neoCalcVCLK(info, par, PICOS2KHZ(info->var.pixclock)); |
999 | 968 | ||
1000 | /* Since we program the clocks ourselves, always use VCLK3. */ | 969 | /* Since we program the clocks ourselves, always use VCLK3. */ |
1001 | par->MiscOutReg |= 0x0C; | 970 | par->MiscOutReg |= 0x0C; |
@@ -1927,9 +1896,6 @@ static int __devinit neo_init_hw(struct fb_info *info) | |||
1927 | int maxClock = 65000; | 1896 | int maxClock = 65000; |
1928 | int CursorMem = 1024; | 1897 | int CursorMem = 1024; |
1929 | int CursorOff = 0x100; | 1898 | int CursorOff = 0x100; |
1930 | int linearSize = 1024; | ||
1931 | int maxWidth = 1024; | ||
1932 | int maxHeight = 1024; | ||
1933 | 1899 | ||
1934 | DBG("neo_init_hw"); | 1900 | DBG("neo_init_hw"); |
1935 | 1901 | ||
@@ -1948,81 +1914,52 @@ static int __devinit neo_init_hw(struct fb_info *info) | |||
1948 | case FB_ACCEL_NEOMAGIC_NM2070: | 1914 | case FB_ACCEL_NEOMAGIC_NM2070: |
1949 | videoRam = 896; | 1915 | videoRam = 896; |
1950 | maxClock = 65000; | 1916 | maxClock = 65000; |
1951 | CursorMem = 2048; | ||
1952 | CursorOff = 0x100; | ||
1953 | linearSize = 1024; | ||
1954 | maxWidth = 1024; | ||
1955 | maxHeight = 1024; | ||
1956 | break; | 1917 | break; |
1957 | case FB_ACCEL_NEOMAGIC_NM2090: | 1918 | case FB_ACCEL_NEOMAGIC_NM2090: |
1958 | case FB_ACCEL_NEOMAGIC_NM2093: | 1919 | case FB_ACCEL_NEOMAGIC_NM2093: |
1959 | videoRam = 1152; | ||
1960 | maxClock = 80000; | ||
1961 | CursorMem = 2048; | ||
1962 | CursorOff = 0x100; | ||
1963 | linearSize = 2048; | ||
1964 | maxWidth = 1024; | ||
1965 | maxHeight = 1024; | ||
1966 | break; | ||
1967 | case FB_ACCEL_NEOMAGIC_NM2097: | 1920 | case FB_ACCEL_NEOMAGIC_NM2097: |
1968 | videoRam = 1152; | 1921 | videoRam = 1152; |
1969 | maxClock = 80000; | 1922 | maxClock = 80000; |
1970 | CursorMem = 1024; | ||
1971 | CursorOff = 0x100; | ||
1972 | linearSize = 2048; | ||
1973 | maxWidth = 1024; | ||
1974 | maxHeight = 1024; | ||
1975 | break; | 1923 | break; |
1976 | case FB_ACCEL_NEOMAGIC_NM2160: | 1924 | case FB_ACCEL_NEOMAGIC_NM2160: |
1977 | videoRam = 2048; | 1925 | videoRam = 2048; |
1978 | maxClock = 90000; | 1926 | maxClock = 90000; |
1979 | CursorMem = 1024; | ||
1980 | CursorOff = 0x100; | ||
1981 | linearSize = 2048; | ||
1982 | maxWidth = 1024; | ||
1983 | maxHeight = 1024; | ||
1984 | break; | 1927 | break; |
1985 | case FB_ACCEL_NEOMAGIC_NM2200: | 1928 | case FB_ACCEL_NEOMAGIC_NM2200: |
1986 | videoRam = 2560; | 1929 | videoRam = 2560; |
1987 | maxClock = 110000; | 1930 | maxClock = 110000; |
1988 | CursorMem = 1024; | ||
1989 | CursorOff = 0x1000; | ||
1990 | linearSize = 4096; | ||
1991 | maxWidth = 1280; | ||
1992 | maxHeight = 1024; /* ???? */ | ||
1993 | |||
1994 | par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase; | ||
1995 | break; | 1931 | break; |
1996 | case FB_ACCEL_NEOMAGIC_NM2230: | 1932 | case FB_ACCEL_NEOMAGIC_NM2230: |
1997 | videoRam = 3008; | 1933 | videoRam = 3008; |
1998 | maxClock = 110000; | 1934 | maxClock = 110000; |
1999 | CursorMem = 1024; | ||
2000 | CursorOff = 0x1000; | ||
2001 | linearSize = 4096; | ||
2002 | maxWidth = 1280; | ||
2003 | maxHeight = 1024; /* ???? */ | ||
2004 | |||
2005 | par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase; | ||
2006 | break; | 1935 | break; |
2007 | case FB_ACCEL_NEOMAGIC_NM2360: | 1936 | case FB_ACCEL_NEOMAGIC_NM2360: |
2008 | videoRam = 4096; | 1937 | videoRam = 4096; |
2009 | maxClock = 110000; | 1938 | maxClock = 110000; |
2010 | CursorMem = 1024; | ||
2011 | CursorOff = 0x1000; | ||
2012 | linearSize = 4096; | ||
2013 | maxWidth = 1280; | ||
2014 | maxHeight = 1024; /* ???? */ | ||
2015 | |||
2016 | par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase; | ||
2017 | break; | 1939 | break; |
2018 | case FB_ACCEL_NEOMAGIC_NM2380: | 1940 | case FB_ACCEL_NEOMAGIC_NM2380: |
2019 | videoRam = 6144; | 1941 | videoRam = 6144; |
2020 | maxClock = 110000; | 1942 | maxClock = 110000; |
1943 | break; | ||
1944 | } | ||
1945 | switch (info->fix.accel) { | ||
1946 | case FB_ACCEL_NEOMAGIC_NM2070: | ||
1947 | case FB_ACCEL_NEOMAGIC_NM2090: | ||
1948 | case FB_ACCEL_NEOMAGIC_NM2093: | ||
1949 | CursorMem = 2048; | ||
1950 | CursorOff = 0x100; | ||
1951 | break; | ||
1952 | case FB_ACCEL_NEOMAGIC_NM2097: | ||
1953 | case FB_ACCEL_NEOMAGIC_NM2160: | ||
1954 | CursorMem = 1024; | ||
1955 | CursorOff = 0x100; | ||
1956 | break; | ||
1957 | case FB_ACCEL_NEOMAGIC_NM2200: | ||
1958 | case FB_ACCEL_NEOMAGIC_NM2230: | ||
1959 | case FB_ACCEL_NEOMAGIC_NM2360: | ||
1960 | case FB_ACCEL_NEOMAGIC_NM2380: | ||
2021 | CursorMem = 1024; | 1961 | CursorMem = 1024; |
2022 | CursorOff = 0x1000; | 1962 | CursorOff = 0x1000; |
2023 | linearSize = 8192; | ||
2024 | maxWidth = 1280; | ||
2025 | maxHeight = 1024; /* ???? */ | ||
2026 | 1963 | ||
2027 | par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase; | 1964 | par->neo2200 = (Neo2200 __iomem *) par->mmio_vbase; |
2028 | break; | 1965 | break; |
@@ -2036,7 +1973,7 @@ static int __devinit neo_init_hw(struct fb_info *info) | |||
2036 | */ | 1973 | */ |
2037 | par->maxClock = maxClock; | 1974 | par->maxClock = maxClock; |
2038 | par->cursorOff = CursorOff; | 1975 | par->cursorOff = CursorOff; |
2039 | return ((videoRam * 1024)); | 1976 | return videoRam * 1024; |
2040 | } | 1977 | } |
2041 | 1978 | ||
2042 | 1979 | ||
diff --git a/drivers/video/omap/dispc.c b/drivers/video/omap/dispc.c index ab32ceb06178..ab77c51fe9d6 100644 --- a/drivers/video/omap/dispc.c +++ b/drivers/video/omap/dispc.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/dma-mapping.h> | 22 | #include <linux/dma-mapping.h> |
23 | #include <linux/mm.h> | ||
23 | #include <linux/vmalloc.h> | 24 | #include <linux/vmalloc.h> |
24 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
25 | #include <linux/io.h> | 26 | #include <linux/io.h> |
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c index 14d0f7a11145..f85af5c4fa68 100644 --- a/drivers/video/omap/omapfb_main.c +++ b/drivers/video/omap/omapfb_main.c | |||
@@ -25,6 +25,7 @@ | |||
25 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 25 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
26 | */ | 26 | */ |
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/mm.h> | ||
28 | #include <linux/uaccess.h> | 29 | #include <linux/uaccess.h> |
29 | 30 | ||
30 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index bb2514369507..2b707a8ce5de 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/string.h> | 30 | #include <linux/string.h> |
31 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/mm.h> | ||
33 | #include <linux/fb.h> | 34 | #include <linux/fb.h> |
34 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
35 | #include <linux/init.h> | 36 | #include <linux/init.h> |
@@ -40,6 +41,7 @@ | |||
40 | #include <linux/clk.h> | 41 | #include <linux/clk.h> |
41 | #include <linux/err.h> | 42 | #include <linux/err.h> |
42 | #include <linux/completion.h> | 43 | #include <linux/completion.h> |
44 | #include <linux/mutex.h> | ||
43 | #include <linux/kthread.h> | 45 | #include <linux/kthread.h> |
44 | #include <linux/freezer.h> | 46 | #include <linux/freezer.h> |
45 | 47 | ||
@@ -1116,7 +1118,7 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state) | |||
1116 | { | 1118 | { |
1117 | u_int old_state; | 1119 | u_int old_state; |
1118 | 1120 | ||
1119 | down(&fbi->ctrlr_sem); | 1121 | mutex_lock(&fbi->ctrlr_lock); |
1120 | 1122 | ||
1121 | old_state = fbi->state; | 1123 | old_state = fbi->state; |
1122 | 1124 | ||
@@ -1204,7 +1206,7 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state) | |||
1204 | } | 1206 | } |
1205 | break; | 1207 | break; |
1206 | } | 1208 | } |
1207 | up(&fbi->ctrlr_sem); | 1209 | mutex_unlock(&fbi->ctrlr_lock); |
1208 | } | 1210 | } |
1209 | 1211 | ||
1210 | /* | 1212 | /* |
@@ -1457,7 +1459,7 @@ static struct pxafb_info * __devinit pxafb_init_fbinfo(struct device *dev) | |||
1457 | 1459 | ||
1458 | init_waitqueue_head(&fbi->ctrlr_wait); | 1460 | init_waitqueue_head(&fbi->ctrlr_wait); |
1459 | INIT_WORK(&fbi->task, pxafb_task); | 1461 | INIT_WORK(&fbi->task, pxafb_task); |
1460 | init_MUTEX(&fbi->ctrlr_sem); | 1462 | mutex_init(&fbi->ctrlr_lock); |
1461 | init_completion(&fbi->disable_done); | 1463 | init_completion(&fbi->disable_done); |
1462 | #ifdef CONFIG_FB_PXA_SMARTPANEL | 1464 | #ifdef CONFIG_FB_PXA_SMARTPANEL |
1463 | init_completion(&fbi->command_done); | 1465 | init_completion(&fbi->command_done); |
diff --git a/drivers/video/pxafb.h b/drivers/video/pxafb.h index 8238dc826429..31541b86f13d 100644 --- a/drivers/video/pxafb.h +++ b/drivers/video/pxafb.h | |||
@@ -106,7 +106,7 @@ struct pxafb_info { | |||
106 | 106 | ||
107 | volatile u_char state; | 107 | volatile u_char state; |
108 | volatile u_char task_state; | 108 | volatile u_char task_state; |
109 | struct semaphore ctrlr_sem; | 109 | struct mutex ctrlr_lock; |
110 | wait_queue_head_t ctrlr_wait; | 110 | wait_queue_head_t ctrlr_wait; |
111 | struct work_struct task; | 111 | struct work_struct task; |
112 | 112 | ||
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c index ab2b2110478b..78bcdbc3f484 100644 --- a/drivers/video/sa1100fb.c +++ b/drivers/video/sa1100fb.c | |||
@@ -167,6 +167,7 @@ | |||
167 | #include <linux/string.h> | 167 | #include <linux/string.h> |
168 | #include <linux/interrupt.h> | 168 | #include <linux/interrupt.h> |
169 | #include <linux/slab.h> | 169 | #include <linux/slab.h> |
170 | #include <linux/mm.h> | ||
170 | #include <linux/fb.h> | 171 | #include <linux/fb.h> |
171 | #include <linux/delay.h> | 172 | #include <linux/delay.h> |
172 | #include <linux/init.h> | 173 | #include <linux/init.h> |
@@ -174,6 +175,7 @@ | |||
174 | #include <linux/cpufreq.h> | 175 | #include <linux/cpufreq.h> |
175 | #include <linux/platform_device.h> | 176 | #include <linux/platform_device.h> |
176 | #include <linux/dma-mapping.h> | 177 | #include <linux/dma-mapping.h> |
178 | #include <linux/mutex.h> | ||
177 | 179 | ||
178 | #include <asm/hardware.h> | 180 | #include <asm/hardware.h> |
179 | #include <asm/io.h> | 181 | #include <asm/io.h> |
@@ -1107,7 +1109,7 @@ static void set_ctrlr_state(struct sa1100fb_info *fbi, u_int state) | |||
1107 | { | 1109 | { |
1108 | u_int old_state; | 1110 | u_int old_state; |
1109 | 1111 | ||
1110 | down(&fbi->ctrlr_sem); | 1112 | mutex_lock(&fbi->ctrlr_lock); |
1111 | 1113 | ||
1112 | old_state = fbi->state; | 1114 | old_state = fbi->state; |
1113 | 1115 | ||
@@ -1192,7 +1194,7 @@ static void set_ctrlr_state(struct sa1100fb_info *fbi, u_int state) | |||
1192 | } | 1194 | } |
1193 | break; | 1195 | break; |
1194 | } | 1196 | } |
1195 | up(&fbi->ctrlr_sem); | 1197 | mutex_unlock(&fbi->ctrlr_lock); |
1196 | } | 1198 | } |
1197 | 1199 | ||
1198 | /* | 1200 | /* |
@@ -1444,7 +1446,7 @@ static struct sa1100fb_info * __init sa1100fb_init_fbinfo(struct device *dev) | |||
1444 | 1446 | ||
1445 | init_waitqueue_head(&fbi->ctrlr_wait); | 1447 | init_waitqueue_head(&fbi->ctrlr_wait); |
1446 | INIT_WORK(&fbi->task, sa1100fb_task); | 1448 | INIT_WORK(&fbi->task, sa1100fb_task); |
1447 | init_MUTEX(&fbi->ctrlr_sem); | 1449 | mutex_init(&fbi->ctrlr_lock); |
1448 | 1450 | ||
1449 | return fbi; | 1451 | return fbi; |
1450 | } | 1452 | } |
diff --git a/drivers/video/sa1100fb.h b/drivers/video/sa1100fb.h index f465b27ed860..86831db9a042 100644 --- a/drivers/video/sa1100fb.h +++ b/drivers/video/sa1100fb.h | |||
@@ -100,7 +100,7 @@ struct sa1100fb_info { | |||
100 | 100 | ||
101 | volatile u_char state; | 101 | volatile u_char state; |
102 | volatile u_char task_state; | 102 | volatile u_char task_state; |
103 | struct semaphore ctrlr_sem; | 103 | struct mutex ctrlr_lock; |
104 | wait_queue_head_t ctrlr_wait; | 104 | wait_queue_head_t ctrlr_wait; |
105 | struct work_struct task; | 105 | struct work_struct task; |
106 | 106 | ||
diff --git a/drivers/video/sh7760fb.c b/drivers/video/sh7760fb.c new file mode 100644 index 000000000000..4d0e28c5790b --- /dev/null +++ b/drivers/video/sh7760fb.c | |||
@@ -0,0 +1,658 @@ | |||
1 | /* | ||
2 | * SH7760/SH7763 LCDC Framebuffer driver. | ||
3 | * | ||
4 | * (c) 2006-2008 MSC Vertriebsges.m.b.H., | ||
5 | * Manuel Lauss <mano@roarinelk.homelinux.net> | ||
6 | * (c) 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com> | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General | ||
9 | * Public License. See the file COPYING in the main directory of this | ||
10 | * archive for more details. | ||
11 | * | ||
12 | * PLEASE HAVE A LOOK AT Documentation/fb/sh7760fb.txt! | ||
13 | * | ||
14 | * Thanks to Siegfried Schaefer <s.schaefer at schaefer-edv.de> | ||
15 | * for his original source and testing! | ||
16 | */ | ||
17 | |||
18 | #include <linux/completion.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/dma-mapping.h> | ||
21 | #include <linux/fb.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | |||
28 | #include <asm/sh7760fb.h> | ||
29 | |||
30 | struct sh7760fb_par { | ||
31 | void __iomem *base; | ||
32 | int irq; | ||
33 | |||
34 | struct sh7760fb_platdata *pd; /* display information */ | ||
35 | |||
36 | dma_addr_t fbdma; /* physical address */ | ||
37 | |||
38 | int rot; /* rotation enabled? */ | ||
39 | |||
40 | u32 pseudo_palette[16]; | ||
41 | |||
42 | struct platform_device *dev; | ||
43 | struct resource *ioarea; | ||
44 | struct completion vsync; /* vsync irq event */ | ||
45 | }; | ||
46 | |||
47 | static irqreturn_t sh7760fb_irq(int irq, void *data) | ||
48 | { | ||
49 | struct completion *c = data; | ||
50 | |||
51 | complete(c); | ||
52 | |||
53 | return IRQ_HANDLED; | ||
54 | } | ||
55 | |||
56 | static void sh7760fb_wait_vsync(struct fb_info *info) | ||
57 | { | ||
58 | struct sh7760fb_par *par = info->par; | ||
59 | |||
60 | if (par->pd->novsync) | ||
61 | return; | ||
62 | |||
63 | iowrite16(ioread16(par->base + LDINTR) & ~VINT_CHECK, | ||
64 | par->base + LDINTR); | ||
65 | |||
66 | if (par->irq < 0) { | ||
67 | /* poll for vert. retrace: status bit is sticky */ | ||
68 | while (!(ioread16(par->base + LDINTR) & VINT_CHECK)) | ||
69 | cpu_relax(); | ||
70 | } else { | ||
71 | /* a "wait_for_irq_event(par->irq)" would be extremely nice */ | ||
72 | init_completion(&par->vsync); | ||
73 | enable_irq(par->irq); | ||
74 | wait_for_completion(&par->vsync); | ||
75 | disable_irq_nosync(par->irq); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | /* wait_for_lps - wait until power supply has reached a certain state. */ | ||
80 | static int wait_for_lps(struct sh7760fb_par *par, int val) | ||
81 | { | ||
82 | int i = 100; | ||
83 | while (--i && ((ioread16(par->base + LDPMMR) & 3) != val)) | ||
84 | msleep(1); | ||
85 | |||
86 | if (i <= 0) | ||
87 | return -ETIMEDOUT; | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | /* en/disable the LCDC */ | ||
93 | static int sh7760fb_blank(int blank, struct fb_info *info) | ||
94 | { | ||
95 | struct sh7760fb_par *par = info->par; | ||
96 | struct sh7760fb_platdata *pd = par->pd; | ||
97 | unsigned short cntr = ioread16(par->base + LDCNTR); | ||
98 | unsigned short intr = ioread16(par->base + LDINTR); | ||
99 | int lps; | ||
100 | |||
101 | if (blank == FB_BLANK_UNBLANK) { | ||
102 | intr |= VINT_START; | ||
103 | cntr = LDCNTR_DON2 | LDCNTR_DON; | ||
104 | lps = 3; | ||
105 | } else { | ||
106 | intr &= ~VINT_START; | ||
107 | cntr = LDCNTR_DON2; | ||
108 | lps = 0; | ||
109 | } | ||
110 | |||
111 | if (pd->blank) | ||
112 | pd->blank(blank); | ||
113 | |||
114 | iowrite16(intr, par->base + LDINTR); | ||
115 | iowrite16(cntr, par->base + LDCNTR); | ||
116 | |||
117 | return wait_for_lps(par, lps); | ||
118 | } | ||
119 | |||
120 | /* set color registers */ | ||
121 | static int sh7760fb_setcmap(struct fb_cmap *cmap, struct fb_info *info) | ||
122 | { | ||
123 | struct sh7760fb_par *par = info->par; | ||
124 | u32 s = cmap->start; | ||
125 | u32 l = cmap->len; | ||
126 | u16 *r = cmap->red; | ||
127 | u16 *g = cmap->green; | ||
128 | u16 *b = cmap->blue; | ||
129 | u32 col, tmo; | ||
130 | int ret; | ||
131 | |||
132 | ret = 0; | ||
133 | |||
134 | sh7760fb_wait_vsync(info); | ||
135 | |||
136 | /* request palette access */ | ||
137 | iowrite16(LDPALCR_PALEN, par->base + LDPALCR); | ||
138 | |||
139 | /* poll for access grant */ | ||
140 | tmo = 100; | ||
141 | while (!(ioread16(par->base + LDPALCR) & LDPALCR_PALS) && (--tmo)) | ||
142 | cpu_relax(); | ||
143 | |||
144 | if (!tmo) { | ||
145 | ret = 1; | ||
146 | dev_dbg(info->dev, "no palette access!\n"); | ||
147 | goto out; | ||
148 | } | ||
149 | |||
150 | while (l && (s < 256)) { | ||
151 | col = ((*r) & 0xff) << 16; | ||
152 | col |= ((*g) & 0xff) << 8; | ||
153 | col |= ((*b) & 0xff); | ||
154 | col &= SH7760FB_PALETTE_MASK; | ||
155 | |||
156 | if (s < 16) | ||
157 | ((u32 *) (info->pseudo_palette))[s] = s; | ||
158 | |||
159 | s++; | ||
160 | l--; | ||
161 | r++; | ||
162 | g++; | ||
163 | b++; | ||
164 | } | ||
165 | out: | ||
166 | iowrite16(0, par->base + LDPALCR); | ||
167 | return ret; | ||
168 | } | ||
169 | |||
170 | static void encode_fix(struct fb_fix_screeninfo *fix, struct fb_info *info, | ||
171 | unsigned long stride) | ||
172 | { | ||
173 | memset(fix, 0, sizeof(struct fb_fix_screeninfo)); | ||
174 | strcpy(fix->id, "sh7760-lcdc"); | ||
175 | |||
176 | fix->smem_start = (unsigned long)info->screen_base; | ||
177 | fix->smem_len = info->screen_size; | ||
178 | |||
179 | fix->line_length = stride; | ||
180 | } | ||
181 | |||
182 | static int sh7760fb_get_color_info(struct device *dev, | ||
183 | u16 lddfr, int *bpp, int *gray) | ||
184 | { | ||
185 | int lbpp, lgray; | ||
186 | |||
187 | lgray = lbpp = 0; | ||
188 | |||
189 | switch (lddfr & LDDFR_COLOR_MASK) { | ||
190 | case LDDFR_1BPP_MONO: | ||
191 | lgray = 1; | ||
192 | lbpp = 1; | ||
193 | break; | ||
194 | case LDDFR_2BPP_MONO: | ||
195 | lgray = 1; | ||
196 | lbpp = 2; | ||
197 | break; | ||
198 | case LDDFR_4BPP_MONO: | ||
199 | lgray = 1; | ||
200 | case LDDFR_4BPP: | ||
201 | lbpp = 4; | ||
202 | break; | ||
203 | case LDDFR_6BPP_MONO: | ||
204 | lgray = 1; | ||
205 | case LDDFR_8BPP: | ||
206 | lbpp = 8; | ||
207 | break; | ||
208 | case LDDFR_16BPP_RGB555: | ||
209 | case LDDFR_16BPP_RGB565: | ||
210 | lbpp = 16; | ||
211 | lgray = 0; | ||
212 | break; | ||
213 | default: | ||
214 | dev_dbg(dev, "unsupported LDDFR bit depth.\n"); | ||
215 | return -EINVAL; | ||
216 | } | ||
217 | |||
218 | if (bpp) | ||
219 | *bpp = lbpp; | ||
220 | if (gray) | ||
221 | *gray = lgray; | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static int sh7760fb_check_var(struct fb_var_screeninfo *var, | ||
227 | struct fb_info *info) | ||
228 | { | ||
229 | struct fb_fix_screeninfo *fix = &info->fix; | ||
230 | struct sh7760fb_par *par = info->par; | ||
231 | int ret, bpp; | ||
232 | |||
233 | /* get color info from register value */ | ||
234 | ret = sh7760fb_get_color_info(info->dev, par->pd->lddfr, &bpp, NULL); | ||
235 | if (ret) | ||
236 | return ret; | ||
237 | |||
238 | var->bits_per_pixel = bpp; | ||
239 | |||
240 | if ((var->grayscale) && (var->bits_per_pixel == 1)) | ||
241 | fix->visual = FB_VISUAL_MONO10; | ||
242 | else if (var->bits_per_pixel >= 15) | ||
243 | fix->visual = FB_VISUAL_TRUECOLOR; | ||
244 | else | ||
245 | fix->visual = FB_VISUAL_PSEUDOCOLOR; | ||
246 | |||
247 | /* TODO: add some more validation here */ | ||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * sh7760fb_set_par - set videomode. | ||
253 | * | ||
254 | * NOTE: The rotation, grayscale and DSTN codepaths are | ||
255 | * totally untested! | ||
256 | */ | ||
257 | static int sh7760fb_set_par(struct fb_info *info) | ||
258 | { | ||
259 | struct sh7760fb_par *par = info->par; | ||
260 | struct fb_videomode *vm = par->pd->def_mode; | ||
261 | unsigned long sbase, dstn_off, ldsarl, stride; | ||
262 | unsigned short hsynp, hsynw, htcn, hdcn; | ||
263 | unsigned short vsynp, vsynw, vtln, vdln; | ||
264 | unsigned short lddfr, ldmtr; | ||
265 | int ret, bpp, gray; | ||
266 | |||
267 | par->rot = par->pd->rotate; | ||
268 | |||
269 | /* rotate only works with xres <= 320 */ | ||
270 | if (par->rot && (vm->xres > 320)) { | ||
271 | dev_dbg(info->dev, "rotation disabled due to display size\n"); | ||
272 | par->rot = 0; | ||
273 | } | ||
274 | |||
275 | /* calculate LCDC reg vals from display parameters */ | ||
276 | hsynp = vm->right_margin + vm->xres; | ||
277 | hsynw = vm->hsync_len; | ||
278 | htcn = vm->left_margin + hsynp + hsynw; | ||
279 | hdcn = vm->xres; | ||
280 | vsynp = vm->lower_margin + vm->yres; | ||
281 | vsynw = vm->vsync_len; | ||
282 | vtln = vm->upper_margin + vsynp + vsynw; | ||
283 | vdln = vm->yres; | ||
284 | |||
285 | /* get color info from register value */ | ||
286 | ret = sh7760fb_get_color_info(info->dev, par->pd->lddfr, &bpp, &gray); | ||
287 | if (ret) | ||
288 | return ret; | ||
289 | |||
290 | dev_dbg(info->dev, "%dx%d %dbpp %s (orientation %s)\n", hdcn, | ||
291 | vdln, bpp, gray ? "grayscale" : "color", | ||
292 | par->rot ? "rotated" : "normal"); | ||
293 | |||
294 | #ifdef CONFIG_CPU_LITTLE_ENDIAN | ||
295 | lddfr = par->pd->lddfr | (1 << 8); | ||
296 | #else | ||
297 | lddfr = par->pd->lddfr & ~(1 << 8); | ||
298 | #endif | ||
299 | |||
300 | ldmtr = par->pd->ldmtr; | ||
301 | |||
302 | if (!(vm->sync & FB_SYNC_HOR_HIGH_ACT)) | ||
303 | ldmtr |= LDMTR_CL1POL; | ||
304 | if (!(vm->sync & FB_SYNC_VERT_HIGH_ACT)) | ||
305 | ldmtr |= LDMTR_FLMPOL; | ||
306 | |||
307 | /* shut down LCDC before changing display parameters */ | ||
308 | sh7760fb_blank(FB_BLANK_POWERDOWN, info); | ||
309 | |||
310 | iowrite16(par->pd->ldickr, par->base + LDICKR); /* pixclock */ | ||
311 | iowrite16(ldmtr, par->base + LDMTR); /* polarities */ | ||
312 | iowrite16(lddfr, par->base + LDDFR); /* color/depth */ | ||
313 | iowrite16((par->rot ? 1 << 13 : 0), par->base + LDSMR); /* rotate */ | ||
314 | iowrite16(par->pd->ldpmmr, par->base + LDPMMR); /* Power Management */ | ||
315 | iowrite16(par->pd->ldpspr, par->base + LDPSPR); /* Power Supply Ctrl */ | ||
316 | |||
317 | /* display resolution */ | ||
318 | iowrite16(((htcn >> 3) - 1) | (((hdcn >> 3) - 1) << 8), | ||
319 | par->base + LDHCNR); | ||
320 | iowrite16(vdln - 1, par->base + LDVDLNR); | ||
321 | iowrite16(vtln - 1, par->base + LDVTLNR); | ||
322 | /* h/v sync signals */ | ||
323 | iowrite16((vsynp - 1) | ((vsynw - 1) << 12), par->base + LDVSYNR); | ||
324 | iowrite16(((hsynp >> 3) - 1) | (((hsynw >> 3) - 1) << 12), | ||
325 | par->base + LDHSYNR); | ||
326 | /* AC modulation sig */ | ||
327 | iowrite16(par->pd->ldaclnr, par->base + LDACLNR); | ||
328 | |||
329 | stride = (par->rot) ? vtln : hdcn; | ||
330 | if (!gray) | ||
331 | stride *= (bpp + 7) >> 3; | ||
332 | else { | ||
333 | if (bpp == 1) | ||
334 | stride >>= 3; | ||
335 | else if (bpp == 2) | ||
336 | stride >>= 2; | ||
337 | else if (bpp == 4) | ||
338 | stride >>= 1; | ||
339 | /* 6 bpp == 8 bpp */ | ||
340 | } | ||
341 | |||
342 | /* if rotated, stride must be power of 2 */ | ||
343 | if (par->rot) { | ||
344 | unsigned long bit = 1 << 31; | ||
345 | while (bit) { | ||
346 | if (stride & bit) | ||
347 | break; | ||
348 | bit >>= 1; | ||
349 | } | ||
350 | if (stride & ~bit) | ||
351 | stride = bit << 1; /* not P-o-2, round up */ | ||
352 | } | ||
353 | iowrite16(stride, par->base + LDLAOR); | ||
354 | |||
355 | /* set display mem start address */ | ||
356 | sbase = (unsigned long)par->fbdma; | ||
357 | if (par->rot) | ||
358 | sbase += (hdcn - 1) * stride; | ||
359 | |||
360 | iowrite32(sbase, par->base + LDSARU); | ||
361 | |||
362 | /* | ||
363 | * for DSTN need to set address for lower half. | ||
364 | * I (mlau) don't know which address to set it to, | ||
365 | * so I guessed at (stride * yres/2). | ||
366 | */ | ||
367 | if (((ldmtr & 0x003f) >= LDMTR_DSTN_MONO_8) && | ||
368 | ((ldmtr & 0x003f) <= LDMTR_DSTN_COLOR_16)) { | ||
369 | |||
370 | dev_dbg(info->dev, " ***** DSTN untested! *****\n"); | ||
371 | |||
372 | dstn_off = stride; | ||
373 | if (par->rot) | ||
374 | dstn_off *= hdcn >> 1; | ||
375 | else | ||
376 | dstn_off *= vdln >> 1; | ||
377 | |||
378 | ldsarl = sbase + dstn_off; | ||
379 | } else | ||
380 | ldsarl = 0; | ||
381 | |||
382 | iowrite32(ldsarl, par->base + LDSARL); /* mem for lower half of DSTN */ | ||
383 | |||
384 | encode_fix(&info->fix, info, stride); | ||
385 | sh7760fb_check_var(&info->var, info); | ||
386 | |||
387 | sh7760fb_blank(FB_BLANK_UNBLANK, info); /* panel on! */ | ||
388 | |||
389 | dev_dbg(info->dev, "hdcn : %6d htcn : %6d\n", hdcn, htcn); | ||
390 | dev_dbg(info->dev, "hsynw : %6d hsynp : %6d\n", hsynw, hsynp); | ||
391 | dev_dbg(info->dev, "vdln : %6d vtln : %6d\n", vdln, vtln); | ||
392 | dev_dbg(info->dev, "vsynw : %6d vsynp : %6d\n", vsynw, vsynp); | ||
393 | dev_dbg(info->dev, "clksrc: %6d clkdiv: %6d\n", | ||
394 | (par->pd->ldickr >> 12) & 3, par->pd->ldickr & 0x1f); | ||
395 | dev_dbg(info->dev, "ldpmmr: 0x%04x ldpspr: 0x%04x\n", par->pd->ldpmmr, | ||
396 | par->pd->ldpspr); | ||
397 | dev_dbg(info->dev, "ldmtr : 0x%04x lddfr : 0x%04x\n", ldmtr, lddfr); | ||
398 | dev_dbg(info->dev, "ldlaor: %ld\n", stride); | ||
399 | dev_dbg(info->dev, "ldsaru: 0x%08lx ldsarl: 0x%08lx\n", sbase, ldsarl); | ||
400 | |||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | static struct fb_ops sh7760fb_ops = { | ||
405 | .owner = THIS_MODULE, | ||
406 | .fb_blank = sh7760fb_blank, | ||
407 | .fb_check_var = sh7760fb_check_var, | ||
408 | .fb_setcmap = sh7760fb_setcmap, | ||
409 | .fb_set_par = sh7760fb_set_par, | ||
410 | .fb_fillrect = cfb_fillrect, | ||
411 | .fb_copyarea = cfb_copyarea, | ||
412 | .fb_imageblit = cfb_imageblit, | ||
413 | }; | ||
414 | |||
415 | static void sh7760fb_free_mem(struct fb_info *info) | ||
416 | { | ||
417 | struct sh7760fb_par *par = info->par; | ||
418 | |||
419 | if (!info->screen_base) | ||
420 | return; | ||
421 | |||
422 | dma_free_coherent(info->dev, info->screen_size, | ||
423 | info->screen_base, par->fbdma); | ||
424 | |||
425 | par->fbdma = 0; | ||
426 | info->screen_base = NULL; | ||
427 | info->screen_size = 0; | ||
428 | } | ||
429 | |||
430 | /* allocate the framebuffer memory. This memory must be in Area3, | ||
431 | * (dictated by the DMA engine) and contiguous, at a 512 byte boundary. | ||
432 | */ | ||
433 | static int sh7760fb_alloc_mem(struct fb_info *info) | ||
434 | { | ||
435 | struct sh7760fb_par *par = info->par; | ||
436 | void *fbmem; | ||
437 | unsigned long vram; | ||
438 | int ret, bpp; | ||
439 | |||
440 | if (info->screen_base) | ||
441 | return 0; | ||
442 | |||
443 | /* get color info from register value */ | ||
444 | ret = sh7760fb_get_color_info(info->dev, par->pd->lddfr, &bpp, NULL); | ||
445 | if (ret) { | ||
446 | printk(KERN_ERR "colinfo\n"); | ||
447 | return ret; | ||
448 | } | ||
449 | |||
450 | /* min VRAM: xres_min = 16, yres_min = 1, bpp = 1: 2byte -> 1 page | ||
451 | max VRAM: xres_max = 1024, yres_max = 1024, bpp = 16: 2MB */ | ||
452 | |||
453 | vram = info->var.xres * info->var.yres; | ||
454 | if (info->var.grayscale) { | ||
455 | if (bpp == 1) | ||
456 | vram >>= 3; | ||
457 | else if (bpp == 2) | ||
458 | vram >>= 2; | ||
459 | else if (bpp == 4) | ||
460 | vram >>= 1; | ||
461 | } else if (bpp > 8) | ||
462 | vram *= 2; | ||
463 | if ((vram < 1) || (vram > 1024 * 2048)) { | ||
464 | dev_dbg(info->dev, "too much VRAM required. Check settings\n"); | ||
465 | return -ENODEV; | ||
466 | } | ||
467 | |||
468 | if (vram < PAGE_SIZE) | ||
469 | vram = PAGE_SIZE; | ||
470 | |||
471 | fbmem = dma_alloc_coherent(info->dev, vram, &par->fbdma, GFP_KERNEL); | ||
472 | |||
473 | if (!fbmem) | ||
474 | return -ENOMEM; | ||
475 | |||
476 | if ((par->fbdma & SH7760FB_DMA_MASK) != SH7760FB_DMA_MASK) { | ||
477 | sh7760fb_free_mem(info); | ||
478 | dev_err(info->dev, "kernel gave me memory at 0x%08lx, which is" | ||
479 | "unusable for the LCDC\n", (unsigned long)par->fbdma); | ||
480 | return -ENOMEM; | ||
481 | } | ||
482 | |||
483 | info->screen_base = fbmem; | ||
484 | info->screen_size = vram; | ||
485 | |||
486 | return 0; | ||
487 | } | ||
488 | |||
489 | static int __devinit sh7760fb_probe(struct platform_device *pdev) | ||
490 | { | ||
491 | struct fb_info *info; | ||
492 | struct resource *res; | ||
493 | struct sh7760fb_par *par; | ||
494 | int ret; | ||
495 | |||
496 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
497 | if (unlikely(res == NULL)) { | ||
498 | dev_err(&pdev->dev, "invalid resource\n"); | ||
499 | return -EINVAL; | ||
500 | } | ||
501 | |||
502 | info = framebuffer_alloc(sizeof(struct sh7760fb_par), &pdev->dev); | ||
503 | if (!info) | ||
504 | return -ENOMEM; | ||
505 | |||
506 | par = info->par; | ||
507 | par->dev = pdev; | ||
508 | |||
509 | par->pd = pdev->dev.platform_data; | ||
510 | if (!par->pd) { | ||
511 | dev_dbg(info->dev, "no display setup data!\n"); | ||
512 | ret = -ENODEV; | ||
513 | goto out_fb; | ||
514 | } | ||
515 | |||
516 | par->ioarea = request_mem_region(res->start, | ||
517 | (res->end - res->start), pdev->name); | ||
518 | if (!par->ioarea) { | ||
519 | dev_err(&pdev->dev, "mmio area busy\n"); | ||
520 | ret = -EBUSY; | ||
521 | goto out_fb; | ||
522 | } | ||
523 | |||
524 | par->base = ioremap_nocache(res->start, res->end - res->start + 1); | ||
525 | if (!par->base) { | ||
526 | dev_err(&pdev->dev, "cannot remap\n"); | ||
527 | ret = -ENODEV; | ||
528 | goto out_res; | ||
529 | } | ||
530 | |||
531 | iowrite16(0, par->base + LDINTR); /* disable vsync irq */ | ||
532 | par->irq = platform_get_irq(pdev, 0); | ||
533 | if (par->irq >= 0) { | ||
534 | ret = request_irq(par->irq, sh7760fb_irq, 0, | ||
535 | "sh7760-lcdc", &par->vsync); | ||
536 | if (ret) { | ||
537 | dev_err(&pdev->dev, "cannot grab IRQ\n"); | ||
538 | par->irq = -ENXIO; | ||
539 | } else | ||
540 | disable_irq_nosync(par->irq); | ||
541 | } | ||
542 | |||
543 | fb_videomode_to_var(&info->var, par->pd->def_mode); | ||
544 | |||
545 | ret = sh7760fb_alloc_mem(info); | ||
546 | if (ret) { | ||
547 | dev_dbg(info->dev, "framebuffer memory allocation failed!\n"); | ||
548 | goto out_unmap; | ||
549 | } | ||
550 | |||
551 | info->pseudo_palette = par->pseudo_palette; | ||
552 | |||
553 | /* fixup color register bitpositions. These are fixed by hardware */ | ||
554 | info->var.red.offset = 11; | ||
555 | info->var.red.length = 5; | ||
556 | info->var.red.msb_right = 0; | ||
557 | |||
558 | info->var.green.offset = 5; | ||
559 | info->var.green.length = 6; | ||
560 | info->var.green.msb_right = 0; | ||
561 | |||
562 | info->var.blue.offset = 0; | ||
563 | info->var.blue.length = 5; | ||
564 | info->var.blue.msb_right = 0; | ||
565 | |||
566 | info->var.transp.offset = 0; | ||
567 | info->var.transp.length = 0; | ||
568 | info->var.transp.msb_right = 0; | ||
569 | |||
570 | /* set the DON2 bit now, before cmap allocation, as it will randomize | ||
571 | * palette memory. | ||
572 | */ | ||
573 | iowrite16(LDCNTR_DON2, par->base + LDCNTR); | ||
574 | info->fbops = &sh7760fb_ops; | ||
575 | |||
576 | ret = fb_alloc_cmap(&info->cmap, 256, 0); | ||
577 | if (ret) { | ||
578 | dev_dbg(info->dev, "Unable to allocate cmap memory\n"); | ||
579 | goto out_mem; | ||
580 | } | ||
581 | |||
582 | ret = register_framebuffer(info); | ||
583 | if (ret < 0) { | ||
584 | dev_dbg(info->dev, "cannot register fb!\n"); | ||
585 | goto out_cmap; | ||
586 | } | ||
587 | platform_set_drvdata(pdev, info); | ||
588 | |||
589 | printk(KERN_INFO "%s: memory at phys 0x%08lx-0x%08lx, size %ld KiB\n", | ||
590 | pdev->name, | ||
591 | (unsigned long)par->fbdma, | ||
592 | (unsigned long)(par->fbdma + info->screen_size - 1), | ||
593 | info->screen_size >> 10); | ||
594 | |||
595 | return 0; | ||
596 | |||
597 | out_cmap: | ||
598 | sh7760fb_blank(FB_BLANK_POWERDOWN, info); | ||
599 | fb_dealloc_cmap(&info->cmap); | ||
600 | out_mem: | ||
601 | sh7760fb_free_mem(info); | ||
602 | out_unmap: | ||
603 | if (par->irq >= 0) | ||
604 | free_irq(par->irq, &par->vsync); | ||
605 | iounmap(par->base); | ||
606 | out_res: | ||
607 | release_resource(par->ioarea); | ||
608 | kfree(par->ioarea); | ||
609 | out_fb: | ||
610 | framebuffer_release(info); | ||
611 | return ret; | ||
612 | } | ||
613 | |||
614 | static int __devexit sh7760fb_remove(struct platform_device *dev) | ||
615 | { | ||
616 | struct fb_info *info = platform_get_drvdata(dev); | ||
617 | struct sh7760fb_par *par = info->par; | ||
618 | |||
619 | sh7760fb_blank(FB_BLANK_POWERDOWN, info); | ||
620 | unregister_framebuffer(info); | ||
621 | fb_dealloc_cmap(&info->cmap); | ||
622 | sh7760fb_free_mem(info); | ||
623 | if (par->irq >= 0) | ||
624 | free_irq(par->irq, par); | ||
625 | iounmap(par->base); | ||
626 | release_resource(par->ioarea); | ||
627 | kfree(par->ioarea); | ||
628 | framebuffer_release(info); | ||
629 | platform_set_drvdata(dev, NULL); | ||
630 | |||
631 | return 0; | ||
632 | } | ||
633 | |||
634 | static struct platform_driver sh7760_lcdc_driver = { | ||
635 | .driver = { | ||
636 | .name = "sh7760-lcdc", | ||
637 | .owner = THIS_MODULE, | ||
638 | }, | ||
639 | .probe = sh7760fb_probe, | ||
640 | .remove = __devexit_p(sh7760fb_remove), | ||
641 | }; | ||
642 | |||
643 | static int __init sh7760fb_init(void) | ||
644 | { | ||
645 | return platform_driver_register(&sh7760_lcdc_driver); | ||
646 | } | ||
647 | |||
648 | static void __exit sh7760fb_exit(void) | ||
649 | { | ||
650 | platform_driver_unregister(&sh7760_lcdc_driver); | ||
651 | } | ||
652 | |||
653 | module_init(sh7760fb_init); | ||
654 | module_exit(sh7760fb_exit); | ||
655 | |||
656 | MODULE_AUTHOR("Nobuhiro Iwamatsu, Manuel Lauss"); | ||
657 | MODULE_DESCRIPTION("FBdev for SH7760/63 integrated LCD Controller"); | ||
658 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c new file mode 100644 index 000000000000..f6ef6cca73cd --- /dev/null +++ b/drivers/video/sh_mobile_lcdcfb.c | |||
@@ -0,0 +1,725 @@ | |||
1 | /* | ||
2 | * SuperH Mobile LCDC Framebuffer | ||
3 | * | ||
4 | * Copyright (c) 2008 Magnus Damm | ||
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 | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/delay.h> | ||
14 | #include <linux/mm.h> | ||
15 | #include <linux/fb.h> | ||
16 | #include <linux/clk.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/dma-mapping.h> | ||
19 | #include <asm/sh_mobile_lcdc.h> | ||
20 | |||
21 | #define PALETTE_NR 16 | ||
22 | |||
23 | struct sh_mobile_lcdc_priv; | ||
24 | struct sh_mobile_lcdc_chan { | ||
25 | struct sh_mobile_lcdc_priv *lcdc; | ||
26 | unsigned long *reg_offs; | ||
27 | unsigned long ldmt1r_value; | ||
28 | unsigned long enabled; /* ME and SE in LDCNT2R */ | ||
29 | struct sh_mobile_lcdc_chan_cfg cfg; | ||
30 | u32 pseudo_palette[PALETTE_NR]; | ||
31 | struct fb_info info; | ||
32 | dma_addr_t dma_handle; | ||
33 | }; | ||
34 | |||
35 | struct sh_mobile_lcdc_priv { | ||
36 | void __iomem *base; | ||
37 | struct clk *clk; | ||
38 | unsigned long lddckr; | ||
39 | struct sh_mobile_lcdc_chan ch[2]; | ||
40 | }; | ||
41 | |||
42 | /* shared registers */ | ||
43 | #define _LDDCKR 0x410 | ||
44 | #define _LDDCKSTPR 0x414 | ||
45 | #define _LDINTR 0x468 | ||
46 | #define _LDSR 0x46c | ||
47 | #define _LDCNT1R 0x470 | ||
48 | #define _LDCNT2R 0x474 | ||
49 | #define _LDDDSR 0x47c | ||
50 | #define _LDDWD0R 0x800 | ||
51 | #define _LDDRDR 0x840 | ||
52 | #define _LDDWAR 0x900 | ||
53 | #define _LDDRAR 0x904 | ||
54 | |||
55 | /* per-channel registers */ | ||
56 | enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R, | ||
57 | LDSA1R, LDMLSR, LDHCNR, LDHSYNR, LDVLNR, LDVSYNR, LDPMR }; | ||
58 | |||
59 | static unsigned long lcdc_offs_mainlcd[] = { | ||
60 | [LDDCKPAT1R] = 0x400, | ||
61 | [LDDCKPAT2R] = 0x404, | ||
62 | [LDMT1R] = 0x418, | ||
63 | [LDMT2R] = 0x41c, | ||
64 | [LDMT3R] = 0x420, | ||
65 | [LDDFR] = 0x424, | ||
66 | [LDSM1R] = 0x428, | ||
67 | [LDSA1R] = 0x430, | ||
68 | [LDMLSR] = 0x438, | ||
69 | [LDHCNR] = 0x448, | ||
70 | [LDHSYNR] = 0x44c, | ||
71 | [LDVLNR] = 0x450, | ||
72 | [LDVSYNR] = 0x454, | ||
73 | [LDPMR] = 0x460, | ||
74 | }; | ||
75 | |||
76 | static unsigned long lcdc_offs_sublcd[] = { | ||
77 | [LDDCKPAT1R] = 0x408, | ||
78 | [LDDCKPAT2R] = 0x40c, | ||
79 | [LDMT1R] = 0x600, | ||
80 | [LDMT2R] = 0x604, | ||
81 | [LDMT3R] = 0x608, | ||
82 | [LDDFR] = 0x60c, | ||
83 | [LDSM1R] = 0x610, | ||
84 | [LDSA1R] = 0x618, | ||
85 | [LDMLSR] = 0x620, | ||
86 | [LDHCNR] = 0x624, | ||
87 | [LDHSYNR] = 0x628, | ||
88 | [LDVLNR] = 0x62c, | ||
89 | [LDVSYNR] = 0x630, | ||
90 | [LDPMR] = 0x63c, | ||
91 | }; | ||
92 | |||
93 | #define START_LCDC 0x00000001 | ||
94 | #define LCDC_RESET 0x00000100 | ||
95 | #define DISPLAY_BEU 0x00000008 | ||
96 | #define LCDC_ENABLE 0x00000001 | ||
97 | |||
98 | static void lcdc_write_chan(struct sh_mobile_lcdc_chan *chan, | ||
99 | int reg_nr, unsigned long data) | ||
100 | { | ||
101 | iowrite32(data, chan->lcdc->base + chan->reg_offs[reg_nr]); | ||
102 | } | ||
103 | |||
104 | static unsigned long lcdc_read_chan(struct sh_mobile_lcdc_chan *chan, | ||
105 | int reg_nr) | ||
106 | { | ||
107 | return ioread32(chan->lcdc->base + chan->reg_offs[reg_nr]); | ||
108 | } | ||
109 | |||
110 | static void lcdc_write(struct sh_mobile_lcdc_priv *priv, | ||
111 | unsigned long reg_offs, unsigned long data) | ||
112 | { | ||
113 | iowrite32(data, priv->base + reg_offs); | ||
114 | } | ||
115 | |||
116 | static unsigned long lcdc_read(struct sh_mobile_lcdc_priv *priv, | ||
117 | unsigned long reg_offs) | ||
118 | { | ||
119 | return ioread32(priv->base + reg_offs); | ||
120 | } | ||
121 | |||
122 | static void lcdc_wait_bit(struct sh_mobile_lcdc_priv *priv, | ||
123 | unsigned long reg_offs, | ||
124 | unsigned long mask, unsigned long until) | ||
125 | { | ||
126 | while ((lcdc_read(priv, reg_offs) & mask) != until) | ||
127 | cpu_relax(); | ||
128 | } | ||
129 | |||
130 | static int lcdc_chan_is_sublcd(struct sh_mobile_lcdc_chan *chan) | ||
131 | { | ||
132 | return chan->cfg.chan == LCDC_CHAN_SUBLCD; | ||
133 | } | ||
134 | |||
135 | static void lcdc_sys_write_index(void *handle, unsigned long data) | ||
136 | { | ||
137 | struct sh_mobile_lcdc_chan *ch = handle; | ||
138 | |||
139 | lcdc_write(ch->lcdc, _LDDWD0R, data | 0x10000000); | ||
140 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | ||
141 | lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); | ||
142 | } | ||
143 | |||
144 | static void lcdc_sys_write_data(void *handle, unsigned long data) | ||
145 | { | ||
146 | struct sh_mobile_lcdc_chan *ch = handle; | ||
147 | |||
148 | lcdc_write(ch->lcdc, _LDDWD0R, data | 0x11000000); | ||
149 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | ||
150 | lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); | ||
151 | } | ||
152 | |||
153 | static unsigned long lcdc_sys_read_data(void *handle) | ||
154 | { | ||
155 | struct sh_mobile_lcdc_chan *ch = handle; | ||
156 | |||
157 | lcdc_write(ch->lcdc, _LDDRDR, 0x01000000); | ||
158 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | ||
159 | lcdc_write(ch->lcdc, _LDDRAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); | ||
160 | udelay(1); | ||
161 | |||
162 | return lcdc_read(ch->lcdc, _LDDRDR) & 0xffff; | ||
163 | } | ||
164 | |||
165 | struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = { | ||
166 | lcdc_sys_write_index, | ||
167 | lcdc_sys_write_data, | ||
168 | lcdc_sys_read_data, | ||
169 | }; | ||
170 | |||
171 | static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv, | ||
172 | int start) | ||
173 | { | ||
174 | unsigned long tmp = lcdc_read(priv, _LDCNT2R); | ||
175 | int k; | ||
176 | |||
177 | /* start or stop the lcdc */ | ||
178 | if (start) | ||
179 | lcdc_write(priv, _LDCNT2R, tmp | START_LCDC); | ||
180 | else | ||
181 | lcdc_write(priv, _LDCNT2R, tmp & ~START_LCDC); | ||
182 | |||
183 | /* wait until power is applied/stopped on all channels */ | ||
184 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) | ||
185 | if (lcdc_read(priv, _LDCNT2R) & priv->ch[k].enabled) | ||
186 | while (1) { | ||
187 | tmp = lcdc_read_chan(&priv->ch[k], LDPMR) & 3; | ||
188 | if (start && tmp == 3) | ||
189 | break; | ||
190 | if (!start && tmp == 0) | ||
191 | break; | ||
192 | cpu_relax(); | ||
193 | } | ||
194 | |||
195 | if (!start) | ||
196 | lcdc_write(priv, _LDDCKSTPR, 1); /* stop dotclock */ | ||
197 | } | ||
198 | |||
199 | static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) | ||
200 | { | ||
201 | struct sh_mobile_lcdc_chan *ch; | ||
202 | struct fb_videomode *lcd_cfg; | ||
203 | struct sh_mobile_lcdc_board_cfg *board_cfg; | ||
204 | unsigned long tmp; | ||
205 | int k, m; | ||
206 | int ret = 0; | ||
207 | |||
208 | /* reset */ | ||
209 | lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) | LCDC_RESET); | ||
210 | lcdc_wait_bit(priv, _LDCNT2R, LCDC_RESET, 0); | ||
211 | |||
212 | /* enable LCDC channels */ | ||
213 | tmp = lcdc_read(priv, _LDCNT2R); | ||
214 | tmp |= priv->ch[0].enabled; | ||
215 | tmp |= priv->ch[1].enabled; | ||
216 | lcdc_write(priv, _LDCNT2R, tmp); | ||
217 | |||
218 | /* read data from external memory, avoid using the BEU for now */ | ||
219 | lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) & ~DISPLAY_BEU); | ||
220 | |||
221 | /* stop the lcdc first */ | ||
222 | sh_mobile_lcdc_start_stop(priv, 0); | ||
223 | |||
224 | /* configure clocks */ | ||
225 | tmp = priv->lddckr; | ||
226 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { | ||
227 | ch = &priv->ch[k]; | ||
228 | |||
229 | if (!priv->ch[k].enabled) | ||
230 | continue; | ||
231 | |||
232 | m = ch->cfg.clock_divider; | ||
233 | if (!m) | ||
234 | continue; | ||
235 | |||
236 | if (m == 1) | ||
237 | m = 1 << 6; | ||
238 | tmp |= m << (lcdc_chan_is_sublcd(ch) ? 8 : 0); | ||
239 | |||
240 | lcdc_write_chan(ch, LDDCKPAT1R, 0x00000000); | ||
241 | lcdc_write_chan(ch, LDDCKPAT2R, (1 << (m/2)) - 1); | ||
242 | } | ||
243 | |||
244 | lcdc_write(priv, _LDDCKR, tmp); | ||
245 | |||
246 | /* start dotclock again */ | ||
247 | lcdc_write(priv, _LDDCKSTPR, 0); | ||
248 | lcdc_wait_bit(priv, _LDDCKSTPR, ~0, 0); | ||
249 | |||
250 | /* interrupts are disabled */ | ||
251 | lcdc_write(priv, _LDINTR, 0); | ||
252 | |||
253 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { | ||
254 | ch = &priv->ch[k]; | ||
255 | lcd_cfg = &ch->cfg.lcd_cfg; | ||
256 | |||
257 | if (!ch->enabled) | ||
258 | continue; | ||
259 | |||
260 | tmp = ch->ldmt1r_value; | ||
261 | tmp |= (lcd_cfg->sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : 1 << 28; | ||
262 | tmp |= (lcd_cfg->sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : 1 << 27; | ||
263 | lcdc_write_chan(ch, LDMT1R, tmp); | ||
264 | |||
265 | /* setup SYS bus */ | ||
266 | lcdc_write_chan(ch, LDMT2R, ch->cfg.sys_bus_cfg.ldmt2r); | ||
267 | lcdc_write_chan(ch, LDMT3R, ch->cfg.sys_bus_cfg.ldmt3r); | ||
268 | |||
269 | /* horizontal configuration */ | ||
270 | tmp = lcd_cfg->xres + lcd_cfg->hsync_len; | ||
271 | tmp += lcd_cfg->left_margin; | ||
272 | tmp += lcd_cfg->right_margin; | ||
273 | tmp /= 8; /* HTCN */ | ||
274 | tmp |= (lcd_cfg->xres / 8) << 16; /* HDCN */ | ||
275 | lcdc_write_chan(ch, LDHCNR, tmp); | ||
276 | |||
277 | tmp = lcd_cfg->xres; | ||
278 | tmp += lcd_cfg->right_margin; | ||
279 | tmp /= 8; /* HSYNP */ | ||
280 | tmp |= (lcd_cfg->hsync_len / 8) << 16; /* HSYNW */ | ||
281 | lcdc_write_chan(ch, LDHSYNR, tmp); | ||
282 | |||
283 | /* power supply */ | ||
284 | lcdc_write_chan(ch, LDPMR, 0); | ||
285 | |||
286 | /* vertical configuration */ | ||
287 | tmp = lcd_cfg->yres + lcd_cfg->vsync_len; | ||
288 | tmp += lcd_cfg->upper_margin; | ||
289 | tmp += lcd_cfg->lower_margin; /* VTLN */ | ||
290 | tmp |= lcd_cfg->yres << 16; /* VDLN */ | ||
291 | lcdc_write_chan(ch, LDVLNR, tmp); | ||
292 | |||
293 | tmp = lcd_cfg->yres; | ||
294 | tmp += lcd_cfg->lower_margin; /* VSYNP */ | ||
295 | tmp |= lcd_cfg->vsync_len << 16; /* VSYNW */ | ||
296 | lcdc_write_chan(ch, LDVSYNR, tmp); | ||
297 | |||
298 | board_cfg = &ch->cfg.board_cfg; | ||
299 | if (board_cfg->setup_sys) | ||
300 | ret = board_cfg->setup_sys(board_cfg->board_data, ch, | ||
301 | &sh_mobile_lcdc_sys_bus_ops); | ||
302 | if (ret) | ||
303 | return ret; | ||
304 | } | ||
305 | |||
306 | /* --- display_lcdc_data() --- */ | ||
307 | lcdc_write(priv, _LDINTR, 0x00000f00); | ||
308 | |||
309 | /* word and long word swap */ | ||
310 | lcdc_write(priv, _LDDDSR, lcdc_read(priv, _LDDDSR) | 6); | ||
311 | |||
312 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { | ||
313 | ch = &priv->ch[k]; | ||
314 | |||
315 | if (!priv->ch[k].enabled) | ||
316 | continue; | ||
317 | |||
318 | /* set bpp format in PKF[4:0] */ | ||
319 | tmp = lcdc_read_chan(ch, LDDFR); | ||
320 | tmp &= ~(0x0001001f); | ||
321 | tmp |= (priv->ch[k].info.var.bits_per_pixel == 16) ? 3 : 0; | ||
322 | lcdc_write_chan(ch, LDDFR, tmp); | ||
323 | |||
324 | /* point out our frame buffer */ | ||
325 | lcdc_write_chan(ch, LDSA1R, ch->info.fix.smem_start); | ||
326 | |||
327 | /* set line size */ | ||
328 | lcdc_write_chan(ch, LDMLSR, ch->info.fix.line_length); | ||
329 | |||
330 | /* continuous read mode */ | ||
331 | lcdc_write_chan(ch, LDSM1R, 0); | ||
332 | } | ||
333 | |||
334 | /* display output */ | ||
335 | lcdc_write(priv, _LDCNT1R, LCDC_ENABLE); | ||
336 | |||
337 | /* start the lcdc */ | ||
338 | sh_mobile_lcdc_start_stop(priv, 1); | ||
339 | |||
340 | /* tell the board code to enable the panel */ | ||
341 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { | ||
342 | ch = &priv->ch[k]; | ||
343 | board_cfg = &ch->cfg.board_cfg; | ||
344 | if (board_cfg->display_on) | ||
345 | board_cfg->display_on(board_cfg->board_data); | ||
346 | } | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
351 | static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv) | ||
352 | { | ||
353 | struct sh_mobile_lcdc_chan *ch; | ||
354 | struct sh_mobile_lcdc_board_cfg *board_cfg; | ||
355 | int k; | ||
356 | |||
357 | /* tell the board code to disable the panel */ | ||
358 | for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { | ||
359 | ch = &priv->ch[k]; | ||
360 | board_cfg = &ch->cfg.board_cfg; | ||
361 | if (board_cfg->display_off) | ||
362 | board_cfg->display_off(board_cfg->board_data); | ||
363 | } | ||
364 | |||
365 | /* stop the lcdc */ | ||
366 | sh_mobile_lcdc_start_stop(priv, 0); | ||
367 | } | ||
368 | |||
369 | static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch) | ||
370 | { | ||
371 | int ifm, miftyp; | ||
372 | |||
373 | switch (ch->cfg.interface_type) { | ||
374 | case RGB8: ifm = 0; miftyp = 0; break; | ||
375 | case RGB9: ifm = 0; miftyp = 4; break; | ||
376 | case RGB12A: ifm = 0; miftyp = 5; break; | ||
377 | case RGB12B: ifm = 0; miftyp = 6; break; | ||
378 | case RGB16: ifm = 0; miftyp = 7; break; | ||
379 | case RGB18: ifm = 0; miftyp = 10; break; | ||
380 | case RGB24: ifm = 0; miftyp = 11; break; | ||
381 | case SYS8A: ifm = 1; miftyp = 0; break; | ||
382 | case SYS8B: ifm = 1; miftyp = 1; break; | ||
383 | case SYS8C: ifm = 1; miftyp = 2; break; | ||
384 | case SYS8D: ifm = 1; miftyp = 3; break; | ||
385 | case SYS9: ifm = 1; miftyp = 4; break; | ||
386 | case SYS12: ifm = 1; miftyp = 5; break; | ||
387 | case SYS16A: ifm = 1; miftyp = 7; break; | ||
388 | case SYS16B: ifm = 1; miftyp = 8; break; | ||
389 | case SYS16C: ifm = 1; miftyp = 9; break; | ||
390 | case SYS18: ifm = 1; miftyp = 10; break; | ||
391 | case SYS24: ifm = 1; miftyp = 11; break; | ||
392 | default: goto bad; | ||
393 | } | ||
394 | |||
395 | /* SUBLCD only supports SYS interface */ | ||
396 | if (lcdc_chan_is_sublcd(ch)) { | ||
397 | if (ifm == 0) | ||
398 | goto bad; | ||
399 | else | ||
400 | ifm = 0; | ||
401 | } | ||
402 | |||
403 | ch->ldmt1r_value = (ifm << 12) | miftyp; | ||
404 | return 0; | ||
405 | bad: | ||
406 | return -EINVAL; | ||
407 | } | ||
408 | |||
409 | static int sh_mobile_lcdc_setup_clocks(struct device *dev, int clock_source, | ||
410 | struct sh_mobile_lcdc_priv *priv) | ||
411 | { | ||
412 | char *str; | ||
413 | int icksel; | ||
414 | |||
415 | switch (clock_source) { | ||
416 | case LCDC_CLK_BUS: str = "bus_clk"; icksel = 0; break; | ||
417 | case LCDC_CLK_PERIPHERAL: str = "peripheral_clk"; icksel = 1; break; | ||
418 | case LCDC_CLK_EXTERNAL: str = NULL; icksel = 2; break; | ||
419 | default: | ||
420 | return -EINVAL; | ||
421 | } | ||
422 | |||
423 | priv->lddckr = icksel << 16; | ||
424 | |||
425 | if (str) { | ||
426 | priv->clk = clk_get(dev, str); | ||
427 | if (IS_ERR(priv->clk)) { | ||
428 | dev_err(dev, "cannot get clock %s\n", str); | ||
429 | return PTR_ERR(priv->clk); | ||
430 | } | ||
431 | |||
432 | clk_enable(priv->clk); | ||
433 | } | ||
434 | |||
435 | return 0; | ||
436 | } | ||
437 | |||
438 | static int sh_mobile_lcdc_setcolreg(u_int regno, | ||
439 | u_int red, u_int green, u_int blue, | ||
440 | u_int transp, struct fb_info *info) | ||
441 | { | ||
442 | u32 *palette = info->pseudo_palette; | ||
443 | |||
444 | if (regno >= PALETTE_NR) | ||
445 | return -EINVAL; | ||
446 | |||
447 | /* only FB_VISUAL_TRUECOLOR supported */ | ||
448 | |||
449 | red >>= 16 - info->var.red.length; | ||
450 | green >>= 16 - info->var.green.length; | ||
451 | blue >>= 16 - info->var.blue.length; | ||
452 | transp >>= 16 - info->var.transp.length; | ||
453 | |||
454 | palette[regno] = (red << info->var.red.offset) | | ||
455 | (green << info->var.green.offset) | | ||
456 | (blue << info->var.blue.offset) | | ||
457 | (transp << info->var.transp.offset); | ||
458 | |||
459 | return 0; | ||
460 | } | ||
461 | |||
462 | static struct fb_fix_screeninfo sh_mobile_lcdc_fix = { | ||
463 | .id = "SH Mobile LCDC", | ||
464 | .type = FB_TYPE_PACKED_PIXELS, | ||
465 | .visual = FB_VISUAL_TRUECOLOR, | ||
466 | .accel = FB_ACCEL_NONE, | ||
467 | }; | ||
468 | |||
469 | static struct fb_ops sh_mobile_lcdc_ops = { | ||
470 | .fb_setcolreg = sh_mobile_lcdc_setcolreg, | ||
471 | .fb_fillrect = cfb_fillrect, | ||
472 | .fb_copyarea = cfb_copyarea, | ||
473 | .fb_imageblit = cfb_imageblit, | ||
474 | }; | ||
475 | |||
476 | static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp) | ||
477 | { | ||
478 | switch (bpp) { | ||
479 | case 16: /* PKF[4:0] = 00011 - RGB 565 */ | ||
480 | var->red.offset = 11; | ||
481 | var->red.length = 5; | ||
482 | var->green.offset = 5; | ||
483 | var->green.length = 6; | ||
484 | var->blue.offset = 0; | ||
485 | var->blue.length = 5; | ||
486 | var->transp.offset = 0; | ||
487 | var->transp.length = 0; | ||
488 | break; | ||
489 | |||
490 | case 32: /* PKF[4:0] = 00000 - RGB 888 | ||
491 | * sh7722 pdf says 00RRGGBB but reality is GGBB00RR | ||
492 | * this may be because LDDDSR has word swap enabled.. | ||
493 | */ | ||
494 | var->red.offset = 0; | ||
495 | var->red.length = 8; | ||
496 | var->green.offset = 24; | ||
497 | var->green.length = 8; | ||
498 | var->blue.offset = 16; | ||
499 | var->blue.length = 8; | ||
500 | var->transp.offset = 0; | ||
501 | var->transp.length = 0; | ||
502 | break; | ||
503 | default: | ||
504 | return -EINVAL; | ||
505 | } | ||
506 | var->bits_per_pixel = bpp; | ||
507 | var->red.msb_right = 0; | ||
508 | var->green.msb_right = 0; | ||
509 | var->blue.msb_right = 0; | ||
510 | var->transp.msb_right = 0; | ||
511 | return 0; | ||
512 | } | ||
513 | |||
514 | static int sh_mobile_lcdc_remove(struct platform_device *pdev); | ||
515 | |||
516 | static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) | ||
517 | { | ||
518 | struct fb_info *info; | ||
519 | struct sh_mobile_lcdc_priv *priv; | ||
520 | struct sh_mobile_lcdc_info *pdata; | ||
521 | struct sh_mobile_lcdc_chan_cfg *cfg; | ||
522 | struct resource *res; | ||
523 | int error; | ||
524 | void *buf; | ||
525 | int i, j; | ||
526 | |||
527 | if (!pdev->dev.platform_data) { | ||
528 | dev_err(&pdev->dev, "no platform data defined\n"); | ||
529 | error = -EINVAL; | ||
530 | goto err0; | ||
531 | } | ||
532 | |||
533 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
534 | if (res == NULL) { | ||
535 | dev_err(&pdev->dev, "cannot find IO resource\n"); | ||
536 | error = -ENOENT; | ||
537 | goto err0; | ||
538 | } | ||
539 | |||
540 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
541 | if (!priv) { | ||
542 | dev_err(&pdev->dev, "cannot allocate device data\n"); | ||
543 | error = -ENOMEM; | ||
544 | goto err0; | ||
545 | } | ||
546 | |||
547 | platform_set_drvdata(pdev, priv); | ||
548 | pdata = pdev->dev.platform_data; | ||
549 | |||
550 | j = 0; | ||
551 | for (i = 0; i < ARRAY_SIZE(pdata->ch); i++) { | ||
552 | priv->ch[j].lcdc = priv; | ||
553 | memcpy(&priv->ch[j].cfg, &pdata->ch[i], sizeof(pdata->ch[i])); | ||
554 | |||
555 | error = sh_mobile_lcdc_check_interface(&priv->ch[i]); | ||
556 | if (error) { | ||
557 | dev_err(&pdev->dev, "unsupported interface type\n"); | ||
558 | goto err1; | ||
559 | } | ||
560 | |||
561 | switch (pdata->ch[i].chan) { | ||
562 | case LCDC_CHAN_MAINLCD: | ||
563 | priv->ch[j].enabled = 1 << 1; | ||
564 | priv->ch[j].reg_offs = lcdc_offs_mainlcd; | ||
565 | j++; | ||
566 | break; | ||
567 | case LCDC_CHAN_SUBLCD: | ||
568 | priv->ch[j].enabled = 1 << 2; | ||
569 | priv->ch[j].reg_offs = lcdc_offs_sublcd; | ||
570 | j++; | ||
571 | break; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | if (!j) { | ||
576 | dev_err(&pdev->dev, "no channels defined\n"); | ||
577 | error = -EINVAL; | ||
578 | goto err1; | ||
579 | } | ||
580 | |||
581 | error = sh_mobile_lcdc_setup_clocks(&pdev->dev, | ||
582 | pdata->clock_source, priv); | ||
583 | if (error) { | ||
584 | dev_err(&pdev->dev, "unable to setup clocks\n"); | ||
585 | goto err1; | ||
586 | } | ||
587 | |||
588 | priv->lddckr = pdata->lddckr; | ||
589 | priv->base = ioremap_nocache(res->start, (res->end - res->start) + 1); | ||
590 | |||
591 | for (i = 0; i < j; i++) { | ||
592 | info = &priv->ch[i].info; | ||
593 | cfg = &priv->ch[i].cfg; | ||
594 | |||
595 | info->fbops = &sh_mobile_lcdc_ops; | ||
596 | info->var.xres = info->var.xres_virtual = cfg->lcd_cfg.xres; | ||
597 | info->var.yres = info->var.yres_virtual = cfg->lcd_cfg.yres; | ||
598 | info->var.activate = FB_ACTIVATE_NOW; | ||
599 | error = sh_mobile_lcdc_set_bpp(&info->var, cfg->bpp); | ||
600 | if (error) | ||
601 | break; | ||
602 | |||
603 | info->fix = sh_mobile_lcdc_fix; | ||
604 | info->fix.line_length = cfg->lcd_cfg.xres * (cfg->bpp / 8); | ||
605 | info->fix.smem_len = info->fix.line_length * cfg->lcd_cfg.yres; | ||
606 | |||
607 | buf = dma_alloc_coherent(&pdev->dev, info->fix.smem_len, | ||
608 | &priv->ch[i].dma_handle, GFP_KERNEL); | ||
609 | if (!buf) { | ||
610 | dev_err(&pdev->dev, "unable to allocate buffer\n"); | ||
611 | error = -ENOMEM; | ||
612 | break; | ||
613 | } | ||
614 | |||
615 | info->pseudo_palette = &priv->ch[i].pseudo_palette; | ||
616 | info->flags = FBINFO_FLAG_DEFAULT; | ||
617 | |||
618 | error = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0); | ||
619 | if (error < 0) { | ||
620 | dev_err(&pdev->dev, "unable to allocate cmap\n"); | ||
621 | dma_free_coherent(&pdev->dev, info->fix.smem_len, | ||
622 | buf, priv->ch[i].dma_handle); | ||
623 | break; | ||
624 | } | ||
625 | |||
626 | memset(buf, 0, info->fix.smem_len); | ||
627 | info->fix.smem_start = priv->ch[i].dma_handle; | ||
628 | info->screen_base = buf; | ||
629 | info->device = &pdev->dev; | ||
630 | } | ||
631 | |||
632 | if (error) | ||
633 | goto err1; | ||
634 | |||
635 | error = sh_mobile_lcdc_start(priv); | ||
636 | if (error) { | ||
637 | dev_err(&pdev->dev, "unable to start hardware\n"); | ||
638 | goto err1; | ||
639 | } | ||
640 | |||
641 | for (i = 0; i < j; i++) { | ||
642 | error = register_framebuffer(&priv->ch[i].info); | ||
643 | if (error < 0) | ||
644 | goto err1; | ||
645 | } | ||
646 | |||
647 | for (i = 0; i < j; i++) { | ||
648 | info = &priv->ch[i].info; | ||
649 | dev_info(info->dev, | ||
650 | "registered %s/%s as %dx%d %dbpp.\n", | ||
651 | pdev->name, | ||
652 | (priv->ch[i].cfg.chan == LCDC_CHAN_MAINLCD) ? | ||
653 | "mainlcd" : "sublcd", | ||
654 | (int) priv->ch[i].cfg.lcd_cfg.xres, | ||
655 | (int) priv->ch[i].cfg.lcd_cfg.yres, | ||
656 | priv->ch[i].cfg.bpp); | ||
657 | } | ||
658 | |||
659 | return 0; | ||
660 | err1: | ||
661 | sh_mobile_lcdc_remove(pdev); | ||
662 | err0: | ||
663 | return error; | ||
664 | } | ||
665 | |||
666 | static int sh_mobile_lcdc_remove(struct platform_device *pdev) | ||
667 | { | ||
668 | struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev); | ||
669 | struct fb_info *info; | ||
670 | int i; | ||
671 | |||
672 | for (i = 0; i < ARRAY_SIZE(priv->ch); i++) | ||
673 | if (priv->ch[i].info.dev) | ||
674 | unregister_framebuffer(&priv->ch[i].info); | ||
675 | |||
676 | sh_mobile_lcdc_stop(priv); | ||
677 | |||
678 | for (i = 0; i < ARRAY_SIZE(priv->ch); i++) { | ||
679 | info = &priv->ch[i].info; | ||
680 | |||
681 | if (!info->device) | ||
682 | continue; | ||
683 | |||
684 | dma_free_coherent(&pdev->dev, info->fix.smem_len, | ||
685 | info->screen_base, priv->ch[i].dma_handle); | ||
686 | fb_dealloc_cmap(&info->cmap); | ||
687 | } | ||
688 | |||
689 | if (priv->clk) { | ||
690 | clk_disable(priv->clk); | ||
691 | clk_put(priv->clk); | ||
692 | } | ||
693 | |||
694 | if (priv->base) | ||
695 | iounmap(priv->base); | ||
696 | |||
697 | kfree(priv); | ||
698 | return 0; | ||
699 | } | ||
700 | |||
701 | static struct platform_driver sh_mobile_lcdc_driver = { | ||
702 | .driver = { | ||
703 | .name = "sh_mobile_lcdc_fb", | ||
704 | .owner = THIS_MODULE, | ||
705 | }, | ||
706 | .probe = sh_mobile_lcdc_probe, | ||
707 | .remove = sh_mobile_lcdc_remove, | ||
708 | }; | ||
709 | |||
710 | static int __init sh_mobile_lcdc_init(void) | ||
711 | { | ||
712 | return platform_driver_register(&sh_mobile_lcdc_driver); | ||
713 | } | ||
714 | |||
715 | static void __exit sh_mobile_lcdc_exit(void) | ||
716 | { | ||
717 | platform_driver_unregister(&sh_mobile_lcdc_driver); | ||
718 | } | ||
719 | |||
720 | module_init(sh_mobile_lcdc_init); | ||
721 | module_exit(sh_mobile_lcdc_exit); | ||
722 | |||
723 | MODULE_DESCRIPTION("SuperH Mobile LCDC Framebuffer driver"); | ||
724 | MODULE_AUTHOR("Magnus Damm <damm@opensource.se>"); | ||
725 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/video/sis/init.h b/drivers/video/sis/init.h index f40a680df86f..b96005c39c67 100644 --- a/drivers/video/sis/init.h +++ b/drivers/video/sis/init.h | |||
@@ -73,7 +73,6 @@ | |||
73 | #ifdef SIS_CP | 73 | #ifdef SIS_CP |
74 | #undef SIS_CP | 74 | #undef SIS_CP |
75 | #endif | 75 | #endif |
76 | #include <linux/version.h> | ||
77 | #include <linux/types.h> | 76 | #include <linux/types.h> |
78 | #include <asm/io.h> | 77 | #include <asm/io.h> |
79 | #include <linux/fb.h> | 78 | #include <linux/fb.h> |
diff --git a/drivers/video/sis/init301.h b/drivers/video/sis/init301.h index 7708e1e1d99e..51d99222375d 100644 --- a/drivers/video/sis/init301.h +++ b/drivers/video/sis/init301.h | |||
@@ -67,7 +67,6 @@ | |||
67 | #ifdef SIS_CP | 67 | #ifdef SIS_CP |
68 | #undef SIS_CP | 68 | #undef SIS_CP |
69 | #endif | 69 | #endif |
70 | #include <linux/version.h> | ||
71 | #include <linux/types.h> | 70 | #include <linux/types.h> |
72 | #include <asm/io.h> | 71 | #include <asm/io.h> |
73 | #include <linux/fb.h> | 72 | #include <linux/fb.h> |
diff --git a/drivers/video/sis/initextlfb.c b/drivers/video/sis/initextlfb.c index 47a33501549d..99c04a4855d1 100644 --- a/drivers/video/sis/initextlfb.c +++ b/drivers/video/sis/initextlfb.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include "vgatypes.h" | 30 | #include "vgatypes.h" |
31 | #include "vstruct.h" | 31 | #include "vstruct.h" |
32 | 32 | ||
33 | #include <linux/version.h> | ||
34 | #include <linux/types.h> | 33 | #include <linux/types.h> |
35 | #include <linux/fb.h> | 34 | #include <linux/fb.h> |
36 | 35 | ||
diff --git a/drivers/video/sis/osdef.h b/drivers/video/sis/osdef.h index c1492782cb18..6ff8f988a1a7 100644 --- a/drivers/video/sis/osdef.h +++ b/drivers/video/sis/osdef.h | |||
@@ -87,7 +87,6 @@ | |||
87 | /**********************************************************************/ | 87 | /**********************************************************************/ |
88 | 88 | ||
89 | #ifdef SIS_LINUX_KERNEL | 89 | #ifdef SIS_LINUX_KERNEL |
90 | #include <linux/version.h> | ||
91 | 90 | ||
92 | #ifdef CONFIG_FB_SIS_300 | 91 | #ifdef CONFIG_FB_SIS_300 |
93 | #define SIS300 | 92 | #define SIS300 |
diff --git a/drivers/video/sis/sis.h b/drivers/video/sis/sis.h index a14e82211037..7c5710e3fb56 100644 --- a/drivers/video/sis/sis.h +++ b/drivers/video/sis/sis.h | |||
@@ -24,8 +24,6 @@ | |||
24 | #ifndef _SIS_H_ | 24 | #ifndef _SIS_H_ |
25 | #define _SIS_H_ | 25 | #define _SIS_H_ |
26 | 26 | ||
27 | #include <linux/version.h> | ||
28 | |||
29 | #include "osdef.h" | 27 | #include "osdef.h" |
30 | #include <video/sisfb.h> | 28 | #include <video/sisfb.h> |
31 | 29 | ||
@@ -42,16 +40,6 @@ | |||
42 | #define SIS_NEW_CONFIG_COMPAT | 40 | #define SIS_NEW_CONFIG_COMPAT |
43 | #endif /* CONFIG_COMPAT */ | 41 | #endif /* CONFIG_COMPAT */ |
44 | 42 | ||
45 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) | ||
46 | #define SIS_IOTYPE1 void __iomem | ||
47 | #define SIS_IOTYPE2 __iomem | ||
48 | #define SISINITSTATIC static | ||
49 | #else | ||
50 | #define SIS_IOTYPE1 unsigned char | ||
51 | #define SIS_IOTYPE2 | ||
52 | #define SISINITSTATIC | ||
53 | #endif | ||
54 | |||
55 | #undef SISFBDEBUG | 43 | #undef SISFBDEBUG |
56 | 44 | ||
57 | #ifdef SISFBDEBUG | 45 | #ifdef SISFBDEBUG |
@@ -505,8 +493,8 @@ struct sis_video_info { | |||
505 | 493 | ||
506 | unsigned long UMAsize, LFBsize; | 494 | unsigned long UMAsize, LFBsize; |
507 | 495 | ||
508 | SIS_IOTYPE1 *video_vbase; | 496 | void __iomem *video_vbase; |
509 | SIS_IOTYPE1 *mmio_vbase; | 497 | void __iomem *mmio_vbase; |
510 | 498 | ||
511 | unsigned char *bios_abase; | 499 | unsigned char *bios_abase; |
512 | 500 | ||
@@ -533,8 +521,8 @@ struct sis_video_info { | |||
533 | int sisfb_nocrt2rate; | 521 | int sisfb_nocrt2rate; |
534 | 522 | ||
535 | u32 heapstart; /* offset */ | 523 | u32 heapstart; /* offset */ |
536 | SIS_IOTYPE1 *sisfb_heap_start; /* address */ | 524 | void __iomem *sisfb_heap_start; /* address */ |
537 | SIS_IOTYPE1 *sisfb_heap_end; /* address */ | 525 | void __iomem *sisfb_heap_end; /* address */ |
538 | u32 sisfb_heap_size; | 526 | u32 sisfb_heap_size; |
539 | int havenoheap; | 527 | int havenoheap; |
540 | 528 | ||
@@ -612,7 +600,7 @@ struct sis_video_info { | |||
612 | u8 detectedpdca; | 600 | u8 detectedpdca; |
613 | u8 detectedlcda; | 601 | u8 detectedlcda; |
614 | 602 | ||
615 | SIS_IOTYPE1 *hwcursor_vbase; | 603 | void __iomem *hwcursor_vbase; |
616 | 604 | ||
617 | int chronteltype; | 605 | int chronteltype; |
618 | int tvxpos, tvypos; | 606 | int tvxpos, tvypos; |
diff --git a/drivers/video/sis/sis_accel.c b/drivers/video/sis/sis_accel.c index 7addf91d2fea..ceb434c95c0d 100644 --- a/drivers/video/sis/sis_accel.c +++ b/drivers/video/sis/sis_accel.c | |||
@@ -28,7 +28,6 @@ | |||
28 | * for more information and updates) | 28 | * for more information and updates) |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/version.h> | ||
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
33 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
34 | #include <linux/fb.h> | 33 | #include <linux/fb.h> |
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c index b9343844cd1f..346d6458cf76 100644 --- a/drivers/video/sis/sis_main.c +++ b/drivers/video/sis/sis_main.c | |||
@@ -33,7 +33,6 @@ | |||
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <linux/version.h> | ||
37 | #include <linux/module.h> | 36 | #include <linux/module.h> |
38 | #include <linux/moduleparam.h> | 37 | #include <linux/moduleparam.h> |
39 | #include <linux/kernel.h> | 38 | #include <linux/kernel.h> |
@@ -41,13 +40,7 @@ | |||
41 | #include <linux/errno.h> | 40 | #include <linux/errno.h> |
42 | #include <linux/string.h> | 41 | #include <linux/string.h> |
43 | #include <linux/mm.h> | 42 | #include <linux/mm.h> |
44 | |||
45 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) | ||
46 | #include <linux/tty.h> | ||
47 | #else | ||
48 | #include <linux/screen_info.h> | 43 | #include <linux/screen_info.h> |
49 | #endif | ||
50 | |||
51 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
52 | #include <linux/fb.h> | 45 | #include <linux/fb.h> |
53 | #include <linux/selection.h> | 46 | #include <linux/selection.h> |
@@ -1167,11 +1160,7 @@ sisfb_set_mode(struct sis_video_info *ivideo, int clrscrn) | |||
1167 | unsigned short modeno = ivideo->mode_no; | 1160 | unsigned short modeno = ivideo->mode_no; |
1168 | 1161 | ||
1169 | /* >=2.6.12's fbcon clears the screen anyway */ | 1162 | /* >=2.6.12's fbcon clears the screen anyway */ |
1170 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) | ||
1171 | if(!clrscrn) modeno |= 0x80; | ||
1172 | #else | ||
1173 | modeno |= 0x80; | 1163 | modeno |= 0x80; |
1174 | #endif | ||
1175 | 1164 | ||
1176 | outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); | 1165 | outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); |
1177 | 1166 | ||
@@ -1436,11 +1425,8 @@ sisfb_set_par(struct fb_info *info) | |||
1436 | if((err = sisfb_do_set_var(&info->var, 1, info))) | 1425 | if((err = sisfb_do_set_var(&info->var, 1, info))) |
1437 | return err; | 1426 | return err; |
1438 | 1427 | ||
1439 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) | ||
1440 | sisfb_get_fix(&info->fix, info->currcon, info); | ||
1441 | #else | ||
1442 | sisfb_get_fix(&info->fix, -1, info); | 1428 | sisfb_get_fix(&info->fix, -1, info); |
1443 | #endif | 1429 | |
1444 | return 0; | 1430 | return 0; |
1445 | } | 1431 | } |
1446 | 1432 | ||
@@ -1676,14 +1662,8 @@ sisfb_blank(int blank, struct fb_info *info) | |||
1676 | 1662 | ||
1677 | /* ----------- FBDev related routines for all series ---------- */ | 1663 | /* ----------- FBDev related routines for all series ---------- */ |
1678 | 1664 | ||
1679 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) | ||
1680 | static int sisfb_ioctl(struct fb_info *info, unsigned int cmd, | 1665 | static int sisfb_ioctl(struct fb_info *info, unsigned int cmd, |
1681 | unsigned long arg) | 1666 | unsigned long arg) |
1682 | #else | ||
1683 | static int sisfb_ioctl(struct inode *inode, struct file *file, | ||
1684 | unsigned int cmd, unsigned long arg, | ||
1685 | struct fb_info *info) | ||
1686 | #endif | ||
1687 | { | 1667 | { |
1688 | struct sis_video_info *ivideo = (struct sis_video_info *)info->par; | 1668 | struct sis_video_info *ivideo = (struct sis_video_info *)info->par; |
1689 | struct sis_memreq sismemreq; | 1669 | struct sis_memreq sismemreq; |
@@ -3986,8 +3966,7 @@ sisfb_handle_command(struct sis_video_info *ivideo, struct sisfb_cmd *sisfb_comm | |||
3986 | } | 3966 | } |
3987 | 3967 | ||
3988 | #ifndef MODULE | 3968 | #ifndef MODULE |
3989 | SISINITSTATIC int __init | 3969 | static int __init sisfb_setup(char *options) |
3990 | sisfb_setup(char *options) | ||
3991 | { | 3970 | { |
3992 | char *this_opt; | 3971 | char *this_opt; |
3993 | 3972 | ||
@@ -4086,9 +4065,9 @@ sisfb_setup(char *options) | |||
4086 | #endif | 4065 | #endif |
4087 | 4066 | ||
4088 | static int __devinit | 4067 | static int __devinit |
4089 | sisfb_check_rom(SIS_IOTYPE1 *rom_base, struct sis_video_info *ivideo) | 4068 | sisfb_check_rom(void __iomem *rom_base, struct sis_video_info *ivideo) |
4090 | { | 4069 | { |
4091 | SIS_IOTYPE1 *rom; | 4070 | void __iomem *rom; |
4092 | int romptr; | 4071 | int romptr; |
4093 | 4072 | ||
4094 | if((readb(rom_base) != 0x55) || (readb(rom_base + 1) != 0xaa)) | 4073 | if((readb(rom_base) != 0x55) || (readb(rom_base + 1) != 0xaa)) |
@@ -4117,10 +4096,9 @@ static unsigned char * __devinit | |||
4117 | sisfb_find_rom(struct pci_dev *pdev) | 4096 | sisfb_find_rom(struct pci_dev *pdev) |
4118 | { | 4097 | { |
4119 | struct sis_video_info *ivideo = pci_get_drvdata(pdev); | 4098 | struct sis_video_info *ivideo = pci_get_drvdata(pdev); |
4120 | SIS_IOTYPE1 *rom_base; | 4099 | void __iomem *rom_base; |
4121 | unsigned char *myrombase = NULL; | 4100 | unsigned char *myrombase = NULL; |
4122 | u32 temp; | 4101 | u32 temp; |
4123 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11) | ||
4124 | size_t romsize; | 4102 | size_t romsize; |
4125 | 4103 | ||
4126 | /* First, try the official pci ROM functions (except | 4104 | /* First, try the official pci ROM functions (except |
@@ -4151,7 +4129,6 @@ sisfb_find_rom(struct pci_dev *pdev) | |||
4151 | } | 4129 | } |
4152 | 4130 | ||
4153 | if(myrombase) return myrombase; | 4131 | if(myrombase) return myrombase; |
4154 | #endif | ||
4155 | 4132 | ||
4156 | /* Otherwise do it the conventional way. */ | 4133 | /* Otherwise do it the conventional way. */ |
4157 | 4134 | ||
@@ -4225,7 +4202,7 @@ sisfb_post_map_vram(struct sis_video_info *ivideo, unsigned int *mapsize, | |||
4225 | static int __devinit | 4202 | static int __devinit |
4226 | sisfb_post_300_buswidth(struct sis_video_info *ivideo) | 4203 | sisfb_post_300_buswidth(struct sis_video_info *ivideo) |
4227 | { | 4204 | { |
4228 | SIS_IOTYPE1 *FBAddress = ivideo->video_vbase; | 4205 | void __iomem *FBAddress = ivideo->video_vbase; |
4229 | unsigned short temp; | 4206 | unsigned short temp; |
4230 | unsigned char reg; | 4207 | unsigned char reg; |
4231 | int i, j; | 4208 | int i, j; |
@@ -4273,7 +4250,7 @@ sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration, int buswidth | |||
4273 | int PseudoRankCapacity, int PseudoAdrPinCount, | 4250 | int PseudoRankCapacity, int PseudoAdrPinCount, |
4274 | unsigned int mapsize) | 4251 | unsigned int mapsize) |
4275 | { | 4252 | { |
4276 | SIS_IOTYPE1 *FBAddr = ivideo->video_vbase; | 4253 | void __iomem *FBAddr = ivideo->video_vbase; |
4277 | unsigned short sr14; | 4254 | unsigned short sr14; |
4278 | unsigned int k, RankCapacity, PageCapacity, BankNumHigh, BankNumMid; | 4255 | unsigned int k, RankCapacity, PageCapacity, BankNumHigh, BankNumMid; |
4279 | unsigned int PhysicalAdrOtherPage, PhysicalAdrHigh, PhysicalAdrHalfPage; | 4256 | unsigned int PhysicalAdrOtherPage, PhysicalAdrHigh, PhysicalAdrHalfPage; |
@@ -5829,7 +5806,7 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
5829 | ivideo->engineok = 0; | 5806 | ivideo->engineok = 0; |
5830 | 5807 | ||
5831 | ivideo->sisfb_was_boot_device = 0; | 5808 | ivideo->sisfb_was_boot_device = 0; |
5832 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)) | 5809 | |
5833 | if(pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW) { | 5810 | if(pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW) { |
5834 | if(ivideo->sisvga_enabled) | 5811 | if(ivideo->sisvga_enabled) |
5835 | ivideo->sisfb_was_boot_device = 1; | 5812 | ivideo->sisfb_was_boot_device = 1; |
@@ -5840,7 +5817,6 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
5840 | "as the primary VGA device\n"); | 5817 | "as the primary VGA device\n"); |
5841 | } | 5818 | } |
5842 | } | 5819 | } |
5843 | #endif | ||
5844 | 5820 | ||
5845 | ivideo->sisfb_parm_mem = sisfb_parm_mem; | 5821 | ivideo->sisfb_parm_mem = sisfb_parm_mem; |
5846 | ivideo->sisfb_accel = sisfb_accel; | 5822 | ivideo->sisfb_accel = sisfb_accel; |
@@ -6010,7 +5986,7 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
6010 | ivideo->modeprechange = reg & 0x7f; | 5986 | ivideo->modeprechange = reg & 0x7f; |
6011 | } else if(ivideo->sisvga_enabled) { | 5987 | } else if(ivideo->sisvga_enabled) { |
6012 | #if defined(__i386__) || defined(__x86_64__) | 5988 | #if defined(__i386__) || defined(__x86_64__) |
6013 | unsigned char SIS_IOTYPE2 *tt = ioremap(0x400, 0x100); | 5989 | unsigned char __iomem *tt = ioremap(0x400, 0x100); |
6014 | if(tt) { | 5990 | if(tt) { |
6015 | ivideo->modeprechange = readb(tt + 0x49); | 5991 | ivideo->modeprechange = readb(tt + 0x49); |
6016 | iounmap(tt); | 5992 | iounmap(tt); |
@@ -6503,7 +6479,7 @@ static struct pci_driver sisfb_driver = { | |||
6503 | .remove = __devexit_p(sisfb_remove) | 6479 | .remove = __devexit_p(sisfb_remove) |
6504 | }; | 6480 | }; |
6505 | 6481 | ||
6506 | SISINITSTATIC int __init sisfb_init(void) | 6482 | static int __init sisfb_init(void) |
6507 | { | 6483 | { |
6508 | #ifndef MODULE | 6484 | #ifndef MODULE |
6509 | char *options = NULL; | 6485 | char *options = NULL; |
diff --git a/drivers/video/sis/sis_main.h b/drivers/video/sis/sis_main.h index 3e3b7fa05d6c..9540e977270e 100644 --- a/drivers/video/sis/sis_main.h +++ b/drivers/video/sis/sis_main.h | |||
@@ -665,11 +665,11 @@ static struct _customttable { | |||
665 | 665 | ||
666 | /* Interface used by the world */ | 666 | /* Interface used by the world */ |
667 | #ifndef MODULE | 667 | #ifndef MODULE |
668 | SISINITSTATIC int sisfb_setup(char *options); | 668 | static int sisfb_setup(char *options); |
669 | #endif | 669 | #endif |
670 | 670 | ||
671 | /* Interface to the low level console driver */ | 671 | /* Interface to the low level console driver */ |
672 | SISINITSTATIC int sisfb_init(void); | 672 | static int sisfb_init(void); |
673 | 673 | ||
674 | /* fbdev routines */ | 674 | /* fbdev routines */ |
675 | static int sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, | 675 | static int sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, |
diff --git a/drivers/video/sis/vgatypes.h b/drivers/video/sis/vgatypes.h index b532fbd2b04c..81a22eaabfde 100644 --- a/drivers/video/sis/vgatypes.h +++ b/drivers/video/sis/vgatypes.h | |||
@@ -53,10 +53,6 @@ | |||
53 | #ifndef _VGATYPES_H_ | 53 | #ifndef _VGATYPES_H_ |
54 | #define _VGATYPES_H_ | 54 | #define _VGATYPES_H_ |
55 | 55 | ||
56 | #ifdef SIS_LINUX_KERNEL | ||
57 | #include <linux/version.h> | ||
58 | #endif | ||
59 | |||
60 | #define SISIOMEMTYPE | 56 | #define SISIOMEMTYPE |
61 | 57 | ||
62 | #ifdef SIS_LINUX_KERNEL | 58 | #ifdef SIS_LINUX_KERNEL |
diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c index 62321458f71a..df5336561d13 100644 --- a/drivers/video/skeletonfb.c +++ b/drivers/video/skeletonfb.c | |||
@@ -675,13 +675,13 @@ static struct fb_ops xxxfb_ops = { | |||
675 | * Initialization | 675 | * Initialization |
676 | */ | 676 | */ |
677 | 677 | ||
678 | /* static int __init xxfb_probe (struct device *device) -- for platform devs */ | 678 | /* static int __init xxfb_probe (struct platform_device *pdev) -- for platform devs */ |
679 | static int __devinit xxxfb_probe(struct pci_dev *dev, | 679 | static int __devinit xxxfb_probe(struct pci_dev *dev, |
680 | const struct pci_device_id *ent) | 680 | const struct pci_device_id *ent) |
681 | { | 681 | { |
682 | struct fb_info *info; | 682 | struct fb_info *info; |
683 | struct xxx_par *par; | 683 | struct xxx_par *par; |
684 | struct device* device = &dev->dev; /* for pci drivers */ | 684 | struct device *device = &dev->dev; /* or &pdev->dev */ |
685 | int cmap_len, retval; | 685 | int cmap_len, retval; |
686 | 686 | ||
687 | /* | 687 | /* |
@@ -824,18 +824,18 @@ static int __devinit xxxfb_probe(struct pci_dev *dev, | |||
824 | return -EINVAL; | 824 | return -EINVAL; |
825 | printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, | 825 | printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, |
826 | info->fix.id); | 826 | info->fix.id); |
827 | pci_set_drvdata(dev, info); /* or dev_set_drvdata(device, info) */ | 827 | pci_set_drvdata(dev, info); /* or platform_set_drvdata(pdev, info) */ |
828 | return 0; | 828 | return 0; |
829 | } | 829 | } |
830 | 830 | ||
831 | /* | 831 | /* |
832 | * Cleanup | 832 | * Cleanup |
833 | */ | 833 | */ |
834 | /* static void __devexit xxxfb_remove(struct device *device) */ | 834 | /* static void __devexit xxxfb_remove(struct platform_device *pdev) */ |
835 | static void __devexit xxxfb_remove(struct pci_dev *dev) | 835 | static void __devexit xxxfb_remove(struct pci_dev *dev) |
836 | { | 836 | { |
837 | struct fb_info *info = pci_get_drvdata(dev); | 837 | struct fb_info *info = pci_get_drvdata(dev); |
838 | /* or dev_get_drvdata(device); */ | 838 | /* or platform_get_drvdata(pdev); */ |
839 | 839 | ||
840 | if (info) { | 840 | if (info) { |
841 | unregister_framebuffer(info); | 841 | unregister_framebuffer(info); |
@@ -961,18 +961,17 @@ static int xxxfb_resume(struct platform_dev *dev) | |||
961 | #define xxxfb_resume NULL | 961 | #define xxxfb_resume NULL |
962 | #endif /* CONFIG_PM */ | 962 | #endif /* CONFIG_PM */ |
963 | 963 | ||
964 | static struct device_driver xxxfb_driver = { | 964 | static struct platform_device_driver xxxfb_driver = { |
965 | .name = "xxxfb", | ||
966 | .bus = &platform_bus_type, | ||
967 | .probe = xxxfb_probe, | 965 | .probe = xxxfb_probe, |
968 | .remove = xxxfb_remove, | 966 | .remove = xxxfb_remove, |
969 | .suspend = xxxfb_suspend, /* optional but recommended */ | 967 | .suspend = xxxfb_suspend, /* optional but recommended */ |
970 | .resume = xxxfb_resume, /* optional but recommended */ | 968 | .resume = xxxfb_resume, /* optional but recommended */ |
969 | .driver = { | ||
970 | .name = "xxxfb", | ||
971 | }, | ||
971 | }; | 972 | }; |
972 | 973 | ||
973 | static struct platform_device xxxfb_device = { | 974 | static struct platform_device *xxxfb_device; |
974 | .name = "xxxfb", | ||
975 | }; | ||
976 | 975 | ||
977 | #ifndef MODULE | 976 | #ifndef MODULE |
978 | /* | 977 | /* |
@@ -1002,12 +1001,16 @@ static int __init xxxfb_init(void) | |||
1002 | return -ENODEV; | 1001 | return -ENODEV; |
1003 | xxxfb_setup(option); | 1002 | xxxfb_setup(option); |
1004 | #endif | 1003 | #endif |
1005 | ret = driver_register(&xxxfb_driver); | 1004 | ret = platform_driver_register(&xxxfb_driver); |
1006 | 1005 | ||
1007 | if (!ret) { | 1006 | if (!ret) { |
1008 | ret = platform_device_register(&xxxfb_device); | 1007 | xxxfb_device = platform_device_register_simple("xxxfb", 0, |
1009 | if (ret) | 1008 | NULL, 0); |
1010 | driver_unregister(&xxxfb_driver); | 1009 | |
1010 | if (IS_ERR(xxxfb_device)) { | ||
1011 | platform_driver_unregister(&xxxfb_driver); | ||
1012 | ret = PTR_ERR(xxxfb_device); | ||
1013 | } | ||
1011 | } | 1014 | } |
1012 | 1015 | ||
1013 | return ret; | 1016 | return ret; |
@@ -1015,8 +1018,8 @@ static int __init xxxfb_init(void) | |||
1015 | 1018 | ||
1016 | static void __exit xxxfb_exit(void) | 1019 | static void __exit xxxfb_exit(void) |
1017 | { | 1020 | { |
1018 | platform_device_unregister(&xxxfb_device); | 1021 | platform_device_unregister(xxxfb_device); |
1019 | driver_unregister(&xxxfb_driver); | 1022 | platform_driver_unregister(&xxxfb_driver); |
1020 | } | 1023 | } |
1021 | #endif /* CONFIG_PCI */ | 1024 | #endif /* CONFIG_PCI */ |
1022 | 1025 | ||
diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c index 15d4a768b1f6..f94ae84a58cd 100644 --- a/drivers/video/sm501fb.c +++ b/drivers/video/sm501fb.c | |||
@@ -48,10 +48,15 @@ enum sm501_controller { | |||
48 | HEAD_PANEL = 1, | 48 | HEAD_PANEL = 1, |
49 | }; | 49 | }; |
50 | 50 | ||
51 | /* SM501 memory address */ | 51 | /* SM501 memory address. |
52 | * | ||
53 | * This structure is used to track memory usage within the SM501 framebuffer | ||
54 | * allocation. The sm_addr field is stored as an offset as it is often used | ||
55 | * against both the physical and mapped addresses. | ||
56 | */ | ||
52 | struct sm501_mem { | 57 | struct sm501_mem { |
53 | unsigned long size; | 58 | unsigned long size; |
54 | unsigned long sm_addr; | 59 | unsigned long sm_addr; /* offset from base of sm501 fb. */ |
55 | void __iomem *k_addr; | 60 | void __iomem *k_addr; |
56 | }; | 61 | }; |
57 | 62 | ||
@@ -142,31 +147,68 @@ static inline void sm501fb_sync_regs(struct sm501fb_info *info) | |||
142 | static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem, | 147 | static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem, |
143 | unsigned int why, size_t size) | 148 | unsigned int why, size_t size) |
144 | { | 149 | { |
145 | unsigned int ptr = 0; | 150 | struct sm501fb_par *par; |
151 | struct fb_info *fbi; | ||
152 | unsigned int ptr; | ||
153 | unsigned int end; | ||
146 | 154 | ||
147 | switch (why) { | 155 | switch (why) { |
148 | case SM501_MEMF_CURSOR: | 156 | case SM501_MEMF_CURSOR: |
149 | ptr = inf->fbmem_len - size; | 157 | ptr = inf->fbmem_len - size; |
150 | inf->fbmem_len = ptr; | 158 | inf->fbmem_len = ptr; /* adjust available memory. */ |
151 | break; | 159 | break; |
152 | 160 | ||
153 | case SM501_MEMF_PANEL: | 161 | case SM501_MEMF_PANEL: |
154 | ptr = inf->fbmem_len - size; | 162 | ptr = inf->fbmem_len - size; |
155 | if (ptr < inf->fb[0]->fix.smem_len) | 163 | fbi = inf->fb[HEAD_CRT]; |
164 | |||
165 | /* round down, some programs such as directfb do not draw | ||
166 | * 0,0 correctly unless the start is aligned to a page start. | ||
167 | */ | ||
168 | |||
169 | if (ptr > 0) | ||
170 | ptr &= ~(PAGE_SIZE - 1); | ||
171 | |||
172 | if (fbi && ptr < fbi->fix.smem_len) | ||
173 | return -ENOMEM; | ||
174 | |||
175 | if (ptr < 0) | ||
156 | return -ENOMEM; | 176 | return -ENOMEM; |
157 | 177 | ||
158 | break; | 178 | break; |
159 | 179 | ||
160 | case SM501_MEMF_CRT: | 180 | case SM501_MEMF_CRT: |
161 | ptr = 0; | 181 | ptr = 0; |
182 | |||
183 | /* check to see if we have panel memory allocated | ||
184 | * which would put an limit on available memory. */ | ||
185 | |||
186 | fbi = inf->fb[HEAD_PANEL]; | ||
187 | if (fbi) { | ||
188 | par = fbi->par; | ||
189 | end = par->screen.k_addr ? par->screen.sm_addr : inf->fbmem_len; | ||
190 | } else | ||
191 | end = inf->fbmem_len; | ||
192 | |||
193 | if ((ptr + size) > end) | ||
194 | return -ENOMEM; | ||
195 | |||
162 | break; | 196 | break; |
163 | 197 | ||
164 | case SM501_MEMF_ACCEL: | 198 | case SM501_MEMF_ACCEL: |
165 | ptr = inf->fb[0]->fix.smem_len; | 199 | fbi = inf->fb[HEAD_CRT]; |
200 | ptr = fbi ? fbi->fix.smem_len : 0; | ||
201 | |||
202 | fbi = inf->fb[HEAD_PANEL]; | ||
203 | if (fbi) { | ||
204 | par = fbi->par; | ||
205 | end = par->screen.sm_addr; | ||
206 | } else | ||
207 | end = inf->fbmem_len; | ||
166 | 208 | ||
167 | if ((ptr + size) > | 209 | if ((ptr + size) > end) |
168 | (inf->fb[1]->fix.smem_start - inf->fbmem_res->start)) | ||
169 | return -ENOMEM; | 210 | return -ENOMEM; |
211 | |||
170 | break; | 212 | break; |
171 | 213 | ||
172 | default: | 214 | default: |
@@ -663,15 +705,25 @@ static void sm501fb_panel_power(struct sm501fb_info *fbi, int to) | |||
663 | sm501fb_sync_regs(fbi); | 705 | sm501fb_sync_regs(fbi); |
664 | mdelay(10); | 706 | mdelay(10); |
665 | 707 | ||
708 | /* VBIASEN */ | ||
709 | |||
666 | if (!(pd->flags & SM501FB_FLAG_PANEL_NO_VBIASEN)) { | 710 | if (!(pd->flags & SM501FB_FLAG_PANEL_NO_VBIASEN)) { |
667 | control |= SM501_DC_PANEL_CONTROL_BIAS; /* VBIASEN */ | 711 | if (pd->flags & SM501FB_FLAG_PANEL_INV_VBIASEN) |
712 | control &= ~SM501_DC_PANEL_CONTROL_BIAS; | ||
713 | else | ||
714 | control |= SM501_DC_PANEL_CONTROL_BIAS; | ||
715 | |||
668 | writel(control, ctrl_reg); | 716 | writel(control, ctrl_reg); |
669 | sm501fb_sync_regs(fbi); | 717 | sm501fb_sync_regs(fbi); |
670 | mdelay(10); | 718 | mdelay(10); |
671 | } | 719 | } |
672 | 720 | ||
673 | if (!(pd->flags & SM501FB_FLAG_PANEL_NO_FPEN)) { | 721 | if (!(pd->flags & SM501FB_FLAG_PANEL_NO_FPEN)) { |
674 | control |= SM501_DC_PANEL_CONTROL_FPEN; | 722 | if (pd->flags & SM501FB_FLAG_PANEL_INV_FPEN) |
723 | control &= ~SM501_DC_PANEL_CONTROL_FPEN; | ||
724 | else | ||
725 | control |= SM501_DC_PANEL_CONTROL_FPEN; | ||
726 | |||
675 | writel(control, ctrl_reg); | 727 | writel(control, ctrl_reg); |
676 | sm501fb_sync_regs(fbi); | 728 | sm501fb_sync_regs(fbi); |
677 | mdelay(10); | 729 | mdelay(10); |
@@ -679,14 +731,22 @@ static void sm501fb_panel_power(struct sm501fb_info *fbi, int to) | |||
679 | } else if (!to && (control & SM501_DC_PANEL_CONTROL_VDD) != 0) { | 731 | } else if (!to && (control & SM501_DC_PANEL_CONTROL_VDD) != 0) { |
680 | /* disable panel power */ | 732 | /* disable panel power */ |
681 | if (!(pd->flags & SM501FB_FLAG_PANEL_NO_FPEN)) { | 733 | if (!(pd->flags & SM501FB_FLAG_PANEL_NO_FPEN)) { |
682 | control &= ~SM501_DC_PANEL_CONTROL_FPEN; | 734 | if (pd->flags & SM501FB_FLAG_PANEL_INV_FPEN) |
735 | control |= SM501_DC_PANEL_CONTROL_FPEN; | ||
736 | else | ||
737 | control &= ~SM501_DC_PANEL_CONTROL_FPEN; | ||
738 | |||
683 | writel(control, ctrl_reg); | 739 | writel(control, ctrl_reg); |
684 | sm501fb_sync_regs(fbi); | 740 | sm501fb_sync_regs(fbi); |
685 | mdelay(10); | 741 | mdelay(10); |
686 | } | 742 | } |
687 | 743 | ||
688 | if (!(pd->flags & SM501FB_FLAG_PANEL_NO_VBIASEN)) { | 744 | if (!(pd->flags & SM501FB_FLAG_PANEL_NO_VBIASEN)) { |
689 | control &= ~SM501_DC_PANEL_CONTROL_BIAS; | 745 | if (pd->flags & SM501FB_FLAG_PANEL_INV_VBIASEN) |
746 | control |= SM501_DC_PANEL_CONTROL_BIAS; | ||
747 | else | ||
748 | control &= ~SM501_DC_PANEL_CONTROL_BIAS; | ||
749 | |||
690 | writel(control, ctrl_reg); | 750 | writel(control, ctrl_reg); |
691 | sm501fb_sync_regs(fbi); | 751 | sm501fb_sync_regs(fbi); |
692 | mdelay(10); | 752 | mdelay(10); |
@@ -1210,39 +1270,6 @@ static struct fb_ops sm501fb_ops_pnl = { | |||
1210 | .fb_imageblit = cfb_imageblit, | 1270 | .fb_imageblit = cfb_imageblit, |
1211 | }; | 1271 | }; |
1212 | 1272 | ||
1213 | /* sm501fb_info_alloc | ||
1214 | * | ||
1215 | * creates and initialises an sm501fb_info structure | ||
1216 | */ | ||
1217 | |||
1218 | static struct sm501fb_info *sm501fb_info_alloc(struct fb_info *fbinfo_crt, | ||
1219 | struct fb_info *fbinfo_pnl) | ||
1220 | { | ||
1221 | struct sm501fb_info *info; | ||
1222 | struct sm501fb_par *par; | ||
1223 | |||
1224 | info = kzalloc(sizeof(struct sm501fb_info), GFP_KERNEL); | ||
1225 | if (info) { | ||
1226 | /* set the references back */ | ||
1227 | |||
1228 | par = fbinfo_crt->par; | ||
1229 | par->info = info; | ||
1230 | par->head = HEAD_CRT; | ||
1231 | fbinfo_crt->pseudo_palette = &par->pseudo_palette; | ||
1232 | |||
1233 | par = fbinfo_pnl->par; | ||
1234 | par->info = info; | ||
1235 | par->head = HEAD_PANEL; | ||
1236 | fbinfo_pnl->pseudo_palette = &par->pseudo_palette; | ||
1237 | |||
1238 | /* store the two fbs into our info */ | ||
1239 | info->fb[HEAD_CRT] = fbinfo_crt; | ||
1240 | info->fb[HEAD_PANEL] = fbinfo_pnl; | ||
1241 | } | ||
1242 | |||
1243 | return info; | ||
1244 | } | ||
1245 | |||
1246 | /* sm501_init_cursor | 1273 | /* sm501_init_cursor |
1247 | * | 1274 | * |
1248 | * initialise hw cursor parameters | 1275 | * initialise hw cursor parameters |
@@ -1250,10 +1277,16 @@ static struct sm501fb_info *sm501fb_info_alloc(struct fb_info *fbinfo_crt, | |||
1250 | 1277 | ||
1251 | static int sm501_init_cursor(struct fb_info *fbi, unsigned int reg_base) | 1278 | static int sm501_init_cursor(struct fb_info *fbi, unsigned int reg_base) |
1252 | { | 1279 | { |
1253 | struct sm501fb_par *par = fbi->par; | 1280 | struct sm501fb_par *par; |
1254 | struct sm501fb_info *info = par->info; | 1281 | struct sm501fb_info *info; |
1255 | int ret; | 1282 | int ret; |
1256 | 1283 | ||
1284 | if (fbi == NULL) | ||
1285 | return 0; | ||
1286 | |||
1287 | par = fbi->par; | ||
1288 | info = par->info; | ||
1289 | |||
1257 | par->cursor_regs = info->regs + reg_base; | 1290 | par->cursor_regs = info->regs + reg_base; |
1258 | 1291 | ||
1259 | ret = sm501_alloc_mem(info, &par->cursor, SM501_MEMF_CURSOR, 1024); | 1292 | ret = sm501_alloc_mem(info, &par->cursor, SM501_MEMF_CURSOR, 1024); |
@@ -1281,13 +1314,10 @@ static int sm501fb_start(struct sm501fb_info *info, | |||
1281 | struct platform_device *pdev) | 1314 | struct platform_device *pdev) |
1282 | { | 1315 | { |
1283 | struct resource *res; | 1316 | struct resource *res; |
1284 | struct device *dev; | 1317 | struct device *dev = &pdev->dev; |
1285 | int k; | 1318 | int k; |
1286 | int ret; | 1319 | int ret; |
1287 | 1320 | ||
1288 | info->dev = dev = &pdev->dev; | ||
1289 | platform_set_drvdata(pdev, info); | ||
1290 | |||
1291 | info->irq = ret = platform_get_irq(pdev, 0); | 1321 | info->irq = ret = platform_get_irq(pdev, 0); |
1292 | if (ret < 0) { | 1322 | if (ret < 0) { |
1293 | /* we currently do not use the IRQ */ | 1323 | /* we currently do not use the IRQ */ |
@@ -1390,11 +1420,6 @@ static void sm501fb_stop(struct sm501fb_info *info) | |||
1390 | kfree(info->regs_res); | 1420 | kfree(info->regs_res); |
1391 | } | 1421 | } |
1392 | 1422 | ||
1393 | static void sm501fb_info_release(struct sm501fb_info *info) | ||
1394 | { | ||
1395 | kfree(info); | ||
1396 | } | ||
1397 | |||
1398 | static int sm501fb_init_fb(struct fb_info *fb, | 1423 | static int sm501fb_init_fb(struct fb_info *fb, |
1399 | enum sm501_controller head, | 1424 | enum sm501_controller head, |
1400 | const char *fbname) | 1425 | const char *fbname) |
@@ -1539,36 +1564,93 @@ static struct sm501_platdata_fb sm501fb_def_pdata = { | |||
1539 | static char driver_name_crt[] = "sm501fb-crt"; | 1564 | static char driver_name_crt[] = "sm501fb-crt"; |
1540 | static char driver_name_pnl[] = "sm501fb-panel"; | 1565 | static char driver_name_pnl[] = "sm501fb-panel"; |
1541 | 1566 | ||
1542 | static int __init sm501fb_probe(struct platform_device *pdev) | 1567 | static int __devinit sm501fb_probe_one(struct sm501fb_info *info, |
1568 | enum sm501_controller head) | ||
1543 | { | 1569 | { |
1544 | struct sm501fb_info *info; | 1570 | unsigned char *name = (head == HEAD_CRT) ? "crt" : "panel"; |
1545 | struct device *dev = &pdev->dev; | 1571 | struct sm501_platdata_fbsub *pd; |
1546 | struct fb_info *fbinfo_crt; | 1572 | struct sm501fb_par *par; |
1547 | struct fb_info *fbinfo_pnl; | 1573 | struct fb_info *fbi; |
1548 | int ret; | ||
1549 | 1574 | ||
1550 | /* allocate our framebuffers */ | 1575 | pd = (head == HEAD_CRT) ? info->pdata->fb_crt : info->pdata->fb_pnl; |
1576 | |||
1577 | /* Do not initialise if we've not been given any platform data */ | ||
1578 | if (pd == NULL) { | ||
1579 | dev_info(info->dev, "no data for fb %s (disabled)\n", name); | ||
1580 | return 0; | ||
1581 | } | ||
1551 | 1582 | ||
1552 | fbinfo_crt = framebuffer_alloc(sizeof(struct sm501fb_par), dev); | 1583 | fbi = framebuffer_alloc(sizeof(struct sm501fb_par), info->dev); |
1553 | if (fbinfo_crt == NULL) { | 1584 | if (fbi == NULL) { |
1554 | dev_err(dev, "cannot allocate crt framebuffer\n"); | 1585 | dev_err(info->dev, "cannot allocate %s framebuffer\n", name); |
1555 | return -ENOMEM; | 1586 | return -ENOMEM; |
1556 | } | 1587 | } |
1557 | 1588 | ||
1558 | fbinfo_pnl = framebuffer_alloc(sizeof(struct sm501fb_par), dev); | 1589 | par = fbi->par; |
1559 | if (fbinfo_pnl == NULL) { | 1590 | par->info = info; |
1560 | dev_err(dev, "cannot allocate panel framebuffer\n"); | 1591 | par->head = head; |
1561 | ret = -ENOMEM; | 1592 | fbi->pseudo_palette = &par->pseudo_palette; |
1562 | goto fbinfo_crt_alloc_fail; | 1593 | |
1594 | info->fb[head] = fbi; | ||
1595 | |||
1596 | return 0; | ||
1597 | } | ||
1598 | |||
1599 | /* Free up anything allocated by sm501fb_init_fb */ | ||
1600 | |||
1601 | static void sm501_free_init_fb(struct sm501fb_info *info, | ||
1602 | enum sm501_controller head) | ||
1603 | { | ||
1604 | struct fb_info *fbi = info->fb[head]; | ||
1605 | |||
1606 | fb_dealloc_cmap(&fbi->cmap); | ||
1607 | } | ||
1608 | |||
1609 | static int __devinit sm501fb_start_one(struct sm501fb_info *info, | ||
1610 | enum sm501_controller head, | ||
1611 | const char *drvname) | ||
1612 | { | ||
1613 | struct fb_info *fbi = info->fb[head]; | ||
1614 | int ret; | ||
1615 | |||
1616 | if (!fbi) | ||
1617 | return 0; | ||
1618 | |||
1619 | ret = sm501fb_init_fb(info->fb[head], head, drvname); | ||
1620 | if (ret) { | ||
1621 | dev_err(info->dev, "cannot initialise fb %s\n", drvname); | ||
1622 | return ret; | ||
1623 | } | ||
1624 | |||
1625 | ret = register_framebuffer(info->fb[head]); | ||
1626 | if (ret) { | ||
1627 | dev_err(info->dev, "failed to register fb %s\n", drvname); | ||
1628 | sm501_free_init_fb(info, head); | ||
1629 | return ret; | ||
1563 | } | 1630 | } |
1564 | 1631 | ||
1565 | info = sm501fb_info_alloc(fbinfo_crt, fbinfo_pnl); | 1632 | dev_info(info->dev, "fb%d: %s frame buffer\n", fbi->node, fbi->fix.id); |
1566 | if (info == NULL) { | 1633 | |
1567 | dev_err(dev, "cannot allocate par\n"); | 1634 | return 0; |
1568 | ret = -ENOMEM; | 1635 | } |
1569 | goto sm501fb_alloc_fail; | 1636 | |
1637 | static int __devinit sm501fb_probe(struct platform_device *pdev) | ||
1638 | { | ||
1639 | struct sm501fb_info *info; | ||
1640 | struct device *dev = &pdev->dev; | ||
1641 | int ret; | ||
1642 | |||
1643 | /* allocate our framebuffers */ | ||
1644 | |||
1645 | info = kzalloc(sizeof(struct sm501fb_info), GFP_KERNEL); | ||
1646 | if (!info) { | ||
1647 | dev_err(dev, "failed to allocate state\n"); | ||
1648 | return -ENOMEM; | ||
1570 | } | 1649 | } |
1571 | 1650 | ||
1651 | info->dev = dev = &pdev->dev; | ||
1652 | platform_set_drvdata(pdev, info); | ||
1653 | |||
1572 | if (dev->parent->platform_data) { | 1654 | if (dev->parent->platform_data) { |
1573 | struct sm501_platdata *pd = dev->parent->platform_data; | 1655 | struct sm501_platdata *pd = dev->parent->platform_data; |
1574 | info->pdata = pd->fb; | 1656 | info->pdata = pd->fb; |
@@ -1579,90 +1661,88 @@ static int __init sm501fb_probe(struct platform_device *pdev) | |||
1579 | info->pdata = &sm501fb_def_pdata; | 1661 | info->pdata = &sm501fb_def_pdata; |
1580 | } | 1662 | } |
1581 | 1663 | ||
1582 | /* start the framebuffers */ | 1664 | /* probe for the presence of each panel */ |
1583 | 1665 | ||
1584 | ret = sm501fb_start(info, pdev); | 1666 | ret = sm501fb_probe_one(info, HEAD_CRT); |
1585 | if (ret) { | 1667 | if (ret < 0) { |
1586 | dev_err(dev, "cannot initialise SM501\n"); | 1668 | dev_err(dev, "failed to probe CRT\n"); |
1587 | goto sm501fb_start_fail; | 1669 | goto err_alloc; |
1588 | } | 1670 | } |
1589 | 1671 | ||
1590 | /* CRT framebuffer setup */ | 1672 | ret = sm501fb_probe_one(info, HEAD_PANEL); |
1673 | if (ret < 0) { | ||
1674 | dev_err(dev, "failed to probe PANEL\n"); | ||
1675 | goto err_probed_crt; | ||
1676 | } | ||
1591 | 1677 | ||
1592 | ret = sm501fb_init_fb(fbinfo_crt, HEAD_CRT, driver_name_crt); | 1678 | if (info->fb[HEAD_PANEL] == NULL && |
1593 | if (ret) { | 1679 | info->fb[HEAD_CRT] == NULL) { |
1594 | dev_err(dev, "cannot initialise CRT fb\n"); | 1680 | dev_err(dev, "no framebuffers found\n"); |
1595 | goto sm501fb_start_fail; | 1681 | goto err_alloc; |
1596 | } | 1682 | } |
1597 | 1683 | ||
1598 | /* Panel framebuffer setup */ | 1684 | /* get the resources for both of the framebuffers */ |
1599 | 1685 | ||
1600 | ret = sm501fb_init_fb(fbinfo_pnl, HEAD_PANEL, driver_name_pnl); | 1686 | ret = sm501fb_start(info, pdev); |
1601 | if (ret) { | 1687 | if (ret) { |
1602 | dev_err(dev, "cannot initialise Panel fb\n"); | 1688 | dev_err(dev, "cannot initialise SM501\n"); |
1603 | goto sm501fb_start_fail; | 1689 | goto err_probed_panel; |
1604 | } | 1690 | } |
1605 | 1691 | ||
1606 | /* register framebuffers */ | 1692 | ret = sm501fb_start_one(info, HEAD_CRT, driver_name_crt); |
1607 | 1693 | if (ret) { | |
1608 | ret = register_framebuffer(fbinfo_crt); | 1694 | dev_err(dev, "failed to start CRT\n"); |
1609 | if (ret < 0) { | 1695 | goto err_started; |
1610 | dev_err(dev, "failed to register CRT fb (%d)\n", ret); | ||
1611 | goto register_crt_fail; | ||
1612 | } | 1696 | } |
1613 | 1697 | ||
1614 | ret = register_framebuffer(fbinfo_pnl); | 1698 | ret = sm501fb_start_one(info, HEAD_PANEL, driver_name_pnl); |
1615 | if (ret < 0) { | 1699 | if (ret) { |
1616 | dev_err(dev, "failed to register panel fb (%d)\n", ret); | 1700 | dev_err(dev, "failed to start Panel\n"); |
1617 | goto register_pnl_fail; | 1701 | goto err_started_crt; |
1618 | } | 1702 | } |
1619 | 1703 | ||
1620 | dev_info(dev, "fb%d: %s frame buffer device\n", | ||
1621 | fbinfo_crt->node, fbinfo_crt->fix.id); | ||
1622 | |||
1623 | dev_info(dev, "fb%d: %s frame buffer device\n", | ||
1624 | fbinfo_pnl->node, fbinfo_pnl->fix.id); | ||
1625 | |||
1626 | /* create device files */ | 1704 | /* create device files */ |
1627 | 1705 | ||
1628 | ret = device_create_file(dev, &dev_attr_crt_src); | 1706 | ret = device_create_file(dev, &dev_attr_crt_src); |
1629 | if (ret) | 1707 | if (ret) |
1630 | goto crtsrc_fail; | 1708 | goto err_started_panel; |
1631 | 1709 | ||
1632 | ret = device_create_file(dev, &dev_attr_fbregs_pnl); | 1710 | ret = device_create_file(dev, &dev_attr_fbregs_pnl); |
1633 | if (ret) | 1711 | if (ret) |
1634 | goto fbregs_pnl_fail; | 1712 | goto err_attached_crtsrc_file; |
1635 | 1713 | ||
1636 | ret = device_create_file(dev, &dev_attr_fbregs_crt); | 1714 | ret = device_create_file(dev, &dev_attr_fbregs_crt); |
1637 | if (ret) | 1715 | if (ret) |
1638 | goto fbregs_crt_fail; | 1716 | goto err_attached_pnlregs_file; |
1639 | 1717 | ||
1640 | /* we registered, return ok */ | 1718 | /* we registered, return ok */ |
1641 | return 0; | 1719 | return 0; |
1642 | 1720 | ||
1643 | fbregs_crt_fail: | 1721 | err_attached_pnlregs_file: |
1644 | device_remove_file(dev, &dev_attr_fbregs_pnl); | 1722 | device_remove_file(dev, &dev_attr_fbregs_pnl); |
1645 | 1723 | ||
1646 | fbregs_pnl_fail: | 1724 | err_attached_crtsrc_file: |
1647 | device_remove_file(dev, &dev_attr_crt_src); | 1725 | device_remove_file(dev, &dev_attr_crt_src); |
1648 | 1726 | ||
1649 | crtsrc_fail: | 1727 | err_started_panel: |
1650 | unregister_framebuffer(fbinfo_pnl); | 1728 | unregister_framebuffer(info->fb[HEAD_PANEL]); |
1729 | sm501_free_init_fb(info, HEAD_PANEL); | ||
1651 | 1730 | ||
1652 | register_pnl_fail: | 1731 | err_started_crt: |
1653 | unregister_framebuffer(fbinfo_crt); | 1732 | unregister_framebuffer(info->fb[HEAD_CRT]); |
1733 | sm501_free_init_fb(info, HEAD_CRT); | ||
1654 | 1734 | ||
1655 | register_crt_fail: | 1735 | err_started: |
1656 | sm501fb_stop(info); | 1736 | sm501fb_stop(info); |
1657 | 1737 | ||
1658 | sm501fb_start_fail: | 1738 | err_probed_panel: |
1659 | sm501fb_info_release(info); | 1739 | framebuffer_release(info->fb[HEAD_PANEL]); |
1660 | 1740 | ||
1661 | sm501fb_alloc_fail: | 1741 | err_probed_crt: |
1662 | framebuffer_release(fbinfo_pnl); | 1742 | framebuffer_release(info->fb[HEAD_CRT]); |
1663 | 1743 | ||
1664 | fbinfo_crt_alloc_fail: | 1744 | err_alloc: |
1665 | framebuffer_release(fbinfo_crt); | 1745 | kfree(info); |
1666 | 1746 | ||
1667 | return ret; | 1747 | return ret; |
1668 | } | 1748 | } |
@@ -1681,11 +1761,14 @@ static int sm501fb_remove(struct platform_device *pdev) | |||
1681 | device_remove_file(&pdev->dev, &dev_attr_fbregs_pnl); | 1761 | device_remove_file(&pdev->dev, &dev_attr_fbregs_pnl); |
1682 | device_remove_file(&pdev->dev, &dev_attr_crt_src); | 1762 | device_remove_file(&pdev->dev, &dev_attr_crt_src); |
1683 | 1763 | ||
1764 | sm501_free_init_fb(info, HEAD_CRT); | ||
1765 | sm501_free_init_fb(info, HEAD_PANEL); | ||
1766 | |||
1684 | unregister_framebuffer(fbinfo_crt); | 1767 | unregister_framebuffer(fbinfo_crt); |
1685 | unregister_framebuffer(fbinfo_pnl); | 1768 | unregister_framebuffer(fbinfo_pnl); |
1686 | 1769 | ||
1687 | sm501fb_stop(info); | 1770 | sm501fb_stop(info); |
1688 | sm501fb_info_release(info); | 1771 | kfree(info); |
1689 | 1772 | ||
1690 | framebuffer_release(fbinfo_pnl); | 1773 | framebuffer_release(fbinfo_pnl); |
1691 | framebuffer_release(fbinfo_crt); | 1774 | framebuffer_release(fbinfo_crt); |
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c index ea9f19d25597..77aafcfae037 100644 --- a/drivers/video/tdfxfb.c +++ b/drivers/video/tdfxfb.c | |||
@@ -836,16 +836,12 @@ static int tdfxfb_pan_display(struct fb_var_screeninfo *var, | |||
836 | struct tdfx_par *par = info->par; | 836 | struct tdfx_par *par = info->par; |
837 | u32 addr = var->yoffset * info->fix.line_length; | 837 | u32 addr = var->yoffset * info->fix.line_length; |
838 | 838 | ||
839 | if (nopan || var->xoffset || (var->yoffset > var->yres_virtual)) | 839 | if (nopan || var->xoffset) |
840 | return -EINVAL; | ||
841 | if ((var->yoffset + var->yres > var->yres_virtual && nowrap)) | ||
842 | return -EINVAL; | 840 | return -EINVAL; |
843 | 841 | ||
844 | banshee_make_room(par, 1); | 842 | banshee_make_room(par, 1); |
845 | tdfx_outl(par, VIDDESKSTART, addr); | 843 | tdfx_outl(par, VIDDESKSTART, addr); |
846 | 844 | ||
847 | info->var.xoffset = var->xoffset; | ||
848 | info->var.yoffset = var->yoffset; | ||
849 | return 0; | 845 | return 0; |
850 | } | 846 | } |
851 | 847 | ||
@@ -1426,6 +1422,8 @@ MODULE_LICENSE("GPL"); | |||
1426 | module_param(hwcursor, int, 0644); | 1422 | module_param(hwcursor, int, 0644); |
1427 | MODULE_PARM_DESC(hwcursor, "Enable hardware cursor " | 1423 | MODULE_PARM_DESC(hwcursor, "Enable hardware cursor " |
1428 | "(1=enable, 0=disable, default=1)"); | 1424 | "(1=enable, 0=disable, default=1)"); |
1425 | module_param(mode_option, charp, 0); | ||
1426 | MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'"); | ||
1429 | #ifdef CONFIG_MTRR | 1427 | #ifdef CONFIG_MTRR |
1430 | module_param(nomtrr, bool, 0); | 1428 | module_param(nomtrr, bool, 0); |
1431 | MODULE_PARM_DESC(nomtrr, "Disable MTRR support (default: enabled)"); | 1429 | MODULE_PARM_DESC(nomtrr, "Disable MTRR support (default: enabled)"); |
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c index beefab2992c0..479b2e79ad68 100644 --- a/drivers/video/tridentfb.c +++ b/drivers/video/tridentfb.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Frame buffer driver for Trident Blade and Image series | 2 | * Frame buffer driver for Trident TGUI, Blade and Image series |
3 | * | 3 | * |
4 | * Copyright 2001, 2002 - Jani Monoses <jani@iv.ro> | 4 | * Copyright 2001, 2002 - Jani Monoses <jani@iv.ro> |
5 | * | 5 | * |
@@ -13,7 +13,6 @@ | |||
13 | * code, suggestions | 13 | * code, suggestions |
14 | * TODO: | 14 | * TODO: |
15 | * timing value tweaking so it looks good on every monitor in every mode | 15 | * timing value tweaking so it looks good on every monitor in every mode |
16 | * TGUI acceleration | ||
17 | */ | 16 | */ |
18 | 17 | ||
19 | #include <linux/module.h> | 18 | #include <linux/module.h> |
@@ -22,25 +21,26 @@ | |||
22 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
23 | 22 | ||
24 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <video/vga.h> | ||
25 | #include <video/trident.h> | 25 | #include <video/trident.h> |
26 | 26 | ||
27 | #define VERSION "0.7.8-NEWAPI" | ||
28 | |||
29 | struct tridentfb_par { | 27 | struct tridentfb_par { |
30 | void __iomem *io_virt; /* iospace virtual memory address */ | 28 | void __iomem *io_virt; /* iospace virtual memory address */ |
29 | u32 pseudo_pal[16]; | ||
30 | int chip_id; | ||
31 | int flatpanel; | ||
32 | void (*init_accel) (struct tridentfb_par *, int, int); | ||
33 | void (*wait_engine) (struct tridentfb_par *); | ||
34 | void (*fill_rect) | ||
35 | (struct tridentfb_par *par, u32, u32, u32, u32, u32, u32); | ||
36 | void (*copy_rect) | ||
37 | (struct tridentfb_par *par, u32, u32, u32, u32, u32, u32); | ||
38 | void (*image_blit) | ||
39 | (struct tridentfb_par *par, const char*, | ||
40 | u32, u32, u32, u32, u32, u32); | ||
41 | unsigned char eng_oper; /* engine operation... */ | ||
31 | }; | 42 | }; |
32 | 43 | ||
33 | static unsigned char eng_oper; /* engine operation... */ | ||
34 | static struct fb_ops tridentfb_ops; | ||
35 | |||
36 | static struct tridentfb_par default_par; | ||
37 | |||
38 | /* FIXME:kmalloc these 3 instead */ | ||
39 | static struct fb_info fb_info; | ||
40 | static u32 pseudo_pal[16]; | ||
41 | |||
42 | static struct fb_var_screeninfo default_var; | ||
43 | |||
44 | static struct fb_fix_screeninfo tridentfb_fix = { | 44 | static struct fb_fix_screeninfo tridentfb_fix = { |
45 | .id = "Trident", | 45 | .id = "Trident", |
46 | .type = FB_TYPE_PACKED_PIXELS, | 46 | .type = FB_TYPE_PACKED_PIXELS, |
@@ -49,27 +49,22 @@ static struct fb_fix_screeninfo tridentfb_fix = { | |||
49 | .accel = FB_ACCEL_NONE, | 49 | .accel = FB_ACCEL_NONE, |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static int chip_id; | ||
53 | |||
54 | static int defaultaccel; | ||
55 | static int displaytype; | ||
56 | |||
57 | /* defaults which are normally overriden by user values */ | 52 | /* defaults which are normally overriden by user values */ |
58 | 53 | ||
59 | /* video mode */ | 54 | /* video mode */ |
60 | static char *mode_option __devinitdata = "640x480"; | 55 | static char *mode_option __devinitdata = "640x480-8@60"; |
61 | static int bpp = 8; | 56 | static int bpp __devinitdata = 8; |
62 | 57 | ||
63 | static int noaccel; | 58 | static int noaccel __devinitdata; |
64 | 59 | ||
65 | static int center; | 60 | static int center; |
66 | static int stretch; | 61 | static int stretch; |
67 | 62 | ||
68 | static int fp; | 63 | static int fp __devinitdata; |
69 | static int crt; | 64 | static int crt __devinitdata; |
70 | 65 | ||
71 | static int memsize; | 66 | static int memsize __devinitdata; |
72 | static int memdiff; | 67 | static int memdiff __devinitdata; |
73 | static int nativex; | 68 | static int nativex; |
74 | 69 | ||
75 | module_param(mode_option, charp, 0); | 70 | module_param(mode_option, charp, 0); |
@@ -84,25 +79,53 @@ module_param(memsize, int, 0); | |||
84 | module_param(memdiff, int, 0); | 79 | module_param(memdiff, int, 0); |
85 | module_param(nativex, int, 0); | 80 | module_param(nativex, int, 0); |
86 | module_param(fp, int, 0); | 81 | module_param(fp, int, 0); |
82 | MODULE_PARM_DESC(fp, "Define if flatpanel is connected"); | ||
87 | module_param(crt, int, 0); | 83 | module_param(crt, int, 0); |
84 | MODULE_PARM_DESC(crt, "Define if CRT is connected"); | ||
85 | |||
86 | static inline int is_oldclock(int id) | ||
87 | { | ||
88 | return (id == TGUI9440) || | ||
89 | (id == TGUI9660) || | ||
90 | (id == CYBER9320); | ||
91 | } | ||
92 | |||
93 | static inline int is_oldprotect(int id) | ||
94 | { | ||
95 | return is_oldclock(id) || | ||
96 | (id == PROVIDIA9685) || | ||
97 | (id == CYBER9382) || | ||
98 | (id == CYBER9385); | ||
99 | } | ||
100 | |||
101 | static inline int is_blade(int id) | ||
102 | { | ||
103 | return (id == BLADE3D) || | ||
104 | (id == CYBERBLADEE4) || | ||
105 | (id == CYBERBLADEi7) || | ||
106 | (id == CYBERBLADEi7D) || | ||
107 | (id == CYBERBLADEi1) || | ||
108 | (id == CYBERBLADEi1D) || | ||
109 | (id == CYBERBLADEAi1) || | ||
110 | (id == CYBERBLADEAi1D); | ||
111 | } | ||
88 | 112 | ||
89 | static int chip3D; | 113 | static inline int is_xp(int id) |
90 | static int chipcyber; | 114 | { |
115 | return (id == CYBERBLADEXPAi1) || | ||
116 | (id == CYBERBLADEXPm8) || | ||
117 | (id == CYBERBLADEXPm16); | ||
118 | } | ||
91 | 119 | ||
92 | static int is3Dchip(int id) | 120 | static inline int is3Dchip(int id) |
93 | { | 121 | { |
94 | return ((id == BLADE3D) || (id == CYBERBLADEE4) || | 122 | return is_blade(id) || is_xp(id) || |
95 | (id == CYBERBLADEi7) || (id == CYBERBLADEi7D) || | ||
96 | (id == CYBER9397) || (id == CYBER9397DVD) || | 123 | (id == CYBER9397) || (id == CYBER9397DVD) || |
97 | (id == CYBER9520) || (id == CYBER9525DVD) || | 124 | (id == CYBER9520) || (id == CYBER9525DVD) || |
98 | (id == IMAGE975) || (id == IMAGE985) || | 125 | (id == IMAGE975) || (id == IMAGE985); |
99 | (id == CYBERBLADEi1) || (id == CYBERBLADEi1D) || | ||
100 | (id == CYBERBLADEAi1) || (id == CYBERBLADEAi1D) || | ||
101 | (id == CYBERBLADEXPm8) || (id == CYBERBLADEXPm16) || | ||
102 | (id == CYBERBLADEXPAi1)); | ||
103 | } | 126 | } |
104 | 127 | ||
105 | static int iscyber(int id) | 128 | static inline int iscyber(int id) |
106 | { | 129 | { |
107 | switch (id) { | 130 | switch (id) { |
108 | case CYBER9388: | 131 | case CYBER9388: |
@@ -122,12 +145,7 @@ static int iscyber(int id) | |||
122 | return 1; | 145 | return 1; |
123 | 146 | ||
124 | case CYBER9320: | 147 | case CYBER9320: |
125 | case TGUI9660: | ||
126 | case IMAGE975: | ||
127 | case IMAGE985: | ||
128 | case BLADE3D: | ||
129 | case CYBERBLADEi7: /* VIA MPV4 integrated version */ | 148 | case CYBERBLADEi7: /* VIA MPV4 integrated version */ |
130 | |||
131 | default: | 149 | default: |
132 | /* case CYBERBLDAEXPm8: Strange */ | 150 | /* case CYBERBLDAEXPm8: Strange */ |
133 | /* case CYBERBLDAEXPm16: Strange */ | 151 | /* case CYBERBLDAEXPm16: Strange */ |
@@ -135,147 +153,110 @@ static int iscyber(int id) | |||
135 | } | 153 | } |
136 | } | 154 | } |
137 | 155 | ||
138 | #define CRT 0x3D0 /* CRTC registers offset for color display */ | 156 | static inline void t_outb(struct tridentfb_par *p, u8 val, u16 reg) |
139 | 157 | { | |
140 | #ifndef TRIDENT_MMIO | 158 | fb_writeb(val, p->io_virt + reg); |
141 | #define TRIDENT_MMIO 1 | 159 | } |
142 | #endif | ||
143 | |||
144 | #if TRIDENT_MMIO | ||
145 | #define t_outb(val, reg) writeb(val,((struct tridentfb_par *)(fb_info.par))->io_virt + reg) | ||
146 | #define t_inb(reg) readb(((struct tridentfb_par*)(fb_info.par))->io_virt + reg) | ||
147 | #else | ||
148 | #define t_outb(val, reg) outb(val, reg) | ||
149 | #define t_inb(reg) inb(reg) | ||
150 | #endif | ||
151 | 160 | ||
161 | static inline u8 t_inb(struct tridentfb_par *p, u16 reg) | ||
162 | { | ||
163 | return fb_readb(p->io_virt + reg); | ||
164 | } | ||
152 | 165 | ||
153 | static struct accel_switch { | 166 | static inline void writemmr(struct tridentfb_par *par, u16 r, u32 v) |
154 | void (*init_accel) (int, int); | 167 | { |
155 | void (*wait_engine) (void); | 168 | fb_writel(v, par->io_virt + r); |
156 | void (*fill_rect) (u32, u32, u32, u32, u32, u32); | 169 | } |
157 | void (*copy_rect) (u32, u32, u32, u32, u32, u32); | ||
158 | } *acc; | ||
159 | 170 | ||
160 | #define writemmr(r, v) writel(v, ((struct tridentfb_par *)fb_info.par)->io_virt + r) | 171 | static inline u32 readmmr(struct tridentfb_par *par, u16 r) |
161 | #define readmmr(r) readl(((struct tridentfb_par *)fb_info.par)->io_virt + r) | 172 | { |
173 | return fb_readl(par->io_virt + r); | ||
174 | } | ||
162 | 175 | ||
163 | /* | 176 | /* |
164 | * Blade specific acceleration. | 177 | * Blade specific acceleration. |
165 | */ | 178 | */ |
166 | 179 | ||
167 | #define point(x, y) ((y) << 16 | (x)) | 180 | #define point(x, y) ((y) << 16 | (x)) |
168 | #define STA 0x2120 | 181 | |
169 | #define CMD 0x2144 | 182 | static void blade_init_accel(struct tridentfb_par *par, int pitch, int bpp) |
170 | #define ROP 0x2148 | ||
171 | #define CLR 0x2160 | ||
172 | #define SR1 0x2100 | ||
173 | #define SR2 0x2104 | ||
174 | #define DR1 0x2108 | ||
175 | #define DR2 0x210C | ||
176 | |||
177 | #define ROP_S 0xCC | ||
178 | |||
179 | static void blade_init_accel(int pitch, int bpp) | ||
180 | { | 183 | { |
181 | int v1 = (pitch >> 3) << 20; | 184 | int v1 = (pitch >> 3) << 20; |
182 | int tmp = 0, v2; | 185 | int tmp = bpp == 24 ? 2 : (bpp >> 4); |
183 | switch (bpp) { | 186 | int v2 = v1 | (tmp << 29); |
184 | case 8: | 187 | |
185 | tmp = 0; | 188 | writemmr(par, 0x21C0, v2); |
186 | break; | 189 | writemmr(par, 0x21C4, v2); |
187 | case 15: | 190 | writemmr(par, 0x21B8, v2); |
188 | tmp = 5; | 191 | writemmr(par, 0x21BC, v2); |
189 | break; | 192 | writemmr(par, 0x21D0, v1); |
190 | case 16: | 193 | writemmr(par, 0x21D4, v1); |
191 | tmp = 1; | 194 | writemmr(par, 0x21C8, v1); |
192 | break; | 195 | writemmr(par, 0x21CC, v1); |
193 | case 24: | 196 | writemmr(par, 0x216C, 0); |
194 | case 32: | ||
195 | tmp = 2; | ||
196 | break; | ||
197 | } | ||
198 | v2 = v1 | (tmp << 29); | ||
199 | writemmr(0x21C0, v2); | ||
200 | writemmr(0x21C4, v2); | ||
201 | writemmr(0x21B8, v2); | ||
202 | writemmr(0x21BC, v2); | ||
203 | writemmr(0x21D0, v1); | ||
204 | writemmr(0x21D4, v1); | ||
205 | writemmr(0x21C8, v1); | ||
206 | writemmr(0x21CC, v1); | ||
207 | writemmr(0x216C, 0); | ||
208 | } | 197 | } |
209 | 198 | ||
210 | static void blade_wait_engine(void) | 199 | static void blade_wait_engine(struct tridentfb_par *par) |
211 | { | 200 | { |
212 | while (readmmr(STA) & 0xFA800000) ; | 201 | while (readmmr(par, STATUS) & 0xFA800000) |
202 | cpu_relax(); | ||
213 | } | 203 | } |
214 | 204 | ||
215 | static void blade_fill_rect(u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) | 205 | static void blade_fill_rect(struct tridentfb_par *par, |
206 | u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) | ||
216 | { | 207 | { |
217 | writemmr(CLR, c); | 208 | writemmr(par, COLOR, c); |
218 | writemmr(ROP, rop ? 0x66 : ROP_S); | 209 | writemmr(par, ROP, rop ? ROP_X : ROP_S); |
219 | writemmr(CMD, 0x20000000 | 1 << 19 | 1 << 4 | 2 << 2); | 210 | writemmr(par, CMD, 0x20000000 | 1 << 19 | 1 << 4 | 2 << 2); |
220 | 211 | ||
221 | writemmr(DR1, point(x, y)); | 212 | writemmr(par, DST1, point(x, y)); |
222 | writemmr(DR2, point(x + w - 1, y + h - 1)); | 213 | writemmr(par, DST2, point(x + w - 1, y + h - 1)); |
223 | } | 214 | } |
224 | 215 | ||
225 | static void blade_copy_rect(u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) | 216 | static void blade_image_blit(struct tridentfb_par *par, const char *data, |
217 | u32 x, u32 y, u32 w, u32 h, u32 c, u32 b) | ||
218 | { | ||
219 | unsigned size = ((w + 31) >> 5) * h; | ||
220 | |||
221 | writemmr(par, COLOR, c); | ||
222 | writemmr(par, BGCOLOR, b); | ||
223 | writemmr(par, CMD, 0xa0000000 | 3 << 19); | ||
224 | |||
225 | writemmr(par, DST1, point(x, y)); | ||
226 | writemmr(par, DST2, point(x + w - 1, y + h - 1)); | ||
227 | |||
228 | memcpy(par->io_virt + 0x10000, data, 4 * size); | ||
229 | } | ||
230 | |||
231 | static void blade_copy_rect(struct tridentfb_par *par, | ||
232 | u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) | ||
226 | { | 233 | { |
227 | u32 s1, s2, d1, d2; | ||
228 | int direction = 2; | 234 | int direction = 2; |
229 | s1 = point(x1, y1); | 235 | u32 s1 = point(x1, y1); |
230 | s2 = point(x1 + w - 1, y1 + h - 1); | 236 | u32 s2 = point(x1 + w - 1, y1 + h - 1); |
231 | d1 = point(x2, y2); | 237 | u32 d1 = point(x2, y2); |
232 | d2 = point(x2 + w - 1, y2 + h - 1); | 238 | u32 d2 = point(x2 + w - 1, y2 + h - 1); |
233 | 239 | ||
234 | if ((y1 > y2) || ((y1 == y2) && (x1 > x2))) | 240 | if ((y1 > y2) || ((y1 == y2) && (x1 > x2))) |
235 | direction = 0; | 241 | direction = 0; |
236 | 242 | ||
237 | writemmr(ROP, ROP_S); | 243 | writemmr(par, ROP, ROP_S); |
238 | writemmr(CMD, 0xE0000000 | 1 << 19 | 1 << 4 | 1 << 2 | direction); | 244 | writemmr(par, CMD, 0xE0000000 | 1 << 19 | 1 << 4 | 1 << 2 | direction); |
239 | 245 | ||
240 | writemmr(SR1, direction ? s2 : s1); | 246 | writemmr(par, SRC1, direction ? s2 : s1); |
241 | writemmr(SR2, direction ? s1 : s2); | 247 | writemmr(par, SRC2, direction ? s1 : s2); |
242 | writemmr(DR1, direction ? d2 : d1); | 248 | writemmr(par, DST1, direction ? d2 : d1); |
243 | writemmr(DR2, direction ? d1 : d2); | 249 | writemmr(par, DST2, direction ? d1 : d2); |
244 | } | 250 | } |
245 | 251 | ||
246 | static struct accel_switch accel_blade = { | ||
247 | blade_init_accel, | ||
248 | blade_wait_engine, | ||
249 | blade_fill_rect, | ||
250 | blade_copy_rect, | ||
251 | }; | ||
252 | |||
253 | /* | 252 | /* |
254 | * BladeXP specific acceleration functions | 253 | * BladeXP specific acceleration functions |
255 | */ | 254 | */ |
256 | 255 | ||
257 | #define ROP_P 0xF0 | 256 | static void xp_init_accel(struct tridentfb_par *par, int pitch, int bpp) |
258 | #define masked_point(x, y) ((y & 0xffff)<<16|(x & 0xffff)) | ||
259 | |||
260 | static void xp_init_accel(int pitch, int bpp) | ||
261 | { | 257 | { |
262 | int tmp = 0, v1; | 258 | unsigned char x = bpp == 24 ? 3 : (bpp >> 4); |
263 | unsigned char x = 0; | 259 | int v1 = pitch << (bpp == 24 ? 20 : (18 + x)); |
264 | |||
265 | switch (bpp) { | ||
266 | case 8: | ||
267 | x = 0; | ||
268 | break; | ||
269 | case 16: | ||
270 | x = 1; | ||
271 | break; | ||
272 | case 24: | ||
273 | x = 3; | ||
274 | break; | ||
275 | case 32: | ||
276 | x = 2; | ||
277 | break; | ||
278 | } | ||
279 | 260 | ||
280 | switch (pitch << (bpp >> 3)) { | 261 | switch (pitch << (bpp >> 3)) { |
281 | case 8192: | 262 | case 8192: |
@@ -293,42 +274,21 @@ static void xp_init_accel(int pitch, int bpp) | |||
293 | break; | 274 | break; |
294 | } | 275 | } |
295 | 276 | ||
296 | t_outb(x, 0x2125); | 277 | t_outb(par, x, 0x2125); |
297 | |||
298 | eng_oper = x | 0x40; | ||
299 | |||
300 | switch (bpp) { | ||
301 | case 8: | ||
302 | tmp = 18; | ||
303 | break; | ||
304 | case 15: | ||
305 | case 16: | ||
306 | tmp = 19; | ||
307 | break; | ||
308 | case 24: | ||
309 | case 32: | ||
310 | tmp = 20; | ||
311 | break; | ||
312 | } | ||
313 | 278 | ||
314 | v1 = pitch << tmp; | 279 | par->eng_oper = x | 0x40; |
315 | 280 | ||
316 | writemmr(0x2154, v1); | 281 | writemmr(par, 0x2154, v1); |
317 | writemmr(0x2150, v1); | 282 | writemmr(par, 0x2150, v1); |
318 | t_outb(3, 0x2126); | 283 | t_outb(par, 3, 0x2126); |
319 | } | 284 | } |
320 | 285 | ||
321 | static void xp_wait_engine(void) | 286 | static void xp_wait_engine(struct tridentfb_par *par) |
322 | { | 287 | { |
323 | int busy; | 288 | int count = 0; |
324 | int count, timeout; | 289 | int timeout = 0; |
325 | 290 | ||
326 | count = 0; | 291 | while (t_inb(par, STATUS) & 0x80) { |
327 | timeout = 0; | ||
328 | for (;;) { | ||
329 | busy = t_inb(STA) & 0x80; | ||
330 | if (busy != 0x80) | ||
331 | return; | ||
332 | count++; | 292 | count++; |
333 | if (count == 10000000) { | 293 | if (count == 10000000) { |
334 | /* Timeout */ | 294 | /* Timeout */ |
@@ -336,30 +296,31 @@ static void xp_wait_engine(void) | |||
336 | timeout++; | 296 | timeout++; |
337 | if (timeout == 8) { | 297 | if (timeout == 8) { |
338 | /* Reset engine */ | 298 | /* Reset engine */ |
339 | t_outb(0x00, 0x2120); | 299 | t_outb(par, 0x00, STATUS); |
340 | return; | 300 | return; |
341 | } | 301 | } |
342 | } | 302 | } |
303 | cpu_relax(); | ||
343 | } | 304 | } |
344 | } | 305 | } |
345 | 306 | ||
346 | static void xp_fill_rect(u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) | 307 | static void xp_fill_rect(struct tridentfb_par *par, |
308 | u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) | ||
347 | { | 309 | { |
348 | writemmr(0x2127, ROP_P); | 310 | writemmr(par, 0x2127, ROP_P); |
349 | writemmr(0x2158, c); | 311 | writemmr(par, 0x2158, c); |
350 | writemmr(0x2128, 0x4000); | 312 | writemmr(par, DRAWFL, 0x4000); |
351 | writemmr(0x2140, masked_point(h, w)); | 313 | writemmr(par, OLDDIM, point(h, w)); |
352 | writemmr(0x2138, masked_point(y, x)); | 314 | writemmr(par, OLDDST, point(y, x)); |
353 | t_outb(0x01, 0x2124); | 315 | t_outb(par, 0x01, OLDCMD); |
354 | t_outb(eng_oper, 0x2125); | 316 | t_outb(par, par->eng_oper, 0x2125); |
355 | } | 317 | } |
356 | 318 | ||
357 | static void xp_copy_rect(u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) | 319 | static void xp_copy_rect(struct tridentfb_par *par, |
320 | u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) | ||
358 | { | 321 | { |
359 | int direction; | ||
360 | u32 x1_tmp, x2_tmp, y1_tmp, y2_tmp; | 322 | u32 x1_tmp, x2_tmp, y1_tmp, y2_tmp; |
361 | 323 | int direction = 0x0004; | |
362 | direction = 0x0004; | ||
363 | 324 | ||
364 | if ((x1 < x2) && (y1 == y2)) { | 325 | if ((x1 < x2) && (y1 == y2)) { |
365 | direction |= 0x0200; | 326 | direction |= 0x0200; |
@@ -379,103 +340,152 @@ static void xp_copy_rect(u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) | |||
379 | y2_tmp = y2; | 340 | y2_tmp = y2; |
380 | } | 341 | } |
381 | 342 | ||
382 | writemmr(0x2128, direction); | 343 | writemmr(par, DRAWFL, direction); |
383 | t_outb(ROP_S, 0x2127); | 344 | t_outb(par, ROP_S, 0x2127); |
384 | writemmr(0x213C, masked_point(y1_tmp, x1_tmp)); | 345 | writemmr(par, OLDSRC, point(y1_tmp, x1_tmp)); |
385 | writemmr(0x2138, masked_point(y2_tmp, x2_tmp)); | 346 | writemmr(par, OLDDST, point(y2_tmp, x2_tmp)); |
386 | writemmr(0x2140, masked_point(h, w)); | 347 | writemmr(par, OLDDIM, point(h, w)); |
387 | t_outb(0x01, 0x2124); | 348 | t_outb(par, 0x01, OLDCMD); |
388 | } | 349 | } |
389 | 350 | ||
390 | static struct accel_switch accel_xp = { | ||
391 | xp_init_accel, | ||
392 | xp_wait_engine, | ||
393 | xp_fill_rect, | ||
394 | xp_copy_rect, | ||
395 | }; | ||
396 | |||
397 | /* | 351 | /* |
398 | * Image specific acceleration functions | 352 | * Image specific acceleration functions |
399 | */ | 353 | */ |
400 | static void image_init_accel(int pitch, int bpp) | 354 | static void image_init_accel(struct tridentfb_par *par, int pitch, int bpp) |
401 | { | 355 | { |
402 | int tmp = 0; | 356 | int tmp = bpp == 24 ? 2: (bpp >> 4); |
403 | switch (bpp) { | 357 | |
404 | case 8: | 358 | writemmr(par, 0x2120, 0xF0000000); |
405 | tmp = 0; | 359 | writemmr(par, 0x2120, 0x40000000 | tmp); |
406 | break; | 360 | writemmr(par, 0x2120, 0x80000000); |
407 | case 15: | 361 | writemmr(par, 0x2144, 0x00000000); |
408 | tmp = 5; | 362 | writemmr(par, 0x2148, 0x00000000); |
409 | break; | 363 | writemmr(par, 0x2150, 0x00000000); |
410 | case 16: | 364 | writemmr(par, 0x2154, 0x00000000); |
411 | tmp = 1; | 365 | writemmr(par, 0x2120, 0x60000000 | (pitch << 16) | pitch); |
412 | break; | 366 | writemmr(par, 0x216C, 0x00000000); |
413 | case 24: | 367 | writemmr(par, 0x2170, 0x00000000); |
414 | case 32: | 368 | writemmr(par, 0x217C, 0x00000000); |
415 | tmp = 2; | 369 | writemmr(par, 0x2120, 0x10000000); |
416 | break; | 370 | writemmr(par, 0x2130, (2047 << 16) | 2047); |
417 | } | ||
418 | writemmr(0x2120, 0xF0000000); | ||
419 | writemmr(0x2120, 0x40000000 | tmp); | ||
420 | writemmr(0x2120, 0x80000000); | ||
421 | writemmr(0x2144, 0x00000000); | ||
422 | writemmr(0x2148, 0x00000000); | ||
423 | writemmr(0x2150, 0x00000000); | ||
424 | writemmr(0x2154, 0x00000000); | ||
425 | writemmr(0x2120, 0x60000000 | (pitch << 16) | pitch); | ||
426 | writemmr(0x216C, 0x00000000); | ||
427 | writemmr(0x2170, 0x00000000); | ||
428 | writemmr(0x217C, 0x00000000); | ||
429 | writemmr(0x2120, 0x10000000); | ||
430 | writemmr(0x2130, (2047 << 16) | 2047); | ||
431 | } | 371 | } |
432 | 372 | ||
433 | static void image_wait_engine(void) | 373 | static void image_wait_engine(struct tridentfb_par *par) |
434 | { | 374 | { |
435 | while (readmmr(0x2164) & 0xF0000000) ; | 375 | while (readmmr(par, 0x2164) & 0xF0000000) |
376 | cpu_relax(); | ||
436 | } | 377 | } |
437 | 378 | ||
438 | static void image_fill_rect(u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) | 379 | static void image_fill_rect(struct tridentfb_par *par, |
380 | u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) | ||
439 | { | 381 | { |
440 | writemmr(0x2120, 0x80000000); | 382 | writemmr(par, 0x2120, 0x80000000); |
441 | writemmr(0x2120, 0x90000000 | ROP_S); | 383 | writemmr(par, 0x2120, 0x90000000 | ROP_S); |
442 | 384 | ||
443 | writemmr(0x2144, c); | 385 | writemmr(par, 0x2144, c); |
444 | 386 | ||
445 | writemmr(DR1, point(x, y)); | 387 | writemmr(par, DST1, point(x, y)); |
446 | writemmr(DR2, point(x + w - 1, y + h - 1)); | 388 | writemmr(par, DST2, point(x + w - 1, y + h - 1)); |
447 | 389 | ||
448 | writemmr(0x2124, 0x80000000 | 3 << 22 | 1 << 10 | 1 << 9); | 390 | writemmr(par, 0x2124, 0x80000000 | 3 << 22 | 1 << 10 | 1 << 9); |
449 | } | 391 | } |
450 | 392 | ||
451 | static void image_copy_rect(u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) | 393 | static void image_copy_rect(struct tridentfb_par *par, |
394 | u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) | ||
452 | { | 395 | { |
453 | u32 s1, s2, d1, d2; | 396 | int direction = 0x4; |
454 | int direction = 2; | 397 | u32 s1 = point(x1, y1); |
455 | s1 = point(x1, y1); | 398 | u32 s2 = point(x1 + w - 1, y1 + h - 1); |
456 | s2 = point(x1 + w - 1, y1 + h - 1); | 399 | u32 d1 = point(x2, y2); |
457 | d1 = point(x2, y2); | 400 | u32 d2 = point(x2 + w - 1, y2 + h - 1); |
458 | d2 = point(x2 + w - 1, y2 + h - 1); | ||
459 | 401 | ||
460 | if ((y1 > y2) || ((y1 == y2) && (x1 > x2))) | 402 | if ((y1 > y2) || ((y1 == y2) && (x1 > x2))) |
461 | direction = 0; | 403 | direction = 0; |
462 | 404 | ||
463 | writemmr(0x2120, 0x80000000); | 405 | writemmr(par, 0x2120, 0x80000000); |
464 | writemmr(0x2120, 0x90000000 | ROP_S); | 406 | writemmr(par, 0x2120, 0x90000000 | ROP_S); |
465 | 407 | ||
466 | writemmr(SR1, direction ? s2 : s1); | 408 | writemmr(par, SRC1, direction ? s2 : s1); |
467 | writemmr(SR2, direction ? s1 : s2); | 409 | writemmr(par, SRC2, direction ? s1 : s2); |
468 | writemmr(DR1, direction ? d2 : d1); | 410 | writemmr(par, DST1, direction ? d2 : d1); |
469 | writemmr(DR2, direction ? d1 : d2); | 411 | writemmr(par, DST2, direction ? d1 : d2); |
470 | writemmr(0x2124, 0x80000000 | 1 << 22 | 1 << 10 | 1 << 7 | direction); | 412 | writemmr(par, 0x2124, |
413 | 0x80000000 | 1 << 22 | 1 << 10 | 1 << 7 | direction); | ||
471 | } | 414 | } |
472 | 415 | ||
473 | static struct accel_switch accel_image = { | 416 | /* |
474 | image_init_accel, | 417 | * TGUI 9440/96XX acceleration |
475 | image_wait_engine, | 418 | */ |
476 | image_fill_rect, | 419 | |
477 | image_copy_rect, | 420 | static void tgui_init_accel(struct tridentfb_par *par, int pitch, int bpp) |
478 | }; | 421 | { |
422 | unsigned char x = bpp == 24 ? 3 : (bpp >> 4); | ||
423 | |||
424 | /* disable clipping */ | ||
425 | writemmr(par, 0x2148, 0); | ||
426 | writemmr(par, 0x214C, point(4095, 2047)); | ||
427 | |||
428 | switch ((pitch * bpp) / 8) { | ||
429 | case 8192: | ||
430 | case 512: | ||
431 | x |= 0x00; | ||
432 | break; | ||
433 | case 1024: | ||
434 | x |= 0x04; | ||
435 | break; | ||
436 | case 2048: | ||
437 | x |= 0x08; | ||
438 | break; | ||
439 | case 4096: | ||
440 | x |= 0x0C; | ||
441 | break; | ||
442 | } | ||
443 | |||
444 | fb_writew(x, par->io_virt + 0x2122); | ||
445 | } | ||
446 | |||
447 | static void tgui_fill_rect(struct tridentfb_par *par, | ||
448 | u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop) | ||
449 | { | ||
450 | t_outb(par, ROP_P, 0x2127); | ||
451 | writemmr(par, OLDCLR, c); | ||
452 | writemmr(par, DRAWFL, 0x4020); | ||
453 | writemmr(par, OLDDIM, point(w - 1, h - 1)); | ||
454 | writemmr(par, OLDDST, point(x, y)); | ||
455 | t_outb(par, 1, OLDCMD); | ||
456 | } | ||
457 | |||
458 | static void tgui_copy_rect(struct tridentfb_par *par, | ||
459 | u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h) | ||
460 | { | ||
461 | int flags = 0; | ||
462 | u16 x1_tmp, x2_tmp, y1_tmp, y2_tmp; | ||
463 | |||
464 | if ((x1 < x2) && (y1 == y2)) { | ||
465 | flags |= 0x0200; | ||
466 | x1_tmp = x1 + w - 1; | ||
467 | x2_tmp = x2 + w - 1; | ||
468 | } else { | ||
469 | x1_tmp = x1; | ||
470 | x2_tmp = x2; | ||
471 | } | ||
472 | |||
473 | if (y1 < y2) { | ||
474 | flags |= 0x0100; | ||
475 | y1_tmp = y1 + h - 1; | ||
476 | y2_tmp = y2 + h - 1; | ||
477 | } else { | ||
478 | y1_tmp = y1; | ||
479 | y2_tmp = y2; | ||
480 | } | ||
481 | |||
482 | writemmr(par, DRAWFL, 0x4 | flags); | ||
483 | t_outb(par, ROP_S, 0x2127); | ||
484 | writemmr(par, OLDSRC, point(x1_tmp, y1_tmp)); | ||
485 | writemmr(par, OLDDST, point(x2_tmp, y2_tmp)); | ||
486 | writemmr(par, OLDDIM, point(w - 1, h - 1)); | ||
487 | t_outb(par, 1, OLDCMD); | ||
488 | } | ||
479 | 489 | ||
480 | /* | 490 | /* |
481 | * Accel functions called by the upper layers | 491 | * Accel functions called by the upper layers |
@@ -484,129 +494,162 @@ static struct accel_switch accel_image = { | |||
484 | static void tridentfb_fillrect(struct fb_info *info, | 494 | static void tridentfb_fillrect(struct fb_info *info, |
485 | const struct fb_fillrect *fr) | 495 | const struct fb_fillrect *fr) |
486 | { | 496 | { |
487 | int bpp = info->var.bits_per_pixel; | 497 | struct tridentfb_par *par = info->par; |
488 | int col = 0; | 498 | int col; |
489 | 499 | ||
490 | switch (bpp) { | 500 | if (info->flags & FBINFO_HWACCEL_DISABLED) { |
491 | default: | 501 | cfb_fillrect(info, fr); |
492 | case 8: | 502 | return; |
493 | col |= fr->color; | 503 | } |
504 | if (info->var.bits_per_pixel == 8) { | ||
505 | col = fr->color; | ||
494 | col |= col << 8; | 506 | col |= col << 8; |
495 | col |= col << 16; | 507 | col |= col << 16; |
496 | break; | 508 | } else |
497 | case 16: | ||
498 | col = ((u32 *)(info->pseudo_palette))[fr->color]; | 509 | col = ((u32 *)(info->pseudo_palette))[fr->color]; |
499 | break; | 510 | |
500 | case 32: | 511 | par->wait_engine(par); |
501 | col = ((u32 *)(info->pseudo_palette))[fr->color]; | 512 | par->fill_rect(par, fr->dx, fr->dy, fr->width, |
502 | break; | 513 | fr->height, col, fr->rop); |
514 | } | ||
515 | |||
516 | static void tridentfb_imageblit(struct fb_info *info, | ||
517 | const struct fb_image *img) | ||
518 | { | ||
519 | struct tridentfb_par *par = info->par; | ||
520 | int col, bgcol; | ||
521 | |||
522 | if ((info->flags & FBINFO_HWACCEL_DISABLED) || img->depth != 1) { | ||
523 | cfb_imageblit(info, img); | ||
524 | return; | ||
525 | } | ||
526 | if (info->var.bits_per_pixel == 8) { | ||
527 | col = img->fg_color; | ||
528 | col |= col << 8; | ||
529 | col |= col << 16; | ||
530 | bgcol = img->bg_color; | ||
531 | bgcol |= bgcol << 8; | ||
532 | bgcol |= bgcol << 16; | ||
533 | } else { | ||
534 | col = ((u32 *)(info->pseudo_palette))[img->fg_color]; | ||
535 | bgcol = ((u32 *)(info->pseudo_palette))[img->bg_color]; | ||
503 | } | 536 | } |
504 | 537 | ||
505 | acc->fill_rect(fr->dx, fr->dy, fr->width, fr->height, col, fr->rop); | 538 | par->wait_engine(par); |
506 | acc->wait_engine(); | 539 | if (par->image_blit) |
540 | par->image_blit(par, img->data, img->dx, img->dy, | ||
541 | img->width, img->height, col, bgcol); | ||
542 | else | ||
543 | cfb_imageblit(info, img); | ||
507 | } | 544 | } |
545 | |||
508 | static void tridentfb_copyarea(struct fb_info *info, | 546 | static void tridentfb_copyarea(struct fb_info *info, |
509 | const struct fb_copyarea *ca) | 547 | const struct fb_copyarea *ca) |
510 | { | 548 | { |
511 | acc->copy_rect(ca->sx, ca->sy, ca->dx, ca->dy, ca->width, ca->height); | 549 | struct tridentfb_par *par = info->par; |
512 | acc->wait_engine(); | 550 | |
551 | if (info->flags & FBINFO_HWACCEL_DISABLED) { | ||
552 | cfb_copyarea(info, ca); | ||
553 | return; | ||
554 | } | ||
555 | par->wait_engine(par); | ||
556 | par->copy_rect(par, ca->sx, ca->sy, ca->dx, ca->dy, | ||
557 | ca->width, ca->height); | ||
558 | } | ||
559 | |||
560 | static int tridentfb_sync(struct fb_info *info) | ||
561 | { | ||
562 | struct tridentfb_par *par = info->par; | ||
563 | |||
564 | if (!(info->flags & FBINFO_HWACCEL_DISABLED)) | ||
565 | par->wait_engine(par); | ||
566 | return 0; | ||
513 | } | 567 | } |
514 | #else /* !CONFIG_FB_TRIDENT_ACCEL */ | 568 | #else |
515 | #define tridentfb_fillrect cfb_fillrect | 569 | #define tridentfb_fillrect cfb_fillrect |
516 | #define tridentfb_copyarea cfb_copyarea | 570 | #define tridentfb_copyarea cfb_copyarea |
571 | #define tridentfb_imageblit cfb_imageblit | ||
517 | #endif /* CONFIG_FB_TRIDENT_ACCEL */ | 572 | #endif /* CONFIG_FB_TRIDENT_ACCEL */ |
518 | 573 | ||
519 | |||
520 | /* | 574 | /* |
521 | * Hardware access functions | 575 | * Hardware access functions |
522 | */ | 576 | */ |
523 | 577 | ||
524 | static inline unsigned char read3X4(int reg) | 578 | static inline unsigned char read3X4(struct tridentfb_par *par, int reg) |
525 | { | 579 | { |
526 | struct tridentfb_par *par = (struct tridentfb_par *)fb_info.par; | 580 | return vga_mm_rcrt(par->io_virt, reg); |
527 | writeb(reg, par->io_virt + CRT + 4); | ||
528 | return readb(par->io_virt + CRT + 5); | ||
529 | } | 581 | } |
530 | 582 | ||
531 | static inline void write3X4(int reg, unsigned char val) | 583 | static inline void write3X4(struct tridentfb_par *par, int reg, |
584 | unsigned char val) | ||
532 | { | 585 | { |
533 | struct tridentfb_par *par = (struct tridentfb_par *)fb_info.par; | 586 | vga_mm_wcrt(par->io_virt, reg, val); |
534 | writeb(reg, par->io_virt + CRT + 4); | ||
535 | writeb(val, par->io_virt + CRT + 5); | ||
536 | } | 587 | } |
537 | 588 | ||
538 | static inline unsigned char read3C4(int reg) | 589 | static inline unsigned char read3CE(struct tridentfb_par *par, |
590 | unsigned char reg) | ||
539 | { | 591 | { |
540 | t_outb(reg, 0x3C4); | 592 | return vga_mm_rgfx(par->io_virt, reg); |
541 | return t_inb(0x3C5); | ||
542 | } | 593 | } |
543 | 594 | ||
544 | static inline void write3C4(int reg, unsigned char val) | 595 | static inline void writeAttr(struct tridentfb_par *par, int reg, |
596 | unsigned char val) | ||
545 | { | 597 | { |
546 | t_outb(reg, 0x3C4); | 598 | fb_readb(par->io_virt + VGA_IS1_RC); /* flip-flop to index */ |
547 | t_outb(val, 0x3C5); | 599 | vga_mm_wattr(par->io_virt, reg, val); |
548 | } | 600 | } |
549 | 601 | ||
550 | static inline unsigned char read3CE(int reg) | 602 | static inline void write3CE(struct tridentfb_par *par, int reg, |
603 | unsigned char val) | ||
551 | { | 604 | { |
552 | t_outb(reg, 0x3CE); | 605 | vga_mm_wgfx(par->io_virt, reg, val); |
553 | return t_inb(0x3CF); | ||
554 | } | 606 | } |
555 | 607 | ||
556 | static inline void writeAttr(int reg, unsigned char val) | 608 | static void enable_mmio(struct tridentfb_par *par) |
557 | { | ||
558 | readb(((struct tridentfb_par *)fb_info.par)->io_virt + CRT + 0x0A); /* flip-flop to index */ | ||
559 | t_outb(reg, 0x3C0); | ||
560 | t_outb(val, 0x3C0); | ||
561 | } | ||
562 | |||
563 | static inline void write3CE(int reg, unsigned char val) | ||
564 | { | ||
565 | t_outb(reg, 0x3CE); | ||
566 | t_outb(val, 0x3CF); | ||
567 | } | ||
568 | |||
569 | static void enable_mmio(void) | ||
570 | { | 609 | { |
571 | /* Goto New Mode */ | 610 | /* Goto New Mode */ |
572 | outb(0x0B, 0x3C4); | 611 | vga_io_rseq(0x0B); |
573 | inb(0x3C5); | ||
574 | 612 | ||
575 | /* Unprotect registers */ | 613 | /* Unprotect registers */ |
576 | outb(NewMode1, 0x3C4); | 614 | vga_io_wseq(NewMode1, 0x80); |
577 | outb(0x80, 0x3C5); | 615 | if (!is_oldprotect(par->chip_id)) |
616 | vga_io_wseq(Protection, 0x92); | ||
578 | 617 | ||
579 | /* Enable MMIO */ | 618 | /* Enable MMIO */ |
580 | outb(PCIReg, 0x3D4); | 619 | outb(PCIReg, 0x3D4); |
581 | outb(inb(0x3D5) | 0x01, 0x3D5); | 620 | outb(inb(0x3D5) | 0x01, 0x3D5); |
582 | } | 621 | } |
583 | 622 | ||
584 | static void disable_mmio(void) | 623 | static void disable_mmio(struct tridentfb_par *par) |
585 | { | 624 | { |
586 | /* Goto New Mode */ | 625 | /* Goto New Mode */ |
587 | t_outb(0x0B, 0x3C4); | 626 | vga_mm_rseq(par->io_virt, 0x0B); |
588 | t_inb(0x3C5); | ||
589 | 627 | ||
590 | /* Unprotect registers */ | 628 | /* Unprotect registers */ |
591 | t_outb(NewMode1, 0x3C4); | 629 | vga_mm_wseq(par->io_virt, NewMode1, 0x80); |
592 | t_outb(0x80, 0x3C5); | 630 | if (!is_oldprotect(par->chip_id)) |
631 | vga_mm_wseq(par->io_virt, Protection, 0x92); | ||
593 | 632 | ||
594 | /* Disable MMIO */ | 633 | /* Disable MMIO */ |
595 | t_outb(PCIReg, 0x3D4); | 634 | t_outb(par, PCIReg, 0x3D4); |
596 | t_outb(t_inb(0x3D5) & ~0x01, 0x3D5); | 635 | t_outb(par, t_inb(par, 0x3D5) & ~0x01, 0x3D5); |
597 | } | 636 | } |
598 | 637 | ||
599 | #define crtc_unlock() write3X4(CRTVSyncEnd, read3X4(CRTVSyncEnd) & 0x7F) | 638 | static inline void crtc_unlock(struct tridentfb_par *par) |
639 | { | ||
640 | write3X4(par, VGA_CRTC_V_SYNC_END, | ||
641 | read3X4(par, VGA_CRTC_V_SYNC_END) & 0x7F); | ||
642 | } | ||
600 | 643 | ||
601 | /* Return flat panel's maximum x resolution */ | 644 | /* Return flat panel's maximum x resolution */ |
602 | static int __devinit get_nativex(void) | 645 | static int __devinit get_nativex(struct tridentfb_par *par) |
603 | { | 646 | { |
604 | int x, y, tmp; | 647 | int x, y, tmp; |
605 | 648 | ||
606 | if (nativex) | 649 | if (nativex) |
607 | return nativex; | 650 | return nativex; |
608 | 651 | ||
609 | tmp = (read3CE(VertStretch) >> 4) & 3; | 652 | tmp = (read3CE(par, VertStretch) >> 4) & 3; |
610 | 653 | ||
611 | switch (tmp) { | 654 | switch (tmp) { |
612 | case 0: | 655 | case 0: |
@@ -632,77 +675,92 @@ static int __devinit get_nativex(void) | |||
632 | } | 675 | } |
633 | 676 | ||
634 | /* Set pitch */ | 677 | /* Set pitch */ |
635 | static void set_lwidth(int width) | 678 | static inline void set_lwidth(struct tridentfb_par *par, int width) |
636 | { | 679 | { |
637 | write3X4(Offset, width & 0xFF); | 680 | write3X4(par, VGA_CRTC_OFFSET, width & 0xFF); |
638 | write3X4(AddColReg, | 681 | write3X4(par, AddColReg, |
639 | (read3X4(AddColReg) & 0xCF) | ((width & 0x300) >> 4)); | 682 | (read3X4(par, AddColReg) & 0xCF) | ((width & 0x300) >> 4)); |
640 | } | 683 | } |
641 | 684 | ||
642 | /* For resolutions smaller than FP resolution stretch */ | 685 | /* For resolutions smaller than FP resolution stretch */ |
643 | static void screen_stretch(void) | 686 | static void screen_stretch(struct tridentfb_par *par) |
644 | { | 687 | { |
645 | if (chip_id != CYBERBLADEXPAi1) | 688 | if (par->chip_id != CYBERBLADEXPAi1) |
646 | write3CE(BiosReg, 0); | 689 | write3CE(par, BiosReg, 0); |
647 | else | 690 | else |
648 | write3CE(BiosReg, 8); | 691 | write3CE(par, BiosReg, 8); |
649 | write3CE(VertStretch, (read3CE(VertStretch) & 0x7C) | 1); | 692 | write3CE(par, VertStretch, (read3CE(par, VertStretch) & 0x7C) | 1); |
650 | write3CE(HorStretch, (read3CE(HorStretch) & 0x7C) | 1); | 693 | write3CE(par, HorStretch, (read3CE(par, HorStretch) & 0x7C) | 1); |
651 | } | 694 | } |
652 | 695 | ||
653 | /* For resolutions smaller than FP resolution center */ | 696 | /* For resolutions smaller than FP resolution center */ |
654 | static void screen_center(void) | 697 | static inline void screen_center(struct tridentfb_par *par) |
655 | { | 698 | { |
656 | write3CE(VertStretch, (read3CE(VertStretch) & 0x7C) | 0x80); | 699 | write3CE(par, VertStretch, (read3CE(par, VertStretch) & 0x7C) | 0x80); |
657 | write3CE(HorStretch, (read3CE(HorStretch) & 0x7C) | 0x80); | 700 | write3CE(par, HorStretch, (read3CE(par, HorStretch) & 0x7C) | 0x80); |
658 | } | 701 | } |
659 | 702 | ||
660 | /* Address of first shown pixel in display memory */ | 703 | /* Address of first shown pixel in display memory */ |
661 | static void set_screen_start(int base) | 704 | static void set_screen_start(struct tridentfb_par *par, int base) |
662 | { | 705 | { |
663 | write3X4(StartAddrLow, base & 0xFF); | 706 | u8 tmp; |
664 | write3X4(StartAddrHigh, (base & 0xFF00) >> 8); | 707 | write3X4(par, VGA_CRTC_START_LO, base & 0xFF); |
665 | write3X4(CRTCModuleTest, | 708 | write3X4(par, VGA_CRTC_START_HI, (base & 0xFF00) >> 8); |
666 | (read3X4(CRTCModuleTest) & 0xDF) | ((base & 0x10000) >> 11)); | 709 | tmp = read3X4(par, CRTCModuleTest) & 0xDF; |
667 | write3X4(CRTHiOrd, | 710 | write3X4(par, CRTCModuleTest, tmp | ((base & 0x10000) >> 11)); |
668 | (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17)); | 711 | tmp = read3X4(par, CRTHiOrd) & 0xF8; |
712 | write3X4(par, CRTHiOrd, tmp | ((base & 0xE0000) >> 17)); | ||
669 | } | 713 | } |
670 | 714 | ||
671 | /* Set dotclock frequency */ | 715 | /* Set dotclock frequency */ |
672 | static void set_vclk(unsigned long freq) | 716 | static void set_vclk(struct tridentfb_par *par, unsigned long freq) |
673 | { | 717 | { |
674 | int m, n, k; | 718 | int m, n, k; |
675 | unsigned long f, fi, d, di; | 719 | unsigned long fi, d, di; |
676 | unsigned char lo = 0, hi = 0; | 720 | unsigned char best_m = 0, best_n = 0, best_k = 0; |
721 | unsigned char hi, lo; | ||
722 | unsigned char shift = !is_oldclock(par->chip_id) ? 2 : 1; | ||
677 | 723 | ||
678 | d = 20000; | 724 | d = 20000; |
679 | for (k = 2; k >= 0; k--) | 725 | for (k = shift; k >= 0; k--) |
680 | for (m = 0; m < 63; m++) | 726 | for (m = 1; m < 32; m++) { |
681 | for (n = 0; n < 128; n++) { | 727 | n = ((m + 2) << shift) - 8; |
728 | for (n = (n < 0 ? 0 : n); n < 122; n++) { | ||
682 | fi = ((14318l * (n + 8)) / (m + 2)) >> k; | 729 | fi = ((14318l * (n + 8)) / (m + 2)) >> k; |
683 | if ((di = abs(fi - freq)) < d) { | 730 | di = abs(fi - freq); |
731 | if (di < d || (di == d && k == best_k)) { | ||
684 | d = di; | 732 | d = di; |
685 | f = fi; | 733 | best_n = n; |
686 | lo = n; | 734 | best_m = m; |
687 | hi = (k << 6) | m; | 735 | best_k = k; |
688 | } | 736 | } |
689 | if (fi > freq) | 737 | if (fi > freq) |
690 | break; | 738 | break; |
691 | } | 739 | } |
692 | if (chip3D) { | 740 | } |
693 | write3C4(ClockHigh, hi); | 741 | |
694 | write3C4(ClockLow, lo); | 742 | if (is_oldclock(par->chip_id)) { |
743 | lo = best_n | (best_m << 7); | ||
744 | hi = (best_m >> 1) | (best_k << 4); | ||
695 | } else { | 745 | } else { |
696 | outb(lo, 0x43C8); | 746 | lo = best_n; |
697 | outb(hi, 0x43C9); | 747 | hi = best_m | (best_k << 6); |
748 | } | ||
749 | |||
750 | if (is3Dchip(par->chip_id)) { | ||
751 | vga_mm_wseq(par->io_virt, ClockHigh, hi); | ||
752 | vga_mm_wseq(par->io_virt, ClockLow, lo); | ||
753 | } else { | ||
754 | t_outb(par, lo, 0x43C8); | ||
755 | t_outb(par, hi, 0x43C9); | ||
698 | } | 756 | } |
699 | debug("VCLK = %X %X\n", hi, lo); | 757 | debug("VCLK = %X %X\n", hi, lo); |
700 | } | 758 | } |
701 | 759 | ||
702 | /* Set number of lines for flat panels*/ | 760 | /* Set number of lines for flat panels*/ |
703 | static void set_number_of_lines(int lines) | 761 | static void set_number_of_lines(struct tridentfb_par *par, int lines) |
704 | { | 762 | { |
705 | int tmp = read3CE(CyberEnhance) & 0x8F; | 763 | int tmp = read3CE(par, CyberEnhance) & 0x8F; |
706 | if (lines > 1024) | 764 | if (lines > 1024) |
707 | tmp |= 0x50; | 765 | tmp |= 0x50; |
708 | else if (lines > 768) | 766 | else if (lines > 768) |
@@ -711,24 +769,24 @@ static void set_number_of_lines(int lines) | |||
711 | tmp |= 0x20; | 769 | tmp |= 0x20; |
712 | else if (lines > 480) | 770 | else if (lines > 480) |
713 | tmp |= 0x10; | 771 | tmp |= 0x10; |
714 | write3CE(CyberEnhance, tmp); | 772 | write3CE(par, CyberEnhance, tmp); |
715 | } | 773 | } |
716 | 774 | ||
717 | /* | 775 | /* |
718 | * If we see that FP is active we assume we have one. | 776 | * If we see that FP is active we assume we have one. |
719 | * Otherwise we have a CRT display.User can override. | 777 | * Otherwise we have a CRT display. User can override. |
720 | */ | 778 | */ |
721 | static unsigned int __devinit get_displaytype(void) | 779 | static int __devinit is_flatpanel(struct tridentfb_par *par) |
722 | { | 780 | { |
723 | if (fp) | 781 | if (fp) |
724 | return DISPLAY_FP; | 782 | return 1; |
725 | if (crt || !chipcyber) | 783 | if (crt || !iscyber(par->chip_id)) |
726 | return DISPLAY_CRT; | 784 | return 0; |
727 | return (read3CE(FPConfig) & 0x10) ? DISPLAY_FP : DISPLAY_CRT; | 785 | return (read3CE(par, FPConfig) & 0x10) ? 1 : 0; |
728 | } | 786 | } |
729 | 787 | ||
730 | /* Try detecting the video memory size */ | 788 | /* Try detecting the video memory size */ |
731 | static unsigned int __devinit get_memsize(void) | 789 | static unsigned int __devinit get_memsize(struct tridentfb_par *par) |
732 | { | 790 | { |
733 | unsigned char tmp, tmp2; | 791 | unsigned char tmp, tmp2; |
734 | unsigned int k; | 792 | unsigned int k; |
@@ -737,12 +795,12 @@ static unsigned int __devinit get_memsize(void) | |||
737 | if (memsize) | 795 | if (memsize) |
738 | k = memsize * Kb; | 796 | k = memsize * Kb; |
739 | else | 797 | else |
740 | switch (chip_id) { | 798 | switch (par->chip_id) { |
741 | case CYBER9525DVD: | 799 | case CYBER9525DVD: |
742 | k = 2560 * Kb; | 800 | k = 2560 * Kb; |
743 | break; | 801 | break; |
744 | default: | 802 | default: |
745 | tmp = read3X4(SPR) & 0x0F; | 803 | tmp = read3X4(par, SPR) & 0x0F; |
746 | switch (tmp) { | 804 | switch (tmp) { |
747 | 805 | ||
748 | case 0x01: | 806 | case 0x01: |
@@ -774,7 +832,7 @@ static unsigned int __devinit get_memsize(void) | |||
774 | break; | 832 | break; |
775 | case 0x0E: /* XP */ | 833 | case 0x0E: /* XP */ |
776 | 834 | ||
777 | tmp2 = read3C4(0xC1); | 835 | tmp2 = vga_mm_rseq(par->io_virt, 0xC1); |
778 | switch (tmp2) { | 836 | switch (tmp2) { |
779 | case 0x00: | 837 | case 0x00: |
780 | k = 20 * Mb; | 838 | k = 20 * Mb; |
@@ -812,26 +870,67 @@ static unsigned int __devinit get_memsize(void) | |||
812 | static int tridentfb_check_var(struct fb_var_screeninfo *var, | 870 | static int tridentfb_check_var(struct fb_var_screeninfo *var, |
813 | struct fb_info *info) | 871 | struct fb_info *info) |
814 | { | 872 | { |
873 | struct tridentfb_par *par = info->par; | ||
815 | int bpp = var->bits_per_pixel; | 874 | int bpp = var->bits_per_pixel; |
875 | int line_length; | ||
876 | int ramdac = 230000; /* 230MHz for most 3D chips */ | ||
816 | debug("enter\n"); | 877 | debug("enter\n"); |
817 | 878 | ||
818 | /* check color depth */ | 879 | /* check color depth */ |
819 | if (bpp == 24) | 880 | if (bpp == 24) |
820 | bpp = var->bits_per_pixel = 32; | 881 | bpp = var->bits_per_pixel = 32; |
882 | if (bpp != 8 && bpp != 16 && bpp != 32) | ||
883 | return -EINVAL; | ||
884 | if (par->chip_id == TGUI9440 && bpp == 32) | ||
885 | return -EINVAL; | ||
821 | /* check whether resolution fits on panel and in memory */ | 886 | /* check whether resolution fits on panel and in memory */ |
822 | if (flatpanel && nativex && var->xres > nativex) | 887 | if (par->flatpanel && nativex && var->xres > nativex) |
888 | return -EINVAL; | ||
889 | /* various resolution checks */ | ||
890 | var->xres = (var->xres + 7) & ~0x7; | ||
891 | if (var->xres > var->xres_virtual) | ||
892 | var->xres_virtual = var->xres; | ||
893 | if (var->yres > var->yres_virtual) | ||
894 | var->yres_virtual = var->yres; | ||
895 | if (var->xres_virtual > 4095 || var->yres > 2048) | ||
823 | return -EINVAL; | 896 | return -EINVAL; |
824 | if (var->xres * var->yres_virtual * bpp / 8 > info->fix.smem_len) | 897 | /* prevent from position overflow for acceleration */ |
898 | if (var->yres_virtual > 0xffff) | ||
899 | return -EINVAL; | ||
900 | line_length = var->xres_virtual * bpp / 8; | ||
901 | |||
902 | if (!is3Dchip(par->chip_id) && | ||
903 | !(info->flags & FBINFO_HWACCEL_DISABLED)) { | ||
904 | /* acceleration requires line length to be power of 2 */ | ||
905 | if (line_length <= 512) | ||
906 | var->xres_virtual = 512 * 8 / bpp; | ||
907 | else if (line_length <= 1024) | ||
908 | var->xres_virtual = 1024 * 8 / bpp; | ||
909 | else if (line_length <= 2048) | ||
910 | var->xres_virtual = 2048 * 8 / bpp; | ||
911 | else if (line_length <= 4096) | ||
912 | var->xres_virtual = 4096 * 8 / bpp; | ||
913 | else if (line_length <= 8192) | ||
914 | var->xres_virtual = 8192 * 8 / bpp; | ||
915 | else | ||
916 | return -EINVAL; | ||
917 | |||
918 | line_length = var->xres_virtual * bpp / 8; | ||
919 | } | ||
920 | |||
921 | /* datasheet specifies how to set panning only up to 4 MB */ | ||
922 | if (line_length * (var->yres_virtual - var->yres) > (4 << 20)) | ||
923 | var->yres_virtual = ((4 << 20) / line_length) + var->yres; | ||
924 | |||
925 | if (line_length * var->yres_virtual > info->fix.smem_len) | ||
825 | return -EINVAL; | 926 | return -EINVAL; |
826 | 927 | ||
827 | switch (bpp) { | 928 | switch (bpp) { |
828 | case 8: | 929 | case 8: |
829 | var->red.offset = 0; | 930 | var->red.offset = 0; |
830 | var->green.offset = 0; | 931 | var->red.length = 8; |
831 | var->blue.offset = 0; | 932 | var->green = var->red; |
832 | var->red.length = 6; | 933 | var->blue = var->red; |
833 | var->green.length = 6; | ||
834 | var->blue.length = 6; | ||
835 | break; | 934 | break; |
836 | case 16: | 935 | case 16: |
837 | var->red.offset = 11; | 936 | var->red.offset = 11; |
@@ -852,6 +951,33 @@ static int tridentfb_check_var(struct fb_var_screeninfo *var, | |||
852 | default: | 951 | default: |
853 | return -EINVAL; | 952 | return -EINVAL; |
854 | } | 953 | } |
954 | |||
955 | if (is_xp(par->chip_id)) | ||
956 | ramdac = 350000; | ||
957 | |||
958 | switch (par->chip_id) { | ||
959 | case TGUI9440: | ||
960 | ramdac = (bpp >= 16) ? 45000 : 90000; | ||
961 | break; | ||
962 | case CYBER9320: | ||
963 | case TGUI9660: | ||
964 | ramdac = 135000; | ||
965 | break; | ||
966 | case PROVIDIA9685: | ||
967 | case CYBER9388: | ||
968 | case CYBER9382: | ||
969 | case CYBER9385: | ||
970 | ramdac = 170000; | ||
971 | break; | ||
972 | } | ||
973 | |||
974 | /* The clock is doubled for 32 bpp */ | ||
975 | if (bpp == 32) | ||
976 | ramdac /= 2; | ||
977 | |||
978 | if (PICOS2KHZ(var->pixclock) > ramdac) | ||
979 | return -EINVAL; | ||
980 | |||
855 | debug("exit\n"); | 981 | debug("exit\n"); |
856 | 982 | ||
857 | return 0; | 983 | return 0; |
@@ -862,25 +988,31 @@ static int tridentfb_check_var(struct fb_var_screeninfo *var, | |||
862 | static int tridentfb_pan_display(struct fb_var_screeninfo *var, | 988 | static int tridentfb_pan_display(struct fb_var_screeninfo *var, |
863 | struct fb_info *info) | 989 | struct fb_info *info) |
864 | { | 990 | { |
991 | struct tridentfb_par *par = info->par; | ||
865 | unsigned int offset; | 992 | unsigned int offset; |
866 | 993 | ||
867 | debug("enter\n"); | 994 | debug("enter\n"); |
868 | offset = (var->xoffset + (var->yoffset * var->xres)) | 995 | offset = (var->xoffset + (var->yoffset * var->xres_virtual)) |
869 | * var->bits_per_pixel / 32; | 996 | * var->bits_per_pixel / 32; |
870 | info->var.xoffset = var->xoffset; | 997 | set_screen_start(par, offset); |
871 | info->var.yoffset = var->yoffset; | ||
872 | set_screen_start(offset); | ||
873 | debug("exit\n"); | 998 | debug("exit\n"); |
874 | return 0; | 999 | return 0; |
875 | } | 1000 | } |
876 | 1001 | ||
877 | #define shadowmode_on() write3CE(CyberControl, read3CE(CyberControl) | 0x81) | 1002 | static inline void shadowmode_on(struct tridentfb_par *par) |
878 | #define shadowmode_off() write3CE(CyberControl, read3CE(CyberControl) & 0x7E) | 1003 | { |
1004 | write3CE(par, CyberControl, read3CE(par, CyberControl) | 0x81); | ||
1005 | } | ||
1006 | |||
1007 | static inline void shadowmode_off(struct tridentfb_par *par) | ||
1008 | { | ||
1009 | write3CE(par, CyberControl, read3CE(par, CyberControl) & 0x7E); | ||
1010 | } | ||
879 | 1011 | ||
880 | /* Set the hardware to the requested video mode */ | 1012 | /* Set the hardware to the requested video mode */ |
881 | static int tridentfb_set_par(struct fb_info *info) | 1013 | static int tridentfb_set_par(struct fb_info *info) |
882 | { | 1014 | { |
883 | struct tridentfb_par *par = (struct tridentfb_par *)(info->par); | 1015 | struct tridentfb_par *par = info->par; |
884 | u32 htotal, hdispend, hsyncstart, hsyncend, hblankstart, hblankend; | 1016 | u32 htotal, hdispend, hsyncstart, hsyncend, hblankstart, hblankend; |
885 | u32 vtotal, vdispend, vsyncstart, vsyncend, vblankstart, vblankend; | 1017 | u32 vtotal, vdispend, vsyncstart, vsyncend, vblankstart, vblankend; |
886 | struct fb_var_screeninfo *var = &info->var; | 1018 | struct fb_var_screeninfo *var = &info->var; |
@@ -891,58 +1023,73 @@ static int tridentfb_set_par(struct fb_info *info) | |||
891 | debug("enter\n"); | 1023 | debug("enter\n"); |
892 | hdispend = var->xres / 8 - 1; | 1024 | hdispend = var->xres / 8 - 1; |
893 | hsyncstart = (var->xres + var->right_margin) / 8; | 1025 | hsyncstart = (var->xres + var->right_margin) / 8; |
894 | hsyncend = var->hsync_len / 8; | 1026 | hsyncend = (var->xres + var->right_margin + var->hsync_len) / 8; |
895 | htotal = | 1027 | htotal = (var->xres + var->left_margin + var->right_margin + |
896 | (var->xres + var->left_margin + var->right_margin + | 1028 | var->hsync_len) / 8 - 5; |
897 | var->hsync_len) / 8 - 10; | ||
898 | hblankstart = hdispend + 1; | 1029 | hblankstart = hdispend + 1; |
899 | hblankend = htotal + 5; | 1030 | hblankend = htotal + 3; |
900 | 1031 | ||
901 | vdispend = var->yres - 1; | 1032 | vdispend = var->yres - 1; |
902 | vsyncstart = var->yres + var->lower_margin; | 1033 | vsyncstart = var->yres + var->lower_margin; |
903 | vsyncend = var->vsync_len; | 1034 | vsyncend = vsyncstart + var->vsync_len; |
904 | vtotal = var->upper_margin + vsyncstart + vsyncend - 2; | 1035 | vtotal = var->upper_margin + vsyncend - 2; |
905 | vblankstart = var->yres; | 1036 | vblankstart = vdispend + 1; |
906 | vblankend = vtotal + 2; | 1037 | vblankend = vtotal; |
1038 | |||
1039 | if (info->var.vmode & FB_VMODE_INTERLACED) { | ||
1040 | vtotal /= 2; | ||
1041 | vdispend /= 2; | ||
1042 | vsyncstart /= 2; | ||
1043 | vsyncend /= 2; | ||
1044 | vblankstart /= 2; | ||
1045 | vblankend /= 2; | ||
1046 | } | ||
907 | 1047 | ||
908 | crtc_unlock(); | 1048 | enable_mmio(par); |
909 | write3CE(CyberControl, 8); | 1049 | crtc_unlock(par); |
1050 | write3CE(par, CyberControl, 8); | ||
1051 | tmp = 0xEB; | ||
1052 | if (var->sync & FB_SYNC_HOR_HIGH_ACT) | ||
1053 | tmp &= ~0x40; | ||
1054 | if (var->sync & FB_SYNC_VERT_HIGH_ACT) | ||
1055 | tmp &= ~0x80; | ||
910 | 1056 | ||
911 | if (flatpanel && var->xres < nativex) { | 1057 | if (par->flatpanel && var->xres < nativex) { |
912 | /* | 1058 | /* |
913 | * on flat panels with native size larger | 1059 | * on flat panels with native size larger |
914 | * than requested resolution decide whether | 1060 | * than requested resolution decide whether |
915 | * we stretch or center | 1061 | * we stretch or center |
916 | */ | 1062 | */ |
917 | t_outb(0xEB, 0x3C2); | 1063 | t_outb(par, tmp | 0xC0, VGA_MIS_W); |
918 | 1064 | ||
919 | shadowmode_on(); | 1065 | shadowmode_on(par); |
920 | 1066 | ||
921 | if (center) | 1067 | if (center) |
922 | screen_center(); | 1068 | screen_center(par); |
923 | else if (stretch) | 1069 | else if (stretch) |
924 | screen_stretch(); | 1070 | screen_stretch(par); |
925 | 1071 | ||
926 | } else { | 1072 | } else { |
927 | t_outb(0x2B, 0x3C2); | 1073 | t_outb(par, tmp, VGA_MIS_W); |
928 | write3CE(CyberControl, 8); | 1074 | write3CE(par, CyberControl, 8); |
929 | } | 1075 | } |
930 | 1076 | ||
931 | /* vertical timing values */ | 1077 | /* vertical timing values */ |
932 | write3X4(CRTVTotal, vtotal & 0xFF); | 1078 | write3X4(par, VGA_CRTC_V_TOTAL, vtotal & 0xFF); |
933 | write3X4(CRTVDispEnd, vdispend & 0xFF); | 1079 | write3X4(par, VGA_CRTC_V_DISP_END, vdispend & 0xFF); |
934 | write3X4(CRTVSyncStart, vsyncstart & 0xFF); | 1080 | write3X4(par, VGA_CRTC_V_SYNC_START, vsyncstart & 0xFF); |
935 | write3X4(CRTVSyncEnd, (vsyncend & 0x0F)); | 1081 | write3X4(par, VGA_CRTC_V_SYNC_END, (vsyncend & 0x0F)); |
936 | write3X4(CRTVBlankStart, vblankstart & 0xFF); | 1082 | write3X4(par, VGA_CRTC_V_BLANK_START, vblankstart & 0xFF); |
937 | write3X4(CRTVBlankEnd, 0 /* p->vblankend & 0xFF */ ); | 1083 | write3X4(par, VGA_CRTC_V_BLANK_END, vblankend & 0xFF); |
938 | 1084 | ||
939 | /* horizontal timing values */ | 1085 | /* horizontal timing values */ |
940 | write3X4(CRTHTotal, htotal & 0xFF); | 1086 | write3X4(par, VGA_CRTC_H_TOTAL, htotal & 0xFF); |
941 | write3X4(CRTHDispEnd, hdispend & 0xFF); | 1087 | write3X4(par, VGA_CRTC_H_DISP, hdispend & 0xFF); |
942 | write3X4(CRTHSyncStart, hsyncstart & 0xFF); | 1088 | write3X4(par, VGA_CRTC_H_SYNC_START, hsyncstart & 0xFF); |
943 | write3X4(CRTHSyncEnd, (hsyncend & 0x1F) | ((hblankend & 0x20) << 2)); | 1089 | write3X4(par, VGA_CRTC_H_SYNC_END, |
944 | write3X4(CRTHBlankStart, hblankstart & 0xFF); | 1090 | (hsyncend & 0x1F) | ((hblankend & 0x20) << 2)); |
945 | write3X4(CRTHBlankEnd, 0 /* (p->hblankend & 0x1F) */ ); | 1091 | write3X4(par, VGA_CRTC_H_BLANK_START, hblankstart & 0xFF); |
1092 | write3X4(par, VGA_CRTC_H_BLANK_END, hblankend & 0x1F); | ||
946 | 1093 | ||
947 | /* higher bits of vertical timing values */ | 1094 | /* higher bits of vertical timing values */ |
948 | tmp = 0x10; | 1095 | tmp = 0x10; |
@@ -954,39 +1101,43 @@ static int tridentfb_set_par(struct fb_info *info) | |||
954 | if (vtotal & 0x200) tmp |= 0x20; | 1101 | if (vtotal & 0x200) tmp |= 0x20; |
955 | if (vdispend & 0x200) tmp |= 0x40; | 1102 | if (vdispend & 0x200) tmp |= 0x40; |
956 | if (vsyncstart & 0x200) tmp |= 0x80; | 1103 | if (vsyncstart & 0x200) tmp |= 0x80; |
957 | write3X4(CRTOverflow, tmp); | 1104 | write3X4(par, VGA_CRTC_OVERFLOW, tmp); |
958 | 1105 | ||
959 | tmp = read3X4(CRTHiOrd) | 0x08; /* line compare bit 10 */ | 1106 | tmp = read3X4(par, CRTHiOrd) & 0x07; |
1107 | tmp |= 0x08; /* line compare bit 10 */ | ||
960 | if (vtotal & 0x400) tmp |= 0x80; | 1108 | if (vtotal & 0x400) tmp |= 0x80; |
961 | if (vblankstart & 0x400) tmp |= 0x40; | 1109 | if (vblankstart & 0x400) tmp |= 0x40; |
962 | if (vsyncstart & 0x400) tmp |= 0x20; | 1110 | if (vsyncstart & 0x400) tmp |= 0x20; |
963 | if (vdispend & 0x400) tmp |= 0x10; | 1111 | if (vdispend & 0x400) tmp |= 0x10; |
964 | write3X4(CRTHiOrd, tmp); | 1112 | write3X4(par, CRTHiOrd, tmp); |
965 | 1113 | ||
966 | tmp = 0; | 1114 | tmp = (htotal >> 8) & 0x01; |
967 | if (htotal & 0x800) tmp |= 0x800 >> 11; | 1115 | tmp |= (hdispend >> 7) & 0x02; |
968 | if (hblankstart & 0x800) tmp |= 0x800 >> 7; | 1116 | tmp |= (hsyncstart >> 5) & 0x08; |
969 | write3X4(HorizOverflow, tmp); | 1117 | tmp |= (hblankstart >> 4) & 0x10; |
1118 | write3X4(par, HorizOverflow, tmp); | ||
970 | 1119 | ||
971 | tmp = 0x40; | 1120 | tmp = 0x40; |
972 | if (vblankstart & 0x200) tmp |= 0x20; | 1121 | if (vblankstart & 0x200) tmp |= 0x20; |
973 | //FIXME if (info->var.vmode & FB_VMODE_DOUBLE) tmp |= 0x80; /* double scan for 200 line modes */ | 1122 | //FIXME if (info->var.vmode & FB_VMODE_DOUBLE) tmp |= 0x80; /* double scan for 200 line modes */ |
974 | write3X4(CRTMaxScanLine, tmp); | 1123 | write3X4(par, VGA_CRTC_MAX_SCAN, tmp); |
975 | 1124 | ||
976 | write3X4(CRTLineCompare, 0xFF); | 1125 | write3X4(par, VGA_CRTC_LINE_COMPARE, 0xFF); |
977 | write3X4(CRTPRowScan, 0); | 1126 | write3X4(par, VGA_CRTC_PRESET_ROW, 0); |
978 | write3X4(CRTModeControl, 0xC3); | 1127 | write3X4(par, VGA_CRTC_MODE, 0xC3); |
979 | 1128 | ||
980 | write3X4(LinearAddReg, 0x20); /* enable linear addressing */ | 1129 | write3X4(par, LinearAddReg, 0x20); /* enable linear addressing */ |
981 | 1130 | ||
982 | tmp = (info->var.vmode & FB_VMODE_INTERLACED) ? 0x84 : 0x80; | 1131 | tmp = (info->var.vmode & FB_VMODE_INTERLACED) ? 0x84 : 0x80; |
983 | write3X4(CRTCModuleTest, tmp); /* enable access extended memory */ | 1132 | /* enable access extended memory */ |
984 | 1133 | write3X4(par, CRTCModuleTest, tmp); | |
985 | write3X4(GraphEngReg, 0x80); /* enable GE for text acceleration */ | 1134 | tmp = read3CE(par, MiscIntContReg) & ~0x4; |
1135 | if (info->var.vmode & FB_VMODE_INTERLACED) | ||
1136 | tmp |= 0x4; | ||
1137 | write3CE(par, MiscIntContReg, tmp); | ||
986 | 1138 | ||
987 | #ifdef CONFIG_FB_TRIDENT_ACCEL | 1139 | /* enable GE for text acceleration */ |
988 | acc->init_accel(info->var.xres, bpp); | 1140 | write3X4(par, GraphEngReg, 0x80); |
989 | #endif | ||
990 | 1141 | ||
991 | switch (bpp) { | 1142 | switch (bpp) { |
992 | case 8: | 1143 | case 8: |
@@ -1003,57 +1154,59 @@ static int tridentfb_set_par(struct fb_info *info) | |||
1003 | break; | 1154 | break; |
1004 | } | 1155 | } |
1005 | 1156 | ||
1006 | write3X4(PixelBusReg, tmp); | 1157 | write3X4(par, PixelBusReg, tmp); |
1007 | 1158 | ||
1008 | tmp = 0x10; | 1159 | tmp = read3X4(par, DRAMControl); |
1009 | if (chipcyber) | 1160 | if (!is_oldprotect(par->chip_id)) |
1161 | tmp |= 0x10; | ||
1162 | if (iscyber(par->chip_id)) | ||
1010 | tmp |= 0x20; | 1163 | tmp |= 0x20; |
1011 | write3X4(DRAMControl, tmp); /* both IO, linear enable */ | 1164 | write3X4(par, DRAMControl, tmp); /* both IO, linear enable */ |
1012 | 1165 | ||
1013 | write3X4(InterfaceSel, read3X4(InterfaceSel) | 0x40); | 1166 | write3X4(par, InterfaceSel, read3X4(par, InterfaceSel) | 0x40); |
1014 | write3X4(Performance, 0x92); | 1167 | if (!is_xp(par->chip_id)) |
1015 | write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */ | 1168 | write3X4(par, Performance, read3X4(par, Performance) | 0x10); |
1169 | /* MMIO & PCI read and write burst enable */ | ||
1170 | if (par->chip_id != TGUI9440 && par->chip_id != IMAGE975) | ||
1171 | write3X4(par, PCIReg, read3X4(par, PCIReg) | 0x06); | ||
1172 | |||
1173 | vga_mm_wseq(par->io_virt, 0, 3); | ||
1174 | vga_mm_wseq(par->io_virt, 1, 1); /* set char clock 8 dots wide */ | ||
1175 | /* enable 4 maps because needed in chain4 mode */ | ||
1176 | vga_mm_wseq(par->io_virt, 2, 0x0F); | ||
1177 | vga_mm_wseq(par->io_virt, 3, 0); | ||
1178 | vga_mm_wseq(par->io_virt, 4, 0x0E); /* memory mode enable bitmaps ?? */ | ||
1016 | 1179 | ||
1017 | /* convert from picoseconds to kHz */ | 1180 | /* convert from picoseconds to kHz */ |
1018 | vclk = PICOS2KHZ(info->var.pixclock); | 1181 | vclk = PICOS2KHZ(info->var.pixclock); |
1019 | if (bpp == 32) | 1182 | |
1183 | /* divide clock by 2 if 32bpp chain4 mode display and CPU path */ | ||
1184 | tmp = read3CE(par, MiscExtFunc) & 0xF0; | ||
1185 | if (bpp == 32 || (par->chip_id == TGUI9440 && bpp == 16)) { | ||
1186 | tmp |= 8; | ||
1020 | vclk *= 2; | 1187 | vclk *= 2; |
1021 | set_vclk(vclk); | ||
1022 | |||
1023 | write3C4(0, 3); | ||
1024 | write3C4(1, 1); /* set char clock 8 dots wide */ | ||
1025 | write3C4(2, 0x0F); /* enable 4 maps because needed in chain4 mode */ | ||
1026 | write3C4(3, 0); | ||
1027 | write3C4(4, 0x0E); /* memory mode enable bitmaps ?? */ | ||
1028 | |||
1029 | write3CE(MiscExtFunc, (bpp == 32) ? 0x1A : 0x12); /* divide clock by 2 if 32bpp */ | ||
1030 | /* chain4 mode display and CPU path */ | ||
1031 | write3CE(0x5, 0x40); /* no CGA compat, allow 256 col */ | ||
1032 | write3CE(0x6, 0x05); /* graphics mode */ | ||
1033 | write3CE(0x7, 0x0F); /* planes? */ | ||
1034 | |||
1035 | if (chip_id == CYBERBLADEXPAi1) { | ||
1036 | /* This fixes snow-effect in 32 bpp */ | ||
1037 | write3X4(CRTHSyncStart, 0x84); | ||
1038 | } | 1188 | } |
1189 | set_vclk(par, vclk); | ||
1190 | write3CE(par, MiscExtFunc, tmp | 0x12); | ||
1191 | write3CE(par, 0x5, 0x40); /* no CGA compat, allow 256 col */ | ||
1192 | write3CE(par, 0x6, 0x05); /* graphics mode */ | ||
1193 | write3CE(par, 0x7, 0x0F); /* planes? */ | ||
1039 | 1194 | ||
1040 | writeAttr(0x10, 0x41); /* graphics mode and support 256 color modes */ | 1195 | /* graphics mode and support 256 color modes */ |
1041 | writeAttr(0x12, 0x0F); /* planes */ | 1196 | writeAttr(par, 0x10, 0x41); |
1042 | writeAttr(0x13, 0); /* horizontal pel panning */ | 1197 | writeAttr(par, 0x12, 0x0F); /* planes */ |
1198 | writeAttr(par, 0x13, 0); /* horizontal pel panning */ | ||
1043 | 1199 | ||
1044 | /* colors */ | 1200 | /* colors */ |
1045 | for (tmp = 0; tmp < 0x10; tmp++) | 1201 | for (tmp = 0; tmp < 0x10; tmp++) |
1046 | writeAttr(tmp, tmp); | 1202 | writeAttr(par, tmp, tmp); |
1047 | readb(par->io_virt + CRT + 0x0A); /* flip-flop to index */ | 1203 | fb_readb(par->io_virt + VGA_IS1_RC); /* flip-flop to index */ |
1048 | t_outb(0x20, 0x3C0); /* enable attr */ | 1204 | t_outb(par, 0x20, VGA_ATT_W); /* enable attr */ |
1049 | 1205 | ||
1050 | switch (bpp) { | 1206 | switch (bpp) { |
1051 | case 8: | 1207 | case 8: |
1052 | tmp = 0; | 1208 | tmp = 0; |
1053 | break; | 1209 | break; |
1054 | case 15: | ||
1055 | tmp = 0x10; | ||
1056 | break; | ||
1057 | case 16: | 1210 | case 16: |
1058 | tmp = 0x30; | 1211 | tmp = 0x30; |
1059 | break; | 1212 | break; |
@@ -1063,19 +1216,23 @@ static int tridentfb_set_par(struct fb_info *info) | |||
1063 | break; | 1216 | break; |
1064 | } | 1217 | } |
1065 | 1218 | ||
1066 | t_inb(0x3C8); | 1219 | t_inb(par, VGA_PEL_IW); |
1067 | t_inb(0x3C6); | 1220 | t_inb(par, VGA_PEL_MSK); |
1068 | t_inb(0x3C6); | 1221 | t_inb(par, VGA_PEL_MSK); |
1069 | t_inb(0x3C6); | 1222 | t_inb(par, VGA_PEL_MSK); |
1070 | t_inb(0x3C6); | 1223 | t_inb(par, VGA_PEL_MSK); |
1071 | t_outb(tmp, 0x3C6); | 1224 | t_outb(par, tmp, VGA_PEL_MSK); |
1072 | t_inb(0x3C8); | 1225 | t_inb(par, VGA_PEL_IW); |
1073 | 1226 | ||
1074 | if (flatpanel) | 1227 | if (par->flatpanel) |
1075 | set_number_of_lines(info->var.yres); | 1228 | set_number_of_lines(par, info->var.yres); |
1076 | set_lwidth(info->var.xres * bpp / (4 * 16)); | 1229 | info->fix.line_length = info->var.xres_virtual * bpp / 8; |
1230 | set_lwidth(par, info->fix.line_length / 8); | ||
1231 | |||
1232 | if (!(info->flags & FBINFO_HWACCEL_DISABLED)) | ||
1233 | par->init_accel(par, info->var.xres_virtual, bpp); | ||
1234 | |||
1077 | info->fix.visual = (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; | 1235 | info->fix.visual = (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
1078 | info->fix.line_length = info->var.xres * (bpp >> 3); | ||
1079 | info->cmap.len = (bpp == 8) ? 256 : 16; | 1236 | info->cmap.len = (bpp == 8) ? 256 : 16; |
1080 | debug("exit\n"); | 1237 | debug("exit\n"); |
1081 | return 0; | 1238 | return 0; |
@@ -1087,17 +1244,18 @@ static int tridentfb_setcolreg(unsigned regno, unsigned red, unsigned green, | |||
1087 | struct fb_info *info) | 1244 | struct fb_info *info) |
1088 | { | 1245 | { |
1089 | int bpp = info->var.bits_per_pixel; | 1246 | int bpp = info->var.bits_per_pixel; |
1247 | struct tridentfb_par *par = info->par; | ||
1090 | 1248 | ||
1091 | if (regno >= info->cmap.len) | 1249 | if (regno >= info->cmap.len) |
1092 | return 1; | 1250 | return 1; |
1093 | 1251 | ||
1094 | if (bpp == 8) { | 1252 | if (bpp == 8) { |
1095 | t_outb(0xFF, 0x3C6); | 1253 | t_outb(par, 0xFF, VGA_PEL_MSK); |
1096 | t_outb(regno, 0x3C8); | 1254 | t_outb(par, regno, VGA_PEL_IW); |
1097 | 1255 | ||
1098 | t_outb(red >> 10, 0x3C9); | 1256 | t_outb(par, red >> 10, VGA_PEL_D); |
1099 | t_outb(green >> 10, 0x3C9); | 1257 | t_outb(par, green >> 10, VGA_PEL_D); |
1100 | t_outb(blue >> 10, 0x3C9); | 1258 | t_outb(par, blue >> 10, VGA_PEL_D); |
1101 | 1259 | ||
1102 | } else if (regno < 16) { | 1260 | } else if (regno < 16) { |
1103 | if (bpp == 16) { /* RGB 565 */ | 1261 | if (bpp == 16) { /* RGB 565 */ |
@@ -1108,28 +1266,28 @@ static int tridentfb_setcolreg(unsigned regno, unsigned red, unsigned green, | |||
1108 | col |= col << 16; | 1266 | col |= col << 16; |
1109 | ((u32 *)(info->pseudo_palette))[regno] = col; | 1267 | ((u32 *)(info->pseudo_palette))[regno] = col; |
1110 | } else if (bpp == 32) /* ARGB 8888 */ | 1268 | } else if (bpp == 32) /* ARGB 8888 */ |
1111 | ((u32*)info->pseudo_palette)[regno] = | 1269 | ((u32 *)info->pseudo_palette)[regno] = |
1112 | ((transp & 0xFF00) << 16) | | 1270 | ((transp & 0xFF00) << 16) | |
1113 | ((red & 0xFF00) << 8) | | 1271 | ((red & 0xFF00) << 8) | |
1114 | ((green & 0xFF00)) | | 1272 | ((green & 0xFF00)) | |
1115 | ((blue & 0xFF00) >> 8); | 1273 | ((blue & 0xFF00) >> 8); |
1116 | } | 1274 | } |
1117 | 1275 | ||
1118 | /* debug("exit\n"); */ | ||
1119 | return 0; | 1276 | return 0; |
1120 | } | 1277 | } |
1121 | 1278 | ||
1122 | /* Try blanking the screen.For flat panels it does nothing */ | 1279 | /* Try blanking the screen. For flat panels it does nothing */ |
1123 | static int tridentfb_blank(int blank_mode, struct fb_info *info) | 1280 | static int tridentfb_blank(int blank_mode, struct fb_info *info) |
1124 | { | 1281 | { |
1125 | unsigned char PMCont, DPMSCont; | 1282 | unsigned char PMCont, DPMSCont; |
1283 | struct tridentfb_par *par = info->par; | ||
1126 | 1284 | ||
1127 | debug("enter\n"); | 1285 | debug("enter\n"); |
1128 | if (flatpanel) | 1286 | if (par->flatpanel) |
1129 | return 0; | 1287 | return 0; |
1130 | t_outb(0x04, 0x83C8); /* Read DPMS Control */ | 1288 | t_outb(par, 0x04, 0x83C8); /* Read DPMS Control */ |
1131 | PMCont = t_inb(0x83C6) & 0xFC; | 1289 | PMCont = t_inb(par, 0x83C6) & 0xFC; |
1132 | DPMSCont = read3CE(PowerStatus) & 0xFC; | 1290 | DPMSCont = read3CE(par, PowerStatus) & 0xFC; |
1133 | switch (blank_mode) { | 1291 | switch (blank_mode) { |
1134 | case FB_BLANK_UNBLANK: | 1292 | case FB_BLANK_UNBLANK: |
1135 | /* Screen: On, HSync: On, VSync: On */ | 1293 | /* Screen: On, HSync: On, VSync: On */ |
@@ -1155,9 +1313,9 @@ static int tridentfb_blank(int blank_mode, struct fb_info *info) | |||
1155 | break; | 1313 | break; |
1156 | } | 1314 | } |
1157 | 1315 | ||
1158 | write3CE(PowerStatus, DPMSCont); | 1316 | write3CE(par, PowerStatus, DPMSCont); |
1159 | t_outb(4, 0x83C8); | 1317 | t_outb(par, 4, 0x83C8); |
1160 | t_outb(PMCont, 0x83C6); | 1318 | t_outb(par, PMCont, 0x83C6); |
1161 | 1319 | ||
1162 | debug("exit\n"); | 1320 | debug("exit\n"); |
1163 | 1321 | ||
@@ -1174,33 +1332,46 @@ static struct fb_ops tridentfb_ops = { | |||
1174 | .fb_set_par = tridentfb_set_par, | 1332 | .fb_set_par = tridentfb_set_par, |
1175 | .fb_fillrect = tridentfb_fillrect, | 1333 | .fb_fillrect = tridentfb_fillrect, |
1176 | .fb_copyarea = tridentfb_copyarea, | 1334 | .fb_copyarea = tridentfb_copyarea, |
1177 | .fb_imageblit = cfb_imageblit, | 1335 | .fb_imageblit = tridentfb_imageblit, |
1336 | #ifdef CONFIG_FB_TRIDENT_ACCEL | ||
1337 | .fb_sync = tridentfb_sync, | ||
1338 | #endif | ||
1178 | }; | 1339 | }; |
1179 | 1340 | ||
1180 | static int __devinit trident_pci_probe(struct pci_dev * dev, | 1341 | static int __devinit trident_pci_probe(struct pci_dev *dev, |
1181 | const struct pci_device_id * id) | 1342 | const struct pci_device_id *id) |
1182 | { | 1343 | { |
1183 | int err; | 1344 | int err; |
1184 | unsigned char revision; | 1345 | unsigned char revision; |
1346 | struct fb_info *info; | ||
1347 | struct tridentfb_par *default_par; | ||
1348 | int chip3D; | ||
1349 | int chip_id; | ||
1185 | 1350 | ||
1186 | err = pci_enable_device(dev); | 1351 | err = pci_enable_device(dev); |
1187 | if (err) | 1352 | if (err) |
1188 | return err; | 1353 | return err; |
1189 | 1354 | ||
1190 | chip_id = id->device; | 1355 | info = framebuffer_alloc(sizeof(struct tridentfb_par), &dev->dev); |
1356 | if (!info) | ||
1357 | return -ENOMEM; | ||
1358 | default_par = info->par; | ||
1191 | 1359 | ||
1192 | if (chip_id == CYBERBLADEi1) | 1360 | chip_id = id->device; |
1193 | output("*** Please do use cyblafb, Cyberblade/i1 support " | ||
1194 | "will soon be removed from tridentfb!\n"); | ||
1195 | 1361 | ||
1362 | #ifndef CONFIG_FB_TRIDENT_ACCEL | ||
1363 | noaccel = 1; | ||
1364 | #endif | ||
1196 | 1365 | ||
1197 | /* If PCI id is 0x9660 then further detect chip type */ | 1366 | /* If PCI id is 0x9660 then further detect chip type */ |
1198 | 1367 | ||
1199 | if (chip_id == TGUI9660) { | 1368 | if (chip_id == TGUI9660) { |
1200 | outb(RevisionID, 0x3C4); | 1369 | revision = vga_io_rseq(RevisionID); |
1201 | revision = inb(0x3C5); | ||
1202 | 1370 | ||
1203 | switch (revision) { | 1371 | switch (revision) { |
1372 | case 0x21: | ||
1373 | chip_id = PROVIDIA9685; | ||
1374 | break; | ||
1204 | case 0x22: | 1375 | case 0x22: |
1205 | case 0x23: | 1376 | case 0x23: |
1206 | chip_id = CYBER9397; | 1377 | chip_id = CYBER9397; |
@@ -1229,123 +1400,170 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, | |||
1229 | } | 1400 | } |
1230 | 1401 | ||
1231 | chip3D = is3Dchip(chip_id); | 1402 | chip3D = is3Dchip(chip_id); |
1232 | chipcyber = iscyber(chip_id); | ||
1233 | 1403 | ||
1234 | if (is_xp(chip_id)) { | 1404 | if (is_xp(chip_id)) { |
1235 | acc = &accel_xp; | 1405 | default_par->init_accel = xp_init_accel; |
1406 | default_par->wait_engine = xp_wait_engine; | ||
1407 | default_par->fill_rect = xp_fill_rect; | ||
1408 | default_par->copy_rect = xp_copy_rect; | ||
1409 | tridentfb_fix.accel = FB_ACCEL_TRIDENT_BLADEXP; | ||
1236 | } else if (is_blade(chip_id)) { | 1410 | } else if (is_blade(chip_id)) { |
1237 | acc = &accel_blade; | 1411 | default_par->init_accel = blade_init_accel; |
1238 | } else { | 1412 | default_par->wait_engine = blade_wait_engine; |
1239 | acc = &accel_image; | 1413 | default_par->fill_rect = blade_fill_rect; |
1414 | default_par->copy_rect = blade_copy_rect; | ||
1415 | default_par->image_blit = blade_image_blit; | ||
1416 | tridentfb_fix.accel = FB_ACCEL_TRIDENT_BLADE3D; | ||
1417 | } else if (chip3D) { /* 3DImage family left */ | ||
1418 | default_par->init_accel = image_init_accel; | ||
1419 | default_par->wait_engine = image_wait_engine; | ||
1420 | default_par->fill_rect = image_fill_rect; | ||
1421 | default_par->copy_rect = image_copy_rect; | ||
1422 | tridentfb_fix.accel = FB_ACCEL_TRIDENT_3DIMAGE; | ||
1423 | } else { /* TGUI 9440/96XX family */ | ||
1424 | default_par->init_accel = tgui_init_accel; | ||
1425 | default_par->wait_engine = xp_wait_engine; | ||
1426 | default_par->fill_rect = tgui_fill_rect; | ||
1427 | default_par->copy_rect = tgui_copy_rect; | ||
1428 | tridentfb_fix.accel = FB_ACCEL_TRIDENT_TGUI; | ||
1240 | } | 1429 | } |
1241 | 1430 | ||
1242 | /* acceleration is on by default for 3D chips */ | 1431 | default_par->chip_id = chip_id; |
1243 | defaultaccel = chip3D && !noaccel; | ||
1244 | |||
1245 | fb_info.par = &default_par; | ||
1246 | 1432 | ||
1247 | /* setup MMIO region */ | 1433 | /* setup MMIO region */ |
1248 | tridentfb_fix.mmio_start = pci_resource_start(dev, 1); | 1434 | tridentfb_fix.mmio_start = pci_resource_start(dev, 1); |
1249 | tridentfb_fix.mmio_len = chip3D ? 0x20000 : 0x10000; | 1435 | tridentfb_fix.mmio_len = pci_resource_len(dev, 1); |
1250 | 1436 | ||
1251 | if (!request_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len, "tridentfb")) { | 1437 | if (!request_mem_region(tridentfb_fix.mmio_start, |
1438 | tridentfb_fix.mmio_len, "tridentfb")) { | ||
1252 | debug("request_region failed!\n"); | 1439 | debug("request_region failed!\n"); |
1440 | framebuffer_release(info); | ||
1253 | return -1; | 1441 | return -1; |
1254 | } | 1442 | } |
1255 | 1443 | ||
1256 | default_par.io_virt = ioremap_nocache(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); | 1444 | default_par->io_virt = ioremap_nocache(tridentfb_fix.mmio_start, |
1445 | tridentfb_fix.mmio_len); | ||
1257 | 1446 | ||
1258 | if (!default_par.io_virt) { | 1447 | if (!default_par->io_virt) { |
1259 | debug("ioremap failed\n"); | 1448 | debug("ioremap failed\n"); |
1260 | err = -1; | 1449 | err = -1; |
1261 | goto out_unmap1; | 1450 | goto out_unmap1; |
1262 | } | 1451 | } |
1263 | 1452 | ||
1264 | enable_mmio(); | 1453 | enable_mmio(default_par); |
1265 | 1454 | ||
1266 | /* setup framebuffer memory */ | 1455 | /* setup framebuffer memory */ |
1267 | tridentfb_fix.smem_start = pci_resource_start(dev, 0); | 1456 | tridentfb_fix.smem_start = pci_resource_start(dev, 0); |
1268 | tridentfb_fix.smem_len = get_memsize(); | 1457 | tridentfb_fix.smem_len = get_memsize(default_par); |
1269 | 1458 | ||
1270 | if (!request_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len, "tridentfb")) { | 1459 | if (!request_mem_region(tridentfb_fix.smem_start, |
1460 | tridentfb_fix.smem_len, "tridentfb")) { | ||
1271 | debug("request_mem_region failed!\n"); | 1461 | debug("request_mem_region failed!\n"); |
1272 | disable_mmio(); | 1462 | disable_mmio(info->par); |
1273 | err = -1; | 1463 | err = -1; |
1274 | goto out_unmap1; | 1464 | goto out_unmap1; |
1275 | } | 1465 | } |
1276 | 1466 | ||
1277 | fb_info.screen_base = ioremap_nocache(tridentfb_fix.smem_start, | 1467 | info->screen_base = ioremap_nocache(tridentfb_fix.smem_start, |
1278 | tridentfb_fix.smem_len); | 1468 | tridentfb_fix.smem_len); |
1279 | 1469 | ||
1280 | if (!fb_info.screen_base) { | 1470 | if (!info->screen_base) { |
1281 | debug("ioremap failed\n"); | 1471 | debug("ioremap failed\n"); |
1282 | err = -1; | 1472 | err = -1; |
1283 | goto out_unmap2; | 1473 | goto out_unmap2; |
1284 | } | 1474 | } |
1285 | 1475 | ||
1286 | output("%s board found\n", pci_name(dev)); | 1476 | default_par->flatpanel = is_flatpanel(default_par); |
1287 | displaytype = get_displaytype(); | ||
1288 | 1477 | ||
1289 | if (flatpanel) | 1478 | if (default_par->flatpanel) |
1290 | nativex = get_nativex(); | 1479 | nativex = get_nativex(default_par); |
1291 | 1480 | ||
1292 | fb_info.fix = tridentfb_fix; | 1481 | info->fix = tridentfb_fix; |
1293 | fb_info.fbops = &tridentfb_ops; | 1482 | info->fbops = &tridentfb_ops; |
1483 | info->pseudo_palette = default_par->pseudo_pal; | ||
1294 | 1484 | ||
1485 | info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; | ||
1486 | if (!noaccel && default_par->init_accel) { | ||
1487 | info->flags &= ~FBINFO_HWACCEL_DISABLED; | ||
1488 | info->flags |= FBINFO_HWACCEL_COPYAREA; | ||
1489 | info->flags |= FBINFO_HWACCEL_FILLRECT; | ||
1490 | } else | ||
1491 | info->flags |= FBINFO_HWACCEL_DISABLED; | ||
1295 | 1492 | ||
1296 | fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; | 1493 | info->pixmap.addr = kmalloc(4096, GFP_KERNEL); |
1297 | #ifdef CONFIG_FB_TRIDENT_ACCEL | 1494 | if (!info->pixmap.addr) { |
1298 | fb_info.flags |= FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; | 1495 | err = -ENOMEM; |
1299 | #endif | 1496 | goto out_unmap2; |
1300 | fb_info.pseudo_palette = pseudo_pal; | 1497 | } |
1498 | |||
1499 | info->pixmap.size = 4096; | ||
1500 | info->pixmap.buf_align = 4; | ||
1501 | info->pixmap.scan_align = 1; | ||
1502 | info->pixmap.access_align = 32; | ||
1503 | info->pixmap.flags = FB_PIXMAP_SYSTEM; | ||
1301 | 1504 | ||
1302 | if (!fb_find_mode(&default_var, &fb_info, | 1505 | if (default_par->image_blit) { |
1506 | info->flags |= FBINFO_HWACCEL_IMAGEBLIT; | ||
1507 | info->pixmap.scan_align = 4; | ||
1508 | } | ||
1509 | |||
1510 | if (noaccel) { | ||
1511 | printk(KERN_DEBUG "disabling acceleration\n"); | ||
1512 | info->flags |= FBINFO_HWACCEL_DISABLED; | ||
1513 | info->pixmap.scan_align = 1; | ||
1514 | } | ||
1515 | |||
1516 | if (!fb_find_mode(&info->var, info, | ||
1303 | mode_option, NULL, 0, NULL, bpp)) { | 1517 | mode_option, NULL, 0, NULL, bpp)) { |
1304 | err = -EINVAL; | 1518 | err = -EINVAL; |
1305 | goto out_unmap2; | 1519 | goto out_unmap2; |
1306 | } | 1520 | } |
1307 | err = fb_alloc_cmap(&fb_info.cmap, 256, 0); | 1521 | err = fb_alloc_cmap(&info->cmap, 256, 0); |
1308 | if (err < 0) | 1522 | if (err < 0) |
1309 | goto out_unmap2; | 1523 | goto out_unmap2; |
1310 | 1524 | ||
1311 | if (defaultaccel && acc) | 1525 | info->var.activate |= FB_ACTIVATE_NOW; |
1312 | default_var.accel_flags |= FB_ACCELF_TEXT; | 1526 | info->device = &dev->dev; |
1313 | else | 1527 | if (register_framebuffer(info) < 0) { |
1314 | default_var.accel_flags &= ~FB_ACCELF_TEXT; | 1528 | printk(KERN_ERR "tridentfb: could not register framebuffer\n"); |
1315 | default_var.activate |= FB_ACTIVATE_NOW; | 1529 | fb_dealloc_cmap(&info->cmap); |
1316 | fb_info.var = default_var; | ||
1317 | fb_info.device = &dev->dev; | ||
1318 | if (register_framebuffer(&fb_info) < 0) { | ||
1319 | printk(KERN_ERR "tridentfb: could not register Trident framebuffer\n"); | ||
1320 | fb_dealloc_cmap(&fb_info.cmap); | ||
1321 | err = -EINVAL; | 1530 | err = -EINVAL; |
1322 | goto out_unmap2; | 1531 | goto out_unmap2; |
1323 | } | 1532 | } |
1324 | output("fb%d: %s frame buffer device %dx%d-%dbpp\n", | 1533 | output("fb%d: %s frame buffer device %dx%d-%dbpp\n", |
1325 | fb_info.node, fb_info.fix.id, default_var.xres, | 1534 | info->node, info->fix.id, info->var.xres, |
1326 | default_var.yres, default_var.bits_per_pixel); | 1535 | info->var.yres, info->var.bits_per_pixel); |
1536 | |||
1537 | pci_set_drvdata(dev, info); | ||
1327 | return 0; | 1538 | return 0; |
1328 | 1539 | ||
1329 | out_unmap2: | 1540 | out_unmap2: |
1330 | if (fb_info.screen_base) | 1541 | kfree(info->pixmap.addr); |
1331 | iounmap(fb_info.screen_base); | 1542 | if (info->screen_base) |
1543 | iounmap(info->screen_base); | ||
1332 | release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len); | 1544 | release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len); |
1333 | disable_mmio(); | 1545 | disable_mmio(info->par); |
1334 | out_unmap1: | 1546 | out_unmap1: |
1335 | if (default_par.io_virt) | 1547 | if (default_par->io_virt) |
1336 | iounmap(default_par.io_virt); | 1548 | iounmap(default_par->io_virt); |
1337 | release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); | 1549 | release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); |
1550 | framebuffer_release(info); | ||
1338 | return err; | 1551 | return err; |
1339 | } | 1552 | } |
1340 | 1553 | ||
1341 | static void __devexit trident_pci_remove(struct pci_dev *dev) | 1554 | static void __devexit trident_pci_remove(struct pci_dev *dev) |
1342 | { | 1555 | { |
1343 | struct tridentfb_par *par = (struct tridentfb_par*)fb_info.par; | 1556 | struct fb_info *info = pci_get_drvdata(dev); |
1344 | unregister_framebuffer(&fb_info); | 1557 | struct tridentfb_par *par = info->par; |
1558 | |||
1559 | unregister_framebuffer(info); | ||
1345 | iounmap(par->io_virt); | 1560 | iounmap(par->io_virt); |
1346 | iounmap(fb_info.screen_base); | 1561 | iounmap(info->screen_base); |
1347 | release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len); | 1562 | release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len); |
1348 | release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); | 1563 | release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); |
1564 | pci_set_drvdata(dev, NULL); | ||
1565 | kfree(info->pixmap.addr); | ||
1566 | framebuffer_release(info); | ||
1349 | } | 1567 | } |
1350 | 1568 | ||
1351 | /* List of boards that we are trying to support */ | 1569 | /* List of boards that we are trying to support */ |
@@ -1358,6 +1576,7 @@ static struct pci_device_id trident_devices[] = { | |||
1358 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 1576 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
1359 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 1577 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
1360 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEE4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 1578 | {PCI_VENDOR_ID_TRIDENT, CYBERBLADEE4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
1579 | {PCI_VENDOR_ID_TRIDENT, TGUI9440, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | ||
1361 | {PCI_VENDOR_ID_TRIDENT, TGUI9660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 1580 | {PCI_VENDOR_ID_TRIDENT, TGUI9660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
1362 | {PCI_VENDOR_ID_TRIDENT, IMAGE975, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 1581 | {PCI_VENDOR_ID_TRIDENT, IMAGE975, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
1363 | {PCI_VENDOR_ID_TRIDENT, IMAGE985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 1582 | {PCI_VENDOR_ID_TRIDENT, IMAGE985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
@@ -1399,9 +1618,9 @@ static int __init tridentfb_setup(char *options) | |||
1399 | if (!strncmp(opt, "noaccel", 7)) | 1618 | if (!strncmp(opt, "noaccel", 7)) |
1400 | noaccel = 1; | 1619 | noaccel = 1; |
1401 | else if (!strncmp(opt, "fp", 2)) | 1620 | else if (!strncmp(opt, "fp", 2)) |
1402 | displaytype = DISPLAY_FP; | 1621 | fp = 1; |
1403 | else if (!strncmp(opt, "crt", 3)) | 1622 | else if (!strncmp(opt, "crt", 3)) |
1404 | displaytype = DISPLAY_CRT; | 1623 | fp = 0; |
1405 | else if (!strncmp(opt, "bpp=", 4)) | 1624 | else if (!strncmp(opt, "bpp=", 4)) |
1406 | bpp = simple_strtoul(opt + 4, NULL, 0); | 1625 | bpp = simple_strtoul(opt + 4, NULL, 0); |
1407 | else if (!strncmp(opt, "center", 6)) | 1626 | else if (!strncmp(opt, "center", 6)) |
@@ -1430,7 +1649,6 @@ static int __init tridentfb_init(void) | |||
1430 | return -ENODEV; | 1649 | return -ENODEV; |
1431 | tridentfb_setup(option); | 1650 | tridentfb_setup(option); |
1432 | #endif | 1651 | #endif |
1433 | output("Trident framebuffer %s initializing\n", VERSION); | ||
1434 | return pci_register_driver(&tridentfb_pci_driver); | 1652 | return pci_register_driver(&tridentfb_pci_driver); |
1435 | } | 1653 | } |
1436 | 1654 | ||
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c index cdbb56edb6cb..50744229c7a9 100644 --- a/drivers/video/uvesafb.c +++ b/drivers/video/uvesafb.c | |||
@@ -2054,8 +2054,8 @@ MODULE_PARM_DESC(maxhf, | |||
2054 | module_param(maxvf, ushort, 0); | 2054 | module_param(maxvf, ushort, 0); |
2055 | MODULE_PARM_DESC(maxvf, | 2055 | MODULE_PARM_DESC(maxvf, |
2056 | "Maximum vertical frequency [Hz], overrides EDID data"); | 2056 | "Maximum vertical frequency [Hz], overrides EDID data"); |
2057 | module_param_named(mode, mode_option, charp, 0); | 2057 | module_param(mode_option, charp, 0); |
2058 | MODULE_PARM_DESC(mode, | 2058 | MODULE_PARM_DESC(mode_option, |
2059 | "Specify initial video mode as \"<xres>x<yres>[-<bpp>][@<refresh>]\""); | 2059 | "Specify initial video mode as \"<xres>x<yres>[-<bpp>][@<refresh>]\""); |
2060 | module_param(vbemode, ushort, 0); | 2060 | module_param(vbemode, ushort, 0); |
2061 | MODULE_PARM_DESC(vbemode, | 2061 | MODULE_PARM_DESC(vbemode, |
diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c index 072638a9528a..93fe08d6c78f 100644 --- a/drivers/video/vfb.c +++ b/drivers/video/vfb.c | |||
@@ -443,19 +443,29 @@ static int vfb_mmap(struct fb_info *info, | |||
443 | } | 443 | } |
444 | 444 | ||
445 | #ifndef MODULE | 445 | #ifndef MODULE |
446 | /* | ||
447 | * The virtual framebuffer driver is only enabled if explicitly | ||
448 | * requested by passing 'video=vfb:' (or any actual options). | ||
449 | */ | ||
446 | static int __init vfb_setup(char *options) | 450 | static int __init vfb_setup(char *options) |
447 | { | 451 | { |
448 | char *this_opt; | 452 | char *this_opt; |
449 | 453 | ||
454 | vfb_enable = 0; | ||
455 | |||
456 | if (!options) | ||
457 | return 1; | ||
458 | |||
450 | vfb_enable = 1; | 459 | vfb_enable = 1; |
451 | 460 | ||
452 | if (!options || !*options) | 461 | if (!*options) |
453 | return 1; | 462 | return 1; |
454 | 463 | ||
455 | while ((this_opt = strsep(&options, ",")) != NULL) { | 464 | while ((this_opt = strsep(&options, ",")) != NULL) { |
456 | if (!*this_opt) | 465 | if (!*this_opt) |
457 | continue; | 466 | continue; |
458 | if (!strncmp(this_opt, "disable", 7)) | 467 | /* Test disable for backwards compatibility */ |
468 | if (!strcmp(this_opt, "disable")) | ||
459 | vfb_enable = 0; | 469 | vfb_enable = 0; |
460 | } | 470 | } |
461 | return 1; | 471 | return 1; |
diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c index 9b3c5923365e..e31bca8a0cb2 100644 --- a/drivers/video/vga16fb.c +++ b/drivers/video/vga16fb.c | |||
@@ -26,18 +26,6 @@ | |||
26 | #include <asm/io.h> | 26 | #include <asm/io.h> |
27 | #include <video/vga.h> | 27 | #include <video/vga.h> |
28 | 28 | ||
29 | #define GRAPHICS_ADDR_REG VGA_GFX_I /* Graphics address register. */ | ||
30 | #define GRAPHICS_DATA_REG VGA_GFX_D /* Graphics data register. */ | ||
31 | |||
32 | #define SET_RESET_INDEX VGA_GFX_SR_VALUE /* Set/Reset Register index. */ | ||
33 | #define ENABLE_SET_RESET_INDEX VGA_GFX_SR_ENABLE /* Enable Set/Reset Register index. */ | ||
34 | #define DATA_ROTATE_INDEX VGA_GFX_DATA_ROTATE /* Data Rotate Register index. */ | ||
35 | #define GRAPHICS_MODE_INDEX VGA_GFX_MODE /* Graphics Mode Register index. */ | ||
36 | #define BIT_MASK_INDEX VGA_GFX_BIT_MASK /* Bit Mask Register index. */ | ||
37 | |||
38 | #define dac_reg (VGA_PEL_IW) | ||
39 | #define dac_val (VGA_PEL_D) | ||
40 | |||
41 | #define VGA_FB_PHYS 0xA0000 | 29 | #define VGA_FB_PHYS 0xA0000 |
42 | #define VGA_FB_PHYS_LEN 65536 | 30 | #define VGA_FB_PHYS_LEN 65536 |
43 | 31 | ||
@@ -108,7 +96,7 @@ static struct fb_fix_screeninfo vga16fb_fix __initdata = { | |||
108 | .visual = FB_VISUAL_PSEUDOCOLOR, | 96 | .visual = FB_VISUAL_PSEUDOCOLOR, |
109 | .xpanstep = 8, | 97 | .xpanstep = 8, |
110 | .ypanstep = 1, | 98 | .ypanstep = 1, |
111 | .line_length = 640/8, | 99 | .line_length = 640 / 8, |
112 | .accel = FB_ACCEL_NONE | 100 | .accel = FB_ACCEL_NONE |
113 | }; | 101 | }; |
114 | 102 | ||
@@ -135,23 +123,22 @@ static inline int setmode(int mode) | |||
135 | { | 123 | { |
136 | int oldmode; | 124 | int oldmode; |
137 | 125 | ||
138 | vga_io_w(GRAPHICS_ADDR_REG, GRAPHICS_MODE_INDEX); | 126 | oldmode = vga_io_rgfx(VGA_GFX_MODE); |
139 | oldmode = vga_io_r(GRAPHICS_DATA_REG); | 127 | vga_io_w(VGA_GFX_D, mode); |
140 | vga_io_w(GRAPHICS_DATA_REG, mode); | ||
141 | return oldmode; | 128 | return oldmode; |
142 | } | 129 | } |
143 | 130 | ||
144 | /* Select the Bit Mask Register and return its value. */ | 131 | /* Select the Bit Mask Register and return its value. */ |
145 | static inline int selectmask(void) | 132 | static inline int selectmask(void) |
146 | { | 133 | { |
147 | return vga_io_rgfx(BIT_MASK_INDEX); | 134 | return vga_io_rgfx(VGA_GFX_BIT_MASK); |
148 | } | 135 | } |
149 | 136 | ||
150 | /* Set the value of the Bit Mask Register. It must already have been | 137 | /* Set the value of the Bit Mask Register. It must already have been |
151 | selected with selectmask(). */ | 138 | selected with selectmask(). */ |
152 | static inline void setmask(int mask) | 139 | static inline void setmask(int mask) |
153 | { | 140 | { |
154 | vga_io_w(GRAPHICS_DATA_REG, mask); | 141 | vga_io_w(VGA_GFX_D, mask); |
155 | } | 142 | } |
156 | 143 | ||
157 | /* Set the Data Rotate Register and return its old value. | 144 | /* Set the Data Rotate Register and return its old value. |
@@ -161,9 +148,8 @@ static inline int setop(int op) | |||
161 | { | 148 | { |
162 | int oldop; | 149 | int oldop; |
163 | 150 | ||
164 | vga_io_w(GRAPHICS_ADDR_REG, DATA_ROTATE_INDEX); | 151 | oldop = vga_io_rgfx(VGA_GFX_DATA_ROTATE); |
165 | oldop = vga_io_r(GRAPHICS_DATA_REG); | 152 | vga_io_w(VGA_GFX_D, op); |
166 | vga_io_w(GRAPHICS_DATA_REG, op); | ||
167 | return oldop; | 153 | return oldop; |
168 | } | 154 | } |
169 | 155 | ||
@@ -173,9 +159,8 @@ static inline int setsr(int sr) | |||
173 | { | 159 | { |
174 | int oldsr; | 160 | int oldsr; |
175 | 161 | ||
176 | vga_io_w(GRAPHICS_ADDR_REG, ENABLE_SET_RESET_INDEX); | 162 | oldsr = vga_io_rgfx(VGA_GFX_SR_ENABLE); |
177 | oldsr = vga_io_r(GRAPHICS_DATA_REG); | 163 | vga_io_w(VGA_GFX_D, sr); |
178 | vga_io_w(GRAPHICS_DATA_REG, sr); | ||
179 | return oldsr; | 164 | return oldsr; |
180 | } | 165 | } |
181 | 166 | ||
@@ -184,22 +169,21 @@ static inline int setcolor(int color) | |||
184 | { | 169 | { |
185 | int oldcolor; | 170 | int oldcolor; |
186 | 171 | ||
187 | vga_io_w(GRAPHICS_ADDR_REG, SET_RESET_INDEX); | 172 | oldcolor = vga_io_rgfx(VGA_GFX_SR_VALUE); |
188 | oldcolor = vga_io_r(GRAPHICS_DATA_REG); | 173 | vga_io_w(VGA_GFX_D, color); |
189 | vga_io_w(GRAPHICS_DATA_REG, color); | ||
190 | return oldcolor; | 174 | return oldcolor; |
191 | } | 175 | } |
192 | 176 | ||
193 | /* Return the value in the Graphics Address Register. */ | 177 | /* Return the value in the Graphics Address Register. */ |
194 | static inline int getindex(void) | 178 | static inline int getindex(void) |
195 | { | 179 | { |
196 | return vga_io_r(GRAPHICS_ADDR_REG); | 180 | return vga_io_r(VGA_GFX_I); |
197 | } | 181 | } |
198 | 182 | ||
199 | /* Set the value in the Graphics Address Register. */ | 183 | /* Set the value in the Graphics Address Register. */ |
200 | static inline void setindex(int index) | 184 | static inline void setindex(int index) |
201 | { | 185 | { |
202 | vga_io_w(GRAPHICS_ADDR_REG, index); | 186 | vga_io_w(VGA_GFX_I, index); |
203 | } | 187 | } |
204 | 188 | ||
205 | static void vga16fb_pan_var(struct fb_info *info, | 189 | static void vga16fb_pan_var(struct fb_info *info, |
@@ -672,10 +656,10 @@ static void ega16_setpalette(int regno, unsigned red, unsigned green, unsigned b | |||
672 | 656 | ||
673 | static void vga16_setpalette(int regno, unsigned red, unsigned green, unsigned blue) | 657 | static void vga16_setpalette(int regno, unsigned red, unsigned green, unsigned blue) |
674 | { | 658 | { |
675 | outb(regno, dac_reg); | 659 | outb(regno, VGA_PEL_IW); |
676 | outb(red >> 10, dac_val); | 660 | outb(red >> 10, VGA_PEL_D); |
677 | outb(green >> 10, dac_val); | 661 | outb(green >> 10, VGA_PEL_D); |
678 | outb(blue >> 10, dac_val); | 662 | outb(blue >> 10, VGA_PEL_D); |
679 | } | 663 | } |
680 | 664 | ||
681 | static int vga16fb_setcolreg(unsigned regno, unsigned red, unsigned green, | 665 | static int vga16fb_setcolreg(unsigned regno, unsigned red, unsigned green, |
@@ -719,28 +703,15 @@ static int vga16fb_pan_display(struct fb_var_screeninfo *var, | |||
719 | blanking code was originally by Huang shi chao, and modified by | 703 | blanking code was originally by Huang shi chao, and modified by |
720 | Christoph Rimek (chrimek@toppoint.de) and todd j. derr | 704 | Christoph Rimek (chrimek@toppoint.de) and todd j. derr |
721 | (tjd@barefoot.org) for Linux. */ | 705 | (tjd@barefoot.org) for Linux. */ |
722 | #define attrib_port VGA_ATC_IW | ||
723 | #define seq_port_reg VGA_SEQ_I | ||
724 | #define seq_port_val VGA_SEQ_D | ||
725 | #define gr_port_reg VGA_GFX_I | ||
726 | #define gr_port_val VGA_GFX_D | ||
727 | #define video_misc_rd VGA_MIS_R | ||
728 | #define video_misc_wr VGA_MIS_W | ||
729 | #define vga_video_port_reg VGA_CRT_IC | ||
730 | #define vga_video_port_val VGA_CRT_DC | ||
731 | 706 | ||
732 | static void vga_vesa_blank(struct vga16fb_par *par, int mode) | 707 | static void vga_vesa_blank(struct vga16fb_par *par, int mode) |
733 | { | 708 | { |
734 | unsigned char SeqCtrlIndex; | 709 | unsigned char SeqCtrlIndex = vga_io_r(VGA_SEQ_I); |
735 | unsigned char CrtCtrlIndex; | 710 | unsigned char CrtCtrlIndex = vga_io_r(VGA_CRT_IC); |
736 | 711 | ||
737 | //cli(); | ||
738 | SeqCtrlIndex = vga_io_r(seq_port_reg); | ||
739 | CrtCtrlIndex = vga_io_r(vga_video_port_reg); | ||
740 | |||
741 | /* save original values of VGA controller registers */ | 712 | /* save original values of VGA controller registers */ |
742 | if(!par->vesa_blanked) { | 713 | if(!par->vesa_blanked) { |
743 | par->vga_state.CrtMiscIO = vga_io_r(video_misc_rd); | 714 | par->vga_state.CrtMiscIO = vga_io_r(VGA_MIS_R); |
744 | //sti(); | 715 | //sti(); |
745 | 716 | ||
746 | par->vga_state.HorizontalTotal = vga_io_rcrt(0x00); /* HorizontalTotal */ | 717 | par->vga_state.HorizontalTotal = vga_io_rcrt(0x00); /* HorizontalTotal */ |
@@ -756,12 +727,11 @@ static void vga_vesa_blank(struct vga16fb_par *par, int mode) | |||
756 | 727 | ||
757 | /* assure that video is enabled */ | 728 | /* assure that video is enabled */ |
758 | /* "0x20" is VIDEO_ENABLE_bit in register 01 of sequencer */ | 729 | /* "0x20" is VIDEO_ENABLE_bit in register 01 of sequencer */ |
759 | //cli(); | ||
760 | vga_io_wseq(0x01, par->vga_state.ClockingMode | 0x20); | 730 | vga_io_wseq(0x01, par->vga_state.ClockingMode | 0x20); |
761 | 731 | ||
762 | /* test for vertical retrace in process.... */ | 732 | /* test for vertical retrace in process.... */ |
763 | if ((par->vga_state.CrtMiscIO & 0x80) == 0x80) | 733 | if ((par->vga_state.CrtMiscIO & 0x80) == 0x80) |
764 | vga_io_w(video_misc_wr, par->vga_state.CrtMiscIO & 0xef); | 734 | vga_io_w(VGA_MIS_W, par->vga_state.CrtMiscIO & 0xef); |
765 | 735 | ||
766 | /* | 736 | /* |
767 | * Set <End of vertical retrace> to minimum (0) and | 737 | * Set <End of vertical retrace> to minimum (0) and |
@@ -769,12 +739,10 @@ static void vga_vesa_blank(struct vga16fb_par *par, int mode) | |||
769 | * Result: turn off vertical sync (VSync) pulse. | 739 | * Result: turn off vertical sync (VSync) pulse. |
770 | */ | 740 | */ |
771 | if (mode & FB_BLANK_VSYNC_SUSPEND) { | 741 | if (mode & FB_BLANK_VSYNC_SUSPEND) { |
772 | outb_p(0x10,vga_video_port_reg); /* StartVertRetrace */ | 742 | vga_io_wcrt(VGA_CRTC_V_SYNC_START, 0xff); |
773 | outb_p(0xff,vga_video_port_val); /* maximum value */ | 743 | vga_io_wcrt(VGA_CRTC_V_SYNC_END, 0x40); |
774 | outb_p(0x11,vga_video_port_reg); /* EndVertRetrace */ | 744 | /* bits 9,10 of vert. retrace */ |
775 | outb_p(0x40,vga_video_port_val); /* minimum (bits 0..3) */ | 745 | vga_io_wcrt(VGA_CRTC_OVERFLOW, par->vga_state.Overflow | 0x84); |
776 | outb_p(0x07,vga_video_port_reg); /* Overflow */ | ||
777 | outb_p(par->vga_state.Overflow | 0x84,vga_video_port_val); /* bits 9,10 of vert. retrace */ | ||
778 | } | 746 | } |
779 | 747 | ||
780 | if (mode & FB_BLANK_HSYNC_SUSPEND) { | 748 | if (mode & FB_BLANK_HSYNC_SUSPEND) { |
@@ -783,29 +751,22 @@ static void vga_vesa_blank(struct vga16fb_par *par, int mode) | |||
783 | * <Start of horizontal Retrace> to maximum | 751 | * <Start of horizontal Retrace> to maximum |
784 | * Result: turn off horizontal sync (HSync) pulse. | 752 | * Result: turn off horizontal sync (HSync) pulse. |
785 | */ | 753 | */ |
786 | outb_p(0x04,vga_video_port_reg); /* StartHorizRetrace */ | 754 | vga_io_wcrt(VGA_CRTC_H_SYNC_START, 0xff); |
787 | outb_p(0xff,vga_video_port_val); /* maximum */ | 755 | vga_io_wcrt(VGA_CRTC_H_SYNC_END, 0x00); |
788 | outb_p(0x05,vga_video_port_reg); /* EndHorizRetrace */ | ||
789 | outb_p(0x00,vga_video_port_val); /* minimum (0) */ | ||
790 | } | 756 | } |
791 | 757 | ||
792 | /* restore both index registers */ | 758 | /* restore both index registers */ |
793 | outb_p(SeqCtrlIndex,seq_port_reg); | 759 | outb_p(SeqCtrlIndex, VGA_SEQ_I); |
794 | outb_p(CrtCtrlIndex,vga_video_port_reg); | 760 | outb_p(CrtCtrlIndex, VGA_CRT_IC); |
795 | //sti(); | ||
796 | } | 761 | } |
797 | 762 | ||
798 | static void vga_vesa_unblank(struct vga16fb_par *par) | 763 | static void vga_vesa_unblank(struct vga16fb_par *par) |
799 | { | 764 | { |
800 | unsigned char SeqCtrlIndex; | 765 | unsigned char SeqCtrlIndex = vga_io_r(VGA_SEQ_I); |
801 | unsigned char CrtCtrlIndex; | 766 | unsigned char CrtCtrlIndex = vga_io_r(VGA_CRT_IC); |
802 | 767 | ||
803 | //cli(); | ||
804 | SeqCtrlIndex = vga_io_r(seq_port_reg); | ||
805 | CrtCtrlIndex = vga_io_r(vga_video_port_reg); | ||
806 | |||
807 | /* restore original values of VGA controller registers */ | 768 | /* restore original values of VGA controller registers */ |
808 | vga_io_w(video_misc_wr, par->vga_state.CrtMiscIO); | 769 | vga_io_w(VGA_MIS_W, par->vga_state.CrtMiscIO); |
809 | 770 | ||
810 | /* HorizontalTotal */ | 771 | /* HorizontalTotal */ |
811 | vga_io_wcrt(0x00, par->vga_state.HorizontalTotal); | 772 | vga_io_wcrt(0x00, par->vga_state.HorizontalTotal); |
@@ -827,9 +788,8 @@ static void vga_vesa_unblank(struct vga16fb_par *par) | |||
827 | vga_io_wseq(0x01, par->vga_state.ClockingMode); | 788 | vga_io_wseq(0x01, par->vga_state.ClockingMode); |
828 | 789 | ||
829 | /* restore index/control registers */ | 790 | /* restore index/control registers */ |
830 | vga_io_w(seq_port_reg, SeqCtrlIndex); | 791 | vga_io_w(VGA_SEQ_I, SeqCtrlIndex); |
831 | vga_io_w(vga_video_port_reg, CrtCtrlIndex); | 792 | vga_io_w(VGA_CRT_IC, CrtCtrlIndex); |
832 | //sti(); | ||
833 | } | 793 | } |
834 | 794 | ||
835 | static void vga_pal_blank(void) | 795 | static void vga_pal_blank(void) |
@@ -837,10 +797,10 @@ static void vga_pal_blank(void) | |||
837 | int i; | 797 | int i; |
838 | 798 | ||
839 | for (i=0; i<16; i++) { | 799 | for (i=0; i<16; i++) { |
840 | outb_p (i, dac_reg) ; | 800 | outb_p(i, VGA_PEL_IW); |
841 | outb_p (0, dac_val) ; | 801 | outb_p(0, VGA_PEL_D); |
842 | outb_p (0, dac_val) ; | 802 | outb_p(0, VGA_PEL_D); |
843 | outb_p (0, dac_val) ; | 803 | outb_p(0, VGA_PEL_D); |
844 | } | 804 | } |
845 | } | 805 | } |
846 | 806 | ||
@@ -1087,12 +1047,15 @@ static void vga16fb_copyarea(struct fb_info *info, const struct fb_copyarea *are | |||
1087 | width = x2 - dx; | 1047 | width = x2 - dx; |
1088 | height = y2 - dy; | 1048 | height = y2 - dy; |
1089 | 1049 | ||
1050 | if (sx + dx < old_dx || sy + dy < old_dy) | ||
1051 | return; | ||
1052 | |||
1090 | /* update sx1,sy1 */ | 1053 | /* update sx1,sy1 */ |
1091 | sx += (dx - old_dx); | 1054 | sx += (dx - old_dx); |
1092 | sy += (dy - old_dy); | 1055 | sy += (dy - old_dy); |
1093 | 1056 | ||
1094 | /* the source must be completely inside the virtual screen */ | 1057 | /* the source must be completely inside the virtual screen */ |
1095 | if (sx < 0 || sy < 0 || (sx + width) > vxres || (sy + height) > vyres) | 1058 | if (sx + width > vxres || sy + height > vyres) |
1096 | return; | 1059 | return; |
1097 | 1060 | ||
1098 | switch (info->fix.type) { | 1061 | switch (info->fix.type) { |
@@ -1482,6 +1445,7 @@ static void __exit vga16fb_exit(void) | |||
1482 | platform_driver_unregister(&vga16fb_driver); | 1445 | platform_driver_unregister(&vga16fb_driver); |
1483 | } | 1446 | } |
1484 | 1447 | ||
1448 | MODULE_DESCRIPTION("Legacy VGA framebuffer device driver"); | ||
1485 | MODULE_LICENSE("GPL"); | 1449 | MODULE_LICENSE("GPL"); |
1486 | module_init(vga16fb_init); | 1450 | module_init(vga16fb_init); |
1487 | module_exit(vga16fb_exit); | 1451 | module_exit(vga16fb_exit); |
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 7084e7e146c0..5b78fd0aff0a 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -71,13 +71,6 @@ static int virtio_uevent(struct device *_dv, struct kobj_uevent_env *env) | |||
71 | dev->id.device, dev->id.vendor); | 71 | dev->id.device, dev->id.vendor); |
72 | } | 72 | } |
73 | 73 | ||
74 | static struct bus_type virtio_bus = { | ||
75 | .name = "virtio", | ||
76 | .match = virtio_dev_match, | ||
77 | .dev_attrs = virtio_dev_attrs, | ||
78 | .uevent = virtio_uevent, | ||
79 | }; | ||
80 | |||
81 | static void add_status(struct virtio_device *dev, unsigned status) | 74 | static void add_status(struct virtio_device *dev, unsigned status) |
82 | { | 75 | { |
83 | dev->config->set_status(dev, dev->config->get_status(dev) | status); | 76 | dev->config->set_status(dev, dev->config->get_status(dev) | status); |
@@ -120,12 +113,16 @@ static int virtio_dev_probe(struct device *_d) | |||
120 | set_bit(f, dev->features); | 113 | set_bit(f, dev->features); |
121 | } | 114 | } |
122 | 115 | ||
116 | /* Transport features always preserved to pass to finalize_features. */ | ||
117 | for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) | ||
118 | if (device_features & (1 << i)) | ||
119 | set_bit(i, dev->features); | ||
120 | |||
123 | err = drv->probe(dev); | 121 | err = drv->probe(dev); |
124 | if (err) | 122 | if (err) |
125 | add_status(dev, VIRTIO_CONFIG_S_FAILED); | 123 | add_status(dev, VIRTIO_CONFIG_S_FAILED); |
126 | else { | 124 | else { |
127 | /* They should never have set feature bits beyond 32 */ | 125 | dev->config->finalize_features(dev); |
128 | dev->config->set_features(dev, dev->features[0]); | ||
129 | add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); | 126 | add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); |
130 | } | 127 | } |
131 | return err; | 128 | return err; |
@@ -147,13 +144,20 @@ static int virtio_dev_remove(struct device *_d) | |||
147 | return 0; | 144 | return 0; |
148 | } | 145 | } |
149 | 146 | ||
147 | static struct bus_type virtio_bus = { | ||
148 | .name = "virtio", | ||
149 | .match = virtio_dev_match, | ||
150 | .dev_attrs = virtio_dev_attrs, | ||
151 | .uevent = virtio_uevent, | ||
152 | .probe = virtio_dev_probe, | ||
153 | .remove = virtio_dev_remove, | ||
154 | }; | ||
155 | |||
150 | int register_virtio_driver(struct virtio_driver *driver) | 156 | int register_virtio_driver(struct virtio_driver *driver) |
151 | { | 157 | { |
152 | /* Catch this early. */ | 158 | /* Catch this early. */ |
153 | BUG_ON(driver->feature_table_size && !driver->feature_table); | 159 | BUG_ON(driver->feature_table_size && !driver->feature_table); |
154 | driver->driver.bus = &virtio_bus; | 160 | driver->driver.bus = &virtio_bus; |
155 | driver->driver.probe = virtio_dev_probe; | ||
156 | driver->driver.remove = virtio_dev_remove; | ||
157 | return driver_register(&driver->driver); | 161 | return driver_register(&driver->driver); |
158 | } | 162 | } |
159 | EXPORT_SYMBOL_GPL(register_virtio_driver); | 163 | EXPORT_SYMBOL_GPL(register_virtio_driver); |
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index eae7236310e4..c7dc37c7cce9 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -94,12 +94,17 @@ static u32 vp_get_features(struct virtio_device *vdev) | |||
94 | return ioread32(vp_dev->ioaddr + VIRTIO_PCI_HOST_FEATURES); | 94 | return ioread32(vp_dev->ioaddr + VIRTIO_PCI_HOST_FEATURES); |
95 | } | 95 | } |
96 | 96 | ||
97 | /* virtio config->set_features() implementation */ | 97 | /* virtio config->finalize_features() implementation */ |
98 | static void vp_set_features(struct virtio_device *vdev, u32 features) | 98 | static void vp_finalize_features(struct virtio_device *vdev) |
99 | { | 99 | { |
100 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 100 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
101 | 101 | ||
102 | iowrite32(features, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); | 102 | /* Give virtio_ring a chance to accept features. */ |
103 | vring_transport_features(vdev); | ||
104 | |||
105 | /* We only support 32 feature bits. */ | ||
106 | BUILD_BUG_ON(ARRAY_SIZE(vdev->features) != 1); | ||
107 | iowrite32(vdev->features[0], vp_dev->ioaddr+VIRTIO_PCI_GUEST_FEATURES); | ||
103 | } | 108 | } |
104 | 109 | ||
105 | /* virtio config->get() implementation */ | 110 | /* virtio config->get() implementation */ |
@@ -297,7 +302,7 @@ static struct virtio_config_ops virtio_pci_config_ops = { | |||
297 | .find_vq = vp_find_vq, | 302 | .find_vq = vp_find_vq, |
298 | .del_vq = vp_del_vq, | 303 | .del_vq = vp_del_vq, |
299 | .get_features = vp_get_features, | 304 | .get_features = vp_get_features, |
300 | .set_features = vp_set_features, | 305 | .finalize_features = vp_finalize_features, |
301 | }; | 306 | }; |
302 | 307 | ||
303 | /* the PCI probing function */ | 308 | /* the PCI probing function */ |
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 72bf8bc09014..6eb5303fed11 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | #include <linux/virtio.h> | 19 | #include <linux/virtio.h> |
20 | #include <linux/virtio_ring.h> | 20 | #include <linux/virtio_ring.h> |
21 | #include <linux/virtio_config.h> | ||
21 | #include <linux/device.h> | 22 | #include <linux/device.h> |
22 | 23 | ||
23 | #ifdef DEBUG | 24 | #ifdef DEBUG |
@@ -87,8 +88,11 @@ static int vring_add_buf(struct virtqueue *_vq, | |||
87 | if (vq->num_free < out + in) { | 88 | if (vq->num_free < out + in) { |
88 | pr_debug("Can't add buf len %i - avail = %i\n", | 89 | pr_debug("Can't add buf len %i - avail = %i\n", |
89 | out + in, vq->num_free); | 90 | out + in, vq->num_free); |
90 | /* We notify *even if* VRING_USED_F_NO_NOTIFY is set here. */ | 91 | /* FIXME: for historical reasons, we force a notify here if |
91 | vq->notify(&vq->vq); | 92 | * there are outgoing parts to the buffer. Presumably the |
93 | * host should service the ring ASAP. */ | ||
94 | if (out) | ||
95 | vq->notify(&vq->vq); | ||
92 | END_USE(vq); | 96 | END_USE(vq); |
93 | return -ENOSPC; | 97 | return -ENOSPC; |
94 | } | 98 | } |
@@ -320,4 +324,19 @@ void vring_del_virtqueue(struct virtqueue *vq) | |||
320 | } | 324 | } |
321 | EXPORT_SYMBOL_GPL(vring_del_virtqueue); | 325 | EXPORT_SYMBOL_GPL(vring_del_virtqueue); |
322 | 326 | ||
327 | /* Manipulates transport-specific feature bits. */ | ||
328 | void vring_transport_features(struct virtio_device *vdev) | ||
329 | { | ||
330 | unsigned int i; | ||
331 | |||
332 | for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) { | ||
333 | switch (i) { | ||
334 | default: | ||
335 | /* We don't understand this bit. */ | ||
336 | clear_bit(i, vdev->features); | ||
337 | } | ||
338 | } | ||
339 | } | ||
340 | EXPORT_SYMBOL_GPL(vring_transport_features); | ||
341 | |||
323 | MODULE_LICENSE("GPL"); | 342 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index ccb78f66c2b6..48399e134c0d 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -788,8 +788,6 @@ config WATCHDOG_RIO | |||
788 | machines. The watchdog timeout period is normally one minute but | 788 | machines. The watchdog timeout period is normally one minute but |
789 | can be changed with a boot-time parameter. | 789 | can be changed with a boot-time parameter. |
790 | 790 | ||
791 | # V850 Architecture | ||
792 | |||
793 | # XTENSA Architecture | 791 | # XTENSA Architecture |
794 | 792 | ||
795 | # | 793 | # |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 25b352b664d9..edd305a64e63 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
@@ -119,8 +119,6 @@ obj-$(CONFIG_SH_WDT) += shwdt.o | |||
119 | 119 | ||
120 | # SPARC64 Architecture | 120 | # SPARC64 Architecture |
121 | 121 | ||
122 | # V850 Architecture | ||
123 | |||
124 | # XTENSA Architecture | 122 | # XTENSA Architecture |
125 | 123 | ||
126 | # Architecture Independant | 124 | # Architecture Independant |
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c index 3da712cc7708..5290552d2ef7 100644 --- a/drivers/zorro/zorro-sysfs.c +++ b/drivers/zorro/zorro-sysfs.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/zorro.h> | 15 | #include <linux/zorro.h> |
16 | #include <linux/stat.h> | 16 | #include <linux/stat.h> |
17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
18 | #include <linux/fs.h> | ||
19 | 18 | ||
20 | #include "zorro.h" | 19 | #include "zorro.h" |
21 | 20 | ||