diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-02-09 08:58:11 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-09 08:58:11 -0500 |
commit | 249d51b53aea1b7cdb1be65a1a9a0c59d9e06f3e (patch) | |
tree | 7fc06930e46ee13d394f5b031166c40206af3189 /drivers | |
parent | 44581a28e805a31661469c4b466b9cd14b36e7b6 (diff) | |
parent | 8e4921515c1a379539607eb443d51c30f4f7f338 (diff) |
Merge commit 'v2.6.29-rc4' into core/percpu
Conflicts:
arch/x86/mach-voyager/voyager_smp.c
arch/x86/mm/fault.c
Diffstat (limited to 'drivers')
195 files changed, 3917 insertions, 2396 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index d7f9839ba264..a7799a99f2d9 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -9,6 +9,7 @@ menuconfig ACPI | |||
9 | depends on PCI | 9 | depends on PCI |
10 | depends on PM | 10 | depends on PM |
11 | select PNP | 11 | select PNP |
12 | select CPU_IDLE | ||
12 | default y | 13 | default y |
13 | ---help--- | 14 | ---help--- |
14 | Advanced Configuration and Power Interface (ACPI) support for | 15 | Advanced Configuration and Power Interface (ACPI) support for |
@@ -287,7 +288,7 @@ config ACPI_CONTAINER | |||
287 | support physical cpu/memory hot-plug. | 288 | support physical cpu/memory hot-plug. |
288 | 289 | ||
289 | If one selects "m", this driver can be loaded with | 290 | If one selects "m", this driver can be loaded with |
290 | "modprobe acpi_container". | 291 | "modprobe container". |
291 | 292 | ||
292 | config ACPI_HOTPLUG_MEMORY | 293 | config ACPI_HOTPLUG_MEMORY |
293 | tristate "Memory Hotplug" | 294 | tristate "Memory Hotplug" |
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index 9684cc827930..22ce48985720 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c | |||
@@ -538,10 +538,9 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) | |||
538 | if (ACPI_FAILURE(status)) { | 538 | if (ACPI_FAILURE(status)) { |
539 | ACPI_WARNING((AE_INFO, | 539 | ACPI_WARNING((AE_INFO, |
540 | "Truncating %u table entries!", | 540 | "Truncating %u table entries!", |
541 | (unsigned) | 541 | (unsigned) (table_count - |
542 | (acpi_gbl_root_table_list.size - | 542 | (acpi_gbl_root_table_list. |
543 | acpi_gbl_root_table_list. | 543 | count - 2)))); |
544 | count))); | ||
545 | break; | 544 | break; |
546 | } | 545 | } |
547 | } | 546 | } |
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c index da9450bc60f7..9c9897dbe907 100644 --- a/drivers/acpi/acpica/uteval.c +++ b/drivers/acpi/acpica/uteval.c | |||
@@ -116,9 +116,9 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) | |||
116 | return_ACPI_STATUS(AE_NO_MEMORY); | 116 | return_ACPI_STATUS(AE_NO_MEMORY); |
117 | } | 117 | } |
118 | 118 | ||
119 | /* Default return value is SUPPORTED */ | 119 | /* Default return value is 0, NOT-SUPPORTED */ |
120 | 120 | ||
121 | return_desc->integer.value = ACPI_UINT32_MAX; | 121 | return_desc->integer.value = 0; |
122 | walk_state->return_desc = return_desc; | 122 | walk_state->return_desc = return_desc; |
123 | 123 | ||
124 | /* Compare input string to static table of supported interfaces */ | 124 | /* Compare input string to static table of supported interfaces */ |
@@ -127,10 +127,8 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) | |||
127 | if (!ACPI_STRCMP | 127 | if (!ACPI_STRCMP |
128 | (string_desc->string.pointer, | 128 | (string_desc->string.pointer, |
129 | acpi_interfaces_supported[i])) { | 129 | acpi_interfaces_supported[i])) { |
130 | 130 | return_desc->integer.value = ACPI_UINT32_MAX; | |
131 | /* The interface is supported */ | 131 | goto done; |
132 | |||
133 | return_ACPI_STATUS(AE_OK); | ||
134 | } | 132 | } |
135 | } | 133 | } |
136 | 134 | ||
@@ -141,15 +139,14 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) | |||
141 | */ | 139 | */ |
142 | status = acpi_os_validate_interface(string_desc->string.pointer); | 140 | status = acpi_os_validate_interface(string_desc->string.pointer); |
143 | if (ACPI_SUCCESS(status)) { | 141 | if (ACPI_SUCCESS(status)) { |
144 | 142 | return_desc->integer.value = ACPI_UINT32_MAX; | |
145 | /* The interface is supported */ | ||
146 | |||
147 | return_ACPI_STATUS(AE_OK); | ||
148 | } | 143 | } |
149 | 144 | ||
150 | /* The interface is not supported */ | 145 | done: |
146 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, "ACPI: BIOS _OSI(%s) %ssupported\n", | ||
147 | string_desc->string.pointer, | ||
148 | return_desc->integer.value == 0 ? "not-" : "")); | ||
151 | 149 | ||
152 | return_desc->integer.value = 0; | ||
153 | return_ACPI_STATUS(AE_OK); | 150 | return_ACPI_STATUS(AE_OK); |
154 | } | 151 | } |
155 | 152 | ||
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 17020c12623c..fe0cdf83641a 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -163,7 +163,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) | |||
163 | case ACPI_NOTIFY_BUS_CHECK: | 163 | case ACPI_NOTIFY_BUS_CHECK: |
164 | /* Fall through */ | 164 | /* Fall through */ |
165 | case ACPI_NOTIFY_DEVICE_CHECK: | 165 | case ACPI_NOTIFY_DEVICE_CHECK: |
166 | printk("Container driver received %s event\n", | 166 | printk(KERN_WARNING "Container driver received %s event\n", |
167 | (type == ACPI_NOTIFY_BUS_CHECK) ? | 167 | (type == ACPI_NOTIFY_BUS_CHECK) ? |
168 | "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); | 168 | "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); |
169 | status = acpi_bus_get_device(handle, &device); | 169 | status = acpi_bus_get_device(handle, &device); |
@@ -174,7 +174,8 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) | |||
174 | kobject_uevent(&device->dev.kobj, | 174 | kobject_uevent(&device->dev.kobj, |
175 | KOBJ_ONLINE); | 175 | KOBJ_ONLINE); |
176 | else | 176 | else |
177 | printk("Failed to add container\n"); | 177 | printk(KERN_WARNING |
178 | "Failed to add container\n"); | ||
178 | } | 179 | } |
179 | } else { | 180 | } else { |
180 | if (ACPI_SUCCESS(status)) { | 181 | if (ACPI_SUCCESS(status)) { |
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 5b30b8d91d71..35094f230b1e 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
@@ -855,10 +855,14 @@ fdd_out: | |||
855 | static ssize_t show_docked(struct device *dev, | 855 | static ssize_t show_docked(struct device *dev, |
856 | struct device_attribute *attr, char *buf) | 856 | struct device_attribute *attr, char *buf) |
857 | { | 857 | { |
858 | struct acpi_device *tmp; | ||
859 | |||
858 | struct dock_station *dock_station = *((struct dock_station **) | 860 | struct dock_station *dock_station = *((struct dock_station **) |
859 | dev->platform_data); | 861 | dev->platform_data); |
860 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_present(dock_station)); | ||
861 | 862 | ||
863 | if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp))) | ||
864 | return snprintf(buf, PAGE_SIZE, "1\n"); | ||
865 | return snprintf(buf, PAGE_SIZE, "0\n"); | ||
862 | } | 866 | } |
863 | static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); | 867 | static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); |
864 | 868 | ||
@@ -984,7 +988,7 @@ static int dock_add(acpi_handle handle) | |||
984 | 988 | ||
985 | ret = device_create_file(&dock_device->dev, &dev_attr_docked); | 989 | ret = device_create_file(&dock_device->dev, &dev_attr_docked); |
986 | if (ret) { | 990 | if (ret) { |
987 | printk("Error %d adding sysfs file\n", ret); | 991 | printk(KERN_ERR "Error %d adding sysfs file\n", ret); |
988 | platform_device_unregister(dock_device); | 992 | platform_device_unregister(dock_device); |
989 | kfree(dock_station); | 993 | kfree(dock_station); |
990 | dock_station = NULL; | 994 | dock_station = NULL; |
@@ -992,7 +996,7 @@ static int dock_add(acpi_handle handle) | |||
992 | } | 996 | } |
993 | ret = device_create_file(&dock_device->dev, &dev_attr_undock); | 997 | ret = device_create_file(&dock_device->dev, &dev_attr_undock); |
994 | if (ret) { | 998 | if (ret) { |
995 | printk("Error %d adding sysfs file\n", ret); | 999 | printk(KERN_ERR "Error %d adding sysfs file\n", ret); |
996 | device_remove_file(&dock_device->dev, &dev_attr_docked); | 1000 | device_remove_file(&dock_device->dev, &dev_attr_docked); |
997 | platform_device_unregister(dock_device); | 1001 | platform_device_unregister(dock_device); |
998 | kfree(dock_station); | 1002 | kfree(dock_station); |
@@ -1001,7 +1005,7 @@ static int dock_add(acpi_handle handle) | |||
1001 | } | 1005 | } |
1002 | ret = device_create_file(&dock_device->dev, &dev_attr_uid); | 1006 | ret = device_create_file(&dock_device->dev, &dev_attr_uid); |
1003 | if (ret) { | 1007 | if (ret) { |
1004 | printk("Error %d adding sysfs file\n", ret); | 1008 | printk(KERN_ERR "Error %d adding sysfs file\n", ret); |
1005 | device_remove_file(&dock_device->dev, &dev_attr_docked); | 1009 | device_remove_file(&dock_device->dev, &dev_attr_docked); |
1006 | device_remove_file(&dock_device->dev, &dev_attr_undock); | 1010 | device_remove_file(&dock_device->dev, &dev_attr_undock); |
1007 | platform_device_unregister(dock_device); | 1011 | platform_device_unregister(dock_device); |
@@ -1011,7 +1015,7 @@ static int dock_add(acpi_handle handle) | |||
1011 | } | 1015 | } |
1012 | ret = device_create_file(&dock_device->dev, &dev_attr_flags); | 1016 | ret = device_create_file(&dock_device->dev, &dev_attr_flags); |
1013 | if (ret) { | 1017 | if (ret) { |
1014 | printk("Error %d adding sysfs file\n", ret); | 1018 | printk(KERN_ERR "Error %d adding sysfs file\n", ret); |
1015 | device_remove_file(&dock_device->dev, &dev_attr_docked); | 1019 | device_remove_file(&dock_device->dev, &dev_attr_docked); |
1016 | device_remove_file(&dock_device->dev, &dev_attr_undock); | 1020 | device_remove_file(&dock_device->dev, &dev_attr_undock); |
1017 | device_remove_file(&dock_device->dev, &dev_attr_uid); | 1021 | device_remove_file(&dock_device->dev, &dev_attr_uid); |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index a2b82c90a683..5c2f5d343be6 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -982,7 +982,7 @@ int __init acpi_ec_ecdt_probe(void) | |||
982 | saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); | 982 | saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
983 | if (!saved_ec) | 983 | if (!saved_ec) |
984 | return -ENOMEM; | 984 | return -ENOMEM; |
985 | memcpy(&saved_ec, boot_ec, sizeof(saved_ec)); | 985 | memcpy(saved_ec, boot_ec, sizeof(*saved_ec)); |
986 | /* fall through */ | 986 | /* fall through */ |
987 | } | 987 | } |
988 | /* This workaround is needed only on some broken machines, | 988 | /* This workaround is needed only on some broken machines, |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index adec3d15810a..5479b9f42513 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -255,12 +255,12 @@ static int acpi_platform_notify(struct device *dev) | |||
255 | } | 255 | } |
256 | type = acpi_get_bus_type(dev->bus); | 256 | type = acpi_get_bus_type(dev->bus); |
257 | if (!type) { | 257 | if (!type) { |
258 | DBG("No ACPI bus support for %s\n", dev->bus_id); | 258 | DBG("No ACPI bus support for %s\n", dev_name(dev)); |
259 | ret = -EINVAL; | 259 | ret = -EINVAL; |
260 | goto end; | 260 | goto end; |
261 | } | 261 | } |
262 | if ((ret = type->find_device(dev, &handle)) != 0) | 262 | if ((ret = type->find_device(dev, &handle)) != 0) |
263 | DBG("Can't get handler for %s\n", dev->bus_id); | 263 | DBG("Can't get handler for %s\n", dev_name(dev)); |
264 | end: | 264 | end: |
265 | if (!ret) | 265 | if (!ret) |
266 | acpi_bind_one(dev, handle); | 266 | acpi_bind_one(dev, handle); |
@@ -271,10 +271,10 @@ static int acpi_platform_notify(struct device *dev) | |||
271 | 271 | ||
272 | acpi_get_name(dev->archdata.acpi_handle, | 272 | acpi_get_name(dev->archdata.acpi_handle, |
273 | ACPI_FULL_PATHNAME, &buffer); | 273 | ACPI_FULL_PATHNAME, &buffer); |
274 | DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer); | 274 | DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer); |
275 | kfree(buffer.pointer); | 275 | kfree(buffer.pointer); |
276 | } else | 276 | } else |
277 | DBG("Device %s -> No ACPI support\n", dev->bus_id); | 277 | DBG("Device %s -> No ACPI support\n", dev_name(dev)); |
278 | #endif | 278 | #endif |
279 | 279 | ||
280 | return ret; | 280 | return ret; |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 6729a4992f2b..b3193ec0a2ef 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -228,10 +228,10 @@ void acpi_os_vprintf(const char *fmt, va_list args) | |||
228 | if (acpi_in_debugger) { | 228 | if (acpi_in_debugger) { |
229 | kdb_printf("%s", buffer); | 229 | kdb_printf("%s", buffer); |
230 | } else { | 230 | } else { |
231 | printk("%s", buffer); | 231 | printk(KERN_CONT "%s", buffer); |
232 | } | 232 | } |
233 | #else | 233 | #else |
234 | printk("%s", buffer); | 234 | printk(KERN_CONT "%s", buffer); |
235 | #endif | 235 | #endif |
236 | } | 236 | } |
237 | 237 | ||
@@ -1317,6 +1317,54 @@ acpi_os_validate_interface (char *interface) | |||
1317 | return AE_SUPPORT; | 1317 | return AE_SUPPORT; |
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | #ifdef CONFIG_X86 | ||
1321 | |||
1322 | struct aml_port_desc { | ||
1323 | uint start; | ||
1324 | uint end; | ||
1325 | char* name; | ||
1326 | char warned; | ||
1327 | }; | ||
1328 | |||
1329 | static struct aml_port_desc aml_invalid_port_list[] = { | ||
1330 | {0x20, 0x21, "PIC0", 0}, | ||
1331 | {0xA0, 0xA1, "PIC1", 0}, | ||
1332 | {0x4D0, 0x4D1, "ELCR", 0} | ||
1333 | }; | ||
1334 | |||
1335 | /* | ||
1336 | * valid_aml_io_address() | ||
1337 | * | ||
1338 | * if valid, return true | ||
1339 | * else invalid, warn once, return false | ||
1340 | */ | ||
1341 | static bool valid_aml_io_address(uint address, uint length) | ||
1342 | { | ||
1343 | int i; | ||
1344 | int entries = sizeof(aml_invalid_port_list) / sizeof(struct aml_port_desc); | ||
1345 | |||
1346 | for (i = 0; i < entries; ++i) { | ||
1347 | if ((address >= aml_invalid_port_list[i].start && | ||
1348 | address <= aml_invalid_port_list[i].end) || | ||
1349 | (address + length >= aml_invalid_port_list[i].start && | ||
1350 | address + length <= aml_invalid_port_list[i].end)) | ||
1351 | { | ||
1352 | if (!aml_invalid_port_list[i].warned) | ||
1353 | { | ||
1354 | printk(KERN_ERR "ACPI: Denied BIOS AML access" | ||
1355 | " to invalid port 0x%x+0x%x (%s)\n", | ||
1356 | address, length, | ||
1357 | aml_invalid_port_list[i].name); | ||
1358 | aml_invalid_port_list[i].warned = 1; | ||
1359 | } | ||
1360 | return false; /* invalid */ | ||
1361 | } | ||
1362 | } | ||
1363 | return true; /* valid */ | ||
1364 | } | ||
1365 | #else | ||
1366 | static inline bool valid_aml_io_address(uint address, uint length) { return true; } | ||
1367 | #endif | ||
1320 | /****************************************************************************** | 1368 | /****************************************************************************** |
1321 | * | 1369 | * |
1322 | * FUNCTION: acpi_os_validate_address | 1370 | * FUNCTION: acpi_os_validate_address |
@@ -1346,6 +1394,8 @@ acpi_os_validate_address ( | |||
1346 | 1394 | ||
1347 | switch (space_id) { | 1395 | switch (space_id) { |
1348 | case ACPI_ADR_SPACE_SYSTEM_IO: | 1396 | case ACPI_ADR_SPACE_SYSTEM_IO: |
1397 | if (!valid_aml_io_address(address, length)) | ||
1398 | return AE_AML_ILLEGAL_ADDRESS; | ||
1349 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | 1399 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
1350 | /* Only interference checks against SystemIO and SytemMemory | 1400 | /* Only interference checks against SystemIO and SytemMemory |
1351 | are needed */ | 1401 | are needed */ |
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 1c6e73c7865e..6c772ca76bd1 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
@@ -593,7 +593,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) | |||
593 | return -ENODEV; | 593 | return -ENODEV; |
594 | } else { | 594 | } else { |
595 | acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; | 595 | acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; |
596 | printk(PREFIX "%s [%s] enabled at IRQ %d\n", | 596 | printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n", |
597 | acpi_device_name(link->device), | 597 | acpi_device_name(link->device), |
598 | acpi_device_bid(link->device), link->irq.active); | 598 | acpi_device_bid(link->device), link->irq.active); |
599 | } | 599 | } |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 66a9d8145562..7bc22a471fe3 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -66,43 +66,17 @@ ACPI_MODULE_NAME("processor_idle"); | |||
66 | #define ACPI_PROCESSOR_FILE_POWER "power" | 66 | #define ACPI_PROCESSOR_FILE_POWER "power" |
67 | #define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) | 67 | #define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) |
68 | #define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) | 68 | #define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) |
69 | #ifndef CONFIG_CPU_IDLE | ||
70 | #define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ | ||
71 | #define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */ | ||
72 | static void (*pm_idle_save) (void) __read_mostly; | ||
73 | #else | ||
74 | #define C2_OVERHEAD 1 /* 1us */ | 69 | #define C2_OVERHEAD 1 /* 1us */ |
75 | #define C3_OVERHEAD 1 /* 1us */ | 70 | #define C3_OVERHEAD 1 /* 1us */ |
76 | #endif | ||
77 | #define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000)) | 71 | #define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000)) |
78 | 72 | ||
79 | static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; | 73 | static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; |
80 | #ifdef CONFIG_CPU_IDLE | ||
81 | module_param(max_cstate, uint, 0000); | 74 | module_param(max_cstate, uint, 0000); |
82 | #else | ||
83 | module_param(max_cstate, uint, 0644); | ||
84 | #endif | ||
85 | static unsigned int nocst __read_mostly; | 75 | static unsigned int nocst __read_mostly; |
86 | module_param(nocst, uint, 0000); | 76 | module_param(nocst, uint, 0000); |
87 | 77 | ||
88 | #ifndef CONFIG_CPU_IDLE | ||
89 | /* | ||
90 | * bm_history -- bit-mask with a bit per jiffy of bus-master activity | ||
91 | * 1000 HZ: 0xFFFFFFFF: 32 jiffies = 32ms | ||
92 | * 800 HZ: 0xFFFFFFFF: 32 jiffies = 40ms | ||
93 | * 100 HZ: 0x0000000F: 4 jiffies = 40ms | ||
94 | * reduce history for more aggressive entry into C3 | ||
95 | */ | ||
96 | static unsigned int bm_history __read_mostly = | ||
97 | (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1)); | ||
98 | module_param(bm_history, uint, 0644); | ||
99 | |||
100 | static int acpi_processor_set_power_policy(struct acpi_processor *pr); | ||
101 | |||
102 | #else /* CONFIG_CPU_IDLE */ | ||
103 | static unsigned int latency_factor __read_mostly = 2; | 78 | static unsigned int latency_factor __read_mostly = 2; |
104 | module_param(latency_factor, uint, 0644); | 79 | module_param(latency_factor, uint, 0644); |
105 | #endif | ||
106 | 80 | ||
107 | /* | 81 | /* |
108 | * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. | 82 | * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. |
@@ -224,71 +198,6 @@ static void acpi_safe_halt(void) | |||
224 | current_thread_info()->status |= TS_POLLING; | 198 | current_thread_info()->status |= TS_POLLING; |
225 | } | 199 | } |
226 | 200 | ||
227 | #ifndef CONFIG_CPU_IDLE | ||
228 | |||
229 | static void | ||
230 | acpi_processor_power_activate(struct acpi_processor *pr, | ||
231 | struct acpi_processor_cx *new) | ||
232 | { | ||
233 | struct acpi_processor_cx *old; | ||
234 | |||
235 | if (!pr || !new) | ||
236 | return; | ||
237 | |||
238 | old = pr->power.state; | ||
239 | |||
240 | if (old) | ||
241 | old->promotion.count = 0; | ||
242 | new->demotion.count = 0; | ||
243 | |||
244 | /* Cleanup from old state. */ | ||
245 | if (old) { | ||
246 | switch (old->type) { | ||
247 | case ACPI_STATE_C3: | ||
248 | /* Disable bus master reload */ | ||
249 | if (new->type != ACPI_STATE_C3 && pr->flags.bm_check) | ||
250 | acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0); | ||
251 | break; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | /* Prepare to use new state. */ | ||
256 | switch (new->type) { | ||
257 | case ACPI_STATE_C3: | ||
258 | /* Enable bus master reload */ | ||
259 | if (old->type != ACPI_STATE_C3 && pr->flags.bm_check) | ||
260 | acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1); | ||
261 | break; | ||
262 | } | ||
263 | |||
264 | pr->power.state = new; | ||
265 | |||
266 | return; | ||
267 | } | ||
268 | |||
269 | static atomic_t c3_cpu_count; | ||
270 | |||
271 | /* Common C-state entry for C2, C3, .. */ | ||
272 | static void acpi_cstate_enter(struct acpi_processor_cx *cstate) | ||
273 | { | ||
274 | /* Don't trace irqs off for idle */ | ||
275 | stop_critical_timings(); | ||
276 | if (cstate->entry_method == ACPI_CSTATE_FFH) { | ||
277 | /* Call into architectural FFH based C-state */ | ||
278 | acpi_processor_ffh_cstate_enter(cstate); | ||
279 | } else { | ||
280 | int unused; | ||
281 | /* IO port based C-state */ | ||
282 | inb(cstate->address); | ||
283 | /* Dummy wait op - must do something useless after P_LVL2 read | ||
284 | because chipsets cannot guarantee that STPCLK# signal | ||
285 | gets asserted in time to freeze execution properly. */ | ||
286 | unused = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
287 | } | ||
288 | start_critical_timings(); | ||
289 | } | ||
290 | #endif /* !CONFIG_CPU_IDLE */ | ||
291 | |||
292 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | 201 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 |
293 | 202 | ||
294 | /* | 203 | /* |
@@ -390,421 +299,6 @@ static int tsc_halts_in_c(int state) | |||
390 | } | 299 | } |
391 | #endif | 300 | #endif |
392 | 301 | ||
393 | #ifndef CONFIG_CPU_IDLE | ||
394 | static void acpi_processor_idle(void) | ||
395 | { | ||
396 | struct acpi_processor *pr = NULL; | ||
397 | struct acpi_processor_cx *cx = NULL; | ||
398 | struct acpi_processor_cx *next_state = NULL; | ||
399 | int sleep_ticks = 0; | ||
400 | u32 t1, t2 = 0; | ||
401 | |||
402 | /* | ||
403 | * Interrupts must be disabled during bus mastering calculations and | ||
404 | * for C2/C3 transitions. | ||
405 | */ | ||
406 | local_irq_disable(); | ||
407 | |||
408 | pr = __get_cpu_var(processors); | ||
409 | if (!pr) { | ||
410 | local_irq_enable(); | ||
411 | return; | ||
412 | } | ||
413 | |||
414 | /* | ||
415 | * Check whether we truly need to go idle, or should | ||
416 | * reschedule: | ||
417 | */ | ||
418 | if (unlikely(need_resched())) { | ||
419 | local_irq_enable(); | ||
420 | return; | ||
421 | } | ||
422 | |||
423 | cx = pr->power.state; | ||
424 | if (!cx || acpi_idle_suspend) { | ||
425 | if (pm_idle_save) { | ||
426 | pm_idle_save(); /* enables IRQs */ | ||
427 | } else { | ||
428 | acpi_safe_halt(); | ||
429 | local_irq_enable(); | ||
430 | } | ||
431 | |||
432 | return; | ||
433 | } | ||
434 | |||
435 | /* | ||
436 | * Check BM Activity | ||
437 | * ----------------- | ||
438 | * Check for bus mastering activity (if required), record, and check | ||
439 | * for demotion. | ||
440 | */ | ||
441 | if (pr->flags.bm_check) { | ||
442 | u32 bm_status = 0; | ||
443 | unsigned long diff = jiffies - pr->power.bm_check_timestamp; | ||
444 | |||
445 | if (diff > 31) | ||
446 | diff = 31; | ||
447 | |||
448 | pr->power.bm_activity <<= diff; | ||
449 | |||
450 | acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status); | ||
451 | if (bm_status) { | ||
452 | pr->power.bm_activity |= 0x1; | ||
453 | acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1); | ||
454 | } | ||
455 | /* | ||
456 | * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect | ||
457 | * the true state of bus mastering activity; forcing us to | ||
458 | * manually check the BMIDEA bit of each IDE channel. | ||
459 | */ | ||
460 | else if (errata.piix4.bmisx) { | ||
461 | if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) | ||
462 | || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) | ||
463 | pr->power.bm_activity |= 0x1; | ||
464 | } | ||
465 | |||
466 | pr->power.bm_check_timestamp = jiffies; | ||
467 | |||
468 | /* | ||
469 | * If bus mastering is or was active this jiffy, demote | ||
470 | * to avoid a faulty transition. Note that the processor | ||
471 | * won't enter a low-power state during this call (to this | ||
472 | * function) but should upon the next. | ||
473 | * | ||
474 | * TBD: A better policy might be to fallback to the demotion | ||
475 | * state (use it for this quantum only) istead of | ||
476 | * demoting -- and rely on duration as our sole demotion | ||
477 | * qualification. This may, however, introduce DMA | ||
478 | * issues (e.g. floppy DMA transfer overrun/underrun). | ||
479 | */ | ||
480 | if ((pr->power.bm_activity & 0x1) && | ||
481 | cx->demotion.threshold.bm) { | ||
482 | local_irq_enable(); | ||
483 | next_state = cx->demotion.state; | ||
484 | goto end; | ||
485 | } | ||
486 | } | ||
487 | |||
488 | #ifdef CONFIG_HOTPLUG_CPU | ||
489 | /* | ||
490 | * Check for P_LVL2_UP flag before entering C2 and above on | ||
491 | * an SMP system. We do it here instead of doing it at _CST/P_LVL | ||
492 | * detection phase, to work cleanly with logical CPU hotplug. | ||
493 | */ | ||
494 | if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) && | ||
495 | !pr->flags.has_cst && !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) | ||
496 | cx = &pr->power.states[ACPI_STATE_C1]; | ||
497 | #endif | ||
498 | |||
499 | /* | ||
500 | * Sleep: | ||
501 | * ------ | ||
502 | * Invoke the current Cx state to put the processor to sleep. | ||
503 | */ | ||
504 | if (cx->type == ACPI_STATE_C2 || cx->type == ACPI_STATE_C3) { | ||
505 | current_thread_info()->status &= ~TS_POLLING; | ||
506 | /* | ||
507 | * TS_POLLING-cleared state must be visible before we | ||
508 | * test NEED_RESCHED: | ||
509 | */ | ||
510 | smp_mb(); | ||
511 | if (need_resched()) { | ||
512 | current_thread_info()->status |= TS_POLLING; | ||
513 | local_irq_enable(); | ||
514 | return; | ||
515 | } | ||
516 | } | ||
517 | |||
518 | switch (cx->type) { | ||
519 | |||
520 | case ACPI_STATE_C1: | ||
521 | /* | ||
522 | * Invoke C1. | ||
523 | * Use the appropriate idle routine, the one that would | ||
524 | * be used without acpi C-states. | ||
525 | */ | ||
526 | if (pm_idle_save) { | ||
527 | pm_idle_save(); /* enables IRQs */ | ||
528 | } else { | ||
529 | acpi_safe_halt(); | ||
530 | local_irq_enable(); | ||
531 | } | ||
532 | |||
533 | /* | ||
534 | * TBD: Can't get time duration while in C1, as resumes | ||
535 | * go to an ISR rather than here. Need to instrument | ||
536 | * base interrupt handler. | ||
537 | * | ||
538 | * Note: the TSC better not stop in C1, sched_clock() will | ||
539 | * skew otherwise. | ||
540 | */ | ||
541 | sleep_ticks = 0xFFFFFFFF; | ||
542 | |||
543 | break; | ||
544 | |||
545 | case ACPI_STATE_C2: | ||
546 | /* Get start time (ticks) */ | ||
547 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
548 | /* Tell the scheduler that we are going deep-idle: */ | ||
549 | sched_clock_idle_sleep_event(); | ||
550 | /* Invoke C2 */ | ||
551 | acpi_state_timer_broadcast(pr, cx, 1); | ||
552 | acpi_cstate_enter(cx); | ||
553 | /* Get end time (ticks) */ | ||
554 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
555 | |||
556 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) | ||
557 | /* TSC halts in C2, so notify users */ | ||
558 | if (tsc_halts_in_c(ACPI_STATE_C2)) | ||
559 | mark_tsc_unstable("possible TSC halt in C2"); | ||
560 | #endif | ||
561 | /* Compute time (ticks) that we were actually asleep */ | ||
562 | sleep_ticks = ticks_elapsed(t1, t2); | ||
563 | |||
564 | /* Tell the scheduler how much we idled: */ | ||
565 | sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); | ||
566 | |||
567 | /* Re-enable interrupts */ | ||
568 | local_irq_enable(); | ||
569 | /* Do not account our idle-switching overhead: */ | ||
570 | sleep_ticks -= cx->latency_ticks + C2_OVERHEAD; | ||
571 | |||
572 | current_thread_info()->status |= TS_POLLING; | ||
573 | acpi_state_timer_broadcast(pr, cx, 0); | ||
574 | break; | ||
575 | |||
576 | case ACPI_STATE_C3: | ||
577 | acpi_unlazy_tlb(smp_processor_id()); | ||
578 | /* | ||
579 | * Must be done before busmaster disable as we might | ||
580 | * need to access HPET ! | ||
581 | */ | ||
582 | acpi_state_timer_broadcast(pr, cx, 1); | ||
583 | /* | ||
584 | * disable bus master | ||
585 | * bm_check implies we need ARB_DIS | ||
586 | * !bm_check implies we need cache flush | ||
587 | * bm_control implies whether we can do ARB_DIS | ||
588 | * | ||
589 | * That leaves a case where bm_check is set and bm_control is | ||
590 | * not set. In that case we cannot do much, we enter C3 | ||
591 | * without doing anything. | ||
592 | */ | ||
593 | if (pr->flags.bm_check && pr->flags.bm_control) { | ||
594 | if (atomic_inc_return(&c3_cpu_count) == | ||
595 | num_online_cpus()) { | ||
596 | /* | ||
597 | * All CPUs are trying to go to C3 | ||
598 | * Disable bus master arbitration | ||
599 | */ | ||
600 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); | ||
601 | } | ||
602 | } else if (!pr->flags.bm_check) { | ||
603 | /* SMP with no shared cache... Invalidate cache */ | ||
604 | ACPI_FLUSH_CPU_CACHE(); | ||
605 | } | ||
606 | |||
607 | /* Get start time (ticks) */ | ||
608 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
609 | /* Invoke C3 */ | ||
610 | /* Tell the scheduler that we are going deep-idle: */ | ||
611 | sched_clock_idle_sleep_event(); | ||
612 | acpi_cstate_enter(cx); | ||
613 | /* Get end time (ticks) */ | ||
614 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
615 | if (pr->flags.bm_check && pr->flags.bm_control) { | ||
616 | /* Enable bus master arbitration */ | ||
617 | atomic_dec(&c3_cpu_count); | ||
618 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); | ||
619 | } | ||
620 | |||
621 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) | ||
622 | /* TSC halts in C3, so notify users */ | ||
623 | if (tsc_halts_in_c(ACPI_STATE_C3)) | ||
624 | mark_tsc_unstable("TSC halts in C3"); | ||
625 | #endif | ||
626 | /* Compute time (ticks) that we were actually asleep */ | ||
627 | sleep_ticks = ticks_elapsed(t1, t2); | ||
628 | /* Tell the scheduler how much we idled: */ | ||
629 | sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); | ||
630 | |||
631 | /* Re-enable interrupts */ | ||
632 | local_irq_enable(); | ||
633 | /* Do not account our idle-switching overhead: */ | ||
634 | sleep_ticks -= cx->latency_ticks + C3_OVERHEAD; | ||
635 | |||
636 | current_thread_info()->status |= TS_POLLING; | ||
637 | acpi_state_timer_broadcast(pr, cx, 0); | ||
638 | break; | ||
639 | |||
640 | default: | ||
641 | local_irq_enable(); | ||
642 | return; | ||
643 | } | ||
644 | cx->usage++; | ||
645 | if ((cx->type != ACPI_STATE_C1) && (sleep_ticks > 0)) | ||
646 | cx->time += sleep_ticks; | ||
647 | |||
648 | next_state = pr->power.state; | ||
649 | |||
650 | #ifdef CONFIG_HOTPLUG_CPU | ||
651 | /* Don't do promotion/demotion */ | ||
652 | if ((cx->type == ACPI_STATE_C1) && (num_online_cpus() > 1) && | ||
653 | !pr->flags.has_cst && !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) { | ||
654 | next_state = cx; | ||
655 | goto end; | ||
656 | } | ||
657 | #endif | ||
658 | |||
659 | /* | ||
660 | * Promotion? | ||
661 | * ---------- | ||
662 | * Track the number of longs (time asleep is greater than threshold) | ||
663 | * and promote when the count threshold is reached. Note that bus | ||
664 | * mastering activity may prevent promotions. | ||
665 | * Do not promote above max_cstate. | ||
666 | */ | ||
667 | if (cx->promotion.state && | ||
668 | ((cx->promotion.state - pr->power.states) <= max_cstate)) { | ||
669 | if (sleep_ticks > cx->promotion.threshold.ticks && | ||
670 | cx->promotion.state->latency <= | ||
671 | pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)) { | ||
672 | cx->promotion.count++; | ||
673 | cx->demotion.count = 0; | ||
674 | if (cx->promotion.count >= | ||
675 | cx->promotion.threshold.count) { | ||
676 | if (pr->flags.bm_check) { | ||
677 | if (! | ||
678 | (pr->power.bm_activity & cx-> | ||
679 | promotion.threshold.bm)) { | ||
680 | next_state = | ||
681 | cx->promotion.state; | ||
682 | goto end; | ||
683 | } | ||
684 | } else { | ||
685 | next_state = cx->promotion.state; | ||
686 | goto end; | ||
687 | } | ||
688 | } | ||
689 | } | ||
690 | } | ||
691 | |||
692 | /* | ||
693 | * Demotion? | ||
694 | * --------- | ||
695 | * Track the number of shorts (time asleep is less than time threshold) | ||
696 | * and demote when the usage threshold is reached. | ||
697 | */ | ||
698 | if (cx->demotion.state) { | ||
699 | if (sleep_ticks < cx->demotion.threshold.ticks) { | ||
700 | cx->demotion.count++; | ||
701 | cx->promotion.count = 0; | ||
702 | if (cx->demotion.count >= cx->demotion.threshold.count) { | ||
703 | next_state = cx->demotion.state; | ||
704 | goto end; | ||
705 | } | ||
706 | } | ||
707 | } | ||
708 | |||
709 | end: | ||
710 | /* | ||
711 | * Demote if current state exceeds max_cstate | ||
712 | * or if the latency of the current state is unacceptable | ||
713 | */ | ||
714 | if ((pr->power.state - pr->power.states) > max_cstate || | ||
715 | pr->power.state->latency > | ||
716 | pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)) { | ||
717 | if (cx->demotion.state) | ||
718 | next_state = cx->demotion.state; | ||
719 | } | ||
720 | |||
721 | /* | ||
722 | * New Cx State? | ||
723 | * ------------- | ||
724 | * If we're going to start using a new Cx state we must clean up | ||
725 | * from the previous and prepare to use the new. | ||
726 | */ | ||
727 | if (next_state != pr->power.state) | ||
728 | acpi_processor_power_activate(pr, next_state); | ||
729 | } | ||
730 | |||
731 | static int acpi_processor_set_power_policy(struct acpi_processor *pr) | ||
732 | { | ||
733 | unsigned int i; | ||
734 | unsigned int state_is_set = 0; | ||
735 | struct acpi_processor_cx *lower = NULL; | ||
736 | struct acpi_processor_cx *higher = NULL; | ||
737 | struct acpi_processor_cx *cx; | ||
738 | |||
739 | |||
740 | if (!pr) | ||
741 | return -EINVAL; | ||
742 | |||
743 | /* | ||
744 | * This function sets the default Cx state policy (OS idle handler). | ||
745 | * Our scheme is to promote quickly to C2 but more conservatively | ||
746 | * to C3. We're favoring C2 for its characteristics of low latency | ||
747 | * (quick response), good power savings, and ability to allow bus | ||
748 | * mastering activity. Note that the Cx state policy is completely | ||
749 | * customizable and can be altered dynamically. | ||
750 | */ | ||
751 | |||
752 | /* startup state */ | ||
753 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { | ||
754 | cx = &pr->power.states[i]; | ||
755 | if (!cx->valid) | ||
756 | continue; | ||
757 | |||
758 | if (!state_is_set) | ||
759 | pr->power.state = cx; | ||
760 | state_is_set++; | ||
761 | break; | ||
762 | } | ||
763 | |||
764 | if (!state_is_set) | ||
765 | return -ENODEV; | ||
766 | |||
767 | /* demotion */ | ||
768 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { | ||
769 | cx = &pr->power.states[i]; | ||
770 | if (!cx->valid) | ||
771 | continue; | ||
772 | |||
773 | if (lower) { | ||
774 | cx->demotion.state = lower; | ||
775 | cx->demotion.threshold.ticks = cx->latency_ticks; | ||
776 | cx->demotion.threshold.count = 1; | ||
777 | if (cx->type == ACPI_STATE_C3) | ||
778 | cx->demotion.threshold.bm = bm_history; | ||
779 | } | ||
780 | |||
781 | lower = cx; | ||
782 | } | ||
783 | |||
784 | /* promotion */ | ||
785 | for (i = (ACPI_PROCESSOR_MAX_POWER - 1); i > 0; i--) { | ||
786 | cx = &pr->power.states[i]; | ||
787 | if (!cx->valid) | ||
788 | continue; | ||
789 | |||
790 | if (higher) { | ||
791 | cx->promotion.state = higher; | ||
792 | cx->promotion.threshold.ticks = cx->latency_ticks; | ||
793 | if (cx->type >= ACPI_STATE_C2) | ||
794 | cx->promotion.threshold.count = 4; | ||
795 | else | ||
796 | cx->promotion.threshold.count = 10; | ||
797 | if (higher->type == ACPI_STATE_C3) | ||
798 | cx->promotion.threshold.bm = bm_history; | ||
799 | } | ||
800 | |||
801 | higher = cx; | ||
802 | } | ||
803 | |||
804 | return 0; | ||
805 | } | ||
806 | #endif /* !CONFIG_CPU_IDLE */ | ||
807 | |||
808 | static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) | 302 | static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) |
809 | { | 303 | { |
810 | 304 | ||
@@ -1047,11 +541,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) | |||
1047 | */ | 541 | */ |
1048 | cx->valid = 1; | 542 | cx->valid = 1; |
1049 | 543 | ||
1050 | #ifndef CONFIG_CPU_IDLE | ||
1051 | cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); | ||
1052 | #else | ||
1053 | cx->latency_ticks = cx->latency; | 544 | cx->latency_ticks = cx->latency; |
1054 | #endif | ||
1055 | 545 | ||
1056 | return; | 546 | return; |
1057 | } | 547 | } |
@@ -1121,7 +611,6 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, | |||
1121 | " for C3 to be enabled on SMP systems\n")); | 611 | " for C3 to be enabled on SMP systems\n")); |
1122 | return; | 612 | return; |
1123 | } | 613 | } |
1124 | acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0); | ||
1125 | } | 614 | } |
1126 | 615 | ||
1127 | /* | 616 | /* |
@@ -1132,11 +621,16 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr, | |||
1132 | */ | 621 | */ |
1133 | cx->valid = 1; | 622 | cx->valid = 1; |
1134 | 623 | ||
1135 | #ifndef CONFIG_CPU_IDLE | ||
1136 | cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); | ||
1137 | #else | ||
1138 | cx->latency_ticks = cx->latency; | 624 | cx->latency_ticks = cx->latency; |
1139 | #endif | 625 | /* |
626 | * On older chipsets, BM_RLD needs to be set | ||
627 | * in order for Bus Master activity to wake the | ||
628 | * system from C3. Newer chipsets handle DMA | ||
629 | * during C3 automatically and BM_RLD is a NOP. | ||
630 | * In either case, the proper way to | ||
631 | * handle BM_RLD is to set it and leave it set. | ||
632 | */ | ||
633 | acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1); | ||
1140 | 634 | ||
1141 | return; | 635 | return; |
1142 | } | 636 | } |
@@ -1201,20 +695,6 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr) | |||
1201 | 695 | ||
1202 | pr->power.count = acpi_processor_power_verify(pr); | 696 | pr->power.count = acpi_processor_power_verify(pr); |
1203 | 697 | ||
1204 | #ifndef CONFIG_CPU_IDLE | ||
1205 | /* | ||
1206 | * Set Default Policy | ||
1207 | * ------------------ | ||
1208 | * Now that we know which states are supported, set the default | ||
1209 | * policy. Note that this policy can be changed dynamically | ||
1210 | * (e.g. encourage deeper sleeps to conserve battery life when | ||
1211 | * not on AC). | ||
1212 | */ | ||
1213 | result = acpi_processor_set_power_policy(pr); | ||
1214 | if (result) | ||
1215 | return result; | ||
1216 | #endif | ||
1217 | |||
1218 | /* | 698 | /* |
1219 | * if one state of type C2 or C3 is available, mark this | 699 | * if one state of type C2 or C3 is available, mark this |
1220 | * CPU as being "idle manageable" | 700 | * CPU as being "idle manageable" |
@@ -1312,69 +792,6 @@ static const struct file_operations acpi_processor_power_fops = { | |||
1312 | .release = single_release, | 792 | .release = single_release, |
1313 | }; | 793 | }; |
1314 | 794 | ||
1315 | #ifndef CONFIG_CPU_IDLE | ||
1316 | |||
1317 | int acpi_processor_cst_has_changed(struct acpi_processor *pr) | ||
1318 | { | ||
1319 | int result = 0; | ||
1320 | |||
1321 | if (boot_option_idle_override) | ||
1322 | return 0; | ||
1323 | |||
1324 | if (!pr) | ||
1325 | return -EINVAL; | ||
1326 | |||
1327 | if (nocst) { | ||
1328 | return -ENODEV; | ||
1329 | } | ||
1330 | |||
1331 | if (!pr->flags.power_setup_done) | ||
1332 | return -ENODEV; | ||
1333 | |||
1334 | /* | ||
1335 | * Fall back to the default idle loop, when pm_idle_save had | ||
1336 | * been initialized. | ||
1337 | */ | ||
1338 | if (pm_idle_save) { | ||
1339 | pm_idle = pm_idle_save; | ||
1340 | /* Relies on interrupts forcing exit from idle. */ | ||
1341 | synchronize_sched(); | ||
1342 | } | ||
1343 | |||
1344 | pr->flags.power = 0; | ||
1345 | result = acpi_processor_get_power_info(pr); | ||
1346 | if ((pr->flags.power == 1) && (pr->flags.power_setup_done)) | ||
1347 | pm_idle = acpi_processor_idle; | ||
1348 | |||
1349 | return result; | ||
1350 | } | ||
1351 | |||
1352 | #ifdef CONFIG_SMP | ||
1353 | static void smp_callback(void *v) | ||
1354 | { | ||
1355 | /* we already woke the CPU up, nothing more to do */ | ||
1356 | } | ||
1357 | |||
1358 | /* | ||
1359 | * This function gets called when a part of the kernel has a new latency | ||
1360 | * requirement. This means we need to get all processors out of their C-state, | ||
1361 | * and then recalculate a new suitable C-state. Just do a cross-cpu IPI; that | ||
1362 | * wakes them all right up. | ||
1363 | */ | ||
1364 | static int acpi_processor_latency_notify(struct notifier_block *b, | ||
1365 | unsigned long l, void *v) | ||
1366 | { | ||
1367 | smp_call_function(smp_callback, NULL, 1); | ||
1368 | return NOTIFY_OK; | ||
1369 | } | ||
1370 | |||
1371 | static struct notifier_block acpi_processor_latency_notifier = { | ||
1372 | .notifier_call = acpi_processor_latency_notify, | ||
1373 | }; | ||
1374 | |||
1375 | #endif | ||
1376 | |||
1377 | #else /* CONFIG_CPU_IDLE */ | ||
1378 | 795 | ||
1379 | /** | 796 | /** |
1380 | * acpi_idle_bm_check - checks if bus master activity was detected | 797 | * acpi_idle_bm_check - checks if bus master activity was detected |
@@ -1383,7 +800,7 @@ static int acpi_idle_bm_check(void) | |||
1383 | { | 800 | { |
1384 | u32 bm_status = 0; | 801 | u32 bm_status = 0; |
1385 | 802 | ||
1386 | acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status); | 803 | acpi_get_register_unlocked(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status); |
1387 | if (bm_status) | 804 | if (bm_status) |
1388 | acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1); | 805 | acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1); |
1389 | /* | 806 | /* |
@@ -1400,25 +817,6 @@ static int acpi_idle_bm_check(void) | |||
1400 | } | 817 | } |
1401 | 818 | ||
1402 | /** | 819 | /** |
1403 | * acpi_idle_update_bm_rld - updates the BM_RLD bit depending on target state | ||
1404 | * @pr: the processor | ||
1405 | * @target: the new target state | ||
1406 | */ | ||
1407 | static inline void acpi_idle_update_bm_rld(struct acpi_processor *pr, | ||
1408 | struct acpi_processor_cx *target) | ||
1409 | { | ||
1410 | if (pr->flags.bm_rld_set && target->type != ACPI_STATE_C3) { | ||
1411 | acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0); | ||
1412 | pr->flags.bm_rld_set = 0; | ||
1413 | } | ||
1414 | |||
1415 | if (!pr->flags.bm_rld_set && target->type == ACPI_STATE_C3) { | ||
1416 | acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1); | ||
1417 | pr->flags.bm_rld_set = 1; | ||
1418 | } | ||
1419 | } | ||
1420 | |||
1421 | /** | ||
1422 | * acpi_idle_do_entry - a helper function that does C2 and C3 type entry | 820 | * acpi_idle_do_entry - a helper function that does C2 and C3 type entry |
1423 | * @cx: cstate data | 821 | * @cx: cstate data |
1424 | * | 822 | * |
@@ -1473,9 +871,6 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, | |||
1473 | return 0; | 871 | return 0; |
1474 | } | 872 | } |
1475 | 873 | ||
1476 | if (pr->flags.bm_check) | ||
1477 | acpi_idle_update_bm_rld(pr, cx); | ||
1478 | |||
1479 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 874 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
1480 | acpi_idle_do_entry(cx); | 875 | acpi_idle_do_entry(cx); |
1481 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 876 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
@@ -1527,9 +922,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
1527 | */ | 922 | */ |
1528 | acpi_state_timer_broadcast(pr, cx, 1); | 923 | acpi_state_timer_broadcast(pr, cx, 1); |
1529 | 924 | ||
1530 | if (pr->flags.bm_check) | ||
1531 | acpi_idle_update_bm_rld(pr, cx); | ||
1532 | |||
1533 | if (cx->type == ACPI_STATE_C3) | 925 | if (cx->type == ACPI_STATE_C3) |
1534 | ACPI_FLUSH_CPU_CACHE(); | 926 | ACPI_FLUSH_CPU_CACHE(); |
1535 | 927 | ||
@@ -1621,8 +1013,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
1621 | */ | 1013 | */ |
1622 | acpi_state_timer_broadcast(pr, cx, 1); | 1014 | acpi_state_timer_broadcast(pr, cx, 1); |
1623 | 1015 | ||
1624 | acpi_idle_update_bm_rld(pr, cx); | ||
1625 | |||
1626 | /* | 1016 | /* |
1627 | * disable bus master | 1017 | * disable bus master |
1628 | * bm_check implies we need ARB_DIS | 1018 | * bm_check implies we need ARB_DIS |
@@ -1795,8 +1185,6 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) | |||
1795 | return ret; | 1185 | return ret; |
1796 | } | 1186 | } |
1797 | 1187 | ||
1798 | #endif /* CONFIG_CPU_IDLE */ | ||
1799 | |||
1800 | int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | 1188 | int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, |
1801 | struct acpi_device *device) | 1189 | struct acpi_device *device) |
1802 | { | 1190 | { |
@@ -1825,10 +1213,6 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
1825 | "ACPI: processor limited to max C-state %d\n", | 1213 | "ACPI: processor limited to max C-state %d\n", |
1826 | max_cstate); | 1214 | max_cstate); |
1827 | first_run++; | 1215 | first_run++; |
1828 | #if !defined(CONFIG_CPU_IDLE) && defined(CONFIG_SMP) | ||
1829 | pm_qos_add_notifier(PM_QOS_CPU_DMA_LATENCY, | ||
1830 | &acpi_processor_latency_notifier); | ||
1831 | #endif | ||
1832 | } | 1216 | } |
1833 | 1217 | ||
1834 | if (!pr) | 1218 | if (!pr) |
@@ -1852,11 +1236,9 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
1852 | * platforms that only support C1. | 1236 | * platforms that only support C1. |
1853 | */ | 1237 | */ |
1854 | if (pr->flags.power) { | 1238 | if (pr->flags.power) { |
1855 | #ifdef CONFIG_CPU_IDLE | ||
1856 | acpi_processor_setup_cpuidle(pr); | 1239 | acpi_processor_setup_cpuidle(pr); |
1857 | if (cpuidle_register_device(&pr->power.dev)) | 1240 | if (cpuidle_register_device(&pr->power.dev)) |
1858 | return -EIO; | 1241 | return -EIO; |
1859 | #endif | ||
1860 | 1242 | ||
1861 | printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id); | 1243 | printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id); |
1862 | for (i = 1; i <= pr->power.count; i++) | 1244 | for (i = 1; i <= pr->power.count; i++) |
@@ -1864,13 +1246,6 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, | |||
1864 | printk(" C%d[C%d]", i, | 1246 | printk(" C%d[C%d]", i, |
1865 | pr->power.states[i].type); | 1247 | pr->power.states[i].type); |
1866 | printk(")\n"); | 1248 | printk(")\n"); |
1867 | |||
1868 | #ifndef CONFIG_CPU_IDLE | ||
1869 | if (pr->id == 0) { | ||
1870 | pm_idle_save = pm_idle; | ||
1871 | pm_idle = acpi_processor_idle; | ||
1872 | } | ||
1873 | #endif | ||
1874 | } | 1249 | } |
1875 | 1250 | ||
1876 | /* 'power' [R] */ | 1251 | /* 'power' [R] */ |
@@ -1889,34 +1264,12 @@ int acpi_processor_power_exit(struct acpi_processor *pr, | |||
1889 | if (boot_option_idle_override) | 1264 | if (boot_option_idle_override) |
1890 | return 0; | 1265 | return 0; |
1891 | 1266 | ||
1892 | #ifdef CONFIG_CPU_IDLE | ||
1893 | cpuidle_unregister_device(&pr->power.dev); | 1267 | cpuidle_unregister_device(&pr->power.dev); |
1894 | #endif | ||
1895 | pr->flags.power_setup_done = 0; | 1268 | pr->flags.power_setup_done = 0; |
1896 | 1269 | ||
1897 | if (acpi_device_dir(device)) | 1270 | if (acpi_device_dir(device)) |
1898 | remove_proc_entry(ACPI_PROCESSOR_FILE_POWER, | 1271 | remove_proc_entry(ACPI_PROCESSOR_FILE_POWER, |
1899 | acpi_device_dir(device)); | 1272 | acpi_device_dir(device)); |
1900 | 1273 | ||
1901 | #ifndef CONFIG_CPU_IDLE | ||
1902 | |||
1903 | /* Unregister the idle handler when processor #0 is removed. */ | ||
1904 | if (pr->id == 0) { | ||
1905 | if (pm_idle_save) | ||
1906 | pm_idle = pm_idle_save; | ||
1907 | |||
1908 | /* | ||
1909 | * We are about to unload the current idle thread pm callback | ||
1910 | * (pm_idle), Wait for all processors to update cached/local | ||
1911 | * copies of pm_idle before proceeding. | ||
1912 | */ | ||
1913 | cpu_idle_wait(); | ||
1914 | #ifdef CONFIG_SMP | ||
1915 | pm_qos_remove_notifier(PM_QOS_CPU_DMA_LATENCY, | ||
1916 | &acpi_processor_latency_notifier); | ||
1917 | #endif | ||
1918 | } | ||
1919 | #endif | ||
1920 | |||
1921 | return 0; | 1274 | return 0; |
1922 | } | 1275 | } |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 846e227592d4..9cc769b587ff 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -31,14 +31,6 @@ | |||
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/cpufreq.h> | 32 | #include <linux/cpufreq.h> |
33 | 33 | ||
34 | #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF | ||
35 | #include <linux/proc_fs.h> | ||
36 | #include <linux/seq_file.h> | ||
37 | #include <linux/mutex.h> | ||
38 | |||
39 | #include <asm/uaccess.h> | ||
40 | #endif | ||
41 | |||
42 | #ifdef CONFIG_X86 | 34 | #ifdef CONFIG_X86 |
43 | #include <asm/cpufeature.h> | 35 | #include <asm/cpufeature.h> |
44 | #endif | 36 | #endif |
@@ -434,96 +426,6 @@ int acpi_processor_notify_smm(struct module *calling_module) | |||
434 | 426 | ||
435 | EXPORT_SYMBOL(acpi_processor_notify_smm); | 427 | EXPORT_SYMBOL(acpi_processor_notify_smm); |
436 | 428 | ||
437 | #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF | ||
438 | /* /proc/acpi/processor/../performance interface (DEPRECATED) */ | ||
439 | |||
440 | static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file); | ||
441 | static struct file_operations acpi_processor_perf_fops = { | ||
442 | .owner = THIS_MODULE, | ||
443 | .open = acpi_processor_perf_open_fs, | ||
444 | .read = seq_read, | ||
445 | .llseek = seq_lseek, | ||
446 | .release = single_release, | ||
447 | }; | ||
448 | |||
449 | static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) | ||
450 | { | ||
451 | struct acpi_processor *pr = seq->private; | ||
452 | int i; | ||
453 | |||
454 | |||
455 | if (!pr) | ||
456 | goto end; | ||
457 | |||
458 | if (!pr->performance) { | ||
459 | seq_puts(seq, "<not supported>\n"); | ||
460 | goto end; | ||
461 | } | ||
462 | |||
463 | seq_printf(seq, "state count: %d\n" | ||
464 | "active state: P%d\n", | ||
465 | pr->performance->state_count, pr->performance->state); | ||
466 | |||
467 | seq_puts(seq, "states:\n"); | ||
468 | for (i = 0; i < pr->performance->state_count; i++) | ||
469 | seq_printf(seq, | ||
470 | " %cP%d: %d MHz, %d mW, %d uS\n", | ||
471 | (i == pr->performance->state ? '*' : ' '), i, | ||
472 | (u32) pr->performance->states[i].core_frequency, | ||
473 | (u32) pr->performance->states[i].power, | ||
474 | (u32) pr->performance->states[i].transition_latency); | ||
475 | |||
476 | end: | ||
477 | return 0; | ||
478 | } | ||
479 | |||
480 | static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) | ||
481 | { | ||
482 | return single_open(file, acpi_processor_perf_seq_show, | ||
483 | PDE(inode)->data); | ||
484 | } | ||
485 | |||
486 | static void acpi_cpufreq_add_file(struct acpi_processor *pr) | ||
487 | { | ||
488 | struct acpi_device *device = NULL; | ||
489 | |||
490 | |||
491 | if (acpi_bus_get_device(pr->handle, &device)) | ||
492 | return; | ||
493 | |||
494 | /* add file 'performance' [R/W] */ | ||
495 | proc_create_data(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO, | ||
496 | acpi_device_dir(device), | ||
497 | &acpi_processor_perf_fops, acpi_driver_data(device)); | ||
498 | return; | ||
499 | } | ||
500 | |||
501 | static void acpi_cpufreq_remove_file(struct acpi_processor *pr) | ||
502 | { | ||
503 | struct acpi_device *device = NULL; | ||
504 | |||
505 | |||
506 | if (acpi_bus_get_device(pr->handle, &device)) | ||
507 | return; | ||
508 | |||
509 | /* remove file 'performance' */ | ||
510 | remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, | ||
511 | acpi_device_dir(device)); | ||
512 | |||
513 | return; | ||
514 | } | ||
515 | |||
516 | #else | ||
517 | static void acpi_cpufreq_add_file(struct acpi_processor *pr) | ||
518 | { | ||
519 | return; | ||
520 | } | ||
521 | static void acpi_cpufreq_remove_file(struct acpi_processor *pr) | ||
522 | { | ||
523 | return; | ||
524 | } | ||
525 | #endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */ | ||
526 | |||
527 | static int acpi_processor_get_psd(struct acpi_processor *pr) | 429 | static int acpi_processor_get_psd(struct acpi_processor *pr) |
528 | { | 430 | { |
529 | int result = 0; | 431 | int result = 0; |
@@ -747,14 +649,12 @@ err_ret: | |||
747 | } | 649 | } |
748 | EXPORT_SYMBOL(acpi_processor_preregister_performance); | 650 | EXPORT_SYMBOL(acpi_processor_preregister_performance); |
749 | 651 | ||
750 | |||
751 | int | 652 | int |
752 | acpi_processor_register_performance(struct acpi_processor_performance | 653 | acpi_processor_register_performance(struct acpi_processor_performance |
753 | *performance, unsigned int cpu) | 654 | *performance, unsigned int cpu) |
754 | { | 655 | { |
755 | struct acpi_processor *pr; | 656 | struct acpi_processor *pr; |
756 | 657 | ||
757 | |||
758 | if (!(acpi_processor_ppc_status & PPC_REGISTERED)) | 658 | if (!(acpi_processor_ppc_status & PPC_REGISTERED)) |
759 | return -EINVAL; | 659 | return -EINVAL; |
760 | 660 | ||
@@ -781,8 +681,6 @@ acpi_processor_register_performance(struct acpi_processor_performance | |||
781 | return -EIO; | 681 | return -EIO; |
782 | } | 682 | } |
783 | 683 | ||
784 | acpi_cpufreq_add_file(pr); | ||
785 | |||
786 | mutex_unlock(&performance_mutex); | 684 | mutex_unlock(&performance_mutex); |
787 | return 0; | 685 | return 0; |
788 | } | 686 | } |
@@ -795,7 +693,6 @@ acpi_processor_unregister_performance(struct acpi_processor_performance | |||
795 | { | 693 | { |
796 | struct acpi_processor *pr; | 694 | struct acpi_processor *pr; |
797 | 695 | ||
798 | |||
799 | mutex_lock(&performance_mutex); | 696 | mutex_lock(&performance_mutex); |
800 | 697 | ||
801 | pr = per_cpu(processors, cpu); | 698 | pr = per_cpu(processors, cpu); |
@@ -808,8 +705,6 @@ acpi_processor_unregister_performance(struct acpi_processor_performance | |||
808 | kfree(pr->performance->states); | 705 | kfree(pr->performance->states); |
809 | pr->performance = NULL; | 706 | pr->performance = NULL; |
810 | 707 | ||
811 | acpi_cpufreq_remove_file(pr); | ||
812 | |||
813 | mutex_unlock(&performance_mutex); | 708 | mutex_unlock(&performance_mutex); |
814 | 709 | ||
815 | return; | 710 | return; |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 7e3c609cbef2..519266654f06 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -90,31 +90,6 @@ void __init acpi_old_suspend_ordering(void) | |||
90 | old_suspend_ordering = true; | 90 | old_suspend_ordering = true; |
91 | } | 91 | } |
92 | 92 | ||
93 | /* | ||
94 | * According to the ACPI specification the BIOS should make sure that ACPI is | ||
95 | * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still, | ||
96 | * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI | ||
97 | * on such systems during resume. Unfortunately that doesn't help in | ||
98 | * particularly pathological cases in which SCI_EN has to be set directly on | ||
99 | * resume, although the specification states very clearly that this flag is | ||
100 | * owned by the hardware. The set_sci_en_on_resume variable will be set in such | ||
101 | * cases. | ||
102 | */ | ||
103 | static bool set_sci_en_on_resume; | ||
104 | /* | ||
105 | * The ACPI specification wants us to save NVS memory regions during hibernation | ||
106 | * and to restore them during the subsequent resume. However, it is not certain | ||
107 | * if this mechanism is going to work on all machines, so we allow the user to | ||
108 | * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line | ||
109 | * option. | ||
110 | */ | ||
111 | static bool s4_no_nvs; | ||
112 | |||
113 | void __init acpi_s4_no_nvs(void) | ||
114 | { | ||
115 | s4_no_nvs = true; | ||
116 | } | ||
117 | |||
118 | /** | 93 | /** |
119 | * acpi_pm_disable_gpes - Disable the GPEs. | 94 | * acpi_pm_disable_gpes - Disable the GPEs. |
120 | */ | 95 | */ |
@@ -193,6 +168,18 @@ static void acpi_pm_end(void) | |||
193 | #endif /* CONFIG_ACPI_SLEEP */ | 168 | #endif /* CONFIG_ACPI_SLEEP */ |
194 | 169 | ||
195 | #ifdef CONFIG_SUSPEND | 170 | #ifdef CONFIG_SUSPEND |
171 | /* | ||
172 | * According to the ACPI specification the BIOS should make sure that ACPI is | ||
173 | * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still, | ||
174 | * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI | ||
175 | * on such systems during resume. Unfortunately that doesn't help in | ||
176 | * particularly pathological cases in which SCI_EN has to be set directly on | ||
177 | * resume, although the specification states very clearly that this flag is | ||
178 | * owned by the hardware. The set_sci_en_on_resume variable will be set in such | ||
179 | * cases. | ||
180 | */ | ||
181 | static bool set_sci_en_on_resume; | ||
182 | |||
196 | extern void do_suspend_lowlevel(void); | 183 | extern void do_suspend_lowlevel(void); |
197 | 184 | ||
198 | static u32 acpi_suspend_states[] = { | 185 | static u32 acpi_suspend_states[] = { |
@@ -396,6 +383,20 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = { | |||
396 | #endif /* CONFIG_SUSPEND */ | 383 | #endif /* CONFIG_SUSPEND */ |
397 | 384 | ||
398 | #ifdef CONFIG_HIBERNATION | 385 | #ifdef CONFIG_HIBERNATION |
386 | /* | ||
387 | * The ACPI specification wants us to save NVS memory regions during hibernation | ||
388 | * and to restore them during the subsequent resume. However, it is not certain | ||
389 | * if this mechanism is going to work on all machines, so we allow the user to | ||
390 | * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line | ||
391 | * option. | ||
392 | */ | ||
393 | static bool s4_no_nvs; | ||
394 | |||
395 | void __init acpi_s4_no_nvs(void) | ||
396 | { | ||
397 | s4_no_nvs = true; | ||
398 | } | ||
399 | |||
399 | static unsigned long s4_hardware_signature; | 400 | static unsigned long s4_hardware_signature; |
400 | static struct acpi_table_facs *facs; | 401 | static struct acpi_table_facs *facs; |
401 | static bool nosigcheck; | 402 | static bool nosigcheck; |
@@ -679,7 +680,7 @@ static void acpi_power_off_prepare(void) | |||
679 | static void acpi_power_off(void) | 680 | static void acpi_power_off(void) |
680 | { | 681 | { |
681 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ | 682 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ |
682 | printk("%s called\n", __func__); | 683 | printk(KERN_DEBUG "%s called\n", __func__); |
683 | local_irq_disable(); | 684 | local_irq_disable(); |
684 | acpi_enable_wakeup_device(ACPI_STATE_S5); | 685 | acpi_enable_wakeup_device(ACPI_STATE_S5); |
685 | acpi_enter_sleep_state(ACPI_STATE_S5); | 686 | acpi_enter_sleep_state(ACPI_STATE_S5); |
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 775c97a282bd..a8852952fac4 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -293,7 +293,12 @@ static void __init check_multiple_madt(void) | |||
293 | 293 | ||
294 | int __init acpi_table_init(void) | 294 | int __init acpi_table_init(void) |
295 | { | 295 | { |
296 | acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); | 296 | acpi_status status; |
297 | |||
298 | status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); | ||
299 | if (ACPI_FAILURE(status)) | ||
300 | return 1; | ||
301 | |||
297 | check_multiple_madt(); | 302 | check_multiple_madt(); |
298 | return 0; | 303 | return 0; |
299 | } | 304 | } |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index f261737636da..bb5ed059114a 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -1020,7 +1020,7 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset) | |||
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | seq_printf(seq, "levels: "); | 1022 | seq_printf(seq, "levels: "); |
1023 | for (i = 0; i < dev->brightness->count; i++) | 1023 | for (i = 2; i < dev->brightness->count; i++) |
1024 | seq_printf(seq, " %d", dev->brightness->levels[i]); | 1024 | seq_printf(seq, " %d", dev->brightness->levels[i]); |
1025 | seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr); | 1025 | seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr); |
1026 | 1026 | ||
@@ -1059,7 +1059,7 @@ acpi_video_device_write_brightness(struct file *file, | |||
1059 | return -EFAULT; | 1059 | return -EFAULT; |
1060 | 1060 | ||
1061 | /* validate through the list of available levels */ | 1061 | /* validate through the list of available levels */ |
1062 | for (i = 0; i < dev->brightness->count; i++) | 1062 | for (i = 2; i < dev->brightness->count; i++) |
1063 | if (level == dev->brightness->levels[i]) { | 1063 | if (level == dev->brightness->levels[i]) { |
1064 | if (ACPI_SUCCESS | 1064 | if (ACPI_SUCCESS |
1065 | (acpi_video_device_lcd_set_level(dev, level))) | 1065 | (acpi_video_device_lcd_set_level(dev, level))) |
@@ -1260,7 +1260,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) | |||
1260 | printk(KERN_WARNING PREFIX | 1260 | printk(KERN_WARNING PREFIX |
1261 | "This indicates a BIOS bug. Please contact the manufacturer.\n"); | 1261 | "This indicates a BIOS bug. Please contact the manufacturer.\n"); |
1262 | } | 1262 | } |
1263 | printk("%llx\n", options); | 1263 | printk(KERN_WARNING "%llx\n", options); |
1264 | seq_printf(seq, "can POST: <integrated video>"); | 1264 | seq_printf(seq, "can POST: <integrated video>"); |
1265 | if (options & 2) | 1265 | if (options & 2) |
1266 | seq_printf(seq, " <PCI video>"); | 1266 | seq_printf(seq, " <PCI video>"); |
@@ -1712,7 +1712,7 @@ acpi_video_get_next_level(struct acpi_video_device *device, | |||
1712 | max = max_below = 0; | 1712 | max = max_below = 0; |
1713 | min = min_above = 255; | 1713 | min = min_above = 255; |
1714 | /* Find closest level to level_current */ | 1714 | /* Find closest level to level_current */ |
1715 | for (i = 0; i < device->brightness->count; i++) { | 1715 | for (i = 2; i < device->brightness->count; i++) { |
1716 | l = device->brightness->levels[i]; | 1716 | l = device->brightness->levels[i]; |
1717 | if (abs(l - level_current) < abs(delta)) { | 1717 | if (abs(l - level_current) < abs(delta)) { |
1718 | delta = l - level_current; | 1718 | delta = l - level_current; |
@@ -1722,7 +1722,7 @@ acpi_video_get_next_level(struct acpi_video_device *device, | |||
1722 | } | 1722 | } |
1723 | /* Ajust level_current to closest available level */ | 1723 | /* Ajust level_current to closest available level */ |
1724 | level_current += delta; | 1724 | level_current += delta; |
1725 | for (i = 0; i < device->brightness->count; i++) { | 1725 | for (i = 2; i < device->brightness->count; i++) { |
1726 | l = device->brightness->levels[i]; | 1726 | l = device->brightness->levels[i]; |
1727 | if (l < min) | 1727 | if (l < min) |
1728 | min = l; | 1728 | min = l; |
@@ -2006,6 +2006,12 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
2006 | device->pnp.bus_id[3] = '0' + instance; | 2006 | device->pnp.bus_id[3] = '0' + instance; |
2007 | instance ++; | 2007 | instance ++; |
2008 | } | 2008 | } |
2009 | /* a hack to fix the duplicate name "VGA" problem on Pa 3553 */ | ||
2010 | if (!strcmp(device->pnp.bus_id, "VGA")) { | ||
2011 | if (instance) | ||
2012 | device->pnp.bus_id[3] = '0' + instance; | ||
2013 | instance++; | ||
2014 | } | ||
2009 | 2015 | ||
2010 | video->device = device; | 2016 | video->device = device; |
2011 | strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); | 2017 | strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 77bba4c083cb..a603bbf9b1b7 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -61,9 +61,14 @@ | |||
61 | #define EM_MSG_LED_VALUE_ON 0x00010000 | 61 | #define EM_MSG_LED_VALUE_ON 0x00010000 |
62 | 62 | ||
63 | static int ahci_skip_host_reset; | 63 | static int ahci_skip_host_reset; |
64 | static int ahci_ignore_sss; | ||
65 | |||
64 | module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444); | 66 | module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444); |
65 | MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)"); | 67 | MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)"); |
66 | 68 | ||
69 | module_param_named(ignore_sss, ahci_ignore_sss, int, 0444); | ||
70 | MODULE_PARM_DESC(ignore_sss, "Ignore staggered spinup flag (0=don't ignore, 1=ignore)"); | ||
71 | |||
67 | static int ahci_enable_alpm(struct ata_port *ap, | 72 | static int ahci_enable_alpm(struct ata_port *ap, |
68 | enum link_pm policy); | 73 | enum link_pm policy); |
69 | static void ahci_disable_alpm(struct ata_port *ap); | 74 | static void ahci_disable_alpm(struct ata_port *ap); |
@@ -2692,8 +2697,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2692 | host->iomap = pcim_iomap_table(pdev); | 2697 | host->iomap = pcim_iomap_table(pdev); |
2693 | host->private_data = hpriv; | 2698 | host->private_data = hpriv; |
2694 | 2699 | ||
2695 | if (!(hpriv->cap & HOST_CAP_SSS)) | 2700 | if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) |
2696 | host->flags |= ATA_HOST_PARALLEL_SCAN; | 2701 | host->flags |= ATA_HOST_PARALLEL_SCAN; |
2702 | else | ||
2703 | printk(KERN_INFO "ahci: SSS flag set, parallel bus scan disabled\n"); | ||
2697 | 2704 | ||
2698 | if (pi.flags & ATA_FLAG_EM) | 2705 | if (pi.flags & ATA_FLAG_EM) |
2699 | ahci_reset_em(host); | 2706 | ahci_reset_em(host); |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 88c242856dae..9fbf0595f3d4 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -164,6 +164,11 @@ MODULE_LICENSE("GPL"); | |||
164 | MODULE_VERSION(DRV_VERSION); | 164 | MODULE_VERSION(DRV_VERSION); |
165 | 165 | ||
166 | 166 | ||
167 | static bool ata_sstatus_online(u32 sstatus) | ||
168 | { | ||
169 | return (sstatus & 0xf) == 0x3; | ||
170 | } | ||
171 | |||
167 | /** | 172 | /** |
168 | * ata_link_next - link iteration helper | 173 | * ata_link_next - link iteration helper |
169 | * @link: the previous link, NULL to start | 174 | * @link: the previous link, NULL to start |
@@ -1015,18 +1020,6 @@ static const char *sata_spd_string(unsigned int spd) | |||
1015 | return spd_str[spd - 1]; | 1020 | return spd_str[spd - 1]; |
1016 | } | 1021 | } |
1017 | 1022 | ||
1018 | void ata_dev_disable(struct ata_device *dev) | ||
1019 | { | ||
1020 | if (ata_dev_enabled(dev)) { | ||
1021 | if (ata_msg_drv(dev->link->ap)) | ||
1022 | ata_dev_printk(dev, KERN_WARNING, "disabled\n"); | ||
1023 | ata_acpi_on_disable(dev); | ||
1024 | ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | | ||
1025 | ATA_DNXFER_QUIET); | ||
1026 | dev->class++; | ||
1027 | } | ||
1028 | } | ||
1029 | |||
1030 | static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy) | 1023 | static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy) |
1031 | { | 1024 | { |
1032 | struct ata_link *link = dev->link; | 1025 | struct ata_link *link = dev->link; |
@@ -2239,6 +2232,40 @@ retry: | |||
2239 | return rc; | 2232 | return rc; |
2240 | } | 2233 | } |
2241 | 2234 | ||
2235 | static int ata_do_link_spd_horkage(struct ata_device *dev) | ||
2236 | { | ||
2237 | struct ata_link *plink = ata_dev_phys_link(dev); | ||
2238 | u32 target, target_limit; | ||
2239 | |||
2240 | if (!sata_scr_valid(plink)) | ||
2241 | return 0; | ||
2242 | |||
2243 | if (dev->horkage & ATA_HORKAGE_1_5_GBPS) | ||
2244 | target = 1; | ||
2245 | else | ||
2246 | return 0; | ||
2247 | |||
2248 | target_limit = (1 << target) - 1; | ||
2249 | |||
2250 | /* if already on stricter limit, no need to push further */ | ||
2251 | if (plink->sata_spd_limit <= target_limit) | ||
2252 | return 0; | ||
2253 | |||
2254 | plink->sata_spd_limit = target_limit; | ||
2255 | |||
2256 | /* Request another EH round by returning -EAGAIN if link is | ||
2257 | * going faster than the target speed. Forward progress is | ||
2258 | * guaranteed by setting sata_spd_limit to target_limit above. | ||
2259 | */ | ||
2260 | if (plink->sata_spd > target) { | ||
2261 | ata_dev_printk(dev, KERN_INFO, | ||
2262 | "applying link speed limit horkage to %s\n", | ||
2263 | sata_spd_string(target)); | ||
2264 | return -EAGAIN; | ||
2265 | } | ||
2266 | return 0; | ||
2267 | } | ||
2268 | |||
2242 | static inline u8 ata_dev_knobble(struct ata_device *dev) | 2269 | static inline u8 ata_dev_knobble(struct ata_device *dev) |
2243 | { | 2270 | { |
2244 | struct ata_port *ap = dev->link->ap; | 2271 | struct ata_port *ap = dev->link->ap; |
@@ -2329,6 +2356,10 @@ int ata_dev_configure(struct ata_device *dev) | |||
2329 | return 0; | 2356 | return 0; |
2330 | } | 2357 | } |
2331 | 2358 | ||
2359 | rc = ata_do_link_spd_horkage(dev); | ||
2360 | if (rc) | ||
2361 | return rc; | ||
2362 | |||
2332 | /* let ACPI work its magic */ | 2363 | /* let ACPI work its magic */ |
2333 | rc = ata_acpi_on_devcfg(dev); | 2364 | rc = ata_acpi_on_devcfg(dev); |
2334 | if (rc) | 2365 | if (rc) |
@@ -2784,7 +2815,7 @@ int ata_bus_probe(struct ata_port *ap) | |||
2784 | /* This is the last chance, better to slow | 2815 | /* This is the last chance, better to slow |
2785 | * down than lose it. | 2816 | * down than lose it. |
2786 | */ | 2817 | */ |
2787 | sata_down_spd_limit(&ap->link); | 2818 | sata_down_spd_limit(&ap->link, 0); |
2788 | ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); | 2819 | ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); |
2789 | } | 2820 | } |
2790 | } | 2821 | } |
@@ -2880,21 +2911,27 @@ void ata_port_disable(struct ata_port *ap) | |||
2880 | /** | 2911 | /** |
2881 | * sata_down_spd_limit - adjust SATA spd limit downward | 2912 | * sata_down_spd_limit - adjust SATA spd limit downward |
2882 | * @link: Link to adjust SATA spd limit for | 2913 | * @link: Link to adjust SATA spd limit for |
2914 | * @spd_limit: Additional limit | ||
2883 | * | 2915 | * |
2884 | * Adjust SATA spd limit of @link downward. Note that this | 2916 | * Adjust SATA spd limit of @link downward. Note that this |
2885 | * function only adjusts the limit. The change must be applied | 2917 | * function only adjusts the limit. The change must be applied |
2886 | * using sata_set_spd(). | 2918 | * using sata_set_spd(). |
2887 | * | 2919 | * |
2920 | * If @spd_limit is non-zero, the speed is limited to equal to or | ||
2921 | * lower than @spd_limit if such speed is supported. If | ||
2922 | * @spd_limit is slower than any supported speed, only the lowest | ||
2923 | * supported speed is allowed. | ||
2924 | * | ||
2888 | * LOCKING: | 2925 | * LOCKING: |
2889 | * Inherited from caller. | 2926 | * Inherited from caller. |
2890 | * | 2927 | * |
2891 | * RETURNS: | 2928 | * RETURNS: |
2892 | * 0 on success, negative errno on failure | 2929 | * 0 on success, negative errno on failure |
2893 | */ | 2930 | */ |
2894 | int sata_down_spd_limit(struct ata_link *link) | 2931 | int sata_down_spd_limit(struct ata_link *link, u32 spd_limit) |
2895 | { | 2932 | { |
2896 | u32 sstatus, spd, mask; | 2933 | u32 sstatus, spd, mask; |
2897 | int rc, highbit; | 2934 | int rc, bit; |
2898 | 2935 | ||
2899 | if (!sata_scr_valid(link)) | 2936 | if (!sata_scr_valid(link)) |
2900 | return -EOPNOTSUPP; | 2937 | return -EOPNOTSUPP; |
@@ -2903,7 +2940,7 @@ int sata_down_spd_limit(struct ata_link *link) | |||
2903 | * If not, use cached value in link->sata_spd. | 2940 | * If not, use cached value in link->sata_spd. |
2904 | */ | 2941 | */ |
2905 | rc = sata_scr_read(link, SCR_STATUS, &sstatus); | 2942 | rc = sata_scr_read(link, SCR_STATUS, &sstatus); |
2906 | if (rc == 0) | 2943 | if (rc == 0 && ata_sstatus_online(sstatus)) |
2907 | spd = (sstatus >> 4) & 0xf; | 2944 | spd = (sstatus >> 4) & 0xf; |
2908 | else | 2945 | else |
2909 | spd = link->sata_spd; | 2946 | spd = link->sata_spd; |
@@ -2913,8 +2950,8 @@ int sata_down_spd_limit(struct ata_link *link) | |||
2913 | return -EINVAL; | 2950 | return -EINVAL; |
2914 | 2951 | ||
2915 | /* unconditionally mask off the highest bit */ | 2952 | /* unconditionally mask off the highest bit */ |
2916 | highbit = fls(mask) - 1; | 2953 | bit = fls(mask) - 1; |
2917 | mask &= ~(1 << highbit); | 2954 | mask &= ~(1 << bit); |
2918 | 2955 | ||
2919 | /* Mask off all speeds higher than or equal to the current | 2956 | /* Mask off all speeds higher than or equal to the current |
2920 | * one. Force 1.5Gbps if current SPD is not available. | 2957 | * one. Force 1.5Gbps if current SPD is not available. |
@@ -2928,6 +2965,15 @@ int sata_down_spd_limit(struct ata_link *link) | |||
2928 | if (!mask) | 2965 | if (!mask) |
2929 | return -EINVAL; | 2966 | return -EINVAL; |
2930 | 2967 | ||
2968 | if (spd_limit) { | ||
2969 | if (mask & ((1 << spd_limit) - 1)) | ||
2970 | mask &= (1 << spd_limit) - 1; | ||
2971 | else { | ||
2972 | bit = ffs(mask) - 1; | ||
2973 | mask = 1 << bit; | ||
2974 | } | ||
2975 | } | ||
2976 | |||
2931 | link->sata_spd_limit = mask; | 2977 | link->sata_spd_limit = mask; |
2932 | 2978 | ||
2933 | ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n", | 2979 | ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n", |
@@ -4215,6 +4261,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4215 | /* Devices that do not need bridging limits applied */ | 4261 | /* Devices that do not need bridging limits applied */ |
4216 | { "MTRON MSP-SATA*", NULL, ATA_HORKAGE_BRIDGE_OK, }, | 4262 | { "MTRON MSP-SATA*", NULL, ATA_HORKAGE_BRIDGE_OK, }, |
4217 | 4263 | ||
4264 | /* Devices which aren't very happy with higher link speeds */ | ||
4265 | { "WD My Book", NULL, ATA_HORKAGE_1_5_GBPS, }, | ||
4266 | |||
4218 | /* End Marker */ | 4267 | /* End Marker */ |
4219 | { } | 4268 | { } |
4220 | }; | 4269 | }; |
@@ -4709,8 +4758,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) | |||
4709 | 4758 | ||
4710 | /** | 4759 | /** |
4711 | * ata_qc_new - Request an available ATA command, for queueing | 4760 | * ata_qc_new - Request an available ATA command, for queueing |
4712 | * @ap: Port associated with device @dev | 4761 | * @ap: target port |
4713 | * @dev: Device from whom we request an available command structure | ||
4714 | * | 4762 | * |
4715 | * LOCKING: | 4763 | * LOCKING: |
4716 | * None. | 4764 | * None. |
@@ -5175,7 +5223,7 @@ bool ata_phys_link_online(struct ata_link *link) | |||
5175 | u32 sstatus; | 5223 | u32 sstatus; |
5176 | 5224 | ||
5177 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && | 5225 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && |
5178 | (sstatus & 0xf) == 0x3) | 5226 | ata_sstatus_online(sstatus)) |
5179 | return true; | 5227 | return true; |
5180 | return false; | 5228 | return false; |
5181 | } | 5229 | } |
@@ -5199,7 +5247,7 @@ bool ata_phys_link_offline(struct ata_link *link) | |||
5199 | u32 sstatus; | 5247 | u32 sstatus; |
5200 | 5248 | ||
5201 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && | 5249 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && |
5202 | (sstatus & 0xf) != 0x3) | 5250 | !ata_sstatus_online(sstatus)) |
5203 | return true; | 5251 | return true; |
5204 | return false; | 5252 | return false; |
5205 | } | 5253 | } |
@@ -5412,8 +5460,8 @@ void ata_dev_init(struct ata_device *dev) | |||
5412 | dev->horkage = 0; | 5460 | dev->horkage = 0; |
5413 | spin_unlock_irqrestore(ap->lock, flags); | 5461 | spin_unlock_irqrestore(ap->lock, flags); |
5414 | 5462 | ||
5415 | memset((void *)dev + ATA_DEVICE_CLEAR_OFFSET, 0, | 5463 | memset((void *)dev + ATA_DEVICE_CLEAR_BEGIN, 0, |
5416 | sizeof(*dev) - ATA_DEVICE_CLEAR_OFFSET); | 5464 | ATA_DEVICE_CLEAR_END - ATA_DEVICE_CLEAR_BEGIN); |
5417 | dev->pio_mask = UINT_MAX; | 5465 | dev->pio_mask = UINT_MAX; |
5418 | dev->mwdma_mask = UINT_MAX; | 5466 | dev->mwdma_mask = UINT_MAX; |
5419 | dev->udma_mask = UINT_MAX; | 5467 | dev->udma_mask = UINT_MAX; |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 8147a8386370..ce2ef0475339 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -82,6 +82,10 @@ enum { | |||
82 | ATA_EH_FASTDRAIN_INTERVAL = 3000, | 82 | ATA_EH_FASTDRAIN_INTERVAL = 3000, |
83 | 83 | ||
84 | ATA_EH_UA_TRIES = 5, | 84 | ATA_EH_UA_TRIES = 5, |
85 | |||
86 | /* probe speed down parameters, see ata_eh_schedule_probe() */ | ||
87 | ATA_EH_PROBE_TRIAL_INTERVAL = 60000, /* 1 min */ | ||
88 | ATA_EH_PROBE_TRIALS = 2, | ||
85 | }; | 89 | }; |
86 | 90 | ||
87 | /* The following table determines how we sequence resets. Each entry | 91 | /* The following table determines how we sequence resets. Each entry |
@@ -1176,6 +1180,32 @@ void ata_eh_qc_retry(struct ata_queued_cmd *qc) | |||
1176 | } | 1180 | } |
1177 | 1181 | ||
1178 | /** | 1182 | /** |
1183 | * ata_dev_disable - disable ATA device | ||
1184 | * @dev: ATA device to disable | ||
1185 | * | ||
1186 | * Disable @dev. | ||
1187 | * | ||
1188 | * Locking: | ||
1189 | * EH context. | ||
1190 | */ | ||
1191 | void ata_dev_disable(struct ata_device *dev) | ||
1192 | { | ||
1193 | if (!ata_dev_enabled(dev)) | ||
1194 | return; | ||
1195 | |||
1196 | if (ata_msg_drv(dev->link->ap)) | ||
1197 | ata_dev_printk(dev, KERN_WARNING, "disabled\n"); | ||
1198 | ata_acpi_on_disable(dev); | ||
1199 | ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | ATA_DNXFER_QUIET); | ||
1200 | dev->class++; | ||
1201 | |||
1202 | /* From now till the next successful probe, ering is used to | ||
1203 | * track probe failures. Clear accumulated device error info. | ||
1204 | */ | ||
1205 | ata_ering_clear(&dev->ering); | ||
1206 | } | ||
1207 | |||
1208 | /** | ||
1179 | * ata_eh_detach_dev - detach ATA device | 1209 | * ata_eh_detach_dev - detach ATA device |
1180 | * @dev: ATA device to detach | 1210 | * @dev: ATA device to detach |
1181 | * | 1211 | * |
@@ -1849,7 +1879,7 @@ static unsigned int ata_eh_speed_down(struct ata_device *dev, | |||
1849 | /* speed down? */ | 1879 | /* speed down? */ |
1850 | if (verdict & ATA_EH_SPDN_SPEED_DOWN) { | 1880 | if (verdict & ATA_EH_SPDN_SPEED_DOWN) { |
1851 | /* speed down SATA link speed if possible */ | 1881 | /* speed down SATA link speed if possible */ |
1852 | if (sata_down_spd_limit(link) == 0) { | 1882 | if (sata_down_spd_limit(link, 0) == 0) { |
1853 | action |= ATA_EH_RESET; | 1883 | action |= ATA_EH_RESET; |
1854 | goto done; | 1884 | goto done; |
1855 | } | 1885 | } |
@@ -2601,11 +2631,11 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2601 | } | 2631 | } |
2602 | 2632 | ||
2603 | if (try == max_tries - 1) { | 2633 | if (try == max_tries - 1) { |
2604 | sata_down_spd_limit(link); | 2634 | sata_down_spd_limit(link, 0); |
2605 | if (slave) | 2635 | if (slave) |
2606 | sata_down_spd_limit(slave); | 2636 | sata_down_spd_limit(slave, 0); |
2607 | } else if (rc == -EPIPE) | 2637 | } else if (rc == -EPIPE) |
2608 | sata_down_spd_limit(failed_link); | 2638 | sata_down_spd_limit(failed_link, 0); |
2609 | 2639 | ||
2610 | if (hardreset) | 2640 | if (hardreset) |
2611 | reset = hardreset; | 2641 | reset = hardreset; |
@@ -2744,6 +2774,8 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link, | |||
2744 | readid_flags, dev->id); | 2774 | readid_flags, dev->id); |
2745 | switch (rc) { | 2775 | switch (rc) { |
2746 | case 0: | 2776 | case 0: |
2777 | /* clear error info accumulated during probe */ | ||
2778 | ata_ering_clear(&dev->ering); | ||
2747 | new_mask |= 1 << dev->devno; | 2779 | new_mask |= 1 << dev->devno; |
2748 | break; | 2780 | break; |
2749 | case -ENOENT: | 2781 | case -ENOENT: |
@@ -2947,9 +2979,24 @@ static int ata_eh_skip_recovery(struct ata_link *link) | |||
2947 | return 1; | 2979 | return 1; |
2948 | } | 2980 | } |
2949 | 2981 | ||
2982 | static int ata_count_probe_trials_cb(struct ata_ering_entry *ent, void *void_arg) | ||
2983 | { | ||
2984 | u64 interval = msecs_to_jiffies(ATA_EH_PROBE_TRIAL_INTERVAL); | ||
2985 | u64 now = get_jiffies_64(); | ||
2986 | int *trials = void_arg; | ||
2987 | |||
2988 | if (ent->timestamp < now - min(now, interval)) | ||
2989 | return -1; | ||
2990 | |||
2991 | (*trials)++; | ||
2992 | return 0; | ||
2993 | } | ||
2994 | |||
2950 | static int ata_eh_schedule_probe(struct ata_device *dev) | 2995 | static int ata_eh_schedule_probe(struct ata_device *dev) |
2951 | { | 2996 | { |
2952 | struct ata_eh_context *ehc = &dev->link->eh_context; | 2997 | struct ata_eh_context *ehc = &dev->link->eh_context; |
2998 | struct ata_link *link = ata_dev_phys_link(dev); | ||
2999 | int trials = 0; | ||
2953 | 3000 | ||
2954 | if (!(ehc->i.probe_mask & (1 << dev->devno)) || | 3001 | if (!(ehc->i.probe_mask & (1 << dev->devno)) || |
2955 | (ehc->did_probe_mask & (1 << dev->devno))) | 3002 | (ehc->did_probe_mask & (1 << dev->devno))) |
@@ -2962,6 +3009,25 @@ static int ata_eh_schedule_probe(struct ata_device *dev) | |||
2962 | ehc->saved_xfer_mode[dev->devno] = 0; | 3009 | ehc->saved_xfer_mode[dev->devno] = 0; |
2963 | ehc->saved_ncq_enabled &= ~(1 << dev->devno); | 3010 | ehc->saved_ncq_enabled &= ~(1 << dev->devno); |
2964 | 3011 | ||
3012 | /* Record and count probe trials on the ering. The specific | ||
3013 | * error mask used is irrelevant. Because a successful device | ||
3014 | * detection clears the ering, this count accumulates only if | ||
3015 | * there are consecutive failed probes. | ||
3016 | * | ||
3017 | * If the count is equal to or higher than ATA_EH_PROBE_TRIALS | ||
3018 | * in the last ATA_EH_PROBE_TRIAL_INTERVAL, link speed is | ||
3019 | * forced to 1.5Gbps. | ||
3020 | * | ||
3021 | * This is to work around cases where failed link speed | ||
3022 | * negotiation results in device misdetection leading to | ||
3023 | * infinite DEVXCHG or PHRDY CHG events. | ||
3024 | */ | ||
3025 | ata_ering_record(&dev->ering, 0, AC_ERR_OTHER); | ||
3026 | ata_ering_map(&dev->ering, ata_count_probe_trials_cb, &trials); | ||
3027 | |||
3028 | if (trials > ATA_EH_PROBE_TRIALS) | ||
3029 | sata_down_spd_limit(link, 1); | ||
3030 | |||
2965 | return 1; | 3031 | return 1; |
2966 | } | 3032 | } |
2967 | 3033 | ||
@@ -2969,7 +3035,11 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err) | |||
2969 | { | 3035 | { |
2970 | struct ata_eh_context *ehc = &dev->link->eh_context; | 3036 | struct ata_eh_context *ehc = &dev->link->eh_context; |
2971 | 3037 | ||
2972 | ehc->tries[dev->devno]--; | 3038 | /* -EAGAIN from EH routine indicates retry without prejudice. |
3039 | * The requester is responsible for ensuring forward progress. | ||
3040 | */ | ||
3041 | if (err != -EAGAIN) | ||
3042 | ehc->tries[dev->devno]--; | ||
2973 | 3043 | ||
2974 | switch (err) { | 3044 | switch (err) { |
2975 | case -ENODEV: | 3045 | case -ENODEV: |
@@ -2979,12 +3049,13 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err) | |||
2979 | /* give it just one more chance */ | 3049 | /* give it just one more chance */ |
2980 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); | 3050 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); |
2981 | case -EIO: | 3051 | case -EIO: |
2982 | if (ehc->tries[dev->devno] == 1 && dev->pio_mode > XFER_PIO_0) { | 3052 | if (ehc->tries[dev->devno] == 1) { |
2983 | /* This is the last chance, better to slow | 3053 | /* This is the last chance, better to slow |
2984 | * down than lose it. | 3054 | * down than lose it. |
2985 | */ | 3055 | */ |
2986 | sata_down_spd_limit(ata_dev_phys_link(dev)); | 3056 | sata_down_spd_limit(ata_dev_phys_link(dev), 0); |
2987 | ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); | 3057 | if (dev->pio_mode > XFER_PIO_0) |
3058 | ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); | ||
2988 | } | 3059 | } |
2989 | } | 3060 | } |
2990 | 3061 | ||
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c index 98ca07a2db87..619f2c33950e 100644 --- a/drivers/ata/libata-pmp.c +++ b/drivers/ata/libata-pmp.c | |||
@@ -729,7 +729,7 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap, | |||
729 | if (tries) { | 729 | if (tries) { |
730 | /* consecutive revalidation failures? speed down */ | 730 | /* consecutive revalidation failures? speed down */ |
731 | if (reval_failed) | 731 | if (reval_failed) |
732 | sata_down_spd_limit(link); | 732 | sata_down_spd_limit(link, 0); |
733 | else | 733 | else |
734 | reval_failed = 1; | 734 | reval_failed = 1; |
735 | 735 | ||
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 3c4c5ae277ba..b9747fa59e54 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -415,6 +415,7 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev, | |||
415 | 415 | ||
416 | /** | 416 | /** |
417 | * ata_get_identity - Handler for HDIO_GET_IDENTITY ioctl | 417 | * ata_get_identity - Handler for HDIO_GET_IDENTITY ioctl |
418 | * @ap: target port | ||
418 | * @sdev: SCSI device to get identify data for | 419 | * @sdev: SCSI device to get identify data for |
419 | * @arg: User buffer area for identify data | 420 | * @arg: User buffer area for identify data |
420 | * | 421 | * |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index fe2839e58774..cea8014cd87e 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -79,7 +79,6 @@ extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, | |||
79 | u64 block, u32 n_block, unsigned int tf_flags, | 79 | u64 block, u32 n_block, unsigned int tf_flags, |
80 | unsigned int tag); | 80 | unsigned int tag); |
81 | extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev); | 81 | extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev); |
82 | extern void ata_dev_disable(struct ata_device *dev); | ||
83 | extern void ata_pio_queue_task(struct ata_port *ap, void *data, | 82 | extern void ata_pio_queue_task(struct ata_port *ap, void *data, |
84 | unsigned long delay); | 83 | unsigned long delay); |
85 | extern void ata_port_flush_task(struct ata_port *ap); | 84 | extern void ata_port_flush_task(struct ata_port *ap); |
@@ -100,7 +99,7 @@ extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags); | |||
100 | extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, | 99 | extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, |
101 | unsigned int readid_flags); | 100 | unsigned int readid_flags); |
102 | extern int ata_dev_configure(struct ata_device *dev); | 101 | extern int ata_dev_configure(struct ata_device *dev); |
103 | extern int sata_down_spd_limit(struct ata_link *link); | 102 | extern int sata_down_spd_limit(struct ata_link *link, u32 spd_limit); |
104 | extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); | 103 | extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); |
105 | extern void ata_sg_clean(struct ata_queued_cmd *qc); | 104 | extern void ata_sg_clean(struct ata_queued_cmd *qc); |
106 | extern void ata_qc_free(struct ata_queued_cmd *qc); | 105 | extern void ata_qc_free(struct ata_queued_cmd *qc); |
@@ -160,6 +159,7 @@ extern void ata_scsi_error(struct Scsi_Host *host); | |||
160 | extern void ata_port_wait_eh(struct ata_port *ap); | 159 | extern void ata_port_wait_eh(struct ata_port *ap); |
161 | extern void ata_eh_fastdrain_timerfn(unsigned long arg); | 160 | extern void ata_eh_fastdrain_timerfn(unsigned long arg); |
162 | extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc); | 161 | extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc); |
162 | extern void ata_dev_disable(struct ata_device *dev); | ||
163 | extern void ata_eh_detach_dev(struct ata_device *dev); | 163 | extern void ata_eh_detach_dev(struct ata_device *dev); |
164 | extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev, | 164 | extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev, |
165 | unsigned int action); | 165 | unsigned int action); |
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c index 3080f371222c..f1b26f7c8e4d 100644 --- a/drivers/ata/pata_qdi.c +++ b/drivers/ata/pata_qdi.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * | 12 | * |
13 | * Probe code based on drivers/ide/legacy/qd65xx.c | 13 | * Probe code based on drivers/ide/legacy/qd65xx.c |
14 | * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by | 14 | * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by |
15 | * Samuel Thibault <samuel.thibault@fnac.net> | 15 | * Samuel Thibault <samuel.thibault@ens-lyon.org> |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index f2d8a020ea53..4ae1a4138b47 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -663,8 +663,8 @@ static const struct pci_device_id mv_pci_tbl[] = { | |||
663 | { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, | 663 | { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, |
664 | /* RocketRAID 1720/174x have different identifiers */ | 664 | /* RocketRAID 1720/174x have different identifiers */ |
665 | { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, | 665 | { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, |
666 | { PCI_VDEVICE(TTI, 0x1740), chip_508x }, | 666 | { PCI_VDEVICE(TTI, 0x1740), chip_6042 }, |
667 | { PCI_VDEVICE(TTI, 0x1742), chip_508x }, | 667 | { PCI_VDEVICE(TTI, 0x1742), chip_6042 }, |
668 | 668 | ||
669 | { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, | 669 | { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, |
670 | { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, | 670 | { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index c49ad0e61b6f..444af0415ca1 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -436,11 +436,16 @@ static struct ata_port_operations nv_nf2_ops = { | |||
436 | .hardreset = nv_noclassify_hardreset, | 436 | .hardreset = nv_noclassify_hardreset, |
437 | }; | 437 | }; |
438 | 438 | ||
439 | /* CK804 finally gets hardreset right */ | 439 | /* For initial probing after boot and hot plugging, hardreset mostly |
440 | * works fine on CK804 but curiously, reprobing on the initial port by | ||
441 | * rescanning or rmmod/insmod fails to acquire the initial D2H Reg FIS | ||
442 | * in somewhat undeterministic way. Use noclassify hardreset. | ||
443 | */ | ||
440 | static struct ata_port_operations nv_ck804_ops = { | 444 | static struct ata_port_operations nv_ck804_ops = { |
441 | .inherits = &nv_common_ops, | 445 | .inherits = &nv_common_ops, |
442 | .freeze = nv_ck804_freeze, | 446 | .freeze = nv_ck804_freeze, |
443 | .thaw = nv_ck804_thaw, | 447 | .thaw = nv_ck804_thaw, |
448 | .hardreset = nv_noclassify_hardreset, | ||
444 | .host_stop = nv_ck804_host_stop, | 449 | .host_stop = nv_ck804_host_stop, |
445 | }; | 450 | }; |
446 | 451 | ||
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 9f029595f454..d0091609e210 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -324,7 +324,7 @@ static void sil_fill_sg(struct ata_queued_cmd *qc) | |||
324 | 324 | ||
325 | prd->addr = cpu_to_le32(addr); | 325 | prd->addr = cpu_to_le32(addr); |
326 | prd->flags_len = cpu_to_le32(sg_len); | 326 | prd->flags_len = cpu_to_le32(sg_len); |
327 | VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", pi, addr, sg_len); | 327 | VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", si, addr, sg_len); |
328 | 328 | ||
329 | last_prd = prd; | 329 | last_prd = prd; |
330 | prd++; | 330 | prd++; |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index f5be8081cd81..735bbe2be51a 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -761,7 +761,7 @@ source "drivers/char/hw_random/Kconfig" | |||
761 | 761 | ||
762 | config NVRAM | 762 | config NVRAM |
763 | tristate "/dev/nvram support" | 763 | tristate "/dev/nvram support" |
764 | depends on ATARI || X86 || ARM || GENERIC_NVRAM | 764 | depends on ATARI || X86 || (ARM && RTC_DRV_CMOS) || GENERIC_NVRAM |
765 | ---help--- | 765 | ---help--- |
766 | If you say Y here and create a character special file /dev/nvram | 766 | If you say Y here and create a character special file /dev/nvram |
767 | with major number 10 and minor number 144 using mknod ("man mknod"), | 767 | with major number 10 and minor number 144 using mknod ("man mknod"), |
diff --git a/drivers/char/selection.c b/drivers/char/selection.c index f29fbe9b8ed7..cb8ca5698963 100644 --- a/drivers/char/selection.c +++ b/drivers/char/selection.c | |||
@@ -268,7 +268,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t | |||
268 | 268 | ||
269 | /* Allocate a new buffer before freeing the old one ... */ | 269 | /* Allocate a new buffer before freeing the old one ... */ |
270 | multiplier = use_unicode ? 3 : 1; /* chars can take up to 3 bytes */ | 270 | multiplier = use_unicode ? 3 : 1; /* chars can take up to 3 bytes */ |
271 | bp = kmalloc((sel_end-sel_start)/2*multiplier+1, GFP_KERNEL); | 271 | bp = kmalloc(((sel_end-sel_start)/2+1)*multiplier, GFP_KERNEL); |
272 | if (!bp) { | 272 | if (!bp) { |
273 | printk(KERN_WARNING "selection: kmalloc() failed\n"); | 273 | printk(KERN_WARNING "selection: kmalloc() failed\n"); |
274 | clear_selection(); | 274 | clear_selection(); |
diff --git a/drivers/char/sx.c b/drivers/char/sx.c index b60be7b0decf..f146e90404fa 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c | |||
@@ -1713,8 +1713,8 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd, | |||
1713 | for (i = 0; i < SX_NBOARDS; i++) | 1713 | for (i = 0; i < SX_NBOARDS; i++) |
1714 | sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags); | 1714 | sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags); |
1715 | sx_dprintk(SX_DEBUG_FIRMWARE, "\n"); | 1715 | sx_dprintk(SX_DEBUG_FIRMWARE, "\n"); |
1716 | unlock_kernel(); | 1716 | rc = -EIO; |
1717 | return -EIO; | 1717 | goto out; |
1718 | } | 1718 | } |
1719 | 1719 | ||
1720 | switch (cmd) { | 1720 | switch (cmd) { |
@@ -1747,7 +1747,8 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd, | |||
1747 | break; | 1747 | break; |
1748 | case SXIO_DO_RAMTEST: | 1748 | case SXIO_DO_RAMTEST: |
1749 | if (sx_initialized) /* Already initialized: better not ramtest the board. */ | 1749 | if (sx_initialized) /* Already initialized: better not ramtest the board. */ |
1750 | return -EPERM; | 1750 | rc = -EPERM; |
1751 | break; | ||
1751 | if (IS_SX_BOARD(board)) { | 1752 | if (IS_SX_BOARD(board)) { |
1752 | rc = do_memtest(board, 0, 0x7000); | 1753 | rc = do_memtest(board, 0, 0x7000); |
1753 | if (!rc) | 1754 | if (!rc) |
@@ -1844,6 +1845,7 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd, | |||
1844 | rc = -ENOTTY; | 1845 | rc = -ENOTTY; |
1845 | break; | 1846 | break; |
1846 | } | 1847 | } |
1848 | out: | ||
1847 | unlock_kernel(); | 1849 | unlock_kernel(); |
1848 | func_exit(); | 1850 | func_exit(); |
1849 | return rc; | 1851 | return rc; |
diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c index 55433849bfa6..33bd75347518 100644 --- a/drivers/dca/dca-core.c +++ b/drivers/dca/dca-core.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/dca.h> | 29 | #include <linux/dca.h> |
30 | 30 | ||
31 | #define DCA_VERSION "1.4" | 31 | #define DCA_VERSION "1.8" |
32 | 32 | ||
33 | MODULE_VERSION(DCA_VERSION); | 33 | MODULE_VERSION(DCA_VERSION); |
34 | MODULE_LICENSE("GPL"); | 34 | MODULE_LICENSE("GPL"); |
@@ -60,16 +60,17 @@ int dca_add_requester(struct device *dev) | |||
60 | { | 60 | { |
61 | struct dca_provider *dca; | 61 | struct dca_provider *dca; |
62 | int err, slot = -ENODEV; | 62 | int err, slot = -ENODEV; |
63 | unsigned long flags; | ||
63 | 64 | ||
64 | if (!dev) | 65 | if (!dev) |
65 | return -EFAULT; | 66 | return -EFAULT; |
66 | 67 | ||
67 | spin_lock(&dca_lock); | 68 | spin_lock_irqsave(&dca_lock, flags); |
68 | 69 | ||
69 | /* check if the requester has not been added already */ | 70 | /* check if the requester has not been added already */ |
70 | dca = dca_find_provider_by_dev(dev); | 71 | dca = dca_find_provider_by_dev(dev); |
71 | if (dca) { | 72 | if (dca) { |
72 | spin_unlock(&dca_lock); | 73 | spin_unlock_irqrestore(&dca_lock, flags); |
73 | return -EEXIST; | 74 | return -EEXIST; |
74 | } | 75 | } |
75 | 76 | ||
@@ -78,19 +79,21 @@ int dca_add_requester(struct device *dev) | |||
78 | if (slot >= 0) | 79 | if (slot >= 0) |
79 | break; | 80 | break; |
80 | } | 81 | } |
81 | if (slot < 0) { | 82 | |
82 | spin_unlock(&dca_lock); | 83 | spin_unlock_irqrestore(&dca_lock, flags); |
84 | |||
85 | if (slot < 0) | ||
83 | return slot; | 86 | return slot; |
84 | } | ||
85 | 87 | ||
86 | err = dca_sysfs_add_req(dca, dev, slot); | 88 | err = dca_sysfs_add_req(dca, dev, slot); |
87 | if (err) { | 89 | if (err) { |
88 | dca->ops->remove_requester(dca, dev); | 90 | spin_lock_irqsave(&dca_lock, flags); |
89 | spin_unlock(&dca_lock); | 91 | if (dca == dca_find_provider_by_dev(dev)) |
92 | dca->ops->remove_requester(dca, dev); | ||
93 | spin_unlock_irqrestore(&dca_lock, flags); | ||
90 | return err; | 94 | return err; |
91 | } | 95 | } |
92 | 96 | ||
93 | spin_unlock(&dca_lock); | ||
94 | return 0; | 97 | return 0; |
95 | } | 98 | } |
96 | EXPORT_SYMBOL_GPL(dca_add_requester); | 99 | EXPORT_SYMBOL_GPL(dca_add_requester); |
@@ -103,25 +106,25 @@ int dca_remove_requester(struct device *dev) | |||
103 | { | 106 | { |
104 | struct dca_provider *dca; | 107 | struct dca_provider *dca; |
105 | int slot; | 108 | int slot; |
109 | unsigned long flags; | ||
106 | 110 | ||
107 | if (!dev) | 111 | if (!dev) |
108 | return -EFAULT; | 112 | return -EFAULT; |
109 | 113 | ||
110 | spin_lock(&dca_lock); | 114 | spin_lock_irqsave(&dca_lock, flags); |
111 | dca = dca_find_provider_by_dev(dev); | 115 | dca = dca_find_provider_by_dev(dev); |
112 | if (!dca) { | 116 | if (!dca) { |
113 | spin_unlock(&dca_lock); | 117 | spin_unlock_irqrestore(&dca_lock, flags); |
114 | return -ENODEV; | 118 | return -ENODEV; |
115 | } | 119 | } |
116 | slot = dca->ops->remove_requester(dca, dev); | 120 | slot = dca->ops->remove_requester(dca, dev); |
117 | if (slot < 0) { | 121 | spin_unlock_irqrestore(&dca_lock, flags); |
118 | spin_unlock(&dca_lock); | 122 | |
123 | if (slot < 0) | ||
119 | return slot; | 124 | return slot; |
120 | } | ||
121 | 125 | ||
122 | dca_sysfs_remove_req(dca, slot); | 126 | dca_sysfs_remove_req(dca, slot); |
123 | 127 | ||
124 | spin_unlock(&dca_lock); | ||
125 | return 0; | 128 | return 0; |
126 | } | 129 | } |
127 | EXPORT_SYMBOL_GPL(dca_remove_requester); | 130 | EXPORT_SYMBOL_GPL(dca_remove_requester); |
@@ -135,17 +138,18 @@ u8 dca_common_get_tag(struct device *dev, int cpu) | |||
135 | { | 138 | { |
136 | struct dca_provider *dca; | 139 | struct dca_provider *dca; |
137 | u8 tag; | 140 | u8 tag; |
141 | unsigned long flags; | ||
138 | 142 | ||
139 | spin_lock(&dca_lock); | 143 | spin_lock_irqsave(&dca_lock, flags); |
140 | 144 | ||
141 | dca = dca_find_provider_by_dev(dev); | 145 | dca = dca_find_provider_by_dev(dev); |
142 | if (!dca) { | 146 | if (!dca) { |
143 | spin_unlock(&dca_lock); | 147 | spin_unlock_irqrestore(&dca_lock, flags); |
144 | return -ENODEV; | 148 | return -ENODEV; |
145 | } | 149 | } |
146 | tag = dca->ops->get_tag(dca, dev, cpu); | 150 | tag = dca->ops->get_tag(dca, dev, cpu); |
147 | 151 | ||
148 | spin_unlock(&dca_lock); | 152 | spin_unlock_irqrestore(&dca_lock, flags); |
149 | return tag; | 153 | return tag; |
150 | } | 154 | } |
151 | 155 | ||
@@ -217,11 +221,16 @@ static BLOCKING_NOTIFIER_HEAD(dca_provider_chain); | |||
217 | int register_dca_provider(struct dca_provider *dca, struct device *dev) | 221 | int register_dca_provider(struct dca_provider *dca, struct device *dev) |
218 | { | 222 | { |
219 | int err; | 223 | int err; |
224 | unsigned long flags; | ||
220 | 225 | ||
221 | err = dca_sysfs_add_provider(dca, dev); | 226 | err = dca_sysfs_add_provider(dca, dev); |
222 | if (err) | 227 | if (err) |
223 | return err; | 228 | return err; |
229 | |||
230 | spin_lock_irqsave(&dca_lock, flags); | ||
224 | list_add(&dca->node, &dca_providers); | 231 | list_add(&dca->node, &dca_providers); |
232 | spin_unlock_irqrestore(&dca_lock, flags); | ||
233 | |||
225 | blocking_notifier_call_chain(&dca_provider_chain, | 234 | blocking_notifier_call_chain(&dca_provider_chain, |
226 | DCA_PROVIDER_ADD, NULL); | 235 | DCA_PROVIDER_ADD, NULL); |
227 | return 0; | 236 | return 0; |
@@ -234,9 +243,15 @@ EXPORT_SYMBOL_GPL(register_dca_provider); | |||
234 | */ | 243 | */ |
235 | void unregister_dca_provider(struct dca_provider *dca) | 244 | void unregister_dca_provider(struct dca_provider *dca) |
236 | { | 245 | { |
246 | unsigned long flags; | ||
247 | |||
237 | blocking_notifier_call_chain(&dca_provider_chain, | 248 | blocking_notifier_call_chain(&dca_provider_chain, |
238 | DCA_PROVIDER_REMOVE, NULL); | 249 | DCA_PROVIDER_REMOVE, NULL); |
250 | |||
251 | spin_lock_irqsave(&dca_lock, flags); | ||
239 | list_del(&dca->node); | 252 | list_del(&dca->node); |
253 | spin_unlock_irqrestore(&dca_lock, flags); | ||
254 | |||
240 | dca_sysfs_remove_provider(dca); | 255 | dca_sysfs_remove_provider(dca); |
241 | } | 256 | } |
242 | EXPORT_SYMBOL_GPL(unregister_dca_provider); | 257 | EXPORT_SYMBOL_GPL(unregister_dca_provider); |
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index 7be2cf3514e7..a5dd7a665aa8 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c | |||
@@ -412,6 +412,7 @@ fw_card_add(struct fw_card *card, | |||
412 | { | 412 | { |
413 | u32 *config_rom; | 413 | u32 *config_rom; |
414 | size_t length; | 414 | size_t length; |
415 | int err; | ||
415 | 416 | ||
416 | card->max_receive = max_receive; | 417 | card->max_receive = max_receive; |
417 | card->link_speed = link_speed; | 418 | card->link_speed = link_speed; |
@@ -422,7 +423,13 @@ fw_card_add(struct fw_card *card, | |||
422 | list_add_tail(&card->link, &card_list); | 423 | list_add_tail(&card->link, &card_list); |
423 | mutex_unlock(&card_mutex); | 424 | mutex_unlock(&card_mutex); |
424 | 425 | ||
425 | return card->driver->enable(card, config_rom, length); | 426 | err = card->driver->enable(card, config_rom, length); |
427 | if (err < 0) { | ||
428 | mutex_lock(&card_mutex); | ||
429 | list_del(&card->link); | ||
430 | mutex_unlock(&card_mutex); | ||
431 | } | ||
432 | return err; | ||
426 | } | 433 | } |
427 | EXPORT_SYMBOL(fw_card_add); | 434 | EXPORT_SYMBOL(fw_card_add); |
428 | 435 | ||
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 9da581452874..6915fb82d0b0 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
@@ -136,7 +136,7 @@ drm_gem_object_alloc(struct drm_device *dev, size_t size) | |||
136 | obj = kcalloc(1, sizeof(*obj), GFP_KERNEL); | 136 | obj = kcalloc(1, sizeof(*obj), GFP_KERNEL); |
137 | 137 | ||
138 | obj->dev = dev; | 138 | obj->dev = dev; |
139 | obj->filp = shmem_file_setup("drm mm object", size, 0); | 139 | obj->filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); |
140 | if (IS_ERR(obj->filp)) { | 140 | if (IS_ERR(obj->filp)) { |
141 | kfree(obj); | 141 | kfree(obj); |
142 | return NULL; | 142 | return NULL; |
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c index 03705240000f..abf4dfc8ec22 100644 --- a/drivers/hwmon/hp_accel.c +++ b/drivers/hwmon/hp_accel.c | |||
@@ -153,7 +153,10 @@ static struct axis_conversion lis3lv02d_axis_y_inverted = {1, -2, 3}; | |||
153 | static struct axis_conversion lis3lv02d_axis_x_inverted = {-1, 2, 3}; | 153 | static struct axis_conversion lis3lv02d_axis_x_inverted = {-1, 2, 3}; |
154 | static struct axis_conversion lis3lv02d_axis_z_inverted = {1, 2, -3}; | 154 | static struct axis_conversion lis3lv02d_axis_z_inverted = {1, 2, -3}; |
155 | static struct axis_conversion lis3lv02d_axis_xy_rotated_left = {-2, 1, 3}; | 155 | static struct axis_conversion lis3lv02d_axis_xy_rotated_left = {-2, 1, 3}; |
156 | static struct axis_conversion lis3lv02d_axis_xy_rotated_left_usd = {-2, 1, -3}; | ||
156 | static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3}; | 157 | static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3}; |
158 | static struct axis_conversion lis3lv02d_axis_xy_rotated_right = {2, -1, 3}; | ||
159 | static struct axis_conversion lis3lv02d_axis_xy_swap_yz_inverted = {2, -1, -3}; | ||
157 | 160 | ||
158 | #define AXIS_DMI_MATCH(_ident, _name, _axis) { \ | 161 | #define AXIS_DMI_MATCH(_ident, _name, _axis) { \ |
159 | .ident = _ident, \ | 162 | .ident = _ident, \ |
@@ -172,10 +175,12 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = { | |||
172 | AXIS_DMI_MATCH("NC2510", "HP Compaq 2510", y_inverted), | 175 | AXIS_DMI_MATCH("NC2510", "HP Compaq 2510", y_inverted), |
173 | AXIS_DMI_MATCH("NC8510", "HP Compaq 8510", xy_swap_inverted), | 176 | AXIS_DMI_MATCH("NC8510", "HP Compaq 8510", xy_swap_inverted), |
174 | AXIS_DMI_MATCH("HP2133", "HP 2133", xy_rotated_left), | 177 | AXIS_DMI_MATCH("HP2133", "HP 2133", xy_rotated_left), |
178 | AXIS_DMI_MATCH("NC653x", "HP Compaq 653", xy_rotated_left_usd), | ||
179 | AXIS_DMI_MATCH("NC673x", "HP Compaq 673", xy_rotated_left_usd), | ||
180 | AXIS_DMI_MATCH("NC651xx", "HP Compaq 651", xy_rotated_right), | ||
181 | AXIS_DMI_MATCH("NC671xx", "HP Compaq 671", xy_swap_yz_inverted), | ||
175 | { NULL, } | 182 | { NULL, } |
176 | /* Laptop models without axis info (yet): | 183 | /* Laptop models without axis info (yet): |
177 | * "NC651xx" "HP Compaq 651" | ||
178 | * "NC671xx" "HP Compaq 671" | ||
179 | * "NC6910" "HP Compaq 6910" | 184 | * "NC6910" "HP Compaq 6910" |
180 | * HP Compaq 8710x Notebook PC / Mobile Workstation | 185 | * HP Compaq 8710x Notebook PC / Mobile Workstation |
181 | * "NC2400" "HP Compaq nc2400" | 186 | * "NC2400" "HP Compaq nc2400" |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index b1c6f68d98ce..3dad2299d9c5 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -465,6 +465,16 @@ config BLK_DEV_CS5535 | |||
465 | 465 | ||
466 | It is safe to say Y to this question. | 466 | It is safe to say Y to this question. |
467 | 467 | ||
468 | config BLK_DEV_CS5536 | ||
469 | tristate "CS5536 chipset support" | ||
470 | depends on X86_32 | ||
471 | select BLK_DEV_IDEDMA_PCI | ||
472 | help | ||
473 | This option enables support for the AMD CS5536 | ||
474 | companion chip used with the Geode LX processor family. | ||
475 | |||
476 | If unsure, say N. | ||
477 | |||
468 | config BLK_DEV_HPT366 | 478 | config BLK_DEV_HPT366 |
469 | tristate "HPT36X/37X chipset support" | 479 | tristate "HPT36X/37X chipset support" |
470 | select BLK_DEV_IDEDMA_PCI | 480 | select BLK_DEV_IDEDMA_PCI |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index c2b9c93f0095..d0e3d7d5b467 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -43,6 +43,7 @@ obj-$(CONFIG_BLK_DEV_CMD64X) += cmd64x.o | |||
43 | obj-$(CONFIG_BLK_DEV_CS5520) += cs5520.o | 43 | obj-$(CONFIG_BLK_DEV_CS5520) += cs5520.o |
44 | obj-$(CONFIG_BLK_DEV_CS5530) += cs5530.o | 44 | obj-$(CONFIG_BLK_DEV_CS5530) += cs5530.o |
45 | obj-$(CONFIG_BLK_DEV_CS5535) += cs5535.o | 45 | obj-$(CONFIG_BLK_DEV_CS5535) += cs5535.o |
46 | obj-$(CONFIG_BLK_DEV_CS5536) += cs5536.o | ||
46 | obj-$(CONFIG_BLK_DEV_SC1200) += sc1200.o | 47 | obj-$(CONFIG_BLK_DEV_SC1200) += sc1200.o |
47 | obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o | 48 | obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o |
48 | obj-$(CONFIG_BLK_DEV_DELKIN) += delkin_cb.o | 49 | obj-$(CONFIG_BLK_DEV_DELKIN) += delkin_cb.o |
diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c new file mode 100644 index 000000000000..7a62db719a46 --- /dev/null +++ b/drivers/ide/cs5536.c | |||
@@ -0,0 +1,308 @@ | |||
1 | /* | ||
2 | * CS5536 PATA support | ||
3 | * (C) 2007 Martin K. Petersen <mkp@mkp.net> | ||
4 | * (C) 2009 Bartlomiej Zolnierkiewicz | ||
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 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | * | ||
19 | * Documentation: | ||
20 | * Available from AMD web site. | ||
21 | * | ||
22 | * The IDE timing registers for the CS5536 live in the Geode Machine | ||
23 | * Specific Register file and not PCI config space. Most BIOSes | ||
24 | * virtualize the PCI registers so the chip looks like a standard IDE | ||
25 | * controller. Unfortunately not all implementations get this right. | ||
26 | * In particular some have problems with unaligned accesses to the | ||
27 | * virtualized PCI registers. This driver always does full dword | ||
28 | * writes to work around the issue. Also, in case of a bad BIOS this | ||
29 | * driver can be loaded with the "msr=1" parameter which forces using | ||
30 | * the Machine Specific Registers to configure the device. | ||
31 | */ | ||
32 | |||
33 | #include <linux/kernel.h> | ||
34 | #include <linux/module.h> | ||
35 | #include <linux/pci.h> | ||
36 | #include <linux/init.h> | ||
37 | #include <linux/ide.h> | ||
38 | #include <asm/msr.h> | ||
39 | |||
40 | #define DRV_NAME "cs5536" | ||
41 | |||
42 | enum { | ||
43 | MSR_IDE_CFG = 0x51300010, | ||
44 | PCI_IDE_CFG = 0x40, | ||
45 | |||
46 | CFG = 0, | ||
47 | DTC = 2, | ||
48 | CAST = 3, | ||
49 | ETC = 4, | ||
50 | |||
51 | IDE_CFG_CHANEN = (1 << 1), | ||
52 | IDE_CFG_CABLE = (1 << 17) | (1 << 16), | ||
53 | |||
54 | IDE_D0_SHIFT = 24, | ||
55 | IDE_D1_SHIFT = 16, | ||
56 | IDE_DRV_MASK = 0xff, | ||
57 | |||
58 | IDE_CAST_D0_SHIFT = 6, | ||
59 | IDE_CAST_D1_SHIFT = 4, | ||
60 | IDE_CAST_DRV_MASK = 0x3, | ||
61 | |||
62 | IDE_CAST_CMD_SHIFT = 24, | ||
63 | IDE_CAST_CMD_MASK = 0xff, | ||
64 | |||
65 | IDE_ETC_UDMA_MASK = 0xc0, | ||
66 | }; | ||
67 | |||
68 | static int use_msr; | ||
69 | |||
70 | static int cs5536_read(struct pci_dev *pdev, int reg, u32 *val) | ||
71 | { | ||
72 | if (unlikely(use_msr)) { | ||
73 | u32 dummy; | ||
74 | |||
75 | rdmsr(MSR_IDE_CFG + reg, *val, dummy); | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | return pci_read_config_dword(pdev, PCI_IDE_CFG + reg * 4, val); | ||
80 | } | ||
81 | |||
82 | static int cs5536_write(struct pci_dev *pdev, int reg, int val) | ||
83 | { | ||
84 | if (unlikely(use_msr)) { | ||
85 | wrmsr(MSR_IDE_CFG + reg, val, 0); | ||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | return pci_write_config_dword(pdev, PCI_IDE_CFG + reg * 4, val); | ||
90 | } | ||
91 | |||
92 | static void cs5536_program_dtc(ide_drive_t *drive, u8 tim) | ||
93 | { | ||
94 | struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); | ||
95 | int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT; | ||
96 | u32 dtc; | ||
97 | |||
98 | cs5536_read(pdev, DTC, &dtc); | ||
99 | dtc &= ~(IDE_DRV_MASK << dshift); | ||
100 | dtc |= tim << dshift; | ||
101 | cs5536_write(pdev, DTC, dtc); | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * cs5536_cable_detect - detect cable type | ||
106 | * @hwif: Port to detect on | ||
107 | * | ||
108 | * Perform cable detection for ATA66 capable cable. | ||
109 | * | ||
110 | * Returns a cable type. | ||
111 | */ | ||
112 | |||
113 | static u8 cs5536_cable_detect(ide_hwif_t *hwif) | ||
114 | { | ||
115 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | ||
116 | u32 cfg; | ||
117 | |||
118 | cs5536_read(pdev, CFG, &cfg); | ||
119 | |||
120 | if (cfg & IDE_CFG_CABLE) | ||
121 | return ATA_CBL_PATA80; | ||
122 | else | ||
123 | return ATA_CBL_PATA40; | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * cs5536_set_pio_mode - PIO timing setup | ||
128 | * @drive: ATA device | ||
129 | * @pio: PIO mode number | ||
130 | */ | ||
131 | |||
132 | static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
133 | { | ||
134 | static const u8 drv_timings[5] = { | ||
135 | 0x98, 0x55, 0x32, 0x21, 0x20, | ||
136 | }; | ||
137 | |||
138 | static const u8 addr_timings[5] = { | ||
139 | 0x2, 0x1, 0x0, 0x0, 0x0, | ||
140 | }; | ||
141 | |||
142 | static const u8 cmd_timings[5] = { | ||
143 | 0x99, 0x92, 0x90, 0x22, 0x20, | ||
144 | }; | ||
145 | |||
146 | struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); | ||
147 | ide_drive_t *pair = ide_get_pair_dev(drive); | ||
148 | int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT; | ||
149 | u32 cast; | ||
150 | u8 cmd_pio = pio; | ||
151 | |||
152 | if (pair) | ||
153 | cmd_pio = min(pio, ide_get_best_pio_mode(pair, 255, 4)); | ||
154 | |||
155 | drive->drive_data &= (IDE_DRV_MASK << 8); | ||
156 | drive->drive_data |= drv_timings[pio]; | ||
157 | |||
158 | cs5536_program_dtc(drive, drv_timings[pio]); | ||
159 | |||
160 | cs5536_read(pdev, CAST, &cast); | ||
161 | |||
162 | cast &= ~(IDE_CAST_DRV_MASK << cshift); | ||
163 | cast |= addr_timings[pio] << cshift; | ||
164 | |||
165 | cast &= ~(IDE_CAST_CMD_MASK << IDE_CAST_CMD_SHIFT); | ||
166 | cast |= cmd_timings[cmd_pio] << IDE_CAST_CMD_SHIFT; | ||
167 | |||
168 | cs5536_write(pdev, CAST, cast); | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * cs5536_set_dma_mode - DMA timing setup | ||
173 | * @drive: ATA device | ||
174 | * @mode: DMA mode | ||
175 | */ | ||
176 | |||
177 | static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode) | ||
178 | { | ||
179 | static const u8 udma_timings[6] = { | ||
180 | 0xc2, 0xc1, 0xc0, 0xc4, 0xc5, 0xc6, | ||
181 | }; | ||
182 | |||
183 | static const u8 mwdma_timings[3] = { | ||
184 | 0x67, 0x21, 0x20, | ||
185 | }; | ||
186 | |||
187 | struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); | ||
188 | int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT; | ||
189 | u32 etc; | ||
190 | |||
191 | cs5536_read(pdev, ETC, &etc); | ||
192 | |||
193 | if (mode >= XFER_UDMA_0) { | ||
194 | etc &= ~(IDE_DRV_MASK << dshift); | ||
195 | etc |= udma_timings[mode - XFER_UDMA_0] << dshift; | ||
196 | } else { /* MWDMA */ | ||
197 | etc &= ~(IDE_ETC_UDMA_MASK << dshift); | ||
198 | drive->drive_data &= IDE_DRV_MASK; | ||
199 | drive->drive_data |= mwdma_timings[mode - XFER_MW_DMA_0] << 8; | ||
200 | } | ||
201 | |||
202 | cs5536_write(pdev, ETC, etc); | ||
203 | } | ||
204 | |||
205 | static void cs5536_dma_start(ide_drive_t *drive) | ||
206 | { | ||
207 | if (drive->current_speed < XFER_UDMA_0 && | ||
208 | (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK)) | ||
209 | cs5536_program_dtc(drive, drive->drive_data >> 8); | ||
210 | |||
211 | ide_dma_start(drive); | ||
212 | } | ||
213 | |||
214 | static int cs5536_dma_end(ide_drive_t *drive) | ||
215 | { | ||
216 | int ret = ide_dma_end(drive); | ||
217 | |||
218 | if (drive->current_speed < XFER_UDMA_0 && | ||
219 | (drive->drive_data >> 8) != (drive->drive_data & IDE_DRV_MASK)) | ||
220 | cs5536_program_dtc(drive, drive->drive_data & IDE_DRV_MASK); | ||
221 | |||
222 | return ret; | ||
223 | } | ||
224 | |||
225 | static const struct ide_port_ops cs5536_port_ops = { | ||
226 | .set_pio_mode = cs5536_set_pio_mode, | ||
227 | .set_dma_mode = cs5536_set_dma_mode, | ||
228 | .cable_detect = cs5536_cable_detect, | ||
229 | }; | ||
230 | |||
231 | static const struct ide_dma_ops cs5536_dma_ops = { | ||
232 | .dma_host_set = ide_dma_host_set, | ||
233 | .dma_setup = ide_dma_setup, | ||
234 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
235 | .dma_start = cs5536_dma_start, | ||
236 | .dma_end = cs5536_dma_end, | ||
237 | .dma_test_irq = ide_dma_test_irq, | ||
238 | .dma_lost_irq = ide_dma_lost_irq, | ||
239 | .dma_timeout = ide_dma_timeout, | ||
240 | }; | ||
241 | |||
242 | static const struct ide_port_info cs5536_info = { | ||
243 | .name = DRV_NAME, | ||
244 | .port_ops = &cs5536_port_ops, | ||
245 | .dma_ops = &cs5536_dma_ops, | ||
246 | .host_flags = IDE_HFLAG_SINGLE, | ||
247 | .pio_mask = ATA_PIO4, | ||
248 | .mwdma_mask = ATA_MWDMA2, | ||
249 | .udma_mask = ATA_UDMA5, | ||
250 | }; | ||
251 | |||
252 | /** | ||
253 | * cs5536_init_one | ||
254 | * @dev: PCI device | ||
255 | * @id: Entry in match table | ||
256 | */ | ||
257 | |||
258 | static int cs5536_init_one(struct pci_dev *dev, const struct pci_device_id *id) | ||
259 | { | ||
260 | u32 cfg; | ||
261 | |||
262 | if (use_msr) | ||
263 | printk(KERN_INFO DRV_NAME ": Using MSR regs instead of PCI\n"); | ||
264 | |||
265 | cs5536_read(dev, CFG, &cfg); | ||
266 | |||
267 | if ((cfg & IDE_CFG_CHANEN) == 0) { | ||
268 | printk(KERN_ERR DRV_NAME ": disabled by BIOS\n"); | ||
269 | return -ENODEV; | ||
270 | } | ||
271 | |||
272 | return ide_pci_init_one(dev, &cs5536_info, NULL); | ||
273 | } | ||
274 | |||
275 | static const struct pci_device_id cs5536_pci_tbl[] = { | ||
276 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), }, | ||
277 | { }, | ||
278 | }; | ||
279 | |||
280 | static struct pci_driver cs5536_pci_driver = { | ||
281 | .name = DRV_NAME, | ||
282 | .id_table = cs5536_pci_tbl, | ||
283 | .probe = cs5536_init_one, | ||
284 | .remove = ide_pci_remove, | ||
285 | .suspend = ide_pci_suspend, | ||
286 | .resume = ide_pci_resume, | ||
287 | }; | ||
288 | |||
289 | static int __init cs5536_init(void) | ||
290 | { | ||
291 | return pci_register_driver(&cs5536_pci_driver); | ||
292 | } | ||
293 | |||
294 | static void __exit cs5536_exit(void) | ||
295 | { | ||
296 | pci_unregister_driver(&cs5536_pci_driver); | ||
297 | } | ||
298 | |||
299 | MODULE_AUTHOR("Martin K. Petersen, Bartlomiej Zolnierkiewicz"); | ||
300 | MODULE_DESCRIPTION("low-level driver for the CS5536 IDE controller"); | ||
301 | MODULE_LICENSE("GPL"); | ||
302 | MODULE_DEVICE_TABLE(pci, cs5536_pci_tbl); | ||
303 | |||
304 | module_param_named(msr, use_msr, int, 0644); | ||
305 | MODULE_PARM_DESC(msr, "Force using MSR to configure IDE function (Default: 0)"); | ||
306 | |||
307 | module_init(cs5536_init); | ||
308 | module_exit(cs5536_exit); | ||
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c index 97a35c667aee..415d7e24f2b6 100644 --- a/drivers/ide/icside.c +++ b/drivers/ide/icside.c | |||
@@ -534,7 +534,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
534 | d.dma_ops = NULL; | 534 | d.dma_ops = NULL; |
535 | } | 535 | } |
536 | 536 | ||
537 | ret = ide_host_register(host, NULL, hws); | 537 | ret = ide_host_register(host, &d, hws); |
538 | if (ret) | 538 | if (ret) |
539 | goto err_free; | 539 | goto err_free; |
540 | 540 | ||
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index d8f295bdad76..ec7d07fa570a 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -282,7 +282,7 @@ static int do_drive_get_GTF(ide_drive_t *drive, | |||
282 | port = hwif->channel ? drive->dn - 2: drive->dn; | 282 | port = hwif->channel ? drive->dn - 2: drive->dn; |
283 | 283 | ||
284 | DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n", | 284 | DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n", |
285 | hwif->name, dev->bus_id, port, hwif->channel); | 285 | hwif->name, dev_name(dev), port, hwif->channel); |
286 | 286 | ||
287 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) { | 287 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) { |
288 | DEBPRINT("%s drive %d:%d not present\n", | 288 | DEBPRINT("%s drive %d:%d not present\n", |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index cae69372cf45..0bfeb0c79d6e 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -787,6 +787,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
787 | if (blk_fs_request(rq)) { | 787 | if (blk_fs_request(rq)) { |
788 | ide_end_request(drive, 1, rq->nr_sectors); | 788 | ide_end_request(drive, 1, rq->nr_sectors); |
789 | return ide_stopped; | 789 | return ide_stopped; |
790 | } else if (rq->cmd_type == REQ_TYPE_ATA_PC && !rq->bio) { | ||
791 | ide_end_request(drive, 1, 1); | ||
792 | return ide_stopped; | ||
790 | } | 793 | } |
791 | goto end_request; | 794 | goto end_request; |
792 | } | 795 | } |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index cc163319dfbd..9ee51adf567f 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -418,11 +418,14 @@ void ide_map_sg(ide_drive_t *drive, struct request *rq) | |||
418 | ide_hwif_t *hwif = drive->hwif; | 418 | ide_hwif_t *hwif = drive->hwif; |
419 | struct scatterlist *sg = hwif->sg_table; | 419 | struct scatterlist *sg = hwif->sg_table; |
420 | 420 | ||
421 | if (rq->cmd_type != REQ_TYPE_ATA_TASKFILE) { | 421 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { |
422 | hwif->sg_nents = blk_rq_map_sg(drive->queue, rq, sg); | ||
423 | } else { | ||
424 | sg_init_one(sg, rq->buffer, rq->nr_sectors * SECTOR_SIZE); | 422 | sg_init_one(sg, rq->buffer, rq->nr_sectors * SECTOR_SIZE); |
425 | hwif->sg_nents = 1; | 423 | hwif->sg_nents = 1; |
424 | } else if (!rq->bio) { | ||
425 | sg_init_one(sg, rq->data, rq->data_len); | ||
426 | hwif->sg_nents = 1; | ||
427 | } else { | ||
428 | hwif->sg_nents = blk_rq_map_sg(drive->queue, rq, sg); | ||
426 | } | 429 | } |
427 | } | 430 | } |
428 | 431 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 0db1ed9f5fc2..ce0818a993f6 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1467,6 +1467,30 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | |||
1467 | } | 1467 | } |
1468 | EXPORT_SYMBOL_GPL(ide_host_alloc); | 1468 | EXPORT_SYMBOL_GPL(ide_host_alloc); |
1469 | 1469 | ||
1470 | static void ide_port_free(ide_hwif_t *hwif) | ||
1471 | { | ||
1472 | ide_port_free_devices(hwif); | ||
1473 | ide_free_port_slot(hwif->index); | ||
1474 | kfree(hwif); | ||
1475 | } | ||
1476 | |||
1477 | static void ide_disable_port(ide_hwif_t *hwif) | ||
1478 | { | ||
1479 | struct ide_host *host = hwif->host; | ||
1480 | int i; | ||
1481 | |||
1482 | printk(KERN_INFO "%s: disabling port\n", hwif->name); | ||
1483 | |||
1484 | for (i = 0; i < MAX_HOST_PORTS; i++) { | ||
1485 | if (host->ports[i] == hwif) { | ||
1486 | host->ports[i] = NULL; | ||
1487 | host->n_ports--; | ||
1488 | } | ||
1489 | } | ||
1490 | |||
1491 | ide_port_free(hwif); | ||
1492 | } | ||
1493 | |||
1470 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | 1494 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, |
1471 | hw_regs_t **hws) | 1495 | hw_regs_t **hws) |
1472 | { | 1496 | { |
@@ -1507,8 +1531,12 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1507 | hwif->present = 1; | 1531 | hwif->present = 1; |
1508 | 1532 | ||
1509 | if (hwif->chipset != ide_4drives || !hwif->mate || | 1533 | if (hwif->chipset != ide_4drives || !hwif->mate || |
1510 | !hwif->mate->present) | 1534 | !hwif->mate->present) { |
1511 | ide_register_port(hwif); | 1535 | if (ide_register_port(hwif)) { |
1536 | ide_disable_port(hwif); | ||
1537 | continue; | ||
1538 | } | ||
1539 | } | ||
1512 | 1540 | ||
1513 | if (hwif->present) | 1541 | if (hwif->present) |
1514 | ide_port_tune_devices(hwif); | 1542 | ide_port_tune_devices(hwif); |
@@ -1521,7 +1549,8 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1521 | if (hwif_init(hwif) == 0) { | 1549 | if (hwif_init(hwif) == 0) { |
1522 | printk(KERN_INFO "%s: failed to initialize IDE " | 1550 | printk(KERN_INFO "%s: failed to initialize IDE " |
1523 | "interface\n", hwif->name); | 1551 | "interface\n", hwif->name); |
1524 | hwif->present = 0; | 1552 | device_unregister(&hwif->gendev); |
1553 | ide_disable_port(hwif); | ||
1525 | continue; | 1554 | continue; |
1526 | } | 1555 | } |
1527 | 1556 | ||
@@ -1660,12 +1689,8 @@ void ide_host_free(struct ide_host *host) | |||
1660 | int i; | 1689 | int i; |
1661 | 1690 | ||
1662 | ide_host_for_each_port(i, hwif, host) { | 1691 | ide_host_for_each_port(i, hwif, host) { |
1663 | if (hwif == NULL) | 1692 | if (hwif) |
1664 | continue; | 1693 | ide_port_free(hwif); |
1665 | |||
1666 | ide_port_free_devices(hwif); | ||
1667 | ide_free_port_slot(hwif->index); | ||
1668 | kfree(hwif); | ||
1669 | } | 1694 | } |
1670 | 1695 | ||
1671 | kfree(host); | 1696 | kfree(host); |
diff --git a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c index 5b2e3af43c4b..08c4fa35e9b1 100644 --- a/drivers/ide/qd65xx.c +++ b/drivers/ide/qd65xx.c | |||
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | /* | 17 | /* |
18 | * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by | 18 | * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by |
19 | * Samuel Thibault <samuel.thibault@fnac.net> | 19 | * Samuel Thibault <samuel.thibault@ens-lyon.org> |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
diff --git a/drivers/ide/qd65xx.h b/drivers/ide/qd65xx.h index 6636f9665d16..d7e67a1a1dcc 100644 --- a/drivers/ide/qd65xx.h +++ b/drivers/ide/qd65xx.h | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | /* | 5 | /* |
6 | * Authors: Petr Soucek <petr@ryston.cz> | 6 | * Authors: Petr Soucek <petr@ryston.cz> |
7 | * Samuel Thibault <samuel.thibault@fnac.net> | 7 | * Samuel Thibault <samuel.thibault@ens-lyon.org> |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* truncates a in [b,c] */ | 10 | /* truncates a in [b,c] */ |
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c index 882f6f07c476..40b0812a045c 100644 --- a/drivers/ide/tx4939ide.c +++ b/drivers/ide/tx4939ide.c | |||
@@ -261,9 +261,9 @@ static int tx4939ide_build_dmatable(ide_drive_t *drive, struct request *rq) | |||
261 | bcount = cur_len; | 261 | bcount = cur_len; |
262 | /* | 262 | /* |
263 | * This workaround for zero count seems required. | 263 | * This workaround for zero count seems required. |
264 | * (standard ide_build_dmatable do it too) | 264 | * (standard ide_build_dmatable does it too) |
265 | */ | 265 | */ |
266 | if ((bcount & 0xffff) == 0x0000) | 266 | if (bcount == 0x10000) |
267 | bcount = 0x8000; | 267 | bcount = 0x8000; |
268 | *table++ = bcount & 0xffff; | 268 | *table++ = bcount & 0xffff; |
269 | *table++ = cur_addr; | 269 | *table++ = cur_addr; |
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c index 703c3eeb20a8..6092fe3f409d 100644 --- a/drivers/ide/via82cxxx.c +++ b/drivers/ide/via82cxxx.c | |||
@@ -448,6 +448,11 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
448 | d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS; | 448 | d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS; |
449 | #endif | 449 | #endif |
450 | 450 | ||
451 | #ifdef CONFIG_AMIGAONE | ||
452 | if (machine_is(amigaone)) | ||
453 | d.host_flags |= IDE_HFLAG_FORCE_LEGACY_IRQS; | ||
454 | #endif | ||
455 | |||
451 | d.udma_mask = via_config->udma_mask; | 456 | d.udma_mask = via_config->udma_mask; |
452 | 457 | ||
453 | vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); | 458 | vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); |
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index a329e6bd5d2d..3838bc4acaba 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c | |||
@@ -1823,6 +1823,10 @@ static int dv1394_open(struct inode *inode, struct file *file) | |||
1823 | 1823 | ||
1824 | #endif | 1824 | #endif |
1825 | 1825 | ||
1826 | printk(KERN_INFO "%s: NOTE, the dv1394 interface is unsupported " | ||
1827 | "and will not be available in the new firewire driver stack. " | ||
1828 | "Try libraw1394 based programs instead.\n", current->comm); | ||
1829 | |||
1826 | return 0; | 1830 | return 0; |
1827 | } | 1831 | } |
1828 | 1832 | ||
@@ -2567,10 +2571,6 @@ static int __init dv1394_init_module(void) | |||
2567 | { | 2571 | { |
2568 | int ret; | 2572 | int ret; |
2569 | 2573 | ||
2570 | printk(KERN_WARNING | ||
2571 | "NOTE: The dv1394 driver is unsupported and may be removed in a " | ||
2572 | "future Linux release. Use raw1394 instead.\n"); | ||
2573 | |||
2574 | cdev_init(&dv1394_cdev, &dv1394_fops); | 2574 | cdev_init(&dv1394_cdev, &dv1394_fops); |
2575 | dv1394_cdev.owner = THIS_MODULE; | 2575 | dv1394_cdev.owner = THIS_MODULE; |
2576 | ret = cdev_add(&dv1394_cdev, IEEE1394_DV1394_DEV, 16); | 2576 | ret = cdev_add(&dv1394_cdev, IEEE1394_DV1394_DEV, 16); |
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 1e3aea9eecf1..09658b218474 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c | |||
@@ -25,13 +25,13 @@ static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector) | |||
25 | { | 25 | { |
26 | dev_info_t *hash; | 26 | dev_info_t *hash; |
27 | linear_conf_t *conf = mddev_to_conf(mddev); | 27 | linear_conf_t *conf = mddev_to_conf(mddev); |
28 | sector_t idx = sector >> conf->sector_shift; | ||
28 | 29 | ||
29 | /* | 30 | /* |
30 | * sector_div(a,b) returns the remainer and sets a to a/b | 31 | * sector_div(a,b) returns the remainer and sets a to a/b |
31 | */ | 32 | */ |
32 | sector >>= conf->sector_shift; | 33 | (void)sector_div(idx, conf->spacing); |
33 | (void)sector_div(sector, conf->spacing); | 34 | hash = conf->hash_table[idx]; |
34 | hash = conf->hash_table[sector]; | ||
35 | 35 | ||
36 | while (sector >= hash->num_sectors + hash->start_sector) | 36 | while (sector >= hash->num_sectors + hash->start_sector) |
37 | hash++; | 37 | hash++; |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 41e2509bf896..4495104f6c9f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1481,6 +1481,11 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1481 | if (find_rdev_nr(mddev, rdev->desc_nr)) | 1481 | if (find_rdev_nr(mddev, rdev->desc_nr)) |
1482 | return -EBUSY; | 1482 | return -EBUSY; |
1483 | } | 1483 | } |
1484 | if (mddev->max_disks && rdev->desc_nr >= mddev->max_disks) { | ||
1485 | printk(KERN_WARNING "md: %s: array is limited to %d devices\n", | ||
1486 | mdname(mddev), mddev->max_disks); | ||
1487 | return -EBUSY; | ||
1488 | } | ||
1484 | bdevname(rdev->bdev,b); | 1489 | bdevname(rdev->bdev,b); |
1485 | while ( (s=strchr(b, '/')) != NULL) | 1490 | while ( (s=strchr(b, '/')) != NULL) |
1486 | *s = '!'; | 1491 | *s = '!'; |
@@ -2441,6 +2446,15 @@ static void analyze_sbs(mddev_t * mddev) | |||
2441 | 2446 | ||
2442 | i = 0; | 2447 | i = 0; |
2443 | rdev_for_each(rdev, tmp, mddev) { | 2448 | rdev_for_each(rdev, tmp, mddev) { |
2449 | if (rdev->desc_nr >= mddev->max_disks || | ||
2450 | i > mddev->max_disks) { | ||
2451 | printk(KERN_WARNING | ||
2452 | "md: %s: %s: only %d devices permitted\n", | ||
2453 | mdname(mddev), bdevname(rdev->bdev, b), | ||
2454 | mddev->max_disks); | ||
2455 | kick_rdev_from_array(rdev); | ||
2456 | continue; | ||
2457 | } | ||
2444 | if (rdev != freshest) | 2458 | if (rdev != freshest) |
2445 | if (super_types[mddev->major_version]. | 2459 | if (super_types[mddev->major_version]. |
2446 | validate_super(mddev, rdev)) { | 2460 | validate_super(mddev, rdev)) { |
@@ -4614,13 +4628,6 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev) | |||
4614 | * noticed in interrupt contexts ... | 4628 | * noticed in interrupt contexts ... |
4615 | */ | 4629 | */ |
4616 | 4630 | ||
4617 | if (rdev->desc_nr == mddev->max_disks) { | ||
4618 | printk(KERN_WARNING "%s: can not hot-add to full array!\n", | ||
4619 | mdname(mddev)); | ||
4620 | err = -EBUSY; | ||
4621 | goto abort_unbind_export; | ||
4622 | } | ||
4623 | |||
4624 | rdev->raid_disk = -1; | 4631 | rdev->raid_disk = -1; |
4625 | 4632 | ||
4626 | md_update_sb(mddev, 1); | 4633 | md_update_sb(mddev, 1); |
@@ -4634,9 +4641,6 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev) | |||
4634 | md_new_event(mddev); | 4641 | md_new_event(mddev); |
4635 | return 0; | 4642 | return 0; |
4636 | 4643 | ||
4637 | abort_unbind_export: | ||
4638 | unbind_rdev_from_array(rdev); | ||
4639 | |||
4640 | abort_export: | 4644 | abort_export: |
4641 | export_rdev(rdev); | 4645 | export_rdev(rdev); |
4642 | return err; | 4646 | return err; |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7b4f5f7155d8..01e3cffd03b8 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1640,7 +1640,8 @@ static void raid1d(mddev_t *mddev) | |||
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | bio = r1_bio->bios[r1_bio->read_disk]; | 1642 | bio = r1_bio->bios[r1_bio->read_disk]; |
1643 | if ((disk=read_balance(conf, r1_bio)) == -1) { | 1643 | if ((disk=read_balance(conf, r1_bio)) == -1 || |
1644 | disk == r1_bio->read_disk) { | ||
1644 | printk(KERN_ALERT "raid1: %s: unrecoverable I/O" | 1645 | printk(KERN_ALERT "raid1: %s: unrecoverable I/O" |
1645 | " read error for block %llu\n", | 1646 | " read error for block %llu\n", |
1646 | bdevname(bio->bi_bdev,b), | 1647 | bdevname(bio->bi_bdev,b), |
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c index 6098b626811f..47fee05eaefb 100644 --- a/drivers/media/common/saa7146_video.c +++ b/drivers/media/common/saa7146_video.c | |||
@@ -576,6 +576,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c) | |||
576 | vv->vflip = c->value; | 576 | vv->vflip = c->value; |
577 | break; | 577 | break; |
578 | default: { | 578 | default: { |
579 | mutex_unlock(&dev->lock); | ||
579 | return -EINVAL; | 580 | return -EINVAL; |
580 | } | 581 | } |
581 | } | 582 | } |
diff --git a/drivers/media/common/tuners/mxl5007t.c b/drivers/media/common/tuners/mxl5007t.c index 64379f2bf237..3ec28945c26f 100644 --- a/drivers/media/common/tuners/mxl5007t.c +++ b/drivers/media/common/tuners/mxl5007t.c | |||
@@ -657,7 +657,7 @@ static int mxl5007t_get_status(struct dvb_frontend *fe, u32 *status) | |||
657 | { | 657 | { |
658 | struct mxl5007t_state *state = fe->tuner_priv; | 658 | struct mxl5007t_state *state = fe->tuner_priv; |
659 | int rf_locked, ref_locked; | 659 | int rf_locked, ref_locked; |
660 | s32 rf_input_level; | 660 | s32 rf_input_level = 0; |
661 | int ret; | 661 | int ret; |
662 | 662 | ||
663 | if (fe->ops.i2c_gate_ctrl) | 663 | if (fe->ops.i2c_gate_ctrl) |
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 98ee16773ff2..7e3aeaa7370f 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c | |||
@@ -93,6 +93,9 @@ struct dvb_ca_slot { | |||
93 | /* current state of the CAM */ | 93 | /* current state of the CAM */ |
94 | int slot_state; | 94 | int slot_state; |
95 | 95 | ||
96 | /* mutex used for serializing access to one CI slot */ | ||
97 | struct mutex slot_lock; | ||
98 | |||
96 | /* Number of CAMCHANGES that have occurred since last processing */ | 99 | /* Number of CAMCHANGES that have occurred since last processing */ |
97 | atomic_t camchange_count; | 100 | atomic_t camchange_count; |
98 | 101 | ||
@@ -711,14 +714,20 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b | |||
711 | dprintk("%s\n", __func__); | 714 | dprintk("%s\n", __func__); |
712 | 715 | ||
713 | 716 | ||
714 | // sanity check | 717 | /* sanity check */ |
715 | if (bytes_write > ca->slot_info[slot].link_buf_size) | 718 | if (bytes_write > ca->slot_info[slot].link_buf_size) |
716 | return -EINVAL; | 719 | return -EINVAL; |
717 | 720 | ||
718 | /* check if interface is actually waiting for us to read from it, or if a read is in progress */ | 721 | /* it is possible we are dealing with a single buffer implementation, |
722 | thus if there is data available for read or if there is even a read | ||
723 | already in progress, we do nothing but awake the kernel thread to | ||
724 | process the data if necessary. */ | ||
719 | if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) | 725 | if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) |
720 | goto exitnowrite; | 726 | goto exitnowrite; |
721 | if (status & (STATUSREG_DA | STATUSREG_RE)) { | 727 | if (status & (STATUSREG_DA | STATUSREG_RE)) { |
728 | if (status & STATUSREG_DA) | ||
729 | dvb_ca_en50221_thread_wakeup(ca); | ||
730 | |||
722 | status = -EAGAIN; | 731 | status = -EAGAIN; |
723 | goto exitnowrite; | 732 | goto exitnowrite; |
724 | } | 733 | } |
@@ -987,6 +996,8 @@ static int dvb_ca_en50221_thread(void *data) | |||
987 | /* go through all the slots processing them */ | 996 | /* go through all the slots processing them */ |
988 | for (slot = 0; slot < ca->slot_count; slot++) { | 997 | for (slot = 0; slot < ca->slot_count; slot++) { |
989 | 998 | ||
999 | mutex_lock(&ca->slot_info[slot].slot_lock); | ||
1000 | |||
990 | // check the cam status + deal with CAMCHANGEs | 1001 | // check the cam status + deal with CAMCHANGEs |
991 | while (dvb_ca_en50221_check_camstatus(ca, slot)) { | 1002 | while (dvb_ca_en50221_check_camstatus(ca, slot)) { |
992 | /* clear down an old CI slot if necessary */ | 1003 | /* clear down an old CI slot if necessary */ |
@@ -1122,7 +1133,7 @@ static int dvb_ca_en50221_thread(void *data) | |||
1122 | 1133 | ||
1123 | case DVB_CA_SLOTSTATE_RUNNING: | 1134 | case DVB_CA_SLOTSTATE_RUNNING: |
1124 | if (!ca->open) | 1135 | if (!ca->open) |
1125 | continue; | 1136 | break; |
1126 | 1137 | ||
1127 | // poll slots for data | 1138 | // poll slots for data |
1128 | pktcount = 0; | 1139 | pktcount = 0; |
@@ -1146,6 +1157,8 @@ static int dvb_ca_en50221_thread(void *data) | |||
1146 | } | 1157 | } |
1147 | break; | 1158 | break; |
1148 | } | 1159 | } |
1160 | |||
1161 | mutex_unlock(&ca->slot_info[slot].slot_lock); | ||
1149 | } | 1162 | } |
1150 | } | 1163 | } |
1151 | 1164 | ||
@@ -1181,6 +1194,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file, | |||
1181 | switch (cmd) { | 1194 | switch (cmd) { |
1182 | case CA_RESET: | 1195 | case CA_RESET: |
1183 | for (slot = 0; slot < ca->slot_count; slot++) { | 1196 | for (slot = 0; slot < ca->slot_count; slot++) { |
1197 | mutex_lock(&ca->slot_info[slot].slot_lock); | ||
1184 | if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) { | 1198 | if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) { |
1185 | dvb_ca_en50221_slot_shutdown(ca, slot); | 1199 | dvb_ca_en50221_slot_shutdown(ca, slot); |
1186 | if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) | 1200 | if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) |
@@ -1188,6 +1202,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file, | |||
1188 | slot, | 1202 | slot, |
1189 | DVB_CA_EN50221_CAMCHANGE_INSERTED); | 1203 | DVB_CA_EN50221_CAMCHANGE_INSERTED); |
1190 | } | 1204 | } |
1205 | mutex_unlock(&ca->slot_info[slot].slot_lock); | ||
1191 | } | 1206 | } |
1192 | ca->next_read_slot = 0; | 1207 | ca->next_read_slot = 0; |
1193 | dvb_ca_en50221_thread_wakeup(ca); | 1208 | dvb_ca_en50221_thread_wakeup(ca); |
@@ -1308,7 +1323,9 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file, | |||
1308 | goto exit; | 1323 | goto exit; |
1309 | } | 1324 | } |
1310 | 1325 | ||
1326 | mutex_lock(&ca->slot_info[slot].slot_lock); | ||
1311 | status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen + 2); | 1327 | status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen + 2); |
1328 | mutex_unlock(&ca->slot_info[slot].slot_lock); | ||
1312 | if (status == (fraglen + 2)) { | 1329 | if (status == (fraglen + 2)) { |
1313 | written = 1; | 1330 | written = 1; |
1314 | break; | 1331 | break; |
@@ -1664,6 +1681,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, | |||
1664 | ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE; | 1681 | ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE; |
1665 | atomic_set(&ca->slot_info[i].camchange_count, 0); | 1682 | atomic_set(&ca->slot_info[i].camchange_count, 0); |
1666 | ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED; | 1683 | ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED; |
1684 | mutex_init(&ca->slot_info[i].slot_lock); | ||
1667 | } | 1685 | } |
1668 | 1686 | ||
1669 | if (signal_pending(current)) { | 1687 | if (signal_pending(current)) { |
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.h b/drivers/media/dvb/dvb-core/dvb_ca_en50221.h index 8467e63ddc0d..7df2e141187a 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.h +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.h | |||
@@ -45,8 +45,10 @@ struct dvb_ca_en50221 { | |||
45 | /* the module owning this structure */ | 45 | /* the module owning this structure */ |
46 | struct module* owner; | 46 | struct module* owner; |
47 | 47 | ||
48 | /* NOTE: the read_*, write_* and poll_slot_status functions must use locks as | 48 | /* NOTE: the read_*, write_* and poll_slot_status functions will be |
49 | * they may be called from several threads at once */ | 49 | * called for different slots concurrently and need to use locks where |
50 | * and if appropriate. There will be no concurrent access to one slot. | ||
51 | */ | ||
50 | 52 | ||
51 | /* functions for accessing attribute memory on the CAM */ | 53 | /* functions for accessing attribute memory on the CAM */ |
52 | int (*read_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address); | 54 | int (*read_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address); |
diff --git a/drivers/media/dvb/dvb-usb/af9005-fe.c b/drivers/media/dvb/dvb-usb/af9005-fe.c index b1a9c4cdec93..199ece0d4883 100644 --- a/drivers/media/dvb/dvb-usb/af9005-fe.c +++ b/drivers/media/dvb/dvb-usb/af9005-fe.c | |||
@@ -220,7 +220,7 @@ static int af9005_get_post_vit_ber(struct dvb_frontend *fe, | |||
220 | u16 * abort_count) | 220 | u16 * abort_count) |
221 | { | 221 | { |
222 | u32 loc_cw_count = 0, loc_err_count; | 222 | u32 loc_cw_count = 0, loc_err_count; |
223 | u16 loc_abort_count; | 223 | u16 loc_abort_count = 0; |
224 | int ret; | 224 | int ret; |
225 | 225 | ||
226 | ret = | 226 | ret = |
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c index e1e9aa5c6b84..6a97a40d3dfb 100644 --- a/drivers/media/dvb/dvb-usb/af9015.c +++ b/drivers/media/dvb/dvb-usb/af9015.c | |||
@@ -694,7 +694,12 @@ static int af9015_read_config(struct usb_device *udev) | |||
694 | 694 | ||
695 | /* IR remote controller */ | 695 | /* IR remote controller */ |
696 | req.addr = AF9015_EEPROM_IR_MODE; | 696 | req.addr = AF9015_EEPROM_IR_MODE; |
697 | ret = af9015_rw_udev(udev, &req); | 697 | /* first message will timeout often due to possible hw bug */ |
698 | for (i = 0; i < 4; i++) { | ||
699 | ret = af9015_rw_udev(udev, &req); | ||
700 | if (!ret) | ||
701 | break; | ||
702 | } | ||
698 | if (ret) | 703 | if (ret) |
699 | goto error; | 704 | goto error; |
700 | deb_info("%s: IR mode:%d\n", __func__, val); | 705 | deb_info("%s: IR mode:%d\n", __func__, val); |
@@ -835,18 +840,19 @@ static int af9015_read_config(struct usb_device *udev) | |||
835 | if (!dvb_usb_af9015_dual_mode) | 840 | if (!dvb_usb_af9015_dual_mode) |
836 | af9015_config.dual_mode = 0; | 841 | af9015_config.dual_mode = 0; |
837 | 842 | ||
838 | /* set buffer size according to USB port speed */ | 843 | /* Set adapter0 buffer size according to USB port speed, adapter1 buffer |
844 | size can be static because it is enabled only USB2.0 */ | ||
839 | for (i = 0; i < af9015_properties_count; i++) { | 845 | for (i = 0; i < af9015_properties_count; i++) { |
840 | /* USB1.1 set smaller buffersize and disable 2nd adapter */ | 846 | /* USB1.1 set smaller buffersize and disable 2nd adapter */ |
841 | if (udev->speed == USB_SPEED_FULL) { | 847 | if (udev->speed == USB_SPEED_FULL) { |
842 | af9015_properties[i].adapter->stream.u.bulk.buffersize = | 848 | af9015_properties[i].adapter[0].stream.u.bulk.buffersize |
843 | TS_USB11_MAX_PACKET_SIZE; | 849 | = TS_USB11_MAX_PACKET_SIZE; |
844 | /* disable 2nd adapter because we don't have | 850 | /* disable 2nd adapter because we don't have |
845 | PID-filters */ | 851 | PID-filters */ |
846 | af9015_config.dual_mode = 0; | 852 | af9015_config.dual_mode = 0; |
847 | } else { | 853 | } else { |
848 | af9015_properties[i].adapter->stream.u.bulk.buffersize = | 854 | af9015_properties[i].adapter[0].stream.u.bulk.buffersize |
849 | TS_USB20_MAX_PACKET_SIZE; | 855 | = TS_USB20_MAX_PACKET_SIZE; |
850 | } | 856 | } |
851 | } | 857 | } |
852 | 858 | ||
@@ -1254,6 +1260,12 @@ static struct dvb_usb_device_properties af9015_properties[] = { | |||
1254 | .type = USB_BULK, | 1260 | .type = USB_BULK, |
1255 | .count = 6, | 1261 | .count = 6, |
1256 | .endpoint = 0x85, | 1262 | .endpoint = 0x85, |
1263 | .u = { | ||
1264 | .bulk = { | ||
1265 | .buffersize = | ||
1266 | TS_USB20_MAX_PACKET_SIZE, | ||
1267 | } | ||
1268 | } | ||
1257 | }, | 1269 | }, |
1258 | } | 1270 | } |
1259 | }, | 1271 | }, |
@@ -1353,6 +1365,12 @@ static struct dvb_usb_device_properties af9015_properties[] = { | |||
1353 | .type = USB_BULK, | 1365 | .type = USB_BULK, |
1354 | .count = 6, | 1366 | .count = 6, |
1355 | .endpoint = 0x85, | 1367 | .endpoint = 0x85, |
1368 | .u = { | ||
1369 | .bulk = { | ||
1370 | .buffersize = | ||
1371 | TS_USB20_MAX_PACKET_SIZE, | ||
1372 | } | ||
1373 | } | ||
1356 | }, | 1374 | }, |
1357 | } | 1375 | } |
1358 | }, | 1376 | }, |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index 391732788911..635d30a55078 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
@@ -1393,6 +1393,9 @@ struct usb_device_id dib0700_usb_id_table[] = { | |||
1393 | { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) }, | 1393 | { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) }, |
1394 | /* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) }, | 1394 | /* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) }, |
1395 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) }, | 1395 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) }, |
1396 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) }, | ||
1397 | { USB_DEVICE(USB_VID_TERRATEC, | ||
1398 | USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) }, | ||
1396 | { 0 } /* Terminating entry */ | 1399 | { 0 } /* Terminating entry */ |
1397 | }; | 1400 | }; |
1398 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); | 1401 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); |
@@ -1537,7 +1540,8 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
1537 | { "DiBcom STK7700D reference design", | 1540 | { "DiBcom STK7700D reference design", |
1538 | { &dib0700_usb_id_table[14], NULL }, | 1541 | { &dib0700_usb_id_table[14], NULL }, |
1539 | { NULL }, | 1542 | { NULL }, |
1540 | } | 1543 | }, |
1544 | |||
1541 | }, | 1545 | }, |
1542 | 1546 | ||
1543 | .rc_interval = DEFAULT_RC_INTERVAL, | 1547 | .rc_interval = DEFAULT_RC_INTERVAL, |
@@ -1557,7 +1561,7 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
1557 | }, | 1561 | }, |
1558 | }, | 1562 | }, |
1559 | 1563 | ||
1560 | .num_device_descs = 2, | 1564 | .num_device_descs = 3, |
1561 | .devices = { | 1565 | .devices = { |
1562 | { "ASUS My Cinema U3000 Mini DVBT Tuner", | 1566 | { "ASUS My Cinema U3000 Mini DVBT Tuner", |
1563 | { &dib0700_usb_id_table[23], NULL }, | 1567 | { &dib0700_usb_id_table[23], NULL }, |
@@ -1566,6 +1570,10 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
1566 | { "Yuan EC372S", | 1570 | { "Yuan EC372S", |
1567 | { &dib0700_usb_id_table[31], NULL }, | 1571 | { &dib0700_usb_id_table[31], NULL }, |
1568 | { NULL }, | 1572 | { NULL }, |
1573 | }, | ||
1574 | { "Terratec Cinergy T Express", | ||
1575 | { &dib0700_usb_id_table[42], NULL }, | ||
1576 | { NULL }, | ||
1569 | } | 1577 | } |
1570 | }, | 1578 | }, |
1571 | 1579 | ||
@@ -1653,7 +1661,7 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
1653 | } | 1661 | } |
1654 | }, | 1662 | }, |
1655 | 1663 | ||
1656 | .num_device_descs = 4, | 1664 | .num_device_descs = 5, |
1657 | .devices = { | 1665 | .devices = { |
1658 | { "DiBcom STK7070PD reference design", | 1666 | { "DiBcom STK7070PD reference design", |
1659 | { &dib0700_usb_id_table[17], NULL }, | 1667 | { &dib0700_usb_id_table[17], NULL }, |
@@ -1670,6 +1678,10 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
1670 | { "Hauppauge Nova-TD-500 (84xxx)", | 1678 | { "Hauppauge Nova-TD-500 (84xxx)", |
1671 | { &dib0700_usb_id_table[36], NULL }, | 1679 | { &dib0700_usb_id_table[36], NULL }, |
1672 | { NULL }, | 1680 | { NULL }, |
1681 | }, | ||
1682 | { "Terratec Cinergy DT USB XS Diversity", | ||
1683 | { &dib0700_usb_id_table[43], NULL }, | ||
1684 | { NULL }, | ||
1673 | } | 1685 | } |
1674 | } | 1686 | } |
1675 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | 1687 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index a4fca3fca5ee..0db0c06ee6f2 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -162,8 +162,10 @@ | |||
162 | #define USB_PID_AVERMEDIA_A309 0xa309 | 162 | #define USB_PID_AVERMEDIA_A309 0xa309 |
163 | #define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 | 163 | #define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 |
164 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a | 164 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a |
165 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081 | ||
165 | #define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058 | 166 | #define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058 |
166 | #define USB_PID_TERRATEC_CINERGY_HT_EXPRESS 0x0060 | 167 | #define USB_PID_TERRATEC_CINERGY_HT_EXPRESS 0x0060 |
168 | #define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062 | ||
167 | #define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078 | 169 | #define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078 |
168 | #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e | 170 | #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e |
169 | #define USB_PID_PINNACLE_PCTV2000E 0x022c | 171 | #define USB_PID_PINNACLE_PCTV2000E 0x022c |
diff --git a/drivers/media/dvb/frontends/drx397xD.c b/drivers/media/dvb/frontends/drx397xD.c index ec4e08dbc699..1e81e713df63 100644 --- a/drivers/media/dvb/frontends/drx397xD.c +++ b/drivers/media/dvb/frontends/drx397xD.c | |||
@@ -646,7 +646,7 @@ static int drx_tune(struct drx397xD_state *s, | |||
646 | u32 edi = 0, ebx = 0, ebp = 0, edx = 0; | 646 | u32 edi = 0, ebx = 0, ebp = 0, edx = 0; |
647 | u16 v20 = 0, v1E = 0, v16 = 0, v14 = 0, v12 = 0, v10 = 0, v0E = 0; | 647 | u16 v20 = 0, v1E = 0, v16 = 0, v14 = 0, v12 = 0, v10 = 0, v0E = 0; |
648 | 648 | ||
649 | int rc, df_tuner; | 649 | int rc, df_tuner = 0; |
650 | int a, b, c, d; | 650 | int a, b, c, d; |
651 | pr_debug("%s %d\n", __func__, s->config.d60); | 651 | pr_debug("%s %d\n", __func__, s->config.d60); |
652 | 652 | ||
diff --git a/drivers/media/dvb/frontends/s5h1409.c b/drivers/media/dvb/frontends/s5h1409.c index cf4d8936bb83..3e08d985d6e5 100644 --- a/drivers/media/dvb/frontends/s5h1409.c +++ b/drivers/media/dvb/frontends/s5h1409.c | |||
@@ -545,9 +545,6 @@ static int s5h1409_set_frontend(struct dvb_frontend *fe, | |||
545 | 545 | ||
546 | s5h1409_enable_modulation(fe, p->u.vsb.modulation); | 546 | s5h1409_enable_modulation(fe, p->u.vsb.modulation); |
547 | 547 | ||
548 | /* Allow the demod to settle */ | ||
549 | msleep(100); | ||
550 | |||
551 | if (fe->ops.tuner_ops.set_params) { | 548 | if (fe->ops.tuner_ops.set_params) { |
552 | if (fe->ops.i2c_gate_ctrl) | 549 | if (fe->ops.i2c_gate_ctrl) |
553 | fe->ops.i2c_gate_ctrl(fe, 1); | 550 | fe->ops.i2c_gate_ctrl(fe, 1); |
@@ -562,6 +559,10 @@ static int s5h1409_set_frontend(struct dvb_frontend *fe, | |||
562 | s5h1409_set_qam_interleave_mode(fe); | 559 | s5h1409_set_qam_interleave_mode(fe); |
563 | } | 560 | } |
564 | 561 | ||
562 | /* Issue a reset to the demod so it knows to resync against the | ||
563 | newly tuned frequency */ | ||
564 | s5h1409_softreset(fe); | ||
565 | |||
565 | return 0; | 566 | return 0; |
566 | } | 567 | } |
567 | 568 | ||
diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c index 83dc7e12d5f0..a67d1775a43c 100644 --- a/drivers/media/dvb/frontends/stb0899_algo.c +++ b/drivers/media/dvb/frontends/stb0899_algo.c | |||
@@ -31,6 +31,8 @@ inline u32 stb0899_do_div(u64 n, u32 d) | |||
31 | return n; | 31 | return n; |
32 | } | 32 | } |
33 | 33 | ||
34 | #if 0 | ||
35 | /* These functions are currently unused */ | ||
34 | /* | 36 | /* |
35 | * stb0899_calc_srate | 37 | * stb0899_calc_srate |
36 | * Compute symbol rate | 38 | * Compute symbol rate |
@@ -63,6 +65,7 @@ static u32 stb0899_get_srate(struct stb0899_state *state) | |||
63 | 65 | ||
64 | return stb0899_calc_srate(internal->master_clk, sfr); | 66 | return stb0899_calc_srate(internal->master_clk, sfr); |
65 | } | 67 | } |
68 | #endif | ||
66 | 69 | ||
67 | /* | 70 | /* |
68 | * stb0899_set_srate | 71 | * stb0899_set_srate |
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 1638e1d9f538..83e9e7750c8c 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c | |||
@@ -470,6 +470,7 @@ static void frontend_init(struct budget *budget) | |||
470 | budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config, &budget->i2c_adap); | 470 | budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config, &budget->i2c_adap); |
471 | if (budget->dvb_frontend) { | 471 | if (budget->dvb_frontend) { |
472 | budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params; | 472 | budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params; |
473 | budget->dvb_frontend->tuner_priv = NULL; | ||
473 | break; | 474 | break; |
474 | } | 475 | } |
475 | break; | 476 | break; |
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 0aa96df80fc2..d91e0638448f 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c | |||
@@ -1384,7 +1384,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) | |||
1384 | static int ttusb_dec_init_stb(struct ttusb_dec *dec) | 1384 | static int ttusb_dec_init_stb(struct ttusb_dec *dec) |
1385 | { | 1385 | { |
1386 | int result; | 1386 | int result; |
1387 | unsigned int mode, model, version; | 1387 | unsigned int mode = 0, model = 0, version = 0; |
1388 | 1388 | ||
1389 | dprintk("%s\n", __func__); | 1389 | dprintk("%s\n", __func__); |
1390 | 1390 | ||
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 0747dc8862b0..fdfc7bf86b9e 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c | |||
@@ -194,10 +194,10 @@ static int amradio_start(struct amradio_device *radio) | |||
194 | return retval; | 194 | return retval; |
195 | } | 195 | } |
196 | 196 | ||
197 | mutex_unlock(&radio->lock); | ||
198 | |||
199 | radio->muted = 0; | 197 | radio->muted = 0; |
200 | 198 | ||
199 | mutex_unlock(&radio->lock); | ||
200 | |||
201 | return retval; | 201 | return retval; |
202 | } | 202 | } |
203 | 203 | ||
@@ -230,10 +230,10 @@ static int amradio_stop(struct amradio_device *radio) | |||
230 | return retval; | 230 | return retval; |
231 | } | 231 | } |
232 | 232 | ||
233 | mutex_unlock(&radio->lock); | ||
234 | |||
235 | radio->muted = 1; | 233 | radio->muted = 1; |
236 | 234 | ||
235 | mutex_unlock(&radio->lock); | ||
236 | |||
237 | return retval; | 237 | return retval; |
238 | } | 238 | } |
239 | 239 | ||
@@ -284,10 +284,10 @@ static int amradio_setfreq(struct amradio_device *radio, int freq) | |||
284 | return retval; | 284 | return retval; |
285 | } | 285 | } |
286 | 286 | ||
287 | mutex_unlock(&radio->lock); | ||
288 | |||
289 | radio->stereo = 0; | 287 | radio->stereo = 0; |
290 | 288 | ||
289 | mutex_unlock(&radio->lock); | ||
290 | |||
291 | return retval; | 291 | return retval; |
292 | } | 292 | } |
293 | 293 | ||
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c index 14bebf8a116f..87e91072627a 100644 --- a/drivers/media/video/cs5345.c +++ b/drivers/media/video/cs5345.c | |||
@@ -18,7 +18,6 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | ||
21 | #include <linux/version.h> | ||
22 | #include <linux/module.h> | 21 | #include <linux/module.h> |
23 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
24 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c index 8f1db57bd1dd..bfe25841dbf4 100644 --- a/drivers/media/video/cx23885/cx23885-417.c +++ b/drivers/media/video/cx23885/cx23885-417.c | |||
@@ -1586,7 +1586,8 @@ static int mpeg_open(struct file *file) | |||
1586 | lock_kernel(); | 1586 | lock_kernel(); |
1587 | list_for_each(list, &cx23885_devlist) { | 1587 | list_for_each(list, &cx23885_devlist) { |
1588 | h = list_entry(list, struct cx23885_dev, devlist); | 1588 | h = list_entry(list, struct cx23885_dev, devlist); |
1589 | if (h->v4l_device->minor == minor) { | 1589 | if (h->v4l_device && |
1590 | h->v4l_device->minor == minor) { | ||
1590 | dev = h; | 1591 | dev = h; |
1591 | break; | 1592 | break; |
1592 | } | 1593 | } |
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index 2d81c4d04340..eaa11893bfe9 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -730,12 +730,13 @@ static int video_open(struct file *file) | |||
730 | lock_kernel(); | 730 | lock_kernel(); |
731 | list_for_each(list, &cx23885_devlist) { | 731 | list_for_each(list, &cx23885_devlist) { |
732 | h = list_entry(list, struct cx23885_dev, devlist); | 732 | h = list_entry(list, struct cx23885_dev, devlist); |
733 | if (h->video_dev->minor == minor) { | 733 | if (h->video_dev && |
734 | h->video_dev->minor == minor) { | ||
734 | dev = h; | 735 | dev = h; |
735 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 736 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
736 | } | 737 | } |
737 | if (h->vbi_dev && | 738 | if (h->vbi_dev && |
738 | h->vbi_dev->minor == minor) { | 739 | h->vbi_dev->minor == minor) { |
739 | dev = h; | 740 | dev = h; |
740 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | 741 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
741 | } | 742 | } |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 88f2fd32bfe3..25eb3bec9e5d 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -1382,6 +1382,14 @@ static int cx25840_log_status(struct v4l2_subdev *sd) | |||
1382 | 1382 | ||
1383 | static int cx25840_command(struct i2c_client *client, unsigned cmd, void *arg) | 1383 | static int cx25840_command(struct i2c_client *client, unsigned cmd, void *arg) |
1384 | { | 1384 | { |
1385 | /* ignore this command */ | ||
1386 | if (cmd == TUNER_SET_TYPE_ADDR || cmd == TUNER_SET_CONFIG) | ||
1387 | return 0; | ||
1388 | |||
1389 | /* Old-style drivers rely on initialization on first use, so | ||
1390 | call the init whenever a command is issued to this driver. | ||
1391 | New-style drivers using v4l2_subdev should call init explicitly. */ | ||
1392 | cx25840_init(i2c_get_clientdata(client), 0); | ||
1385 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | 1393 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); |
1386 | } | 1394 | } |
1387 | 1395 | ||
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 613dfea4ff3e..aef5297534af 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c | |||
@@ -614,34 +614,41 @@ static struct stv0288_config tevii_tuner_earda_config = { | |||
614 | .set_ts_params = cx24116_set_ts_param, | 614 | .set_ts_params = cx24116_set_ts_param, |
615 | }; | 615 | }; |
616 | 616 | ||
617 | static int dvb_register(struct cx8802_dev *dev) | 617 | static int cx8802_alloc_frontends(struct cx8802_dev *dev) |
618 | { | 618 | { |
619 | struct cx88_core *core = dev->core; | 619 | struct cx88_core *core = dev->core; |
620 | struct videobuf_dvb_frontend *fe0, *fe1 = NULL; | 620 | struct videobuf_dvb_frontend *fe = NULL; |
621 | int mfe_shared = 0; /* bus not shared by default */ | ||
622 | int i; | 621 | int i; |
623 | 622 | ||
624 | if (0 != core->i2c_rc) { | ||
625 | printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name); | ||
626 | goto frontend_detach; | ||
627 | } | ||
628 | |||
629 | if (!core->board.num_frontends) | ||
630 | return -EINVAL; | ||
631 | |||
632 | mutex_init(&dev->frontends.lock); | 623 | mutex_init(&dev->frontends.lock); |
633 | INIT_LIST_HEAD(&dev->frontends.felist); | 624 | INIT_LIST_HEAD(&dev->frontends.felist); |
634 | 625 | ||
626 | if (!core->board.num_frontends) | ||
627 | return -ENODEV; | ||
628 | |||
635 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, | 629 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, |
636 | core->board.num_frontends); | 630 | core->board.num_frontends); |
637 | for (i = 1; i <= core->board.num_frontends; i++) { | 631 | for (i = 1; i <= core->board.num_frontends; i++) { |
638 | fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, i); | 632 | fe = videobuf_dvb_alloc_frontend(&dev->frontends, i); |
639 | if (!fe0) { | 633 | if (!fe) { |
640 | printk(KERN_ERR "%s() failed to alloc\n", __func__); | 634 | printk(KERN_ERR "%s() failed to alloc\n", __func__); |
641 | videobuf_dvb_dealloc_frontends(&dev->frontends); | 635 | videobuf_dvb_dealloc_frontends(&dev->frontends); |
642 | goto frontend_detach; | 636 | return -ENOMEM; |
643 | } | 637 | } |
644 | } | 638 | } |
639 | return 0; | ||
640 | } | ||
641 | |||
642 | static int dvb_register(struct cx8802_dev *dev) | ||
643 | { | ||
644 | struct cx88_core *core = dev->core; | ||
645 | struct videobuf_dvb_frontend *fe0, *fe1 = NULL; | ||
646 | int mfe_shared = 0; /* bus not shared by default */ | ||
647 | |||
648 | if (0 != core->i2c_rc) { | ||
649 | printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name); | ||
650 | goto frontend_detach; | ||
651 | } | ||
645 | 652 | ||
646 | /* Get the first frontend */ | 653 | /* Get the first frontend */ |
647 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | 654 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); |
@@ -1243,6 +1250,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1243 | struct cx88_core *core = drv->core; | 1250 | struct cx88_core *core = drv->core; |
1244 | struct cx8802_dev *dev = drv->core->dvbdev; | 1251 | struct cx8802_dev *dev = drv->core->dvbdev; |
1245 | int err; | 1252 | int err; |
1253 | struct videobuf_dvb_frontend *fe; | ||
1254 | int i; | ||
1246 | 1255 | ||
1247 | dprintk( 1, "%s\n", __func__); | 1256 | dprintk( 1, "%s\n", __func__); |
1248 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", | 1257 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", |
@@ -1258,39 +1267,34 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1258 | /* If vp3054 isn't enabled, a stub will just return 0 */ | 1267 | /* If vp3054 isn't enabled, a stub will just return 0 */ |
1259 | err = vp3054_i2c_probe(dev); | 1268 | err = vp3054_i2c_probe(dev); |
1260 | if (0 != err) | 1269 | if (0 != err) |
1261 | goto fail_probe; | 1270 | goto fail_core; |
1262 | 1271 | ||
1263 | /* dvb stuff */ | 1272 | /* dvb stuff */ |
1264 | printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); | 1273 | printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); |
1265 | dev->ts_gen_cntrl = 0x0c; | 1274 | dev->ts_gen_cntrl = 0x0c; |
1266 | 1275 | ||
1276 | err = cx8802_alloc_frontends(dev); | ||
1277 | if (err) | ||
1278 | goto fail_core; | ||
1279 | |||
1267 | err = -ENODEV; | 1280 | err = -ENODEV; |
1268 | if (core->board.num_frontends) { | 1281 | for (i = 1; i <= core->board.num_frontends; i++) { |
1269 | struct videobuf_dvb_frontend *fe; | 1282 | fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i); |
1270 | int i; | 1283 | if (fe == NULL) { |
1271 | 1284 | printk(KERN_ERR "%s() failed to get frontend(%d)\n", | |
1272 | for (i = 1; i <= core->board.num_frontends; i++) { | ||
1273 | fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i); | ||
1274 | if (fe == NULL) { | ||
1275 | printk(KERN_ERR "%s() failed to get frontend(%d)\n", | ||
1276 | __func__, i); | 1285 | __func__, i); |
1277 | goto fail_probe; | 1286 | goto fail_probe; |
1278 | } | 1287 | } |
1279 | videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, | 1288 | videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, |
1280 | &dev->pci->dev, &dev->slock, | 1289 | &dev->pci->dev, &dev->slock, |
1281 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1290 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
1282 | V4L2_FIELD_TOP, | 1291 | V4L2_FIELD_TOP, |
1283 | sizeof(struct cx88_buffer), | 1292 | sizeof(struct cx88_buffer), |
1284 | dev); | 1293 | dev); |
1285 | /* init struct videobuf_dvb */ | 1294 | /* init struct videobuf_dvb */ |
1286 | fe->dvb.name = dev->core->name; | 1295 | fe->dvb.name = dev->core->name; |
1287 | } | ||
1288 | } else { | ||
1289 | /* no frontends allocated */ | ||
1290 | printk(KERN_ERR "%s/2 .num_frontends should be non-zero\n", | ||
1291 | core->name); | ||
1292 | goto fail_core; | ||
1293 | } | 1296 | } |
1297 | |||
1294 | err = dvb_register(dev); | 1298 | err = dvb_register(dev); |
1295 | if (err) | 1299 | if (err) |
1296 | /* frontends/adapter de-allocated in dvb_register */ | 1300 | /* frontends/adapter de-allocated in dvb_register */ |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 60a8b3187f14..6025fdd23344 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -336,8 +336,8 @@ struct cx88_core { | |||
336 | /* config info -- dvb */ | 336 | /* config info -- dvb */ |
337 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) | 337 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) |
338 | int (*prev_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); | 338 | int (*prev_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); |
339 | void (*gate_ctrl)(struct cx88_core *core, int open); | ||
340 | #endif | 339 | #endif |
340 | void (*gate_ctrl)(struct cx88_core *core, int open); | ||
341 | 341 | ||
342 | /* state info */ | 342 | /* state info */ |
343 | struct task_struct *kthread; | 343 | struct task_struct *kthread; |
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index 94378ccb7505..5d882a44e3ee 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c | |||
@@ -62,9 +62,15 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev) | |||
62 | 62 | ||
63 | dprintk("Stopping isoc\n"); | 63 | dprintk("Stopping isoc\n"); |
64 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { | 64 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { |
65 | usb_unlink_urb(dev->adev.urb[i]); | 65 | if (!irqs_disabled()) |
66 | usb_kill_urb(dev->adev.urb[i]); | ||
67 | else | ||
68 | usb_unlink_urb(dev->adev.urb[i]); | ||
66 | usb_free_urb(dev->adev.urb[i]); | 69 | usb_free_urb(dev->adev.urb[i]); |
67 | dev->adev.urb[i] = NULL; | 70 | dev->adev.urb[i] = NULL; |
71 | |||
72 | kfree(dev->adev.transfer_buffer[i]); | ||
73 | dev->adev.transfer_buffer[i] = NULL; | ||
68 | } | 74 | } |
69 | 75 | ||
70 | return 0; | 76 | return 0; |
@@ -389,11 +395,15 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, | |||
389 | static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream | 395 | static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream |
390 | *substream) | 396 | *substream) |
391 | { | 397 | { |
392 | struct em28xx *dev; | 398 | unsigned long flags; |
393 | 399 | ||
400 | struct em28xx *dev; | ||
394 | snd_pcm_uframes_t hwptr_done; | 401 | snd_pcm_uframes_t hwptr_done; |
402 | |||
395 | dev = snd_pcm_substream_chip(substream); | 403 | dev = snd_pcm_substream_chip(substream); |
404 | spin_lock_irqsave(&dev->adev.slock, flags); | ||
396 | hwptr_done = dev->adev.hwptr_done_capture; | 405 | hwptr_done = dev->adev.hwptr_done_capture; |
406 | spin_unlock_irqrestore(&dev->adev.slock, flags); | ||
397 | 407 | ||
398 | return hwptr_done; | 408 | return hwptr_done; |
399 | } | 409 | } |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index ef9bf008a924..3b3ca3f46d52 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -102,6 +102,18 @@ static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = { | |||
102 | /* Board - EM2870 Kworld 355u | 102 | /* Board - EM2870 Kworld 355u |
103 | Analog - No input analog */ | 103 | Analog - No input analog */ |
104 | 104 | ||
105 | static struct em28xx_reg_seq kworld_330u_analog[] = { | ||
106 | {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10}, | ||
107 | {EM2880_R04_GPO, 0x00, 0xff, 10}, | ||
108 | { -1, -1, -1, -1}, | ||
109 | }; | ||
110 | |||
111 | static struct em28xx_reg_seq kworld_330u_digital[] = { | ||
112 | {EM28XX_R08_GPIO, 0x6e, ~EM_GPIO_4, 10}, | ||
113 | {EM2880_R04_GPO, 0x08, 0xff, 10}, | ||
114 | { -1, -1, -1, -1}, | ||
115 | }; | ||
116 | |||
105 | /* Callback for the most boards */ | 117 | /* Callback for the most boards */ |
106 | static struct em28xx_reg_seq default_tuner_gpio[] = { | 118 | static struct em28xx_reg_seq default_tuner_gpio[] = { |
107 | {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, | 119 | {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, |
@@ -1177,29 +1189,33 @@ struct em28xx_board em28xx_boards[] = { | |||
1177 | .gpio = hauppauge_wintv_hvr_900_analog, | 1189 | .gpio = hauppauge_wintv_hvr_900_analog, |
1178 | } }, | 1190 | } }, |
1179 | }, | 1191 | }, |
1180 | [EM2883_BOARD_KWORLD_HYBRID_A316] = { | 1192 | [EM2883_BOARD_KWORLD_HYBRID_330U] = { |
1181 | .name = "Kworld PlusTV HD Hybrid 330", | 1193 | .name = "Kworld PlusTV HD Hybrid 330", |
1182 | .tuner_type = TUNER_XC2028, | 1194 | .tuner_type = TUNER_XC2028, |
1183 | .tuner_gpio = default_tuner_gpio, | 1195 | .tuner_gpio = default_tuner_gpio, |
1184 | .decoder = EM28XX_TVP5150, | 1196 | .decoder = EM28XX_TVP5150, |
1185 | .mts_firmware = 1, | 1197 | .mts_firmware = 1, |
1186 | .has_dvb = 1, | 1198 | .has_dvb = 1, |
1187 | .dvb_gpio = default_digital, | 1199 | .dvb_gpio = kworld_330u_digital, |
1200 | .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, | ||
1201 | .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_EEPROM_ON_BOARD | EM28XX_I2C_EEPROM_KEY_VALID, | ||
1188 | .input = { { | 1202 | .input = { { |
1189 | .type = EM28XX_VMUX_TELEVISION, | 1203 | .type = EM28XX_VMUX_TELEVISION, |
1190 | .vmux = TVP5150_COMPOSITE0, | 1204 | .vmux = TVP5150_COMPOSITE0, |
1191 | .amux = EM28XX_AMUX_VIDEO, | 1205 | .amux = EM28XX_AMUX_VIDEO, |
1192 | .gpio = default_analog, | 1206 | .gpio = kworld_330u_analog, |
1207 | .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, | ||
1193 | }, { | 1208 | }, { |
1194 | .type = EM28XX_VMUX_COMPOSITE1, | 1209 | .type = EM28XX_VMUX_COMPOSITE1, |
1195 | .vmux = TVP5150_COMPOSITE1, | 1210 | .vmux = TVP5150_COMPOSITE1, |
1196 | .amux = EM28XX_AMUX_LINE_IN, | 1211 | .amux = EM28XX_AMUX_LINE_IN, |
1197 | .gpio = hauppauge_wintv_hvr_900_analog, | 1212 | .gpio = kworld_330u_analog, |
1213 | .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO, | ||
1198 | }, { | 1214 | }, { |
1199 | .type = EM28XX_VMUX_SVIDEO, | 1215 | .type = EM28XX_VMUX_SVIDEO, |
1200 | .vmux = TVP5150_SVIDEO, | 1216 | .vmux = TVP5150_SVIDEO, |
1201 | .amux = EM28XX_AMUX_LINE_IN, | 1217 | .amux = EM28XX_AMUX_LINE_IN, |
1202 | .gpio = hauppauge_wintv_hvr_900_analog, | 1218 | .gpio = kworld_330u_analog, |
1203 | } }, | 1219 | } }, |
1204 | }, | 1220 | }, |
1205 | [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = { | 1221 | [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = { |
@@ -1249,7 +1265,7 @@ struct usb_device_id em28xx_id_table [] = { | |||
1249 | { USB_DEVICE(0xeb1a, 0xe310), | 1265 | { USB_DEVICE(0xeb1a, 0xe310), |
1250 | .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD }, | 1266 | .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD }, |
1251 | { USB_DEVICE(0xeb1a, 0xa316), | 1267 | { USB_DEVICE(0xeb1a, 0xa316), |
1252 | .driver_info = EM2883_BOARD_KWORLD_HYBRID_A316 }, | 1268 | .driver_info = EM2883_BOARD_KWORLD_HYBRID_330U }, |
1253 | { USB_DEVICE(0xeb1a, 0xe320), | 1269 | { USB_DEVICE(0xeb1a, 0xe320), |
1254 | .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II }, | 1270 | .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II }, |
1255 | { USB_DEVICE(0xeb1a, 0xe323), | 1271 | { USB_DEVICE(0xeb1a, 0xe323), |
@@ -1526,6 +1542,10 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl) | |||
1526 | /* FIXME: Better to specify the needed IF */ | 1542 | /* FIXME: Better to specify the needed IF */ |
1527 | ctl->demod = XC3028_FE_DEFAULT; | 1543 | ctl->demod = XC3028_FE_DEFAULT; |
1528 | break; | 1544 | break; |
1545 | case EM2883_BOARD_KWORLD_HYBRID_330U: | ||
1546 | ctl->demod = XC3028_FE_CHINA; | ||
1547 | ctl->fname = XC2028_DEFAULT_FIRMWARE; | ||
1548 | break; | ||
1529 | default: | 1549 | default: |
1530 | ctl->demod = XC3028_FE_OREN538; | 1550 | ctl->demod = XC3028_FE_OREN538; |
1531 | } | 1551 | } |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index eb5fb05fab22..94fb1b639a2e 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -438,6 +438,10 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
438 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { | 438 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { |
439 | int vol; | 439 | int vol; |
440 | 440 | ||
441 | em28xx_write_ac97(dev, AC97_POWER_DOWN_CTRL, 0x4200); | ||
442 | em28xx_write_ac97(dev, AC97_EXT_AUD_CTRL, 0x0031); | ||
443 | em28xx_write_ac97(dev, AC97_PCM_IN_SRATE, 0xbb80); | ||
444 | |||
441 | /* LSB: left channel - both channels with the same level */ | 445 | /* LSB: left channel - both channels with the same level */ |
442 | vol = (0x1f - dev->volume) | ((0x1f - dev->volume) << 8); | 446 | vol = (0x1f - dev->volume) | ((0x1f - dev->volume) << 8); |
443 | 447 | ||
@@ -454,6 +458,15 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
454 | em28xx_warn("couldn't setup AC97 register %d\n", | 458 | em28xx_warn("couldn't setup AC97 register %d\n", |
455 | outputs[i].reg); | 459 | outputs[i].reg); |
456 | } | 460 | } |
461 | |||
462 | if (dev->ctl_aoutput & EM28XX_AOUT_PCM_IN) { | ||
463 | int sel = ac97_return_record_select(dev->ctl_aoutput); | ||
464 | |||
465 | /* Use the same input for both left and right channels */ | ||
466 | sel |= (sel << 8); | ||
467 | |||
468 | em28xx_write_ac97(dev, AC97_RECORD_SELECT, sel); | ||
469 | } | ||
457 | } | 470 | } |
458 | 471 | ||
459 | return ret; | 472 | return ret; |
@@ -847,8 +860,11 @@ void em28xx_uninit_isoc(struct em28xx *dev) | |||
847 | for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { | 860 | for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { |
848 | urb = dev->isoc_ctl.urb[i]; | 861 | urb = dev->isoc_ctl.urb[i]; |
849 | if (urb) { | 862 | if (urb) { |
850 | usb_kill_urb(urb); | 863 | if (!irqs_disabled()) |
851 | usb_unlink_urb(urb); | 864 | usb_kill_urb(urb); |
865 | else | ||
866 | usb_unlink_urb(urb); | ||
867 | |||
852 | if (dev->isoc_ctl.transfer_buffer[i]) { | 868 | if (dev->isoc_ctl.transfer_buffer[i]) { |
853 | usb_buffer_free(dev->udev, | 869 | usb_buffer_free(dev->udev, |
854 | urb->transfer_buffer_length, | 870 | urb->transfer_buffer_length, |
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c index d38cb21834d9..9ad8527b3fda 100644 --- a/drivers/media/video/em28xx/em28xx-dvb.c +++ b/drivers/media/video/em28xx/em28xx-dvb.c | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #include "lgdt330x.h" | 29 | #include "lgdt330x.h" |
30 | #include "zl10353.h" | 30 | #include "zl10353.h" |
31 | #include "s5h1409.h" | ||
31 | #ifdef EM28XX_DRX397XD_SUPPORT | 32 | #ifdef EM28XX_DRX397XD_SUPPORT |
32 | #include "drx397xD.h" | 33 | #include "drx397xD.h" |
33 | #endif | 34 | #endif |
@@ -232,6 +233,15 @@ static struct zl10353_config em28xx_zl10353_with_xc3028 = { | |||
232 | .if2 = 45600, | 233 | .if2 = 45600, |
233 | }; | 234 | }; |
234 | 235 | ||
236 | static struct s5h1409_config em28xx_s5h1409_with_xc3028 = { | ||
237 | .demod_address = 0x32 >> 1, | ||
238 | .output_mode = S5H1409_PARALLEL_OUTPUT, | ||
239 | .gpio = S5H1409_GPIO_OFF, | ||
240 | .inversion = S5H1409_INVERSION_OFF, | ||
241 | .status_mode = S5H1409_DEMODLOCKING, | ||
242 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK | ||
243 | }; | ||
244 | |||
235 | #ifdef EM28XX_DRX397XD_SUPPORT | 245 | #ifdef EM28XX_DRX397XD_SUPPORT |
236 | /* [TODO] djh - not sure yet what the device config needs to contain */ | 246 | /* [TODO] djh - not sure yet what the device config needs to contain */ |
237 | static struct drx397xD_config em28xx_drx397xD_with_xc3028 = { | 247 | static struct drx397xD_config em28xx_drx397xD_with_xc3028 = { |
@@ -412,7 +422,6 @@ static int dvb_init(struct em28xx *dev) | |||
412 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850: | 422 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850: |
413 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: | 423 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: |
414 | case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: | 424 | case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: |
415 | case EM2883_BOARD_KWORLD_HYBRID_A316: | ||
416 | case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600: | 425 | case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600: |
417 | dvb->frontend = dvb_attach(lgdt330x_attach, | 426 | dvb->frontend = dvb_attach(lgdt330x_attach, |
418 | &em2880_lgdt3303_dev, | 427 | &em2880_lgdt3303_dev, |
@@ -433,6 +442,15 @@ static int dvb_init(struct em28xx *dev) | |||
433 | goto out_free; | 442 | goto out_free; |
434 | } | 443 | } |
435 | break; | 444 | break; |
445 | case EM2883_BOARD_KWORLD_HYBRID_330U: | ||
446 | dvb->frontend = dvb_attach(s5h1409_attach, | ||
447 | &em28xx_s5h1409_with_xc3028, | ||
448 | &dev->i2c_adap); | ||
449 | if (attach_xc3028(0x61, dev) < 0) { | ||
450 | result = -EINVAL; | ||
451 | goto out_free; | ||
452 | } | ||
453 | break; | ||
436 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: | 454 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: |
437 | #ifdef EM28XX_DRX397XD_SUPPORT | 455 | #ifdef EM28XX_DRX397XD_SUPPORT |
438 | /* We don't have the config structure properly populated, so | 456 | /* We don't have the config structure properly populated, so |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 416b691c33c1..8e61b2ca9167 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -886,10 +886,10 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | |||
886 | if (0 == INPUT(i)->type) | 886 | if (0 == INPUT(i)->type) |
887 | return -EINVAL; | 887 | return -EINVAL; |
888 | 888 | ||
889 | mutex_lock(&dev->lock); | 889 | dev->ctl_input = i; |
890 | |||
891 | video_mux(dev, i); | ||
892 | 890 | ||
891 | mutex_lock(&dev->lock); | ||
892 | video_mux(dev, dev->ctl_input); | ||
893 | mutex_unlock(&dev->lock); | 893 | mutex_unlock(&dev->lock); |
894 | return 0; | 894 | return 0; |
895 | } | 895 | } |
@@ -939,6 +939,12 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) | |||
939 | struct em28xx_fh *fh = priv; | 939 | struct em28xx_fh *fh = priv; |
940 | struct em28xx *dev = fh->dev; | 940 | struct em28xx *dev = fh->dev; |
941 | 941 | ||
942 | |||
943 | if (a->index >= MAX_EM28XX_INPUT) | ||
944 | return -EINVAL; | ||
945 | if (0 == INPUT(a->index)->type) | ||
946 | return -EINVAL; | ||
947 | |||
942 | mutex_lock(&dev->lock); | 948 | mutex_lock(&dev->lock); |
943 | 949 | ||
944 | dev->ctl_ainput = INPUT(a->index)->amux; | 950 | dev->ctl_ainput = INPUT(a->index)->amux; |
@@ -1950,6 +1956,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, | |||
1950 | 1956 | ||
1951 | int em28xx_register_analog_devices(struct em28xx *dev) | 1957 | int em28xx_register_analog_devices(struct em28xx *dev) |
1952 | { | 1958 | { |
1959 | u8 val; | ||
1953 | int ret; | 1960 | int ret; |
1954 | 1961 | ||
1955 | printk(KERN_INFO "%s: v4l2 driver version %d.%d.%d\n", | 1962 | printk(KERN_INFO "%s: v4l2 driver version %d.%d.%d\n", |
@@ -1957,34 +1964,34 @@ int em28xx_register_analog_devices(struct em28xx *dev) | |||
1957 | (EM28XX_VERSION_CODE >> 16) & 0xff, | 1964 | (EM28XX_VERSION_CODE >> 16) & 0xff, |
1958 | (EM28XX_VERSION_CODE >> 8) & 0xff, EM28XX_VERSION_CODE & 0xff); | 1965 | (EM28XX_VERSION_CODE >> 8) & 0xff, EM28XX_VERSION_CODE & 0xff); |
1959 | 1966 | ||
1967 | /* set default norm */ | ||
1968 | dev->norm = em28xx_video_template.current_norm; | ||
1969 | dev->width = norm_maxw(dev); | ||
1970 | dev->height = norm_maxh(dev); | ||
1971 | dev->interlaced = EM28XX_INTERLACED_DEFAULT; | ||
1972 | dev->hscale = 0; | ||
1973 | dev->vscale = 0; | ||
1974 | dev->ctl_input = 0; | ||
1975 | |||
1960 | /* Analog specific initialization */ | 1976 | /* Analog specific initialization */ |
1961 | dev->format = &format[0]; | 1977 | dev->format = &format[0]; |
1962 | video_mux(dev, 0); | 1978 | video_mux(dev, dev->ctl_input); |
1979 | |||
1980 | /* Audio defaults */ | ||
1981 | dev->mute = 1; | ||
1982 | dev->volume = 0x1f; | ||
1963 | 1983 | ||
1964 | /* enable vbi capturing */ | 1984 | /* enable vbi capturing */ |
1965 | 1985 | ||
1966 | /* em28xx_write_reg(dev, EM28XX_R0E_AUDIOSRC, 0xc0); audio register */ | 1986 | /* em28xx_write_reg(dev, EM28XX_R0E_AUDIOSRC, 0xc0); audio register */ |
1967 | /* em28xx_write_reg(dev, EM28XX_R0F_XCLK, 0x80); clk register */ | 1987 | val = (u8)em28xx_read_reg(dev, EM28XX_R0F_XCLK); |
1988 | em28xx_write_reg(dev, EM28XX_R0F_XCLK, (EM28XX_XCLK_AUDIO_UNMUTE | val)); | ||
1968 | em28xx_write_reg(dev, EM28XX_R11_VINCTRL, 0x51); | 1989 | em28xx_write_reg(dev, EM28XX_R11_VINCTRL, 0x51); |
1969 | 1990 | ||
1970 | dev->mute = 1; /* maybe not the right place... */ | ||
1971 | dev->volume = 0x1f; | ||
1972 | |||
1973 | em28xx_set_outfmt(dev); | 1991 | em28xx_set_outfmt(dev); |
1974 | em28xx_colorlevels_set_default(dev); | 1992 | em28xx_colorlevels_set_default(dev); |
1975 | em28xx_compression_disable(dev); | 1993 | em28xx_compression_disable(dev); |
1976 | 1994 | ||
1977 | /* set default norm */ | ||
1978 | dev->norm = em28xx_video_template.current_norm; | ||
1979 | dev->width = norm_maxw(dev); | ||
1980 | dev->height = norm_maxh(dev); | ||
1981 | dev->interlaced = EM28XX_INTERLACED_DEFAULT; | ||
1982 | dev->hscale = 0; | ||
1983 | dev->vscale = 0; | ||
1984 | |||
1985 | /* FIXME: This is a very bad hack! Not all devices have TV on input 2 */ | ||
1986 | dev->ctl_input = 2; | ||
1987 | |||
1988 | /* allocate and fill video video_device struct */ | 1995 | /* allocate and fill video video_device struct */ |
1989 | dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video"); | 1996 | dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video"); |
1990 | if (!dev->vdev) { | 1997 | if (!dev->vdev) { |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 6c6b94aa05b2..dd2cd36fb1bb 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -94,7 +94,7 @@ | |||
94 | #define EM2882_BOARD_KWORLD_VS_DVBT 54 | 94 | #define EM2882_BOARD_KWORLD_VS_DVBT 54 |
95 | #define EM2882_BOARD_TERRATEC_HYBRID_XS 55 | 95 | #define EM2882_BOARD_TERRATEC_HYBRID_XS 55 |
96 | #define EM2882_BOARD_PINNACLE_HYBRID_PRO 56 | 96 | #define EM2882_BOARD_PINNACLE_HYBRID_PRO 56 |
97 | #define EM2883_BOARD_KWORLD_HYBRID_A316 57 | 97 | #define EM2883_BOARD_KWORLD_HYBRID_330U 57 |
98 | #define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58 | 98 | #define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58 |
99 | #define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 60 | 99 | #define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 60 |
100 | #define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2 61 | 100 | #define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2 61 |
@@ -300,13 +300,32 @@ enum em28xx_amux { | |||
300 | }; | 300 | }; |
301 | 301 | ||
302 | enum em28xx_aout { | 302 | enum em28xx_aout { |
303 | /* AC97 outputs */ | ||
303 | EM28XX_AOUT_MASTER = 1 << 0, | 304 | EM28XX_AOUT_MASTER = 1 << 0, |
304 | EM28XX_AOUT_LINE = 1 << 1, | 305 | EM28XX_AOUT_LINE = 1 << 1, |
305 | EM28XX_AOUT_MONO = 1 << 2, | 306 | EM28XX_AOUT_MONO = 1 << 2, |
306 | EM28XX_AOUT_LFE = 1 << 3, | 307 | EM28XX_AOUT_LFE = 1 << 3, |
307 | EM28XX_AOUT_SURR = 1 << 4, | 308 | EM28XX_AOUT_SURR = 1 << 4, |
309 | |||
310 | /* PCM IN Mixer - used by AC97_RECORD_SELECT register */ | ||
311 | EM28XX_AOUT_PCM_IN = 1 << 7, | ||
312 | |||
313 | /* Bits 10-8 are used to indicate the PCM IN record select */ | ||
314 | EM28XX_AOUT_PCM_MIC_PCM = 0 << 8, | ||
315 | EM28XX_AOUT_PCM_CD = 1 << 8, | ||
316 | EM28XX_AOUT_PCM_VIDEO = 2 << 8, | ||
317 | EM28XX_AOUT_PCM_AUX = 3 << 8, | ||
318 | EM28XX_AOUT_PCM_LINE = 4 << 8, | ||
319 | EM28XX_AOUT_PCM_STEREO = 5 << 8, | ||
320 | EM28XX_AOUT_PCM_MONO = 6 << 8, | ||
321 | EM28XX_AOUT_PCM_PHONE = 7 << 8, | ||
308 | }; | 322 | }; |
309 | 323 | ||
324 | static inline int ac97_return_record_select(int a_out) | ||
325 | { | ||
326 | return (a_out & 0x700) >> 8; | ||
327 | } | ||
328 | |||
310 | struct em28xx_reg_seq { | 329 | struct em28xx_reg_seq { |
311 | int reg; | 330 | int reg; |
312 | unsigned char val, mask; | 331 | unsigned char val, mask; |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index 5e36b9a4ae3e..2ed24527ecd6 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -423,7 +423,8 @@ static void destroy_urbs(struct gspca_dev *gspca_dev) | |||
423 | break; | 423 | break; |
424 | 424 | ||
425 | gspca_dev->urb[i] = NULL; | 425 | gspca_dev->urb[i] = NULL; |
426 | usb_kill_urb(urb); | 426 | if (!gspca_dev->present) |
427 | usb_kill_urb(urb); | ||
427 | if (urb->transfer_buffer != NULL) | 428 | if (urb->transfer_buffer != NULL) |
428 | usb_buffer_free(gspca_dev->dev, | 429 | usb_buffer_free(gspca_dev->dev, |
429 | urb->transfer_buffer_length, | 430 | urb->transfer_buffer_length, |
@@ -1950,7 +1951,6 @@ void gspca_disconnect(struct usb_interface *intf) | |||
1950 | struct gspca_dev *gspca_dev = usb_get_intfdata(intf); | 1951 | struct gspca_dev *gspca_dev = usb_get_intfdata(intf); |
1951 | 1952 | ||
1952 | gspca_dev->present = 0; | 1953 | gspca_dev->present = 0; |
1953 | gspca_dev->streaming = 0; | ||
1954 | 1954 | ||
1955 | usb_set_intfdata(intf, NULL); | 1955 | usb_set_intfdata(intf, NULL); |
1956 | 1956 | ||
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index e8e5921cdc34..c46c990987f9 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -949,8 +949,10 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
949 | itv->instance = atomic_inc_return(&ivtv_instance) - 1; | 949 | itv->instance = atomic_inc_return(&ivtv_instance) - 1; |
950 | 950 | ||
951 | retval = v4l2_device_register(&dev->dev, &itv->device); | 951 | retval = v4l2_device_register(&dev->dev, &itv->device); |
952 | if (retval) | 952 | if (retval) { |
953 | kfree(itv); | ||
953 | return retval; | 954 | return retval; |
955 | } | ||
954 | /* "ivtv + PCI ID" is a bit of a mouthful, so use | 956 | /* "ivtv + PCI ID" is a bit of a mouthful, so use |
955 | "ivtv + instance" instead. */ | 957 | "ivtv + instance" instead. */ |
956 | snprintf(itv->device.name, sizeof(itv->device.name), | 958 | snprintf(itv->device.name, sizeof(itv->device.name), |
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index 39fbc970f43d..0d810189dd87 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -62,7 +62,6 @@ | |||
62 | #include <linux/poll.h> | 62 | #include <linux/poll.h> |
63 | #include <linux/slab.h> | 63 | #include <linux/slab.h> |
64 | #include <linux/vmalloc.h> | 64 | #include <linux/vmalloc.h> |
65 | #include <linux/version.h> | ||
66 | #include <asm/io.h> | 65 | #include <asm/io.h> |
67 | 66 | ||
68 | #include "pwc.h" | 67 | #include "pwc.h" |
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index d6848f7a503b..05221d47dd4c 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c | |||
@@ -149,7 +149,7 @@ static const struct i2c_reg_value saa7127_init_config_common[] = { | |||
149 | { SAA7127_REG_COPYGEN_0, 0x77 }, | 149 | { SAA7127_REG_COPYGEN_0, 0x77 }, |
150 | { SAA7127_REG_COPYGEN_1, 0x41 }, | 150 | { SAA7127_REG_COPYGEN_1, 0x41 }, |
151 | { SAA7127_REG_COPYGEN_2, 0x00 }, /* Macrovision enable/disable */ | 151 | { SAA7127_REG_COPYGEN_2, 0x00 }, /* Macrovision enable/disable */ |
152 | { SAA7127_REG_OUTPUT_PORT_CONTROL, 0x9e }, | 152 | { SAA7127_REG_OUTPUT_PORT_CONTROL, 0xbf }, |
153 | { SAA7127_REG_GAIN_LUMINANCE_RGB, 0x00 }, | 153 | { SAA7127_REG_GAIN_LUMINANCE_RGB, 0x00 }, |
154 | { SAA7127_REG_GAIN_COLORDIFF_RGB, 0x00 }, | 154 | { SAA7127_REG_GAIN_COLORDIFF_RGB, 0x00 }, |
155 | { SAA7127_REG_INPUT_PORT_CONTROL_1, 0x80 }, /* for color bars */ | 155 | { SAA7127_REG_INPUT_PORT_CONTROL_1, 0x80 }, /* for color bars */ |
@@ -488,12 +488,18 @@ static int saa7127_set_output_type(struct v4l2_subdev *sd, int output) | |||
488 | break; | 488 | break; |
489 | 489 | ||
490 | case SAA7127_OUTPUT_TYPE_COMPOSITE: | 490 | case SAA7127_OUTPUT_TYPE_COMPOSITE: |
491 | state->reg_2d = 0x08; /* 00001000 CVBS only, RGB DAC's off (high impedance mode) */ | 491 | if (state->ident == V4L2_IDENT_SAA7129) |
492 | state->reg_2d = 0x20; /* CVBS only */ | ||
493 | else | ||
494 | state->reg_2d = 0x08; /* 00001000 CVBS only, RGB DAC's off (high impedance mode) */ | ||
492 | state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ | 495 | state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ |
493 | break; | 496 | break; |
494 | 497 | ||
495 | case SAA7127_OUTPUT_TYPE_SVIDEO: | 498 | case SAA7127_OUTPUT_TYPE_SVIDEO: |
496 | state->reg_2d = 0xff; /* 11111111 croma -> R, luma -> CVBS + G + B */ | 499 | if (state->ident == V4L2_IDENT_SAA7129) |
500 | state->reg_2d = 0x18; /* Y + C */ | ||
501 | else | ||
502 | state->reg_2d = 0xff; /*11111111 croma -> R, luma -> CVBS + G + B */ | ||
497 | state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ | 503 | state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ |
498 | break; | 504 | break; |
499 | 505 | ||
@@ -508,7 +514,10 @@ static int saa7127_set_output_type(struct v4l2_subdev *sd, int output) | |||
508 | break; | 514 | break; |
509 | 515 | ||
510 | case SAA7127_OUTPUT_TYPE_BOTH: | 516 | case SAA7127_OUTPUT_TYPE_BOTH: |
511 | state->reg_2d = 0xbf; | 517 | if (state->ident == V4L2_IDENT_SAA7129) |
518 | state->reg_2d = 0x38; | ||
519 | else | ||
520 | state->reg_2d = 0xbf; | ||
512 | state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ | 521 | state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ |
513 | break; | 522 | break; |
514 | 523 | ||
@@ -731,24 +740,6 @@ static int saa7127_probe(struct i2c_client *client, | |||
731 | return -ENODEV; | 740 | return -ENODEV; |
732 | } | 741 | } |
733 | 742 | ||
734 | /* Configure Encoder */ | ||
735 | |||
736 | v4l2_dbg(1, debug, sd, "Configuring encoder\n"); | ||
737 | saa7127_write_inittab(sd, saa7127_init_config_common); | ||
738 | saa7127_set_std(sd, V4L2_STD_NTSC); | ||
739 | saa7127_set_output_type(sd, SAA7127_OUTPUT_TYPE_BOTH); | ||
740 | saa7127_set_vps(sd, &vbi); | ||
741 | saa7127_set_wss(sd, &vbi); | ||
742 | saa7127_set_cc(sd, &vbi); | ||
743 | saa7127_set_xds(sd, &vbi); | ||
744 | if (test_image == 1) | ||
745 | /* The Encoder has an internal Colorbar generator */ | ||
746 | /* This can be used for debugging */ | ||
747 | saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_TEST_IMAGE); | ||
748 | else | ||
749 | saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_NORMAL); | ||
750 | saa7127_set_video_enable(sd, 1); | ||
751 | |||
752 | if (id->driver_data) { /* Chip type is already known */ | 743 | if (id->driver_data) { /* Chip type is already known */ |
753 | state->ident = id->driver_data; | 744 | state->ident = id->driver_data; |
754 | } else { /* Needs detection */ | 745 | } else { /* Needs detection */ |
@@ -770,6 +761,23 @@ static int saa7127_probe(struct i2c_client *client, | |||
770 | 761 | ||
771 | v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, | 762 | v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, |
772 | client->addr << 1, client->adapter->name); | 763 | client->addr << 1, client->adapter->name); |
764 | |||
765 | v4l2_dbg(1, debug, sd, "Configuring encoder\n"); | ||
766 | saa7127_write_inittab(sd, saa7127_init_config_common); | ||
767 | saa7127_set_std(sd, V4L2_STD_NTSC); | ||
768 | saa7127_set_output_type(sd, SAA7127_OUTPUT_TYPE_BOTH); | ||
769 | saa7127_set_vps(sd, &vbi); | ||
770 | saa7127_set_wss(sd, &vbi); | ||
771 | saa7127_set_cc(sd, &vbi); | ||
772 | saa7127_set_xds(sd, &vbi); | ||
773 | if (test_image == 1) | ||
774 | /* The Encoder has an internal Colorbar generator */ | ||
775 | /* This can be used for debugging */ | ||
776 | saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_TEST_IMAGE); | ||
777 | else | ||
778 | saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_NORMAL); | ||
779 | saa7127_set_video_enable(sd, 1); | ||
780 | |||
773 | if (state->ident == V4L2_IDENT_SAA7129) | 781 | if (state->ident == V4L2_IDENT_SAA7129) |
774 | saa7127_write_inittab(sd, saa7129_init_config_extra); | 782 | saa7127_write_inittab(sd, saa7129_init_config_extra); |
775 | return 0; | 783 | return 0; |
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index 26194a0ce927..c750d3dd57d2 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c | |||
@@ -1089,7 +1089,11 @@ static int saa7134_alsa_init(void) | |||
1089 | 1089 | ||
1090 | list_for_each(list,&saa7134_devlist) { | 1090 | list_for_each(list,&saa7134_devlist) { |
1091 | dev = list_entry(list, struct saa7134_dev, devlist); | 1091 | dev = list_entry(list, struct saa7134_dev, devlist); |
1092 | alsa_device_init(dev); | 1092 | if (dev->pci->device == PCI_DEVICE_ID_PHILIPS_SAA7130) |
1093 | printk(KERN_INFO "%s/alsa: %s doesn't support digital audio\n", | ||
1094 | dev->name, saa7134_boards[dev->board].name); | ||
1095 | else | ||
1096 | alsa_device_init(dev); | ||
1093 | } | 1097 | } |
1094 | 1098 | ||
1095 | if (dev == NULL) | 1099 | if (dev == NULL) |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index dfbe08a9ad9b..99221d726edb 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -660,6 +660,10 @@ static int saa7134_hwinit1(struct saa7134_dev *dev) | |||
660 | 660 | ||
661 | saa_writel(SAA7134_IRQ1, 0); | 661 | saa_writel(SAA7134_IRQ1, 0); |
662 | saa_writel(SAA7134_IRQ2, 0); | 662 | saa_writel(SAA7134_IRQ2, 0); |
663 | |||
664 | /* Clear any stale IRQ reports */ | ||
665 | saa_writel(SAA7134_IRQ_REPORT, saa_readl(SAA7134_IRQ_REPORT)); | ||
666 | |||
663 | mutex_init(&dev->lock); | 667 | mutex_init(&dev->lock); |
664 | spin_lock_init(&dev->slock); | 668 | spin_lock_init(&dev->slock); |
665 | 669 | ||
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c index 454ad1dd7507..88c5e942f751 100644 --- a/drivers/media/video/saa717x.c +++ b/drivers/media/video/saa717x.c | |||
@@ -30,7 +30,6 @@ | |||
30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/version.h> | ||
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
36 | #include <linux/sched.h> | 35 | #include <linux/sched.h> |
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index 56f0c0eb500f..00c6cbe06ab0 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c | |||
@@ -242,7 +242,7 @@ static int tda9875_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | |||
242 | static int tda9875_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) | 242 | static int tda9875_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) |
243 | { | 243 | { |
244 | struct tda9875 *t = to_state(sd); | 244 | struct tda9875 *t = to_state(sd); |
245 | int chvol=0, volume, balance, left, right; | 245 | int chvol = 0, volume = 0, balance = 0, left, right; |
246 | 246 | ||
247 | switch (ctrl->id) { | 247 | switch (ctrl->id) { |
248 | case V4L2_CID_AUDIO_VOLUME: | 248 | case V4L2_CID_AUDIO_VOLUME: |
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 3b0b84c2e451..78277abb733b 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c | |||
@@ -427,6 +427,9 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, | |||
427 | const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" }; | 427 | const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" }; |
428 | 428 | ||
429 | memset(tvee, 0, sizeof(*tvee)); | 429 | memset(tvee, 0, sizeof(*tvee)); |
430 | tvee->tuner_type = TUNER_ABSENT; | ||
431 | tvee->tuner2_type = TUNER_ABSENT; | ||
432 | |||
430 | done = len = beenhere = 0; | 433 | done = len = beenhere = 0; |
431 | 434 | ||
432 | /* Different eeprom start offsets for em28xx, cx2388x and cx23418 */ | 435 | /* Different eeprom start offsets for em28xx, cx2388x and cx23418 */ |
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c index ac9aa40d09f6..8e23aa53c29a 100644 --- a/drivers/media/video/tvp514x.c +++ b/drivers/media/video/tvp514x.c | |||
@@ -1401,7 +1401,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1401 | 1401 | ||
1402 | decoder->pdata = client->dev.platform_data; | 1402 | decoder->pdata = client->dev.platform_data; |
1403 | if (!decoder->pdata) { | 1403 | if (!decoder->pdata) { |
1404 | v4l_err(client, "No platform data\n!!"); | 1404 | v4l_err(client, "No platform data!!\n"); |
1405 | return -ENODEV; | 1405 | return -ENODEV; |
1406 | } | 1406 | } |
1407 | /* | 1407 | /* |
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c index 4f16effb530f..f4522bb08916 100644 --- a/drivers/media/video/upd64031a.c +++ b/drivers/media/video/upd64031a.c | |||
@@ -21,7 +21,6 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | 23 | ||
24 | #include <linux/version.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
27 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c index 4b712f69d1b7..a5fb74bf2407 100644 --- a/drivers/media/video/upd64083.c +++ b/drivers/media/video/upd64083.c | |||
@@ -21,7 +21,6 @@ | |||
21 | * 02110-1301, USA. | 21 | * 02110-1301, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/version.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
27 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c index 9907b9aff2b9..6b66ae4f430f 100644 --- a/drivers/media/video/usbvision/usbvision-i2c.c +++ b/drivers/media/video/usbvision/usbvision-i2c.c | |||
@@ -157,7 +157,7 @@ usbvision_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) | |||
157 | struct i2c_msg *pmsg; | 157 | struct i2c_msg *pmsg; |
158 | struct usb_usbvision *usbvision; | 158 | struct usb_usbvision *usbvision; |
159 | int i, ret; | 159 | int i, ret; |
160 | unsigned char addr; | 160 | unsigned char addr = 0; |
161 | 161 | ||
162 | usbvision = (struct usb_usbvision *)i2c_get_adapdata(i2c_adap); | 162 | usbvision = (struct usb_usbvision *)i2c_get_adapdata(i2c_adap); |
163 | 163 | ||
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c index 2208165aa6f0..d2576f6391c0 100644 --- a/drivers/media/video/uvc/uvc_ctrl.c +++ b/drivers/media/video/uvc/uvc_ctrl.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * uvc_ctrl.c -- USB Video Class driver - Controls | 2 | * uvc_ctrl.c -- USB Video Class driver - Controls |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2008 | 4 | * Copyright (C) 2005-2009 |
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | 5 | * Laurent Pinchart (laurent.pinchart@skynet.be) |
6 | * | 6 | * |
7 | * 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 |
@@ -12,7 +12,6 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/version.h> | ||
16 | #include <linux/list.h> | 15 | #include <linux/list.h> |
17 | #include <linux/module.h> | 16 | #include <linux/module.h> |
18 | #include <linux/uaccess.h> | 17 | #include <linux/uaccess.h> |
@@ -29,7 +28,7 @@ | |||
29 | #define UVC_CTRL_DATA_BACKUP 1 | 28 | #define UVC_CTRL_DATA_BACKUP 1 |
30 | 29 | ||
31 | /* ------------------------------------------------------------------------ | 30 | /* ------------------------------------------------------------------------ |
32 | * Control, formats, ... | 31 | * Controls |
33 | */ | 32 | */ |
34 | 33 | ||
35 | static struct uvc_control_info uvc_ctrls[] = { | 34 | static struct uvc_control_info uvc_ctrls[] = { |
@@ -635,7 +634,7 @@ static __s32 uvc_get_le_value(struct uvc_control_mapping *mapping, | |||
635 | mask = (1 << bits) - 1; | 634 | mask = (1 << bits) - 1; |
636 | } | 635 | } |
637 | 636 | ||
638 | /* Sign-extend the value if needed */ | 637 | /* Sign-extend the value if needed. */ |
639 | if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED) | 638 | if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED) |
640 | value |= -(value & (1 << (mapping->size - 1))); | 639 | value |= -(value & (1 << (mapping->size - 1))); |
641 | 640 | ||
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c index 89d8bd10a852..b12873265cc5 100644 --- a/drivers/media/video/uvc/uvc_driver.c +++ b/drivers/media/video/uvc/uvc_driver.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * uvc_driver.c -- USB Video Class driver | 2 | * uvc_driver.c -- USB Video Class driver |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2008 | 4 | * Copyright (C) 2005-2009 |
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | 5 | * Laurent Pinchart (laurent.pinchart@skynet.be) |
6 | * | 6 | * |
7 | * 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 |
@@ -24,7 +24,6 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/version.h> | ||
28 | #include <linux/list.h> | 27 | #include <linux/list.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/usb.h> | 29 | #include <linux/usb.h> |
@@ -49,7 +48,7 @@ static unsigned int uvc_quirks_param; | |||
49 | unsigned int uvc_trace_param; | 48 | unsigned int uvc_trace_param; |
50 | 49 | ||
51 | /* ------------------------------------------------------------------------ | 50 | /* ------------------------------------------------------------------------ |
52 | * Control, formats, ... | 51 | * Video formats |
53 | */ | 52 | */ |
54 | 53 | ||
55 | static struct uvc_format_desc uvc_fmts[] = { | 54 | static struct uvc_format_desc uvc_fmts[] = { |
@@ -474,7 +473,7 @@ static int uvc_parse_format(struct uvc_device *dev, | |||
474 | 473 | ||
475 | /* Several UVC chipsets screw up dwMaxVideoFrameBufferSize | 474 | /* Several UVC chipsets screw up dwMaxVideoFrameBufferSize |
476 | * completely. Observed behaviours range from setting the | 475 | * completely. Observed behaviours range from setting the |
477 | * value to 1.1x the actual frame size of hardwiring the | 476 | * value to 1.1x the actual frame size to hardwiring the |
478 | * 16 low bits to 0. This results in a higher than necessary | 477 | * 16 low bits to 0. This results in a higher than necessary |
479 | * memory usage as well as a wrong image size information. For | 478 | * memory usage as well as a wrong image size information. For |
480 | * uncompressed formats this can be fixed by computing the | 479 | * uncompressed formats this can be fixed by computing the |
@@ -487,7 +486,7 @@ static int uvc_parse_format(struct uvc_device *dev, | |||
487 | /* Some bogus devices report dwMinFrameInterval equal to | 486 | /* Some bogus devices report dwMinFrameInterval equal to |
488 | * dwMaxFrameInterval and have dwFrameIntervalStep set to | 487 | * dwMaxFrameInterval and have dwFrameIntervalStep set to |
489 | * zero. Setting all null intervals to 1 fixes the problem and | 488 | * zero. Setting all null intervals to 1 fixes the problem and |
490 | * some other divisions by zero which could happen. | 489 | * some other divisions by zero that could happen. |
491 | */ | 490 | */ |
492 | for (i = 0; i < n; ++i) { | 491 | for (i = 0; i < n; ++i) { |
493 | interval = get_unaligned_le32(&buffer[26+4*i]); | 492 | interval = get_unaligned_le32(&buffer[26+4*i]); |
@@ -1200,13 +1199,13 @@ static void uvc_unregister_video(struct uvc_device *dev) | |||
1200 | * Scan the UVC descriptors to locate a chain starting at an Output Terminal | 1199 | * Scan the UVC descriptors to locate a chain starting at an Output Terminal |
1201 | * and containing the following units: | 1200 | * and containing the following units: |
1202 | * | 1201 | * |
1203 | * - a USB Streaming Output Terminal | 1202 | * - one Output Terminal (USB Streaming or Display) |
1204 | * - zero or one Processing Unit | 1203 | * - zero or one Processing Unit |
1205 | * - zero, one or mode single-input Selector Units | 1204 | * - zero, one or mode single-input Selector Units |
1206 | * - zero or one multiple-input Selector Units, provided all inputs are | 1205 | * - zero or one multiple-input Selector Units, provided all inputs are |
1207 | * connected to input terminals | 1206 | * connected to input terminals |
1208 | * - zero, one or mode single-input Extension Units | 1207 | * - zero, one or mode single-input Extension Units |
1209 | * - one Camera Input Terminal, or one or more External terminals. | 1208 | * - one or more Input Terminals (Camera, External or USB Streaming) |
1210 | * | 1209 | * |
1211 | * A side forward scan is made on each detected entity to check for additional | 1210 | * A side forward scan is made on each detected entity to check for additional |
1212 | * extension units. | 1211 | * extension units. |
@@ -1531,10 +1530,6 @@ static int uvc_register_video(struct uvc_device *dev) | |||
1531 | 1530 | ||
1532 | /* Set the driver data before calling video_register_device, otherwise | 1531 | /* Set the driver data before calling video_register_device, otherwise |
1533 | * uvc_v4l2_open might race us. | 1532 | * uvc_v4l2_open might race us. |
1534 | * | ||
1535 | * FIXME: usb_set_intfdata hasn't been called so far. Is that a | ||
1536 | * problem ? Does any function which could be called here get | ||
1537 | * a pointer to the usb_interface ? | ||
1538 | */ | 1533 | */ |
1539 | dev->video.vdev = vdev; | 1534 | dev->video.vdev = vdev; |
1540 | video_set_drvdata(vdev, &dev->video); | 1535 | video_set_drvdata(vdev, &dev->video); |
@@ -1569,7 +1564,7 @@ void uvc_delete(struct kref *kref) | |||
1569 | struct uvc_device *dev = container_of(kref, struct uvc_device, kref); | 1564 | struct uvc_device *dev = container_of(kref, struct uvc_device, kref); |
1570 | struct list_head *p, *n; | 1565 | struct list_head *p, *n; |
1571 | 1566 | ||
1572 | /* Unregister the video device */ | 1567 | /* Unregister the video device. */ |
1573 | uvc_unregister_video(dev); | 1568 | uvc_unregister_video(dev); |
1574 | usb_put_intf(dev->intf); | 1569 | usb_put_intf(dev->intf); |
1575 | usb_put_dev(dev->udev); | 1570 | usb_put_dev(dev->udev); |
@@ -1612,7 +1607,7 @@ static int uvc_probe(struct usb_interface *intf, | |||
1612 | uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n", | 1607 | uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n", |
1613 | udev->devpath); | 1608 | udev->devpath); |
1614 | 1609 | ||
1615 | /* Allocate memory for the device and initialize it */ | 1610 | /* Allocate memory for the device and initialize it. */ |
1616 | if ((dev = kzalloc(sizeof *dev, GFP_KERNEL)) == NULL) | 1611 | if ((dev = kzalloc(sizeof *dev, GFP_KERNEL)) == NULL) |
1617 | return -ENOMEM; | 1612 | return -ENOMEM; |
1618 | 1613 | ||
@@ -1633,14 +1628,14 @@ static int uvc_probe(struct usb_interface *intf, | |||
1633 | le16_to_cpu(udev->descriptor.idVendor), | 1628 | le16_to_cpu(udev->descriptor.idVendor), |
1634 | le16_to_cpu(udev->descriptor.idProduct)); | 1629 | le16_to_cpu(udev->descriptor.idProduct)); |
1635 | 1630 | ||
1636 | /* Parse the Video Class control descriptor */ | 1631 | /* Parse the Video Class control descriptor. */ |
1637 | if (uvc_parse_control(dev) < 0) { | 1632 | if (uvc_parse_control(dev) < 0) { |
1638 | uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC " | 1633 | uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC " |
1639 | "descriptors.\n"); | 1634 | "descriptors.\n"); |
1640 | goto error; | 1635 | goto error; |
1641 | } | 1636 | } |
1642 | 1637 | ||
1643 | uvc_printk(KERN_INFO, "Found UVC %u.%02u device %s (%04x:%04x)\n", | 1638 | uvc_printk(KERN_INFO, "Found UVC %u.%02x device %s (%04x:%04x)\n", |
1644 | dev->uvc_version >> 8, dev->uvc_version & 0xff, | 1639 | dev->uvc_version >> 8, dev->uvc_version & 0xff, |
1645 | udev->product ? udev->product : "<unnamed>", | 1640 | udev->product ? udev->product : "<unnamed>", |
1646 | le16_to_cpu(udev->descriptor.idVendor), | 1641 | le16_to_cpu(udev->descriptor.idVendor), |
@@ -1653,18 +1648,18 @@ static int uvc_probe(struct usb_interface *intf, | |||
1653 | "linux-uvc-devel mailing list.\n"); | 1648 | "linux-uvc-devel mailing list.\n"); |
1654 | } | 1649 | } |
1655 | 1650 | ||
1656 | /* Initialize controls */ | 1651 | /* Initialize controls. */ |
1657 | if (uvc_ctrl_init_device(dev) < 0) | 1652 | if (uvc_ctrl_init_device(dev) < 0) |
1658 | goto error; | 1653 | goto error; |
1659 | 1654 | ||
1660 | /* Register the video devices */ | 1655 | /* Register the video devices. */ |
1661 | if (uvc_register_video(dev) < 0) | 1656 | if (uvc_register_video(dev) < 0) |
1662 | goto error; | 1657 | goto error; |
1663 | 1658 | ||
1664 | /* Save our data pointer in the interface data */ | 1659 | /* Save our data pointer in the interface data. */ |
1665 | usb_set_intfdata(intf, dev); | 1660 | usb_set_intfdata(intf, dev); |
1666 | 1661 | ||
1667 | /* Initialize the interrupt URB */ | 1662 | /* Initialize the interrupt URB. */ |
1668 | if ((ret = uvc_status_init(dev)) < 0) { | 1663 | if ((ret = uvc_status_init(dev)) < 0) { |
1669 | uvc_printk(KERN_INFO, "Unable to initialize the status " | 1664 | uvc_printk(KERN_INFO, "Unable to initialize the status " |
1670 | "endpoint (%d), status interrupt will not be " | 1665 | "endpoint (%d), status interrupt will not be " |
@@ -1839,24 +1834,24 @@ static struct usb_device_id uvc_ids[] = { | |||
1839 | .bInterfaceSubClass = 1, | 1834 | .bInterfaceSubClass = 1, |
1840 | .bInterfaceProtocol = 0 }, | 1835 | .bInterfaceProtocol = 0 }, |
1841 | /* Apple Built-In iSight */ | 1836 | /* Apple Built-In iSight */ |
1842 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 1837 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
1843 | | USB_DEVICE_ID_MATCH_INT_INFO, | 1838 | | USB_DEVICE_ID_MATCH_INT_INFO, |
1844 | .idVendor = 0x05ac, | 1839 | .idVendor = 0x05ac, |
1845 | .idProduct = 0x8501, | 1840 | .idProduct = 0x8501, |
1846 | .bInterfaceClass = USB_CLASS_VIDEO, | 1841 | .bInterfaceClass = USB_CLASS_VIDEO, |
1847 | .bInterfaceSubClass = 1, | 1842 | .bInterfaceSubClass = 1, |
1848 | .bInterfaceProtocol = 0, | 1843 | .bInterfaceProtocol = 0, |
1849 | .driver_info = UVC_QUIRK_PROBE_MINMAX | 1844 | .driver_info = UVC_QUIRK_PROBE_MINMAX |
1850 | | UVC_QUIRK_BUILTIN_ISIGHT }, | 1845 | | UVC_QUIRK_BUILTIN_ISIGHT }, |
1851 | /* Genesys Logic USB 2.0 PC Camera */ | 1846 | /* Genesys Logic USB 2.0 PC Camera */ |
1852 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 1847 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
1853 | | USB_DEVICE_ID_MATCH_INT_INFO, | 1848 | | USB_DEVICE_ID_MATCH_INT_INFO, |
1854 | .idVendor = 0x05e3, | 1849 | .idVendor = 0x05e3, |
1855 | .idProduct = 0x0505, | 1850 | .idProduct = 0x0505, |
1856 | .bInterfaceClass = USB_CLASS_VIDEO, | 1851 | .bInterfaceClass = USB_CLASS_VIDEO, |
1857 | .bInterfaceSubClass = 1, | 1852 | .bInterfaceSubClass = 1, |
1858 | .bInterfaceProtocol = 0, | 1853 | .bInterfaceProtocol = 0, |
1859 | .driver_info = UVC_QUIRK_STREAM_NO_FID }, | 1854 | .driver_info = UVC_QUIRK_STREAM_NO_FID }, |
1860 | /* MT6227 */ | 1855 | /* MT6227 */ |
1861 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 1856 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
1862 | | USB_DEVICE_ID_MATCH_INT_INFO, | 1857 | | USB_DEVICE_ID_MATCH_INT_INFO, |
diff --git a/drivers/media/video/uvc/uvc_isight.c b/drivers/media/video/uvc/uvc_isight.c index 37bdefdbead5..436f462685a0 100644 --- a/drivers/media/video/uvc/uvc_isight.c +++ b/drivers/media/video/uvc/uvc_isight.c | |||
@@ -3,6 +3,8 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2006-2007 | 4 | * Copyright (C) 2006-2007 |
5 | * Ivan N. Zlatev <contact@i-nz.net> | 5 | * Ivan N. Zlatev <contact@i-nz.net> |
6 | * Copyright (C) 2008-2009 | ||
7 | * Laurent Pinchart <laurent.pinchart@skynet.be> | ||
6 | * | 8 | * |
7 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c index 42546342e97d..0155752e4a5a 100644 --- a/drivers/media/video/uvc/uvc_queue.c +++ b/drivers/media/video/uvc/uvc_queue.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * uvc_queue.c -- USB Video Class driver - Buffers management | 2 | * uvc_queue.c -- USB Video Class driver - Buffers management |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2008 | 4 | * Copyright (C) 2005-2009 |
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | 5 | * Laurent Pinchart (laurent.pinchart@skynet.be) |
6 | * | 6 | * |
7 | * 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 |
@@ -12,7 +12,6 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/version.h> | ||
16 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
17 | #include <linux/list.h> | 16 | #include <linux/list.h> |
18 | #include <linux/module.h> | 17 | #include <linux/module.h> |
@@ -37,22 +36,22 @@ | |||
37 | * to user space will return -EBUSY. | 36 | * to user space will return -EBUSY. |
38 | * | 37 | * |
39 | * Video buffers are managed using two queues. However, unlike most USB video | 38 | * Video buffers are managed using two queues. However, unlike most USB video |
40 | * drivers which use an in queue and an out queue, we use a main queue which | 39 | * drivers that use an in queue and an out queue, we use a main queue to hold |
41 | * holds all queued buffers (both 'empty' and 'done' buffers), and an irq | 40 | * all queued buffers (both 'empty' and 'done' buffers), and an irq queue to |
42 | * queue which holds empty buffers. This design (copied from video-buf) | 41 | * hold empty buffers. This design (copied from video-buf) minimizes locking |
43 | * minimizes locking in interrupt, as only one queue is shared between | 42 | * in interrupt, as only one queue is shared between interrupt and user |
44 | * interrupt and user contexts. | 43 | * contexts. |
45 | * | 44 | * |
46 | * Use cases | 45 | * Use cases |
47 | * --------- | 46 | * --------- |
48 | * | 47 | * |
49 | * Unless stated otherwise, all operations which modify the irq buffers queue | 48 | * Unless stated otherwise, all operations that modify the irq buffers queue |
50 | * are protected by the irq spinlock. | 49 | * are protected by the irq spinlock. |
51 | * | 50 | * |
52 | * 1. The user queues the buffers, starts streaming and dequeues a buffer. | 51 | * 1. The user queues the buffers, starts streaming and dequeues a buffer. |
53 | * | 52 | * |
54 | * The buffers are added to the main and irq queues. Both operations are | 53 | * The buffers are added to the main and irq queues. Both operations are |
55 | * protected by the queue lock, and the latert is protected by the irq | 54 | * protected by the queue lock, and the later is protected by the irq |
56 | * spinlock as well. | 55 | * spinlock as well. |
57 | * | 56 | * |
58 | * The completion handler fetches a buffer from the irq queue and fills it | 57 | * The completion handler fetches a buffer from the irq queue and fills it |
@@ -60,7 +59,7 @@ | |||
60 | * returns immediately. | 59 | * returns immediately. |
61 | * | 60 | * |
62 | * When the buffer is full, the completion handler removes it from the irq | 61 | * When the buffer is full, the completion handler removes it from the irq |
63 | * queue, marks it as ready (UVC_BUF_STATE_DONE) and wake its wait queue. | 62 | * queue, marks it as ready (UVC_BUF_STATE_DONE) and wakes its wait queue. |
64 | * At that point, any process waiting on the buffer will be woken up. If a | 63 | * At that point, any process waiting on the buffer will be woken up. If a |
65 | * process tries to dequeue a buffer after it has been marked ready, the | 64 | * process tries to dequeue a buffer after it has been marked ready, the |
66 | * dequeing will succeed immediately. | 65 | * dequeing will succeed immediately. |
@@ -91,8 +90,8 @@ void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type) | |||
91 | /* | 90 | /* |
92 | * Allocate the video buffers. | 91 | * Allocate the video buffers. |
93 | * | 92 | * |
94 | * Pages are reserved to make sure they will not be swaped, as they will be | 93 | * Pages are reserved to make sure they will not be swapped, as they will be |
95 | * filled in URB completion handler. | 94 | * filled in the URB completion handler. |
96 | * | 95 | * |
97 | * Buffers will be individually mapped, so they must all be page aligned. | 96 | * Buffers will be individually mapped, so they must all be page aligned. |
98 | */ | 97 | */ |
@@ -210,8 +209,8 @@ int uvc_query_buffer(struct uvc_video_queue *queue, | |||
210 | __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf); | 209 | __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf); |
211 | 210 | ||
212 | done: | 211 | done: |
213 | mutex_unlock(&queue->mutex); | 212 | mutex_unlock(&queue->mutex); |
214 | return ret; | 213 | return ret; |
215 | } | 214 | } |
216 | 215 | ||
217 | /* | 216 | /* |
@@ -236,7 +235,7 @@ int uvc_queue_buffer(struct uvc_video_queue *queue, | |||
236 | } | 235 | } |
237 | 236 | ||
238 | mutex_lock(&queue->mutex); | 237 | mutex_lock(&queue->mutex); |
239 | if (v4l2_buf->index >= queue->count) { | 238 | if (v4l2_buf->index >= queue->count) { |
240 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n"); | 239 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n"); |
241 | ret = -EINVAL; | 240 | ret = -EINVAL; |
242 | goto done; | 241 | goto done; |
@@ -429,7 +428,7 @@ done: | |||
429 | * Cancel the video buffers queue. | 428 | * Cancel the video buffers queue. |
430 | * | 429 | * |
431 | * Cancelling the queue marks all buffers on the irq queue as erroneous, | 430 | * Cancelling the queue marks all buffers on the irq queue as erroneous, |
432 | * wakes them up and remove them from the queue. | 431 | * wakes them up and removes them from the queue. |
433 | * | 432 | * |
434 | * If the disconnect parameter is set, further calls to uvc_queue_buffer will | 433 | * If the disconnect parameter is set, further calls to uvc_queue_buffer will |
435 | * fail with -ENODEV. | 434 | * fail with -ENODEV. |
diff --git a/drivers/media/video/uvc/uvc_status.c b/drivers/media/video/uvc/uvc_status.c index 5d60b264d59a..c1e4ae27c613 100644 --- a/drivers/media/video/uvc/uvc_status.c +++ b/drivers/media/video/uvc/uvc_status.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * uvc_status.c -- USB Video Class driver - Status endpoint | 2 | * uvc_status.c -- USB Video Class driver - Status endpoint |
3 | * | 3 | * |
4 | * Copyright (C) 2007-2008 | 4 | * Copyright (C) 2007-2009 |
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | 5 | * Laurent Pinchart (laurent.pinchart@skynet.be) |
6 | * | 6 | * |
7 | * 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 |
@@ -12,7 +12,6 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/version.h> | ||
16 | #include <linux/input.h> | 15 | #include <linux/input.h> |
17 | #include <linux/usb.h> | 16 | #include <linux/usb.h> |
18 | #include <linux/usb/input.h> | 17 | #include <linux/usb/input.h> |
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c index fa150fff2c10..d681519d0c8a 100644 --- a/drivers/media/video/uvc/uvc_v4l2.c +++ b/drivers/media/video/uvc/uvc_v4l2.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * uvc_v4l2.c -- USB Video Class driver - V4L2 API | 2 | * uvc_v4l2.c -- USB Video Class driver - V4L2 API |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2008 | 4 | * Copyright (C) 2005-2009 |
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | 5 | * Laurent Pinchart (laurent.pinchart@skynet.be) |
6 | * | 6 | * |
7 | * 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 |
@@ -37,7 +37,7 @@ | |||
37 | * must be grouped (for instance the Red Balance, Blue Balance and Do White | 37 | * must be grouped (for instance the Red Balance, Blue Balance and Do White |
38 | * Balance V4L2 controls use the White Balance Component UVC control) or | 38 | * Balance V4L2 controls use the White Balance Component UVC control) or |
39 | * otherwise translated. The approach we take here is to use a translation | 39 | * otherwise translated. The approach we take here is to use a translation |
40 | * table for the controls which can be mapped directly, and handle the others | 40 | * table for the controls that can be mapped directly, and handle the others |
41 | * manually. | 41 | * manually. |
42 | */ | 42 | */ |
43 | static int uvc_v4l2_query_menu(struct uvc_video_device *video, | 43 | static int uvc_v4l2_query_menu(struct uvc_video_device *video, |
@@ -189,7 +189,7 @@ static int uvc_v4l2_try_format(struct uvc_video_device *video, | |||
189 | probe->dwMaxVideoFrameSize = | 189 | probe->dwMaxVideoFrameSize = |
190 | video->streaming->ctrl.dwMaxVideoFrameSize; | 190 | video->streaming->ctrl.dwMaxVideoFrameSize; |
191 | 191 | ||
192 | /* Probe the device */ | 192 | /* Probe the device. */ |
193 | if ((ret = uvc_probe_video(video, probe)) < 0) | 193 | if ((ret = uvc_probe_video(video, probe)) < 0) |
194 | goto done; | 194 | goto done; |
195 | 195 | ||
@@ -354,11 +354,11 @@ static int uvc_v4l2_set_streamparm(struct uvc_video_device *video, | |||
354 | * | 354 | * |
355 | * Each open instance of a UVC device can either be in a privileged or | 355 | * Each open instance of a UVC device can either be in a privileged or |
356 | * unprivileged state. Only a single instance can be in a privileged state at | 356 | * unprivileged state. Only a single instance can be in a privileged state at |
357 | * a given time. Trying to perform an operation which requires privileges will | 357 | * a given time. Trying to perform an operation that requires privileges will |
358 | * automatically acquire the required privileges if possible, or return -EBUSY | 358 | * automatically acquire the required privileges if possible, or return -EBUSY |
359 | * otherwise. Privileges are dismissed when closing the instance. | 359 | * otherwise. Privileges are dismissed when closing the instance. |
360 | * | 360 | * |
361 | * Operations which require privileges are: | 361 | * Operations that require privileges are: |
362 | * | 362 | * |
363 | * - VIDIOC_S_INPUT | 363 | * - VIDIOC_S_INPUT |
364 | * - VIDIOC_S_PARM | 364 | * - VIDIOC_S_PARM |
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c index e7c31995527f..9bc4705be78d 100644 --- a/drivers/media/video/uvc/uvc_video.c +++ b/drivers/media/video/uvc/uvc_video.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * uvc_video.c -- USB Video Class driver - Video handling | 2 | * uvc_video.c -- USB Video Class driver - Video handling |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2008 | 4 | * Copyright (C) 2005-2009 |
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | 5 | * Laurent Pinchart (laurent.pinchart@skynet.be) |
6 | * | 6 | * |
7 | * 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 |
@@ -12,7 +12,6 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/version.h> | ||
16 | #include <linux/list.h> | 15 | #include <linux/list.h> |
17 | #include <linux/module.h> | 16 | #include <linux/module.h> |
18 | #include <linux/usb.h> | 17 | #include <linux/usb.h> |
@@ -115,7 +114,7 @@ static int uvc_get_video_ctrl(struct uvc_video_device *video, | |||
115 | ctrl->wCompQuality = le16_to_cpup((__le16 *)data); | 114 | ctrl->wCompQuality = le16_to_cpup((__le16 *)data); |
116 | ret = 0; | 115 | ret = 0; |
117 | goto out; | 116 | goto out; |
118 | } else if (query == GET_DEF && probe == 1) { | 117 | } else if (query == GET_DEF && probe == 1 && ret != size) { |
119 | /* Many cameras don't support the GET_DEF request on their | 118 | /* Many cameras don't support the GET_DEF request on their |
120 | * video probe control. Warn once and return, the caller will | 119 | * video probe control. Warn once and return, the caller will |
121 | * fall back to GET_CUR. | 120 | * fall back to GET_CUR. |
@@ -160,7 +159,7 @@ static int uvc_get_video_ctrl(struct uvc_video_device *video, | |||
160 | } | 159 | } |
161 | 160 | ||
162 | /* Some broken devices return a null or wrong dwMaxVideoFrameSize. | 161 | /* Some broken devices return a null or wrong dwMaxVideoFrameSize. |
163 | * Try to get the value from the format and frame descriptor. | 162 | * Try to get the value from the format and frame descriptors. |
164 | */ | 163 | */ |
165 | uvc_fixup_buffer_size(video, ctrl); | 164 | uvc_fixup_buffer_size(video, ctrl); |
166 | ret = 0; | 165 | ret = 0; |
@@ -191,9 +190,6 @@ static int uvc_set_video_ctrl(struct uvc_video_device *video, | |||
191 | *(__le16 *)&data[12] = cpu_to_le16(ctrl->wCompQuality); | 190 | *(__le16 *)&data[12] = cpu_to_le16(ctrl->wCompQuality); |
192 | *(__le16 *)&data[14] = cpu_to_le16(ctrl->wCompWindowSize); | 191 | *(__le16 *)&data[14] = cpu_to_le16(ctrl->wCompWindowSize); |
193 | *(__le16 *)&data[16] = cpu_to_le16(ctrl->wDelay); | 192 | *(__le16 *)&data[16] = cpu_to_le16(ctrl->wDelay); |
194 | /* Note: Some of the fields below are not required for IN devices (see | ||
195 | * UVC spec, 4.3.1.1), but we still copy them in case support for OUT | ||
196 | * devices is added in the future. */ | ||
197 | put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]); | 193 | put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]); |
198 | put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]); | 194 | put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]); |
199 | 195 | ||
@@ -400,7 +396,7 @@ static int uvc_video_decode_start(struct uvc_video_device *video, | |||
400 | * | 396 | * |
401 | * Empty buffers (bytesused == 0) don't trigger end of frame detection | 397 | * Empty buffers (bytesused == 0) don't trigger end of frame detection |
402 | * as it doesn't make sense to return an empty buffer. This also | 398 | * as it doesn't make sense to return an empty buffer. This also |
403 | * avoids detecting and of frame conditions at FID toggling if the | 399 | * avoids detecting end of frame conditions at FID toggling if the |
404 | * previous payload had the EOF bit set. | 400 | * previous payload had the EOF bit set. |
405 | */ | 401 | */ |
406 | if (fid != video->last_fid && buf->buf.bytesused != 0) { | 402 | if (fid != video->last_fid && buf->buf.bytesused != 0) { |
@@ -453,6 +449,17 @@ static void uvc_video_decode_end(struct uvc_video_device *video, | |||
453 | } | 449 | } |
454 | } | 450 | } |
455 | 451 | ||
452 | /* Video payload encoding is handled by uvc_video_encode_header() and | ||
453 | * uvc_video_encode_data(). Only bulk transfers are currently supported. | ||
454 | * | ||
455 | * uvc_video_encode_header is called at the start of a payload. It adds header | ||
456 | * data to the transfer buffer and returns the header size. As the only known | ||
457 | * UVC output device transfers a whole frame in a single payload, the EOF bit | ||
458 | * is always set in the header. | ||
459 | * | ||
460 | * uvc_video_encode_data is called for every URB and copies the data from the | ||
461 | * video buffer to the transfer buffer. | ||
462 | */ | ||
456 | static int uvc_video_encode_header(struct uvc_video_device *video, | 463 | static int uvc_video_encode_header(struct uvc_video_device *video, |
457 | struct uvc_buffer *buf, __u8 *data, int len) | 464 | struct uvc_buffer *buf, __u8 *data, int len) |
458 | { | 465 | { |
@@ -953,7 +960,7 @@ int uvc_video_suspend(struct uvc_video_device *video) | |||
953 | } | 960 | } |
954 | 961 | ||
955 | /* | 962 | /* |
956 | * Reconfigure the video interface and restart streaming if it was enable | 963 | * Reconfigure the video interface and restart streaming if it was enabled |
957 | * before suspend. | 964 | * before suspend. |
958 | * | 965 | * |
959 | * If an error occurs, disable the video queue. This will wake all pending | 966 | * If an error occurs, disable the video queue. This will wake all pending |
@@ -985,8 +992,8 @@ int uvc_video_resume(struct uvc_video_device *video) | |||
985 | */ | 992 | */ |
986 | 993 | ||
987 | /* | 994 | /* |
988 | * Initialize the UVC video device by retrieving the default format and | 995 | * Initialize the UVC video device by switching to alternate setting 0 and |
989 | * committing it. | 996 | * retrieve the default format. |
990 | * | 997 | * |
991 | * Some cameras (namely the Fuji Finepix) set the format and frame | 998 | * Some cameras (namely the Fuji Finepix) set the format and frame |
992 | * indexes to zero. The UVC standard doesn't clearly make this a spec | 999 | * indexes to zero. The UVC standard doesn't clearly make this a spec |
@@ -1014,7 +1021,7 @@ int uvc_video_init(struct uvc_video_device *video) | |||
1014 | */ | 1021 | */ |
1015 | usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); | 1022 | usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); |
1016 | 1023 | ||
1017 | /* Some webcams don't suport GET_DEF request on the probe control. We | 1024 | /* Some webcams don't suport GET_DEF requests on the probe control. We |
1018 | * fall back to GET_CUR if GET_DEF fails. | 1025 | * fall back to GET_CUR if GET_DEF fails. |
1019 | */ | 1026 | */ |
1020 | if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_DEF)) < 0 && | 1027 | if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_DEF)) < 0 && |
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h index bcf4361dc1bc..027947ea9b6e 100644 --- a/drivers/media/video/uvc/uvcvideo.h +++ b/drivers/media/video/uvc/uvcvideo.h | |||
@@ -72,149 +72,149 @@ struct uvc_xu_control { | |||
72 | * UVC constants | 72 | * UVC constants |
73 | */ | 73 | */ |
74 | 74 | ||
75 | #define SC_UNDEFINED 0x00 | 75 | #define SC_UNDEFINED 0x00 |
76 | #define SC_VIDEOCONTROL 0x01 | 76 | #define SC_VIDEOCONTROL 0x01 |
77 | #define SC_VIDEOSTREAMING 0x02 | 77 | #define SC_VIDEOSTREAMING 0x02 |
78 | #define SC_VIDEO_INTERFACE_COLLECTION 0x03 | 78 | #define SC_VIDEO_INTERFACE_COLLECTION 0x03 |
79 | 79 | ||
80 | #define PC_PROTOCOL_UNDEFINED 0x00 | 80 | #define PC_PROTOCOL_UNDEFINED 0x00 |
81 | 81 | ||
82 | #define CS_UNDEFINED 0x20 | 82 | #define CS_UNDEFINED 0x20 |
83 | #define CS_DEVICE 0x21 | 83 | #define CS_DEVICE 0x21 |
84 | #define CS_CONFIGURATION 0x22 | 84 | #define CS_CONFIGURATION 0x22 |
85 | #define CS_STRING 0x23 | 85 | #define CS_STRING 0x23 |
86 | #define CS_INTERFACE 0x24 | 86 | #define CS_INTERFACE 0x24 |
87 | #define CS_ENDPOINT 0x25 | 87 | #define CS_ENDPOINT 0x25 |
88 | 88 | ||
89 | /* VideoControl class specific interface descriptor */ | 89 | /* VideoControl class specific interface descriptor */ |
90 | #define VC_DESCRIPTOR_UNDEFINED 0x00 | 90 | #define VC_DESCRIPTOR_UNDEFINED 0x00 |
91 | #define VC_HEADER 0x01 | 91 | #define VC_HEADER 0x01 |
92 | #define VC_INPUT_TERMINAL 0x02 | 92 | #define VC_INPUT_TERMINAL 0x02 |
93 | #define VC_OUTPUT_TERMINAL 0x03 | 93 | #define VC_OUTPUT_TERMINAL 0x03 |
94 | #define VC_SELECTOR_UNIT 0x04 | 94 | #define VC_SELECTOR_UNIT 0x04 |
95 | #define VC_PROCESSING_UNIT 0x05 | 95 | #define VC_PROCESSING_UNIT 0x05 |
96 | #define VC_EXTENSION_UNIT 0x06 | 96 | #define VC_EXTENSION_UNIT 0x06 |
97 | 97 | ||
98 | /* VideoStreaming class specific interface descriptor */ | 98 | /* VideoStreaming class specific interface descriptor */ |
99 | #define VS_UNDEFINED 0x00 | 99 | #define VS_UNDEFINED 0x00 |
100 | #define VS_INPUT_HEADER 0x01 | 100 | #define VS_INPUT_HEADER 0x01 |
101 | #define VS_OUTPUT_HEADER 0x02 | 101 | #define VS_OUTPUT_HEADER 0x02 |
102 | #define VS_STILL_IMAGE_FRAME 0x03 | 102 | #define VS_STILL_IMAGE_FRAME 0x03 |
103 | #define VS_FORMAT_UNCOMPRESSED 0x04 | 103 | #define VS_FORMAT_UNCOMPRESSED 0x04 |
104 | #define VS_FRAME_UNCOMPRESSED 0x05 | 104 | #define VS_FRAME_UNCOMPRESSED 0x05 |
105 | #define VS_FORMAT_MJPEG 0x06 | 105 | #define VS_FORMAT_MJPEG 0x06 |
106 | #define VS_FRAME_MJPEG 0x07 | 106 | #define VS_FRAME_MJPEG 0x07 |
107 | #define VS_FORMAT_MPEG2TS 0x0a | 107 | #define VS_FORMAT_MPEG2TS 0x0a |
108 | #define VS_FORMAT_DV 0x0c | 108 | #define VS_FORMAT_DV 0x0c |
109 | #define VS_COLORFORMAT 0x0d | 109 | #define VS_COLORFORMAT 0x0d |
110 | #define VS_FORMAT_FRAME_BASED 0x10 | 110 | #define VS_FORMAT_FRAME_BASED 0x10 |
111 | #define VS_FRAME_FRAME_BASED 0x11 | 111 | #define VS_FRAME_FRAME_BASED 0x11 |
112 | #define VS_FORMAT_STREAM_BASED 0x12 | 112 | #define VS_FORMAT_STREAM_BASED 0x12 |
113 | 113 | ||
114 | /* Endpoint type */ | 114 | /* Endpoint type */ |
115 | #define EP_UNDEFINED 0x00 | 115 | #define EP_UNDEFINED 0x00 |
116 | #define EP_GENERAL 0x01 | 116 | #define EP_GENERAL 0x01 |
117 | #define EP_ENDPOINT 0x02 | 117 | #define EP_ENDPOINT 0x02 |
118 | #define EP_INTERRUPT 0x03 | 118 | #define EP_INTERRUPT 0x03 |
119 | 119 | ||
120 | /* Request codes */ | 120 | /* Request codes */ |
121 | #define RC_UNDEFINED 0x00 | 121 | #define RC_UNDEFINED 0x00 |
122 | #define SET_CUR 0x01 | 122 | #define SET_CUR 0x01 |
123 | #define GET_CUR 0x81 | 123 | #define GET_CUR 0x81 |
124 | #define GET_MIN 0x82 | 124 | #define GET_MIN 0x82 |
125 | #define GET_MAX 0x83 | 125 | #define GET_MAX 0x83 |
126 | #define GET_RES 0x84 | 126 | #define GET_RES 0x84 |
127 | #define GET_LEN 0x85 | 127 | #define GET_LEN 0x85 |
128 | #define GET_INFO 0x86 | 128 | #define GET_INFO 0x86 |
129 | #define GET_DEF 0x87 | 129 | #define GET_DEF 0x87 |
130 | 130 | ||
131 | /* VideoControl interface controls */ | 131 | /* VideoControl interface controls */ |
132 | #define VC_CONTROL_UNDEFINED 0x00 | 132 | #define VC_CONTROL_UNDEFINED 0x00 |
133 | #define VC_VIDEO_POWER_MODE_CONTROL 0x01 | 133 | #define VC_VIDEO_POWER_MODE_CONTROL 0x01 |
134 | #define VC_REQUEST_ERROR_CODE_CONTROL 0x02 | 134 | #define VC_REQUEST_ERROR_CODE_CONTROL 0x02 |
135 | 135 | ||
136 | /* Terminal controls */ | 136 | /* Terminal controls */ |
137 | #define TE_CONTROL_UNDEFINED 0x00 | 137 | #define TE_CONTROL_UNDEFINED 0x00 |
138 | 138 | ||
139 | /* Selector Unit controls */ | 139 | /* Selector Unit controls */ |
140 | #define SU_CONTROL_UNDEFINED 0x00 | 140 | #define SU_CONTROL_UNDEFINED 0x00 |
141 | #define SU_INPUT_SELECT_CONTROL 0x01 | 141 | #define SU_INPUT_SELECT_CONTROL 0x01 |
142 | 142 | ||
143 | /* Camera Terminal controls */ | 143 | /* Camera Terminal controls */ |
144 | #define CT_CONTROL_UNDEFINED 0x00 | 144 | #define CT_CONTROL_UNDEFINED 0x00 |
145 | #define CT_SCANNING_MODE_CONTROL 0x01 | 145 | #define CT_SCANNING_MODE_CONTROL 0x01 |
146 | #define CT_AE_MODE_CONTROL 0x02 | 146 | #define CT_AE_MODE_CONTROL 0x02 |
147 | #define CT_AE_PRIORITY_CONTROL 0x03 | 147 | #define CT_AE_PRIORITY_CONTROL 0x03 |
148 | #define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04 | 148 | #define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04 |
149 | #define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05 | 149 | #define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05 |
150 | #define CT_FOCUS_ABSOLUTE_CONTROL 0x06 | 150 | #define CT_FOCUS_ABSOLUTE_CONTROL 0x06 |
151 | #define CT_FOCUS_RELATIVE_CONTROL 0x07 | 151 | #define CT_FOCUS_RELATIVE_CONTROL 0x07 |
152 | #define CT_FOCUS_AUTO_CONTROL 0x08 | 152 | #define CT_FOCUS_AUTO_CONTROL 0x08 |
153 | #define CT_IRIS_ABSOLUTE_CONTROL 0x09 | 153 | #define CT_IRIS_ABSOLUTE_CONTROL 0x09 |
154 | #define CT_IRIS_RELATIVE_CONTROL 0x0a | 154 | #define CT_IRIS_RELATIVE_CONTROL 0x0a |
155 | #define CT_ZOOM_ABSOLUTE_CONTROL 0x0b | 155 | #define CT_ZOOM_ABSOLUTE_CONTROL 0x0b |
156 | #define CT_ZOOM_RELATIVE_CONTROL 0x0c | 156 | #define CT_ZOOM_RELATIVE_CONTROL 0x0c |
157 | #define CT_PANTILT_ABSOLUTE_CONTROL 0x0d | 157 | #define CT_PANTILT_ABSOLUTE_CONTROL 0x0d |
158 | #define CT_PANTILT_RELATIVE_CONTROL 0x0e | 158 | #define CT_PANTILT_RELATIVE_CONTROL 0x0e |
159 | #define CT_ROLL_ABSOLUTE_CONTROL 0x0f | 159 | #define CT_ROLL_ABSOLUTE_CONTROL 0x0f |
160 | #define CT_ROLL_RELATIVE_CONTROL 0x10 | 160 | #define CT_ROLL_RELATIVE_CONTROL 0x10 |
161 | #define CT_PRIVACY_CONTROL 0x11 | 161 | #define CT_PRIVACY_CONTROL 0x11 |
162 | 162 | ||
163 | /* Processing Unit controls */ | 163 | /* Processing Unit controls */ |
164 | #define PU_CONTROL_UNDEFINED 0x00 | 164 | #define PU_CONTROL_UNDEFINED 0x00 |
165 | #define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01 | 165 | #define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01 |
166 | #define PU_BRIGHTNESS_CONTROL 0x02 | 166 | #define PU_BRIGHTNESS_CONTROL 0x02 |
167 | #define PU_CONTRAST_CONTROL 0x03 | 167 | #define PU_CONTRAST_CONTROL 0x03 |
168 | #define PU_GAIN_CONTROL 0x04 | 168 | #define PU_GAIN_CONTROL 0x04 |
169 | #define PU_POWER_LINE_FREQUENCY_CONTROL 0x05 | 169 | #define PU_POWER_LINE_FREQUENCY_CONTROL 0x05 |
170 | #define PU_HUE_CONTROL 0x06 | 170 | #define PU_HUE_CONTROL 0x06 |
171 | #define PU_SATURATION_CONTROL 0x07 | 171 | #define PU_SATURATION_CONTROL 0x07 |
172 | #define PU_SHARPNESS_CONTROL 0x08 | 172 | #define PU_SHARPNESS_CONTROL 0x08 |
173 | #define PU_GAMMA_CONTROL 0x09 | 173 | #define PU_GAMMA_CONTROL 0x09 |
174 | #define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a | 174 | #define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a |
175 | #define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b | 175 | #define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b |
176 | #define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c | 176 | #define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c |
177 | #define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d | 177 | #define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d |
178 | #define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e | 178 | #define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e |
179 | #define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f | 179 | #define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f |
180 | #define PU_HUE_AUTO_CONTROL 0x10 | 180 | #define PU_HUE_AUTO_CONTROL 0x10 |
181 | #define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 | 181 | #define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 |
182 | #define PU_ANALOG_LOCK_STATUS_CONTROL 0x12 | 182 | #define PU_ANALOG_LOCK_STATUS_CONTROL 0x12 |
183 | 183 | ||
184 | #define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01 | 184 | #define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01 |
185 | #define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02 | 185 | #define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02 |
186 | #define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03 | 186 | #define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03 |
187 | 187 | ||
188 | /* VideoStreaming interface controls */ | 188 | /* VideoStreaming interface controls */ |
189 | #define VS_CONTROL_UNDEFINED 0x00 | 189 | #define VS_CONTROL_UNDEFINED 0x00 |
190 | #define VS_PROBE_CONTROL 0x01 | 190 | #define VS_PROBE_CONTROL 0x01 |
191 | #define VS_COMMIT_CONTROL 0x02 | 191 | #define VS_COMMIT_CONTROL 0x02 |
192 | #define VS_STILL_PROBE_CONTROL 0x03 | 192 | #define VS_STILL_PROBE_CONTROL 0x03 |
193 | #define VS_STILL_COMMIT_CONTROL 0x04 | 193 | #define VS_STILL_COMMIT_CONTROL 0x04 |
194 | #define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05 | 194 | #define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05 |
195 | #define VS_STREAM_ERROR_CODE_CONTROL 0x06 | 195 | #define VS_STREAM_ERROR_CODE_CONTROL 0x06 |
196 | #define VS_GENERATE_KEY_FRAME_CONTROL 0x07 | 196 | #define VS_GENERATE_KEY_FRAME_CONTROL 0x07 |
197 | #define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08 | 197 | #define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08 |
198 | #define VS_SYNC_DELAY_CONTROL 0x09 | 198 | #define VS_SYNC_DELAY_CONTROL 0x09 |
199 | 199 | ||
200 | #define TT_VENDOR_SPECIFIC 0x0100 | 200 | #define TT_VENDOR_SPECIFIC 0x0100 |
201 | #define TT_STREAMING 0x0101 | 201 | #define TT_STREAMING 0x0101 |
202 | 202 | ||
203 | /* Input Terminal types */ | 203 | /* Input Terminal types */ |
204 | #define ITT_VENDOR_SPECIFIC 0x0200 | 204 | #define ITT_VENDOR_SPECIFIC 0x0200 |
205 | #define ITT_CAMERA 0x0201 | 205 | #define ITT_CAMERA 0x0201 |
206 | #define ITT_MEDIA_TRANSPORT_INPUT 0x0202 | 206 | #define ITT_MEDIA_TRANSPORT_INPUT 0x0202 |
207 | 207 | ||
208 | /* Output Terminal types */ | 208 | /* Output Terminal types */ |
209 | #define OTT_VENDOR_SPECIFIC 0x0300 | 209 | #define OTT_VENDOR_SPECIFIC 0x0300 |
210 | #define OTT_DISPLAY 0x0301 | 210 | #define OTT_DISPLAY 0x0301 |
211 | #define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302 | 211 | #define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302 |
212 | 212 | ||
213 | /* External Terminal types */ | 213 | /* External Terminal types */ |
214 | #define EXTERNAL_VENDOR_SPECIFIC 0x0400 | 214 | #define EXTERNAL_VENDOR_SPECIFIC 0x0400 |
215 | #define COMPOSITE_CONNECTOR 0x0401 | 215 | #define COMPOSITE_CONNECTOR 0x0401 |
216 | #define SVIDEO_CONNECTOR 0x0402 | 216 | #define SVIDEO_CONNECTOR 0x0402 |
217 | #define COMPONENT_CONNECTOR 0x0403 | 217 | #define COMPONENT_CONNECTOR 0x0403 |
218 | 218 | ||
219 | #define UVC_TERM_INPUT 0x0000 | 219 | #define UVC_TERM_INPUT 0x0000 |
220 | #define UVC_TERM_OUTPUT 0x8000 | 220 | #define UVC_TERM_OUTPUT 0x8000 |
@@ -541,11 +541,11 @@ struct uvc_streaming { | |||
541 | }; | 541 | }; |
542 | 542 | ||
543 | enum uvc_buffer_state { | 543 | enum uvc_buffer_state { |
544 | UVC_BUF_STATE_IDLE = 0, | 544 | UVC_BUF_STATE_IDLE = 0, |
545 | UVC_BUF_STATE_QUEUED = 1, | 545 | UVC_BUF_STATE_QUEUED = 1, |
546 | UVC_BUF_STATE_ACTIVE = 2, | 546 | UVC_BUF_STATE_ACTIVE = 2, |
547 | UVC_BUF_STATE_DONE = 3, | 547 | UVC_BUF_STATE_DONE = 3, |
548 | UVC_BUF_STATE_ERROR = 4, | 548 | UVC_BUF_STATE_ERROR = 4, |
549 | }; | 549 | }; |
550 | 550 | ||
551 | struct uvc_buffer { | 551 | struct uvc_buffer { |
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c index fbe9cc0d433a..21208805ea9b 100644 --- a/drivers/media/video/v4l2-subdev.c +++ b/drivers/media/video/v4l2-subdev.c | |||
@@ -28,13 +28,13 @@ int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg) | |||
28 | { | 28 | { |
29 | switch (cmd) { | 29 | switch (cmd) { |
30 | case VIDIOC_QUERYCTRL: | 30 | case VIDIOC_QUERYCTRL: |
31 | return v4l2_subdev_call(sd, core, querymenu, arg); | 31 | return v4l2_subdev_call(sd, core, queryctrl, arg); |
32 | case VIDIOC_G_CTRL: | 32 | case VIDIOC_G_CTRL: |
33 | return v4l2_subdev_call(sd, core, g_ctrl, arg); | 33 | return v4l2_subdev_call(sd, core, g_ctrl, arg); |
34 | case VIDIOC_S_CTRL: | 34 | case VIDIOC_S_CTRL: |
35 | return v4l2_subdev_call(sd, core, s_ctrl, arg); | 35 | return v4l2_subdev_call(sd, core, s_ctrl, arg); |
36 | case VIDIOC_QUERYMENU: | 36 | case VIDIOC_QUERYMENU: |
37 | return v4l2_subdev_call(sd, core, queryctrl, arg); | 37 | return v4l2_subdev_call(sd, core, querymenu, arg); |
38 | case VIDIOC_LOG_STATUS: | 38 | case VIDIOC_LOG_STATUS: |
39 | return v4l2_subdev_call(sd, core, log_status); | 39 | return v4l2_subdev_call(sd, core, log_status); |
40 | case VIDIOC_DBG_G_CHIP_IDENT: | 40 | case VIDIOC_DBG_G_CHIP_IDENT: |
diff --git a/drivers/media/video/zoran/zoran.h b/drivers/media/video/zoran/zoran.h index 46b7ad477ceb..e873a916250f 100644 --- a/drivers/media/video/zoran/zoran.h +++ b/drivers/media/video/zoran/zoran.h | |||
@@ -349,7 +349,6 @@ struct card_info { | |||
349 | u16 i2c_decoder, i2c_encoder; /* I2C types */ | 349 | u16 i2c_decoder, i2c_encoder; /* I2C types */ |
350 | u16 video_vfe, video_codec; /* videocodec types */ | 350 | u16 video_vfe, video_codec; /* videocodec types */ |
351 | u16 audio_chip; /* audio type */ | 351 | u16 audio_chip; /* audio type */ |
352 | u16 vendor_id, device_id; /* subsystem vendor/device ID */ | ||
353 | 352 | ||
354 | int inputs; /* number of video inputs */ | 353 | int inputs; /* number of video inputs */ |
355 | struct input { | 354 | struct input { |
@@ -401,7 +400,6 @@ struct zoran { | |||
401 | char name[32]; /* name of this device */ | 400 | char name[32]; /* name of this device */ |
402 | struct pci_dev *pci_dev; /* PCI device */ | 401 | struct pci_dev *pci_dev; /* PCI device */ |
403 | unsigned char revision; /* revision of zr36057 */ | 402 | unsigned char revision; /* revision of zr36057 */ |
404 | unsigned int zr36057_adr; /* bus address of IO mem returned by PCI BIOS */ | ||
405 | unsigned char __iomem *zr36057_mem;/* pointer to mapped IO memory */ | 403 | unsigned char __iomem *zr36057_mem;/* pointer to mapped IO memory */ |
406 | 404 | ||
407 | spinlock_t spinlock; /* Spinlock */ | 405 | spinlock_t spinlock; /* Spinlock */ |
@@ -490,16 +488,10 @@ struct zoran { | |||
490 | wait_queue_head_t test_q; | 488 | wait_queue_head_t test_q; |
491 | }; | 489 | }; |
492 | 490 | ||
493 | /*The following should be done in more portable way. It depends on define | 491 | /* There was something called _ALPHA_BUZ that used the PCI address instead of |
494 | of _ALPHA_BUZ in the Makefile.*/ | 492 | * the kernel iomapped address for btread/btwrite. */ |
495 | |||
496 | #ifdef _ALPHA_BUZ | ||
497 | #define btwrite(dat,adr) writel((dat), zr->zr36057_adr+(adr)) | ||
498 | #define btread(adr) readl(zr->zr36057_adr+(adr)) | ||
499 | #else | ||
500 | #define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr)) | 493 | #define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr)) |
501 | #define btread(adr) readl(zr->zr36057_mem+(adr)) | 494 | #define btread(adr) readl(zr->zr36057_mem+(adr)) |
502 | #endif | ||
503 | 495 | ||
504 | #define btand(dat,adr) btwrite((dat) & btread(adr), adr) | 496 | #define btand(dat,adr) btwrite((dat) & btread(adr), adr) |
505 | #define btor(dat,adr) btwrite((dat) | btread(adr), adr) | 497 | #define btor(dat,adr) btwrite((dat) | btread(adr), adr) |
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c index 05f39195372e..5d2f090aa0f8 100644 --- a/drivers/media/video/zoran/zoran_card.c +++ b/drivers/media/video/zoran/zoran_card.c | |||
@@ -61,17 +61,17 @@ | |||
61 | 61 | ||
62 | extern const struct zoran_format zoran_formats[]; | 62 | extern const struct zoran_format zoran_formats[]; |
63 | 63 | ||
64 | static int card[BUZ_MAX] = { -1, -1, -1, -1 }; | 64 | static int card[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 }; |
65 | module_param_array(card, int, NULL, 0444); | 65 | module_param_array(card, int, NULL, 0444); |
66 | MODULE_PARM_DESC(card, "The type of card"); | 66 | MODULE_PARM_DESC(card, "Card type"); |
67 | 67 | ||
68 | static int encoder[BUZ_MAX] = { -1, -1, -1, -1 }; | 68 | static int encoder[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 }; |
69 | module_param_array(encoder, int, NULL, 0444); | 69 | module_param_array(encoder, int, NULL, 0444); |
70 | MODULE_PARM_DESC(encoder, "i2c TV encoder"); | 70 | MODULE_PARM_DESC(encoder, "Video encoder chip"); |
71 | 71 | ||
72 | static int decoder[BUZ_MAX] = { -1, -1, -1, -1 }; | 72 | static int decoder[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 }; |
73 | module_param_array(decoder, int, NULL, 0444); | 73 | module_param_array(decoder, int, NULL, 0444); |
74 | MODULE_PARM_DESC(decoder, "i2c TV decoder"); | 74 | MODULE_PARM_DESC(decoder, "Video decoder chip"); |
75 | 75 | ||
76 | /* | 76 | /* |
77 | The video mem address of the video card. | 77 | The video mem address of the video card. |
@@ -104,9 +104,9 @@ module_param(default_norm, int, 0444); | |||
104 | MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)"); | 104 | MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)"); |
105 | 105 | ||
106 | /* /dev/videoN, -1 for autodetect */ | 106 | /* /dev/videoN, -1 for autodetect */ |
107 | static int video_nr[BUZ_MAX] = {-1, -1, -1, -1}; | 107 | static int video_nr[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 }; |
108 | module_param_array(video_nr, int, NULL, 0444); | 108 | module_param_array(video_nr, int, NULL, 0444); |
109 | MODULE_PARM_DESC(video_nr, "video device number (-1=Auto)"); | 109 | MODULE_PARM_DESC(video_nr, "Video device number (-1=Auto)"); |
110 | 110 | ||
111 | /* | 111 | /* |
112 | Number and size of grab buffers for Video 4 Linux | 112 | Number and size of grab buffers for Video 4 Linux |
@@ -153,9 +153,21 @@ MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver"); | |||
153 | MODULE_AUTHOR("Serguei Miridonov"); | 153 | MODULE_AUTHOR("Serguei Miridonov"); |
154 | MODULE_LICENSE("GPL"); | 154 | MODULE_LICENSE("GPL"); |
155 | 155 | ||
156 | #define ZR_DEVICE(subven, subdev, data) { \ | ||
157 | .vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \ | ||
158 | .subvendor = (subven), .subdevice = (subdev), .driver_data = (data) } | ||
159 | |||
160 | static struct pci_device_id zr36067_pci_tbl[] = { | ||
161 | ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus), | ||
162 | ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus), | ||
163 | ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, LML33R10), | ||
164 | ZR_DEVICE(PCI_VENDOR_ID_IOMEGA, PCI_DEVICE_ID_IOMEGA_BUZ, BUZ), | ||
165 | ZR_DEVICE(PCI_ANY_ID, PCI_ANY_ID, NUM_CARDS), | ||
166 | {0} | ||
167 | }; | ||
168 | MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl); | ||
156 | 169 | ||
157 | int zoran_num; /* number of Buzs in use */ | 170 | static unsigned int zoran_num; /* number of cards found */ |
158 | struct zoran *zoran[BUZ_MAX]; | ||
159 | 171 | ||
160 | /* videocodec bus functions ZR36060 */ | 172 | /* videocodec bus functions ZR36060 */ |
161 | static u32 | 173 | static u32 |
@@ -472,8 +484,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
472 | }, { | 484 | }, { |
473 | .type = DC10plus, | 485 | .type = DC10plus, |
474 | .name = "DC10plus", | 486 | .name = "DC10plus", |
475 | .vendor_id = PCI_VENDOR_ID_MIRO, | ||
476 | .device_id = PCI_DEVICE_ID_MIRO_DC10PLUS, | ||
477 | .i2c_decoder = I2C_DRIVERID_SAA7110, | 487 | .i2c_decoder = I2C_DRIVERID_SAA7110, |
478 | .i2c_encoder = I2C_DRIVERID_ADV7175, | 488 | .i2c_encoder = I2C_DRIVERID_ADV7175, |
479 | .video_codec = CODEC_TYPE_ZR36060, | 489 | .video_codec = CODEC_TYPE_ZR36060, |
@@ -531,8 +541,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
531 | }, { | 541 | }, { |
532 | .type = DC30plus, | 542 | .type = DC30plus, |
533 | .name = "DC30plus", | 543 | .name = "DC30plus", |
534 | .vendor_id = PCI_VENDOR_ID_MIRO, | ||
535 | .device_id = PCI_DEVICE_ID_MIRO_DC30PLUS, | ||
536 | .i2c_decoder = I2C_DRIVERID_VPX3220, | 544 | .i2c_decoder = I2C_DRIVERID_VPX3220, |
537 | .i2c_encoder = I2C_DRIVERID_ADV7175, | 545 | .i2c_encoder = I2C_DRIVERID_ADV7175, |
538 | .video_codec = CODEC_TYPE_ZR36050, | 546 | .video_codec = CODEC_TYPE_ZR36050, |
@@ -589,8 +597,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
589 | }, { | 597 | }, { |
590 | .type = LML33R10, | 598 | .type = LML33R10, |
591 | .name = "LML33R10", | 599 | .name = "LML33R10", |
592 | .vendor_id = PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, | ||
593 | .device_id = PCI_DEVICE_ID_LML_33R10, | ||
594 | .i2c_decoder = I2C_DRIVERID_SAA7114, | 600 | .i2c_decoder = I2C_DRIVERID_SAA7114, |
595 | .i2c_encoder = I2C_DRIVERID_ADV7170, | 601 | .i2c_encoder = I2C_DRIVERID_ADV7170, |
596 | .video_codec = CODEC_TYPE_ZR36060, | 602 | .video_codec = CODEC_TYPE_ZR36060, |
@@ -618,8 +624,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
618 | }, { | 624 | }, { |
619 | .type = BUZ, | 625 | .type = BUZ, |
620 | .name = "Buz", | 626 | .name = "Buz", |
621 | .vendor_id = PCI_VENDOR_ID_IOMEGA, | ||
622 | .device_id = PCI_DEVICE_ID_IOMEGA_BUZ, | ||
623 | .i2c_decoder = I2C_DRIVERID_SAA7111A, | 627 | .i2c_decoder = I2C_DRIVERID_SAA7111A, |
624 | .i2c_encoder = I2C_DRIVERID_SAA7185B, | 628 | .i2c_encoder = I2C_DRIVERID_SAA7185B, |
625 | .video_codec = CODEC_TYPE_ZR36060, | 629 | .video_codec = CODEC_TYPE_ZR36060, |
@@ -649,8 +653,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
649 | .name = "6-Eyes", | 653 | .name = "6-Eyes", |
650 | /* AverMedia chose not to brand the 6-Eyes. Thus it | 654 | /* AverMedia chose not to brand the 6-Eyes. Thus it |
651 | can't be autodetected, and requires card=x. */ | 655 | can't be autodetected, and requires card=x. */ |
652 | .vendor_id = -1, | ||
653 | .device_id = -1, | ||
654 | .i2c_decoder = I2C_DRIVERID_KS0127, | 656 | .i2c_decoder = I2C_DRIVERID_KS0127, |
655 | .i2c_encoder = I2C_DRIVERID_BT866, | 657 | .i2c_encoder = I2C_DRIVERID_BT866, |
656 | .video_codec = CODEC_TYPE_ZR36060, | 658 | .video_codec = CODEC_TYPE_ZR36060, |
@@ -1138,7 +1140,8 @@ zr36057_init (struct zoran *zr) | |||
1138 | strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); | 1140 | strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); |
1139 | err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr[zr->id]); | 1141 | err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr[zr->id]); |
1140 | if (err < 0) | 1142 | if (err < 0) |
1141 | goto exit_unregister; | 1143 | goto exit_free; |
1144 | video_set_drvdata(zr->video_dev, zr); | ||
1142 | 1145 | ||
1143 | zoran_init_hardware(zr); | 1146 | zoran_init_hardware(zr); |
1144 | if (zr36067_debug > 2) | 1147 | if (zr36067_debug > 2) |
@@ -1153,19 +1156,19 @@ zr36057_init (struct zoran *zr) | |||
1153 | zr->initialized = 1; | 1156 | zr->initialized = 1; |
1154 | return 0; | 1157 | return 0; |
1155 | 1158 | ||
1156 | exit_unregister: | ||
1157 | zoran_unregister_i2c(zr); | ||
1158 | exit_free: | 1159 | exit_free: |
1159 | kfree(zr->stat_com); | 1160 | kfree(zr->stat_com); |
1160 | kfree(zr->video_dev); | 1161 | kfree(zr->video_dev); |
1161 | return err; | 1162 | return err; |
1162 | } | 1163 | } |
1163 | 1164 | ||
1164 | static void | 1165 | static void __devexit zoran_remove(struct pci_dev *pdev) |
1165 | zoran_release (struct zoran *zr) | ||
1166 | { | 1166 | { |
1167 | struct zoran *zr = pci_get_drvdata(pdev); | ||
1168 | |||
1167 | if (!zr->initialized) | 1169 | if (!zr->initialized) |
1168 | goto exit_free; | 1170 | goto exit_free; |
1171 | |||
1169 | /* unregister videocodec bus */ | 1172 | /* unregister videocodec bus */ |
1170 | if (zr->codec) { | 1173 | if (zr->codec) { |
1171 | struct videocodec_master *master = zr->codec->master_data; | 1174 | struct videocodec_master *master = zr->codec->master_data; |
@@ -1194,6 +1197,7 @@ zoran_release (struct zoran *zr) | |||
1194 | pci_disable_device(zr->pci_dev); | 1197 | pci_disable_device(zr->pci_dev); |
1195 | video_unregister_device(zr->video_dev); | 1198 | video_unregister_device(zr->video_dev); |
1196 | exit_free: | 1199 | exit_free: |
1200 | pci_set_drvdata(pdev, NULL); | ||
1197 | kfree(zr); | 1201 | kfree(zr); |
1198 | } | 1202 | } |
1199 | 1203 | ||
@@ -1256,338 +1260,329 @@ zoran_setup_videocodec (struct zoran *zr, | |||
1256 | * Scan for a Buz card (actually for the PCI controller ZR36057), | 1260 | * Scan for a Buz card (actually for the PCI controller ZR36057), |
1257 | * request the irq and map the io memory | 1261 | * request the irq and map the io memory |
1258 | */ | 1262 | */ |
1259 | static int __devinit | 1263 | static int __devinit zoran_probe(struct pci_dev *pdev, |
1260 | find_zr36057 (void) | 1264 | const struct pci_device_id *ent) |
1261 | { | 1265 | { |
1262 | unsigned char latency, need_latency; | 1266 | unsigned char latency, need_latency; |
1263 | struct zoran *zr; | 1267 | struct zoran *zr; |
1264 | struct pci_dev *dev = NULL; | ||
1265 | int result; | 1268 | int result; |
1266 | struct videocodec_master *master_vfe = NULL; | 1269 | struct videocodec_master *master_vfe = NULL; |
1267 | struct videocodec_master *master_codec = NULL; | 1270 | struct videocodec_master *master_codec = NULL; |
1268 | int card_num; | 1271 | int card_num; |
1269 | char *i2c_enc_name, *i2c_dec_name, *codec_name, *vfe_name; | 1272 | char *i2c_enc_name, *i2c_dec_name, *codec_name, *vfe_name; |
1273 | unsigned int nr; | ||
1270 | 1274 | ||
1271 | zoran_num = 0; | ||
1272 | while (zoran_num < BUZ_MAX && | ||
1273 | (dev = pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) { | ||
1274 | card_num = card[zoran_num]; | ||
1275 | zr = kzalloc(sizeof(struct zoran), GFP_KERNEL); | ||
1276 | if (!zr) { | ||
1277 | dprintk(1, | ||
1278 | KERN_ERR | ||
1279 | "%s: find_zr36057() - kzalloc failed\n", | ||
1280 | ZORAN_NAME); | ||
1281 | continue; | ||
1282 | } | ||
1283 | zr->pci_dev = dev; | ||
1284 | //zr->zr36057_mem = NULL; | ||
1285 | zr->id = zoran_num; | ||
1286 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); | ||
1287 | spin_lock_init(&zr->spinlock); | ||
1288 | mutex_init(&zr->resource_lock); | ||
1289 | if (pci_enable_device(dev)) | ||
1290 | goto zr_free_mem; | ||
1291 | zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); | ||
1292 | pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, | ||
1293 | &zr->revision); | ||
1294 | if (zr->revision < 2) { | ||
1295 | dprintk(1, | ||
1296 | KERN_INFO | ||
1297 | "%s: Zoran ZR36057 (rev %d) irq: %d, memory: 0x%08x.\n", | ||
1298 | ZR_DEVNAME(zr), zr->revision, zr->pci_dev->irq, | ||
1299 | zr->zr36057_adr); | ||
1300 | 1275 | ||
1301 | if (card_num == -1) { | 1276 | nr = zoran_num++; |
1302 | dprintk(1, | 1277 | if (nr >= BUZ_MAX) { |
1303 | KERN_ERR | 1278 | dprintk(1, |
1304 | "%s: find_zr36057() - no card specified, please use the card=X insmod option\n", | 1279 | KERN_ERR |
1305 | ZR_DEVNAME(zr)); | 1280 | "%s: driver limited to %d card(s) maximum\n", |
1306 | goto zr_free_mem; | 1281 | ZORAN_NAME, BUZ_MAX); |
1307 | } | 1282 | return -ENOENT; |
1308 | } else { | 1283 | } |
1309 | int i; | ||
1310 | unsigned short ss_vendor, ss_device; | ||
1311 | 1284 | ||
1312 | ss_vendor = zr->pci_dev->subsystem_vendor; | 1285 | zr = kzalloc(sizeof(struct zoran), GFP_KERNEL); |
1313 | ss_device = zr->pci_dev->subsystem_device; | 1286 | if (!zr) { |
1287 | dprintk(1, | ||
1288 | KERN_ERR | ||
1289 | "%s: find_zr36057() - kzalloc failed\n", | ||
1290 | ZORAN_NAME); | ||
1291 | return -ENOMEM; | ||
1292 | } | ||
1293 | zr->pci_dev = pdev; | ||
1294 | zr->id = nr; | ||
1295 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); | ||
1296 | spin_lock_init(&zr->spinlock); | ||
1297 | mutex_init(&zr->resource_lock); | ||
1298 | if (pci_enable_device(pdev)) | ||
1299 | goto zr_free_mem; | ||
1300 | pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, &zr->revision); | ||
1301 | |||
1302 | dprintk(1, | ||
1303 | KERN_INFO | ||
1304 | "%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n", | ||
1305 | ZR_DEVNAME(zr), zr->revision < 2 ? '5' : '6', zr->revision, | ||
1306 | zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0)); | ||
1307 | if (zr->revision >= 2) { | ||
1308 | dprintk(1, | ||
1309 | KERN_INFO | ||
1310 | "%s: Subsystem vendor=0x%04x id=0x%04x\n", | ||
1311 | ZR_DEVNAME(zr), zr->pci_dev->subsystem_vendor, | ||
1312 | zr->pci_dev->subsystem_device); | ||
1313 | } | ||
1314 | |||
1315 | /* Use auto-detected card type? */ | ||
1316 | if (card[nr] == -1) { | ||
1317 | if (zr->revision < 2) { | ||
1314 | dprintk(1, | 1318 | dprintk(1, |
1315 | KERN_INFO | 1319 | KERN_ERR |
1316 | "%s: Zoran ZR36067 (rev %d) irq: %d, memory: 0x%08x\n", | 1320 | "%s: No card type specified, please use the card=X module parameter\n", |
1317 | ZR_DEVNAME(zr), zr->revision, zr->pci_dev->irq, | 1321 | ZR_DEVNAME(zr)); |
1318 | zr->zr36057_adr); | ||
1319 | dprintk(1, | 1322 | dprintk(1, |
1320 | KERN_INFO | ||
1321 | "%s: subsystem vendor=0x%04x id=0x%04x\n", | ||
1322 | ZR_DEVNAME(zr), ss_vendor, ss_device); | ||
1323 | if (card_num == -1) { | ||
1324 | dprintk(3, | ||
1325 | KERN_DEBUG | ||
1326 | "%s: find_zr36057() - trying to autodetect card type\n", | ||
1327 | ZR_DEVNAME(zr)); | ||
1328 | for (i=0;i<NUM_CARDS;i++) { | ||
1329 | if (ss_vendor == zoran_cards[i].vendor_id && | ||
1330 | ss_device == zoran_cards[i].device_id) { | ||
1331 | dprintk(3, | ||
1332 | KERN_DEBUG | ||
1333 | "%s: find_zr36057() - card %s detected\n", | ||
1334 | ZR_DEVNAME(zr), | ||
1335 | zoran_cards[i].name); | ||
1336 | card_num = i; | ||
1337 | break; | ||
1338 | } | ||
1339 | } | ||
1340 | if (i == NUM_CARDS) { | ||
1341 | dprintk(1, | ||
1342 | KERN_ERR | ||
1343 | "%s: find_zr36057() - unknown card\n", | ||
1344 | ZR_DEVNAME(zr)); | ||
1345 | goto zr_free_mem; | ||
1346 | } | ||
1347 | } | ||
1348 | } | ||
1349 | |||
1350 | if (card_num < 0 || card_num >= NUM_CARDS) { | ||
1351 | dprintk(2, | ||
1352 | KERN_ERR | 1323 | KERN_ERR |
1353 | "%s: find_zr36057() - invalid cardnum %d\n", | 1324 | "%s: It is not possible to auto-detect ZR36057 based cards\n", |
1354 | ZR_DEVNAME(zr), card_num); | 1325 | ZR_DEVNAME(zr)); |
1355 | goto zr_free_mem; | 1326 | goto zr_free_mem; |
1356 | } | 1327 | } |
1357 | 1328 | ||
1358 | /* even though we make this a non pointer and thus | 1329 | card_num = ent->driver_data; |
1359 | * theoretically allow for making changes to this struct | 1330 | if (card_num >= NUM_CARDS) { |
1360 | * on a per-individual card basis at runtime, this is | ||
1361 | * strongly discouraged. This structure is intended to | ||
1362 | * keep general card information, no settings or anything */ | ||
1363 | zr->card = zoran_cards[card_num]; | ||
1364 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), | ||
1365 | "%s[%u]", zr->card.name, zr->id); | ||
1366 | |||
1367 | zr->zr36057_mem = ioremap_nocache(zr->zr36057_adr, 0x1000); | ||
1368 | if (!zr->zr36057_mem) { | ||
1369 | dprintk(1, | 1331 | dprintk(1, |
1370 | KERN_ERR | 1332 | KERN_ERR |
1371 | "%s: find_zr36057() - ioremap failed\n", | 1333 | "%s: Unknown card, try specifying card=X module parameter\n", |
1372 | ZR_DEVNAME(zr)); | 1334 | ZR_DEVNAME(zr)); |
1373 | goto zr_free_mem; | 1335 | goto zr_free_mem; |
1374 | } | 1336 | } |
1375 | 1337 | dprintk(3, | |
1376 | result = request_irq(zr->pci_dev->irq, | 1338 | KERN_DEBUG |
1377 | zoran_irq, | 1339 | "%s: %s() - card %s detected\n", |
1378 | IRQF_SHARED | IRQF_DISABLED, | 1340 | ZR_DEVNAME(zr), __func__, zoran_cards[card_num].name); |
1379 | ZR_DEVNAME(zr), | 1341 | } else { |
1380 | (void *) zr); | 1342 | card_num = card[nr]; |
1381 | if (result < 0) { | 1343 | if (card_num >= NUM_CARDS || card_num < 0) { |
1382 | if (result == -EINVAL) { | 1344 | dprintk(1, |
1383 | dprintk(1, | 1345 | KERN_ERR |
1384 | KERN_ERR | 1346 | "%s: User specified card type %d out of range (0 .. %d)\n", |
1385 | "%s: find_zr36057() - bad irq number or handler\n", | 1347 | ZR_DEVNAME(zr), card_num, NUM_CARDS - 1); |
1386 | ZR_DEVNAME(zr)); | 1348 | goto zr_free_mem; |
1387 | } else if (result == -EBUSY) { | ||
1388 | dprintk(1, | ||
1389 | KERN_ERR | ||
1390 | "%s: find_zr36057() - IRQ %d busy, change your PnP config in BIOS\n", | ||
1391 | ZR_DEVNAME(zr), zr->pci_dev->irq); | ||
1392 | } else { | ||
1393 | dprintk(1, | ||
1394 | KERN_ERR | ||
1395 | "%s: find_zr36057() - can't assign irq, error code %d\n", | ||
1396 | ZR_DEVNAME(zr), result); | ||
1397 | } | ||
1398 | goto zr_unmap; | ||
1399 | } | ||
1400 | |||
1401 | /* set PCI latency timer */ | ||
1402 | pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, | ||
1403 | &latency); | ||
1404 | need_latency = zr->revision > 1 ? 32 : 48; | ||
1405 | if (latency != need_latency) { | ||
1406 | dprintk(2, | ||
1407 | KERN_INFO | ||
1408 | "%s: Changing PCI latency from %d to %d.\n", | ||
1409 | ZR_DEVNAME(zr), latency, need_latency); | ||
1410 | pci_write_config_byte(zr->pci_dev, | ||
1411 | PCI_LATENCY_TIMER, | ||
1412 | need_latency); | ||
1413 | } | 1349 | } |
1350 | } | ||
1414 | 1351 | ||
1415 | zr36057_restart(zr); | 1352 | /* even though we make this a non pointer and thus |
1416 | /* i2c */ | 1353 | * theoretically allow for making changes to this struct |
1417 | dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n", | 1354 | * on a per-individual card basis at runtime, this is |
1418 | ZR_DEVNAME(zr)); | 1355 | * strongly discouraged. This structure is intended to |
1356 | * keep general card information, no settings or anything */ | ||
1357 | zr->card = zoran_cards[card_num]; | ||
1358 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), | ||
1359 | "%s[%u]", zr->card.name, zr->id); | ||
1360 | |||
1361 | zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0); | ||
1362 | if (!zr->zr36057_mem) { | ||
1363 | dprintk(1, | ||
1364 | KERN_ERR | ||
1365 | "%s: %s() - ioremap failed\n", | ||
1366 | ZR_DEVNAME(zr), __func__); | ||
1367 | goto zr_free_mem; | ||
1368 | } | ||
1419 | 1369 | ||
1420 | /* i2c decoder */ | 1370 | result = request_irq(zr->pci_dev->irq, zoran_irq, |
1421 | if (decoder[zr->id] != -1) { | 1371 | IRQF_SHARED | IRQF_DISABLED, ZR_DEVNAME(zr), zr); |
1422 | i2c_dec_name = i2cid_to_modulename(decoder[zr->id]); | 1372 | if (result < 0) { |
1423 | zr->card.i2c_decoder = decoder[zr->id]; | 1373 | if (result == -EINVAL) { |
1424 | } else if (zr->card.i2c_decoder != 0) { | 1374 | dprintk(1, |
1425 | i2c_dec_name = | 1375 | KERN_ERR |
1426 | i2cid_to_modulename(zr->card.i2c_decoder); | 1376 | "%s: find_zr36057() - bad irq number or handler\n", |
1377 | ZR_DEVNAME(zr)); | ||
1378 | } else if (result == -EBUSY) { | ||
1379 | dprintk(1, | ||
1380 | KERN_ERR | ||
1381 | "%s: find_zr36057() - IRQ %d busy, change your PnP config in BIOS\n", | ||
1382 | ZR_DEVNAME(zr), zr->pci_dev->irq); | ||
1427 | } else { | 1383 | } else { |
1428 | i2c_dec_name = NULL; | 1384 | dprintk(1, |
1385 | KERN_ERR | ||
1386 | "%s: find_zr36057() - can't assign irq, error code %d\n", | ||
1387 | ZR_DEVNAME(zr), result); | ||
1429 | } | 1388 | } |
1389 | goto zr_unmap; | ||
1390 | } | ||
1430 | 1391 | ||
1431 | if (i2c_dec_name) { | 1392 | /* set PCI latency timer */ |
1432 | if ((result = request_module(i2c_dec_name)) < 0) { | 1393 | pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, |
1433 | dprintk(1, | 1394 | &latency); |
1434 | KERN_ERR | 1395 | need_latency = zr->revision > 1 ? 32 : 48; |
1435 | "%s: failed to load module %s: %d\n", | 1396 | if (latency != need_latency) { |
1436 | ZR_DEVNAME(zr), i2c_dec_name, result); | 1397 | dprintk(2, |
1437 | } | 1398 | KERN_INFO |
1438 | } | 1399 | "%s: Changing PCI latency from %d to %d\n", |
1400 | ZR_DEVNAME(zr), latency, need_latency); | ||
1401 | pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, | ||
1402 | need_latency); | ||
1403 | } | ||
1439 | 1404 | ||
1440 | /* i2c encoder */ | 1405 | zr36057_restart(zr); |
1441 | if (encoder[zr->id] != -1) { | 1406 | /* i2c */ |
1442 | i2c_enc_name = i2cid_to_modulename(encoder[zr->id]); | 1407 | dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n", |
1443 | zr->card.i2c_encoder = encoder[zr->id]; | 1408 | ZR_DEVNAME(zr)); |
1444 | } else if (zr->card.i2c_encoder != 0) { | 1409 | |
1445 | i2c_enc_name = | 1410 | /* i2c decoder */ |
1446 | i2cid_to_modulename(zr->card.i2c_encoder); | 1411 | if (decoder[zr->id] != -1) { |
1447 | } else { | 1412 | i2c_dec_name = i2cid_to_modulename(decoder[zr->id]); |
1448 | i2c_enc_name = NULL; | 1413 | zr->card.i2c_decoder = decoder[zr->id]; |
1449 | } | 1414 | } else if (zr->card.i2c_decoder != 0) { |
1415 | i2c_dec_name = i2cid_to_modulename(zr->card.i2c_decoder); | ||
1416 | } else { | ||
1417 | i2c_dec_name = NULL; | ||
1418 | } | ||
1450 | 1419 | ||
1451 | if (i2c_enc_name) { | 1420 | if (i2c_dec_name) { |
1452 | if ((result = request_module(i2c_enc_name)) < 0) { | 1421 | result = request_module(i2c_dec_name); |
1453 | dprintk(1, | 1422 | if (result < 0) { |
1454 | KERN_ERR | 1423 | dprintk(1, |
1455 | "%s: failed to load module %s: %d\n", | 1424 | KERN_ERR |
1456 | ZR_DEVNAME(zr), i2c_enc_name, result); | 1425 | "%s: failed to load module %s: %d\n", |
1457 | } | 1426 | ZR_DEVNAME(zr), i2c_dec_name, result); |
1458 | } | 1427 | } |
1428 | } | ||
1429 | |||
1430 | /* i2c encoder */ | ||
1431 | if (encoder[zr->id] != -1) { | ||
1432 | i2c_enc_name = i2cid_to_modulename(encoder[zr->id]); | ||
1433 | zr->card.i2c_encoder = encoder[zr->id]; | ||
1434 | } else if (zr->card.i2c_encoder != 0) { | ||
1435 | i2c_enc_name = i2cid_to_modulename(zr->card.i2c_encoder); | ||
1436 | } else { | ||
1437 | i2c_enc_name = NULL; | ||
1438 | } | ||
1459 | 1439 | ||
1460 | if (zoran_register_i2c(zr) < 0) { | 1440 | if (i2c_enc_name) { |
1441 | result = request_module(i2c_enc_name); | ||
1442 | if (result < 0) { | ||
1461 | dprintk(1, | 1443 | dprintk(1, |
1462 | KERN_ERR | 1444 | KERN_ERR |
1463 | "%s: find_zr36057() - can't initialize i2c bus\n", | 1445 | "%s: failed to load module %s: %d\n", |
1464 | ZR_DEVNAME(zr)); | 1446 | ZR_DEVNAME(zr), i2c_enc_name, result); |
1465 | goto zr_free_irq; | ||
1466 | } | 1447 | } |
1448 | } | ||
1467 | 1449 | ||
1468 | dprintk(2, | 1450 | if (zoran_register_i2c(zr) < 0) { |
1469 | KERN_INFO "%s: Initializing videocodec bus...\n", | 1451 | dprintk(1, |
1452 | KERN_ERR | ||
1453 | "%s: find_zr36057() - can't initialize i2c bus\n", | ||
1470 | ZR_DEVNAME(zr)); | 1454 | ZR_DEVNAME(zr)); |
1455 | goto zr_free_irq; | ||
1456 | } | ||
1471 | 1457 | ||
1472 | if (zr->card.video_codec != 0 && | 1458 | dprintk(2, |
1473 | (codec_name = | 1459 | KERN_INFO "%s: Initializing videocodec bus...\n", |
1474 | codecid_to_modulename(zr->card.video_codec)) != NULL) { | 1460 | ZR_DEVNAME(zr)); |
1475 | if ((result = request_module(codec_name)) < 0) { | 1461 | |
1462 | if (zr->card.video_codec) { | ||
1463 | codec_name = codecid_to_modulename(zr->card.video_codec); | ||
1464 | if (codec_name) { | ||
1465 | result = request_module(codec_name); | ||
1466 | if (result) { | ||
1476 | dprintk(1, | 1467 | dprintk(1, |
1477 | KERN_ERR | 1468 | KERN_ERR |
1478 | "%s: failed to load modules %s: %d\n", | 1469 | "%s: failed to load modules %s: %d\n", |
1479 | ZR_DEVNAME(zr), codec_name, result); | 1470 | ZR_DEVNAME(zr), codec_name, result); |
1480 | } | 1471 | } |
1481 | } | 1472 | } |
1482 | if (zr->card.video_vfe != 0 && | 1473 | } |
1483 | (vfe_name = | 1474 | if (zr->card.video_vfe) { |
1484 | codecid_to_modulename(zr->card.video_vfe)) != NULL) { | 1475 | vfe_name = codecid_to_modulename(zr->card.video_vfe); |
1485 | if ((result = request_module(vfe_name)) < 0) { | 1476 | if (vfe_name) { |
1477 | result = request_module(vfe_name); | ||
1478 | if (result < 0) { | ||
1486 | dprintk(1, | 1479 | dprintk(1, |
1487 | KERN_ERR | 1480 | KERN_ERR |
1488 | "%s: failed to load modules %s: %d\n", | 1481 | "%s: failed to load modules %s: %d\n", |
1489 | ZR_DEVNAME(zr), vfe_name, result); | 1482 | ZR_DEVNAME(zr), vfe_name, result); |
1490 | } | 1483 | } |
1491 | } | 1484 | } |
1485 | } | ||
1492 | 1486 | ||
1493 | /* reset JPEG codec */ | 1487 | /* reset JPEG codec */ |
1494 | jpeg_codec_sleep(zr, 1); | 1488 | jpeg_codec_sleep(zr, 1); |
1495 | jpeg_codec_reset(zr); | 1489 | jpeg_codec_reset(zr); |
1496 | /* video bus enabled */ | 1490 | /* video bus enabled */ |
1497 | /* display codec revision */ | 1491 | /* display codec revision */ |
1498 | if (zr->card.video_codec != 0) { | 1492 | if (zr->card.video_codec != 0) { |
1499 | master_codec = zoran_setup_videocodec(zr, | 1493 | master_codec = zoran_setup_videocodec(zr, zr->card.video_codec); |
1500 | zr->card.video_codec); | 1494 | if (!master_codec) |
1501 | if (!master_codec) | 1495 | goto zr_unreg_i2c; |
1502 | goto zr_unreg_i2c; | 1496 | zr->codec = videocodec_attach(master_codec); |
1503 | zr->codec = videocodec_attach(master_codec); | 1497 | if (!zr->codec) { |
1504 | if (!zr->codec) { | 1498 | dprintk(1, |
1505 | dprintk(1, | 1499 | KERN_ERR |
1506 | KERN_ERR | 1500 | "%s: find_zr36057() - no codec found\n", |
1507 | "%s: find_zr36057() - no codec found\n", | 1501 | ZR_DEVNAME(zr)); |
1508 | ZR_DEVNAME(zr)); | 1502 | goto zr_free_codec; |
1509 | goto zr_free_codec; | ||
1510 | } | ||
1511 | if (zr->codec->type != zr->card.video_codec) { | ||
1512 | dprintk(1, | ||
1513 | KERN_ERR | ||
1514 | "%s: find_zr36057() - wrong codec\n", | ||
1515 | ZR_DEVNAME(zr)); | ||
1516 | goto zr_detach_codec; | ||
1517 | } | ||
1518 | } | 1503 | } |
1519 | if (zr->card.video_vfe != 0) { | 1504 | if (zr->codec->type != zr->card.video_codec) { |
1520 | master_vfe = zoran_setup_videocodec(zr, | 1505 | dprintk(1, |
1521 | zr->card.video_vfe); | 1506 | KERN_ERR |
1522 | if (!master_vfe) | 1507 | "%s: find_zr36057() - wrong codec\n", |
1523 | goto zr_detach_codec; | 1508 | ZR_DEVNAME(zr)); |
1524 | zr->vfe = videocodec_attach(master_vfe); | 1509 | goto zr_detach_codec; |
1525 | if (!zr->vfe) { | 1510 | } |
1526 | dprintk(1, | 1511 | } |
1527 | KERN_ERR | 1512 | if (zr->card.video_vfe != 0) { |
1528 | "%s: find_zr36057() - no VFE found\n", | 1513 | master_vfe = zoran_setup_videocodec(zr, zr->card.video_vfe); |
1529 | ZR_DEVNAME(zr)); | 1514 | if (!master_vfe) |
1530 | goto zr_free_vfe; | 1515 | goto zr_detach_codec; |
1531 | } | 1516 | zr->vfe = videocodec_attach(master_vfe); |
1532 | if (zr->vfe->type != zr->card.video_vfe) { | 1517 | if (!zr->vfe) { |
1533 | dprintk(1, | 1518 | dprintk(1, |
1534 | KERN_ERR | 1519 | KERN_ERR |
1535 | "%s: find_zr36057() = wrong VFE\n", | 1520 | "%s: find_zr36057() - no VFE found\n", |
1536 | ZR_DEVNAME(zr)); | 1521 | ZR_DEVNAME(zr)); |
1537 | goto zr_detach_vfe; | 1522 | goto zr_free_vfe; |
1538 | } | 1523 | } |
1524 | if (zr->vfe->type != zr->card.video_vfe) { | ||
1525 | dprintk(1, | ||
1526 | KERN_ERR | ||
1527 | "%s: find_zr36057() = wrong VFE\n", | ||
1528 | ZR_DEVNAME(zr)); | ||
1529 | goto zr_detach_vfe; | ||
1539 | } | 1530 | } |
1540 | /* Success so keep the pci_dev referenced */ | ||
1541 | pci_dev_get(zr->pci_dev); | ||
1542 | zoran[zoran_num++] = zr; | ||
1543 | continue; | ||
1544 | |||
1545 | // Init errors | ||
1546 | zr_detach_vfe: | ||
1547 | videocodec_detach(zr->vfe); | ||
1548 | zr_free_vfe: | ||
1549 | kfree(master_vfe); | ||
1550 | zr_detach_codec: | ||
1551 | videocodec_detach(zr->codec); | ||
1552 | zr_free_codec: | ||
1553 | kfree(master_codec); | ||
1554 | zr_unreg_i2c: | ||
1555 | zoran_unregister_i2c(zr); | ||
1556 | zr_free_irq: | ||
1557 | btwrite(0, ZR36057_SPGPPCR); | ||
1558 | free_irq(zr->pci_dev->irq, zr); | ||
1559 | zr_unmap: | ||
1560 | iounmap(zr->zr36057_mem); | ||
1561 | zr_free_mem: | ||
1562 | kfree(zr); | ||
1563 | continue; | ||
1564 | } | 1531 | } |
1565 | if (dev) /* Clean up ref count on early exit */ | ||
1566 | pci_dev_put(dev); | ||
1567 | 1532 | ||
1568 | if (zoran_num == 0) { | 1533 | /* take care of Natoma chipset and a revision 1 zr36057 */ |
1569 | dprintk(1, KERN_INFO "No known MJPEG cards found.\n"); | 1534 | if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) { |
1535 | zr->jpg_buffers.need_contiguous = 1; | ||
1536 | dprintk(1, | ||
1537 | KERN_INFO | ||
1538 | "%s: ZR36057/Natoma bug, max. buffer size is 128K\n", | ||
1539 | ZR_DEVNAME(zr)); | ||
1570 | } | 1540 | } |
1571 | return zoran_num; | 1541 | |
1542 | if (zr36057_init(zr) < 0) | ||
1543 | goto zr_detach_vfe; | ||
1544 | |||
1545 | zoran_proc_init(zr); | ||
1546 | |||
1547 | pci_set_drvdata(pdev, zr); | ||
1548 | |||
1549 | return 0; | ||
1550 | |||
1551 | zr_detach_vfe: | ||
1552 | videocodec_detach(zr->vfe); | ||
1553 | zr_free_vfe: | ||
1554 | kfree(master_vfe); | ||
1555 | zr_detach_codec: | ||
1556 | videocodec_detach(zr->codec); | ||
1557 | zr_free_codec: | ||
1558 | kfree(master_codec); | ||
1559 | zr_unreg_i2c: | ||
1560 | zoran_unregister_i2c(zr); | ||
1561 | zr_free_irq: | ||
1562 | btwrite(0, ZR36057_SPGPPCR); | ||
1563 | free_irq(zr->pci_dev->irq, zr); | ||
1564 | zr_unmap: | ||
1565 | iounmap(zr->zr36057_mem); | ||
1566 | zr_free_mem: | ||
1567 | kfree(zr); | ||
1568 | |||
1569 | return -ENODEV; | ||
1572 | } | 1570 | } |
1573 | 1571 | ||
1574 | static int __init | 1572 | static struct pci_driver zoran_driver = { |
1575 | init_dc10_cards (void) | 1573 | .name = "zr36067", |
1574 | .id_table = zr36067_pci_tbl, | ||
1575 | .probe = zoran_probe, | ||
1576 | .remove = zoran_remove, | ||
1577 | }; | ||
1578 | |||
1579 | static int __init zoran_init(void) | ||
1576 | { | 1580 | { |
1577 | int i; | 1581 | int res; |
1578 | 1582 | ||
1579 | memset(zoran, 0, sizeof(zoran)); | ||
1580 | printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n", | 1583 | printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n", |
1581 | MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION); | 1584 | MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION); |
1582 | 1585 | ||
1583 | /* Look for cards */ | ||
1584 | if (find_zr36057() < 0) { | ||
1585 | return -EIO; | ||
1586 | } | ||
1587 | if (zoran_num == 0) | ||
1588 | return -ENODEV; | ||
1589 | dprintk(1, KERN_INFO "%s: %d card(s) found\n", ZORAN_NAME, | ||
1590 | zoran_num); | ||
1591 | /* check the parameters we have been given, adjust if necessary */ | 1586 | /* check the parameters we have been given, adjust if necessary */ |
1592 | if (v4l_nbufs < 2) | 1587 | if (v4l_nbufs < 2) |
1593 | v4l_nbufs = 2; | 1588 | v4l_nbufs = 2; |
@@ -1629,37 +1624,22 @@ init_dc10_cards (void) | |||
1629 | ZORAN_NAME); | 1624 | ZORAN_NAME); |
1630 | } | 1625 | } |
1631 | 1626 | ||
1632 | /* take care of Natoma chipset and a revision 1 zr36057 */ | 1627 | res = pci_register_driver(&zoran_driver); |
1633 | for (i = 0; i < zoran_num; i++) { | 1628 | if (res) { |
1634 | struct zoran *zr = zoran[i]; | 1629 | dprintk(1, |
1635 | 1630 | KERN_ERR | |
1636 | if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) { | 1631 | "%s: Unable to register ZR36057 driver\n", |
1637 | zr->jpg_buffers.need_contiguous = 1; | 1632 | ZORAN_NAME); |
1638 | dprintk(1, | 1633 | return res; |
1639 | KERN_INFO | ||
1640 | "%s: ZR36057/Natoma bug, max. buffer size is 128K\n", | ||
1641 | ZR_DEVNAME(zr)); | ||
1642 | } | ||
1643 | |||
1644 | if (zr36057_init(zr) < 0) { | ||
1645 | for (i = 0; i < zoran_num; i++) | ||
1646 | zoran_release(zoran[i]); | ||
1647 | return -EIO; | ||
1648 | } | ||
1649 | zoran_proc_init(zr); | ||
1650 | } | 1634 | } |
1651 | 1635 | ||
1652 | return 0; | 1636 | return 0; |
1653 | } | 1637 | } |
1654 | 1638 | ||
1655 | static void __exit | 1639 | static void __exit zoran_exit(void) |
1656 | unload_dc10_cards (void) | ||
1657 | { | 1640 | { |
1658 | int i; | 1641 | pci_unregister_driver(&zoran_driver); |
1659 | |||
1660 | for (i = 0; i < zoran_num; i++) | ||
1661 | zoran_release(zoran[i]); | ||
1662 | } | 1642 | } |
1663 | 1643 | ||
1664 | module_init(init_dc10_cards); | 1644 | module_init(zoran_init); |
1665 | module_exit(unload_dc10_cards); | 1645 | module_exit(zoran_exit); |
diff --git a/drivers/media/video/zoran/zoran_card.h b/drivers/media/video/zoran/zoran_card.h index e4dc9d29b404..4507bdc5e338 100644 --- a/drivers/media/video/zoran/zoran_card.h +++ b/drivers/media/video/zoran/zoran_card.h | |||
@@ -40,8 +40,6 @@ extern int zr36067_debug; | |||
40 | 40 | ||
41 | /* Anybody who uses more than four? */ | 41 | /* Anybody who uses more than four? */ |
42 | #define BUZ_MAX 4 | 42 | #define BUZ_MAX 4 |
43 | extern int zoran_num; | ||
44 | extern struct zoran *zoran[BUZ_MAX]; | ||
45 | 43 | ||
46 | extern struct video_device zoran_template; | 44 | extern struct video_device zoran_template; |
47 | 45 | ||
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c index b58b9dda715c..120ef235e63d 100644 --- a/drivers/media/video/zoran/zoran_driver.c +++ b/drivers/media/video/zoran/zoran_driver.c | |||
@@ -1196,83 +1196,54 @@ zoran_close_end_session (struct file *file) | |||
1196 | * Open a zoran card. Right now the flags stuff is just playing | 1196 | * Open a zoran card. Right now the flags stuff is just playing |
1197 | */ | 1197 | */ |
1198 | 1198 | ||
1199 | static int | 1199 | static int zoran_open(struct file *file) |
1200 | zoran_open(struct file *file) | ||
1201 | { | 1200 | { |
1202 | unsigned int minor = video_devdata(file)->minor; | 1201 | struct zoran *zr = video_drvdata(file); |
1203 | struct zoran *zr = NULL; | ||
1204 | struct zoran_fh *fh; | 1202 | struct zoran_fh *fh; |
1205 | int i, res, first_open = 0, have_module_locks = 0; | 1203 | int res, first_open = 0; |
1206 | 1204 | ||
1207 | lock_kernel(); | 1205 | dprintk(2, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n", |
1208 | /* find the device */ | 1206 | ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user + 1); |
1209 | for (i = 0; i < zoran_num; i++) { | ||
1210 | if (zoran[i]->video_dev->minor == minor) { | ||
1211 | zr = zoran[i]; | ||
1212 | break; | ||
1213 | } | ||
1214 | } | ||
1215 | 1207 | ||
1216 | if (!zr) { | 1208 | lock_kernel(); |
1217 | dprintk(1, KERN_ERR "%s: device not found!\n", ZORAN_NAME); | ||
1218 | res = -ENODEV; | ||
1219 | goto open_unlock_and_return; | ||
1220 | } | ||
1221 | 1209 | ||
1222 | /* see fs/device.c - the kernel already locks during open(), | 1210 | /* see fs/device.c - the kernel already locks during open(), |
1223 | * so locking ourselves only causes deadlocks */ | 1211 | * so locking ourselves only causes deadlocks */ |
1224 | /*mutex_lock(&zr->resource_lock);*/ | 1212 | /*mutex_lock(&zr->resource_lock);*/ |
1225 | 1213 | ||
1214 | if (zr->user >= 2048) { | ||
1215 | dprintk(1, KERN_ERR "%s: too many users (%d) on device\n", | ||
1216 | ZR_DEVNAME(zr), zr->user); | ||
1217 | res = -EBUSY; | ||
1218 | goto fail_unlock; | ||
1219 | } | ||
1220 | |||
1226 | if (!zr->decoder) { | 1221 | if (!zr->decoder) { |
1227 | dprintk(1, | 1222 | dprintk(1, |
1228 | KERN_ERR "%s: no TV decoder loaded for device!\n", | 1223 | KERN_ERR "%s: no TV decoder loaded for device!\n", |
1229 | ZR_DEVNAME(zr)); | 1224 | ZR_DEVNAME(zr)); |
1230 | res = -EIO; | 1225 | res = -EIO; |
1231 | goto open_unlock_and_return; | 1226 | goto fail_unlock; |
1232 | } | 1227 | } |
1233 | 1228 | ||
1234 | /* try to grab a module lock */ | ||
1235 | if (!try_module_get(THIS_MODULE)) { | ||
1236 | dprintk(1, | ||
1237 | KERN_ERR | ||
1238 | "%s: failed to acquire my own lock! PANIC!\n", | ||
1239 | ZR_DEVNAME(zr)); | ||
1240 | res = -ENODEV; | ||
1241 | goto open_unlock_and_return; | ||
1242 | } | ||
1243 | if (!try_module_get(zr->decoder->driver->driver.owner)) { | 1229 | if (!try_module_get(zr->decoder->driver->driver.owner)) { |
1244 | dprintk(1, | 1230 | dprintk(1, |
1245 | KERN_ERR | 1231 | KERN_ERR |
1246 | "%s: failed to grab ownership of i2c decoder\n", | 1232 | "%s: failed to grab ownership of video decoder\n", |
1247 | ZR_DEVNAME(zr)); | 1233 | ZR_DEVNAME(zr)); |
1248 | res = -EIO; | 1234 | res = -EIO; |
1249 | module_put(THIS_MODULE); | 1235 | goto fail_unlock; |
1250 | goto open_unlock_and_return; | ||
1251 | } | 1236 | } |
1252 | if (zr->encoder && | 1237 | if (zr->encoder && |
1253 | !try_module_get(zr->encoder->driver->driver.owner)) { | 1238 | !try_module_get(zr->encoder->driver->driver.owner)) { |
1254 | dprintk(1, | 1239 | dprintk(1, |
1255 | KERN_ERR | 1240 | KERN_ERR |
1256 | "%s: failed to grab ownership of i2c encoder\n", | 1241 | "%s: failed to grab ownership of video encoder\n", |
1257 | ZR_DEVNAME(zr)); | 1242 | ZR_DEVNAME(zr)); |
1258 | res = -EIO; | 1243 | res = -EIO; |
1259 | module_put(zr->decoder->driver->driver.owner); | 1244 | goto fail_decoder; |
1260 | module_put(THIS_MODULE); | ||
1261 | goto open_unlock_and_return; | ||
1262 | } | 1245 | } |
1263 | 1246 | ||
1264 | have_module_locks = 1; | ||
1265 | |||
1266 | if (zr->user >= 2048) { | ||
1267 | dprintk(1, KERN_ERR "%s: too many users (%d) on device\n", | ||
1268 | ZR_DEVNAME(zr), zr->user); | ||
1269 | res = -EBUSY; | ||
1270 | goto open_unlock_and_return; | ||
1271 | } | ||
1272 | |||
1273 | dprintk(1, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n", | ||
1274 | ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user); | ||
1275 | |||
1276 | /* now, create the open()-specific file_ops struct */ | 1247 | /* now, create the open()-specific file_ops struct */ |
1277 | fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL); | 1248 | fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL); |
1278 | if (!fh) { | 1249 | if (!fh) { |
@@ -1281,7 +1252,7 @@ zoran_open(struct file *file) | |||
1281 | "%s: zoran_open() - allocation of zoran_fh failed\n", | 1252 | "%s: zoran_open() - allocation of zoran_fh failed\n", |
1282 | ZR_DEVNAME(zr)); | 1253 | ZR_DEVNAME(zr)); |
1283 | res = -ENOMEM; | 1254 | res = -ENOMEM; |
1284 | goto open_unlock_and_return; | 1255 | goto fail_encoder; |
1285 | } | 1256 | } |
1286 | /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows | 1257 | /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows |
1287 | * on norm-change! */ | 1258 | * on norm-change! */ |
@@ -1292,9 +1263,8 @@ zoran_open(struct file *file) | |||
1292 | KERN_ERR | 1263 | KERN_ERR |
1293 | "%s: zoran_open() - allocation of overlay_mask failed\n", | 1264 | "%s: zoran_open() - allocation of overlay_mask failed\n", |
1294 | ZR_DEVNAME(zr)); | 1265 | ZR_DEVNAME(zr)); |
1295 | kfree(fh); | ||
1296 | res = -ENOMEM; | 1266 | res = -ENOMEM; |
1297 | goto open_unlock_and_return; | 1267 | goto fail_fh; |
1298 | } | 1268 | } |
1299 | 1269 | ||
1300 | if (zr->user++ == 0) | 1270 | if (zr->user++ == 0) |
@@ -1319,22 +1289,19 @@ zoran_open(struct file *file) | |||
1319 | 1289 | ||
1320 | return 0; | 1290 | return 0; |
1321 | 1291 | ||
1322 | open_unlock_and_return: | 1292 | fail_fh: |
1323 | /* if we grabbed locks, release them accordingly */ | 1293 | kfree(fh); |
1324 | if (have_module_locks) { | 1294 | fail_encoder: |
1325 | module_put(zr->decoder->driver->driver.owner); | 1295 | if (zr->encoder) |
1326 | if (zr->encoder) { | 1296 | module_put(zr->encoder->driver->driver.owner); |
1327 | module_put(zr->encoder->driver->driver.owner); | 1297 | fail_decoder: |
1328 | } | 1298 | module_put(zr->decoder->driver->driver.owner); |
1329 | module_put(THIS_MODULE); | 1299 | fail_unlock: |
1330 | } | ||
1331 | |||
1332 | /* if there's no device found, we didn't obtain the lock either */ | ||
1333 | if (zr) { | ||
1334 | /*mutex_unlock(&zr->resource_lock);*/ | ||
1335 | } | ||
1336 | unlock_kernel(); | 1300 | unlock_kernel(); |
1337 | 1301 | ||
1302 | dprintk(2, KERN_INFO "%s: open failed (%d), users(-)=%d\n", | ||
1303 | ZR_DEVNAME(zr), res, zr->user); | ||
1304 | |||
1338 | return res; | 1305 | return res; |
1339 | } | 1306 | } |
1340 | 1307 | ||
@@ -1344,8 +1311,8 @@ zoran_close(struct file *file) | |||
1344 | struct zoran_fh *fh = file->private_data; | 1311 | struct zoran_fh *fh = file->private_data; |
1345 | struct zoran *zr = fh->zr; | 1312 | struct zoran *zr = fh->zr; |
1346 | 1313 | ||
1347 | dprintk(1, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n", | 1314 | dprintk(2, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n", |
1348 | ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user); | 1315 | ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user - 1); |
1349 | 1316 | ||
1350 | /* kernel locks (fs/device.c), so don't do that ourselves | 1317 | /* kernel locks (fs/device.c), so don't do that ourselves |
1351 | * (prevents deadlocks) */ | 1318 | * (prevents deadlocks) */ |
@@ -1391,10 +1358,8 @@ zoran_close(struct file *file) | |||
1391 | 1358 | ||
1392 | /* release locks on the i2c modules */ | 1359 | /* release locks on the i2c modules */ |
1393 | module_put(zr->decoder->driver->driver.owner); | 1360 | module_put(zr->decoder->driver->driver.owner); |
1394 | if (zr->encoder) { | 1361 | if (zr->encoder) |
1395 | module_put(zr->encoder->driver->driver.owner); | 1362 | module_put(zr->encoder->driver->driver.owner); |
1396 | } | ||
1397 | module_put(THIS_MODULE); | ||
1398 | 1363 | ||
1399 | /*mutex_unlock(&zr->resource_lock);*/ | 1364 | /*mutex_unlock(&zr->resource_lock);*/ |
1400 | 1365 | ||
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index 24508e28e3fb..ea9488e7ad6d 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c | |||
@@ -626,7 +626,6 @@ static int __devinit pcf50633_probe(struct i2c_client *client, | |||
626 | } | 626 | } |
627 | 627 | ||
628 | if (client->irq) { | 628 | if (client->irq) { |
629 | set_irq_handler(client->irq, handle_level_irq); | ||
630 | ret = request_irq(client->irq, pcf50633_irq, | 629 | ret = request_irq(client->irq, pcf50633_irq, |
631 | IRQF_TRIGGER_LOW, "pcf50633", pcf); | 630 | IRQF_TRIGGER_LOW, "pcf50633", pcf); |
632 | 631 | ||
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 396d935012f2..1c484084ed4f 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -217,6 +217,7 @@ config DELL_LAPTOP | |||
217 | depends on EXPERIMENTAL | 217 | depends on EXPERIMENTAL |
218 | depends on BACKLIGHT_CLASS_DEVICE | 218 | depends on BACKLIGHT_CLASS_DEVICE |
219 | depends on RFKILL | 219 | depends on RFKILL |
220 | depends on POWER_SUPPLY | ||
220 | default n | 221 | default n |
221 | ---help--- | 222 | ---help--- |
222 | This driver adds support for rfkill and backlight control to Dell | 223 | This driver adds support for rfkill and backlight control to Dell |
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index bf5e4d065436..558bf3f2c276 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c | |||
@@ -35,7 +35,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num) | |||
35 | 35 | ||
36 | if (!ssc_valid) { | 36 | if (!ssc_valid) { |
37 | spin_unlock(&user_lock); | 37 | spin_unlock(&user_lock); |
38 | dev_dbg(&ssc->pdev->dev, "could not find requested device\n"); | 38 | pr_err("ssc: ssc%d platform device is missing\n", ssc_num); |
39 | return ERR_PTR(-ENODEV); | 39 | return ERR_PTR(-ENODEV); |
40 | } | 40 | } |
41 | 41 | ||
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c index 10c421b73eaf..f26667a7abf7 100644 --- a/drivers/misc/hpilo.c +++ b/drivers/misc/hpilo.c | |||
@@ -207,7 +207,7 @@ static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data) | |||
207 | &device_ccb->recv_ctrl); | 207 | &device_ccb->recv_ctrl); |
208 | 208 | ||
209 | /* give iLO some time to process stop request */ | 209 | /* give iLO some time to process stop request */ |
210 | for (retries = 1000; retries > 0; retries--) { | 210 | for (retries = MAX_WAIT; retries > 0; retries--) { |
211 | doorbell_set(driver_ccb); | 211 | doorbell_set(driver_ccb); |
212 | udelay(1); | 212 | udelay(1); |
213 | if (!(ioread32(&device_ccb->send_ctrl) & (1 << CTRL_BITPOS_A)) | 213 | if (!(ioread32(&device_ccb->send_ctrl) & (1 << CTRL_BITPOS_A)) |
@@ -309,7 +309,7 @@ static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot) | |||
309 | doorbell_clr(driver_ccb); | 309 | doorbell_clr(driver_ccb); |
310 | 310 | ||
311 | /* make sure iLO is really handling requests */ | 311 | /* make sure iLO is really handling requests */ |
312 | for (i = 1000; i > 0; i--) { | 312 | for (i = MAX_WAIT; i > 0; i--) { |
313 | if (ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, NULL, NULL)) | 313 | if (ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, NULL, NULL)) |
314 | break; | 314 | break; |
315 | udelay(1); | 315 | udelay(1); |
@@ -326,7 +326,7 @@ static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot) | |||
326 | 326 | ||
327 | return 0; | 327 | return 0; |
328 | free: | 328 | free: |
329 | pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa); | 329 | ilo_ccb_close(pdev, data); |
330 | out: | 330 | out: |
331 | return error; | 331 | return error; |
332 | } | 332 | } |
diff --git a/drivers/misc/hpilo.h b/drivers/misc/hpilo.h index a281207696c1..b64a20ef07e3 100644 --- a/drivers/misc/hpilo.h +++ b/drivers/misc/hpilo.h | |||
@@ -19,6 +19,8 @@ | |||
19 | #define MAX_ILO_DEV 1 | 19 | #define MAX_ILO_DEV 1 |
20 | /* max number of files */ | 20 | /* max number of files */ |
21 | #define MAX_OPEN (MAX_CCB * MAX_ILO_DEV) | 21 | #define MAX_OPEN (MAX_CCB * MAX_ILO_DEV) |
22 | /* spin counter for open/close delay */ | ||
23 | #define MAX_WAIT 10000 | ||
22 | 24 | ||
23 | /* | 25 | /* |
24 | * Per device, used to track global memory allocations. | 26 | * Per device, used to track global memory allocations. |
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h index a5bd658c2e83..275b78896a73 100644 --- a/drivers/misc/sgi-xp/xpc.h +++ b/drivers/misc/sgi-xp/xpc.h | |||
@@ -3,7 +3,7 @@ | |||
3 | * License. See the file "COPYING" in the main directory of this archive | 3 | * License. See the file "COPYING" in the main directory of this archive |
4 | * for more details. | 4 | * for more details. |
5 | * | 5 | * |
6 | * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved. | 6 | * Copyright (c) 2004-2009 Silicon Graphics, Inc. All Rights Reserved. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* | 9 | /* |
@@ -514,7 +514,8 @@ struct xpc_channel_uv { | |||
514 | /* partition's notify mq */ | 514 | /* partition's notify mq */ |
515 | 515 | ||
516 | struct xpc_send_msg_slot_uv *send_msg_slots; | 516 | struct xpc_send_msg_slot_uv *send_msg_slots; |
517 | struct xpc_notify_mq_msg_uv *recv_msg_slots; | 517 | void *recv_msg_slots; /* each slot will hold a xpc_notify_mq_msg_uv */ |
518 | /* structure plus the user's payload */ | ||
518 | 519 | ||
519 | struct xpc_fifo_head_uv msg_slot_free_list; | 520 | struct xpc_fifo_head_uv msg_slot_free_list; |
520 | struct xpc_fifo_head_uv recv_msg_list; /* deliverable payloads */ | 521 | struct xpc_fifo_head_uv recv_msg_list; /* deliverable payloads */ |
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c index f17f7d40ea2c..29c0502a96b2 100644 --- a/drivers/misc/sgi-xp/xpc_uv.c +++ b/drivers/misc/sgi-xp/xpc_uv.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * License. See the file "COPYING" in the main directory of this archive | 3 | * License. See the file "COPYING" in the main directory of this archive |
4 | * for more details. | 4 | * for more details. |
5 | * | 5 | * |
6 | * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. | 6 | * Copyright (c) 2008-2009 Silicon Graphics, Inc. All Rights Reserved. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* | 9 | /* |
@@ -1010,8 +1010,8 @@ xpc_allocate_recv_msg_slot_uv(struct xpc_channel *ch) | |||
1010 | continue; | 1010 | continue; |
1011 | 1011 | ||
1012 | for (entry = 0; entry < nentries; entry++) { | 1012 | for (entry = 0; entry < nentries; entry++) { |
1013 | msg_slot = ch_uv->recv_msg_slots + entry * | 1013 | msg_slot = ch_uv->recv_msg_slots + |
1014 | ch->entry_size; | 1014 | entry * ch->entry_size; |
1015 | 1015 | ||
1016 | msg_slot->hdr.msg_slot_number = entry; | 1016 | msg_slot->hdr.msg_slot_number = entry; |
1017 | } | 1017 | } |
@@ -1308,9 +1308,8 @@ xpc_handle_notify_mq_msg_uv(struct xpc_partition *part, | |||
1308 | /* we're dealing with a normal message sent via the notify_mq */ | 1308 | /* we're dealing with a normal message sent via the notify_mq */ |
1309 | ch_uv = &ch->sn.uv; | 1309 | ch_uv = &ch->sn.uv; |
1310 | 1310 | ||
1311 | msg_slot = (struct xpc_notify_mq_msg_uv *)((u64)ch_uv->recv_msg_slots + | 1311 | msg_slot = ch_uv->recv_msg_slots + |
1312 | (msg->hdr.msg_slot_number % ch->remote_nentries) * | 1312 | (msg->hdr.msg_slot_number % ch->remote_nentries) * ch->entry_size; |
1313 | ch->entry_size); | ||
1314 | 1313 | ||
1315 | BUG_ON(msg->hdr.msg_slot_number != msg_slot->hdr.msg_slot_number); | 1314 | BUG_ON(msg->hdr.msg_slot_number != msg_slot->hdr.msg_slot_number); |
1316 | BUG_ON(msg_slot->hdr.size != 0); | 1315 | BUG_ON(msg_slot->hdr.size != 0); |
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c index 7957f525b2f4..6faefcffcb53 100644 --- a/drivers/misc/sgi-xp/xpnet.c +++ b/drivers/misc/sgi-xp/xpnet.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * License. See the file "COPYING" in the main directory of this archive | 3 | * License. See the file "COPYING" in the main directory of this archive |
4 | * for more details. | 4 | * for more details. |
5 | * | 5 | * |
6 | * Copyright (C) 1999-2008 Silicon Graphics, Inc. All rights reserved. | 6 | * Copyright (C) 1999-2009 Silicon Graphics, Inc. All rights reserved. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* | 9 | /* |
@@ -551,6 +551,7 @@ xpnet_init(void) | |||
551 | 551 | ||
552 | netif_carrier_off(xpnet_device); | 552 | netif_carrier_off(xpnet_device); |
553 | 553 | ||
554 | xpnet_device->netdev_ops = &xpnet_netdev_ops; | ||
554 | xpnet_device->mtu = XPNET_DEF_MTU; | 555 | xpnet_device->mtu = XPNET_DEF_MTU; |
555 | 556 | ||
556 | /* | 557 | /* |
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 0efa390978bd..99d4b28d52ed 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -145,6 +145,16 @@ config MMC_IMX | |||
145 | 145 | ||
146 | If unsure, say N. | 146 | If unsure, say N. |
147 | 147 | ||
148 | config MMC_MXC | ||
149 | tristate "Freescale i.MX2/3 Multimedia Card Interface support" | ||
150 | depends on ARCH_MXC | ||
151 | help | ||
152 | This selects the Freescale i.MX2/3 Multimedia card Interface. | ||
153 | If you have a i.MX platform with a Multimedia Card slot, | ||
154 | say Y or M here. | ||
155 | |||
156 | If unsure, say N. | ||
157 | |||
148 | config MMC_TIFM_SD | 158 | config MMC_TIFM_SD |
149 | tristate "TI Flash Media MMC/SD Interface support (EXPERIMENTAL)" | 159 | tristate "TI Flash Media MMC/SD Interface support (EXPERIMENTAL)" |
150 | depends on EXPERIMENTAL && PCI | 160 | depends on EXPERIMENTAL && PCI |
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 98cab84829b8..dedec55861d9 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -9,6 +9,7 @@ endif | |||
9 | obj-$(CONFIG_MMC_ARMMMCI) += mmci.o | 9 | obj-$(CONFIG_MMC_ARMMMCI) += mmci.o |
10 | obj-$(CONFIG_MMC_PXA) += pxamci.o | 10 | obj-$(CONFIG_MMC_PXA) += pxamci.o |
11 | obj-$(CONFIG_MMC_IMX) += imxmmc.o | 11 | obj-$(CONFIG_MMC_IMX) += imxmmc.o |
12 | obj-$(CONFIG_MMC_MXC) += mxcmmc.o | ||
12 | obj-$(CONFIG_MMC_SDHCI) += sdhci.o | 13 | obj-$(CONFIG_MMC_SDHCI) += sdhci.o |
13 | obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o | 14 | obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o |
14 | obj-$(CONFIG_MMC_RICOH_MMC) += ricoh_mmc.o | 15 | obj-$(CONFIG_MMC_RICOH_MMC) += ricoh_mmc.o |
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 1bcbdd6763ac..2909bbc8ad00 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c | |||
@@ -430,6 +430,8 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
430 | clk = 255; | 430 | clk = 255; |
431 | host->cclk = host->mclk / (2 * (clk + 1)); | 431 | host->cclk = host->mclk / (2 * (clk + 1)); |
432 | } | 432 | } |
433 | if (host->hw_designer == 0x80) | ||
434 | clk |= MCI_FCEN; /* Bug fix in ST IP block */ | ||
433 | clk |= MCI_CLK_ENABLE; | 435 | clk |= MCI_CLK_ENABLE; |
434 | } | 436 | } |
435 | 437 | ||
@@ -440,15 +442,27 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
440 | case MMC_POWER_OFF: | 442 | case MMC_POWER_OFF: |
441 | break; | 443 | break; |
442 | case MMC_POWER_UP: | 444 | case MMC_POWER_UP: |
443 | pwr |= MCI_PWR_UP; | 445 | /* The ST version does not have this, fall through to POWER_ON */ |
444 | break; | 446 | if (host->hw_designer != 0x80) { |
447 | pwr |= MCI_PWR_UP; | ||
448 | break; | ||
449 | } | ||
445 | case MMC_POWER_ON: | 450 | case MMC_POWER_ON: |
446 | pwr |= MCI_PWR_ON; | 451 | pwr |= MCI_PWR_ON; |
447 | break; | 452 | break; |
448 | } | 453 | } |
449 | 454 | ||
450 | if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) | 455 | if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) { |
451 | pwr |= MCI_ROD; | 456 | if (host->hw_designer != 0x80) |
457 | pwr |= MCI_ROD; | ||
458 | else { | ||
459 | /* | ||
460 | * The ST Micro variant use the ROD bit for something | ||
461 | * else and only has OD (Open Drain). | ||
462 | */ | ||
463 | pwr |= MCI_OD; | ||
464 | } | ||
465 | } | ||
452 | 466 | ||
453 | writel(clk, host->base + MMCICLOCK); | 467 | writel(clk, host->base + MMCICLOCK); |
454 | 468 | ||
@@ -500,6 +514,12 @@ static int mmci_probe(struct amba_device *dev, void *id) | |||
500 | } | 514 | } |
501 | 515 | ||
502 | host = mmc_priv(mmc); | 516 | host = mmc_priv(mmc); |
517 | /* Bits 12 thru 19 is the designer */ | ||
518 | host->hw_designer = (dev->periphid >> 12) & 0xff; | ||
519 | /* Bits 20 thru 23 is the revison */ | ||
520 | host->hw_revision = (dev->periphid >> 20) & 0xf; | ||
521 | DBG(host, "designer ID = 0x%02x\n", host->hw_designer); | ||
522 | DBG(host, "revision = 0x%01x\n", host->hw_revision); | ||
503 | host->clk = clk_get(&dev->dev, NULL); | 523 | host->clk = clk_get(&dev->dev, NULL); |
504 | if (IS_ERR(host->clk)) { | 524 | if (IS_ERR(host->clk)) { |
505 | ret = PTR_ERR(host->clk); | 525 | ret = PTR_ERR(host->clk); |
@@ -693,6 +713,15 @@ static struct amba_id mmci_ids[] = { | |||
693 | .id = 0x00041181, | 713 | .id = 0x00041181, |
694 | .mask = 0x000fffff, | 714 | .mask = 0x000fffff, |
695 | }, | 715 | }, |
716 | /* ST Micro variants */ | ||
717 | { | ||
718 | .id = 0x00180180, | ||
719 | .mask = 0x00ffffff, | ||
720 | }, | ||
721 | { | ||
722 | .id = 0x00280180, | ||
723 | .mask = 0x00ffffff, | ||
724 | }, | ||
696 | { 0, 0 }, | 725 | { 0, 0 }, |
697 | }; | 726 | }; |
698 | 727 | ||
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 0f39c490f022..0441bac1c0ec 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h | |||
@@ -11,13 +11,23 @@ | |||
11 | #define MCI_PWR_OFF 0x00 | 11 | #define MCI_PWR_OFF 0x00 |
12 | #define MCI_PWR_UP 0x02 | 12 | #define MCI_PWR_UP 0x02 |
13 | #define MCI_PWR_ON 0x03 | 13 | #define MCI_PWR_ON 0x03 |
14 | #define MCI_DATA2DIREN (1 << 2) | ||
15 | #define MCI_CMDDIREN (1 << 3) | ||
16 | #define MCI_DATA0DIREN (1 << 4) | ||
17 | #define MCI_DATA31DIREN (1 << 5) | ||
14 | #define MCI_OD (1 << 6) | 18 | #define MCI_OD (1 << 6) |
15 | #define MCI_ROD (1 << 7) | 19 | #define MCI_ROD (1 << 7) |
20 | /* The ST Micro version does not have ROD */ | ||
21 | #define MCI_FBCLKEN (1 << 7) | ||
22 | #define MCI_DATA74DIREN (1 << 8) | ||
16 | 23 | ||
17 | #define MMCICLOCK 0x004 | 24 | #define MMCICLOCK 0x004 |
18 | #define MCI_CLK_ENABLE (1 << 8) | 25 | #define MCI_CLK_ENABLE (1 << 8) |
19 | #define MCI_CLK_PWRSAVE (1 << 9) | 26 | #define MCI_CLK_PWRSAVE (1 << 9) |
20 | #define MCI_CLK_BYPASS (1 << 10) | 27 | #define MCI_CLK_BYPASS (1 << 10) |
28 | #define MCI_WIDE_BUS (1 << 11) | ||
29 | /* HW flow control on the ST Micro version */ | ||
30 | #define MCI_FCEN (1 << 13) | ||
21 | 31 | ||
22 | #define MMCIARGUMENT 0x008 | 32 | #define MMCIARGUMENT 0x008 |
23 | #define MMCICOMMAND 0x00c | 33 | #define MMCICOMMAND 0x00c |
@@ -26,6 +36,10 @@ | |||
26 | #define MCI_CPSM_INTERRUPT (1 << 8) | 36 | #define MCI_CPSM_INTERRUPT (1 << 8) |
27 | #define MCI_CPSM_PENDING (1 << 9) | 37 | #define MCI_CPSM_PENDING (1 << 9) |
28 | #define MCI_CPSM_ENABLE (1 << 10) | 38 | #define MCI_CPSM_ENABLE (1 << 10) |
39 | #define MCI_SDIO_SUSP (1 << 11) | ||
40 | #define MCI_ENCMD_COMPL (1 << 12) | ||
41 | #define MCI_NIEN (1 << 13) | ||
42 | #define MCI_CE_ATACMD (1 << 14) | ||
29 | 43 | ||
30 | #define MMCIRESPCMD 0x010 | 44 | #define MMCIRESPCMD 0x010 |
31 | #define MMCIRESPONSE0 0x014 | 45 | #define MMCIRESPONSE0 0x014 |
@@ -39,6 +53,11 @@ | |||
39 | #define MCI_DPSM_DIRECTION (1 << 1) | 53 | #define MCI_DPSM_DIRECTION (1 << 1) |
40 | #define MCI_DPSM_MODE (1 << 2) | 54 | #define MCI_DPSM_MODE (1 << 2) |
41 | #define MCI_DPSM_DMAENABLE (1 << 3) | 55 | #define MCI_DPSM_DMAENABLE (1 << 3) |
56 | #define MCI_DPSM_BLOCKSIZE (1 << 4) | ||
57 | #define MCI_DPSM_RWSTART (1 << 8) | ||
58 | #define MCI_DPSM_RWSTOP (1 << 9) | ||
59 | #define MCI_DPSM_RWMOD (1 << 10) | ||
60 | #define MCI_DPSM_SDIOEN (1 << 11) | ||
42 | 61 | ||
43 | #define MMCIDATACNT 0x030 | 62 | #define MMCIDATACNT 0x030 |
44 | #define MMCISTATUS 0x034 | 63 | #define MMCISTATUS 0x034 |
@@ -63,6 +82,8 @@ | |||
63 | #define MCI_RXFIFOEMPTY (1 << 19) | 82 | #define MCI_RXFIFOEMPTY (1 << 19) |
64 | #define MCI_TXDATAAVLBL (1 << 20) | 83 | #define MCI_TXDATAAVLBL (1 << 20) |
65 | #define MCI_RXDATAAVLBL (1 << 21) | 84 | #define MCI_RXDATAAVLBL (1 << 21) |
85 | #define MCI_SDIOIT (1 << 22) | ||
86 | #define MCI_CEATAEND (1 << 23) | ||
66 | 87 | ||
67 | #define MMCICLEAR 0x038 | 88 | #define MMCICLEAR 0x038 |
68 | #define MCI_CMDCRCFAILCLR (1 << 0) | 89 | #define MCI_CMDCRCFAILCLR (1 << 0) |
@@ -75,6 +96,8 @@ | |||
75 | #define MCI_CMDSENTCLR (1 << 7) | 96 | #define MCI_CMDSENTCLR (1 << 7) |
76 | #define MCI_DATAENDCLR (1 << 8) | 97 | #define MCI_DATAENDCLR (1 << 8) |
77 | #define MCI_DATABLOCKENDCLR (1 << 10) | 98 | #define MCI_DATABLOCKENDCLR (1 << 10) |
99 | #define MCI_SDIOITC (1 << 22) | ||
100 | #define MCI_CEATAENDC (1 << 23) | ||
78 | 101 | ||
79 | #define MMCIMASK0 0x03c | 102 | #define MMCIMASK0 0x03c |
80 | #define MCI_CMDCRCFAILMASK (1 << 0) | 103 | #define MCI_CMDCRCFAILMASK (1 << 0) |
@@ -98,6 +121,8 @@ | |||
98 | #define MCI_RXFIFOEMPTYMASK (1 << 19) | 121 | #define MCI_RXFIFOEMPTYMASK (1 << 19) |
99 | #define MCI_TXDATAAVLBLMASK (1 << 20) | 122 | #define MCI_TXDATAAVLBLMASK (1 << 20) |
100 | #define MCI_RXDATAAVLBLMASK (1 << 21) | 123 | #define MCI_RXDATAAVLBLMASK (1 << 21) |
124 | #define MCI_SDIOITMASK (1 << 22) | ||
125 | #define MCI_CEATAENDMASK (1 << 23) | ||
101 | 126 | ||
102 | #define MMCIMASK1 0x040 | 127 | #define MMCIMASK1 0x040 |
103 | #define MMCIFIFOCNT 0x048 | 128 | #define MMCIFIFOCNT 0x048 |
@@ -136,6 +161,9 @@ struct mmci_host { | |||
136 | u32 pwr; | 161 | u32 pwr; |
137 | struct mmc_platform_data *plat; | 162 | struct mmc_platform_data *plat; |
138 | 163 | ||
164 | u8 hw_designer; | ||
165 | u8 hw_revision:4; | ||
166 | |||
139 | struct timer_list timer; | 167 | struct timer_list timer; |
140 | unsigned int oldstat; | 168 | unsigned int oldstat; |
141 | 169 | ||
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c new file mode 100644 index 000000000000..dda0be4e25dc --- /dev/null +++ b/drivers/mmc/host/mxcmmc.c | |||
@@ -0,0 +1,880 @@ | |||
1 | /* | ||
2 | * linux/drivers/mmc/host/mxcmmc.c - Freescale i.MX MMCI driver | ||
3 | * | ||
4 | * This is a driver for the SDHC controller found in Freescale MX2/MX3 | ||
5 | * SoCs. It is basically the same hardware as found on MX1 (imxmmc.c). | ||
6 | * Unlike the hardware found on MX1, this hardware just works and does | ||
7 | * not need all the quirks found in imxmmc.c, hence the seperate driver. | ||
8 | * | ||
9 | * Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> | ||
10 | * Copyright (C) 2006 Pavel Pisa, PiKRON <ppisa@pikron.com> | ||
11 | * | ||
12 | * derived from pxamci.c by Russell King | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | * | ||
18 | */ | ||
19 | |||
20 | #include <linux/module.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/ioport.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/irq.h> | ||
26 | #include <linux/blkdev.h> | ||
27 | #include <linux/dma-mapping.h> | ||
28 | #include <linux/mmc/host.h> | ||
29 | #include <linux/mmc/card.h> | ||
30 | #include <linux/delay.h> | ||
31 | #include <linux/clk.h> | ||
32 | #include <linux/io.h> | ||
33 | #include <linux/gpio.h> | ||
34 | |||
35 | #include <asm/dma.h> | ||
36 | #include <asm/irq.h> | ||
37 | #include <asm/sizes.h> | ||
38 | #include <mach/mmc.h> | ||
39 | |||
40 | #ifdef CONFIG_ARCH_MX2 | ||
41 | #include <mach/dma-mx1-mx2.h> | ||
42 | #define HAS_DMA | ||
43 | #endif | ||
44 | |||
45 | #define DRIVER_NAME "imx-mmc" | ||
46 | |||
47 | #define MMC_REG_STR_STP_CLK 0x00 | ||
48 | #define MMC_REG_STATUS 0x04 | ||
49 | #define MMC_REG_CLK_RATE 0x08 | ||
50 | #define MMC_REG_CMD_DAT_CONT 0x0C | ||
51 | #define MMC_REG_RES_TO 0x10 | ||
52 | #define MMC_REG_READ_TO 0x14 | ||
53 | #define MMC_REG_BLK_LEN 0x18 | ||
54 | #define MMC_REG_NOB 0x1C | ||
55 | #define MMC_REG_REV_NO 0x20 | ||
56 | #define MMC_REG_INT_CNTR 0x24 | ||
57 | #define MMC_REG_CMD 0x28 | ||
58 | #define MMC_REG_ARG 0x2C | ||
59 | #define MMC_REG_RES_FIFO 0x34 | ||
60 | #define MMC_REG_BUFFER_ACCESS 0x38 | ||
61 | |||
62 | #define STR_STP_CLK_RESET (1 << 3) | ||
63 | #define STR_STP_CLK_START_CLK (1 << 1) | ||
64 | #define STR_STP_CLK_STOP_CLK (1 << 0) | ||
65 | |||
66 | #define STATUS_CARD_INSERTION (1 << 31) | ||
67 | #define STATUS_CARD_REMOVAL (1 << 30) | ||
68 | #define STATUS_YBUF_EMPTY (1 << 29) | ||
69 | #define STATUS_XBUF_EMPTY (1 << 28) | ||
70 | #define STATUS_YBUF_FULL (1 << 27) | ||
71 | #define STATUS_XBUF_FULL (1 << 26) | ||
72 | #define STATUS_BUF_UND_RUN (1 << 25) | ||
73 | #define STATUS_BUF_OVFL (1 << 24) | ||
74 | #define STATUS_SDIO_INT_ACTIVE (1 << 14) | ||
75 | #define STATUS_END_CMD_RESP (1 << 13) | ||
76 | #define STATUS_WRITE_OP_DONE (1 << 12) | ||
77 | #define STATUS_DATA_TRANS_DONE (1 << 11) | ||
78 | #define STATUS_READ_OP_DONE (1 << 11) | ||
79 | #define STATUS_WR_CRC_ERROR_CODE_MASK (3 << 10) | ||
80 | #define STATUS_CARD_BUS_CLK_RUN (1 << 8) | ||
81 | #define STATUS_BUF_READ_RDY (1 << 7) | ||
82 | #define STATUS_BUF_WRITE_RDY (1 << 6) | ||
83 | #define STATUS_RESP_CRC_ERR (1 << 5) | ||
84 | #define STATUS_CRC_READ_ERR (1 << 3) | ||
85 | #define STATUS_CRC_WRITE_ERR (1 << 2) | ||
86 | #define STATUS_TIME_OUT_RESP (1 << 1) | ||
87 | #define STATUS_TIME_OUT_READ (1 << 0) | ||
88 | #define STATUS_ERR_MASK 0x2f | ||
89 | |||
90 | #define CMD_DAT_CONT_CMD_RESP_LONG_OFF (1 << 12) | ||
91 | #define CMD_DAT_CONT_STOP_READWAIT (1 << 11) | ||
92 | #define CMD_DAT_CONT_START_READWAIT (1 << 10) | ||
93 | #define CMD_DAT_CONT_BUS_WIDTH_4 (2 << 8) | ||
94 | #define CMD_DAT_CONT_INIT (1 << 7) | ||
95 | #define CMD_DAT_CONT_WRITE (1 << 4) | ||
96 | #define CMD_DAT_CONT_DATA_ENABLE (1 << 3) | ||
97 | #define CMD_DAT_CONT_RESPONSE_48BIT_CRC (1 << 0) | ||
98 | #define CMD_DAT_CONT_RESPONSE_136BIT (2 << 0) | ||
99 | #define CMD_DAT_CONT_RESPONSE_48BIT (3 << 0) | ||
100 | |||
101 | #define INT_SDIO_INT_WKP_EN (1 << 18) | ||
102 | #define INT_CARD_INSERTION_WKP_EN (1 << 17) | ||
103 | #define INT_CARD_REMOVAL_WKP_EN (1 << 16) | ||
104 | #define INT_CARD_INSERTION_EN (1 << 15) | ||
105 | #define INT_CARD_REMOVAL_EN (1 << 14) | ||
106 | #define INT_SDIO_IRQ_EN (1 << 13) | ||
107 | #define INT_DAT0_EN (1 << 12) | ||
108 | #define INT_BUF_READ_EN (1 << 4) | ||
109 | #define INT_BUF_WRITE_EN (1 << 3) | ||
110 | #define INT_END_CMD_RES_EN (1 << 2) | ||
111 | #define INT_WRITE_OP_DONE_EN (1 << 1) | ||
112 | #define INT_READ_OP_EN (1 << 0) | ||
113 | |||
114 | struct mxcmci_host { | ||
115 | struct mmc_host *mmc; | ||
116 | struct resource *res; | ||
117 | void __iomem *base; | ||
118 | int irq; | ||
119 | int detect_irq; | ||
120 | int dma; | ||
121 | int do_dma; | ||
122 | unsigned int power_mode; | ||
123 | struct imxmmc_platform_data *pdata; | ||
124 | |||
125 | struct mmc_request *req; | ||
126 | struct mmc_command *cmd; | ||
127 | struct mmc_data *data; | ||
128 | |||
129 | unsigned int dma_nents; | ||
130 | unsigned int datasize; | ||
131 | unsigned int dma_dir; | ||
132 | |||
133 | u16 rev_no; | ||
134 | unsigned int cmdat; | ||
135 | |||
136 | struct clk *clk; | ||
137 | |||
138 | int clock; | ||
139 | |||
140 | struct work_struct datawork; | ||
141 | }; | ||
142 | |||
143 | static inline int mxcmci_use_dma(struct mxcmci_host *host) | ||
144 | { | ||
145 | return host->do_dma; | ||
146 | } | ||
147 | |||
148 | static void mxcmci_softreset(struct mxcmci_host *host) | ||
149 | { | ||
150 | int i; | ||
151 | |||
152 | /* reset sequence */ | ||
153 | writew(STR_STP_CLK_RESET, host->base + MMC_REG_STR_STP_CLK); | ||
154 | writew(STR_STP_CLK_RESET | STR_STP_CLK_START_CLK, | ||
155 | host->base + MMC_REG_STR_STP_CLK); | ||
156 | |||
157 | for (i = 0; i < 8; i++) | ||
158 | writew(STR_STP_CLK_START_CLK, host->base + MMC_REG_STR_STP_CLK); | ||
159 | |||
160 | writew(0xff, host->base + MMC_REG_RES_TO); | ||
161 | } | ||
162 | |||
163 | static void mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data) | ||
164 | { | ||
165 | unsigned int nob = data->blocks; | ||
166 | unsigned int blksz = data->blksz; | ||
167 | unsigned int datasize = nob * blksz; | ||
168 | #ifdef HAS_DMA | ||
169 | struct scatterlist *sg; | ||
170 | int i; | ||
171 | #endif | ||
172 | if (data->flags & MMC_DATA_STREAM) | ||
173 | nob = 0xffff; | ||
174 | |||
175 | host->data = data; | ||
176 | data->bytes_xfered = 0; | ||
177 | |||
178 | writew(nob, host->base + MMC_REG_NOB); | ||
179 | writew(blksz, host->base + MMC_REG_BLK_LEN); | ||
180 | host->datasize = datasize; | ||
181 | |||
182 | #ifdef HAS_DMA | ||
183 | for_each_sg(data->sg, sg, data->sg_len, i) { | ||
184 | if (sg->offset & 3 || sg->length & 3) { | ||
185 | host->do_dma = 0; | ||
186 | return; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | if (data->flags & MMC_DATA_READ) { | ||
191 | host->dma_dir = DMA_FROM_DEVICE; | ||
192 | host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg, | ||
193 | data->sg_len, host->dma_dir); | ||
194 | |||
195 | imx_dma_setup_sg(host->dma, data->sg, host->dma_nents, datasize, | ||
196 | host->res->start + MMC_REG_BUFFER_ACCESS, | ||
197 | DMA_MODE_READ); | ||
198 | } else { | ||
199 | host->dma_dir = DMA_TO_DEVICE; | ||
200 | host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg, | ||
201 | data->sg_len, host->dma_dir); | ||
202 | |||
203 | imx_dma_setup_sg(host->dma, data->sg, host->dma_nents, datasize, | ||
204 | host->res->start + MMC_REG_BUFFER_ACCESS, | ||
205 | DMA_MODE_WRITE); | ||
206 | } | ||
207 | |||
208 | wmb(); | ||
209 | |||
210 | imx_dma_enable(host->dma); | ||
211 | #endif /* HAS_DMA */ | ||
212 | } | ||
213 | |||
214 | static int mxcmci_start_cmd(struct mxcmci_host *host, struct mmc_command *cmd, | ||
215 | unsigned int cmdat) | ||
216 | { | ||
217 | WARN_ON(host->cmd != NULL); | ||
218 | host->cmd = cmd; | ||
219 | |||
220 | switch (mmc_resp_type(cmd)) { | ||
221 | case MMC_RSP_R1: /* short CRC, OPCODE */ | ||
222 | case MMC_RSP_R1B:/* short CRC, OPCODE, BUSY */ | ||
223 | cmdat |= CMD_DAT_CONT_RESPONSE_48BIT_CRC; | ||
224 | break; | ||
225 | case MMC_RSP_R2: /* long 136 bit + CRC */ | ||
226 | cmdat |= CMD_DAT_CONT_RESPONSE_136BIT; | ||
227 | break; | ||
228 | case MMC_RSP_R3: /* short */ | ||
229 | cmdat |= CMD_DAT_CONT_RESPONSE_48BIT; | ||
230 | break; | ||
231 | case MMC_RSP_NONE: | ||
232 | break; | ||
233 | default: | ||
234 | dev_err(mmc_dev(host->mmc), "unhandled response type 0x%x\n", | ||
235 | mmc_resp_type(cmd)); | ||
236 | cmd->error = -EINVAL; | ||
237 | return -EINVAL; | ||
238 | } | ||
239 | |||
240 | if (mxcmci_use_dma(host)) | ||
241 | writel(INT_READ_OP_EN | INT_WRITE_OP_DONE_EN | | ||
242 | INT_END_CMD_RES_EN, | ||
243 | host->base + MMC_REG_INT_CNTR); | ||
244 | else | ||
245 | writel(INT_END_CMD_RES_EN, host->base + MMC_REG_INT_CNTR); | ||
246 | |||
247 | writew(cmd->opcode, host->base + MMC_REG_CMD); | ||
248 | writel(cmd->arg, host->base + MMC_REG_ARG); | ||
249 | writew(cmdat, host->base + MMC_REG_CMD_DAT_CONT); | ||
250 | |||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static void mxcmci_finish_request(struct mxcmci_host *host, | ||
255 | struct mmc_request *req) | ||
256 | { | ||
257 | writel(0, host->base + MMC_REG_INT_CNTR); | ||
258 | |||
259 | host->req = NULL; | ||
260 | host->cmd = NULL; | ||
261 | host->data = NULL; | ||
262 | |||
263 | mmc_request_done(host->mmc, req); | ||
264 | } | ||
265 | |||
266 | static int mxcmci_finish_data(struct mxcmci_host *host, unsigned int stat) | ||
267 | { | ||
268 | struct mmc_data *data = host->data; | ||
269 | int data_error; | ||
270 | |||
271 | #ifdef HAS_DMA | ||
272 | if (mxcmci_use_dma(host)) { | ||
273 | imx_dma_disable(host->dma); | ||
274 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_nents, | ||
275 | host->dma_dir); | ||
276 | } | ||
277 | #endif | ||
278 | |||
279 | if (stat & STATUS_ERR_MASK) { | ||
280 | dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n", | ||
281 | stat); | ||
282 | if (stat & STATUS_CRC_READ_ERR) { | ||
283 | data->error = -EILSEQ; | ||
284 | } else if (stat & STATUS_CRC_WRITE_ERR) { | ||
285 | u32 err_code = (stat >> 9) & 0x3; | ||
286 | if (err_code == 2) /* No CRC response */ | ||
287 | data->error = -ETIMEDOUT; | ||
288 | else | ||
289 | data->error = -EILSEQ; | ||
290 | } else if (stat & STATUS_TIME_OUT_READ) { | ||
291 | data->error = -ETIMEDOUT; | ||
292 | } else { | ||
293 | data->error = -EIO; | ||
294 | } | ||
295 | } else { | ||
296 | data->bytes_xfered = host->datasize; | ||
297 | } | ||
298 | |||
299 | data_error = data->error; | ||
300 | |||
301 | host->data = NULL; | ||
302 | |||
303 | return data_error; | ||
304 | } | ||
305 | |||
306 | static void mxcmci_read_response(struct mxcmci_host *host, unsigned int stat) | ||
307 | { | ||
308 | struct mmc_command *cmd = host->cmd; | ||
309 | int i; | ||
310 | u32 a, b, c; | ||
311 | |||
312 | if (!cmd) | ||
313 | return; | ||
314 | |||
315 | if (stat & STATUS_TIME_OUT_RESP) { | ||
316 | dev_dbg(mmc_dev(host->mmc), "CMD TIMEOUT\n"); | ||
317 | cmd->error = -ETIMEDOUT; | ||
318 | } else if (stat & STATUS_RESP_CRC_ERR && cmd->flags & MMC_RSP_CRC) { | ||
319 | dev_dbg(mmc_dev(host->mmc), "cmd crc error\n"); | ||
320 | cmd->error = -EILSEQ; | ||
321 | } | ||
322 | |||
323 | if (cmd->flags & MMC_RSP_PRESENT) { | ||
324 | if (cmd->flags & MMC_RSP_136) { | ||
325 | for (i = 0; i < 4; i++) { | ||
326 | a = readw(host->base + MMC_REG_RES_FIFO); | ||
327 | b = readw(host->base + MMC_REG_RES_FIFO); | ||
328 | cmd->resp[i] = a << 16 | b; | ||
329 | } | ||
330 | } else { | ||
331 | a = readw(host->base + MMC_REG_RES_FIFO); | ||
332 | b = readw(host->base + MMC_REG_RES_FIFO); | ||
333 | c = readw(host->base + MMC_REG_RES_FIFO); | ||
334 | cmd->resp[0] = a << 24 | b << 8 | c >> 8; | ||
335 | } | ||
336 | } | ||
337 | } | ||
338 | |||
339 | static int mxcmci_poll_status(struct mxcmci_host *host, u32 mask) | ||
340 | { | ||
341 | u32 stat; | ||
342 | unsigned long timeout = jiffies + HZ; | ||
343 | |||
344 | do { | ||
345 | stat = readl(host->base + MMC_REG_STATUS); | ||
346 | if (stat & STATUS_ERR_MASK) | ||
347 | return stat; | ||
348 | if (time_after(jiffies, timeout)) | ||
349 | return STATUS_TIME_OUT_READ; | ||
350 | if (stat & mask) | ||
351 | return 0; | ||
352 | cpu_relax(); | ||
353 | } while (1); | ||
354 | } | ||
355 | |||
356 | static int mxcmci_pull(struct mxcmci_host *host, void *_buf, int bytes) | ||
357 | { | ||
358 | unsigned int stat; | ||
359 | u32 *buf = _buf; | ||
360 | |||
361 | while (bytes > 3) { | ||
362 | stat = mxcmci_poll_status(host, | ||
363 | STATUS_BUF_READ_RDY | STATUS_READ_OP_DONE); | ||
364 | if (stat) | ||
365 | return stat; | ||
366 | *buf++ = readl(host->base + MMC_REG_BUFFER_ACCESS); | ||
367 | bytes -= 4; | ||
368 | } | ||
369 | |||
370 | if (bytes) { | ||
371 | u8 *b = (u8 *)buf; | ||
372 | u32 tmp; | ||
373 | |||
374 | stat = mxcmci_poll_status(host, | ||
375 | STATUS_BUF_READ_RDY | STATUS_READ_OP_DONE); | ||
376 | if (stat) | ||
377 | return stat; | ||
378 | tmp = readl(host->base + MMC_REG_BUFFER_ACCESS); | ||
379 | memcpy(b, &tmp, bytes); | ||
380 | } | ||
381 | |||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | static int mxcmci_push(struct mxcmci_host *host, void *_buf, int bytes) | ||
386 | { | ||
387 | unsigned int stat; | ||
388 | u32 *buf = _buf; | ||
389 | |||
390 | while (bytes > 3) { | ||
391 | stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY); | ||
392 | if (stat) | ||
393 | return stat; | ||
394 | writel(*buf++, host->base + MMC_REG_BUFFER_ACCESS); | ||
395 | bytes -= 4; | ||
396 | } | ||
397 | |||
398 | if (bytes) { | ||
399 | u8 *b = (u8 *)buf; | ||
400 | u32 tmp; | ||
401 | |||
402 | stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY); | ||
403 | if (stat) | ||
404 | return stat; | ||
405 | |||
406 | memcpy(&tmp, b, bytes); | ||
407 | writel(tmp, host->base + MMC_REG_BUFFER_ACCESS); | ||
408 | } | ||
409 | |||
410 | stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY); | ||
411 | if (stat) | ||
412 | return stat; | ||
413 | |||
414 | return 0; | ||
415 | } | ||
416 | |||
417 | static int mxcmci_transfer_data(struct mxcmci_host *host) | ||
418 | { | ||
419 | struct mmc_data *data = host->req->data; | ||
420 | struct scatterlist *sg; | ||
421 | int stat, i; | ||
422 | |||
423 | host->datasize = 0; | ||
424 | |||
425 | host->data = data; | ||
426 | host->datasize = 0; | ||
427 | |||
428 | if (data->flags & MMC_DATA_READ) { | ||
429 | for_each_sg(data->sg, sg, data->sg_len, i) { | ||
430 | stat = mxcmci_pull(host, sg_virt(sg), sg->length); | ||
431 | if (stat) | ||
432 | return stat; | ||
433 | host->datasize += sg->length; | ||
434 | } | ||
435 | } else { | ||
436 | for_each_sg(data->sg, sg, data->sg_len, i) { | ||
437 | stat = mxcmci_push(host, sg_virt(sg), sg->length); | ||
438 | if (stat) | ||
439 | return stat; | ||
440 | host->datasize += sg->length; | ||
441 | } | ||
442 | stat = mxcmci_poll_status(host, STATUS_WRITE_OP_DONE); | ||
443 | if (stat) | ||
444 | return stat; | ||
445 | } | ||
446 | return 0; | ||
447 | } | ||
448 | |||
449 | static void mxcmci_datawork(struct work_struct *work) | ||
450 | { | ||
451 | struct mxcmci_host *host = container_of(work, struct mxcmci_host, | ||
452 | datawork); | ||
453 | int datastat = mxcmci_transfer_data(host); | ||
454 | mxcmci_finish_data(host, datastat); | ||
455 | |||
456 | if (host->req->stop) { | ||
457 | if (mxcmci_start_cmd(host, host->req->stop, 0)) { | ||
458 | mxcmci_finish_request(host, host->req); | ||
459 | return; | ||
460 | } | ||
461 | } else { | ||
462 | mxcmci_finish_request(host, host->req); | ||
463 | } | ||
464 | } | ||
465 | |||
466 | #ifdef HAS_DMA | ||
467 | static void mxcmci_data_done(struct mxcmci_host *host, unsigned int stat) | ||
468 | { | ||
469 | struct mmc_data *data = host->data; | ||
470 | int data_error; | ||
471 | |||
472 | if (!data) | ||
473 | return; | ||
474 | |||
475 | data_error = mxcmci_finish_data(host, stat); | ||
476 | |||
477 | mxcmci_read_response(host, stat); | ||
478 | host->cmd = NULL; | ||
479 | |||
480 | if (host->req->stop) { | ||
481 | if (mxcmci_start_cmd(host, host->req->stop, 0)) { | ||
482 | mxcmci_finish_request(host, host->req); | ||
483 | return; | ||
484 | } | ||
485 | } else { | ||
486 | mxcmci_finish_request(host, host->req); | ||
487 | } | ||
488 | } | ||
489 | #endif /* HAS_DMA */ | ||
490 | |||
491 | static void mxcmci_cmd_done(struct mxcmci_host *host, unsigned int stat) | ||
492 | { | ||
493 | mxcmci_read_response(host, stat); | ||
494 | host->cmd = NULL; | ||
495 | |||
496 | if (!host->data && host->req) { | ||
497 | mxcmci_finish_request(host, host->req); | ||
498 | return; | ||
499 | } | ||
500 | |||
501 | /* For the DMA case the DMA engine handles the data transfer | ||
502 | * automatically. For non DMA we have to to it ourselves. | ||
503 | * Don't do it in interrupt context though. | ||
504 | */ | ||
505 | if (!mxcmci_use_dma(host) && host->data) | ||
506 | schedule_work(&host->datawork); | ||
507 | |||
508 | } | ||
509 | |||
510 | static irqreturn_t mxcmci_irq(int irq, void *devid) | ||
511 | { | ||
512 | struct mxcmci_host *host = devid; | ||
513 | u32 stat; | ||
514 | |||
515 | stat = readl(host->base + MMC_REG_STATUS); | ||
516 | writel(stat, host->base + MMC_REG_STATUS); | ||
517 | |||
518 | dev_dbg(mmc_dev(host->mmc), "%s: 0x%08x\n", __func__, stat); | ||
519 | |||
520 | if (stat & STATUS_END_CMD_RESP) | ||
521 | mxcmci_cmd_done(host, stat); | ||
522 | #ifdef HAS_DMA | ||
523 | if (mxcmci_use_dma(host) && | ||
524 | (stat & (STATUS_DATA_TRANS_DONE | STATUS_WRITE_OP_DONE))) | ||
525 | mxcmci_data_done(host, stat); | ||
526 | #endif | ||
527 | return IRQ_HANDLED; | ||
528 | } | ||
529 | |||
530 | static void mxcmci_request(struct mmc_host *mmc, struct mmc_request *req) | ||
531 | { | ||
532 | struct mxcmci_host *host = mmc_priv(mmc); | ||
533 | unsigned int cmdat = host->cmdat; | ||
534 | |||
535 | WARN_ON(host->req != NULL); | ||
536 | |||
537 | host->req = req; | ||
538 | host->cmdat &= ~CMD_DAT_CONT_INIT; | ||
539 | #ifdef HAS_DMA | ||
540 | host->do_dma = 1; | ||
541 | #endif | ||
542 | if (req->data) { | ||
543 | mxcmci_setup_data(host, req->data); | ||
544 | |||
545 | cmdat |= CMD_DAT_CONT_DATA_ENABLE; | ||
546 | |||
547 | if (req->data->flags & MMC_DATA_WRITE) | ||
548 | cmdat |= CMD_DAT_CONT_WRITE; | ||
549 | } | ||
550 | |||
551 | if (mxcmci_start_cmd(host, req->cmd, cmdat)) | ||
552 | mxcmci_finish_request(host, req); | ||
553 | } | ||
554 | |||
555 | static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios) | ||
556 | { | ||
557 | unsigned int divider; | ||
558 | int prescaler = 0; | ||
559 | unsigned int clk_in = clk_get_rate(host->clk); | ||
560 | |||
561 | while (prescaler <= 0x800) { | ||
562 | for (divider = 1; divider <= 0xF; divider++) { | ||
563 | int x; | ||
564 | |||
565 | x = (clk_in / (divider + 1)); | ||
566 | |||
567 | if (prescaler) | ||
568 | x /= (prescaler * 2); | ||
569 | |||
570 | if (x <= clk_ios) | ||
571 | break; | ||
572 | } | ||
573 | if (divider < 0x10) | ||
574 | break; | ||
575 | |||
576 | if (prescaler == 0) | ||
577 | prescaler = 1; | ||
578 | else | ||
579 | prescaler <<= 1; | ||
580 | } | ||
581 | |||
582 | writew((prescaler << 4) | divider, host->base + MMC_REG_CLK_RATE); | ||
583 | |||
584 | dev_dbg(mmc_dev(host->mmc), "scaler: %d divider: %d in: %d out: %d\n", | ||
585 | prescaler, divider, clk_in, clk_ios); | ||
586 | } | ||
587 | |||
588 | static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | ||
589 | { | ||
590 | struct mxcmci_host *host = mmc_priv(mmc); | ||
591 | #ifdef HAS_DMA | ||
592 | unsigned int blen; | ||
593 | /* | ||
594 | * use burstlen of 64 in 4 bit mode (--> reg value 0) | ||
595 | * use burstlen of 16 in 1 bit mode (--> reg value 16) | ||
596 | */ | ||
597 | if (ios->bus_width == MMC_BUS_WIDTH_4) | ||
598 | blen = 0; | ||
599 | else | ||
600 | blen = 16; | ||
601 | |||
602 | imx_dma_config_burstlen(host->dma, blen); | ||
603 | #endif | ||
604 | if (ios->bus_width == MMC_BUS_WIDTH_4) | ||
605 | host->cmdat |= CMD_DAT_CONT_BUS_WIDTH_4; | ||
606 | else | ||
607 | host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4; | ||
608 | |||
609 | if (host->power_mode != ios->power_mode) { | ||
610 | if (host->pdata && host->pdata->setpower) | ||
611 | host->pdata->setpower(mmc_dev(mmc), ios->vdd); | ||
612 | host->power_mode = ios->power_mode; | ||
613 | if (ios->power_mode == MMC_POWER_ON) | ||
614 | host->cmdat |= CMD_DAT_CONT_INIT; | ||
615 | } | ||
616 | |||
617 | if (ios->clock) { | ||
618 | mxcmci_set_clk_rate(host, ios->clock); | ||
619 | writew(STR_STP_CLK_START_CLK, host->base + MMC_REG_STR_STP_CLK); | ||
620 | } else { | ||
621 | writew(STR_STP_CLK_STOP_CLK, host->base + MMC_REG_STR_STP_CLK); | ||
622 | } | ||
623 | |||
624 | host->clock = ios->clock; | ||
625 | } | ||
626 | |||
627 | static irqreturn_t mxcmci_detect_irq(int irq, void *data) | ||
628 | { | ||
629 | struct mmc_host *mmc = data; | ||
630 | |||
631 | dev_dbg(mmc_dev(mmc), "%s\n", __func__); | ||
632 | |||
633 | mmc_detect_change(mmc, msecs_to_jiffies(250)); | ||
634 | return IRQ_HANDLED; | ||
635 | } | ||
636 | |||
637 | static int mxcmci_get_ro(struct mmc_host *mmc) | ||
638 | { | ||
639 | struct mxcmci_host *host = mmc_priv(mmc); | ||
640 | |||
641 | if (host->pdata && host->pdata->get_ro) | ||
642 | return !!host->pdata->get_ro(mmc_dev(mmc)); | ||
643 | /* | ||
644 | * Board doesn't support read only detection; let the mmc core | ||
645 | * decide what to do. | ||
646 | */ | ||
647 | return -ENOSYS; | ||
648 | } | ||
649 | |||
650 | |||
651 | static const struct mmc_host_ops mxcmci_ops = { | ||
652 | .request = mxcmci_request, | ||
653 | .set_ios = mxcmci_set_ios, | ||
654 | .get_ro = mxcmci_get_ro, | ||
655 | }; | ||
656 | |||
657 | static int mxcmci_probe(struct platform_device *pdev) | ||
658 | { | ||
659 | struct mmc_host *mmc; | ||
660 | struct mxcmci_host *host = NULL; | ||
661 | struct resource *r; | ||
662 | int ret = 0, irq; | ||
663 | |||
664 | printk(KERN_INFO "i.MX SDHC driver\n"); | ||
665 | |||
666 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
667 | irq = platform_get_irq(pdev, 0); | ||
668 | if (!r || irq < 0) | ||
669 | return -EINVAL; | ||
670 | |||
671 | r = request_mem_region(r->start, resource_size(r), pdev->name); | ||
672 | if (!r) | ||
673 | return -EBUSY; | ||
674 | |||
675 | mmc = mmc_alloc_host(sizeof(struct mxcmci_host), &pdev->dev); | ||
676 | if (!mmc) { | ||
677 | ret = -ENOMEM; | ||
678 | goto out_release_mem; | ||
679 | } | ||
680 | |||
681 | mmc->ops = &mxcmci_ops; | ||
682 | mmc->caps = MMC_CAP_4_BIT_DATA; | ||
683 | |||
684 | /* MMC core transfer sizes tunable parameters */ | ||
685 | mmc->max_hw_segs = 64; | ||
686 | mmc->max_phys_segs = 64; | ||
687 | mmc->max_blk_size = 2048; | ||
688 | mmc->max_blk_count = 65535; | ||
689 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; | ||
690 | mmc->max_seg_size = mmc->max_seg_size; | ||
691 | |||
692 | host = mmc_priv(mmc); | ||
693 | host->base = ioremap(r->start, resource_size(r)); | ||
694 | if (!host->base) { | ||
695 | ret = -ENOMEM; | ||
696 | goto out_free; | ||
697 | } | ||
698 | |||
699 | host->mmc = mmc; | ||
700 | host->pdata = pdev->dev.platform_data; | ||
701 | |||
702 | if (host->pdata && host->pdata->ocr_avail) | ||
703 | mmc->ocr_avail = host->pdata->ocr_avail; | ||
704 | else | ||
705 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; | ||
706 | |||
707 | host->res = r; | ||
708 | host->irq = irq; | ||
709 | |||
710 | host->clk = clk_get(&pdev->dev, "sdhc_clk"); | ||
711 | if (IS_ERR(host->clk)) { | ||
712 | ret = PTR_ERR(host->clk); | ||
713 | goto out_iounmap; | ||
714 | } | ||
715 | clk_enable(host->clk); | ||
716 | |||
717 | mxcmci_softreset(host); | ||
718 | |||
719 | host->rev_no = readw(host->base + MMC_REG_REV_NO); | ||
720 | if (host->rev_no != 0x400) { | ||
721 | ret = -ENODEV; | ||
722 | dev_err(mmc_dev(host->mmc), "wrong rev.no. 0x%08x. aborting.\n", | ||
723 | host->rev_no); | ||
724 | goto out_clk_put; | ||
725 | } | ||
726 | |||
727 | mmc->f_min = clk_get_rate(host->clk) >> 7; | ||
728 | mmc->f_max = clk_get_rate(host->clk) >> 1; | ||
729 | |||
730 | /* recommended in data sheet */ | ||
731 | writew(0x2db4, host->base + MMC_REG_READ_TO); | ||
732 | |||
733 | writel(0, host->base + MMC_REG_INT_CNTR); | ||
734 | |||
735 | #ifdef HAS_DMA | ||
736 | host->dma = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_LOW); | ||
737 | if (host->dma < 0) { | ||
738 | dev_err(mmc_dev(host->mmc), "imx_dma_request_by_prio failed\n"); | ||
739 | ret = -EBUSY; | ||
740 | goto out_clk_put; | ||
741 | } | ||
742 | |||
743 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
744 | if (!r) { | ||
745 | ret = -EINVAL; | ||
746 | goto out_free_dma; | ||
747 | } | ||
748 | |||
749 | ret = imx_dma_config_channel(host->dma, | ||
750 | IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_FIFO, | ||
751 | IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR, | ||
752 | r->start, 0); | ||
753 | if (ret) { | ||
754 | dev_err(mmc_dev(host->mmc), "failed to config DMA channel\n"); | ||
755 | goto out_free_dma; | ||
756 | } | ||
757 | #endif | ||
758 | INIT_WORK(&host->datawork, mxcmci_datawork); | ||
759 | |||
760 | ret = request_irq(host->irq, mxcmci_irq, 0, DRIVER_NAME, host); | ||
761 | if (ret) | ||
762 | goto out_free_dma; | ||
763 | |||
764 | platform_set_drvdata(pdev, mmc); | ||
765 | |||
766 | if (host->pdata && host->pdata->init) { | ||
767 | ret = host->pdata->init(&pdev->dev, mxcmci_detect_irq, | ||
768 | host->mmc); | ||
769 | if (ret) | ||
770 | goto out_free_irq; | ||
771 | } | ||
772 | |||
773 | mmc_add_host(mmc); | ||
774 | |||
775 | return 0; | ||
776 | |||
777 | out_free_irq: | ||
778 | free_irq(host->irq, host); | ||
779 | out_free_dma: | ||
780 | #ifdef HAS_DMA | ||
781 | imx_dma_free(host->dma); | ||
782 | #endif | ||
783 | out_clk_put: | ||
784 | clk_disable(host->clk); | ||
785 | clk_put(host->clk); | ||
786 | out_iounmap: | ||
787 | iounmap(host->base); | ||
788 | out_free: | ||
789 | mmc_free_host(mmc); | ||
790 | out_release_mem: | ||
791 | release_mem_region(host->res->start, resource_size(host->res)); | ||
792 | return ret; | ||
793 | } | ||
794 | |||
795 | static int mxcmci_remove(struct platform_device *pdev) | ||
796 | { | ||
797 | struct mmc_host *mmc = platform_get_drvdata(pdev); | ||
798 | struct mxcmci_host *host = mmc_priv(mmc); | ||
799 | |||
800 | platform_set_drvdata(pdev, NULL); | ||
801 | |||
802 | mmc_remove_host(mmc); | ||
803 | |||
804 | if (host->pdata && host->pdata->exit) | ||
805 | host->pdata->exit(&pdev->dev, mmc); | ||
806 | |||
807 | free_irq(host->irq, host); | ||
808 | iounmap(host->base); | ||
809 | #ifdef HAS_DMA | ||
810 | imx_dma_free(host->dma); | ||
811 | #endif | ||
812 | clk_disable(host->clk); | ||
813 | clk_put(host->clk); | ||
814 | |||
815 | release_mem_region(host->res->start, resource_size(host->res)); | ||
816 | release_resource(host->res); | ||
817 | |||
818 | mmc_free_host(mmc); | ||
819 | |||
820 | return 0; | ||
821 | } | ||
822 | |||
823 | #ifdef CONFIG_PM | ||
824 | static int mxcmci_suspend(struct platform_device *dev, pm_message_t state) | ||
825 | { | ||
826 | struct mmc_host *mmc = platform_get_drvdata(dev); | ||
827 | int ret = 0; | ||
828 | |||
829 | if (mmc) | ||
830 | ret = mmc_suspend_host(mmc, state); | ||
831 | |||
832 | return ret; | ||
833 | } | ||
834 | |||
835 | static int mxcmci_resume(struct platform_device *dev) | ||
836 | { | ||
837 | struct mmc_host *mmc = platform_get_drvdata(dev); | ||
838 | struct mxcmci_host *host; | ||
839 | int ret = 0; | ||
840 | |||
841 | if (mmc) { | ||
842 | host = mmc_priv(mmc); | ||
843 | ret = mmc_resume_host(mmc); | ||
844 | } | ||
845 | |||
846 | return ret; | ||
847 | } | ||
848 | #else | ||
849 | #define mxcmci_suspend NULL | ||
850 | #define mxcmci_resume NULL | ||
851 | #endif /* CONFIG_PM */ | ||
852 | |||
853 | static struct platform_driver mxcmci_driver = { | ||
854 | .probe = mxcmci_probe, | ||
855 | .remove = mxcmci_remove, | ||
856 | .suspend = mxcmci_suspend, | ||
857 | .resume = mxcmci_resume, | ||
858 | .driver = { | ||
859 | .name = DRIVER_NAME, | ||
860 | .owner = THIS_MODULE, | ||
861 | } | ||
862 | }; | ||
863 | |||
864 | static int __init mxcmci_init(void) | ||
865 | { | ||
866 | return platform_driver_register(&mxcmci_driver); | ||
867 | } | ||
868 | |||
869 | static void __exit mxcmci_exit(void) | ||
870 | { | ||
871 | platform_driver_unregister(&mxcmci_driver); | ||
872 | } | ||
873 | |||
874 | module_init(mxcmci_init); | ||
875 | module_exit(mxcmci_exit); | ||
876 | |||
877 | MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver"); | ||
878 | MODULE_AUTHOR("Sascha Hauer, Pengutronix"); | ||
879 | MODULE_LICENSE("GPL"); | ||
880 | MODULE_ALIAS("platform:imx-mmc"); | ||
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index 3c5483b75da4..9702ad3774cf 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -180,7 +180,15 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) | |||
180 | else | 180 | else |
181 | DALGN &= ~(1 << host->dma); | 181 | DALGN &= ~(1 << host->dma); |
182 | DDADR(host->dma) = host->sg_dma; | 182 | DDADR(host->dma) = host->sg_dma; |
183 | DCSR(host->dma) = DCSR_RUN; | 183 | |
184 | /* | ||
185 | * workaround for erratum #91: | ||
186 | * only start DMA now if we are doing a read, | ||
187 | * otherwise we wait until CMD/RESP has finished | ||
188 | * before starting DMA. | ||
189 | */ | ||
190 | if (!cpu_is_pxa27x() || data->flags & MMC_DATA_READ) | ||
191 | DCSR(host->dma) = DCSR_RUN; | ||
184 | } | 192 | } |
185 | 193 | ||
186 | static void pxamci_start_cmd(struct pxamci_host *host, struct mmc_command *cmd, unsigned int cmdat) | 194 | static void pxamci_start_cmd(struct pxamci_host *host, struct mmc_command *cmd, unsigned int cmdat) |
@@ -251,23 +259,28 @@ static int pxamci_cmd_done(struct pxamci_host *host, unsigned int stat) | |||
251 | if (stat & STAT_TIME_OUT_RESPONSE) { | 259 | if (stat & STAT_TIME_OUT_RESPONSE) { |
252 | cmd->error = -ETIMEDOUT; | 260 | cmd->error = -ETIMEDOUT; |
253 | } else if (stat & STAT_RES_CRC_ERR && cmd->flags & MMC_RSP_CRC) { | 261 | } else if (stat & STAT_RES_CRC_ERR && cmd->flags & MMC_RSP_CRC) { |
254 | #ifdef CONFIG_PXA27x | ||
255 | /* | 262 | /* |
256 | * workaround for erratum #42: | 263 | * workaround for erratum #42: |
257 | * Intel PXA27x Family Processor Specification Update Rev 001 | 264 | * Intel PXA27x Family Processor Specification Update Rev 001 |
258 | * A bogus CRC error can appear if the msb of a 136 bit | 265 | * A bogus CRC error can appear if the msb of a 136 bit |
259 | * response is a one. | 266 | * response is a one. |
260 | */ | 267 | */ |
261 | if (cmd->flags & MMC_RSP_136 && cmd->resp[0] & 0x80000000) { | 268 | if (cpu_is_pxa27x() && |
269 | (cmd->flags & MMC_RSP_136 && cmd->resp[0] & 0x80000000)) | ||
262 | pr_debug("ignoring CRC from command %d - *risky*\n", cmd->opcode); | 270 | pr_debug("ignoring CRC from command %d - *risky*\n", cmd->opcode); |
263 | } else | 271 | else |
264 | #endif | 272 | cmd->error = -EILSEQ; |
265 | cmd->error = -EILSEQ; | ||
266 | } | 273 | } |
267 | 274 | ||
268 | pxamci_disable_irq(host, END_CMD_RES); | 275 | pxamci_disable_irq(host, END_CMD_RES); |
269 | if (host->data && !cmd->error) { | 276 | if (host->data && !cmd->error) { |
270 | pxamci_enable_irq(host, DATA_TRAN_DONE); | 277 | pxamci_enable_irq(host, DATA_TRAN_DONE); |
278 | /* | ||
279 | * workaround for erratum #91, if doing write | ||
280 | * enable DMA late | ||
281 | */ | ||
282 | if (cpu_is_pxa27x() && host->data->flags & MMC_DATA_WRITE) | ||
283 | DCSR(host->dma) = DCSR_RUN; | ||
271 | } else { | 284 | } else { |
272 | pxamci_finish_request(host, host->mrq); | 285 | pxamci_finish_request(host, host->mrq); |
273 | } | 286 | } |
diff --git a/drivers/mmc/host/ricoh_mmc.c b/drivers/mmc/host/ricoh_mmc.c index be9e7b32b34e..f62790513322 100644 --- a/drivers/mmc/host/ricoh_mmc.c +++ b/drivers/mmc/host/ricoh_mmc.c | |||
@@ -196,7 +196,7 @@ static void __devexit ricoh_mmc_remove(struct pci_dev *pdev) | |||
196 | pci_set_drvdata(pdev, NULL); | 196 | pci_set_drvdata(pdev, NULL); |
197 | } | 197 | } |
198 | 198 | ||
199 | static int ricoh_mmc_suspend(struct pci_dev *pdev, pm_message_t state) | 199 | static int ricoh_mmc_suspend_late(struct pci_dev *pdev, pm_message_t state) |
200 | { | 200 | { |
201 | struct pci_dev *fw_dev = NULL; | 201 | struct pci_dev *fw_dev = NULL; |
202 | 202 | ||
@@ -210,7 +210,7 @@ static int ricoh_mmc_suspend(struct pci_dev *pdev, pm_message_t state) | |||
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | static int ricoh_mmc_resume(struct pci_dev *pdev) | 213 | static int ricoh_mmc_resume_early(struct pci_dev *pdev) |
214 | { | 214 | { |
215 | struct pci_dev *fw_dev = NULL; | 215 | struct pci_dev *fw_dev = NULL; |
216 | 216 | ||
@@ -229,8 +229,8 @@ static struct pci_driver ricoh_mmc_driver = { | |||
229 | .id_table = pci_ids, | 229 | .id_table = pci_ids, |
230 | .probe = ricoh_mmc_probe, | 230 | .probe = ricoh_mmc_probe, |
231 | .remove = __devexit_p(ricoh_mmc_remove), | 231 | .remove = __devexit_p(ricoh_mmc_remove), |
232 | .suspend = ricoh_mmc_suspend, | 232 | .suspend_late = ricoh_mmc_suspend_late, |
233 | .resume = ricoh_mmc_resume, | 233 | .resume_early = ricoh_mmc_resume_early, |
234 | }; | 234 | }; |
235 | 235 | ||
236 | /*****************************************************************************\ | 236 | /*****************************************************************************\ |
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index 7df6bbf0e4d9..6f6a0f6dafd6 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c | |||
@@ -453,7 +453,7 @@ static struct platform_driver sa1100_mtd_driver = { | |||
453 | .resume = sa1100_mtd_resume, | 453 | .resume = sa1100_mtd_resume, |
454 | .shutdown = sa1100_mtd_shutdown, | 454 | .shutdown = sa1100_mtd_shutdown, |
455 | .driver = { | 455 | .driver = { |
456 | .name = "flash", | 456 | .name = "sa1100-mtd", |
457 | .owner = THIS_MODULE, | 457 | .owner = THIS_MODULE, |
458 | }, | 458 | }, |
459 | }; | 459 | }; |
@@ -474,4 +474,4 @@ module_exit(sa1100_mtd_exit); | |||
474 | MODULE_AUTHOR("Nicolas Pitre"); | 474 | MODULE_AUTHOR("Nicolas Pitre"); |
475 | MODULE_DESCRIPTION("SA1100 CFI map driver"); | 475 | MODULE_DESCRIPTION("SA1100 CFI map driver"); |
476 | MODULE_LICENSE("GPL"); | 476 | MODULE_LICENSE("GPL"); |
477 | MODULE_ALIAS("platform:flash"); | 477 | MODULE_ALIAS("platform:sa1100-mtd"); |
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c index d15d8b79d8e5..54b52e5b1821 100644 --- a/drivers/net/arm/etherh.c +++ b/drivers/net/arm/etherh.c | |||
@@ -646,7 +646,7 @@ static const struct net_device_ops etherh_netdev_ops = { | |||
646 | .ndo_get_stats = ei_get_stats, | 646 | .ndo_get_stats = ei_get_stats, |
647 | .ndo_set_multicast_list = ei_set_multicast_list, | 647 | .ndo_set_multicast_list = ei_set_multicast_list, |
648 | .ndo_validate_addr = eth_validate_addr, | 648 | .ndo_validate_addr = eth_validate_addr, |
649 | .ndo_set_mac_address = eth_set_mac_addr, | 649 | .ndo_set_mac_address = eth_mac_addr, |
650 | .ndo_change_mtu = eth_change_mtu, | 650 | .ndo_change_mtu = eth_change_mtu, |
651 | #ifdef CONFIG_NET_POLL_CONTROLLER | 651 | #ifdef CONFIG_NET_POLL_CONTROLLER |
652 | .ndo_poll_controller = ei_poll, | 652 | .ndo_poll_controller = ei_poll, |
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c index 840b3d1a22f5..bbbc3bb08aa5 100644 --- a/drivers/net/cassini.c +++ b/drivers/net/cassini.c | |||
@@ -806,7 +806,7 @@ static int cas_reset_mii_phy(struct cas *cp) | |||
806 | 806 | ||
807 | cas_phy_write(cp, MII_BMCR, BMCR_RESET); | 807 | cas_phy_write(cp, MII_BMCR, BMCR_RESET); |
808 | udelay(100); | 808 | udelay(100); |
809 | while (limit--) { | 809 | while (--limit) { |
810 | val = cas_phy_read(cp, MII_BMCR); | 810 | val = cas_phy_read(cp, MII_BMCR); |
811 | if ((val & BMCR_RESET) == 0) | 811 | if ((val & BMCR_RESET) == 0) |
812 | break; | 812 | break; |
@@ -979,7 +979,7 @@ static void cas_phy_init(struct cas *cp) | |||
979 | writel(val, cp->regs + REG_PCS_MII_CTRL); | 979 | writel(val, cp->regs + REG_PCS_MII_CTRL); |
980 | 980 | ||
981 | limit = STOP_TRIES; | 981 | limit = STOP_TRIES; |
982 | while (limit-- > 0) { | 982 | while (--limit > 0) { |
983 | udelay(10); | 983 | udelay(10); |
984 | if ((readl(cp->regs + REG_PCS_MII_CTRL) & | 984 | if ((readl(cp->regs + REG_PCS_MII_CTRL) & |
985 | PCS_MII_RESET) == 0) | 985 | PCS_MII_RESET) == 0) |
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c index 379a1324db4e..d31791f60292 100644 --- a/drivers/net/cxgb3/sge.c +++ b/drivers/net/cxgb3/sge.c | |||
@@ -2276,8 +2276,7 @@ no_mem: | |||
2276 | } else if ((len = ntohl(r->len_cq)) != 0) { | 2276 | } else if ((len = ntohl(r->len_cq)) != 0) { |
2277 | struct sge_fl *fl; | 2277 | struct sge_fl *fl; |
2278 | 2278 | ||
2279 | if (eth) | 2279 | lro &= eth && is_eth_tcp(rss_hi); |
2280 | lro = qs->lro_enabled && is_eth_tcp(rss_hi); | ||
2281 | 2280 | ||
2282 | fl = (len & F_RSPD_FLQ) ? &qs->fl[1] : &qs->fl[0]; | 2281 | fl = (len & F_RSPD_FLQ) ? &qs->fl[1] : &qs->fl[0]; |
2283 | if (fl->use_pages) { | 2282 | if (fl->use_pages) { |
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index c986978ce761..6bd63cc67b3e 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -940,7 +940,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
940 | err = pci_enable_device(pdev); | 940 | err = pci_enable_device(pdev); |
941 | } else { | 941 | } else { |
942 | bars = pci_select_bars(pdev, IORESOURCE_MEM); | 942 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
943 | err = pci_enable_device(pdev); | 943 | err = pci_enable_device_mem(pdev); |
944 | } | 944 | } |
945 | if (err) | 945 | if (err) |
946 | return err; | 946 | return err; |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 3f7eab42aef1..acae2d8cd688 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -351,6 +351,9 @@ static int gfar_probe(struct of_device *ofdev, | |||
351 | /* Reset MAC layer */ | 351 | /* Reset MAC layer */ |
352 | gfar_write(&priv->regs->maccfg1, MACCFG1_SOFT_RESET); | 352 | gfar_write(&priv->regs->maccfg1, MACCFG1_SOFT_RESET); |
353 | 353 | ||
354 | /* We need to delay at least 3 TX clocks */ | ||
355 | udelay(2); | ||
356 | |||
354 | tempval = (MACCFG1_TX_FLOW | MACCFG1_RX_FLOW); | 357 | tempval = (MACCFG1_TX_FLOW | MACCFG1_RX_FLOW); |
355 | gfar_write(&priv->regs->maccfg1, tempval); | 358 | gfar_write(&priv->regs->maccfg1, tempval); |
356 | 359 | ||
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h index b1a83344acc7..eaa86897f5c3 100644 --- a/drivers/net/gianfar.h +++ b/drivers/net/gianfar.h | |||
@@ -312,7 +312,7 @@ extern const char gfar_driver_version[]; | |||
312 | #define ATTRELI_EI(x) (x) | 312 | #define ATTRELI_EI(x) (x) |
313 | 313 | ||
314 | #define BD_LFLAG(flags) ((flags) << 16) | 314 | #define BD_LFLAG(flags) ((flags) << 16) |
315 | #define BD_LENGTH_MASK 0x00ff | 315 | #define BD_LENGTH_MASK 0x0000ffff |
316 | 316 | ||
317 | /* TxBD status field bits */ | 317 | /* TxBD status field bits */ |
318 | #define TXBD_READY 0x8000 | 318 | #define TXBD_READY 0x8000 |
diff --git a/drivers/net/ibm_newemac/phy.c b/drivers/net/ibm_newemac/phy.c index c40cd8df2212..ac9d964e59ec 100644 --- a/drivers/net/ibm_newemac/phy.c +++ b/drivers/net/ibm_newemac/phy.c | |||
@@ -60,7 +60,7 @@ int emac_mii_reset_phy(struct mii_phy *phy) | |||
60 | 60 | ||
61 | udelay(300); | 61 | udelay(300); |
62 | 62 | ||
63 | while (limit--) { | 63 | while (--limit) { |
64 | val = phy_read(phy, MII_BMCR); | 64 | val = phy_read(phy, MII_BMCR); |
65 | if (val >= 0 && (val & BMCR_RESET) == 0) | 65 | if (val >= 0 && (val & BMCR_RESET) == 0) |
66 | break; | 66 | break; |
@@ -84,7 +84,7 @@ int emac_mii_reset_gpcs(struct mii_phy *phy) | |||
84 | 84 | ||
85 | udelay(300); | 85 | udelay(300); |
86 | 86 | ||
87 | while (limit--) { | 87 | while (--limit) { |
88 | val = gpcs_phy_read(phy, MII_BMCR); | 88 | val = gpcs_phy_read(phy, MII_BMCR); |
89 | if (val >= 0 && (val & BMCR_RESET) == 0) | 89 | if (val >= 0 && (val & BMCR_RESET) == 0) |
90 | break; | 90 | break; |
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c index f5e2e7235fcb..13ca73f96ec6 100644 --- a/drivers/net/igb/e1000_82575.c +++ b/drivers/net/igb/e1000_82575.c | |||
@@ -699,11 +699,18 @@ static s32 igb_check_for_link_82575(struct e1000_hw *hw) | |||
699 | 699 | ||
700 | /* SGMII link check is done through the PCS register. */ | 700 | /* SGMII link check is done through the PCS register. */ |
701 | if ((hw->phy.media_type != e1000_media_type_copper) || | 701 | if ((hw->phy.media_type != e1000_media_type_copper) || |
702 | (igb_sgmii_active_82575(hw))) | 702 | (igb_sgmii_active_82575(hw))) { |
703 | ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed, | 703 | ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed, |
704 | &duplex); | 704 | &duplex); |
705 | else | 705 | /* |
706 | * Use this flag to determine if link needs to be checked or | ||
707 | * not. If we have link clear the flag so that we do not | ||
708 | * continue to check for link. | ||
709 | */ | ||
710 | hw->mac.get_link_status = !hw->mac.serdes_has_link; | ||
711 | } else { | ||
706 | ret_val = igb_check_for_copper_link(hw); | 712 | ret_val = igb_check_for_copper_link(hw); |
713 | } | ||
707 | 714 | ||
708 | return ret_val; | 715 | return ret_val; |
709 | } | 716 | } |
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h index 5a27825cc48a..aebef8e48e76 100644 --- a/drivers/net/igb/igb.h +++ b/drivers/net/igb/igb.h | |||
@@ -300,11 +300,10 @@ struct igb_adapter { | |||
300 | 300 | ||
301 | #define IGB_FLAG_HAS_MSI (1 << 0) | 301 | #define IGB_FLAG_HAS_MSI (1 << 0) |
302 | #define IGB_FLAG_MSI_ENABLE (1 << 1) | 302 | #define IGB_FLAG_MSI_ENABLE (1 << 1) |
303 | #define IGB_FLAG_HAS_DCA (1 << 2) | 303 | #define IGB_FLAG_DCA_ENABLED (1 << 2) |
304 | #define IGB_FLAG_DCA_ENABLED (1 << 3) | 304 | #define IGB_FLAG_IN_NETPOLL (1 << 3) |
305 | #define IGB_FLAG_IN_NETPOLL (1 << 5) | 305 | #define IGB_FLAG_QUAD_PORT_A (1 << 4) |
306 | #define IGB_FLAG_QUAD_PORT_A (1 << 6) | 306 | #define IGB_FLAG_NEED_CTX_IDX (1 << 5) |
307 | #define IGB_FLAG_NEED_CTX_IDX (1 << 7) | ||
308 | 307 | ||
309 | enum e1000_state_t { | 308 | enum e1000_state_t { |
310 | __IGB_TESTING, | 309 | __IGB_TESTING, |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index b82b0fb2056c..a50db5398fa5 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -206,10 +206,11 @@ static int __init igb_init_module(void) | |||
206 | 206 | ||
207 | global_quad_port_a = 0; | 207 | global_quad_port_a = 0; |
208 | 208 | ||
209 | ret = pci_register_driver(&igb_driver); | ||
210 | #ifdef CONFIG_IGB_DCA | 209 | #ifdef CONFIG_IGB_DCA |
211 | dca_register_notify(&dca_notifier); | 210 | dca_register_notify(&dca_notifier); |
212 | #endif | 211 | #endif |
212 | |||
213 | ret = pci_register_driver(&igb_driver); | ||
213 | return ret; | 214 | return ret; |
214 | } | 215 | } |
215 | 216 | ||
@@ -1156,11 +1157,10 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1156 | 1157 | ||
1157 | /* set flags */ | 1158 | /* set flags */ |
1158 | switch (hw->mac.type) { | 1159 | switch (hw->mac.type) { |
1159 | case e1000_82576: | ||
1160 | case e1000_82575: | 1160 | case e1000_82575: |
1161 | adapter->flags |= IGB_FLAG_HAS_DCA; | ||
1162 | adapter->flags |= IGB_FLAG_NEED_CTX_IDX; | 1161 | adapter->flags |= IGB_FLAG_NEED_CTX_IDX; |
1163 | break; | 1162 | break; |
1163 | case e1000_82576: | ||
1164 | default: | 1164 | default: |
1165 | break; | 1165 | break; |
1166 | } | 1166 | } |
@@ -1310,8 +1310,7 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1310 | goto err_register; | 1310 | goto err_register; |
1311 | 1311 | ||
1312 | #ifdef CONFIG_IGB_DCA | 1312 | #ifdef CONFIG_IGB_DCA |
1313 | if ((adapter->flags & IGB_FLAG_HAS_DCA) && | 1313 | if (dca_add_requester(&pdev->dev) == 0) { |
1314 | (dca_add_requester(&pdev->dev) == 0)) { | ||
1315 | adapter->flags |= IGB_FLAG_DCA_ENABLED; | 1314 | adapter->flags |= IGB_FLAG_DCA_ENABLED; |
1316 | dev_info(&pdev->dev, "DCA enabled\n"); | 1315 | dev_info(&pdev->dev, "DCA enabled\n"); |
1317 | /* Always use CB2 mode, difference is masked | 1316 | /* Always use CB2 mode, difference is masked |
@@ -1835,11 +1834,11 @@ static void igb_setup_rctl(struct igb_adapter *adapter) | |||
1835 | rctl |= E1000_RCTL_SECRC; | 1834 | rctl |= E1000_RCTL_SECRC; |
1836 | 1835 | ||
1837 | /* | 1836 | /* |
1838 | * disable store bad packets, long packet enable, and clear size bits. | 1837 | * disable store bad packets and clear size bits. |
1839 | */ | 1838 | */ |
1840 | rctl &= ~(E1000_RCTL_SBP | E1000_RCTL_LPE | E1000_RCTL_SZ_256); | 1839 | rctl &= ~(E1000_RCTL_SBP | E1000_RCTL_SZ_256); |
1841 | 1840 | ||
1842 | if (adapter->netdev->mtu > ETH_DATA_LEN) | 1841 | /* enable LPE when to prevent packets larger than max_frame_size */ |
1843 | rctl |= E1000_RCTL_LPE; | 1842 | rctl |= E1000_RCTL_LPE; |
1844 | 1843 | ||
1845 | /* Setup buffer sizes */ | 1844 | /* Setup buffer sizes */ |
@@ -1865,7 +1864,7 @@ static void igb_setup_rctl(struct igb_adapter *adapter) | |||
1865 | */ | 1864 | */ |
1866 | /* allocations using alloc_page take too long for regular MTU | 1865 | /* allocations using alloc_page take too long for regular MTU |
1867 | * so only enable packet split for jumbo frames */ | 1866 | * so only enable packet split for jumbo frames */ |
1868 | if (rctl & E1000_RCTL_LPE) { | 1867 | if (adapter->netdev->mtu > ETH_DATA_LEN) { |
1869 | adapter->rx_ps_hdr_size = IGB_RXBUFFER_128; | 1868 | adapter->rx_ps_hdr_size = IGB_RXBUFFER_128; |
1870 | srrctl |= adapter->rx_ps_hdr_size << | 1869 | srrctl |= adapter->rx_ps_hdr_size << |
1871 | E1000_SRRCTL_BSIZEHDRSIZE_SHIFT; | 1870 | E1000_SRRCTL_BSIZEHDRSIZE_SHIFT; |
@@ -3473,19 +3472,16 @@ static int __igb_notify_dca(struct device *dev, void *data) | |||
3473 | struct e1000_hw *hw = &adapter->hw; | 3472 | struct e1000_hw *hw = &adapter->hw; |
3474 | unsigned long event = *(unsigned long *)data; | 3473 | unsigned long event = *(unsigned long *)data; |
3475 | 3474 | ||
3476 | if (!(adapter->flags & IGB_FLAG_HAS_DCA)) | ||
3477 | goto out; | ||
3478 | |||
3479 | switch (event) { | 3475 | switch (event) { |
3480 | case DCA_PROVIDER_ADD: | 3476 | case DCA_PROVIDER_ADD: |
3481 | /* if already enabled, don't do it again */ | 3477 | /* if already enabled, don't do it again */ |
3482 | if (adapter->flags & IGB_FLAG_DCA_ENABLED) | 3478 | if (adapter->flags & IGB_FLAG_DCA_ENABLED) |
3483 | break; | 3479 | break; |
3484 | adapter->flags |= IGB_FLAG_DCA_ENABLED; | ||
3485 | /* Always use CB2 mode, difference is masked | 3480 | /* Always use CB2 mode, difference is masked |
3486 | * in the CB driver. */ | 3481 | * in the CB driver. */ |
3487 | wr32(E1000_DCA_CTRL, 2); | 3482 | wr32(E1000_DCA_CTRL, 2); |
3488 | if (dca_add_requester(dev) == 0) { | 3483 | if (dca_add_requester(dev) == 0) { |
3484 | adapter->flags |= IGB_FLAG_DCA_ENABLED; | ||
3489 | dev_info(&adapter->pdev->dev, "DCA enabled\n"); | 3485 | dev_info(&adapter->pdev->dev, "DCA enabled\n"); |
3490 | igb_setup_dca(adapter); | 3486 | igb_setup_dca(adapter); |
3491 | break; | 3487 | break; |
@@ -3502,7 +3498,7 @@ static int __igb_notify_dca(struct device *dev, void *data) | |||
3502 | } | 3498 | } |
3503 | break; | 3499 | break; |
3504 | } | 3500 | } |
3505 | out: | 3501 | |
3506 | return 0; | 3502 | return 0; |
3507 | } | 3503 | } |
3508 | 3504 | ||
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index c38ed777f0a8..a6999403f37b 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -586,7 +586,7 @@ static int pcnet_config(struct pcmcia_device *link) | |||
586 | } | 586 | } |
587 | 587 | ||
588 | if ((link->conf.ConfigBase == 0x03c0) | 588 | if ((link->conf.ConfigBase == 0x03c0) |
589 | && (link->manf_id == 0x149) && (link->card_id = 0xc1ab)) { | 589 | && (link->manf_id == 0x149) && (link->card_id == 0xc1ab)) { |
590 | printk(KERN_INFO "pcnet_cs: this is an AX88190 card!\n"); | 590 | printk(KERN_INFO "pcnet_cs: this is an AX88190 card!\n"); |
591 | printk(KERN_INFO "pcnet_cs: use axnet_cs instead.\n"); | 591 | printk(KERN_INFO "pcnet_cs: use axnet_cs instead.\n"); |
592 | goto failed; | 592 | goto failed; |
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c index ec2314246682..335da4831ab3 100644 --- a/drivers/net/ps3_gelic_wireless.c +++ b/drivers/net/ps3_gelic_wireless.c | |||
@@ -2168,7 +2168,7 @@ static void gelic_wl_connected_event(struct gelic_wl_info *wl, | |||
2168 | complete(&wl->assoc_done); | 2168 | complete(&wl->assoc_done); |
2169 | netif_carrier_on(port_to_netdev(wl_port(wl))); | 2169 | netif_carrier_on(port_to_netdev(wl_port(wl))); |
2170 | } else | 2170 | } else |
2171 | pr_debug("%s: event %#lx under wpa\n", | 2171 | pr_debug("%s: event %#llx under wpa\n", |
2172 | __func__, event); | 2172 | __func__, event); |
2173 | } | 2173 | } |
2174 | 2174 | ||
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h index c1dadadfab18..e6fdce9206cc 100644 --- a/drivers/net/qlge/qlge.h +++ b/drivers/net/qlge/qlge.h | |||
@@ -787,12 +787,12 @@ struct mbox_params { | |||
787 | 787 | ||
788 | struct flash_params { | 788 | struct flash_params { |
789 | u8 dev_id_str[4]; | 789 | u8 dev_id_str[4]; |
790 | u16 size; | 790 | __le16 size; |
791 | u16 csum; | 791 | __le16 csum; |
792 | u16 ver; | 792 | __le16 ver; |
793 | u16 sub_dev_id; | 793 | __le16 sub_dev_id; |
794 | u8 mac_addr[6]; | 794 | u8 mac_addr[6]; |
795 | u16 res; | 795 | __le16 res; |
796 | }; | 796 | }; |
797 | 797 | ||
798 | 798 | ||
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c index 45421c8b6010..3d1d7b6e55aa 100644 --- a/drivers/net/qlge/qlge_main.c +++ b/drivers/net/qlge/qlge_main.c | |||
@@ -641,7 +641,7 @@ static void ql_enable_all_completion_interrupts(struct ql_adapter *qdev) | |||
641 | 641 | ||
642 | } | 642 | } |
643 | 643 | ||
644 | static int ql_read_flash_word(struct ql_adapter *qdev, int offset, u32 *data) | 644 | static int ql_read_flash_word(struct ql_adapter *qdev, int offset, __le32 *data) |
645 | { | 645 | { |
646 | int status = 0; | 646 | int status = 0; |
647 | /* wait for reg to come ready */ | 647 | /* wait for reg to come ready */ |
@@ -656,8 +656,11 @@ static int ql_read_flash_word(struct ql_adapter *qdev, int offset, u32 *data) | |||
656 | FLASH_ADDR, FLASH_ADDR_RDY, FLASH_ADDR_ERR); | 656 | FLASH_ADDR, FLASH_ADDR_RDY, FLASH_ADDR_ERR); |
657 | if (status) | 657 | if (status) |
658 | goto exit; | 658 | goto exit; |
659 | /* get the data */ | 659 | /* This data is stored on flash as an array of |
660 | *data = ql_read32(qdev, FLASH_DATA); | 660 | * __le32. Since ql_read32() returns cpu endian |
661 | * we need to swap it back. | ||
662 | */ | ||
663 | *data = cpu_to_le32(ql_read32(qdev, FLASH_DATA)); | ||
661 | exit: | 664 | exit: |
662 | return status; | 665 | return status; |
663 | } | 666 | } |
@@ -666,13 +669,20 @@ static int ql_get_flash_params(struct ql_adapter *qdev) | |||
666 | { | 669 | { |
667 | int i; | 670 | int i; |
668 | int status; | 671 | int status; |
669 | u32 *p = (u32 *)&qdev->flash; | 672 | __le32 *p = (__le32 *)&qdev->flash; |
673 | u32 offset = 0; | ||
674 | |||
675 | /* Second function's parameters follow the first | ||
676 | * function's. | ||
677 | */ | ||
678 | if (qdev->func) | ||
679 | offset = sizeof(qdev->flash) / sizeof(u32); | ||
670 | 680 | ||
671 | if (ql_sem_spinlock(qdev, SEM_FLASH_MASK)) | 681 | if (ql_sem_spinlock(qdev, SEM_FLASH_MASK)) |
672 | return -ETIMEDOUT; | 682 | return -ETIMEDOUT; |
673 | 683 | ||
674 | for (i = 0; i < sizeof(qdev->flash) / sizeof(u32); i++, p++) { | 684 | for (i = 0; i < sizeof(qdev->flash) / sizeof(u32); i++, p++) { |
675 | status = ql_read_flash_word(qdev, i, p); | 685 | status = ql_read_flash_word(qdev, i+offset, p); |
676 | if (status) { | 686 | if (status) { |
677 | QPRINTK(qdev, IFUP, ERR, "Error reading flash.\n"); | 687 | QPRINTK(qdev, IFUP, ERR, "Error reading flash.\n"); |
678 | goto exit; | 688 | goto exit; |
@@ -3826,7 +3836,7 @@ static int qlge_suspend(struct pci_dev *pdev, pm_message_t state) | |||
3826 | { | 3836 | { |
3827 | struct net_device *ndev = pci_get_drvdata(pdev); | 3837 | struct net_device *ndev = pci_get_drvdata(pdev); |
3828 | struct ql_adapter *qdev = netdev_priv(ndev); | 3838 | struct ql_adapter *qdev = netdev_priv(ndev); |
3829 | int err; | 3839 | int err, i; |
3830 | 3840 | ||
3831 | netif_device_detach(ndev); | 3841 | netif_device_detach(ndev); |
3832 | 3842 | ||
@@ -3836,6 +3846,9 @@ static int qlge_suspend(struct pci_dev *pdev, pm_message_t state) | |||
3836 | return err; | 3846 | return err; |
3837 | } | 3847 | } |
3838 | 3848 | ||
3849 | for (i = qdev->rss_ring_first_cq_id; i < qdev->rx_ring_count; i++) | ||
3850 | netif_napi_del(&qdev->rx_ring[i].napi); | ||
3851 | |||
3839 | err = pci_save_state(pdev); | 3852 | err = pci_save_state(pdev); |
3840 | if (err) | 3853 | if (err) |
3841 | return err; | 3854 | return err; |
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index 101c00a7bb73..847e9bb0098f 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -676,9 +676,8 @@ static int efx_init_port(struct efx_nic *efx) | |||
676 | rc = efx->phy_op->init(efx); | 676 | rc = efx->phy_op->init(efx); |
677 | if (rc) | 677 | if (rc) |
678 | return rc; | 678 | return rc; |
679 | efx->phy_op->reconfigure(efx); | ||
680 | |||
681 | mutex_lock(&efx->mac_lock); | 679 | mutex_lock(&efx->mac_lock); |
680 | efx->phy_op->reconfigure(efx); | ||
682 | rc = falcon_switch_mac(efx); | 681 | rc = falcon_switch_mac(efx); |
683 | mutex_unlock(&efx->mac_lock); | 682 | mutex_unlock(&efx->mac_lock); |
684 | if (rc) | 683 | if (rc) |
@@ -686,7 +685,7 @@ static int efx_init_port(struct efx_nic *efx) | |||
686 | efx->mac_op->reconfigure(efx); | 685 | efx->mac_op->reconfigure(efx); |
687 | 686 | ||
688 | efx->port_initialized = true; | 687 | efx->port_initialized = true; |
689 | efx->stats_enabled = true; | 688 | efx_stats_enable(efx); |
690 | return 0; | 689 | return 0; |
691 | 690 | ||
692 | fail: | 691 | fail: |
@@ -735,6 +734,7 @@ static void efx_fini_port(struct efx_nic *efx) | |||
735 | if (!efx->port_initialized) | 734 | if (!efx->port_initialized) |
736 | return; | 735 | return; |
737 | 736 | ||
737 | efx_stats_disable(efx); | ||
738 | efx->phy_op->fini(efx); | 738 | efx->phy_op->fini(efx); |
739 | efx->port_initialized = false; | 739 | efx->port_initialized = false; |
740 | 740 | ||
@@ -1368,6 +1368,20 @@ static int efx_net_stop(struct net_device *net_dev) | |||
1368 | return 0; | 1368 | return 0; |
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | void efx_stats_disable(struct efx_nic *efx) | ||
1372 | { | ||
1373 | spin_lock(&efx->stats_lock); | ||
1374 | ++efx->stats_disable_count; | ||
1375 | spin_unlock(&efx->stats_lock); | ||
1376 | } | ||
1377 | |||
1378 | void efx_stats_enable(struct efx_nic *efx) | ||
1379 | { | ||
1380 | spin_lock(&efx->stats_lock); | ||
1381 | --efx->stats_disable_count; | ||
1382 | spin_unlock(&efx->stats_lock); | ||
1383 | } | ||
1384 | |||
1371 | /* Context: process, dev_base_lock or RTNL held, non-blocking. */ | 1385 | /* Context: process, dev_base_lock or RTNL held, non-blocking. */ |
1372 | static struct net_device_stats *efx_net_stats(struct net_device *net_dev) | 1386 | static struct net_device_stats *efx_net_stats(struct net_device *net_dev) |
1373 | { | 1387 | { |
@@ -1376,12 +1390,12 @@ static struct net_device_stats *efx_net_stats(struct net_device *net_dev) | |||
1376 | struct net_device_stats *stats = &net_dev->stats; | 1390 | struct net_device_stats *stats = &net_dev->stats; |
1377 | 1391 | ||
1378 | /* Update stats if possible, but do not wait if another thread | 1392 | /* Update stats if possible, but do not wait if another thread |
1379 | * is updating them (or resetting the NIC); slightly stale | 1393 | * is updating them or if MAC stats fetches are temporarily |
1380 | * stats are acceptable. | 1394 | * disabled; slightly stale stats are acceptable. |
1381 | */ | 1395 | */ |
1382 | if (!spin_trylock(&efx->stats_lock)) | 1396 | if (!spin_trylock(&efx->stats_lock)) |
1383 | return stats; | 1397 | return stats; |
1384 | if (efx->stats_enabled) { | 1398 | if (!efx->stats_disable_count) { |
1385 | efx->mac_op->update_stats(efx); | 1399 | efx->mac_op->update_stats(efx); |
1386 | falcon_update_nic_stats(efx); | 1400 | falcon_update_nic_stats(efx); |
1387 | } | 1401 | } |
@@ -1629,16 +1643,12 @@ static void efx_unregister_netdev(struct efx_nic *efx) | |||
1629 | 1643 | ||
1630 | /* Tears down the entire software state and most of the hardware state | 1644 | /* Tears down the entire software state and most of the hardware state |
1631 | * before reset. */ | 1645 | * before reset. */ |
1632 | void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd) | 1646 | void efx_reset_down(struct efx_nic *efx, enum reset_type method, |
1647 | struct ethtool_cmd *ecmd) | ||
1633 | { | 1648 | { |
1634 | EFX_ASSERT_RESET_SERIALISED(efx); | 1649 | EFX_ASSERT_RESET_SERIALISED(efx); |
1635 | 1650 | ||
1636 | /* The net_dev->get_stats handler is quite slow, and will fail | 1651 | efx_stats_disable(efx); |
1637 | * if a fetch is pending over reset. Serialise against it. */ | ||
1638 | spin_lock(&efx->stats_lock); | ||
1639 | efx->stats_enabled = false; | ||
1640 | spin_unlock(&efx->stats_lock); | ||
1641 | |||
1642 | efx_stop_all(efx); | 1652 | efx_stop_all(efx); |
1643 | mutex_lock(&efx->mac_lock); | 1653 | mutex_lock(&efx->mac_lock); |
1644 | mutex_lock(&efx->spi_lock); | 1654 | mutex_lock(&efx->spi_lock); |
@@ -1646,6 +1656,8 @@ void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd) | |||
1646 | efx->phy_op->get_settings(efx, ecmd); | 1656 | efx->phy_op->get_settings(efx, ecmd); |
1647 | 1657 | ||
1648 | efx_fini_channels(efx); | 1658 | efx_fini_channels(efx); |
1659 | if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) | ||
1660 | efx->phy_op->fini(efx); | ||
1649 | } | 1661 | } |
1650 | 1662 | ||
1651 | /* This function will always ensure that the locks acquired in | 1663 | /* This function will always ensure that the locks acquired in |
@@ -1653,7 +1665,8 @@ void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd) | |||
1653 | * that we were unable to reinitialise the hardware, and the | 1665 | * that we were unable to reinitialise the hardware, and the |
1654 | * driver should be disabled. If ok is false, then the rx and tx | 1666 | * driver should be disabled. If ok is false, then the rx and tx |
1655 | * engines are not restarted, pending a RESET_DISABLE. */ | 1667 | * engines are not restarted, pending a RESET_DISABLE. */ |
1656 | int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok) | 1668 | int efx_reset_up(struct efx_nic *efx, enum reset_type method, |
1669 | struct ethtool_cmd *ecmd, bool ok) | ||
1657 | { | 1670 | { |
1658 | int rc; | 1671 | int rc; |
1659 | 1672 | ||
@@ -1665,6 +1678,15 @@ int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok) | |||
1665 | ok = false; | 1678 | ok = false; |
1666 | } | 1679 | } |
1667 | 1680 | ||
1681 | if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) { | ||
1682 | if (ok) { | ||
1683 | rc = efx->phy_op->init(efx); | ||
1684 | if (rc) | ||
1685 | ok = false; | ||
1686 | } else | ||
1687 | efx->port_initialized = false; | ||
1688 | } | ||
1689 | |||
1668 | if (ok) { | 1690 | if (ok) { |
1669 | efx_init_channels(efx); | 1691 | efx_init_channels(efx); |
1670 | 1692 | ||
@@ -1677,7 +1699,7 @@ int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok) | |||
1677 | 1699 | ||
1678 | if (ok) { | 1700 | if (ok) { |
1679 | efx_start_all(efx); | 1701 | efx_start_all(efx); |
1680 | efx->stats_enabled = true; | 1702 | efx_stats_enable(efx); |
1681 | } | 1703 | } |
1682 | return rc; | 1704 | return rc; |
1683 | } | 1705 | } |
@@ -1709,7 +1731,7 @@ static int efx_reset(struct efx_nic *efx) | |||
1709 | 1731 | ||
1710 | EFX_INFO(efx, "resetting (%d)\n", method); | 1732 | EFX_INFO(efx, "resetting (%d)\n", method); |
1711 | 1733 | ||
1712 | efx_reset_down(efx, &ecmd); | 1734 | efx_reset_down(efx, method, &ecmd); |
1713 | 1735 | ||
1714 | rc = falcon_reset_hw(efx, method); | 1736 | rc = falcon_reset_hw(efx, method); |
1715 | if (rc) { | 1737 | if (rc) { |
@@ -1728,10 +1750,10 @@ static int efx_reset(struct efx_nic *efx) | |||
1728 | 1750 | ||
1729 | /* Leave device stopped if necessary */ | 1751 | /* Leave device stopped if necessary */ |
1730 | if (method == RESET_TYPE_DISABLE) { | 1752 | if (method == RESET_TYPE_DISABLE) { |
1731 | efx_reset_up(efx, &ecmd, false); | 1753 | efx_reset_up(efx, method, &ecmd, false); |
1732 | rc = -EIO; | 1754 | rc = -EIO; |
1733 | } else { | 1755 | } else { |
1734 | rc = efx_reset_up(efx, &ecmd, true); | 1756 | rc = efx_reset_up(efx, method, &ecmd, true); |
1735 | } | 1757 | } |
1736 | 1758 | ||
1737 | out_disable: | 1759 | out_disable: |
@@ -1883,6 +1905,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type, | |||
1883 | efx->rx_checksum_enabled = true; | 1905 | efx->rx_checksum_enabled = true; |
1884 | spin_lock_init(&efx->netif_stop_lock); | 1906 | spin_lock_init(&efx->netif_stop_lock); |
1885 | spin_lock_init(&efx->stats_lock); | 1907 | spin_lock_init(&efx->stats_lock); |
1908 | efx->stats_disable_count = 1; | ||
1886 | mutex_init(&efx->mac_lock); | 1909 | mutex_init(&efx->mac_lock); |
1887 | efx->mac_op = &efx_dummy_mac_operations; | 1910 | efx->mac_op = &efx_dummy_mac_operations; |
1888 | efx->phy_op = &efx_dummy_phy_operations; | 1911 | efx->phy_op = &efx_dummy_phy_operations; |
diff --git a/drivers/net/sfc/efx.h b/drivers/net/sfc/efx.h index 0dd7a532c78a..55d0f131b0e9 100644 --- a/drivers/net/sfc/efx.h +++ b/drivers/net/sfc/efx.h | |||
@@ -36,13 +36,16 @@ extern void efx_process_channel_now(struct efx_channel *channel); | |||
36 | extern void efx_flush_queues(struct efx_nic *efx); | 36 | extern void efx_flush_queues(struct efx_nic *efx); |
37 | 37 | ||
38 | /* Ports */ | 38 | /* Ports */ |
39 | extern void efx_stats_disable(struct efx_nic *efx); | ||
40 | extern void efx_stats_enable(struct efx_nic *efx); | ||
39 | extern void efx_reconfigure_port(struct efx_nic *efx); | 41 | extern void efx_reconfigure_port(struct efx_nic *efx); |
40 | extern void __efx_reconfigure_port(struct efx_nic *efx); | 42 | extern void __efx_reconfigure_port(struct efx_nic *efx); |
41 | 43 | ||
42 | /* Reset handling */ | 44 | /* Reset handling */ |
43 | extern void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd); | 45 | extern void efx_reset_down(struct efx_nic *efx, enum reset_type method, |
44 | extern int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, | 46 | struct ethtool_cmd *ecmd); |
45 | bool ok); | 47 | extern int efx_reset_up(struct efx_nic *efx, enum reset_type method, |
48 | struct ethtool_cmd *ecmd, bool ok); | ||
46 | 49 | ||
47 | /* Global */ | 50 | /* Global */ |
48 | extern void efx_schedule_reset(struct efx_nic *efx, enum reset_type type); | 51 | extern void efx_schedule_reset(struct efx_nic *efx, enum reset_type type); |
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c index 53d259e90187..7b5924c039b3 100644 --- a/drivers/net/sfc/ethtool.c +++ b/drivers/net/sfc/ethtool.c | |||
@@ -219,9 +219,6 @@ int efx_ethtool_set_settings(struct net_device *net_dev, | |||
219 | struct efx_nic *efx = netdev_priv(net_dev); | 219 | struct efx_nic *efx = netdev_priv(net_dev); |
220 | int rc; | 220 | int rc; |
221 | 221 | ||
222 | if (EFX_WORKAROUND_13963(efx) && !ecmd->autoneg) | ||
223 | return -EINVAL; | ||
224 | |||
225 | /* Falcon GMAC does not support 1000Mbps HD */ | 222 | /* Falcon GMAC does not support 1000Mbps HD */ |
226 | if (ecmd->speed == SPEED_1000 && ecmd->duplex != DUPLEX_FULL) { | 223 | if (ecmd->speed == SPEED_1000 && ecmd->duplex != DUPLEX_FULL) { |
227 | EFX_LOG(efx, "rejecting unsupported 1000Mbps HD" | 224 | EFX_LOG(efx, "rejecting unsupported 1000Mbps HD" |
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index 5b9f2d9cc4ed..d5378e60fcdd 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -824,10 +824,6 @@ static void falcon_handle_rx_not_ok(struct efx_rx_queue *rx_queue, | |||
824 | rx_ev_pause_frm ? " [PAUSE]" : ""); | 824 | rx_ev_pause_frm ? " [PAUSE]" : ""); |
825 | } | 825 | } |
826 | #endif | 826 | #endif |
827 | |||
828 | if (unlikely(rx_ev_eth_crc_err && EFX_WORKAROUND_10750(efx) && | ||
829 | efx->phy_type == PHY_TYPE_SFX7101)) | ||
830 | tenxpress_crc_err(efx); | ||
831 | } | 827 | } |
832 | 828 | ||
833 | /* Handle receive events that are not in-order. */ | 829 | /* Handle receive events that are not in-order. */ |
@@ -1887,7 +1883,7 @@ static int falcon_reset_macs(struct efx_nic *efx) | |||
1887 | 1883 | ||
1888 | /* MAC stats will fail whilst the TX fifo is draining. Serialise | 1884 | /* MAC stats will fail whilst the TX fifo is draining. Serialise |
1889 | * the drain sequence with the statistics fetch */ | 1885 | * the drain sequence with the statistics fetch */ |
1890 | spin_lock(&efx->stats_lock); | 1886 | efx_stats_disable(efx); |
1891 | 1887 | ||
1892 | falcon_read(efx, ®, MAC0_CTRL_REG_KER); | 1888 | falcon_read(efx, ®, MAC0_CTRL_REG_KER); |
1893 | EFX_SET_OWORD_FIELD(reg, TXFIFO_DRAIN_EN_B0, 1); | 1889 | EFX_SET_OWORD_FIELD(reg, TXFIFO_DRAIN_EN_B0, 1); |
@@ -1917,7 +1913,7 @@ static int falcon_reset_macs(struct efx_nic *efx) | |||
1917 | udelay(10); | 1913 | udelay(10); |
1918 | } | 1914 | } |
1919 | 1915 | ||
1920 | spin_unlock(&efx->stats_lock); | 1916 | efx_stats_enable(efx); |
1921 | 1917 | ||
1922 | /* If we've reset the EM block and the link is up, then | 1918 | /* If we've reset the EM block and the link is up, then |
1923 | * we'll have to kick the XAUI link so the PHY can recover */ | 1919 | * we'll have to kick the XAUI link so the PHY can recover */ |
@@ -2277,6 +2273,10 @@ int falcon_switch_mac(struct efx_nic *efx) | |||
2277 | struct efx_mac_operations *old_mac_op = efx->mac_op; | 2273 | struct efx_mac_operations *old_mac_op = efx->mac_op; |
2278 | efx_oword_t nic_stat; | 2274 | efx_oword_t nic_stat; |
2279 | unsigned strap_val; | 2275 | unsigned strap_val; |
2276 | int rc = 0; | ||
2277 | |||
2278 | /* Don't try to fetch MAC stats while we're switching MACs */ | ||
2279 | efx_stats_disable(efx); | ||
2280 | 2280 | ||
2281 | /* Internal loopbacks override the phy speed setting */ | 2281 | /* Internal loopbacks override the phy speed setting */ |
2282 | if (efx->loopback_mode == LOOPBACK_GMAC) { | 2282 | if (efx->loopback_mode == LOOPBACK_GMAC) { |
@@ -2287,16 +2287,12 @@ int falcon_switch_mac(struct efx_nic *efx) | |||
2287 | efx->link_fd = true; | 2287 | efx->link_fd = true; |
2288 | } | 2288 | } |
2289 | 2289 | ||
2290 | WARN_ON(!mutex_is_locked(&efx->mac_lock)); | ||
2290 | efx->mac_op = (EFX_IS10G(efx) ? | 2291 | efx->mac_op = (EFX_IS10G(efx) ? |
2291 | &falcon_xmac_operations : &falcon_gmac_operations); | 2292 | &falcon_xmac_operations : &falcon_gmac_operations); |
2292 | if (old_mac_op == efx->mac_op) | ||
2293 | return 0; | ||
2294 | |||
2295 | WARN_ON(!mutex_is_locked(&efx->mac_lock)); | ||
2296 | |||
2297 | /* Not all macs support a mac-level link state */ | ||
2298 | efx->mac_up = true; | ||
2299 | 2293 | ||
2294 | /* Always push the NIC_STAT_REG setting even if the mac hasn't | ||
2295 | * changed, because this function is run post online reset */ | ||
2300 | falcon_read(efx, &nic_stat, NIC_STAT_REG); | 2296 | falcon_read(efx, &nic_stat, NIC_STAT_REG); |
2301 | strap_val = EFX_IS10G(efx) ? 5 : 3; | 2297 | strap_val = EFX_IS10G(efx) ? 5 : 3; |
2302 | if (falcon_rev(efx) >= FALCON_REV_B0) { | 2298 | if (falcon_rev(efx) >= FALCON_REV_B0) { |
@@ -2309,9 +2305,17 @@ int falcon_switch_mac(struct efx_nic *efx) | |||
2309 | BUG_ON(EFX_OWORD_FIELD(nic_stat, STRAP_PINS) != strap_val); | 2305 | BUG_ON(EFX_OWORD_FIELD(nic_stat, STRAP_PINS) != strap_val); |
2310 | } | 2306 | } |
2311 | 2307 | ||
2308 | if (old_mac_op == efx->mac_op) | ||
2309 | goto out; | ||
2312 | 2310 | ||
2313 | EFX_LOG(efx, "selected %cMAC\n", EFX_IS10G(efx) ? 'X' : 'G'); | 2311 | EFX_LOG(efx, "selected %cMAC\n", EFX_IS10G(efx) ? 'X' : 'G'); |
2314 | return falcon_reset_macs(efx); | 2312 | /* Not all macs support a mac-level link state */ |
2313 | efx->mac_up = true; | ||
2314 | |||
2315 | rc = falcon_reset_macs(efx); | ||
2316 | out: | ||
2317 | efx_stats_enable(efx); | ||
2318 | return rc; | ||
2315 | } | 2319 | } |
2316 | 2320 | ||
2317 | /* This call is responsible for hooking in the MAC and PHY operations */ | 2321 | /* This call is responsible for hooking in the MAC and PHY operations */ |
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c index f6a16428113d..f9e2f95c3b48 100644 --- a/drivers/net/sfc/mdio_10g.c +++ b/drivers/net/sfc/mdio_10g.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "net_driver.h" | 15 | #include "net_driver.h" |
16 | #include "mdio_10g.h" | 16 | #include "mdio_10g.h" |
17 | #include "boards.h" | 17 | #include "boards.h" |
18 | #include "workarounds.h" | ||
18 | 19 | ||
19 | int mdio_clause45_reset_mmd(struct efx_nic *port, int mmd, | 20 | int mdio_clause45_reset_mmd(struct efx_nic *port, int mmd, |
20 | int spins, int spintime) | 21 | int spins, int spintime) |
@@ -179,17 +180,12 @@ bool mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask) | |||
179 | return false; | 180 | return false; |
180 | else if (efx_phy_mode_disabled(efx->phy_mode)) | 181 | else if (efx_phy_mode_disabled(efx->phy_mode)) |
181 | return false; | 182 | return false; |
182 | else if (efx->loopback_mode == LOOPBACK_PHYXS) { | 183 | else if (efx->loopback_mode == LOOPBACK_PHYXS) |
183 | mmd_mask &= ~(MDIO_MMDREG_DEVS_PHYXS | | 184 | mmd_mask &= ~(MDIO_MMDREG_DEVS_PHYXS | |
184 | MDIO_MMDREG_DEVS_PCS | | 185 | MDIO_MMDREG_DEVS_PCS | |
185 | MDIO_MMDREG_DEVS_PMAPMD | | 186 | MDIO_MMDREG_DEVS_PMAPMD | |
186 | MDIO_MMDREG_DEVS_AN); | 187 | MDIO_MMDREG_DEVS_AN); |
187 | if (!mmd_mask) { | 188 | else if (efx->loopback_mode == LOOPBACK_PCS) |
188 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS, | ||
189 | MDIO_PHYXS_STATUS2); | ||
190 | return !(reg & (1 << MDIO_PHYXS_STATUS2_RX_FAULT_LBN)); | ||
191 | } | ||
192 | } else if (efx->loopback_mode == LOOPBACK_PCS) | ||
193 | mmd_mask &= ~(MDIO_MMDREG_DEVS_PCS | | 189 | mmd_mask &= ~(MDIO_MMDREG_DEVS_PCS | |
194 | MDIO_MMDREG_DEVS_PMAPMD | | 190 | MDIO_MMDREG_DEVS_PMAPMD | |
195 | MDIO_MMDREG_DEVS_AN); | 191 | MDIO_MMDREG_DEVS_AN); |
@@ -197,6 +193,13 @@ bool mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask) | |||
197 | mmd_mask &= ~(MDIO_MMDREG_DEVS_PMAPMD | | 193 | mmd_mask &= ~(MDIO_MMDREG_DEVS_PMAPMD | |
198 | MDIO_MMDREG_DEVS_AN); | 194 | MDIO_MMDREG_DEVS_AN); |
199 | 195 | ||
196 | if (!mmd_mask) { | ||
197 | /* Use presence of XGMII faults in leui of link state */ | ||
198 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS, | ||
199 | MDIO_PHYXS_STATUS2); | ||
200 | return !(reg & (1 << MDIO_PHYXS_STATUS2_RX_FAULT_LBN)); | ||
201 | } | ||
202 | |||
200 | while (mmd_mask) { | 203 | while (mmd_mask) { |
201 | if (mmd_mask & 1) { | 204 | if (mmd_mask & 1) { |
202 | /* Double reads because link state is latched, and a | 205 | /* Double reads because link state is latched, and a |
@@ -263,7 +266,7 @@ void mdio_clause45_set_mmds_lpower(struct efx_nic *efx, | |||
263 | } | 266 | } |
264 | } | 267 | } |
265 | 268 | ||
266 | static u32 mdio_clause45_get_an(struct efx_nic *efx, u16 addr, u32 xnp) | 269 | static u32 mdio_clause45_get_an(struct efx_nic *efx, u16 addr) |
267 | { | 270 | { |
268 | int phy_id = efx->mii.phy_id; | 271 | int phy_id = efx->mii.phy_id; |
269 | u32 result = 0; | 272 | u32 result = 0; |
@@ -278,9 +281,6 @@ static u32 mdio_clause45_get_an(struct efx_nic *efx, u16 addr, u32 xnp) | |||
278 | result |= ADVERTISED_100baseT_Half; | 281 | result |= ADVERTISED_100baseT_Half; |
279 | if (reg & ADVERTISE_100FULL) | 282 | if (reg & ADVERTISE_100FULL) |
280 | result |= ADVERTISED_100baseT_Full; | 283 | result |= ADVERTISED_100baseT_Full; |
281 | if (reg & LPA_RESV) | ||
282 | result |= xnp; | ||
283 | |||
284 | return result; | 284 | return result; |
285 | } | 285 | } |
286 | 286 | ||
@@ -310,7 +310,7 @@ void mdio_clause45_get_settings(struct efx_nic *efx, | |||
310 | */ | 310 | */ |
311 | void mdio_clause45_get_settings_ext(struct efx_nic *efx, | 311 | void mdio_clause45_get_settings_ext(struct efx_nic *efx, |
312 | struct ethtool_cmd *ecmd, | 312 | struct ethtool_cmd *ecmd, |
313 | u32 xnp, u32 xnp_lpa) | 313 | u32 npage_adv, u32 npage_lpa) |
314 | { | 314 | { |
315 | int phy_id = efx->mii.phy_id; | 315 | int phy_id = efx->mii.phy_id; |
316 | int reg; | 316 | int reg; |
@@ -361,8 +361,8 @@ void mdio_clause45_get_settings_ext(struct efx_nic *efx, | |||
361 | ecmd->autoneg = AUTONEG_ENABLE; | 361 | ecmd->autoneg = AUTONEG_ENABLE; |
362 | ecmd->advertising |= | 362 | ecmd->advertising |= |
363 | ADVERTISED_Autoneg | | 363 | ADVERTISED_Autoneg | |
364 | mdio_clause45_get_an(efx, | 364 | mdio_clause45_get_an(efx, MDIO_AN_ADVERTISE) | |
365 | MDIO_AN_ADVERTISE, xnp); | 365 | npage_adv; |
366 | } else | 366 | } else |
367 | ecmd->autoneg = AUTONEG_DISABLE; | 367 | ecmd->autoneg = AUTONEG_DISABLE; |
368 | } else | 368 | } else |
@@ -371,27 +371,30 @@ void mdio_clause45_get_settings_ext(struct efx_nic *efx, | |||
371 | if (ecmd->autoneg) { | 371 | if (ecmd->autoneg) { |
372 | /* If AN is complete, report best common mode, | 372 | /* If AN is complete, report best common mode, |
373 | * otherwise report best advertised mode. */ | 373 | * otherwise report best advertised mode. */ |
374 | u32 common = ecmd->advertising; | 374 | u32 modes = 0; |
375 | if (mdio_clause45_read(efx, phy_id, MDIO_MMD_AN, | 375 | if (mdio_clause45_read(efx, phy_id, MDIO_MMD_AN, |
376 | MDIO_MMDREG_STAT1) & | 376 | MDIO_MMDREG_STAT1) & |
377 | (1 << MDIO_AN_STATUS_AN_DONE_LBN)) { | 377 | (1 << MDIO_AN_STATUS_AN_DONE_LBN)) |
378 | common &= mdio_clause45_get_an(efx, MDIO_AN_LPA, | 378 | modes = (ecmd->advertising & |
379 | xnp_lpa); | 379 | (mdio_clause45_get_an(efx, MDIO_AN_LPA) | |
380 | } | 380 | npage_lpa)); |
381 | if (common & ADVERTISED_10000baseT_Full) { | 381 | if (modes == 0) |
382 | modes = ecmd->advertising; | ||
383 | |||
384 | if (modes & ADVERTISED_10000baseT_Full) { | ||
382 | ecmd->speed = SPEED_10000; | 385 | ecmd->speed = SPEED_10000; |
383 | ecmd->duplex = DUPLEX_FULL; | 386 | ecmd->duplex = DUPLEX_FULL; |
384 | } else if (common & (ADVERTISED_1000baseT_Full | | 387 | } else if (modes & (ADVERTISED_1000baseT_Full | |
385 | ADVERTISED_1000baseT_Half)) { | 388 | ADVERTISED_1000baseT_Half)) { |
386 | ecmd->speed = SPEED_1000; | 389 | ecmd->speed = SPEED_1000; |
387 | ecmd->duplex = !!(common & ADVERTISED_1000baseT_Full); | 390 | ecmd->duplex = !!(modes & ADVERTISED_1000baseT_Full); |
388 | } else if (common & (ADVERTISED_100baseT_Full | | 391 | } else if (modes & (ADVERTISED_100baseT_Full | |
389 | ADVERTISED_100baseT_Half)) { | 392 | ADVERTISED_100baseT_Half)) { |
390 | ecmd->speed = SPEED_100; | 393 | ecmd->speed = SPEED_100; |
391 | ecmd->duplex = !!(common & ADVERTISED_100baseT_Full); | 394 | ecmd->duplex = !!(modes & ADVERTISED_100baseT_Full); |
392 | } else { | 395 | } else { |
393 | ecmd->speed = SPEED_10; | 396 | ecmd->speed = SPEED_10; |
394 | ecmd->duplex = !!(common & ADVERTISED_10baseT_Full); | 397 | ecmd->duplex = !!(modes & ADVERTISED_10baseT_Full); |
395 | } | 398 | } |
396 | } else { | 399 | } else { |
397 | /* Report forced settings */ | 400 | /* Report forced settings */ |
@@ -415,7 +418,7 @@ int mdio_clause45_set_settings(struct efx_nic *efx, | |||
415 | int phy_id = efx->mii.phy_id; | 418 | int phy_id = efx->mii.phy_id; |
416 | struct ethtool_cmd prev; | 419 | struct ethtool_cmd prev; |
417 | u32 required; | 420 | u32 required; |
418 | int ctrl1_bits, reg; | 421 | int reg; |
419 | 422 | ||
420 | efx->phy_op->get_settings(efx, &prev); | 423 | efx->phy_op->get_settings(efx, &prev); |
421 | 424 | ||
@@ -430,99 +433,83 @@ int mdio_clause45_set_settings(struct efx_nic *efx, | |||
430 | if (prev.port != PORT_TP || ecmd->port != PORT_TP) | 433 | if (prev.port != PORT_TP || ecmd->port != PORT_TP) |
431 | return -EINVAL; | 434 | return -EINVAL; |
432 | 435 | ||
433 | /* Check that PHY supports these settings and work out the | 436 | /* Check that PHY supports these settings */ |
434 | * basic control bits */ | 437 | if (ecmd->autoneg) { |
435 | if (ecmd->duplex) { | 438 | required = SUPPORTED_Autoneg; |
439 | } else if (ecmd->duplex) { | ||
436 | switch (ecmd->speed) { | 440 | switch (ecmd->speed) { |
437 | case SPEED_10: | 441 | case SPEED_10: required = SUPPORTED_10baseT_Full; break; |
438 | ctrl1_bits = BMCR_FULLDPLX; | 442 | case SPEED_100: required = SUPPORTED_100baseT_Full; break; |
439 | required = SUPPORTED_10baseT_Full; | 443 | default: return -EINVAL; |
440 | break; | ||
441 | case SPEED_100: | ||
442 | ctrl1_bits = BMCR_SPEED100 | BMCR_FULLDPLX; | ||
443 | required = SUPPORTED_100baseT_Full; | ||
444 | break; | ||
445 | case SPEED_1000: | ||
446 | ctrl1_bits = BMCR_SPEED1000 | BMCR_FULLDPLX; | ||
447 | required = SUPPORTED_1000baseT_Full; | ||
448 | break; | ||
449 | case SPEED_10000: | ||
450 | ctrl1_bits = (BMCR_SPEED1000 | BMCR_SPEED100 | | ||
451 | BMCR_FULLDPLX); | ||
452 | required = SUPPORTED_10000baseT_Full; | ||
453 | break; | ||
454 | default: | ||
455 | return -EINVAL; | ||
456 | } | 444 | } |
457 | } else { | 445 | } else { |
458 | switch (ecmd->speed) { | 446 | switch (ecmd->speed) { |
459 | case SPEED_10: | 447 | case SPEED_10: required = SUPPORTED_10baseT_Half; break; |
460 | ctrl1_bits = 0; | 448 | case SPEED_100: required = SUPPORTED_100baseT_Half; break; |
461 | required = SUPPORTED_10baseT_Half; | 449 | default: return -EINVAL; |
462 | break; | ||
463 | case SPEED_100: | ||
464 | ctrl1_bits = BMCR_SPEED100; | ||
465 | required = SUPPORTED_100baseT_Half; | ||
466 | break; | ||
467 | case SPEED_1000: | ||
468 | ctrl1_bits = BMCR_SPEED1000; | ||
469 | required = SUPPORTED_1000baseT_Half; | ||
470 | break; | ||
471 | default: | ||
472 | return -EINVAL; | ||
473 | } | 450 | } |
474 | } | 451 | } |
475 | if (ecmd->autoneg) | ||
476 | required |= SUPPORTED_Autoneg; | ||
477 | required |= ecmd->advertising; | 452 | required |= ecmd->advertising; |
478 | if (required & ~prev.supported) | 453 | if (required & ~prev.supported) |
479 | return -EINVAL; | 454 | return -EINVAL; |
480 | 455 | ||
481 | /* Set the basic control bits */ | 456 | if (ecmd->autoneg) { |
482 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, | 457 | bool xnp = (ecmd->advertising & ADVERTISED_10000baseT_Full |
483 | MDIO_MMDREG_CTRL1); | 458 | || EFX_WORKAROUND_13204(efx)); |
484 | reg &= ~(BMCR_SPEED1000 | BMCR_SPEED100 | BMCR_FULLDPLX | 0x003c); | 459 | |
485 | reg |= ctrl1_bits; | 460 | /* Set up the base page */ |
486 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, MDIO_MMDREG_CTRL1, | 461 | reg = ADVERTISE_CSMA; |
487 | reg); | 462 | if (ecmd->advertising & ADVERTISED_10baseT_Half) |
488 | 463 | reg |= ADVERTISE_10HALF; | |
489 | /* Set the AN registers */ | 464 | if (ecmd->advertising & ADVERTISED_10baseT_Full) |
490 | if (ecmd->autoneg != prev.autoneg || | 465 | reg |= ADVERTISE_10FULL; |
491 | ecmd->advertising != prev.advertising) { | 466 | if (ecmd->advertising & ADVERTISED_100baseT_Half) |
492 | bool xnp = false; | 467 | reg |= ADVERTISE_100HALF; |
493 | 468 | if (ecmd->advertising & ADVERTISED_100baseT_Full) | |
494 | if (efx->phy_op->set_xnp_advertise) | 469 | reg |= ADVERTISE_100FULL; |
495 | xnp = efx->phy_op->set_xnp_advertise(efx, | 470 | if (xnp) |
496 | ecmd->advertising); | 471 | reg |= ADVERTISE_RESV; |
497 | 472 | else if (ecmd->advertising & (ADVERTISED_1000baseT_Half | | |
498 | if (ecmd->autoneg) { | 473 | ADVERTISED_1000baseT_Full)) |
499 | reg = 0; | 474 | reg |= ADVERTISE_NPAGE; |
500 | if (ecmd->advertising & ADVERTISED_10baseT_Half) | 475 | reg |= efx_fc_advertise(efx->wanted_fc); |
501 | reg |= ADVERTISE_10HALF; | 476 | mdio_clause45_write(efx, phy_id, MDIO_MMD_AN, |
502 | if (ecmd->advertising & ADVERTISED_10baseT_Full) | 477 | MDIO_AN_ADVERTISE, reg); |
503 | reg |= ADVERTISE_10FULL; | 478 | |
504 | if (ecmd->advertising & ADVERTISED_100baseT_Half) | 479 | /* Set up the (extended) next page if necessary */ |
505 | reg |= ADVERTISE_100HALF; | 480 | if (efx->phy_op->set_npage_adv) |
506 | if (ecmd->advertising & ADVERTISED_100baseT_Full) | 481 | efx->phy_op->set_npage_adv(efx, ecmd->advertising); |
507 | reg |= ADVERTISE_100FULL; | ||
508 | if (xnp) | ||
509 | reg |= ADVERTISE_RESV; | ||
510 | mdio_clause45_write(efx, phy_id, MDIO_MMD_AN, | ||
511 | MDIO_AN_ADVERTISE, reg); | ||
512 | } | ||
513 | 482 | ||
483 | /* Enable and restart AN */ | ||
514 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN, | 484 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN, |
515 | MDIO_MMDREG_CTRL1); | 485 | MDIO_MMDREG_CTRL1); |
516 | if (ecmd->autoneg) | 486 | reg |= BMCR_ANENABLE; |
517 | reg |= BMCR_ANENABLE | BMCR_ANRESTART; | 487 | if (!(EFX_WORKAROUND_15195(efx) && |
518 | else | 488 | LOOPBACK_MASK(efx) & efx->phy_op->loopbacks)) |
519 | reg &= ~BMCR_ANENABLE; | 489 | reg |= BMCR_ANRESTART; |
520 | if (xnp) | 490 | if (xnp) |
521 | reg |= 1 << MDIO_AN_CTRL_XNP_LBN; | 491 | reg |= 1 << MDIO_AN_CTRL_XNP_LBN; |
522 | else | 492 | else |
523 | reg &= ~(1 << MDIO_AN_CTRL_XNP_LBN); | 493 | reg &= ~(1 << MDIO_AN_CTRL_XNP_LBN); |
524 | mdio_clause45_write(efx, phy_id, MDIO_MMD_AN, | 494 | mdio_clause45_write(efx, phy_id, MDIO_MMD_AN, |
525 | MDIO_MMDREG_CTRL1, reg); | 495 | MDIO_MMDREG_CTRL1, reg); |
496 | } else { | ||
497 | /* Disable AN */ | ||
498 | mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_AN, | ||
499 | MDIO_MMDREG_CTRL1, | ||
500 | __ffs(BMCR_ANENABLE), false); | ||
501 | |||
502 | /* Set the basic control bits */ | ||
503 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, | ||
504 | MDIO_MMDREG_CTRL1); | ||
505 | reg &= ~(BMCR_SPEED1000 | BMCR_SPEED100 | BMCR_FULLDPLX | | ||
506 | 0x003c); | ||
507 | if (ecmd->speed == SPEED_100) | ||
508 | reg |= BMCR_SPEED100; | ||
509 | if (ecmd->duplex) | ||
510 | reg |= BMCR_FULLDPLX; | ||
511 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, | ||
512 | MDIO_MMDREG_CTRL1, reg); | ||
526 | } | 513 | } |
527 | 514 | ||
528 | return 0; | 515 | return 0; |
diff --git a/drivers/net/sfc/mdio_10g.h b/drivers/net/sfc/mdio_10g.h index 09bf801d0569..8ba49773ce7e 100644 --- a/drivers/net/sfc/mdio_10g.h +++ b/drivers/net/sfc/mdio_10g.h | |||
@@ -155,7 +155,8 @@ | |||
155 | #define MDIO_AN_XNP 22 | 155 | #define MDIO_AN_XNP 22 |
156 | #define MDIO_AN_LPA_XNP 25 | 156 | #define MDIO_AN_LPA_XNP 25 |
157 | 157 | ||
158 | #define MDIO_AN_10GBT_ADVERTISE 32 | 158 | #define MDIO_AN_10GBT_CTRL 32 |
159 | #define MDIO_AN_10GBT_CTRL_ADV_10G_LBN 12 | ||
159 | #define MDIO_AN_10GBT_STATUS (33) | 160 | #define MDIO_AN_10GBT_STATUS (33) |
160 | #define MDIO_AN_10GBT_STATUS_MS_FLT_LBN (15) /* MASTER/SLAVE config fault */ | 161 | #define MDIO_AN_10GBT_STATUS_MS_FLT_LBN (15) /* MASTER/SLAVE config fault */ |
161 | #define MDIO_AN_10GBT_STATUS_MS_LBN (14) /* MASTER/SLAVE config */ | 162 | #define MDIO_AN_10GBT_STATUS_MS_LBN (14) /* MASTER/SLAVE config */ |
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h index 5f255f75754e..e019ad1fb9a0 100644 --- a/drivers/net/sfc/net_driver.h +++ b/drivers/net/sfc/net_driver.h | |||
@@ -566,7 +566,7 @@ struct efx_mac_operations { | |||
566 | * @poll: Poll for hardware state. Serialised by the mac_lock. | 566 | * @poll: Poll for hardware state. Serialised by the mac_lock. |
567 | * @get_settings: Get ethtool settings. Serialised by the mac_lock. | 567 | * @get_settings: Get ethtool settings. Serialised by the mac_lock. |
568 | * @set_settings: Set ethtool settings. Serialised by the mac_lock. | 568 | * @set_settings: Set ethtool settings. Serialised by the mac_lock. |
569 | * @set_xnp_advertise: Set abilities advertised in Extended Next Page | 569 | * @set_npage_adv: Set abilities advertised in (Extended) Next Page |
570 | * (only needed where AN bit is set in mmds) | 570 | * (only needed where AN bit is set in mmds) |
571 | * @num_tests: Number of PHY-specific tests/results | 571 | * @num_tests: Number of PHY-specific tests/results |
572 | * @test_names: Names of the tests/results | 572 | * @test_names: Names of the tests/results |
@@ -586,7 +586,7 @@ struct efx_phy_operations { | |||
586 | struct ethtool_cmd *ecmd); | 586 | struct ethtool_cmd *ecmd); |
587 | int (*set_settings) (struct efx_nic *efx, | 587 | int (*set_settings) (struct efx_nic *efx, |
588 | struct ethtool_cmd *ecmd); | 588 | struct ethtool_cmd *ecmd); |
589 | bool (*set_xnp_advertise) (struct efx_nic *efx, u32); | 589 | void (*set_npage_adv) (struct efx_nic *efx, u32); |
590 | u32 num_tests; | 590 | u32 num_tests; |
591 | const char *const *test_names; | 591 | const char *const *test_names; |
592 | int (*run_tests) (struct efx_nic *efx, int *results, unsigned flags); | 592 | int (*run_tests) (struct efx_nic *efx, int *results, unsigned flags); |
@@ -754,8 +754,7 @@ union efx_multicast_hash { | |||
754 | * &struct net_device_stats. | 754 | * &struct net_device_stats. |
755 | * @stats_buffer: DMA buffer for statistics | 755 | * @stats_buffer: DMA buffer for statistics |
756 | * @stats_lock: Statistics update lock. Serialises statistics fetches | 756 | * @stats_lock: Statistics update lock. Serialises statistics fetches |
757 | * @stats_enabled: Temporarily disable statistics fetches. | 757 | * @stats_disable_count: Nest count for disabling statistics fetches |
758 | * Serialised by @stats_lock | ||
759 | * @mac_op: MAC interface | 758 | * @mac_op: MAC interface |
760 | * @mac_address: Permanent MAC address | 759 | * @mac_address: Permanent MAC address |
761 | * @phy_type: PHY type | 760 | * @phy_type: PHY type |
@@ -837,7 +836,7 @@ struct efx_nic { | |||
837 | struct efx_mac_stats mac_stats; | 836 | struct efx_mac_stats mac_stats; |
838 | struct efx_buffer stats_buffer; | 837 | struct efx_buffer stats_buffer; |
839 | spinlock_t stats_lock; | 838 | spinlock_t stats_lock; |
840 | bool stats_enabled; | 839 | unsigned int stats_disable_count; |
841 | 840 | ||
842 | struct efx_mac_operations *mac_op; | 841 | struct efx_mac_operations *mac_op; |
843 | unsigned char mac_address[ETH_ALEN]; | 842 | unsigned char mac_address[ETH_ALEN]; |
diff --git a/drivers/net/sfc/phy.h b/drivers/net/sfc/phy.h index 58c493ef81bb..07e855c148bc 100644 --- a/drivers/net/sfc/phy.h +++ b/drivers/net/sfc/phy.h | |||
@@ -17,7 +17,6 @@ extern struct efx_phy_operations falcon_sfx7101_phy_ops; | |||
17 | extern struct efx_phy_operations falcon_sft9001_phy_ops; | 17 | extern struct efx_phy_operations falcon_sft9001_phy_ops; |
18 | 18 | ||
19 | extern void tenxpress_phy_blink(struct efx_nic *efx, bool blink); | 19 | extern void tenxpress_phy_blink(struct efx_nic *efx, bool blink); |
20 | extern void tenxpress_crc_err(struct efx_nic *efx); | ||
21 | 20 | ||
22 | /**************************************************************************** | 21 | /**************************************************************************** |
23 | * Exported functions from the driver for XFP optical PHYs | 22 | * Exported functions from the driver for XFP optical PHYs |
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c index dba0d64d50cd..0a598084c513 100644 --- a/drivers/net/sfc/selftest.c +++ b/drivers/net/sfc/selftest.c | |||
@@ -665,6 +665,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, | |||
665 | { | 665 | { |
666 | enum efx_loopback_mode loopback_mode = efx->loopback_mode; | 666 | enum efx_loopback_mode loopback_mode = efx->loopback_mode; |
667 | int phy_mode = efx->phy_mode; | 667 | int phy_mode = efx->phy_mode; |
668 | enum reset_type reset_method = RESET_TYPE_INVISIBLE; | ||
668 | struct ethtool_cmd ecmd; | 669 | struct ethtool_cmd ecmd; |
669 | struct efx_channel *channel; | 670 | struct efx_channel *channel; |
670 | int rc_test = 0, rc_reset = 0, rc; | 671 | int rc_test = 0, rc_reset = 0, rc; |
@@ -718,21 +719,21 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, | |||
718 | mutex_unlock(&efx->mac_lock); | 719 | mutex_unlock(&efx->mac_lock); |
719 | 720 | ||
720 | /* free up all consumers of SRAM (including all the queues) */ | 721 | /* free up all consumers of SRAM (including all the queues) */ |
721 | efx_reset_down(efx, &ecmd); | 722 | efx_reset_down(efx, reset_method, &ecmd); |
722 | 723 | ||
723 | rc = efx_test_chip(efx, tests); | 724 | rc = efx_test_chip(efx, tests); |
724 | if (rc && !rc_test) | 725 | if (rc && !rc_test) |
725 | rc_test = rc; | 726 | rc_test = rc; |
726 | 727 | ||
727 | /* reset the chip to recover from the register test */ | 728 | /* reset the chip to recover from the register test */ |
728 | rc_reset = falcon_reset_hw(efx, RESET_TYPE_ALL); | 729 | rc_reset = falcon_reset_hw(efx, reset_method); |
729 | 730 | ||
730 | /* Ensure that the phy is powered and out of loopback | 731 | /* Ensure that the phy is powered and out of loopback |
731 | * for the bist and loopback tests */ | 732 | * for the bist and loopback tests */ |
732 | efx->phy_mode &= ~PHY_MODE_LOW_POWER; | 733 | efx->phy_mode &= ~PHY_MODE_LOW_POWER; |
733 | efx->loopback_mode = LOOPBACK_NONE; | 734 | efx->loopback_mode = LOOPBACK_NONE; |
734 | 735 | ||
735 | rc = efx_reset_up(efx, &ecmd, rc_reset == 0); | 736 | rc = efx_reset_up(efx, reset_method, &ecmd, rc_reset == 0); |
736 | if (rc && !rc_reset) | 737 | if (rc && !rc_reset) |
737 | rc_reset = rc; | 738 | rc_reset = rc; |
738 | 739 | ||
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c index 16b80acb9992..cb25ae5b257a 100644 --- a/drivers/net/sfc/sfe4001.c +++ b/drivers/net/sfc/sfe4001.c | |||
@@ -186,19 +186,22 @@ static int sfn4111t_reset(struct efx_nic *efx) | |||
186 | { | 186 | { |
187 | efx_oword_t reg; | 187 | efx_oword_t reg; |
188 | 188 | ||
189 | /* GPIO pins are also used for I2C, so block that temporarily */ | 189 | /* GPIO 3 and the GPIO register are shared with I2C, so block that */ |
190 | mutex_lock(&efx->i2c_adap.bus_lock); | 190 | mutex_lock(&efx->i2c_adap.bus_lock); |
191 | 191 | ||
192 | /* Pull RST_N (GPIO 2) low then let it up again, setting the | ||
193 | * FLASH_CFG_1 strap (GPIO 3) appropriately. Only change the | ||
194 | * output enables; the output levels should always be 0 (low) | ||
195 | * and we rely on external pull-ups. */ | ||
192 | falcon_read(efx, ®, GPIO_CTL_REG_KER); | 196 | falcon_read(efx, ®, GPIO_CTL_REG_KER); |
193 | EFX_SET_OWORD_FIELD(reg, GPIO2_OEN, true); | 197 | EFX_SET_OWORD_FIELD(reg, GPIO2_OEN, true); |
194 | EFX_SET_OWORD_FIELD(reg, GPIO2_OUT, false); | ||
195 | falcon_write(efx, ®, GPIO_CTL_REG_KER); | 198 | falcon_write(efx, ®, GPIO_CTL_REG_KER); |
196 | msleep(1000); | 199 | msleep(1000); |
197 | EFX_SET_OWORD_FIELD(reg, GPIO2_OUT, true); | 200 | EFX_SET_OWORD_FIELD(reg, GPIO2_OEN, false); |
198 | EFX_SET_OWORD_FIELD(reg, GPIO3_OEN, true); | 201 | EFX_SET_OWORD_FIELD(reg, GPIO3_OEN, |
199 | EFX_SET_OWORD_FIELD(reg, GPIO3_OUT, | 202 | !!(efx->phy_mode & PHY_MODE_SPECIAL)); |
200 | !(efx->phy_mode & PHY_MODE_SPECIAL)); | ||
201 | falcon_write(efx, ®, GPIO_CTL_REG_KER); | 203 | falcon_write(efx, ®, GPIO_CTL_REG_KER); |
204 | msleep(1); | ||
202 | 205 | ||
203 | mutex_unlock(&efx->i2c_adap.bus_lock); | 206 | mutex_unlock(&efx->i2c_adap.bus_lock); |
204 | 207 | ||
@@ -232,12 +235,18 @@ static ssize_t set_phy_flash_cfg(struct device *dev, | |||
232 | } else if (efx->state != STATE_RUNNING || netif_running(efx->net_dev)) { | 235 | } else if (efx->state != STATE_RUNNING || netif_running(efx->net_dev)) { |
233 | err = -EBUSY; | 236 | err = -EBUSY; |
234 | } else { | 237 | } else { |
238 | /* Reset the PHY, reconfigure the MAC and enable/disable | ||
239 | * MAC stats accordingly. */ | ||
235 | efx->phy_mode = new_mode; | 240 | efx->phy_mode = new_mode; |
241 | if (new_mode & PHY_MODE_SPECIAL) | ||
242 | efx_stats_disable(efx); | ||
236 | if (efx->board_info.type == EFX_BOARD_SFE4001) | 243 | if (efx->board_info.type == EFX_BOARD_SFE4001) |
237 | err = sfe4001_poweron(efx); | 244 | err = sfe4001_poweron(efx); |
238 | else | 245 | else |
239 | err = sfn4111t_reset(efx); | 246 | err = sfn4111t_reset(efx); |
240 | efx_reconfigure_port(efx); | 247 | efx_reconfigure_port(efx); |
248 | if (!(new_mode & PHY_MODE_SPECIAL)) | ||
249 | efx_stats_enable(efx); | ||
241 | } | 250 | } |
242 | rtnl_unlock(); | 251 | rtnl_unlock(); |
243 | 252 | ||
@@ -326,6 +335,11 @@ int sfe4001_init(struct efx_nic *efx) | |||
326 | efx->board_info.monitor = sfe4001_check_hw; | 335 | efx->board_info.monitor = sfe4001_check_hw; |
327 | efx->board_info.fini = sfe4001_fini; | 336 | efx->board_info.fini = sfe4001_fini; |
328 | 337 | ||
338 | if (efx->phy_mode & PHY_MODE_SPECIAL) { | ||
339 | /* PHY won't generate a 156.25 MHz clock and MAC stats fetch | ||
340 | * will fail. */ | ||
341 | efx_stats_disable(efx); | ||
342 | } | ||
329 | rc = sfe4001_poweron(efx); | 343 | rc = sfe4001_poweron(efx); |
330 | if (rc) | 344 | if (rc) |
331 | goto fail_ioexp; | 345 | goto fail_ioexp; |
@@ -372,17 +386,25 @@ static void sfn4111t_fini(struct efx_nic *efx) | |||
372 | i2c_unregister_device(efx->board_info.hwmon_client); | 386 | i2c_unregister_device(efx->board_info.hwmon_client); |
373 | } | 387 | } |
374 | 388 | ||
375 | static struct i2c_board_info sfn4111t_hwmon_info = { | 389 | static struct i2c_board_info sfn4111t_a0_hwmon_info = { |
376 | I2C_BOARD_INFO("max6647", 0x4e), | 390 | I2C_BOARD_INFO("max6647", 0x4e), |
377 | .irq = -1, | 391 | .irq = -1, |
378 | }; | 392 | }; |
379 | 393 | ||
394 | static struct i2c_board_info sfn4111t_r5_hwmon_info = { | ||
395 | I2C_BOARD_INFO("max6646", 0x4d), | ||
396 | .irq = -1, | ||
397 | }; | ||
398 | |||
380 | int sfn4111t_init(struct efx_nic *efx) | 399 | int sfn4111t_init(struct efx_nic *efx) |
381 | { | 400 | { |
382 | int rc; | 401 | int rc; |
383 | 402 | ||
384 | efx->board_info.hwmon_client = | 403 | efx->board_info.hwmon_client = |
385 | i2c_new_device(&efx->i2c_adap, &sfn4111t_hwmon_info); | 404 | i2c_new_device(&efx->i2c_adap, |
405 | (efx->board_info.minor < 5) ? | ||
406 | &sfn4111t_a0_hwmon_info : | ||
407 | &sfn4111t_r5_hwmon_info); | ||
386 | if (!efx->board_info.hwmon_client) | 408 | if (!efx->board_info.hwmon_client) |
387 | return -EIO; | 409 | return -EIO; |
388 | 410 | ||
@@ -394,8 +416,10 @@ int sfn4111t_init(struct efx_nic *efx) | |||
394 | if (rc) | 416 | if (rc) |
395 | goto fail_hwmon; | 417 | goto fail_hwmon; |
396 | 418 | ||
397 | if (efx->phy_mode & PHY_MODE_SPECIAL) | 419 | if (efx->phy_mode & PHY_MODE_SPECIAL) { |
420 | efx_stats_disable(efx); | ||
398 | sfn4111t_reset(efx); | 421 | sfn4111t_reset(efx); |
422 | } | ||
399 | 423 | ||
400 | return 0; | 424 | return 0; |
401 | 425 | ||
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c index 9ecb77da9545..f0efd246962c 100644 --- a/drivers/net/sfc/tenxpress.c +++ b/drivers/net/sfc/tenxpress.c | |||
@@ -67,6 +67,8 @@ | |||
67 | #define PMA_PMD_EXT_CLK312_WIDTH 1 | 67 | #define PMA_PMD_EXT_CLK312_WIDTH 1 |
68 | #define PMA_PMD_EXT_LPOWER_LBN 12 | 68 | #define PMA_PMD_EXT_LPOWER_LBN 12 |
69 | #define PMA_PMD_EXT_LPOWER_WIDTH 1 | 69 | #define PMA_PMD_EXT_LPOWER_WIDTH 1 |
70 | #define PMA_PMD_EXT_ROBUST_LBN 14 | ||
71 | #define PMA_PMD_EXT_ROBUST_WIDTH 1 | ||
70 | #define PMA_PMD_EXT_SSR_LBN 15 | 72 | #define PMA_PMD_EXT_SSR_LBN 15 |
71 | #define PMA_PMD_EXT_SSR_WIDTH 1 | 73 | #define PMA_PMD_EXT_SSR_WIDTH 1 |
72 | 74 | ||
@@ -177,35 +179,24 @@ | |||
177 | #define C22EXT_STATUS_LINK_LBN 2 | 179 | #define C22EXT_STATUS_LINK_LBN 2 |
178 | #define C22EXT_STATUS_LINK_WIDTH 1 | 180 | #define C22EXT_STATUS_LINK_WIDTH 1 |
179 | 181 | ||
180 | #define C22EXT_MSTSLV_REG 49162 | 182 | #define C22EXT_MSTSLV_CTRL 49161 |
181 | #define C22EXT_MSTSLV_1000_HD_LBN 10 | 183 | #define C22EXT_MSTSLV_CTRL_ADV_1000_HD_LBN 8 |
182 | #define C22EXT_MSTSLV_1000_HD_WIDTH 1 | 184 | #define C22EXT_MSTSLV_CTRL_ADV_1000_FD_LBN 9 |
183 | #define C22EXT_MSTSLV_1000_FD_LBN 11 | 185 | |
184 | #define C22EXT_MSTSLV_1000_FD_WIDTH 1 | 186 | #define C22EXT_MSTSLV_STATUS 49162 |
187 | #define C22EXT_MSTSLV_STATUS_LP_1000_HD_LBN 10 | ||
188 | #define C22EXT_MSTSLV_STATUS_LP_1000_FD_LBN 11 | ||
185 | 189 | ||
186 | /* Time to wait between powering down the LNPGA and turning off the power | 190 | /* Time to wait between powering down the LNPGA and turning off the power |
187 | * rails */ | 191 | * rails */ |
188 | #define LNPGA_PDOWN_WAIT (HZ / 5) | 192 | #define LNPGA_PDOWN_WAIT (HZ / 5) |
189 | 193 | ||
190 | static int crc_error_reset_threshold = 100; | ||
191 | module_param(crc_error_reset_threshold, int, 0644); | ||
192 | MODULE_PARM_DESC(crc_error_reset_threshold, | ||
193 | "Max number of CRC errors before XAUI reset"); | ||
194 | |||
195 | struct tenxpress_phy_data { | 194 | struct tenxpress_phy_data { |
196 | enum efx_loopback_mode loopback_mode; | 195 | enum efx_loopback_mode loopback_mode; |
197 | atomic_t bad_crc_count; | ||
198 | enum efx_phy_mode phy_mode; | 196 | enum efx_phy_mode phy_mode; |
199 | int bad_lp_tries; | 197 | int bad_lp_tries; |
200 | }; | 198 | }; |
201 | 199 | ||
202 | void tenxpress_crc_err(struct efx_nic *efx) | ||
203 | { | ||
204 | struct tenxpress_phy_data *phy_data = efx->phy_data; | ||
205 | if (phy_data != NULL) | ||
206 | atomic_inc(&phy_data->bad_crc_count); | ||
207 | } | ||
208 | |||
209 | static ssize_t show_phy_short_reach(struct device *dev, | 200 | static ssize_t show_phy_short_reach(struct device *dev, |
210 | struct device_attribute *attr, char *buf) | 201 | struct device_attribute *attr, char *buf) |
211 | { | 202 | { |
@@ -284,7 +275,9 @@ static int tenxpress_init(struct efx_nic *efx) | |||
284 | PMA_PMD_XCONTROL_REG); | 275 | PMA_PMD_XCONTROL_REG); |
285 | reg |= ((1 << PMA_PMD_EXT_GMII_EN_LBN) | | 276 | reg |= ((1 << PMA_PMD_EXT_GMII_EN_LBN) | |
286 | (1 << PMA_PMD_EXT_CLK_OUT_LBN) | | 277 | (1 << PMA_PMD_EXT_CLK_OUT_LBN) | |
287 | (1 << PMA_PMD_EXT_CLK312_LBN)); | 278 | (1 << PMA_PMD_EXT_CLK312_LBN) | |
279 | (1 << PMA_PMD_EXT_ROBUST_LBN)); | ||
280 | |||
288 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, | 281 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, |
289 | PMA_PMD_XCONTROL_REG, reg); | 282 | PMA_PMD_XCONTROL_REG, reg); |
290 | mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_C22EXT, | 283 | mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_C22EXT, |
@@ -346,6 +339,7 @@ static int tenxpress_phy_init(struct efx_nic *efx) | |||
346 | rc = tenxpress_init(efx); | 339 | rc = tenxpress_init(efx); |
347 | if (rc < 0) | 340 | if (rc < 0) |
348 | goto fail; | 341 | goto fail; |
342 | mdio_clause45_set_pause(efx); | ||
349 | 343 | ||
350 | if (efx->phy_type == PHY_TYPE_SFT9001B) { | 344 | if (efx->phy_type == PHY_TYPE_SFT9001B) { |
351 | rc = device_create_file(&efx->pci_dev->dev, | 345 | rc = device_create_file(&efx->pci_dev->dev, |
@@ -376,8 +370,8 @@ static int tenxpress_special_reset(struct efx_nic *efx) | |||
376 | 370 | ||
377 | /* The XGMAC clock is driven from the SFC7101/SFT9001 312MHz clock, so | 371 | /* The XGMAC clock is driven from the SFC7101/SFT9001 312MHz clock, so |
378 | * a special software reset can glitch the XGMAC sufficiently for stats | 372 | * a special software reset can glitch the XGMAC sufficiently for stats |
379 | * requests to fail. Since we don't often special_reset, just lock. */ | 373 | * requests to fail. */ |
380 | spin_lock(&efx->stats_lock); | 374 | efx_stats_disable(efx); |
381 | 375 | ||
382 | /* Initiate reset */ | 376 | /* Initiate reset */ |
383 | reg = mdio_clause45_read(efx, efx->mii.phy_id, | 377 | reg = mdio_clause45_read(efx, efx->mii.phy_id, |
@@ -392,17 +386,17 @@ static int tenxpress_special_reset(struct efx_nic *efx) | |||
392 | rc = mdio_clause45_wait_reset_mmds(efx, | 386 | rc = mdio_clause45_wait_reset_mmds(efx, |
393 | TENXPRESS_REQUIRED_DEVS); | 387 | TENXPRESS_REQUIRED_DEVS); |
394 | if (rc < 0) | 388 | if (rc < 0) |
395 | goto unlock; | 389 | goto out; |
396 | 390 | ||
397 | /* Try and reconfigure the device */ | 391 | /* Try and reconfigure the device */ |
398 | rc = tenxpress_init(efx); | 392 | rc = tenxpress_init(efx); |
399 | if (rc < 0) | 393 | if (rc < 0) |
400 | goto unlock; | 394 | goto out; |
401 | 395 | ||
402 | /* Wait for the XGXS state machine to churn */ | 396 | /* Wait for the XGXS state machine to churn */ |
403 | mdelay(10); | 397 | mdelay(10); |
404 | unlock: | 398 | out: |
405 | spin_unlock(&efx->stats_lock); | 399 | efx_stats_enable(efx); |
406 | return rc; | 400 | return rc; |
407 | } | 401 | } |
408 | 402 | ||
@@ -520,7 +514,7 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx) | |||
520 | { | 514 | { |
521 | struct tenxpress_phy_data *phy_data = efx->phy_data; | 515 | struct tenxpress_phy_data *phy_data = efx->phy_data; |
522 | struct ethtool_cmd ecmd; | 516 | struct ethtool_cmd ecmd; |
523 | bool phy_mode_change, loop_reset, loop_toggle, loopback; | 517 | bool phy_mode_change, loop_reset; |
524 | 518 | ||
525 | if (efx->phy_mode & (PHY_MODE_OFF | PHY_MODE_SPECIAL)) { | 519 | if (efx->phy_mode & (PHY_MODE_OFF | PHY_MODE_SPECIAL)) { |
526 | phy_data->phy_mode = efx->phy_mode; | 520 | phy_data->phy_mode = efx->phy_mode; |
@@ -531,12 +525,10 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx) | |||
531 | 525 | ||
532 | phy_mode_change = (efx->phy_mode == PHY_MODE_NORMAL && | 526 | phy_mode_change = (efx->phy_mode == PHY_MODE_NORMAL && |
533 | phy_data->phy_mode != PHY_MODE_NORMAL); | 527 | phy_data->phy_mode != PHY_MODE_NORMAL); |
534 | loopback = LOOPBACK_MASK(efx) & efx->phy_op->loopbacks; | ||
535 | loop_toggle = LOOPBACK_CHANGED(phy_data, efx, efx->phy_op->loopbacks); | ||
536 | loop_reset = (LOOPBACK_OUT_OF(phy_data, efx, efx->phy_op->loopbacks) || | 528 | loop_reset = (LOOPBACK_OUT_OF(phy_data, efx, efx->phy_op->loopbacks) || |
537 | LOOPBACK_CHANGED(phy_data, efx, 1 << LOOPBACK_GPHY)); | 529 | LOOPBACK_CHANGED(phy_data, efx, 1 << LOOPBACK_GPHY)); |
538 | 530 | ||
539 | if (loop_reset || loop_toggle || loopback || phy_mode_change) { | 531 | if (loop_reset || phy_mode_change) { |
540 | int rc; | 532 | int rc; |
541 | 533 | ||
542 | efx->phy_op->get_settings(efx, &ecmd); | 534 | efx->phy_op->get_settings(efx, &ecmd); |
@@ -551,20 +543,6 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx) | |||
551 | falcon_reset_xaui(efx); | 543 | falcon_reset_xaui(efx); |
552 | } | 544 | } |
553 | 545 | ||
554 | if (efx->phy_type != PHY_TYPE_SFX7101) { | ||
555 | /* Only change autoneg once, on coming out or | ||
556 | * going into loopback */ | ||
557 | if (loop_toggle) | ||
558 | ecmd.autoneg = !loopback; | ||
559 | if (loopback) { | ||
560 | ecmd.duplex = DUPLEX_FULL; | ||
561 | if (efx->loopback_mode == LOOPBACK_GPHY) | ||
562 | ecmd.speed = SPEED_1000; | ||
563 | else | ||
564 | ecmd.speed = SPEED_10000; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | rc = efx->phy_op->set_settings(efx, &ecmd); | 546 | rc = efx->phy_op->set_settings(efx, &ecmd); |
569 | WARN_ON(rc); | 547 | WARN_ON(rc); |
570 | } | 548 | } |
@@ -623,13 +601,6 @@ static void tenxpress_phy_poll(struct efx_nic *efx) | |||
623 | 601 | ||
624 | if (phy_data->phy_mode != PHY_MODE_NORMAL) | 602 | if (phy_data->phy_mode != PHY_MODE_NORMAL) |
625 | return; | 603 | return; |
626 | |||
627 | if (EFX_WORKAROUND_10750(efx) && | ||
628 | atomic_read(&phy_data->bad_crc_count) > crc_error_reset_threshold) { | ||
629 | EFX_ERR(efx, "Resetting XAUI due to too many CRC errors\n"); | ||
630 | falcon_reset_xaui(efx); | ||
631 | atomic_set(&phy_data->bad_crc_count, 0); | ||
632 | } | ||
633 | } | 604 | } |
634 | 605 | ||
635 | static void tenxpress_phy_fini(struct efx_nic *efx) | 606 | static void tenxpress_phy_fini(struct efx_nic *efx) |
@@ -772,107 +743,76 @@ reset: | |||
772 | return rc; | 743 | return rc; |
773 | } | 744 | } |
774 | 745 | ||
775 | static u32 tenxpress_get_xnp_lpa(struct efx_nic *efx) | 746 | static void |
747 | tenxpress_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) | ||
776 | { | 748 | { |
777 | int phy = efx->mii.phy_id; | 749 | int phy_id = efx->mii.phy_id; |
778 | u32 lpa = 0; | 750 | u32 adv = 0, lpa = 0; |
779 | int reg; | 751 | int reg; |
780 | 752 | ||
781 | if (efx->phy_type != PHY_TYPE_SFX7101) { | 753 | if (efx->phy_type != PHY_TYPE_SFX7101) { |
782 | reg = mdio_clause45_read(efx, phy, MDIO_MMD_C22EXT, | 754 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_C22EXT, |
783 | C22EXT_MSTSLV_REG); | 755 | C22EXT_MSTSLV_CTRL); |
784 | if (reg & (1 << C22EXT_MSTSLV_1000_HD_LBN)) | 756 | if (reg & (1 << C22EXT_MSTSLV_CTRL_ADV_1000_FD_LBN)) |
757 | adv |= ADVERTISED_1000baseT_Full; | ||
758 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_C22EXT, | ||
759 | C22EXT_MSTSLV_STATUS); | ||
760 | if (reg & (1 << C22EXT_MSTSLV_STATUS_LP_1000_HD_LBN)) | ||
785 | lpa |= ADVERTISED_1000baseT_Half; | 761 | lpa |= ADVERTISED_1000baseT_Half; |
786 | if (reg & (1 << C22EXT_MSTSLV_1000_FD_LBN)) | 762 | if (reg & (1 << C22EXT_MSTSLV_STATUS_LP_1000_FD_LBN)) |
787 | lpa |= ADVERTISED_1000baseT_Full; | 763 | lpa |= ADVERTISED_1000baseT_Full; |
788 | } | 764 | } |
789 | reg = mdio_clause45_read(efx, phy, MDIO_MMD_AN, MDIO_AN_10GBT_STATUS); | 765 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN, |
766 | MDIO_AN_10GBT_CTRL); | ||
767 | if (reg & (1 << MDIO_AN_10GBT_CTRL_ADV_10G_LBN)) | ||
768 | adv |= ADVERTISED_10000baseT_Full; | ||
769 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN, | ||
770 | MDIO_AN_10GBT_STATUS); | ||
790 | if (reg & (1 << MDIO_AN_10GBT_STATUS_LP_10G_LBN)) | 771 | if (reg & (1 << MDIO_AN_10GBT_STATUS_LP_10G_LBN)) |
791 | lpa |= ADVERTISED_10000baseT_Full; | 772 | lpa |= ADVERTISED_10000baseT_Full; |
792 | return lpa; | ||
793 | } | ||
794 | 773 | ||
795 | static void sfx7101_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) | 774 | mdio_clause45_get_settings_ext(efx, ecmd, adv, lpa); |
796 | { | 775 | |
797 | mdio_clause45_get_settings_ext(efx, ecmd, ADVERTISED_10000baseT_Full, | 776 | if (efx->phy_type != PHY_TYPE_SFX7101) |
798 | tenxpress_get_xnp_lpa(efx)); | 777 | ecmd->supported |= (SUPPORTED_100baseT_Full | |
799 | ecmd->supported |= SUPPORTED_10000baseT_Full; | 778 | SUPPORTED_1000baseT_Full); |
800 | ecmd->advertising |= ADVERTISED_10000baseT_Full; | 779 | |
780 | /* In loopback, the PHY automatically brings up the correct interface, | ||
781 | * but doesn't advertise the correct speed. So override it */ | ||
782 | if (efx->loopback_mode == LOOPBACK_GPHY) | ||
783 | ecmd->speed = SPEED_1000; | ||
784 | else if (LOOPBACK_MASK(efx) & efx->phy_op->loopbacks) | ||
785 | ecmd->speed = SPEED_10000; | ||
801 | } | 786 | } |
802 | 787 | ||
803 | static void sft9001_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) | 788 | static int tenxpress_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) |
804 | { | 789 | { |
805 | int phy_id = efx->mii.phy_id; | 790 | if (!ecmd->autoneg) |
806 | u32 xnp_adv = 0; | 791 | return -EINVAL; |
807 | int reg; | ||
808 | |||
809 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, | ||
810 | PMA_PMD_SPEED_ENABLE_REG); | ||
811 | if (EFX_WORKAROUND_13204(efx) && (reg & (1 << PMA_PMD_100TX_ADV_LBN))) | ||
812 | xnp_adv |= ADVERTISED_100baseT_Full; | ||
813 | if (reg & (1 << PMA_PMD_1000T_ADV_LBN)) | ||
814 | xnp_adv |= ADVERTISED_1000baseT_Full; | ||
815 | if (reg & (1 << PMA_PMD_10000T_ADV_LBN)) | ||
816 | xnp_adv |= ADVERTISED_10000baseT_Full; | ||
817 | |||
818 | mdio_clause45_get_settings_ext(efx, ecmd, xnp_adv, | ||
819 | tenxpress_get_xnp_lpa(efx)); | ||
820 | |||
821 | ecmd->supported |= (SUPPORTED_100baseT_Half | | ||
822 | SUPPORTED_100baseT_Full | | ||
823 | SUPPORTED_1000baseT_Full); | ||
824 | 792 | ||
825 | /* Use the vendor defined C22ext register for duplex settings */ | 793 | return mdio_clause45_set_settings(efx, ecmd); |
826 | if (ecmd->speed != SPEED_10000 && !ecmd->autoneg) { | ||
827 | reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_C22EXT, | ||
828 | GPHY_XCONTROL_REG); | ||
829 | ecmd->duplex = (reg & (1 << GPHY_DUPLEX_LBN) ? | ||
830 | DUPLEX_FULL : DUPLEX_HALF); | ||
831 | } | ||
832 | } | 794 | } |
833 | 795 | ||
834 | static int sft9001_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) | 796 | static void sfx7101_set_npage_adv(struct efx_nic *efx, u32 advertising) |
835 | { | 797 | { |
836 | int phy_id = efx->mii.phy_id; | 798 | mdio_clause45_set_flag(efx, efx->mii.phy_id, MDIO_MMD_AN, |
837 | int rc; | 799 | MDIO_AN_10GBT_CTRL, |
838 | 800 | MDIO_AN_10GBT_CTRL_ADV_10G_LBN, | |
839 | rc = mdio_clause45_set_settings(efx, ecmd); | 801 | advertising & ADVERTISED_10000baseT_Full); |
840 | if (rc) | ||
841 | return rc; | ||
842 | |||
843 | if (ecmd->speed != SPEED_10000 && !ecmd->autoneg) | ||
844 | mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_C22EXT, | ||
845 | GPHY_XCONTROL_REG, GPHY_DUPLEX_LBN, | ||
846 | ecmd->duplex == DUPLEX_FULL); | ||
847 | |||
848 | return rc; | ||
849 | } | 802 | } |
850 | 803 | ||
851 | static bool sft9001_set_xnp_advertise(struct efx_nic *efx, u32 advertising) | 804 | static void sft9001_set_npage_adv(struct efx_nic *efx, u32 advertising) |
852 | { | 805 | { |
853 | int phy = efx->mii.phy_id; | 806 | int phy_id = efx->mii.phy_id; |
854 | int reg = mdio_clause45_read(efx, phy, MDIO_MMD_PMAPMD, | 807 | |
855 | PMA_PMD_SPEED_ENABLE_REG); | 808 | mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_C22EXT, |
856 | bool enabled; | 809 | C22EXT_MSTSLV_CTRL, |
857 | 810 | C22EXT_MSTSLV_CTRL_ADV_1000_FD_LBN, | |
858 | reg &= ~((1 << 2) | (1 << 3)); | 811 | advertising & ADVERTISED_1000baseT_Full); |
859 | if (EFX_WORKAROUND_13204(efx) && | 812 | mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_AN, |
860 | (advertising & ADVERTISED_100baseT_Full)) | 813 | MDIO_AN_10GBT_CTRL, |
861 | reg |= 1 << PMA_PMD_100TX_ADV_LBN; | 814 | MDIO_AN_10GBT_CTRL_ADV_10G_LBN, |
862 | if (advertising & ADVERTISED_1000baseT_Full) | 815 | advertising & ADVERTISED_10000baseT_Full); |
863 | reg |= 1 << PMA_PMD_1000T_ADV_LBN; | ||
864 | if (advertising & ADVERTISED_10000baseT_Full) | ||
865 | reg |= 1 << PMA_PMD_10000T_ADV_LBN; | ||
866 | mdio_clause45_write(efx, phy, MDIO_MMD_PMAPMD, | ||
867 | PMA_PMD_SPEED_ENABLE_REG, reg); | ||
868 | |||
869 | enabled = (advertising & | ||
870 | (ADVERTISED_1000baseT_Half | | ||
871 | ADVERTISED_1000baseT_Full | | ||
872 | ADVERTISED_10000baseT_Full)); | ||
873 | if (EFX_WORKAROUND_13204(efx)) | ||
874 | enabled |= (advertising & ADVERTISED_100baseT_Full); | ||
875 | return enabled; | ||
876 | } | 816 | } |
877 | 817 | ||
878 | struct efx_phy_operations falcon_sfx7101_phy_ops = { | 818 | struct efx_phy_operations falcon_sfx7101_phy_ops = { |
@@ -882,8 +822,9 @@ struct efx_phy_operations falcon_sfx7101_phy_ops = { | |||
882 | .poll = tenxpress_phy_poll, | 822 | .poll = tenxpress_phy_poll, |
883 | .fini = tenxpress_phy_fini, | 823 | .fini = tenxpress_phy_fini, |
884 | .clear_interrupt = efx_port_dummy_op_void, | 824 | .clear_interrupt = efx_port_dummy_op_void, |
885 | .get_settings = sfx7101_get_settings, | 825 | .get_settings = tenxpress_get_settings, |
886 | .set_settings = mdio_clause45_set_settings, | 826 | .set_settings = tenxpress_set_settings, |
827 | .set_npage_adv = sfx7101_set_npage_adv, | ||
887 | .num_tests = ARRAY_SIZE(sfx7101_test_names), | 828 | .num_tests = ARRAY_SIZE(sfx7101_test_names), |
888 | .test_names = sfx7101_test_names, | 829 | .test_names = sfx7101_test_names, |
889 | .run_tests = sfx7101_run_tests, | 830 | .run_tests = sfx7101_run_tests, |
@@ -898,9 +839,9 @@ struct efx_phy_operations falcon_sft9001_phy_ops = { | |||
898 | .poll = tenxpress_phy_poll, | 839 | .poll = tenxpress_phy_poll, |
899 | .fini = tenxpress_phy_fini, | 840 | .fini = tenxpress_phy_fini, |
900 | .clear_interrupt = efx_port_dummy_op_void, | 841 | .clear_interrupt = efx_port_dummy_op_void, |
901 | .get_settings = sft9001_get_settings, | 842 | .get_settings = tenxpress_get_settings, |
902 | .set_settings = sft9001_set_settings, | 843 | .set_settings = tenxpress_set_settings, |
903 | .set_xnp_advertise = sft9001_set_xnp_advertise, | 844 | .set_npage_adv = sft9001_set_npage_adv, |
904 | .num_tests = ARRAY_SIZE(sft9001_test_names), | 845 | .num_tests = ARRAY_SIZE(sft9001_test_names), |
905 | .test_names = sft9001_test_names, | 846 | .test_names = sft9001_test_names, |
906 | .run_tests = sft9001_run_tests, | 847 | .run_tests = sft9001_run_tests, |
diff --git a/drivers/net/sfc/workarounds.h b/drivers/net/sfc/workarounds.h index 82e03e1d7371..78de68f4a95b 100644 --- a/drivers/net/sfc/workarounds.h +++ b/drivers/net/sfc/workarounds.h | |||
@@ -18,8 +18,8 @@ | |||
18 | #define EFX_WORKAROUND_ALWAYS(efx) 1 | 18 | #define EFX_WORKAROUND_ALWAYS(efx) 1 |
19 | #define EFX_WORKAROUND_FALCON_A(efx) (falcon_rev(efx) <= FALCON_REV_A1) | 19 | #define EFX_WORKAROUND_FALCON_A(efx) (falcon_rev(efx) <= FALCON_REV_A1) |
20 | #define EFX_WORKAROUND_10G(efx) EFX_IS10G(efx) | 20 | #define EFX_WORKAROUND_10G(efx) EFX_IS10G(efx) |
21 | #define EFX_WORKAROUND_SFX7101(efx) ((efx)->phy_type == PHY_TYPE_SFX7101) | 21 | #define EFX_WORKAROUND_SFT9001(efx) ((efx)->phy_type == PHY_TYPE_SFT9001A || \ |
22 | #define EFX_WORKAROUND_SFT9001A(efx) ((efx)->phy_type == PHY_TYPE_SFT9001A) | 22 | (efx)->phy_type == PHY_TYPE_SFT9001B) |
23 | 23 | ||
24 | /* XAUI resets if link not detected */ | 24 | /* XAUI resets if link not detected */ |
25 | #define EFX_WORKAROUND_5147 EFX_WORKAROUND_ALWAYS | 25 | #define EFX_WORKAROUND_5147 EFX_WORKAROUND_ALWAYS |
@@ -29,8 +29,6 @@ | |||
29 | #define EFX_WORKAROUND_7884 EFX_WORKAROUND_10G | 29 | #define EFX_WORKAROUND_7884 EFX_WORKAROUND_10G |
30 | /* TX pkt parser problem with <= 16 byte TXes */ | 30 | /* TX pkt parser problem with <= 16 byte TXes */ |
31 | #define EFX_WORKAROUND_9141 EFX_WORKAROUND_ALWAYS | 31 | #define EFX_WORKAROUND_9141 EFX_WORKAROUND_ALWAYS |
32 | /* Low rate CRC errors require XAUI reset */ | ||
33 | #define EFX_WORKAROUND_10750 EFX_WORKAROUND_SFX7101 | ||
34 | /* TX_EV_PKT_ERR can be caused by a dangling TX descriptor | 32 | /* TX_EV_PKT_ERR can be caused by a dangling TX descriptor |
35 | * or a PCIe error (bug 11028) */ | 33 | * or a PCIe error (bug 11028) */ |
36 | #define EFX_WORKAROUND_10727 EFX_WORKAROUND_ALWAYS | 34 | #define EFX_WORKAROUND_10727 EFX_WORKAROUND_ALWAYS |
@@ -55,8 +53,8 @@ | |||
55 | #define EFX_WORKAROUND_8071 EFX_WORKAROUND_FALCON_A | 53 | #define EFX_WORKAROUND_8071 EFX_WORKAROUND_FALCON_A |
56 | 54 | ||
57 | /* Need to send XNP pages for 100BaseT */ | 55 | /* Need to send XNP pages for 100BaseT */ |
58 | #define EFX_WORKAROUND_13204 EFX_WORKAROUND_SFT9001A | 56 | #define EFX_WORKAROUND_13204 EFX_WORKAROUND_SFT9001 |
59 | /* Need to keep AN enabled */ | 57 | /* Don't restart AN in near-side loopback */ |
60 | #define EFX_WORKAROUND_13963 EFX_WORKAROUND_SFT9001A | 58 | #define EFX_WORKAROUND_15195 EFX_WORKAROUND_SFT9001 |
61 | 59 | ||
62 | #endif /* EFX_WORKAROUNDS_H */ | 60 | #endif /* EFX_WORKAROUNDS_H */ |
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 3668e81e474d..994703cc0db3 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -1403,9 +1403,6 @@ static int sky2_up(struct net_device *dev) | |||
1403 | 1403 | ||
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | if (netif_msg_ifup(sky2)) | ||
1407 | printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); | ||
1408 | |||
1409 | netif_carrier_off(dev); | 1406 | netif_carrier_off(dev); |
1410 | 1407 | ||
1411 | /* must be power of 2 */ | 1408 | /* must be power of 2 */ |
@@ -1484,6 +1481,9 @@ static int sky2_up(struct net_device *dev) | |||
1484 | sky2_write32(hw, B0_IMSK, imask); | 1481 | sky2_write32(hw, B0_IMSK, imask); |
1485 | 1482 | ||
1486 | sky2_set_multicast(dev); | 1483 | sky2_set_multicast(dev); |
1484 | |||
1485 | if (netif_msg_ifup(sky2)) | ||
1486 | printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); | ||
1487 | return 0; | 1487 | return 0; |
1488 | 1488 | ||
1489 | err_out: | 1489 | err_out: |
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index bf3aa2a1effe..223cde0d43be 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c | |||
@@ -220,9 +220,9 @@ static void smc911x_reset(struct net_device *dev) | |||
220 | 220 | ||
221 | /* make sure EEPROM has finished loading before setting GPIO_CFG */ | 221 | /* make sure EEPROM has finished loading before setting GPIO_CFG */ |
222 | timeout=1000; | 222 | timeout=1000; |
223 | while ( timeout-- && (SMC_GET_E2P_CMD(lp) & E2P_CMD_EPC_BUSY_)) { | 223 | while (--timeout && (SMC_GET_E2P_CMD(lp) & E2P_CMD_EPC_BUSY_)) |
224 | udelay(10); | 224 | udelay(10); |
225 | } | 225 | |
226 | if (timeout == 0){ | 226 | if (timeout == 0){ |
227 | PRINTK("%s: smc911x_reset timeout waiting for EEPROM busy\n", dev->name); | 227 | PRINTK("%s: smc911x_reset timeout waiting for EEPROM busy\n", dev->name); |
228 | return; | 228 | return; |
diff --git a/drivers/net/smsc9420.c b/drivers/net/smsc9420.c index d801900a5036..a1e4b3895b33 100644 --- a/drivers/net/smsc9420.c +++ b/drivers/net/smsc9420.c | |||
@@ -498,7 +498,7 @@ static void smsc9420_check_mac_address(struct net_device *dev) | |||
498 | static void smsc9420_stop_tx(struct smsc9420_pdata *pd) | 498 | static void smsc9420_stop_tx(struct smsc9420_pdata *pd) |
499 | { | 499 | { |
500 | u32 dmac_control, mac_cr, dma_intr_ena; | 500 | u32 dmac_control, mac_cr, dma_intr_ena; |
501 | int timeOut = 1000; | 501 | int timeout = 1000; |
502 | 502 | ||
503 | /* disable TX DMAC */ | 503 | /* disable TX DMAC */ |
504 | dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); | 504 | dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); |
@@ -506,13 +506,13 @@ static void smsc9420_stop_tx(struct smsc9420_pdata *pd) | |||
506 | smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); | 506 | smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); |
507 | 507 | ||
508 | /* Wait max 10ms for transmit process to stop */ | 508 | /* Wait max 10ms for transmit process to stop */ |
509 | while (timeOut--) { | 509 | while (--timeout) { |
510 | if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_TS_) | 510 | if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_TS_) |
511 | break; | 511 | break; |
512 | udelay(10); | 512 | udelay(10); |
513 | } | 513 | } |
514 | 514 | ||
515 | if (!timeOut) | 515 | if (!timeout) |
516 | smsc_warn(IFDOWN, "TX DMAC failed to stop"); | 516 | smsc_warn(IFDOWN, "TX DMAC failed to stop"); |
517 | 517 | ||
518 | /* ACK Tx DMAC stop bit */ | 518 | /* ACK Tx DMAC stop bit */ |
@@ -596,7 +596,7 @@ static void smsc9420_free_rx_ring(struct smsc9420_pdata *pd) | |||
596 | 596 | ||
597 | static void smsc9420_stop_rx(struct smsc9420_pdata *pd) | 597 | static void smsc9420_stop_rx(struct smsc9420_pdata *pd) |
598 | { | 598 | { |
599 | int timeOut = 1000; | 599 | int timeout = 1000; |
600 | u32 mac_cr, dmac_control, dma_intr_ena; | 600 | u32 mac_cr, dmac_control, dma_intr_ena; |
601 | 601 | ||
602 | /* mask RX DMAC interrupts */ | 602 | /* mask RX DMAC interrupts */ |
@@ -617,13 +617,13 @@ static void smsc9420_stop_rx(struct smsc9420_pdata *pd) | |||
617 | smsc9420_pci_flush_write(pd); | 617 | smsc9420_pci_flush_write(pd); |
618 | 618 | ||
619 | /* wait up to 10ms for receive to stop */ | 619 | /* wait up to 10ms for receive to stop */ |
620 | while (timeOut--) { | 620 | while (--timeout) { |
621 | if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_RS_) | 621 | if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_RS_) |
622 | break; | 622 | break; |
623 | udelay(10); | 623 | udelay(10); |
624 | } | 624 | } |
625 | 625 | ||
626 | if (!timeOut) | 626 | if (!timeout) |
627 | smsc_warn(IFDOWN, "RX DMAC did not stop! timeout."); | 627 | smsc_warn(IFDOWN, "RX DMAC did not stop! timeout."); |
628 | 628 | ||
629 | /* ACK the Rx DMAC stop bit */ | 629 | /* ACK the Rx DMAC stop bit */ |
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 86c765d83de1..b17efa9cc530 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c | |||
@@ -148,7 +148,7 @@ static u16 __phy_read(struct gem *gp, int phy_addr, int reg) | |||
148 | cmd |= (MIF_FRAME_TAMSB); | 148 | cmd |= (MIF_FRAME_TAMSB); |
149 | writel(cmd, gp->regs + MIF_FRAME); | 149 | writel(cmd, gp->regs + MIF_FRAME); |
150 | 150 | ||
151 | while (limit--) { | 151 | while (--limit) { |
152 | cmd = readl(gp->regs + MIF_FRAME); | 152 | cmd = readl(gp->regs + MIF_FRAME); |
153 | if (cmd & MIF_FRAME_TALSB) | 153 | if (cmd & MIF_FRAME_TALSB) |
154 | break; | 154 | break; |
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c index 61843fd57525..78f8cee5fd74 100644 --- a/drivers/net/sungem_phy.c +++ b/drivers/net/sungem_phy.c | |||
@@ -79,7 +79,7 @@ static int reset_one_mii_phy(struct mii_phy* phy, int phy_id) | |||
79 | 79 | ||
80 | udelay(100); | 80 | udelay(100); |
81 | 81 | ||
82 | while (limit--) { | 82 | while (--limit) { |
83 | val = __phy_read(phy, phy_id, MII_BMCR); | 83 | val = __phy_read(phy, phy_id, MII_BMCR); |
84 | if ((val & BMCR_RESET) == 0) | 84 | if ((val & BMCR_RESET) == 0) |
85 | break; | 85 | break; |
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c index 6e8f377355fe..fe0c3f244562 100644 --- a/drivers/net/sunqe.c +++ b/drivers/net/sunqe.c | |||
@@ -227,7 +227,7 @@ static int qe_init(struct sunqe *qep, int from_irq) | |||
227 | if (!(sbus_readb(mregs + MREGS_PHYCONFIG) & MREGS_PHYCONFIG_LTESTDIS)) { | 227 | if (!(sbus_readb(mregs + MREGS_PHYCONFIG) & MREGS_PHYCONFIG_LTESTDIS)) { |
228 | int tries = 50; | 228 | int tries = 50; |
229 | 229 | ||
230 | while (tries--) { | 230 | while (--tries) { |
231 | u8 tmp; | 231 | u8 tmp; |
232 | 232 | ||
233 | mdelay(5); | 233 | mdelay(5); |
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c index 75461dbd4876..a9fd2b2ccaf6 100644 --- a/drivers/net/tsi108_eth.c +++ b/drivers/net/tsi108_eth.c | |||
@@ -1237,7 +1237,7 @@ static void tsi108_init_phy(struct net_device *dev) | |||
1237 | spin_lock_irqsave(&phy_lock, flags); | 1237 | spin_lock_irqsave(&phy_lock, flags); |
1238 | 1238 | ||
1239 | tsi108_write_mii(data, MII_BMCR, BMCR_RESET); | 1239 | tsi108_write_mii(data, MII_BMCR, BMCR_RESET); |
1240 | while (i--){ | 1240 | while (--i) { |
1241 | if(!(tsi108_read_mii(data, MII_BMCR) & BMCR_RESET)) | 1241 | if(!(tsi108_read_mii(data, MII_BMCR) & BMCR_RESET)) |
1242 | break; | 1242 | break; |
1243 | udelay(10); | 1243 | udelay(10); |
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c index d5d53b633cf8..0bf2114738be 100644 --- a/drivers/net/tulip/de2104x.c +++ b/drivers/net/tulip/de2104x.c | |||
@@ -392,7 +392,7 @@ static void de_rx (struct de_private *de) | |||
392 | unsigned drop = 0; | 392 | unsigned drop = 0; |
393 | int rc; | 393 | int rc; |
394 | 394 | ||
395 | while (rx_work--) { | 395 | while (--rx_work) { |
396 | u32 status, len; | 396 | u32 status, len; |
397 | dma_addr_t mapping; | 397 | dma_addr_t mapping; |
398 | struct sk_buff *skb, *copy_skb; | 398 | struct sk_buff *skb, *copy_skb; |
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 0d0fa91c0251..fe98acaead97 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -455,6 +455,7 @@ static const struct usb_device_id hso_ids[] = { | |||
455 | {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */ | 455 | {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */ |
456 | {USB_DEVICE(0x0af0, 0x7301)}, /* GE40x */ | 456 | {USB_DEVICE(0x0af0, 0x7301)}, /* GE40x */ |
457 | {USB_DEVICE(0x0af0, 0x7361)}, /* GE40x */ | 457 | {USB_DEVICE(0x0af0, 0x7361)}, /* GE40x */ |
458 | {USB_DEVICE(0x0af0, 0x7381)}, /* GE40x */ | ||
458 | {USB_DEVICE(0x0af0, 0x7401)}, /* GI 0401 */ | 459 | {USB_DEVICE(0x0af0, 0x7401)}, /* GI 0401 */ |
459 | {USB_DEVICE(0x0af0, 0x7501)}, /* GTM 382 */ | 460 | {USB_DEVICE(0x0af0, 0x7501)}, /* GTM 382 */ |
460 | {USB_DEVICE(0x0af0, 0x7601)}, /* GE40x */ | 461 | {USB_DEVICE(0x0af0, 0x7601)}, /* GE40x */ |
@@ -462,7 +463,8 @@ static const struct usb_device_id hso_ids[] = { | |||
462 | {USB_DEVICE(0x0af0, 0x7801)}, | 463 | {USB_DEVICE(0x0af0, 0x7801)}, |
463 | {USB_DEVICE(0x0af0, 0x7901)}, | 464 | {USB_DEVICE(0x0af0, 0x7901)}, |
464 | {USB_DEVICE(0x0af0, 0x7361)}, | 465 | {USB_DEVICE(0x0af0, 0x7361)}, |
465 | {icon321_port_device(0x0af0, 0xd051)}, | 466 | {USB_DEVICE(0x0af0, 0xd057)}, |
467 | {USB_DEVICE(0x0af0, 0xd055)}, | ||
466 | {} | 468 | {} |
467 | }; | 469 | }; |
468 | MODULE_DEVICE_TABLE(usb, hso_ids); | 470 | MODULE_DEVICE_TABLE(usb, hso_ids); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index b35c8813bef4..c01ea48da5fe 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -4042,6 +4042,7 @@ static int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
4042 | priv->is_open = 1; | 4042 | priv->is_open = 1; |
4043 | } | 4043 | } |
4044 | 4044 | ||
4045 | pci_save_state(pdev); | ||
4045 | pci_set_power_state(pdev, PCI_D3hot); | 4046 | pci_set_power_state(pdev, PCI_D3hot); |
4046 | 4047 | ||
4047 | return 0; | 4048 | return 0; |
@@ -4052,6 +4053,7 @@ static int iwl_pci_resume(struct pci_dev *pdev) | |||
4052 | struct iwl_priv *priv = pci_get_drvdata(pdev); | 4053 | struct iwl_priv *priv = pci_get_drvdata(pdev); |
4053 | 4054 | ||
4054 | pci_set_power_state(pdev, PCI_D0); | 4055 | pci_set_power_state(pdev, PCI_D0); |
4056 | pci_restore_state(pdev); | ||
4055 | 4057 | ||
4056 | if (priv->is_open) | 4058 | if (priv->is_open) |
4057 | iwl_mac_start(priv->hw); | 4059 | iwl_mac_start(priv->hw); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c index 412f66bac1af..70a8b21ca39b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-sta.c | |||
@@ -480,6 +480,9 @@ void iwl_clear_stations_table(struct iwl_priv *priv) | |||
480 | priv->num_stations = 0; | 480 | priv->num_stations = 0; |
481 | memset(priv->stations, 0, sizeof(priv->stations)); | 481 | memset(priv->stations, 0, sizeof(priv->stations)); |
482 | 482 | ||
483 | /* clean ucode key table bit map */ | ||
484 | priv->ucode_key_table = 0; | ||
485 | |||
483 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 486 | spin_unlock_irqrestore(&priv->sta_lock, flags); |
484 | } | 487 | } |
485 | EXPORT_SYMBOL(iwl_clear_stations_table); | 488 | EXPORT_SYMBOL(iwl_clear_stations_table); |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 95d01984c80e..5b44d322b99f 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -8143,6 +8143,7 @@ static int iwl3945_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
8143 | priv->is_open = 1; | 8143 | priv->is_open = 1; |
8144 | } | 8144 | } |
8145 | 8145 | ||
8146 | pci_save_state(pdev); | ||
8146 | pci_set_power_state(pdev, PCI_D3hot); | 8147 | pci_set_power_state(pdev, PCI_D3hot); |
8147 | 8148 | ||
8148 | return 0; | 8149 | return 0; |
@@ -8153,6 +8154,7 @@ static int iwl3945_pci_resume(struct pci_dev *pdev) | |||
8153 | struct iwl3945_priv *priv = pci_get_drvdata(pdev); | 8154 | struct iwl3945_priv *priv = pci_get_drvdata(pdev); |
8154 | 8155 | ||
8155 | pci_set_power_state(pdev, PCI_D0); | 8156 | pci_set_power_state(pdev, PCI_D0); |
8157 | pci_restore_state(pdev); | ||
8156 | 8158 | ||
8157 | if (priv->is_open) | 8159 | if (priv->is_open) |
8158 | iwl3945_mac_start(priv->hw); | 8160 | iwl3945_mac_start(priv->hw); |
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index e31fb91652ce..2aa117c8cd87 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile | |||
@@ -5,11 +5,15 @@ | |||
5 | obj-$(CONFIG_HOTPLUG_PCI) += pci_hotplug.o | 5 | obj-$(CONFIG_HOTPLUG_PCI) += pci_hotplug.o |
6 | obj-$(CONFIG_HOTPLUG_PCI_COMPAQ) += cpqphp.o | 6 | obj-$(CONFIG_HOTPLUG_PCI_COMPAQ) += cpqphp.o |
7 | obj-$(CONFIG_HOTPLUG_PCI_IBM) += ibmphp.o | 7 | obj-$(CONFIG_HOTPLUG_PCI_IBM) += ibmphp.o |
8 | |||
9 | # pciehp should be linked before acpiphp in order to allow the native driver | ||
10 | # to attempt to bind first. We can then fall back to generic support. | ||
11 | |||
12 | obj-$(CONFIG_HOTPLUG_PCI_PCIE) += pciehp.o | ||
8 | obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o | 13 | obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o |
9 | obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o | 14 | obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o |
10 | obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550) += cpcihp_zt5550.o | 15 | obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550) += cpcihp_zt5550.o |
11 | obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC) += cpcihp_generic.o | 16 | obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC) += cpcihp_generic.o |
12 | obj-$(CONFIG_HOTPLUG_PCI_PCIE) += pciehp.o | ||
13 | obj-$(CONFIG_HOTPLUG_PCI_SHPC) += shpchp.o | 17 | obj-$(CONFIG_HOTPLUG_PCI_SHPC) += shpchp.o |
14 | obj-$(CONFIG_HOTPLUG_PCI_RPA) += rpaphp.o | 18 | obj-$(CONFIG_HOTPLUG_PCI_RPA) += rpaphp.o |
15 | obj-$(CONFIG_HOTPLUG_PCI_RPA_DLPAR) += rpadlpar_io.o | 19 | obj-$(CONFIG_HOTPLUG_PCI_RPA_DLPAR) += rpadlpar_io.o |
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c index b0e7de9e536d..d8649e127298 100644 --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c | |||
@@ -195,13 +195,13 @@ static void remove_slot_worker(struct work_struct *work) | |||
195 | * Tries hard not to re-enable already existing devices; | 195 | * Tries hard not to re-enable already existing devices; |
196 | * also handles scanning of subfunctions. | 196 | * also handles scanning of subfunctions. |
197 | */ | 197 | */ |
198 | static void pci_rescan_slot(struct pci_dev *temp) | 198 | static int pci_rescan_slot(struct pci_dev *temp) |
199 | { | 199 | { |
200 | struct pci_bus *bus = temp->bus; | 200 | struct pci_bus *bus = temp->bus; |
201 | struct pci_dev *dev; | 201 | struct pci_dev *dev; |
202 | int func; | 202 | int func; |
203 | int retval; | ||
204 | u8 hdr_type; | 203 | u8 hdr_type; |
204 | int count = 0; | ||
205 | 205 | ||
206 | if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) { | 206 | if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) { |
207 | temp->hdr_type = hdr_type & 0x7f; | 207 | temp->hdr_type = hdr_type & 0x7f; |
@@ -213,17 +213,12 @@ static void pci_rescan_slot(struct pci_dev *temp) | |||
213 | dbg("New device on %s function %x:%x\n", | 213 | dbg("New device on %s function %x:%x\n", |
214 | bus->name, temp->devfn >> 3, | 214 | bus->name, temp->devfn >> 3, |
215 | temp->devfn & 7); | 215 | temp->devfn & 7); |
216 | retval = pci_bus_add_device(dev); | 216 | count++; |
217 | if (retval) | ||
218 | dev_err(&dev->dev, "error adding " | ||
219 | "device, continuing.\n"); | ||
220 | else | ||
221 | add_slot(dev); | ||
222 | } | 217 | } |
223 | } | 218 | } |
224 | /* multifunction device? */ | 219 | /* multifunction device? */ |
225 | if (!(hdr_type & 0x80)) | 220 | if (!(hdr_type & 0x80)) |
226 | return; | 221 | return count; |
227 | 222 | ||
228 | /* continue scanning for other functions */ | 223 | /* continue scanning for other functions */ |
229 | for (func = 1, temp->devfn++; func < 8; func++, temp->devfn++) { | 224 | for (func = 1, temp->devfn++; func < 8; func++, temp->devfn++) { |
@@ -239,16 +234,13 @@ static void pci_rescan_slot(struct pci_dev *temp) | |||
239 | dbg("New device on %s function %x:%x\n", | 234 | dbg("New device on %s function %x:%x\n", |
240 | bus->name, temp->devfn >> 3, | 235 | bus->name, temp->devfn >> 3, |
241 | temp->devfn & 7); | 236 | temp->devfn & 7); |
242 | retval = pci_bus_add_device(dev); | 237 | count++; |
243 | if (retval) | ||
244 | dev_err(&dev->dev, "error adding " | ||
245 | "device, continuing.\n"); | ||
246 | else | ||
247 | add_slot(dev); | ||
248 | } | 238 | } |
249 | } | 239 | } |
250 | } | 240 | } |
251 | } | 241 | } |
242 | |||
243 | return count; | ||
252 | } | 244 | } |
253 | 245 | ||
254 | 246 | ||
@@ -262,6 +254,8 @@ static void pci_rescan_bus(const struct pci_bus *bus) | |||
262 | { | 254 | { |
263 | unsigned int devfn; | 255 | unsigned int devfn; |
264 | struct pci_dev *dev; | 256 | struct pci_dev *dev; |
257 | int retval; | ||
258 | int found = 0; | ||
265 | dev = alloc_pci_dev(); | 259 | dev = alloc_pci_dev(); |
266 | if (!dev) | 260 | if (!dev) |
267 | return; | 261 | return; |
@@ -270,7 +264,23 @@ static void pci_rescan_bus(const struct pci_bus *bus) | |||
270 | dev->sysdata = bus->sysdata; | 264 | dev->sysdata = bus->sysdata; |
271 | for (devfn = 0; devfn < 0x100; devfn += 8) { | 265 | for (devfn = 0; devfn < 0x100; devfn += 8) { |
272 | dev->devfn = devfn; | 266 | dev->devfn = devfn; |
273 | pci_rescan_slot(dev); | 267 | found += pci_rescan_slot(dev); |
268 | } | ||
269 | |||
270 | if (found) { | ||
271 | pci_bus_assign_resources(bus); | ||
272 | list_for_each_entry(dev, &bus->devices, bus_list) { | ||
273 | /* Skip already-added devices */ | ||
274 | if (dev->is_added) | ||
275 | continue; | ||
276 | retval = pci_bus_add_device(dev); | ||
277 | if (retval) | ||
278 | dev_err(&dev->dev, | ||
279 | "Error adding device, continuing\n"); | ||
280 | else | ||
281 | add_slot(dev); | ||
282 | } | ||
283 | pci_bus_add_devices(bus); | ||
274 | } | 284 | } |
275 | kfree(dev); | 285 | kfree(dev); |
276 | } | 286 | } |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 896a15d70f5b..44f15ff70c1d 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -103,6 +103,16 @@ static void msix_set_enable(struct pci_dev *dev, int enable) | |||
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | ||
107 | * Essentially, this is ((1 << (1 << x)) - 1), but without the | ||
108 | * undefinedness of a << 32. | ||
109 | */ | ||
110 | static inline __attribute_const__ u32 msi_mask(unsigned x) | ||
111 | { | ||
112 | static const u32 mask[] = { 1, 2, 4, 0xf, 0xff, 0xffff, 0xffffffff }; | ||
113 | return mask[x]; | ||
114 | } | ||
115 | |||
106 | static void msix_flush_writes(struct irq_desc *desc) | 116 | static void msix_flush_writes(struct irq_desc *desc) |
107 | { | 117 | { |
108 | struct msi_desc *entry; | 118 | struct msi_desc *entry; |
@@ -407,8 +417,7 @@ static int msi_capability_init(struct pci_dev *dev) | |||
407 | 417 | ||
408 | /* All MSIs are unmasked by default, Mask them all */ | 418 | /* All MSIs are unmasked by default, Mask them all */ |
409 | pci_read_config_dword(dev, base, &maskbits); | 419 | pci_read_config_dword(dev, base, &maskbits); |
410 | temp = (1 << multi_msi_capable(control)); | 420 | temp = msi_mask((control & PCI_MSI_FLAGS_QMASK) >> 1); |
411 | temp = ((temp - 1) & ~temp); | ||
412 | maskbits |= temp; | 421 | maskbits |= temp; |
413 | pci_write_config_dword(dev, base, maskbits); | 422 | pci_write_config_dword(dev, base, maskbits); |
414 | entry->msi_attrib.maskbits_mask = temp; | 423 | entry->msi_attrib.maskbits_mask = temp; |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 9de07b75b993..93eac1423585 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -355,6 +355,8 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state) | |||
355 | int i = 0; | 355 | int i = 0; |
356 | 356 | ||
357 | if (drv && drv->suspend) { | 357 | if (drv && drv->suspend) { |
358 | pci_power_t prev = pci_dev->current_state; | ||
359 | |||
358 | pci_dev->state_saved = false; | 360 | pci_dev->state_saved = false; |
359 | 361 | ||
360 | i = drv->suspend(pci_dev, state); | 362 | i = drv->suspend(pci_dev, state); |
@@ -365,8 +367,13 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state) | |||
365 | if (pci_dev->state_saved) | 367 | if (pci_dev->state_saved) |
366 | goto Fixup; | 368 | goto Fixup; |
367 | 369 | ||
368 | if (WARN_ON_ONCE(pci_dev->current_state != PCI_D0)) | 370 | if (pci_dev->current_state != PCI_D0 |
371 | && pci_dev->current_state != PCI_UNKNOWN) { | ||
372 | WARN_ONCE(pci_dev->current_state != prev, | ||
373 | "PCI PM: Device state not saved by %pF\n", | ||
374 | drv->suspend); | ||
369 | goto Fixup; | 375 | goto Fixup; |
376 | } | ||
370 | } | 377 | } |
371 | 378 | ||
372 | pci_save_state(pci_dev); | 379 | pci_save_state(pci_dev); |
@@ -419,38 +426,24 @@ static int pci_legacy_resume(struct device *dev) | |||
419 | static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev) | 426 | static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev) |
420 | { | 427 | { |
421 | pci_restore_standard_config(pci_dev); | 428 | pci_restore_standard_config(pci_dev); |
429 | pci_dev->state_saved = false; | ||
422 | pci_fixup_device(pci_fixup_resume_early, pci_dev); | 430 | pci_fixup_device(pci_fixup_resume_early, pci_dev); |
423 | } | 431 | } |
424 | 432 | ||
425 | static int pci_pm_default_resume(struct pci_dev *pci_dev) | 433 | static void pci_pm_default_resume(struct pci_dev *pci_dev) |
426 | { | 434 | { |
427 | pci_fixup_device(pci_fixup_resume, pci_dev); | 435 | pci_fixup_device(pci_fixup_resume, pci_dev); |
428 | 436 | ||
429 | if (!pci_is_bridge(pci_dev)) | 437 | if (!pci_is_bridge(pci_dev)) |
430 | pci_enable_wake(pci_dev, PCI_D0, false); | 438 | pci_enable_wake(pci_dev, PCI_D0, false); |
431 | |||
432 | return pci_pm_reenable_device(pci_dev); | ||
433 | } | ||
434 | |||
435 | static void pci_pm_default_suspend_generic(struct pci_dev *pci_dev) | ||
436 | { | ||
437 | /* If device is enabled at this point, disable it */ | ||
438 | pci_disable_enabled_device(pci_dev); | ||
439 | /* | ||
440 | * Save state with interrupts enabled, because in principle the bus the | ||
441 | * device is on may be put into a low power state after this code runs. | ||
442 | */ | ||
443 | pci_save_state(pci_dev); | ||
444 | } | 439 | } |
445 | 440 | ||
446 | static void pci_pm_default_suspend(struct pci_dev *pci_dev) | 441 | static void pci_pm_default_suspend(struct pci_dev *pci_dev) |
447 | { | 442 | { |
448 | pci_pm_default_suspend_generic(pci_dev); | 443 | /* Disable non-bridge devices without PM support */ |
449 | |||
450 | if (!pci_is_bridge(pci_dev)) | 444 | if (!pci_is_bridge(pci_dev)) |
451 | pci_prepare_to_sleep(pci_dev); | 445 | pci_disable_enabled_device(pci_dev); |
452 | 446 | pci_save_state(pci_dev); | |
453 | pci_fixup_device(pci_fixup_suspend, pci_dev); | ||
454 | } | 447 | } |
455 | 448 | ||
456 | static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) | 449 | static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) |
@@ -495,21 +488,49 @@ static void pci_pm_complete(struct device *dev) | |||
495 | static int pci_pm_suspend(struct device *dev) | 488 | static int pci_pm_suspend(struct device *dev) |
496 | { | 489 | { |
497 | struct pci_dev *pci_dev = to_pci_dev(dev); | 490 | struct pci_dev *pci_dev = to_pci_dev(dev); |
498 | struct device_driver *drv = dev->driver; | 491 | struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
499 | int error = 0; | ||
500 | 492 | ||
501 | if (pci_has_legacy_pm_support(pci_dev)) | 493 | if (pci_has_legacy_pm_support(pci_dev)) |
502 | return pci_legacy_suspend(dev, PMSG_SUSPEND); | 494 | return pci_legacy_suspend(dev, PMSG_SUSPEND); |
503 | 495 | ||
504 | if (drv && drv->pm && drv->pm->suspend) { | 496 | if (!pm) { |
505 | error = drv->pm->suspend(dev); | 497 | pci_pm_default_suspend(pci_dev); |
506 | suspend_report_result(drv->pm->suspend, error); | 498 | goto Fixup; |
507 | } | 499 | } |
508 | 500 | ||
509 | if (!error) | 501 | pci_dev->state_saved = false; |
510 | pci_pm_default_suspend(pci_dev); | ||
511 | 502 | ||
512 | return error; | 503 | if (pm->suspend) { |
504 | pci_power_t prev = pci_dev->current_state; | ||
505 | int error; | ||
506 | |||
507 | error = pm->suspend(dev); | ||
508 | suspend_report_result(pm->suspend, error); | ||
509 | if (error) | ||
510 | return error; | ||
511 | |||
512 | if (pci_dev->state_saved) | ||
513 | goto Fixup; | ||
514 | |||
515 | if (pci_dev->current_state != PCI_D0 | ||
516 | && pci_dev->current_state != PCI_UNKNOWN) { | ||
517 | WARN_ONCE(pci_dev->current_state != prev, | ||
518 | "PCI PM: State of device not saved by %pF\n", | ||
519 | pm->suspend); | ||
520 | goto Fixup; | ||
521 | } | ||
522 | } | ||
523 | |||
524 | if (!pci_dev->state_saved) { | ||
525 | pci_save_state(pci_dev); | ||
526 | if (!pci_is_bridge(pci_dev)) | ||
527 | pci_prepare_to_sleep(pci_dev); | ||
528 | } | ||
529 | |||
530 | Fixup: | ||
531 | pci_fixup_device(pci_fixup_suspend, pci_dev); | ||
532 | |||
533 | return 0; | ||
513 | } | 534 | } |
514 | 535 | ||
515 | static int pci_pm_suspend_noirq(struct device *dev) | 536 | static int pci_pm_suspend_noirq(struct device *dev) |
@@ -552,18 +573,29 @@ static int pci_pm_resume_noirq(struct device *dev) | |||
552 | static int pci_pm_resume(struct device *dev) | 573 | static int pci_pm_resume(struct device *dev) |
553 | { | 574 | { |
554 | struct pci_dev *pci_dev = to_pci_dev(dev); | 575 | struct pci_dev *pci_dev = to_pci_dev(dev); |
555 | struct device_driver *drv = dev->driver; | 576 | struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
556 | int error = 0; | 577 | int error = 0; |
557 | 578 | ||
579 | /* | ||
580 | * This is necessary for the suspend error path in which resume is | ||
581 | * called without restoring the standard config registers of the device. | ||
582 | */ | ||
583 | if (pci_dev->state_saved) | ||
584 | pci_restore_standard_config(pci_dev); | ||
585 | |||
558 | if (pci_has_legacy_pm_support(pci_dev)) | 586 | if (pci_has_legacy_pm_support(pci_dev)) |
559 | return pci_legacy_resume(dev); | 587 | return pci_legacy_resume(dev); |
560 | 588 | ||
561 | error = pci_pm_default_resume(pci_dev); | 589 | pci_pm_default_resume(pci_dev); |
562 | 590 | ||
563 | if (!error && drv && drv->pm && drv->pm->resume) | 591 | if (pm) { |
564 | error = drv->pm->resume(dev); | 592 | if (pm->resume) |
593 | error = pm->resume(dev); | ||
594 | } else { | ||
595 | pci_pm_reenable_device(pci_dev); | ||
596 | } | ||
565 | 597 | ||
566 | return error; | 598 | return 0; |
567 | } | 599 | } |
568 | 600 | ||
569 | #else /* !CONFIG_SUSPEND */ | 601 | #else /* !CONFIG_SUSPEND */ |
@@ -580,21 +612,31 @@ static int pci_pm_resume(struct device *dev) | |||
580 | static int pci_pm_freeze(struct device *dev) | 612 | static int pci_pm_freeze(struct device *dev) |
581 | { | 613 | { |
582 | struct pci_dev *pci_dev = to_pci_dev(dev); | 614 | struct pci_dev *pci_dev = to_pci_dev(dev); |
583 | struct device_driver *drv = dev->driver; | 615 | struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
584 | int error = 0; | ||
585 | 616 | ||
586 | if (pci_has_legacy_pm_support(pci_dev)) | 617 | if (pci_has_legacy_pm_support(pci_dev)) |
587 | return pci_legacy_suspend(dev, PMSG_FREEZE); | 618 | return pci_legacy_suspend(dev, PMSG_FREEZE); |
588 | 619 | ||
589 | if (drv && drv->pm && drv->pm->freeze) { | 620 | if (!pm) { |
590 | error = drv->pm->freeze(dev); | 621 | pci_pm_default_suspend(pci_dev); |
591 | suspend_report_result(drv->pm->freeze, error); | 622 | return 0; |
623 | } | ||
624 | |||
625 | pci_dev->state_saved = false; | ||
626 | |||
627 | if (pm->freeze) { | ||
628 | int error; | ||
629 | |||
630 | error = pm->freeze(dev); | ||
631 | suspend_report_result(pm->freeze, error); | ||
632 | if (error) | ||
633 | return error; | ||
592 | } | 634 | } |
593 | 635 | ||
594 | if (!error) | 636 | if (!pci_dev->state_saved) |
595 | pci_pm_default_suspend_generic(pci_dev); | 637 | pci_save_state(pci_dev); |
596 | 638 | ||
597 | return error; | 639 | return 0; |
598 | } | 640 | } |
599 | 641 | ||
600 | static int pci_pm_freeze_noirq(struct device *dev) | 642 | static int pci_pm_freeze_noirq(struct device *dev) |
@@ -637,16 +679,18 @@ static int pci_pm_thaw_noirq(struct device *dev) | |||
637 | static int pci_pm_thaw(struct device *dev) | 679 | static int pci_pm_thaw(struct device *dev) |
638 | { | 680 | { |
639 | struct pci_dev *pci_dev = to_pci_dev(dev); | 681 | struct pci_dev *pci_dev = to_pci_dev(dev); |
640 | struct device_driver *drv = dev->driver; | 682 | struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
641 | int error = 0; | 683 | int error = 0; |
642 | 684 | ||
643 | if (pci_has_legacy_pm_support(pci_dev)) | 685 | if (pci_has_legacy_pm_support(pci_dev)) |
644 | return pci_legacy_resume(dev); | 686 | return pci_legacy_resume(dev); |
645 | 687 | ||
646 | pci_pm_reenable_device(pci_dev); | 688 | if (pm) { |
647 | 689 | if (pm->thaw) | |
648 | if (drv && drv->pm && drv->pm->thaw) | 690 | error = pm->thaw(dev); |
649 | error = drv->pm->thaw(dev); | 691 | } else { |
692 | pci_pm_reenable_device(pci_dev); | ||
693 | } | ||
650 | 694 | ||
651 | return error; | 695 | return error; |
652 | } | 696 | } |
@@ -654,19 +698,29 @@ static int pci_pm_thaw(struct device *dev) | |||
654 | static int pci_pm_poweroff(struct device *dev) | 698 | static int pci_pm_poweroff(struct device *dev) |
655 | { | 699 | { |
656 | struct pci_dev *pci_dev = to_pci_dev(dev); | 700 | struct pci_dev *pci_dev = to_pci_dev(dev); |
657 | struct device_driver *drv = dev->driver; | 701 | struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
658 | int error = 0; | 702 | int error = 0; |
659 | 703 | ||
660 | if (pci_has_legacy_pm_support(pci_dev)) | 704 | if (pci_has_legacy_pm_support(pci_dev)) |
661 | return pci_legacy_suspend(dev, PMSG_HIBERNATE); | 705 | return pci_legacy_suspend(dev, PMSG_HIBERNATE); |
662 | 706 | ||
663 | if (drv && drv->pm && drv->pm->poweroff) { | 707 | if (!pm) { |
664 | error = drv->pm->poweroff(dev); | 708 | pci_pm_default_suspend(pci_dev); |
665 | suspend_report_result(drv->pm->poweroff, error); | 709 | goto Fixup; |
666 | } | 710 | } |
667 | 711 | ||
668 | if (!error) | 712 | pci_dev->state_saved = false; |
669 | pci_pm_default_suspend(pci_dev); | 713 | |
714 | if (pm->poweroff) { | ||
715 | error = pm->poweroff(dev); | ||
716 | suspend_report_result(pm->poweroff, error); | ||
717 | } | ||
718 | |||
719 | if (!pci_dev->state_saved && !pci_is_bridge(pci_dev)) | ||
720 | pci_prepare_to_sleep(pci_dev); | ||
721 | |||
722 | Fixup: | ||
723 | pci_fixup_device(pci_fixup_suspend, pci_dev); | ||
670 | 724 | ||
671 | return error; | 725 | return error; |
672 | } | 726 | } |
@@ -707,16 +761,27 @@ static int pci_pm_restore_noirq(struct device *dev) | |||
707 | static int pci_pm_restore(struct device *dev) | 761 | static int pci_pm_restore(struct device *dev) |
708 | { | 762 | { |
709 | struct pci_dev *pci_dev = to_pci_dev(dev); | 763 | struct pci_dev *pci_dev = to_pci_dev(dev); |
710 | struct device_driver *drv = dev->driver; | 764 | struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
711 | int error = 0; | 765 | int error = 0; |
712 | 766 | ||
767 | /* | ||
768 | * This is necessary for the hibernation error path in which restore is | ||
769 | * called without restoring the standard config registers of the device. | ||
770 | */ | ||
771 | if (pci_dev->state_saved) | ||
772 | pci_restore_standard_config(pci_dev); | ||
773 | |||
713 | if (pci_has_legacy_pm_support(pci_dev)) | 774 | if (pci_has_legacy_pm_support(pci_dev)) |
714 | return pci_legacy_resume(dev); | 775 | return pci_legacy_resume(dev); |
715 | 776 | ||
716 | error = pci_pm_default_resume(pci_dev); | 777 | pci_pm_default_resume(pci_dev); |
717 | 778 | ||
718 | if (!error && drv && drv->pm && drv->pm->restore) | 779 | if (pm) { |
719 | error = drv->pm->restore(dev); | 780 | if (pm->restore) |
781 | error = pm->restore(dev); | ||
782 | } else { | ||
783 | pci_pm_reenable_device(pci_dev); | ||
784 | } | ||
720 | 785 | ||
721 | return error; | 786 | return error; |
722 | } | 787 | } |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index db7ec14fa719..dfc4e0ddf241 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -768,8 +768,8 @@ pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
768 | return -EINVAL; | 768 | return -EINVAL; |
769 | 769 | ||
770 | rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */ | 770 | rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */ |
771 | if (!rom) | 771 | if (!rom || !size) |
772 | return 0; | 772 | return -EIO; |
773 | 773 | ||
774 | if (off >= size) | 774 | if (off >= size) |
775 | count = 0; | 775 | count = 0; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 17bd9325a245..e3efe6b19ee7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1393,35 +1393,35 @@ int pci_restore_standard_config(struct pci_dev *dev) | |||
1393 | pci_power_t prev_state; | 1393 | pci_power_t prev_state; |
1394 | int error; | 1394 | int error; |
1395 | 1395 | ||
1396 | pci_restore_state(dev); | ||
1397 | pci_update_current_state(dev, PCI_D0); | 1396 | pci_update_current_state(dev, PCI_D0); |
1398 | 1397 | ||
1399 | prev_state = dev->current_state; | 1398 | prev_state = dev->current_state; |
1400 | if (prev_state == PCI_D0) | 1399 | if (prev_state == PCI_D0) |
1401 | return 0; | 1400 | goto Restore; |
1402 | 1401 | ||
1403 | error = pci_raw_set_power_state(dev, PCI_D0, false); | 1402 | error = pci_raw_set_power_state(dev, PCI_D0, false); |
1404 | if (error) | 1403 | if (error) |
1405 | return error; | 1404 | return error; |
1406 | 1405 | ||
1407 | if (pci_is_bridge(dev)) { | 1406 | /* |
1408 | if (prev_state > PCI_D1) | 1407 | * This assumes that we won't get a bus in B2 or B3 from the BIOS, but |
1409 | mdelay(PCI_PM_BUS_WAIT); | 1408 | * we've made this assumption forever and it appears to be universally |
1410 | } else { | 1409 | * satisfied. |
1411 | switch(prev_state) { | 1410 | */ |
1412 | case PCI_D3cold: | 1411 | switch(prev_state) { |
1413 | case PCI_D3hot: | 1412 | case PCI_D3cold: |
1414 | mdelay(pci_pm_d3_delay); | 1413 | case PCI_D3hot: |
1415 | break; | 1414 | mdelay(pci_pm_d3_delay); |
1416 | case PCI_D2: | 1415 | break; |
1417 | udelay(PCI_PM_D2_DELAY); | 1416 | case PCI_D2: |
1418 | break; | 1417 | udelay(PCI_PM_D2_DELAY); |
1419 | } | 1418 | break; |
1420 | } | 1419 | } |
1421 | 1420 | ||
1422 | dev->current_state = PCI_D0; | 1421 | pci_update_current_state(dev, PCI_D0); |
1423 | 1422 | ||
1424 | return 0; | 1423 | Restore: |
1424 | return dev->state_saved ? pci_restore_state(dev) : 0; | ||
1425 | } | 1425 | } |
1426 | 1426 | ||
1427 | /** | 1427 | /** |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 586b6f75910d..b0367f168af4 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -718,9 +718,9 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev) | |||
718 | 718 | ||
719 | /* | 719 | /* |
720 | * All PCIe functions are in one slot, remove one function will remove | 720 | * All PCIe functions are in one slot, remove one function will remove |
721 | * the the whole slot, so just wait | 721 | * the whole slot, so just wait until we are the last function left. |
722 | */ | 722 | */ |
723 | if (!list_empty(&parent->subordinate->devices)) | 723 | if (!list_is_last(&pdev->bus_list, &parent->subordinate->devices)) |
724 | goto out; | 724 | goto out; |
725 | 725 | ||
726 | /* All functions are removed, so just disable ASPM for the link */ | 726 | /* All functions are removed, so just disable ASPM for the link */ |
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 99a914a027f8..f9b874eaeb9f 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c | |||
@@ -55,25 +55,13 @@ static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state) | |||
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | static int pcie_portdrv_suspend_late(struct pci_dev *dev, pm_message_t state) | ||
59 | { | ||
60 | return pci_save_state(dev); | ||
61 | } | ||
62 | |||
63 | static int pcie_portdrv_resume_early(struct pci_dev *dev) | ||
64 | { | ||
65 | return pci_restore_state(dev); | ||
66 | } | ||
67 | |||
68 | static int pcie_portdrv_resume(struct pci_dev *dev) | 58 | static int pcie_portdrv_resume(struct pci_dev *dev) |
69 | { | 59 | { |
70 | pcie_portdrv_restore_config(dev); | 60 | pci_set_master(dev); |
71 | return pcie_port_device_resume(dev); | 61 | return pcie_port_device_resume(dev); |
72 | } | 62 | } |
73 | #else | 63 | #else |
74 | #define pcie_portdrv_suspend NULL | 64 | #define pcie_portdrv_suspend NULL |
75 | #define pcie_portdrv_suspend_late NULL | ||
76 | #define pcie_portdrv_resume_early NULL | ||
77 | #define pcie_portdrv_resume NULL | 65 | #define pcie_portdrv_resume NULL |
78 | #endif | 66 | #endif |
79 | 67 | ||
@@ -292,8 +280,6 @@ static struct pci_driver pcie_portdriver = { | |||
292 | .remove = pcie_portdrv_remove, | 280 | .remove = pcie_portdrv_remove, |
293 | 281 | ||
294 | .suspend = pcie_portdrv_suspend, | 282 | .suspend = pcie_portdrv_suspend, |
295 | .suspend_late = pcie_portdrv_suspend_late, | ||
296 | .resume_early = pcie_portdrv_resume_early, | ||
297 | .resume = pcie_portdrv_resume, | 283 | .resume = pcie_portdrv_resume, |
298 | 284 | ||
299 | .err_handler = &pcie_portdrv_err_handler, | 285 | .err_handler = &pcie_portdrv_err_handler, |
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 132a78159b60..29cbe47f219f 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c | |||
@@ -63,7 +63,7 @@ void pci_disable_rom(struct pci_dev *pdev) | |||
63 | * The PCI window size could be much larger than the | 63 | * The PCI window size could be much larger than the |
64 | * actual image size. | 64 | * actual image size. |
65 | */ | 65 | */ |
66 | size_t pci_get_rom_size(void __iomem *rom, size_t size) | 66 | size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size) |
67 | { | 67 | { |
68 | void __iomem *image; | 68 | void __iomem *image; |
69 | int last_image; | 69 | int last_image; |
@@ -72,8 +72,10 @@ size_t pci_get_rom_size(void __iomem *rom, size_t size) | |||
72 | do { | 72 | do { |
73 | void __iomem *pds; | 73 | void __iomem *pds; |
74 | /* Standard PCI ROMs start out with these bytes 55 AA */ | 74 | /* Standard PCI ROMs start out with these bytes 55 AA */ |
75 | if (readb(image) != 0x55) | 75 | if (readb(image) != 0x55) { |
76 | dev_err(&pdev->dev, "Invalid ROM contents\n"); | ||
76 | break; | 77 | break; |
78 | } | ||
77 | if (readb(image + 1) != 0xAA) | 79 | if (readb(image + 1) != 0xAA) |
78 | break; | 80 | break; |
79 | /* get the PCI data structure and check its signature */ | 81 | /* get the PCI data structure and check its signature */ |
@@ -159,7 +161,7 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size) | |||
159 | * size is much larger than the actual size of the ROM. | 161 | * size is much larger than the actual size of the ROM. |
160 | * True size is important if the ROM is going to be copied. | 162 | * True size is important if the ROM is going to be copied. |
161 | */ | 163 | */ |
162 | *size = pci_get_rom_size(rom, *size); | 164 | *size = pci_get_rom_size(pdev, rom, *size); |
163 | return rom; | 165 | return rom; |
164 | } | 166 | } |
165 | 167 | ||
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 1a266d4ab5f1..94363115a42a 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -42,6 +42,7 @@ config ASUS_LAPTOP | |||
42 | depends on LEDS_CLASS | 42 | depends on LEDS_CLASS |
43 | depends on NEW_LEDS | 43 | depends on NEW_LEDS |
44 | depends on BACKLIGHT_CLASS_DEVICE | 44 | depends on BACKLIGHT_CLASS_DEVICE |
45 | depends on INPUT | ||
45 | ---help--- | 46 | ---help--- |
46 | This is the new Linux driver for Asus laptops. It may also support some | 47 | This is the new Linux driver for Asus laptops. It may also support some |
47 | MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate | 48 | MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate |
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 8fb8b3591048..56af6cf385b0 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <acpi/acpi_drivers.h> | 46 | #include <acpi/acpi_drivers.h> |
47 | #include <acpi/acpi_bus.h> | 47 | #include <acpi/acpi_bus.h> |
48 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
49 | #include <linux/input.h> | ||
49 | 50 | ||
50 | #define ASUS_LAPTOP_VERSION "0.42" | 51 | #define ASUS_LAPTOP_VERSION "0.42" |
51 | 52 | ||
@@ -181,6 +182,8 @@ struct asus_hotk { | |||
181 | u8 light_level; //light sensor level | 182 | u8 light_level; //light sensor level |
182 | u8 light_switch; //light sensor switch value | 183 | u8 light_switch; //light sensor switch value |
183 | u16 event_count[128]; //count for each event TODO make this better | 184 | u16 event_count[128]; //count for each event TODO make this better |
185 | struct input_dev *inputdev; | ||
186 | u16 *keycode_map; | ||
184 | }; | 187 | }; |
185 | 188 | ||
186 | /* | 189 | /* |
@@ -250,6 +253,37 @@ ASUS_LED(rled, "record"); | |||
250 | ASUS_LED(pled, "phone"); | 253 | ASUS_LED(pled, "phone"); |
251 | ASUS_LED(gled, "gaming"); | 254 | ASUS_LED(gled, "gaming"); |
252 | 255 | ||
256 | struct key_entry { | ||
257 | char type; | ||
258 | u8 code; | ||
259 | u16 keycode; | ||
260 | }; | ||
261 | |||
262 | enum { KE_KEY, KE_END }; | ||
263 | |||
264 | static struct key_entry asus_keymap[] = { | ||
265 | {KE_KEY, 0x30, KEY_VOLUMEUP}, | ||
266 | {KE_KEY, 0x31, KEY_VOLUMEDOWN}, | ||
267 | {KE_KEY, 0x32, KEY_MUTE}, | ||
268 | {KE_KEY, 0x33, KEY_SWITCHVIDEOMODE}, | ||
269 | {KE_KEY, 0x34, KEY_SWITCHVIDEOMODE}, | ||
270 | {KE_KEY, 0x40, KEY_PREVIOUSSONG}, | ||
271 | {KE_KEY, 0x41, KEY_NEXTSONG}, | ||
272 | {KE_KEY, 0x43, KEY_STOP}, | ||
273 | {KE_KEY, 0x45, KEY_PLAYPAUSE}, | ||
274 | {KE_KEY, 0x50, KEY_EMAIL}, | ||
275 | {KE_KEY, 0x51, KEY_WWW}, | ||
276 | {KE_KEY, 0x5C, BTN_EXTRA}, /* Performance */ | ||
277 | {KE_KEY, 0x5D, KEY_WLAN}, | ||
278 | {KE_KEY, 0x61, KEY_SWITCHVIDEOMODE}, | ||
279 | {KE_KEY, 0x6B, BTN_TOUCH}, /* Lock Mouse */ | ||
280 | {KE_KEY, 0x82, KEY_CAMERA}, | ||
281 | {KE_KEY, 0x8A, KEY_TV}, | ||
282 | {KE_KEY, 0x95, KEY_MEDIA}, | ||
283 | {KE_KEY, 0x99, KEY_PHONE}, | ||
284 | {KE_END, 0}, | ||
285 | }; | ||
286 | |||
253 | /* | 287 | /* |
254 | * This function evaluates an ACPI method, given an int as parameter, the | 288 | * This function evaluates an ACPI method, given an int as parameter, the |
255 | * method is searched within the scope of the handle, can be NULL. The output | 289 | * method is searched within the scope of the handle, can be NULL. The output |
@@ -720,8 +754,68 @@ static ssize_t store_gps(struct device *dev, struct device_attribute *attr, | |||
720 | return store_status(buf, count, NULL, GPS_ON); | 754 | return store_status(buf, count, NULL, GPS_ON); |
721 | } | 755 | } |
722 | 756 | ||
757 | /* | ||
758 | * Hotkey functions | ||
759 | */ | ||
760 | static struct key_entry *asus_get_entry_by_scancode(int code) | ||
761 | { | ||
762 | struct key_entry *key; | ||
763 | |||
764 | for (key = asus_keymap; key->type != KE_END; key++) | ||
765 | if (code == key->code) | ||
766 | return key; | ||
767 | |||
768 | return NULL; | ||
769 | } | ||
770 | |||
771 | static struct key_entry *asus_get_entry_by_keycode(int code) | ||
772 | { | ||
773 | struct key_entry *key; | ||
774 | |||
775 | for (key = asus_keymap; key->type != KE_END; key++) | ||
776 | if (code == key->keycode && key->type == KE_KEY) | ||
777 | return key; | ||
778 | |||
779 | return NULL; | ||
780 | } | ||
781 | |||
782 | static int asus_getkeycode(struct input_dev *dev, int scancode, int *keycode) | ||
783 | { | ||
784 | struct key_entry *key = asus_get_entry_by_scancode(scancode); | ||
785 | |||
786 | if (key && key->type == KE_KEY) { | ||
787 | *keycode = key->keycode; | ||
788 | return 0; | ||
789 | } | ||
790 | |||
791 | return -EINVAL; | ||
792 | } | ||
793 | |||
794 | static int asus_setkeycode(struct input_dev *dev, int scancode, int keycode) | ||
795 | { | ||
796 | struct key_entry *key; | ||
797 | int old_keycode; | ||
798 | |||
799 | if (keycode < 0 || keycode > KEY_MAX) | ||
800 | return -EINVAL; | ||
801 | |||
802 | key = asus_get_entry_by_scancode(scancode); | ||
803 | if (key && key->type == KE_KEY) { | ||
804 | old_keycode = key->keycode; | ||
805 | key->keycode = keycode; | ||
806 | set_bit(keycode, dev->keybit); | ||
807 | if (!asus_get_entry_by_keycode(old_keycode)) | ||
808 | clear_bit(old_keycode, dev->keybit); | ||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | return -EINVAL; | ||
813 | } | ||
814 | |||
723 | static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) | 815 | static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) |
724 | { | 816 | { |
817 | static struct key_entry *key; | ||
818 | |||
725 | /* TODO Find a better way to handle events count. */ | 819 | /* TODO Find a better way to handle events count. */ |
726 | if (!hotk) | 820 | if (!hotk) |
727 | return; | 821 | return; |
@@ -738,10 +832,24 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) | |||
738 | lcd_blank(FB_BLANK_POWERDOWN); | 832 | lcd_blank(FB_BLANK_POWERDOWN); |
739 | } | 833 | } |
740 | 834 | ||
741 | acpi_bus_generate_proc_event(hotk->device, event, | 835 | acpi_bus_generate_netlink_event(hotk->device->pnp.device_class, |
742 | hotk->event_count[event % 128]++); | 836 | dev_name(&hotk->device->dev), event, |
743 | 837 | hotk->event_count[event % 128]++); | |
744 | return; | 838 | |
839 | if (hotk->inputdev) { | ||
840 | key = asus_get_entry_by_scancode(event); | ||
841 | if (!key) | ||
842 | return ; | ||
843 | |||
844 | switch (key->type) { | ||
845 | case KE_KEY: | ||
846 | input_report_key(hotk->inputdev, key->keycode, 1); | ||
847 | input_sync(hotk->inputdev); | ||
848 | input_report_key(hotk->inputdev, key->keycode, 0); | ||
849 | input_sync(hotk->inputdev); | ||
850 | break; | ||
851 | } | ||
852 | } | ||
745 | } | 853 | } |
746 | 854 | ||
747 | #define ASUS_CREATE_DEVICE_ATTR(_name) \ | 855 | #define ASUS_CREATE_DEVICE_ATTR(_name) \ |
@@ -959,6 +1067,38 @@ static int asus_hotk_get_info(void) | |||
959 | return AE_OK; | 1067 | return AE_OK; |
960 | } | 1068 | } |
961 | 1069 | ||
1070 | static int asus_input_init(void) | ||
1071 | { | ||
1072 | const struct key_entry *key; | ||
1073 | int result; | ||
1074 | |||
1075 | hotk->inputdev = input_allocate_device(); | ||
1076 | if (!hotk->inputdev) { | ||
1077 | printk(ASUS_INFO "Unable to allocate input device\n"); | ||
1078 | return 0; | ||
1079 | } | ||
1080 | hotk->inputdev->name = "Asus Laptop extra buttons"; | ||
1081 | hotk->inputdev->phys = ASUS_HOTK_FILE "/input0"; | ||
1082 | hotk->inputdev->id.bustype = BUS_HOST; | ||
1083 | hotk->inputdev->getkeycode = asus_getkeycode; | ||
1084 | hotk->inputdev->setkeycode = asus_setkeycode; | ||
1085 | |||
1086 | for (key = asus_keymap; key->type != KE_END; key++) { | ||
1087 | switch (key->type) { | ||
1088 | case KE_KEY: | ||
1089 | set_bit(EV_KEY, hotk->inputdev->evbit); | ||
1090 | set_bit(key->keycode, hotk->inputdev->keybit); | ||
1091 | break; | ||
1092 | } | ||
1093 | } | ||
1094 | result = input_register_device(hotk->inputdev); | ||
1095 | if (result) { | ||
1096 | printk(ASUS_INFO "Unable to register input device\n"); | ||
1097 | input_free_device(hotk->inputdev); | ||
1098 | } | ||
1099 | return result; | ||
1100 | } | ||
1101 | |||
962 | static int asus_hotk_check(void) | 1102 | static int asus_hotk_check(void) |
963 | { | 1103 | { |
964 | int result = 0; | 1104 | int result = 0; |
@@ -1044,7 +1184,7 @@ static int asus_hotk_add(struct acpi_device *device) | |||
1044 | /* GPS is on by default */ | 1184 | /* GPS is on by default */ |
1045 | write_status(NULL, 1, GPS_ON); | 1185 | write_status(NULL, 1, GPS_ON); |
1046 | 1186 | ||
1047 | end: | 1187 | end: |
1048 | if (result) { | 1188 | if (result) { |
1049 | kfree(hotk->name); | 1189 | kfree(hotk->name); |
1050 | kfree(hotk); | 1190 | kfree(hotk); |
@@ -1091,10 +1231,17 @@ static void asus_led_exit(void) | |||
1091 | ASUS_LED_UNREGISTER(gled); | 1231 | ASUS_LED_UNREGISTER(gled); |
1092 | } | 1232 | } |
1093 | 1233 | ||
1234 | static void asus_input_exit(void) | ||
1235 | { | ||
1236 | if (hotk->inputdev) | ||
1237 | input_unregister_device(hotk->inputdev); | ||
1238 | } | ||
1239 | |||
1094 | static void __exit asus_laptop_exit(void) | 1240 | static void __exit asus_laptop_exit(void) |
1095 | { | 1241 | { |
1096 | asus_backlight_exit(); | 1242 | asus_backlight_exit(); |
1097 | asus_led_exit(); | 1243 | asus_led_exit(); |
1244 | asus_input_exit(); | ||
1098 | 1245 | ||
1099 | acpi_bus_unregister_driver(&asus_hotk_driver); | 1246 | acpi_bus_unregister_driver(&asus_hotk_driver); |
1100 | sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group); | 1247 | sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group); |
@@ -1216,6 +1363,10 @@ static int __init asus_laptop_init(void) | |||
1216 | printk(ASUS_INFO "Brightness ignored, must be controlled by " | 1363 | printk(ASUS_INFO "Brightness ignored, must be controlled by " |
1217 | "ACPI video driver\n"); | 1364 | "ACPI video driver\n"); |
1218 | 1365 | ||
1366 | result = asus_input_init(); | ||
1367 | if (result) | ||
1368 | goto fail_input; | ||
1369 | |||
1219 | result = asus_led_init(dev); | 1370 | result = asus_led_init(dev); |
1220 | if (result) | 1371 | if (result) |
1221 | goto fail_led; | 1372 | goto fail_led; |
@@ -1242,22 +1393,25 @@ static int __init asus_laptop_init(void) | |||
1242 | 1393 | ||
1243 | return 0; | 1394 | return 0; |
1244 | 1395 | ||
1245 | fail_sysfs: | 1396 | fail_sysfs: |
1246 | platform_device_del(asuspf_device); | 1397 | platform_device_del(asuspf_device); |
1247 | 1398 | ||
1248 | fail_platform_device2: | 1399 | fail_platform_device2: |
1249 | platform_device_put(asuspf_device); | 1400 | platform_device_put(asuspf_device); |
1250 | 1401 | ||
1251 | fail_platform_device1: | 1402 | fail_platform_device1: |
1252 | platform_driver_unregister(&asuspf_driver); | 1403 | platform_driver_unregister(&asuspf_driver); |
1253 | 1404 | ||
1254 | fail_platform_driver: | 1405 | fail_platform_driver: |
1255 | asus_led_exit(); | 1406 | asus_led_exit(); |
1256 | 1407 | ||
1257 | fail_led: | 1408 | fail_led: |
1409 | asus_input_exit(); | ||
1410 | |||
1411 | fail_input: | ||
1258 | asus_backlight_exit(); | 1412 | asus_backlight_exit(); |
1259 | 1413 | ||
1260 | fail_backlight: | 1414 | fail_backlight: |
1261 | 1415 | ||
1262 | return result; | 1416 | return result; |
1263 | } | 1417 | } |
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c index 1e74988c7b2d..d63f26e666a4 100644 --- a/drivers/platform/x86/asus_acpi.c +++ b/drivers/platform/x86/asus_acpi.c | |||
@@ -143,6 +143,7 @@ struct asus_hotk { | |||
143 | S1300N, S5200N*/ | 143 | S1300N, S5200N*/ |
144 | A4S, /* Z81sp */ | 144 | A4S, /* Z81sp */ |
145 | F3Sa, /* (Centrino) */ | 145 | F3Sa, /* (Centrino) */ |
146 | R1F, | ||
146 | END_MODEL | 147 | END_MODEL |
147 | } model; /* Models currently supported */ | 148 | } model; /* Models currently supported */ |
148 | u16 event_count[128]; /* Count for each event TODO make this better */ | 149 | u16 event_count[128]; /* Count for each event TODO make this better */ |
@@ -420,7 +421,18 @@ static struct model_data model_conf[END_MODEL] = { | |||
420 | .display_get = "\\ADVG", | 421 | .display_get = "\\ADVG", |
421 | .display_set = "SDSP", | 422 | .display_set = "SDSP", |
422 | }, | 423 | }, |
423 | 424 | { | |
425 | .name = "R1F", | ||
426 | .mt_bt_switch = "BLED", | ||
427 | .mt_mled = "MLED", | ||
428 | .mt_wled = "WLED", | ||
429 | .mt_lcd_switch = "\\Q10", | ||
430 | .lcd_status = "\\GP06", | ||
431 | .brightness_set = "SPLV", | ||
432 | .brightness_get = "GPLV", | ||
433 | .display_set = "SDSP", | ||
434 | .display_get = "\\INFB" | ||
435 | } | ||
424 | }; | 436 | }; |
425 | 437 | ||
426 | /* procdir we use */ | 438 | /* procdir we use */ |
@@ -1165,6 +1177,8 @@ static int asus_model_match(char *model) | |||
1165 | return W3V; | 1177 | return W3V; |
1166 | else if (strncmp(model, "W5A", 3) == 0) | 1178 | else if (strncmp(model, "W5A", 3) == 0) |
1167 | return W5A; | 1179 | return W5A; |
1180 | else if (strncmp(model, "R1F", 3) == 0) | ||
1181 | return R1F; | ||
1168 | else if (strncmp(model, "A4S", 3) == 0) | 1182 | else if (strncmp(model, "A4S", 3) == 0) |
1169 | return A4S; | 1183 | return A4S; |
1170 | else if (strncmp(model, "F3Sa", 4) == 0) | 1184 | else if (strncmp(model, "F3Sa", 4) == 0) |
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 9d93cb971e59..786ed8661cb0 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/uaccess.h> | 30 | #include <linux/uaccess.h> |
31 | #include <linux/input.h> | 31 | #include <linux/input.h> |
32 | #include <linux/rfkill.h> | 32 | #include <linux/rfkill.h> |
33 | #include <linux/pci.h> | ||
33 | 34 | ||
34 | #define EEEPC_LAPTOP_VERSION "0.1" | 35 | #define EEEPC_LAPTOP_VERSION "0.1" |
35 | 36 | ||
@@ -161,6 +162,10 @@ static struct key_entry eeepc_keymap[] = { | |||
161 | {KE_KEY, 0x13, KEY_MUTE }, | 162 | {KE_KEY, 0x13, KEY_MUTE }, |
162 | {KE_KEY, 0x14, KEY_VOLUMEDOWN }, | 163 | {KE_KEY, 0x14, KEY_VOLUMEDOWN }, |
163 | {KE_KEY, 0x15, KEY_VOLUMEUP }, | 164 | {KE_KEY, 0x15, KEY_VOLUMEUP }, |
165 | {KE_KEY, 0x1a, KEY_COFFEE }, | ||
166 | {KE_KEY, 0x1b, KEY_ZOOM }, | ||
167 | {KE_KEY, 0x1c, KEY_PROG2 }, | ||
168 | {KE_KEY, 0x1d, KEY_PROG3 }, | ||
164 | {KE_KEY, 0x30, KEY_SWITCHVIDEOMODE }, | 169 | {KE_KEY, 0x30, KEY_SWITCHVIDEOMODE }, |
165 | {KE_KEY, 0x31, KEY_SWITCHVIDEOMODE }, | 170 | {KE_KEY, 0x31, KEY_SWITCHVIDEOMODE }, |
166 | {KE_KEY, 0x32, KEY_SWITCHVIDEOMODE }, | 171 | {KE_KEY, 0x32, KEY_SWITCHVIDEOMODE }, |
@@ -510,7 +515,43 @@ static int eeepc_hotk_check(void) | |||
510 | static void notify_brn(void) | 515 | static void notify_brn(void) |
511 | { | 516 | { |
512 | struct backlight_device *bd = eeepc_backlight_device; | 517 | struct backlight_device *bd = eeepc_backlight_device; |
513 | bd->props.brightness = read_brightness(bd); | 518 | if (bd) |
519 | bd->props.brightness = read_brightness(bd); | ||
520 | } | ||
521 | |||
522 | static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) | ||
523 | { | ||
524 | struct pci_dev *dev; | ||
525 | struct pci_bus *bus = pci_find_bus(0, 1); | ||
526 | |||
527 | if (event != ACPI_NOTIFY_BUS_CHECK) | ||
528 | return; | ||
529 | |||
530 | if (!bus) { | ||
531 | printk(EEEPC_WARNING "Unable to find PCI bus 1?\n"); | ||
532 | return; | ||
533 | } | ||
534 | |||
535 | if (get_acpi(CM_ASL_WLAN) == 1) { | ||
536 | dev = pci_get_slot(bus, 0); | ||
537 | if (dev) { | ||
538 | /* Device already present */ | ||
539 | pci_dev_put(dev); | ||
540 | return; | ||
541 | } | ||
542 | dev = pci_scan_single_device(bus, 0); | ||
543 | if (dev) { | ||
544 | pci_bus_assign_resources(bus); | ||
545 | if (pci_bus_add_device(dev)) | ||
546 | printk(EEEPC_ERR "Unable to hotplug wifi\n"); | ||
547 | } | ||
548 | } else { | ||
549 | dev = pci_get_slot(bus, 0); | ||
550 | if (dev) { | ||
551 | pci_remove_bus_device(dev); | ||
552 | pci_dev_put(dev); | ||
553 | } | ||
554 | } | ||
514 | } | 555 | } |
515 | 556 | ||
516 | static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) | 557 | static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) |
@@ -520,8 +561,9 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) | |||
520 | return; | 561 | return; |
521 | if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) | 562 | if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) |
522 | notify_brn(); | 563 | notify_brn(); |
523 | acpi_bus_generate_proc_event(ehotk->device, event, | 564 | acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class, |
524 | ehotk->event_count[event % 128]++); | 565 | dev_name(&ehotk->device->dev), event, |
566 | ehotk->event_count[event % 128]++); | ||
525 | if (ehotk->inputdev) { | 567 | if (ehotk->inputdev) { |
526 | key = eepc_get_entry_by_scancode(event); | 568 | key = eepc_get_entry_by_scancode(event); |
527 | if (key) { | 569 | if (key) { |
@@ -539,6 +581,45 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) | |||
539 | } | 581 | } |
540 | } | 582 | } |
541 | 583 | ||
584 | static int eeepc_register_rfkill_notifier(char *node) | ||
585 | { | ||
586 | acpi_status status = AE_OK; | ||
587 | acpi_handle handle; | ||
588 | |||
589 | status = acpi_get_handle(NULL, node, &handle); | ||
590 | |||
591 | if (ACPI_SUCCESS(status)) { | ||
592 | status = acpi_install_notify_handler(handle, | ||
593 | ACPI_SYSTEM_NOTIFY, | ||
594 | eeepc_rfkill_notify, | ||
595 | NULL); | ||
596 | if (ACPI_FAILURE(status)) | ||
597 | printk(EEEPC_WARNING | ||
598 | "Failed to register notify on %s\n", node); | ||
599 | } else | ||
600 | return -ENODEV; | ||
601 | |||
602 | return 0; | ||
603 | } | ||
604 | |||
605 | static void eeepc_unregister_rfkill_notifier(char *node) | ||
606 | { | ||
607 | acpi_status status = AE_OK; | ||
608 | acpi_handle handle; | ||
609 | |||
610 | status = acpi_get_handle(NULL, node, &handle); | ||
611 | |||
612 | if (ACPI_SUCCESS(status)) { | ||
613 | status = acpi_remove_notify_handler(handle, | ||
614 | ACPI_SYSTEM_NOTIFY, | ||
615 | eeepc_rfkill_notify); | ||
616 | if (ACPI_FAILURE(status)) | ||
617 | printk(EEEPC_ERR | ||
618 | "Error removing rfkill notify handler %s\n", | ||
619 | node); | ||
620 | } | ||
621 | } | ||
622 | |||
542 | static int eeepc_hotk_add(struct acpi_device *device) | 623 | static int eeepc_hotk_add(struct acpi_device *device) |
543 | { | 624 | { |
544 | acpi_status status = AE_OK; | 625 | acpi_status status = AE_OK; |
@@ -558,7 +639,7 @@ static int eeepc_hotk_add(struct acpi_device *device) | |||
558 | ehotk->device = device; | 639 | ehotk->device = device; |
559 | result = eeepc_hotk_check(); | 640 | result = eeepc_hotk_check(); |
560 | if (result) | 641 | if (result) |
561 | goto end; | 642 | goto ehotk_fail; |
562 | status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY, | 643 | status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY, |
563 | eeepc_hotk_notify, ehotk); | 644 | eeepc_hotk_notify, ehotk); |
564 | if (ACPI_FAILURE(status)) | 645 | if (ACPI_FAILURE(status)) |
@@ -569,18 +650,25 @@ static int eeepc_hotk_add(struct acpi_device *device) | |||
569 | RFKILL_TYPE_WLAN); | 650 | RFKILL_TYPE_WLAN); |
570 | 651 | ||
571 | if (!ehotk->eeepc_wlan_rfkill) | 652 | if (!ehotk->eeepc_wlan_rfkill) |
572 | goto end; | 653 | goto wlan_fail; |
573 | 654 | ||
574 | ehotk->eeepc_wlan_rfkill->name = "eeepc-wlan"; | 655 | ehotk->eeepc_wlan_rfkill->name = "eeepc-wlan"; |
575 | ehotk->eeepc_wlan_rfkill->toggle_radio = eeepc_wlan_rfkill_set; | 656 | ehotk->eeepc_wlan_rfkill->toggle_radio = eeepc_wlan_rfkill_set; |
576 | ehotk->eeepc_wlan_rfkill->get_state = eeepc_wlan_rfkill_state; | 657 | ehotk->eeepc_wlan_rfkill->get_state = eeepc_wlan_rfkill_state; |
577 | if (get_acpi(CM_ASL_WLAN) == 1) | 658 | if (get_acpi(CM_ASL_WLAN) == 1) { |
578 | ehotk->eeepc_wlan_rfkill->state = | 659 | ehotk->eeepc_wlan_rfkill->state = |
579 | RFKILL_STATE_UNBLOCKED; | 660 | RFKILL_STATE_UNBLOCKED; |
580 | else | 661 | rfkill_set_default(RFKILL_TYPE_WLAN, |
662 | RFKILL_STATE_UNBLOCKED); | ||
663 | } else { | ||
581 | ehotk->eeepc_wlan_rfkill->state = | 664 | ehotk->eeepc_wlan_rfkill->state = |
582 | RFKILL_STATE_SOFT_BLOCKED; | 665 | RFKILL_STATE_SOFT_BLOCKED; |
583 | rfkill_register(ehotk->eeepc_wlan_rfkill); | 666 | rfkill_set_default(RFKILL_TYPE_WLAN, |
667 | RFKILL_STATE_SOFT_BLOCKED); | ||
668 | } | ||
669 | result = rfkill_register(ehotk->eeepc_wlan_rfkill); | ||
670 | if (result) | ||
671 | goto wlan_fail; | ||
584 | } | 672 | } |
585 | 673 | ||
586 | if (get_acpi(CM_ASL_BLUETOOTH) != -1) { | 674 | if (get_acpi(CM_ASL_BLUETOOTH) != -1) { |
@@ -588,27 +676,47 @@ static int eeepc_hotk_add(struct acpi_device *device) | |||
588 | rfkill_allocate(&device->dev, RFKILL_TYPE_BLUETOOTH); | 676 | rfkill_allocate(&device->dev, RFKILL_TYPE_BLUETOOTH); |
589 | 677 | ||
590 | if (!ehotk->eeepc_bluetooth_rfkill) | 678 | if (!ehotk->eeepc_bluetooth_rfkill) |
591 | goto end; | 679 | goto bluetooth_fail; |
592 | 680 | ||
593 | ehotk->eeepc_bluetooth_rfkill->name = "eeepc-bluetooth"; | 681 | ehotk->eeepc_bluetooth_rfkill->name = "eeepc-bluetooth"; |
594 | ehotk->eeepc_bluetooth_rfkill->toggle_radio = | 682 | ehotk->eeepc_bluetooth_rfkill->toggle_radio = |
595 | eeepc_bluetooth_rfkill_set; | 683 | eeepc_bluetooth_rfkill_set; |
596 | ehotk->eeepc_bluetooth_rfkill->get_state = | 684 | ehotk->eeepc_bluetooth_rfkill->get_state = |
597 | eeepc_bluetooth_rfkill_state; | 685 | eeepc_bluetooth_rfkill_state; |
598 | if (get_acpi(CM_ASL_BLUETOOTH) == 1) | 686 | if (get_acpi(CM_ASL_BLUETOOTH) == 1) { |
599 | ehotk->eeepc_bluetooth_rfkill->state = | 687 | ehotk->eeepc_bluetooth_rfkill->state = |
600 | RFKILL_STATE_UNBLOCKED; | 688 | RFKILL_STATE_UNBLOCKED; |
601 | else | 689 | rfkill_set_default(RFKILL_TYPE_BLUETOOTH, |
690 | RFKILL_STATE_UNBLOCKED); | ||
691 | } else { | ||
602 | ehotk->eeepc_bluetooth_rfkill->state = | 692 | ehotk->eeepc_bluetooth_rfkill->state = |
603 | RFKILL_STATE_SOFT_BLOCKED; | 693 | RFKILL_STATE_SOFT_BLOCKED; |
604 | rfkill_register(ehotk->eeepc_bluetooth_rfkill); | 694 | rfkill_set_default(RFKILL_TYPE_BLUETOOTH, |
605 | } | 695 | RFKILL_STATE_SOFT_BLOCKED); |
696 | } | ||
606 | 697 | ||
607 | end: | 698 | result = rfkill_register(ehotk->eeepc_bluetooth_rfkill); |
608 | if (result) { | 699 | if (result) |
609 | kfree(ehotk); | 700 | goto bluetooth_fail; |
610 | ehotk = NULL; | ||
611 | } | 701 | } |
702 | |||
703 | eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6"); | ||
704 | eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7"); | ||
705 | |||
706 | return 0; | ||
707 | |||
708 | bluetooth_fail: | ||
709 | if (ehotk->eeepc_bluetooth_rfkill) | ||
710 | rfkill_free(ehotk->eeepc_bluetooth_rfkill); | ||
711 | rfkill_unregister(ehotk->eeepc_wlan_rfkill); | ||
712 | ehotk->eeepc_wlan_rfkill = NULL; | ||
713 | wlan_fail: | ||
714 | if (ehotk->eeepc_wlan_rfkill) | ||
715 | rfkill_free(ehotk->eeepc_wlan_rfkill); | ||
716 | ehotk_fail: | ||
717 | kfree(ehotk); | ||
718 | ehotk = NULL; | ||
719 | |||
612 | return result; | 720 | return result; |
613 | } | 721 | } |
614 | 722 | ||
@@ -622,6 +730,10 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type) | |||
622 | eeepc_hotk_notify); | 730 | eeepc_hotk_notify); |
623 | if (ACPI_FAILURE(status)) | 731 | if (ACPI_FAILURE(status)) |
624 | printk(EEEPC_ERR "Error removing notify handler\n"); | 732 | printk(EEEPC_ERR "Error removing notify handler\n"); |
733 | |||
734 | eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6"); | ||
735 | eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7"); | ||
736 | |||
625 | kfree(ehotk); | 737 | kfree(ehotk); |
626 | return 0; | 738 | return 0; |
627 | } | 739 | } |
@@ -737,13 +849,21 @@ static void eeepc_backlight_exit(void) | |||
737 | { | 849 | { |
738 | if (eeepc_backlight_device) | 850 | if (eeepc_backlight_device) |
739 | backlight_device_unregister(eeepc_backlight_device); | 851 | backlight_device_unregister(eeepc_backlight_device); |
740 | if (ehotk->inputdev) | 852 | eeepc_backlight_device = NULL; |
741 | input_unregister_device(ehotk->inputdev); | 853 | } |
854 | |||
855 | static void eeepc_rfkill_exit(void) | ||
856 | { | ||
742 | if (ehotk->eeepc_wlan_rfkill) | 857 | if (ehotk->eeepc_wlan_rfkill) |
743 | rfkill_unregister(ehotk->eeepc_wlan_rfkill); | 858 | rfkill_unregister(ehotk->eeepc_wlan_rfkill); |
744 | if (ehotk->eeepc_bluetooth_rfkill) | 859 | if (ehotk->eeepc_bluetooth_rfkill) |
745 | rfkill_unregister(ehotk->eeepc_bluetooth_rfkill); | 860 | rfkill_unregister(ehotk->eeepc_bluetooth_rfkill); |
746 | eeepc_backlight_device = NULL; | 861 | } |
862 | |||
863 | static void eeepc_input_exit(void) | ||
864 | { | ||
865 | if (ehotk->inputdev) | ||
866 | input_unregister_device(ehotk->inputdev); | ||
747 | } | 867 | } |
748 | 868 | ||
749 | static void eeepc_hwmon_exit(void) | 869 | static void eeepc_hwmon_exit(void) |
@@ -762,6 +882,8 @@ static void eeepc_hwmon_exit(void) | |||
762 | static void __exit eeepc_laptop_exit(void) | 882 | static void __exit eeepc_laptop_exit(void) |
763 | { | 883 | { |
764 | eeepc_backlight_exit(); | 884 | eeepc_backlight_exit(); |
885 | eeepc_rfkill_exit(); | ||
886 | eeepc_input_exit(); | ||
765 | eeepc_hwmon_exit(); | 887 | eeepc_hwmon_exit(); |
766 | acpi_bus_unregister_driver(&eeepc_hotk_driver); | 888 | acpi_bus_unregister_driver(&eeepc_hotk_driver); |
767 | sysfs_remove_group(&platform_device->dev.kobj, | 889 | sysfs_remove_group(&platform_device->dev.kobj, |
@@ -865,6 +987,8 @@ fail_platform_driver: | |||
865 | fail_hwmon: | 987 | fail_hwmon: |
866 | eeepc_backlight_exit(); | 988 | eeepc_backlight_exit(); |
867 | fail_backlight: | 989 | fail_backlight: |
990 | eeepc_input_exit(); | ||
991 | eeepc_rfkill_exit(); | ||
868 | return result; | 992 | return result; |
869 | } | 993 | } |
870 | 994 | ||
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index de91ddab0a86..f41135f2fb29 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c | |||
@@ -463,9 +463,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) | |||
463 | 463 | ||
464 | return 0; | 464 | return 0; |
465 | register_wwan_err: | 465 | register_wwan_err: |
466 | rfkill_unregister(bluetooth_rfkill); | 466 | if (bluetooth_rfkill) |
467 | rfkill_unregister(bluetooth_rfkill); | ||
467 | register_bluetooth_error: | 468 | register_bluetooth_error: |
468 | rfkill_unregister(wifi_rfkill); | 469 | if (wifi_rfkill) |
470 | rfkill_unregister(wifi_rfkill); | ||
469 | add_sysfs_error: | 471 | add_sysfs_error: |
470 | cleanup_sysfs(device); | 472 | cleanup_sysfs(device); |
471 | return err; | 473 | return err; |
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index f30db367c82e..c47a44dcb702 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c | |||
@@ -507,7 +507,7 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc) | |||
507 | 507 | ||
508 | hkey_num = result & 0xf; | 508 | hkey_num = result & 0xf; |
509 | 509 | ||
510 | if (hkey_num < 0 || hkey_num > ARRAY_SIZE(pcc->keymap)) { | 510 | if (hkey_num < 0 || hkey_num >= ARRAY_SIZE(pcc->keymap)) { |
511 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 511 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
512 | "hotkey number out of range: %d\n", | 512 | "hotkey number out of range: %d\n", |
513 | hkey_num)); | 513 | hkey_num)); |
diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c index 366565aba865..c175e38a4cd5 100644 --- a/drivers/regulator/bq24022.c +++ b/drivers/regulator/bq24022.c | |||
@@ -152,11 +152,7 @@ static void __exit bq24022_exit(void) | |||
152 | platform_driver_unregister(&bq24022_driver); | 152 | platform_driver_unregister(&bq24022_driver); |
153 | } | 153 | } |
154 | 154 | ||
155 | /* | 155 | module_init(bq24022_init); |
156 | * make sure this is probed before gpio_vbus and pda_power, | ||
157 | * but after asic3 or other GPIO expander drivers. | ||
158 | */ | ||
159 | subsys_initcall(bq24022_init); | ||
160 | module_exit(bq24022_exit); | 156 | module_exit(bq24022_exit); |
161 | 157 | ||
162 | MODULE_AUTHOR("Philipp Zabel"); | 158 | MODULE_AUTHOR("Philipp Zabel"); |
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index 7aa35248181b..5056e23e4414 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c | |||
@@ -1435,7 +1435,7 @@ int wm8350_register_led(struct wm8350 *wm8350, int lednum, int dcdc, int isink, | |||
1435 | struct platform_device *pdev; | 1435 | struct platform_device *pdev; |
1436 | int ret; | 1436 | int ret; |
1437 | 1437 | ||
1438 | if (lednum > ARRAY_SIZE(wm8350->pmic.led) || lednum < 0) { | 1438 | if (lednum >= ARRAY_SIZE(wm8350->pmic.led) || lednum < 0) { |
1439 | dev_err(wm8350->dev, "Invalid LED index %d\n", lednum); | 1439 | dev_err(wm8350->dev, "Invalid LED index %d\n", lednum); |
1440 | return -ENODEV; | 1440 | return -ENODEV; |
1441 | } | 1441 | } |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index cced4d108319..81450fbd8b12 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -241,6 +241,12 @@ config RTC_DRV_M41T80_WDT | |||
241 | If you say Y here you will get support for the | 241 | If you say Y here you will get support for the |
242 | watchdog timer in the ST M41T60 and M41T80 RTC chips series. | 242 | watchdog timer in the ST M41T60 and M41T80 RTC chips series. |
243 | 243 | ||
244 | config RTC_DRV_DM355EVM | ||
245 | tristate "TI DaVinci DM355 EVM RTC" | ||
246 | depends on MFD_DM355EVM_MSP | ||
247 | help | ||
248 | Supports the RTC firmware in the MSP430 on the DM355 EVM. | ||
249 | |||
244 | config RTC_DRV_TWL92330 | 250 | config RTC_DRV_TWL92330 |
245 | boolean "TI TWL92330/Menelaus" | 251 | boolean "TI TWL92330/Menelaus" |
246 | depends on MENELAUS | 252 | depends on MENELAUS |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 6e28021abb9d..0e697aa51caa 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -23,6 +23,7 @@ obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o | |||
23 | obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o | 23 | obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o |
24 | obj-$(CONFIG_RTC_DRV_BFIN) += rtc-bfin.o | 24 | obj-$(CONFIG_RTC_DRV_BFIN) += rtc-bfin.o |
25 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o | 25 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o |
26 | obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o | ||
26 | obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o | 27 | obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o |
27 | obj-$(CONFIG_RTC_DRV_DS1286) += rtc-ds1286.o | 28 | obj-$(CONFIG_RTC_DRV_DS1286) += rtc-ds1286.o |
28 | obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o | 29 | obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o |
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c new file mode 100644 index 000000000000..58d4e18530da --- /dev/null +++ b/drivers/rtc/rtc-dm355evm.c | |||
@@ -0,0 +1,175 @@ | |||
1 | /* | ||
2 | * rtc-dm355evm.c - access battery-backed counter in MSP430 firmware | ||
3 | * | ||
4 | * Copyright (c) 2008 by David Brownell | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/rtc.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | |||
16 | #include <linux/i2c/dm355evm_msp.h> | ||
17 | |||
18 | |||
19 | /* | ||
20 | * The MSP430 firmware on the DM355 EVM uses a watch crystal to feed | ||
21 | * a 1 Hz counter. When a backup battery is supplied, that makes a | ||
22 | * reasonable RTC for applications where alarms and non-NTP drift | ||
23 | * compensation aren't important. | ||
24 | * | ||
25 | * The only real glitch is the inability to read or write all four | ||
26 | * counter bytes atomically: the count may increment in the middle | ||
27 | * of an operation, causing trouble when the LSB rolls over. | ||
28 | * | ||
29 | * This driver was tested with firmware revision A4. | ||
30 | */ | ||
31 | union evm_time { | ||
32 | u8 bytes[4]; | ||
33 | u32 value; | ||
34 | }; | ||
35 | |||
36 | static int dm355evm_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
37 | { | ||
38 | union evm_time time; | ||
39 | int status; | ||
40 | int tries = 0; | ||
41 | |||
42 | do { | ||
43 | /* | ||
44 | * Read LSB(0) to MSB(3) bytes. Defend against the counter | ||
45 | * rolling over by re-reading until the value is stable, | ||
46 | * and assuming the four reads take at most a few seconds. | ||
47 | */ | ||
48 | status = dm355evm_msp_read(DM355EVM_MSP_RTC_0); | ||
49 | if (status < 0) | ||
50 | return status; | ||
51 | if (tries && time.bytes[0] == status) | ||
52 | break; | ||
53 | time.bytes[0] = status; | ||
54 | |||
55 | status = dm355evm_msp_read(DM355EVM_MSP_RTC_1); | ||
56 | if (status < 0) | ||
57 | return status; | ||
58 | if (tries && time.bytes[1] == status) | ||
59 | break; | ||
60 | time.bytes[1] = status; | ||
61 | |||
62 | status = dm355evm_msp_read(DM355EVM_MSP_RTC_2); | ||
63 | if (status < 0) | ||
64 | return status; | ||
65 | if (tries && time.bytes[2] == status) | ||
66 | break; | ||
67 | time.bytes[2] = status; | ||
68 | |||
69 | status = dm355evm_msp_read(DM355EVM_MSP_RTC_3); | ||
70 | if (status < 0) | ||
71 | return status; | ||
72 | if (tries && time.bytes[3] == status) | ||
73 | break; | ||
74 | time.bytes[3] = status; | ||
75 | |||
76 | } while (++tries < 5); | ||
77 | |||
78 | dev_dbg(dev, "read timestamp %08x\n", time.value); | ||
79 | |||
80 | rtc_time_to_tm(le32_to_cpu(time.value), tm); | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static int dm355evm_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
85 | { | ||
86 | union evm_time time; | ||
87 | unsigned long value; | ||
88 | int status; | ||
89 | |||
90 | rtc_tm_to_time(tm, &value); | ||
91 | time.value = cpu_to_le32(value); | ||
92 | |||
93 | dev_dbg(dev, "write timestamp %08x\n", time.value); | ||
94 | |||
95 | /* | ||
96 | * REVISIT handle non-atomic writes ... maybe just retry until | ||
97 | * byte[1] sticks (no rollover)? | ||
98 | */ | ||
99 | status = dm355evm_msp_write(time.bytes[0], DM355EVM_MSP_RTC_0); | ||
100 | if (status < 0) | ||
101 | return status; | ||
102 | |||
103 | status = dm355evm_msp_write(time.bytes[1], DM355EVM_MSP_RTC_1); | ||
104 | if (status < 0) | ||
105 | return status; | ||
106 | |||
107 | status = dm355evm_msp_write(time.bytes[2], DM355EVM_MSP_RTC_2); | ||
108 | if (status < 0) | ||
109 | return status; | ||
110 | |||
111 | status = dm355evm_msp_write(time.bytes[3], DM355EVM_MSP_RTC_3); | ||
112 | if (status < 0) | ||
113 | return status; | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | static struct rtc_class_ops dm355evm_rtc_ops = { | ||
119 | .read_time = dm355evm_rtc_read_time, | ||
120 | .set_time = dm355evm_rtc_set_time, | ||
121 | }; | ||
122 | |||
123 | /*----------------------------------------------------------------------*/ | ||
124 | |||
125 | static int __devinit dm355evm_rtc_probe(struct platform_device *pdev) | ||
126 | { | ||
127 | struct rtc_device *rtc; | ||
128 | |||
129 | rtc = rtc_device_register(pdev->name, | ||
130 | &pdev->dev, &dm355evm_rtc_ops, THIS_MODULE); | ||
131 | if (IS_ERR(rtc)) { | ||
132 | dev_err(&pdev->dev, "can't register RTC device, err %ld\n", | ||
133 | PTR_ERR(rtc)); | ||
134 | return PTR_ERR(rtc); | ||
135 | } | ||
136 | platform_set_drvdata(pdev, rtc); | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static int __devexit dm355evm_rtc_remove(struct platform_device *pdev) | ||
142 | { | ||
143 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
144 | |||
145 | rtc_device_unregister(rtc); | ||
146 | platform_set_drvdata(pdev, NULL); | ||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | /* | ||
151 | * I2C is used to talk to the MSP430, but this platform device is | ||
152 | * exposed by an MFD driver that manages I2C communications. | ||
153 | */ | ||
154 | static struct platform_driver rtc_dm355evm_driver = { | ||
155 | .probe = dm355evm_rtc_probe, | ||
156 | .remove = __devexit_p(dm355evm_rtc_remove), | ||
157 | .driver = { | ||
158 | .owner = THIS_MODULE, | ||
159 | .name = "rtc-dm355evm", | ||
160 | }, | ||
161 | }; | ||
162 | |||
163 | static int __init dm355evm_rtc_init(void) | ||
164 | { | ||
165 | return platform_driver_register(&rtc_dm355evm_driver); | ||
166 | } | ||
167 | module_init(dm355evm_rtc_init); | ||
168 | |||
169 | static void __exit dm355evm_rtc_exit(void) | ||
170 | { | ||
171 | platform_driver_unregister(&rtc_dm355evm_driver); | ||
172 | } | ||
173 | module_exit(dm355evm_rtc_exit); | ||
174 | |||
175 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c index e54b5c619bdf..e01b955db077 100644 --- a/drivers/rtc/rtc-ds1390.c +++ b/drivers/rtc/rtc-ds1390.c | |||
@@ -122,7 +122,6 @@ static const struct rtc_class_ops ds1390_rtc_ops = { | |||
122 | 122 | ||
123 | static int __devinit ds1390_probe(struct spi_device *spi) | 123 | static int __devinit ds1390_probe(struct spi_device *spi) |
124 | { | 124 | { |
125 | struct rtc_device *rtc; | ||
126 | unsigned char tmp; | 125 | unsigned char tmp; |
127 | struct ds1390 *chip; | 126 | struct ds1390 *chip; |
128 | int res; | 127 | int res; |
diff --git a/drivers/usb/host/whci/asl.c b/drivers/usb/host/whci/asl.c index 577c0d29849d..2291c5f5af51 100644 --- a/drivers/usb/host/whci/asl.c +++ b/drivers/usb/host/whci/asl.c | |||
@@ -170,12 +170,17 @@ void asl_stop(struct whc *whc) | |||
170 | void asl_update(struct whc *whc, uint32_t wusbcmd) | 170 | void asl_update(struct whc *whc, uint32_t wusbcmd) |
171 | { | 171 | { |
172 | struct wusbhc *wusbhc = &whc->wusbhc; | 172 | struct wusbhc *wusbhc = &whc->wusbhc; |
173 | long t; | ||
173 | 174 | ||
174 | mutex_lock(&wusbhc->mutex); | 175 | mutex_lock(&wusbhc->mutex); |
175 | if (wusbhc->active) { | 176 | if (wusbhc->active) { |
176 | whc_write_wusbcmd(whc, wusbcmd, wusbcmd); | 177 | whc_write_wusbcmd(whc, wusbcmd, wusbcmd); |
177 | wait_event(whc->async_list_wq, | 178 | t = wait_event_timeout( |
178 | (le_readl(whc->base + WUSBCMD) & WUSBCMD_ASYNC_UPDATED) == 0); | 179 | whc->async_list_wq, |
180 | (le_readl(whc->base + WUSBCMD) & WUSBCMD_ASYNC_UPDATED) == 0, | ||
181 | msecs_to_jiffies(1000)); | ||
182 | if (t == 0) | ||
183 | whc_hw_error(whc, "ASL update timeout"); | ||
179 | } | 184 | } |
180 | mutex_unlock(&wusbhc->mutex); | 185 | mutex_unlock(&wusbhc->mutex); |
181 | } | 186 | } |
diff --git a/drivers/usb/host/whci/hw.c b/drivers/usb/host/whci/hw.c index d498e7203217..6afa2e379160 100644 --- a/drivers/usb/host/whci/hw.c +++ b/drivers/usb/host/whci/hw.c | |||
@@ -87,3 +87,18 @@ out: | |||
87 | 87 | ||
88 | return ret; | 88 | return ret; |
89 | } | 89 | } |
90 | |||
91 | /** | ||
92 | * whc_hw_error - recover from a hardware error | ||
93 | * @whc: the WHCI HC that broke. | ||
94 | * @reason: a description of the failure. | ||
95 | * | ||
96 | * Recover from broken hardware with a full reset. | ||
97 | */ | ||
98 | void whc_hw_error(struct whc *whc, const char *reason) | ||
99 | { | ||
100 | struct wusbhc *wusbhc = &whc->wusbhc; | ||
101 | |||
102 | dev_err(&whc->umc->dev, "hardware error: %s\n", reason); | ||
103 | wusbhc_reset_all(wusbhc); | ||
104 | } | ||
diff --git a/drivers/usb/host/whci/pzl.c b/drivers/usb/host/whci/pzl.c index 2ae5abf69a6a..7dc85a0bee7c 100644 --- a/drivers/usb/host/whci/pzl.c +++ b/drivers/usb/host/whci/pzl.c | |||
@@ -183,12 +183,17 @@ void pzl_stop(struct whc *whc) | |||
183 | void pzl_update(struct whc *whc, uint32_t wusbcmd) | 183 | void pzl_update(struct whc *whc, uint32_t wusbcmd) |
184 | { | 184 | { |
185 | struct wusbhc *wusbhc = &whc->wusbhc; | 185 | struct wusbhc *wusbhc = &whc->wusbhc; |
186 | long t; | ||
186 | 187 | ||
187 | mutex_lock(&wusbhc->mutex); | 188 | mutex_lock(&wusbhc->mutex); |
188 | if (wusbhc->active) { | 189 | if (wusbhc->active) { |
189 | whc_write_wusbcmd(whc, wusbcmd, wusbcmd); | 190 | whc_write_wusbcmd(whc, wusbcmd, wusbcmd); |
190 | wait_event(whc->periodic_list_wq, | 191 | t = wait_event_timeout( |
191 | (le_readl(whc->base + WUSBCMD) & WUSBCMD_PERIODIC_UPDATED) == 0); | 192 | whc->periodic_list_wq, |
193 | (le_readl(whc->base + WUSBCMD) & WUSBCMD_PERIODIC_UPDATED) == 0, | ||
194 | msecs_to_jiffies(1000)); | ||
195 | if (t == 0) | ||
196 | whc_hw_error(whc, "PZL update timeout"); | ||
192 | } | 197 | } |
193 | mutex_unlock(&wusbhc->mutex); | 198 | mutex_unlock(&wusbhc->mutex); |
194 | } | 199 | } |
diff --git a/drivers/usb/host/whci/whcd.h b/drivers/usb/host/whci/whcd.h index 0f3540f04f53..d3543a181dc9 100644 --- a/drivers/usb/host/whci/whcd.h +++ b/drivers/usb/host/whci/whcd.h | |||
@@ -137,6 +137,7 @@ void whc_clean_up(struct whc *whc); | |||
137 | /* hw.c */ | 137 | /* hw.c */ |
138 | void whc_write_wusbcmd(struct whc *whc, u32 mask, u32 val); | 138 | void whc_write_wusbcmd(struct whc *whc, u32 mask, u32 val); |
139 | int whc_do_gencmd(struct whc *whc, u32 cmd, u32 params, void *addr, size_t len); | 139 | int whc_do_gencmd(struct whc *whc, u32 cmd, u32 params, void *addr, size_t len); |
140 | void whc_hw_error(struct whc *whc, const char *reason); | ||
140 | 141 | ||
141 | /* wusb.c */ | 142 | /* wusb.c */ |
142 | int whc_wusbhc_start(struct wusbhc *wusbhc); | 143 | int whc_wusbhc_start(struct wusbhc *wusbhc); |
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c index e2e7e4bc8463..8e18141bb2e0 100644 --- a/drivers/usb/wusbcore/devconnect.c +++ b/drivers/usb/wusbcore/devconnect.c | |||
@@ -386,6 +386,7 @@ static void __wusbhc_dev_disconnect(struct wusbhc *wusbhc, | |||
386 | | USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED); | 386 | | USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED); |
387 | port->change |= USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE; | 387 | port->change |= USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE; |
388 | if (wusb_dev) { | 388 | if (wusb_dev) { |
389 | dev_dbg(wusbhc->dev, "disconnecting device from port %d\n", wusb_dev->port_idx); | ||
389 | if (!list_empty(&wusb_dev->cack_node)) | 390 | if (!list_empty(&wusb_dev->cack_node)) |
390 | list_del_init(&wusb_dev->cack_node); | 391 | list_del_init(&wusb_dev->cack_node); |
391 | /* For the one in cack_add() */ | 392 | /* For the one in cack_add() */ |
diff --git a/drivers/usb/wusbcore/rh.c b/drivers/usb/wusbcore/rh.c index 3937bf6f8cef..9fe4246cecb9 100644 --- a/drivers/usb/wusbcore/rh.c +++ b/drivers/usb/wusbcore/rh.c | |||
@@ -100,6 +100,9 @@ static int wusbhc_rh_port_reset(struct wusbhc *wusbhc, u8 port_idx) | |||
100 | struct wusb_port *port = wusb_port_by_idx(wusbhc, port_idx); | 100 | struct wusb_port *port = wusb_port_by_idx(wusbhc, port_idx); |
101 | struct wusb_dev *wusb_dev = port->wusb_dev; | 101 | struct wusb_dev *wusb_dev = port->wusb_dev; |
102 | 102 | ||
103 | if (wusb_dev == NULL) | ||
104 | return -ENOTCONN; | ||
105 | |||
103 | port->status |= USB_PORT_STAT_RESET; | 106 | port->status |= USB_PORT_STAT_RESET; |
104 | port->change |= USB_PORT_STAT_C_RESET; | 107 | port->change |= USB_PORT_STAT_C_RESET; |
105 | 108 | ||
diff --git a/drivers/uwb/allocator.c b/drivers/uwb/allocator.c index c8185e6b0cd5..c13cec7dcbc5 100644 --- a/drivers/uwb/allocator.c +++ b/drivers/uwb/allocator.c | |||
@@ -15,7 +15,6 @@ | |||
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
18 | #include <linux/version.h> | ||
19 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
20 | #include <linux/uwb.h> | 19 | #include <linux/uwb.h> |
21 | 20 | ||
diff --git a/drivers/uwb/drp.c b/drivers/uwb/drp.c index 2b4f9406789d..4f5ca99a04b9 100644 --- a/drivers/uwb/drp.c +++ b/drivers/uwb/drp.c | |||
@@ -66,14 +66,14 @@ static void uwb_rc_set_drp_cmd_done(struct uwb_rc *rc, void *arg, | |||
66 | } else | 66 | } else |
67 | dev_err(&rc->uwb_dev.dev, "SET-DRP-IE: timeout\n"); | 67 | dev_err(&rc->uwb_dev.dev, "SET-DRP-IE: timeout\n"); |
68 | 68 | ||
69 | spin_lock(&rc->rsvs_lock); | 69 | spin_lock_bh(&rc->rsvs_lock); |
70 | if (rc->set_drp_ie_pending > 1) { | 70 | if (rc->set_drp_ie_pending > 1) { |
71 | rc->set_drp_ie_pending = 0; | 71 | rc->set_drp_ie_pending = 0; |
72 | uwb_rsv_queue_update(rc); | 72 | uwb_rsv_queue_update(rc); |
73 | } else { | 73 | } else { |
74 | rc->set_drp_ie_pending = 0; | 74 | rc->set_drp_ie_pending = 0; |
75 | } | 75 | } |
76 | spin_unlock(&rc->rsvs_lock); | 76 | spin_unlock_bh(&rc->rsvs_lock); |
77 | } | 77 | } |
78 | 78 | ||
79 | /** | 79 | /** |
diff --git a/drivers/uwb/rsv.c b/drivers/uwb/rsv.c index ec6eecb32f30..6b76f4bb4cc7 100644 --- a/drivers/uwb/rsv.c +++ b/drivers/uwb/rsv.c | |||
@@ -114,7 +114,8 @@ void uwb_rsv_dump(char *text, struct uwb_rsv *rsv) | |||
114 | devaddr = rsv->target.devaddr; | 114 | devaddr = rsv->target.devaddr; |
115 | uwb_dev_addr_print(target, sizeof(target), &devaddr); | 115 | uwb_dev_addr_print(target, sizeof(target), &devaddr); |
116 | 116 | ||
117 | dev_dbg(dev, "rsv %s -> %s: %s\n", owner, target, uwb_rsv_state_str(rsv->state)); | 117 | dev_dbg(dev, "rsv %s %s -> %s: %s\n", |
118 | text, owner, target, uwb_rsv_state_str(rsv->state)); | ||
118 | } | 119 | } |
119 | 120 | ||
120 | static void uwb_rsv_release(struct kref *kref) | 121 | static void uwb_rsv_release(struct kref *kref) |
@@ -511,8 +512,7 @@ void uwb_rsv_remove(struct uwb_rsv *rsv) | |||
511 | 512 | ||
512 | if (uwb_rsv_is_owner(rsv)) | 513 | if (uwb_rsv_is_owner(rsv)) |
513 | uwb_rsv_put_stream(rsv); | 514 | uwb_rsv_put_stream(rsv); |
514 | 515 | ||
515 | del_timer_sync(&rsv->timer); | ||
516 | uwb_dev_put(rsv->owner); | 516 | uwb_dev_put(rsv->owner); |
517 | if (rsv->target.type == UWB_RSV_TARGET_DEV) | 517 | if (rsv->target.type == UWB_RSV_TARGET_DEV) |
518 | uwb_dev_put(rsv->target.dev); | 518 | uwb_dev_put(rsv->target.dev); |
@@ -870,7 +870,7 @@ void uwb_rsv_queue_update(struct uwb_rc *rc) | |||
870 | */ | 870 | */ |
871 | void uwb_rsv_sched_update(struct uwb_rc *rc) | 871 | void uwb_rsv_sched_update(struct uwb_rc *rc) |
872 | { | 872 | { |
873 | spin_lock(&rc->rsvs_lock); | 873 | spin_lock_bh(&rc->rsvs_lock); |
874 | if (!delayed_work_pending(&rc->rsv_update_work)) { | 874 | if (!delayed_work_pending(&rc->rsv_update_work)) { |
875 | if (rc->set_drp_ie_pending > 0) { | 875 | if (rc->set_drp_ie_pending > 0) { |
876 | rc->set_drp_ie_pending++; | 876 | rc->set_drp_ie_pending++; |
@@ -879,7 +879,7 @@ void uwb_rsv_sched_update(struct uwb_rc *rc) | |||
879 | uwb_rsv_queue_update(rc); | 879 | uwb_rsv_queue_update(rc); |
880 | } | 880 | } |
881 | unlock: | 881 | unlock: |
882 | spin_unlock(&rc->rsvs_lock); | 882 | spin_unlock_bh(&rc->rsvs_lock); |
883 | } | 883 | } |
884 | 884 | ||
885 | /* | 885 | /* |
@@ -943,13 +943,22 @@ void uwb_rsv_remove_all(struct uwb_rc *rc) | |||
943 | 943 | ||
944 | mutex_lock(&rc->rsvs_mutex); | 944 | mutex_lock(&rc->rsvs_mutex); |
945 | list_for_each_entry_safe(rsv, t, &rc->reservations, rc_node) { | 945 | list_for_each_entry_safe(rsv, t, &rc->reservations, rc_node) { |
946 | uwb_rsv_remove(rsv); | 946 | if (rsv->state != UWB_RSV_STATE_NONE) |
947 | uwb_rsv_set_state(rsv, UWB_RSV_STATE_NONE); | ||
948 | del_timer_sync(&rsv->timer); | ||
947 | } | 949 | } |
948 | /* Cancel any postponed update. */ | 950 | /* Cancel any postponed update. */ |
949 | rc->set_drp_ie_pending = 0; | 951 | rc->set_drp_ie_pending = 0; |
950 | mutex_unlock(&rc->rsvs_mutex); | 952 | mutex_unlock(&rc->rsvs_mutex); |
951 | 953 | ||
952 | cancel_delayed_work_sync(&rc->rsv_update_work); | 954 | cancel_delayed_work_sync(&rc->rsv_update_work); |
955 | flush_workqueue(rc->rsv_workq); | ||
956 | |||
957 | mutex_lock(&rc->rsvs_mutex); | ||
958 | list_for_each_entry_safe(rsv, t, &rc->reservations, rc_node) { | ||
959 | uwb_rsv_remove(rsv); | ||
960 | } | ||
961 | mutex_unlock(&rc->rsvs_mutex); | ||
953 | } | 962 | } |
954 | 963 | ||
955 | void uwb_rsv_init(struct uwb_rc *rc) | 964 | void uwb_rsv_init(struct uwb_rc *rc) |
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index db16112cf197..e6e299feb51b 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c | |||
@@ -1475,7 +1475,7 @@ static int aty128fb_set_par(struct fb_info *info) | |||
1475 | aty128_set_pll(&par->pll, par); | 1475 | aty128_set_pll(&par->pll, par); |
1476 | aty128_set_fifo(&par->fifo_reg, par); | 1476 | aty128_set_fifo(&par->fifo_reg, par); |
1477 | 1477 | ||
1478 | config = aty_ld_le32(CONFIG_CNTL) & ~3; | 1478 | config = aty_ld_le32(CNFG_CNTL) & ~3; |
1479 | 1479 | ||
1480 | #if defined(__BIG_ENDIAN) | 1480 | #if defined(__BIG_ENDIAN) |
1481 | if (par->crtc.bpp == 32) | 1481 | if (par->crtc.bpp == 32) |
@@ -1484,7 +1484,7 @@ static int aty128fb_set_par(struct fb_info *info) | |||
1484 | config |= 1; /* make aperture do 16 bit swapping */ | 1484 | config |= 1; /* make aperture do 16 bit swapping */ |
1485 | #endif | 1485 | #endif |
1486 | 1486 | ||
1487 | aty_st_le32(CONFIG_CNTL, config); | 1487 | aty_st_le32(CNFG_CNTL, config); |
1488 | aty_st_8(CRTC_EXT_CNTL + 1, 0); /* turn the video back on */ | 1488 | aty_st_8(CRTC_EXT_CNTL + 1, 0); /* turn the video back on */ |
1489 | 1489 | ||
1490 | info->fix.line_length = (par->crtc.vxres * par->crtc.bpp) >> 3; | 1490 | info->fix.line_length = (par->crtc.vxres * par->crtc.bpp) >> 3; |
@@ -1875,7 +1875,7 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i | |||
1875 | u32 dac; | 1875 | u32 dac; |
1876 | 1876 | ||
1877 | /* Get the chip revision */ | 1877 | /* Get the chip revision */ |
1878 | chip_rev = (aty_ld_le32(CONFIG_CNTL) >> 16) & 0x1F; | 1878 | chip_rev = (aty_ld_le32(CNFG_CNTL) >> 16) & 0x1F; |
1879 | 1879 | ||
1880 | strcpy(video_card, "Rage128 XX "); | 1880 | strcpy(video_card, "Rage128 XX "); |
1881 | video_card[8] = ent->device >> 8; | 1881 | video_card[8] = ent->device >> 8; |
@@ -2057,7 +2057,7 @@ static int __devinit aty128_probe(struct pci_dev *pdev, const struct pci_device_ | |||
2057 | 2057 | ||
2058 | /* Grab memory size from the card */ | 2058 | /* Grab memory size from the card */ |
2059 | // How does this relate to the resource length from the PCI hardware? | 2059 | // How does this relate to the resource length from the PCI hardware? |
2060 | par->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF; | 2060 | par->vram_size = aty_ld_le32(CNFG_MEMSIZE) & 0x03FFFFFF; |
2061 | 2061 | ||
2062 | /* Virtualize the framebuffer */ | 2062 | /* Virtualize the framebuffer */ |
2063 | info->screen_base = ioremap(fb_addr, par->vram_size); | 2063 | info->screen_base = ioremap(fb_addr, par->vram_size); |
@@ -2374,6 +2374,8 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend) | |||
2374 | /* Set the chip into the appropriate suspend mode (we use D2, | 2374 | /* Set the chip into the appropriate suspend mode (we use D2, |
2375 | * D3 would require a complete re-initialisation of the chip, | 2375 | * D3 would require a complete re-initialisation of the chip, |
2376 | * including PCI config registers, clocks, AGP configuration, ...) | 2376 | * including PCI config registers, clocks, AGP configuration, ...) |
2377 | * | ||
2378 | * For resume, the core will have already brought us back to D0 | ||
2377 | */ | 2379 | */ |
2378 | if (suspend) { | 2380 | if (suspend) { |
2379 | /* Make sure CRTC2 is reset. Remove that the day we decide to | 2381 | /* Make sure CRTC2 is reset. Remove that the day we decide to |
@@ -2391,17 +2393,9 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend) | |||
2391 | aty_st_le32(BUS_CNTL1, 0x00000010); | 2393 | aty_st_le32(BUS_CNTL1, 0x00000010); |
2392 | aty_st_le32(MEM_POWER_MISC, 0x0c830000); | 2394 | aty_st_le32(MEM_POWER_MISC, 0x0c830000); |
2393 | mdelay(100); | 2395 | mdelay(100); |
2394 | pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command); | 2396 | |
2395 | /* Switch PCI power management to D2 */ | 2397 | /* Switch PCI power management to D2 */ |
2396 | pci_write_config_word(pdev, par->pm_reg+PCI_PM_CTRL, | 2398 | pci_set_power_state(pdev, PCI_D2); |
2397 | (pwr_command & ~PCI_PM_CTRL_STATE_MASK) | 2); | ||
2398 | pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command); | ||
2399 | } else { | ||
2400 | /* Switch back PCI power management to D0 */ | ||
2401 | mdelay(100); | ||
2402 | pci_write_config_word(pdev, par->pm_reg+PCI_PM_CTRL, 0); | ||
2403 | pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command); | ||
2404 | mdelay(100); | ||
2405 | } | 2399 | } |
2406 | } | 2400 | } |
2407 | 2401 | ||
@@ -2410,6 +2404,12 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2410 | struct fb_info *info = pci_get_drvdata(pdev); | 2404 | struct fb_info *info = pci_get_drvdata(pdev); |
2411 | struct aty128fb_par *par = info->par; | 2405 | struct aty128fb_par *par = info->par; |
2412 | 2406 | ||
2407 | /* Because we may change PCI D state ourselves, we need to | ||
2408 | * first save the config space content so the core can | ||
2409 | * restore it properly on resume. | ||
2410 | */ | ||
2411 | pci_save_state(pdev); | ||
2412 | |||
2413 | /* We don't do anything but D2, for now we return 0, but | 2413 | /* We don't do anything but D2, for now we return 0, but |
2414 | * we may want to change that. How do we know if the BIOS | 2414 | * we may want to change that. How do we know if the BIOS |
2415 | * can properly take care of D3 ? Also, with swsusp, we | 2415 | * can properly take care of D3 ? Also, with swsusp, we |
@@ -2476,6 +2476,11 @@ static int aty128_do_resume(struct pci_dev *pdev) | |||
2476 | if (pdev->dev.power.power_state.event == PM_EVENT_ON) | 2476 | if (pdev->dev.power.power_state.event == PM_EVENT_ON) |
2477 | return 0; | 2477 | return 0; |
2478 | 2478 | ||
2479 | /* PCI state will have been restored by the core, so | ||
2480 | * we should be in D0 now with our config space fully | ||
2481 | * restored | ||
2482 | */ | ||
2483 | |||
2479 | /* Wakeup chip */ | 2484 | /* Wakeup chip */ |
2480 | aty128_set_suspend(par, 0); | 2485 | aty128_set_suspend(par, 0); |
2481 | par->asleep = 0; | 2486 | par->asleep = 0; |
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index cc6b470073da..1207c208a30b 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c | |||
@@ -135,7 +135,7 @@ | |||
135 | #if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \ | 135 | #if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \ |
136 | defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT) | 136 | defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT) |
137 | static const u32 lt_lcd_regs[] = { | 137 | static const u32 lt_lcd_regs[] = { |
138 | CONFIG_PANEL_LG, | 138 | CNFG_PANEL_LG, |
139 | LCD_GEN_CNTL_LG, | 139 | LCD_GEN_CNTL_LG, |
140 | DSTN_CONTROL_LG, | 140 | DSTN_CONTROL_LG, |
141 | HFB_PITCH_ADDR_LG, | 141 | HFB_PITCH_ADDR_LG, |
@@ -446,7 +446,7 @@ static int __devinit correct_chipset(struct atyfb_par *par) | |||
446 | par->pll_limits.ecp_max = aty_chips[i].ecp_max; | 446 | par->pll_limits.ecp_max = aty_chips[i].ecp_max; |
447 | par->features = aty_chips[i].features; | 447 | par->features = aty_chips[i].features; |
448 | 448 | ||
449 | chip_id = aty_ld_le32(CONFIG_CHIP_ID, par); | 449 | chip_id = aty_ld_le32(CNFG_CHIP_ID, par); |
450 | type = chip_id & CFG_CHIP_TYPE; | 450 | type = chip_id & CFG_CHIP_TYPE; |
451 | rev = (chip_id & CFG_CHIP_REV) >> 24; | 451 | rev = (chip_id & CFG_CHIP_REV) >> 24; |
452 | 452 | ||
@@ -629,7 +629,7 @@ static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc) | |||
629 | crtc->lcd_index = aty_ld_le32(LCD_INDEX, par); | 629 | crtc->lcd_index = aty_ld_le32(LCD_INDEX, par); |
630 | aty_st_le32(LCD_INDEX, crtc->lcd_index, par); | 630 | aty_st_le32(LCD_INDEX, crtc->lcd_index, par); |
631 | } | 631 | } |
632 | crtc->lcd_config_panel = aty_ld_lcd(CONFIG_PANEL, par); | 632 | crtc->lcd_config_panel = aty_ld_lcd(CNFG_PANEL, par); |
633 | crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par); | 633 | crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par); |
634 | 634 | ||
635 | 635 | ||
@@ -676,7 +676,7 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc) | |||
676 | aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl & ~(CRTC_EXT_DISP_EN | CRTC_EN), par); | 676 | aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl & ~(CRTC_EXT_DISP_EN | CRTC_EN), par); |
677 | 677 | ||
678 | /* update non-shadow registers first */ | 678 | /* update non-shadow registers first */ |
679 | aty_st_lcd(CONFIG_PANEL, crtc->lcd_config_panel, par); | 679 | aty_st_lcd(CNFG_PANEL, crtc->lcd_config_panel, par); |
680 | aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl & | 680 | aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl & |
681 | ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par); | 681 | ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par); |
682 | 682 | ||
@@ -858,7 +858,7 @@ static int aty_var_to_crtc(const struct fb_info *info, | |||
858 | if (!M64_HAS(MOBIL_BUS)) | 858 | if (!M64_HAS(MOBIL_BUS)) |
859 | crtc->lcd_index |= CRTC2_DISPLAY_DIS; | 859 | crtc->lcd_index |= CRTC2_DISPLAY_DIS; |
860 | 860 | ||
861 | crtc->lcd_config_panel = aty_ld_lcd(CONFIG_PANEL, par) | 0x4000; | 861 | crtc->lcd_config_panel = aty_ld_lcd(CNFG_PANEL, par) | 0x4000; |
862 | crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par) & ~CRTC_RW_SELECT; | 862 | crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par) & ~CRTC_RW_SELECT; |
863 | 863 | ||
864 | crtc->lcd_gen_cntl &= | 864 | crtc->lcd_gen_cntl &= |
@@ -1978,7 +1978,7 @@ static int aty_power_mgmt(int sleep, struct atyfb_par *par) | |||
1978 | 1978 | ||
1979 | return timeout ? 0 : -EIO; | 1979 | return timeout ? 0 : -EIO; |
1980 | } | 1980 | } |
1981 | #endif | 1981 | #endif /* CONFIG_PPC_PMAC */ |
1982 | 1982 | ||
1983 | static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) | 1983 | static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) |
1984 | { | 1984 | { |
@@ -2002,9 +2002,15 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2002 | par->asleep = 1; | 2002 | par->asleep = 1; |
2003 | par->lock_blank = 1; | 2003 | par->lock_blank = 1; |
2004 | 2004 | ||
2005 | /* Because we may change PCI D state ourselves, we need to | ||
2006 | * first save the config space content so the core can | ||
2007 | * restore it properly on resume. | ||
2008 | */ | ||
2009 | pci_save_state(pdev); | ||
2010 | |||
2005 | #ifdef CONFIG_PPC_PMAC | 2011 | #ifdef CONFIG_PPC_PMAC |
2006 | /* Set chip to "suspend" mode */ | 2012 | /* Set chip to "suspend" mode */ |
2007 | if (aty_power_mgmt(1, par)) { | 2013 | if (machine_is(powermac) && aty_power_mgmt(1, par)) { |
2008 | par->asleep = 0; | 2014 | par->asleep = 0; |
2009 | par->lock_blank = 0; | 2015 | par->lock_blank = 0; |
2010 | atyfb_blank(FB_BLANK_UNBLANK, info); | 2016 | atyfb_blank(FB_BLANK_UNBLANK, info); |
@@ -2047,11 +2053,15 @@ static int atyfb_pci_resume(struct pci_dev *pdev) | |||
2047 | 2053 | ||
2048 | acquire_console_sem(); | 2054 | acquire_console_sem(); |
2049 | 2055 | ||
2056 | /* PCI state will have been restored by the core, so | ||
2057 | * we should be in D0 now with our config space fully | ||
2058 | * restored | ||
2059 | */ | ||
2060 | |||
2050 | #ifdef CONFIG_PPC_PMAC | 2061 | #ifdef CONFIG_PPC_PMAC |
2051 | if (pdev->dev.power.power_state.event == 2) | 2062 | if (machine_is(powermac) && |
2063 | pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) | ||
2052 | aty_power_mgmt(0, par); | 2064 | aty_power_mgmt(0, par); |
2053 | #else | ||
2054 | pci_set_power_state(pdev, PCI_D0); | ||
2055 | #endif | 2065 | #endif |
2056 | 2066 | ||
2057 | aty_resume_chip(info); | 2067 | aty_resume_chip(info); |
@@ -2254,7 +2264,7 @@ static int __devinit aty_init(struct fb_info *info) | |||
2254 | if (!M64_HAS(INTEGRATED)) { | 2264 | if (!M64_HAS(INTEGRATED)) { |
2255 | u32 stat0; | 2265 | u32 stat0; |
2256 | u8 dac_type, dac_subtype, clk_type; | 2266 | u8 dac_type, dac_subtype, clk_type; |
2257 | stat0 = aty_ld_le32(CONFIG_STAT0, par); | 2267 | stat0 = aty_ld_le32(CNFG_STAT0, par); |
2258 | par->bus_type = (stat0 >> 0) & 0x07; | 2268 | par->bus_type = (stat0 >> 0) & 0x07; |
2259 | par->ram_type = (stat0 >> 3) & 0x07; | 2269 | par->ram_type = (stat0 >> 3) & 0x07; |
2260 | ramname = aty_gx_ram[par->ram_type]; | 2270 | ramname = aty_gx_ram[par->ram_type]; |
@@ -2324,7 +2334,7 @@ static int __devinit aty_init(struct fb_info *info) | |||
2324 | par->dac_ops = &aty_dac_ct; | 2334 | par->dac_ops = &aty_dac_ct; |
2325 | par->pll_ops = &aty_pll_ct; | 2335 | par->pll_ops = &aty_pll_ct; |
2326 | par->bus_type = PCI; | 2336 | par->bus_type = PCI; |
2327 | par->ram_type = (aty_ld_le32(CONFIG_STAT0, par) & 0x07); | 2337 | par->ram_type = (aty_ld_le32(CNFG_STAT0, par) & 0x07); |
2328 | ramname = aty_ct_ram[par->ram_type]; | 2338 | ramname = aty_ct_ram[par->ram_type]; |
2329 | /* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz otherwise */ | 2339 | /* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz otherwise */ |
2330 | if (par->pll_limits.mclk == 67 && par->ram_type < SDRAM) | 2340 | if (par->pll_limits.mclk == 67 && par->ram_type < SDRAM) |
@@ -2433,7 +2443,7 @@ static int __devinit aty_init(struct fb_info *info) | |||
2433 | } | 2443 | } |
2434 | 2444 | ||
2435 | if (M64_HAS(MAGIC_VRAM_SIZE)) { | 2445 | if (M64_HAS(MAGIC_VRAM_SIZE)) { |
2436 | if (aty_ld_le32(CONFIG_STAT1, par) & 0x40000000) | 2446 | if (aty_ld_le32(CNFG_STAT1, par) & 0x40000000) |
2437 | info->fix.smem_len += 0x400000; | 2447 | info->fix.smem_len += 0x400000; |
2438 | } | 2448 | } |
2439 | 2449 | ||
@@ -2946,7 +2956,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, | |||
2946 | * Fix PROMs idea of MEM_CNTL settings... | 2956 | * Fix PROMs idea of MEM_CNTL settings... |
2947 | */ | 2957 | */ |
2948 | mem = aty_ld_le32(MEM_CNTL, par); | 2958 | mem = aty_ld_le32(MEM_CNTL, par); |
2949 | chip_id = aty_ld_le32(CONFIG_CHIP_ID, par); | 2959 | chip_id = aty_ld_le32(CNFG_CHIP_ID, par); |
2950 | if (((chip_id & CFG_CHIP_TYPE) == VT_CHIP_ID) && !((chip_id >> 24) & 1)) { | 2960 | if (((chip_id & CFG_CHIP_TYPE) == VT_CHIP_ID) && !((chip_id >> 24) & 1)) { |
2951 | switch (mem & 0x0f) { | 2961 | switch (mem & 0x0f) { |
2952 | case 3: | 2962 | case 3: |
@@ -2964,7 +2974,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, | |||
2964 | default: | 2974 | default: |
2965 | break; | 2975 | break; |
2966 | } | 2976 | } |
2967 | if ((aty_ld_le32(CONFIG_STAT0, par) & 7) >= SDRAM) | 2977 | if ((aty_ld_le32(CNFG_STAT0, par) & 7) >= SDRAM) |
2968 | mem &= ~(0x00700000); | 2978 | mem &= ~(0x00700000); |
2969 | } | 2979 | } |
2970 | mem &= ~(0xcf80e000); /* Turn off all undocumented bits. */ | 2980 | mem &= ~(0xcf80e000); /* Turn off all undocumented bits. */ |
@@ -3572,7 +3582,7 @@ static int __init atyfb_atari_probe(void) | |||
3572 | } | 3582 | } |
3573 | 3583 | ||
3574 | /* Fake pci_id for correct_chipset() */ | 3584 | /* Fake pci_id for correct_chipset() */ |
3575 | switch (aty_ld_le32(CONFIG_CHIP_ID, par) & CFG_CHIP_TYPE) { | 3585 | switch (aty_ld_le32(CNFG_CHIP_ID, par) & CFG_CHIP_TYPE) { |
3576 | case 0x00d7: | 3586 | case 0x00d7: |
3577 | par->pci_id = PCI_CHIP_MACH64GX; | 3587 | par->pci_id = PCI_CHIP_MACH64GX; |
3578 | break; | 3588 | break; |
diff --git a/drivers/video/aty/mach64_ct.c b/drivers/video/aty/mach64_ct.c index c50c7cf26fe9..2745b8539485 100644 --- a/drivers/video/aty/mach64_ct.c +++ b/drivers/video/aty/mach64_ct.c | |||
@@ -8,6 +8,9 @@ | |||
8 | #include <asm/io.h> | 8 | #include <asm/io.h> |
9 | #include <video/mach64.h> | 9 | #include <video/mach64.h> |
10 | #include "atyfb.h" | 10 | #include "atyfb.h" |
11 | #ifdef CONFIG_PPC | ||
12 | #include <asm/machdep.h> | ||
13 | #endif | ||
11 | 14 | ||
12 | #undef DEBUG | 15 | #undef DEBUG |
13 | 16 | ||
@@ -536,6 +539,14 @@ static int __devinit aty_init_pll_ct(const struct fb_info *info, | |||
536 | pll->ct.xclk_post_div_real = postdividers[xpost_div]; | 539 | pll->ct.xclk_post_div_real = postdividers[xpost_div]; |
537 | pll->ct.mclk_fb_div = q * pll->ct.xclk_post_div_real / 8; | 540 | pll->ct.mclk_fb_div = q * pll->ct.xclk_post_div_real / 8; |
538 | 541 | ||
542 | #ifdef CONFIG_PPC | ||
543 | if (machine_is(powermac)) { | ||
544 | /* Override PLL_EXT_CNTL & 0x07. */ | ||
545 | pll->ct.xclk_post_div = xpost_div; | ||
546 | pll->ct.xclk_ref_div = 1; | ||
547 | } | ||
548 | #endif | ||
549 | |||
539 | #ifdef DEBUG | 550 | #ifdef DEBUG |
540 | pllmclk = (1000000 * pll->ct.mclk_fb_mult * pll->ct.mclk_fb_div) / | 551 | pllmclk = (1000000 * pll->ct.mclk_fb_mult * pll->ct.mclk_fb_div) / |
541 | (par->ref_clk_per * pll->ct.pll_ref_div); | 552 | (par->ref_clk_per * pll->ct.pll_ref_div); |
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index d0f1a7fc2c9d..16bb7e3c0310 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c | |||
@@ -1936,8 +1936,8 @@ static void fixup_memory_mappings(struct radeonfb_info *rinfo) | |||
1936 | OUTREG(CRTC_GEN_CNTL, save_crtc_gen_cntl | CRTC_DISP_REQ_EN_B); | 1936 | OUTREG(CRTC_GEN_CNTL, save_crtc_gen_cntl | CRTC_DISP_REQ_EN_B); |
1937 | mdelay(100); | 1937 | mdelay(100); |
1938 | 1938 | ||
1939 | aper_base = INREG(CONFIG_APER_0_BASE); | 1939 | aper_base = INREG(CNFG_APER_0_BASE); |
1940 | aper_size = INREG(CONFIG_APER_SIZE); | 1940 | aper_size = INREG(CNFG_APER_SIZE); |
1941 | 1941 | ||
1942 | #ifdef SET_MC_FB_FROM_APERTURE | 1942 | #ifdef SET_MC_FB_FROM_APERTURE |
1943 | /* Set framebuffer to be at the same address as set in PCI BAR */ | 1943 | /* Set framebuffer to be at the same address as set in PCI BAR */ |
@@ -2024,11 +2024,11 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo) | |||
2024 | ~CRTC_H_CUTOFF_ACTIVE_EN); | 2024 | ~CRTC_H_CUTOFF_ACTIVE_EN); |
2025 | } | 2025 | } |
2026 | } else { | 2026 | } else { |
2027 | tmp = INREG(CONFIG_MEMSIZE); | 2027 | tmp = INREG(CNFG_MEMSIZE); |
2028 | } | 2028 | } |
2029 | 2029 | ||
2030 | /* mem size is bits [28:0], mask off the rest */ | 2030 | /* mem size is bits [28:0], mask off the rest */ |
2031 | rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK; | 2031 | rinfo->video_ram = tmp & CNFG_MEMSIZE_MASK; |
2032 | 2032 | ||
2033 | /* | 2033 | /* |
2034 | * Hack to get around some busted production M6's | 2034 | * Hack to get around some busted production M6's |
@@ -2228,7 +2228,7 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev, | |||
2228 | */ | 2228 | */ |
2229 | rinfo->errata = 0; | 2229 | rinfo->errata = 0; |
2230 | if (rinfo->family == CHIP_FAMILY_R300 && | 2230 | if (rinfo->family == CHIP_FAMILY_R300 && |
2231 | (INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) | 2231 | (INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) |
2232 | == CFG_ATI_REV_A11) | 2232 | == CFG_ATI_REV_A11) |
2233 | rinfo->errata |= CHIP_ERRATA_R300_CG; | 2233 | rinfo->errata |= CHIP_ERRATA_R300_CG; |
2234 | 2234 | ||
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c index 675abdafc2d8..ca5f0dc28546 100644 --- a/drivers/video/aty/radeon_pm.c +++ b/drivers/video/aty/radeon_pm.c | |||
@@ -333,7 +333,7 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo) | |||
333 | if (!rinfo->has_CRTC2) { | 333 | if (!rinfo->has_CRTC2) { |
334 | tmp = INPLL(pllSCLK_CNTL); | 334 | tmp = INPLL(pllSCLK_CNTL); |
335 | 335 | ||
336 | if ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) > CFG_ATI_REV_A13) | 336 | if ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) > CFG_ATI_REV_A13) |
337 | tmp &= ~(SCLK_CNTL__FORCE_CP | SCLK_CNTL__FORCE_RB); | 337 | tmp &= ~(SCLK_CNTL__FORCE_CP | SCLK_CNTL__FORCE_RB); |
338 | tmp &= ~(SCLK_CNTL__FORCE_HDP | SCLK_CNTL__FORCE_DISP1 | | 338 | tmp &= ~(SCLK_CNTL__FORCE_HDP | SCLK_CNTL__FORCE_DISP1 | |
339 | SCLK_CNTL__FORCE_TOP | SCLK_CNTL__FORCE_SE | | 339 | SCLK_CNTL__FORCE_TOP | SCLK_CNTL__FORCE_SE | |
@@ -468,9 +468,9 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo) | |||
468 | 468 | ||
469 | /*RAGE_6::A11 A12 A12N1 A13, RV250::A11 A12, R300*/ | 469 | /*RAGE_6::A11 A12 A12N1 A13, RV250::A11 A12, R300*/ |
470 | if ((rinfo->family == CHIP_FAMILY_RV250 && | 470 | if ((rinfo->family == CHIP_FAMILY_RV250 && |
471 | ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) || | 471 | ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) || |
472 | ((rinfo->family == CHIP_FAMILY_RV100) && | 472 | ((rinfo->family == CHIP_FAMILY_RV100) && |
473 | ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) <= CFG_ATI_REV_A13))) { | 473 | ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) <= CFG_ATI_REV_A13))) { |
474 | tmp |= SCLK_CNTL__FORCE_CP; | 474 | tmp |= SCLK_CNTL__FORCE_CP; |
475 | tmp |= SCLK_CNTL__FORCE_VIP; | 475 | tmp |= SCLK_CNTL__FORCE_VIP; |
476 | } | 476 | } |
@@ -486,7 +486,7 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo) | |||
486 | /* RV200::A11 A12 RV250::A11 A12 */ | 486 | /* RV200::A11 A12 RV250::A11 A12 */ |
487 | if (((rinfo->family == CHIP_FAMILY_RV200) || | 487 | if (((rinfo->family == CHIP_FAMILY_RV200) || |
488 | (rinfo->family == CHIP_FAMILY_RV250)) && | 488 | (rinfo->family == CHIP_FAMILY_RV250)) && |
489 | ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) | 489 | ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) |
490 | tmp |= SCLK_MORE_CNTL__FORCEON; | 490 | tmp |= SCLK_MORE_CNTL__FORCEON; |
491 | 491 | ||
492 | OUTPLL(pllSCLK_MORE_CNTL, tmp); | 492 | OUTPLL(pllSCLK_MORE_CNTL, tmp); |
@@ -497,7 +497,7 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo) | |||
497 | /* RV200::A11 A12, RV250::A11 A12 */ | 497 | /* RV200::A11 A12, RV250::A11 A12 */ |
498 | if (((rinfo->family == CHIP_FAMILY_RV200) || | 498 | if (((rinfo->family == CHIP_FAMILY_RV200) || |
499 | (rinfo->family == CHIP_FAMILY_RV250)) && | 499 | (rinfo->family == CHIP_FAMILY_RV250)) && |
500 | ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) { | 500 | ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) { |
501 | tmp = INPLL(pllPLL_PWRMGT_CNTL); | 501 | tmp = INPLL(pllPLL_PWRMGT_CNTL); |
502 | tmp |= PLL_PWRMGT_CNTL__TCL_BYPASS_DISABLE; | 502 | tmp |= PLL_PWRMGT_CNTL__TCL_BYPASS_DISABLE; |
503 | OUTPLL(pllPLL_PWRMGT_CNTL, tmp); | 503 | OUTPLL(pllPLL_PWRMGT_CNTL, tmp); |
@@ -702,7 +702,7 @@ static void radeon_pm_restore_regs(struct radeonfb_info *rinfo) | |||
702 | OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]); | 702 | OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]); |
703 | OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]); | 703 | OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]); |
704 | OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]); | 704 | OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]); |
705 | OUTREG(CONFIG_MEMSIZE, rinfo->video_ram); | 705 | OUTREG(CNFG_MEMSIZE, rinfo->video_ram); |
706 | 706 | ||
707 | OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]); | 707 | OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]); |
708 | OUTREG(DISP_PWR_MAN, rinfo->save_regs[10]); | 708 | OUTREG(DISP_PWR_MAN, rinfo->save_regs[10]); |
@@ -1723,7 +1723,7 @@ static void radeon_reinitialize_M10(struct radeonfb_info *rinfo) | |||
1723 | OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]); | 1723 | OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]); |
1724 | OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]); | 1724 | OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]); |
1725 | OUTREG(OV0_BASE_ADDR, rinfo->save_regs[80]); | 1725 | OUTREG(OV0_BASE_ADDR, rinfo->save_regs[80]); |
1726 | OUTREG(CONFIG_MEMSIZE, rinfo->video_ram); | 1726 | OUTREG(CNFG_MEMSIZE, rinfo->video_ram); |
1727 | OUTREG(BUS_CNTL, rinfo->save_regs[36]); | 1727 | OUTREG(BUS_CNTL, rinfo->save_regs[36]); |
1728 | OUTREG(BUS_CNTL1, rinfo->save_regs[14]); | 1728 | OUTREG(BUS_CNTL1, rinfo->save_regs[14]); |
1729 | OUTREG(MPP_TB_CONFIG, rinfo->save_regs[37]); | 1729 | OUTREG(MPP_TB_CONFIG, rinfo->save_regs[37]); |
@@ -1961,7 +1961,7 @@ static void radeon_pm_m9p_reconfigure_mc(struct radeonfb_info *rinfo) | |||
1961 | OUTMC(rinfo, ixMC_CHP_IO_CNTL_B1, rinfo->save_regs[68] /*0x141555ff*/); | 1961 | OUTMC(rinfo, ixMC_CHP_IO_CNTL_B1, rinfo->save_regs[68] /*0x141555ff*/); |
1962 | OUTMC(rinfo, ixMC_IMP_CNTL_0, rinfo->save_regs[71] /*0x00009249*/); | 1962 | OUTMC(rinfo, ixMC_IMP_CNTL_0, rinfo->save_regs[71] /*0x00009249*/); |
1963 | OUTREG(MC_IND_INDEX, 0); | 1963 | OUTREG(MC_IND_INDEX, 0); |
1964 | OUTREG(CONFIG_MEMSIZE, rinfo->video_ram); | 1964 | OUTREG(CNFG_MEMSIZE, rinfo->video_ram); |
1965 | 1965 | ||
1966 | mdelay(20); | 1966 | mdelay(20); |
1967 | } | 1967 | } |
@@ -2361,7 +2361,7 @@ static void radeon_reinitialize_QW(struct radeonfb_info *rinfo) | |||
2361 | OUTMC(rinfo, ixMC_IMP_CNTL_0, 0x00009249); | 2361 | OUTMC(rinfo, ixMC_IMP_CNTL_0, 0x00009249); |
2362 | OUTREG(MC_IND_INDEX, 0); | 2362 | OUTREG(MC_IND_INDEX, 0); |
2363 | 2363 | ||
2364 | OUTREG(CONFIG_MEMSIZE, rinfo->video_ram); | 2364 | OUTREG(CNFG_MEMSIZE, rinfo->video_ram); |
2365 | 2365 | ||
2366 | radeon_pm_full_reset_sdram(rinfo); | 2366 | radeon_pm_full_reset_sdram(rinfo); |
2367 | 2367 | ||
@@ -2509,9 +2509,7 @@ static void radeon_reinitialize_QW(struct radeonfb_info *rinfo) | |||
2509 | 2509 | ||
2510 | static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend) | 2510 | static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend) |
2511 | { | 2511 | { |
2512 | u16 pwr_cmd; | ||
2513 | u32 tmp; | 2512 | u32 tmp; |
2514 | int i; | ||
2515 | 2513 | ||
2516 | if (!rinfo->pm_reg) | 2514 | if (!rinfo->pm_reg) |
2517 | return; | 2515 | return; |
@@ -2557,32 +2555,14 @@ static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend) | |||
2557 | } | 2555 | } |
2558 | } | 2556 | } |
2559 | 2557 | ||
2560 | for (i = 0; i < 64; ++i) | ||
2561 | pci_read_config_dword(rinfo->pdev, i * 4, | ||
2562 | &rinfo->cfg_save[i]); | ||
2563 | |||
2564 | /* Switch PCI power management to D2. */ | 2558 | /* Switch PCI power management to D2. */ |
2565 | pci_disable_device(rinfo->pdev); | 2559 | pci_disable_device(rinfo->pdev); |
2566 | for (;;) { | 2560 | pci_save_state(rinfo->pdev); |
2567 | pci_read_config_word( | 2561 | pci_set_power_state(rinfo->pdev, PCI_D2); |
2568 | rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, | ||
2569 | &pwr_cmd); | ||
2570 | if (pwr_cmd & 2) | ||
2571 | break; | ||
2572 | pci_write_config_word( | ||
2573 | rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, | ||
2574 | (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | 2); | ||
2575 | mdelay(500); | ||
2576 | } | ||
2577 | } else { | 2562 | } else { |
2578 | printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n", | 2563 | printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n", |
2579 | pci_name(rinfo->pdev)); | 2564 | pci_name(rinfo->pdev)); |
2580 | 2565 | ||
2581 | /* Switch back PCI powermanagment to D0 */ | ||
2582 | mdelay(200); | ||
2583 | pci_write_config_word(rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, 0); | ||
2584 | mdelay(500); | ||
2585 | |||
2586 | if (rinfo->family <= CHIP_FAMILY_RV250) { | 2566 | if (rinfo->family <= CHIP_FAMILY_RV250) { |
2587 | /* Reset the SDRAM controller */ | 2567 | /* Reset the SDRAM controller */ |
2588 | radeon_pm_full_reset_sdram(rinfo); | 2568 | radeon_pm_full_reset_sdram(rinfo); |
@@ -2598,37 +2578,10 @@ static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend) | |||
2598 | } | 2578 | } |
2599 | } | 2579 | } |
2600 | 2580 | ||
2601 | static int radeon_restore_pci_cfg(struct radeonfb_info *rinfo) | ||
2602 | { | ||
2603 | int i; | ||
2604 | static u32 radeon_cfg_after_resume[64]; | ||
2605 | |||
2606 | for (i = 0; i < 64; ++i) | ||
2607 | pci_read_config_dword(rinfo->pdev, i * 4, | ||
2608 | &radeon_cfg_after_resume[i]); | ||
2609 | |||
2610 | if (radeon_cfg_after_resume[PCI_BASE_ADDRESS_0/4] | ||
2611 | == rinfo->cfg_save[PCI_BASE_ADDRESS_0/4]) | ||
2612 | return 0; /* assume everything is ok */ | ||
2613 | |||
2614 | for (i = PCI_BASE_ADDRESS_0/4; i < 64; ++i) { | ||
2615 | if (radeon_cfg_after_resume[i] != rinfo->cfg_save[i]) | ||
2616 | pci_write_config_dword(rinfo->pdev, i * 4, | ||
2617 | rinfo->cfg_save[i]); | ||
2618 | } | ||
2619 | pci_write_config_word(rinfo->pdev, PCI_CACHE_LINE_SIZE, | ||
2620 | rinfo->cfg_save[PCI_CACHE_LINE_SIZE/4]); | ||
2621 | pci_write_config_word(rinfo->pdev, PCI_COMMAND, | ||
2622 | rinfo->cfg_save[PCI_COMMAND/4]); | ||
2623 | return 1; | ||
2624 | } | ||
2625 | |||
2626 | |||
2627 | int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) | 2581 | int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) |
2628 | { | 2582 | { |
2629 | struct fb_info *info = pci_get_drvdata(pdev); | 2583 | struct fb_info *info = pci_get_drvdata(pdev); |
2630 | struct radeonfb_info *rinfo = info->par; | 2584 | struct radeonfb_info *rinfo = info->par; |
2631 | int i; | ||
2632 | 2585 | ||
2633 | if (mesg.event == pdev->dev.power.power_state.event) | 2586 | if (mesg.event == pdev->dev.power.power_state.event) |
2634 | return 0; | 2587 | return 0; |
@@ -2674,6 +2627,11 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
2674 | pmac_suspend_agp_for_card(pdev); | 2627 | pmac_suspend_agp_for_card(pdev); |
2675 | #endif /* CONFIG_PPC_PMAC */ | 2628 | #endif /* CONFIG_PPC_PMAC */ |
2676 | 2629 | ||
2630 | /* It's unclear whether or when the generic code will do that, so let's | ||
2631 | * do it ourselves. We save state before we do any power management | ||
2632 | */ | ||
2633 | pci_save_state(pdev); | ||
2634 | |||
2677 | /* If we support wakeup from poweroff, we save all regs we can including cfg | 2635 | /* If we support wakeup from poweroff, we save all regs we can including cfg |
2678 | * space | 2636 | * space |
2679 | */ | 2637 | */ |
@@ -2698,9 +2656,6 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
2698 | mdelay(20); | 2656 | mdelay(20); |
2699 | OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_DIGON)); | 2657 | OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_DIGON)); |
2700 | } | 2658 | } |
2701 | // FIXME: Use PCI layer | ||
2702 | for (i = 0; i < 64; ++i) | ||
2703 | pci_read_config_dword(pdev, i * 4, &rinfo->cfg_save[i]); | ||
2704 | pci_disable_device(pdev); | 2659 | pci_disable_device(pdev); |
2705 | } | 2660 | } |
2706 | /* If we support D2, we go to it (should be fixed later with a flag forcing | 2661 | /* If we support D2, we go to it (should be fixed later with a flag forcing |
@@ -2717,6 +2672,13 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) | |||
2717 | return 0; | 2672 | return 0; |
2718 | } | 2673 | } |
2719 | 2674 | ||
2675 | static int radeon_check_power_loss(struct radeonfb_info *rinfo) | ||
2676 | { | ||
2677 | return rinfo->save_regs[4] != INPLL(CLK_PIN_CNTL) || | ||
2678 | rinfo->save_regs[2] != INPLL(MCLK_CNTL) || | ||
2679 | rinfo->save_regs[3] != INPLL(SCLK_CNTL); | ||
2680 | } | ||
2681 | |||
2720 | int radeonfb_pci_resume(struct pci_dev *pdev) | 2682 | int radeonfb_pci_resume(struct pci_dev *pdev) |
2721 | { | 2683 | { |
2722 | struct fb_info *info = pci_get_drvdata(pdev); | 2684 | struct fb_info *info = pci_get_drvdata(pdev); |
@@ -2735,20 +2697,13 @@ int radeonfb_pci_resume(struct pci_dev *pdev) | |||
2735 | printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n", | 2697 | printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n", |
2736 | pci_name(pdev), pdev->dev.power.power_state.event); | 2698 | pci_name(pdev), pdev->dev.power.power_state.event); |
2737 | 2699 | ||
2738 | 2700 | /* PCI state will have been restored by the core, so | |
2739 | if (pci_enable_device(pdev)) { | 2701 | * we should be in D0 now with our config space fully |
2740 | rc = -ENODEV; | 2702 | * restored |
2741 | printk(KERN_ERR "radeonfb (%s): can't enable PCI device !\n", | 2703 | */ |
2742 | pci_name(pdev)); | ||
2743 | goto bail; | ||
2744 | } | ||
2745 | pci_set_master(pdev); | ||
2746 | |||
2747 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { | 2704 | if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { |
2748 | /* Wakeup chip. Check from config space if we were powered off | 2705 | /* Wakeup chip */ |
2749 | * (todo: additionally, check CLK_PIN_CNTL too) | 2706 | if ((rinfo->pm_mode & radeon_pm_off) && radeon_check_power_loss(rinfo)) { |
2750 | */ | ||
2751 | if ((rinfo->pm_mode & radeon_pm_off) && radeon_restore_pci_cfg(rinfo)) { | ||
2752 | if (rinfo->reinit_func != NULL) | 2707 | if (rinfo->reinit_func != NULL) |
2753 | rinfo->reinit_func(rinfo); | 2708 | rinfo->reinit_func(rinfo); |
2754 | else { | 2709 | else { |
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h index 3ea1b00fdd22..7351e66c7f54 100644 --- a/drivers/video/aty/radeonfb.h +++ b/drivers/video/aty/radeonfb.h | |||
@@ -361,8 +361,6 @@ struct radeonfb_info { | |||
361 | #ifdef CONFIG_FB_RADEON_I2C | 361 | #ifdef CONFIG_FB_RADEON_I2C |
362 | struct radeon_i2c_chan i2c[4]; | 362 | struct radeon_i2c_chan i2c[4]; |
363 | #endif | 363 | #endif |
364 | |||
365 | u32 cfg_save[64]; | ||
366 | }; | 364 | }; |
367 | 365 | ||
368 | 366 | ||
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 363b3cb2f01b..63d759498165 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -18,7 +18,7 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o | |||
18 | obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o | 18 | obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o |
19 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o | 19 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o |
20 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o | 20 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o |
21 | obj-$(CONFIG_BACKLIGHT_DA903X) += da903x.o | 21 | obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o |
22 | obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o | 22 | obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o |
23 | obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o | 23 | obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o |
24 | obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o | 24 | obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o |
diff --git a/drivers/video/backlight/da903x.c b/drivers/video/backlight/da903x_bl.c index 93bb4340cc64..93bb4340cc64 100644 --- a/drivers/video/backlight/da903x.c +++ b/drivers/video/backlight/da903x_bl.c | |||
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c index 91b78e691505..f53b9f1d6aba 100644 --- a/drivers/video/fbcmap.c +++ b/drivers/video/fbcmap.c | |||
@@ -250,10 +250,6 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info) | |||
250 | int rc, size = cmap->len * sizeof(u16); | 250 | int rc, size = cmap->len * sizeof(u16); |
251 | struct fb_cmap umap; | 251 | struct fb_cmap umap; |
252 | 252 | ||
253 | if (cmap->start < 0 || (!info->fbops->fb_setcolreg && | ||
254 | !info->fbops->fb_setcmap)) | ||
255 | return -EINVAL; | ||
256 | |||
257 | memset(&umap, 0, sizeof(struct fb_cmap)); | 253 | memset(&umap, 0, sizeof(struct fb_cmap)); |
258 | rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL); | 254 | rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL); |
259 | if (rc) | 255 | if (rc) |
@@ -262,11 +258,23 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info) | |||
262 | copy_from_user(umap.green, cmap->green, size) || | 258 | copy_from_user(umap.green, cmap->green, size) || |
263 | copy_from_user(umap.blue, cmap->blue, size) || | 259 | copy_from_user(umap.blue, cmap->blue, size) || |
264 | (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) { | 260 | (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) { |
265 | fb_dealloc_cmap(&umap); | 261 | rc = -EFAULT; |
266 | return -EFAULT; | 262 | goto out; |
267 | } | 263 | } |
268 | umap.start = cmap->start; | 264 | umap.start = cmap->start; |
265 | if (!lock_fb_info(info)) { | ||
266 | rc = -ENODEV; | ||
267 | goto out; | ||
268 | } | ||
269 | if (cmap->start < 0 || (!info->fbops->fb_setcolreg && | ||
270 | !info->fbops->fb_setcmap)) { | ||
271 | rc = -EINVAL; | ||
272 | goto out1; | ||
273 | } | ||
269 | rc = fb_set_cmap(&umap, info); | 274 | rc = fb_set_cmap(&umap, info); |
275 | out1: | ||
276 | unlock_fb_info(info); | ||
277 | out: | ||
270 | fb_dealloc_cmap(&umap); | 278 | fb_dealloc_cmap(&umap); |
271 | return rc; | 279 | return rc; |
272 | } | 280 | } |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 756efeb91abc..cfd9dce1ce0b 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -1013,132 +1013,139 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, | |||
1013 | struct fb_var_screeninfo var; | 1013 | struct fb_var_screeninfo var; |
1014 | struct fb_fix_screeninfo fix; | 1014 | struct fb_fix_screeninfo fix; |
1015 | struct fb_con2fbmap con2fb; | 1015 | struct fb_con2fbmap con2fb; |
1016 | struct fb_cmap cmap_from; | ||
1016 | struct fb_cmap_user cmap; | 1017 | struct fb_cmap_user cmap; |
1017 | struct fb_event event; | 1018 | struct fb_event event; |
1018 | void __user *argp = (void __user *)arg; | 1019 | void __user *argp = (void __user *)arg; |
1019 | long ret = 0; | 1020 | long ret = 0; |
1020 | 1021 | ||
1021 | fb = info->fbops; | ||
1022 | if (!fb) | ||
1023 | return -ENODEV; | ||
1024 | |||
1025 | switch (cmd) { | 1022 | switch (cmd) { |
1026 | case FBIOGET_VSCREENINFO: | 1023 | case FBIOGET_VSCREENINFO: |
1027 | ret = copy_to_user(argp, &info->var, | 1024 | if (!lock_fb_info(info)) |
1028 | sizeof(var)) ? -EFAULT : 0; | 1025 | return -ENODEV; |
1026 | var = info->var; | ||
1027 | unlock_fb_info(info); | ||
1028 | |||
1029 | ret = copy_to_user(argp, &var, sizeof(var)) ? -EFAULT : 0; | ||
1029 | break; | 1030 | break; |
1030 | case FBIOPUT_VSCREENINFO: | 1031 | case FBIOPUT_VSCREENINFO: |
1031 | if (copy_from_user(&var, argp, sizeof(var))) { | 1032 | if (copy_from_user(&var, argp, sizeof(var))) |
1032 | ret = -EFAULT; | 1033 | return -EFAULT; |
1033 | break; | 1034 | if (!lock_fb_info(info)) |
1034 | } | 1035 | return -ENODEV; |
1035 | acquire_console_sem(); | 1036 | acquire_console_sem(); |
1036 | info->flags |= FBINFO_MISC_USEREVENT; | 1037 | info->flags |= FBINFO_MISC_USEREVENT; |
1037 | ret = fb_set_var(info, &var); | 1038 | ret = fb_set_var(info, &var); |
1038 | info->flags &= ~FBINFO_MISC_USEREVENT; | 1039 | info->flags &= ~FBINFO_MISC_USEREVENT; |
1039 | release_console_sem(); | 1040 | release_console_sem(); |
1040 | if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) | 1041 | unlock_fb_info(info); |
1042 | if (!ret && copy_to_user(argp, &var, sizeof(var))) | ||
1041 | ret = -EFAULT; | 1043 | ret = -EFAULT; |
1042 | break; | 1044 | break; |
1043 | case FBIOGET_FSCREENINFO: | 1045 | case FBIOGET_FSCREENINFO: |
1044 | ret = copy_to_user(argp, &info->fix, | 1046 | if (!lock_fb_info(info)) |
1045 | sizeof(fix)) ? -EFAULT : 0; | 1047 | return -ENODEV; |
1048 | fix = info->fix; | ||
1049 | unlock_fb_info(info); | ||
1050 | |||
1051 | ret = copy_to_user(argp, &fix, sizeof(fix)) ? -EFAULT : 0; | ||
1046 | break; | 1052 | break; |
1047 | case FBIOPUTCMAP: | 1053 | case FBIOPUTCMAP: |
1048 | if (copy_from_user(&cmap, argp, sizeof(cmap))) | 1054 | if (copy_from_user(&cmap, argp, sizeof(cmap))) |
1049 | ret = -EFAULT; | 1055 | return -EFAULT; |
1050 | else | 1056 | ret = fb_set_user_cmap(&cmap, info); |
1051 | ret = fb_set_user_cmap(&cmap, info); | ||
1052 | break; | 1057 | break; |
1053 | case FBIOGETCMAP: | 1058 | case FBIOGETCMAP: |
1054 | if (copy_from_user(&cmap, argp, sizeof(cmap))) | 1059 | if (copy_from_user(&cmap, argp, sizeof(cmap))) |
1055 | ret = -EFAULT; | 1060 | return -EFAULT; |
1056 | else | 1061 | if (!lock_fb_info(info)) |
1057 | ret = fb_cmap_to_user(&info->cmap, &cmap); | 1062 | return -ENODEV; |
1063 | cmap_from = info->cmap; | ||
1064 | unlock_fb_info(info); | ||
1065 | ret = fb_cmap_to_user(&cmap_from, &cmap); | ||
1058 | break; | 1066 | break; |
1059 | case FBIOPAN_DISPLAY: | 1067 | case FBIOPAN_DISPLAY: |
1060 | if (copy_from_user(&var, argp, sizeof(var))) { | 1068 | if (copy_from_user(&var, argp, sizeof(var))) |
1061 | ret = -EFAULT; | 1069 | return -EFAULT; |
1062 | break; | 1070 | if (!lock_fb_info(info)) |
1063 | } | 1071 | return -ENODEV; |
1064 | acquire_console_sem(); | 1072 | acquire_console_sem(); |
1065 | ret = fb_pan_display(info, &var); | 1073 | ret = fb_pan_display(info, &var); |
1066 | release_console_sem(); | 1074 | release_console_sem(); |
1075 | unlock_fb_info(info); | ||
1067 | if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) | 1076 | if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) |
1068 | ret = -EFAULT; | 1077 | return -EFAULT; |
1069 | break; | 1078 | break; |
1070 | case FBIO_CURSOR: | 1079 | case FBIO_CURSOR: |
1071 | ret = -EINVAL; | 1080 | ret = -EINVAL; |
1072 | break; | 1081 | break; |
1073 | case FBIOGET_CON2FBMAP: | 1082 | case FBIOGET_CON2FBMAP: |
1074 | if (copy_from_user(&con2fb, argp, sizeof(con2fb))) | 1083 | if (copy_from_user(&con2fb, argp, sizeof(con2fb))) |
1075 | ret = -EFAULT; | 1084 | return -EFAULT; |
1076 | else if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) | 1085 | if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) |
1077 | ret = -EINVAL; | 1086 | return -EINVAL; |
1078 | else { | 1087 | con2fb.framebuffer = -1; |
1079 | con2fb.framebuffer = -1; | 1088 | event.data = &con2fb; |
1080 | event.info = info; | 1089 | |
1081 | event.data = &con2fb; | 1090 | if (!lock_fb_info(info)) |
1082 | fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, | 1091 | return -ENODEV; |
1083 | &event); | 1092 | event.info = info; |
1084 | ret = copy_to_user(argp, &con2fb, | 1093 | fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event); |
1085 | sizeof(con2fb)) ? -EFAULT : 0; | 1094 | unlock_fb_info(info); |
1086 | } | 1095 | |
1096 | ret = copy_to_user(argp, &con2fb, sizeof(con2fb)) ? -EFAULT : 0; | ||
1087 | break; | 1097 | break; |
1088 | case FBIOPUT_CON2FBMAP: | 1098 | case FBIOPUT_CON2FBMAP: |
1089 | if (copy_from_user(&con2fb, argp, sizeof(con2fb))) { | 1099 | if (copy_from_user(&con2fb, argp, sizeof(con2fb))) |
1090 | ret = -EFAULT; | 1100 | return -EFAULT; |
1091 | break; | 1101 | if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) |
1092 | } | 1102 | return -EINVAL; |
1093 | if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) { | 1103 | if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) |
1094 | ret = -EINVAL; | 1104 | return -EINVAL; |
1095 | break; | ||
1096 | } | ||
1097 | if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) { | ||
1098 | ret = -EINVAL; | ||
1099 | break; | ||
1100 | } | ||
1101 | if (!registered_fb[con2fb.framebuffer]) | 1105 | if (!registered_fb[con2fb.framebuffer]) |
1102 | request_module("fb%d", con2fb.framebuffer); | 1106 | request_module("fb%d", con2fb.framebuffer); |
1103 | if (!registered_fb[con2fb.framebuffer]) { | 1107 | if (!registered_fb[con2fb.framebuffer]) { |
1104 | ret = -EINVAL; | 1108 | ret = -EINVAL; |
1105 | break; | 1109 | break; |
1106 | } | 1110 | } |
1107 | event.info = info; | ||
1108 | event.data = &con2fb; | 1111 | event.data = &con2fb; |
1112 | if (!lock_fb_info(info)) | ||
1113 | return -ENODEV; | ||
1114 | event.info = info; | ||
1109 | ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, | 1115 | ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, |
1110 | &event); | 1116 | &event); |
1117 | unlock_fb_info(info); | ||
1111 | break; | 1118 | break; |
1112 | case FBIOBLANK: | 1119 | case FBIOBLANK: |
1120 | if (!lock_fb_info(info)) | ||
1121 | return -ENODEV; | ||
1113 | acquire_console_sem(); | 1122 | acquire_console_sem(); |
1114 | info->flags |= FBINFO_MISC_USEREVENT; | 1123 | info->flags |= FBINFO_MISC_USEREVENT; |
1115 | ret = fb_blank(info, arg); | 1124 | ret = fb_blank(info, arg); |
1116 | info->flags &= ~FBINFO_MISC_USEREVENT; | 1125 | info->flags &= ~FBINFO_MISC_USEREVENT; |
1117 | release_console_sem(); | 1126 | release_console_sem(); |
1118 | break;; | 1127 | unlock_fb_info(info); |
1128 | break; | ||
1119 | default: | 1129 | default: |
1120 | if (fb->fb_ioctl == NULL) | 1130 | if (!lock_fb_info(info)) |
1121 | ret = -ENOTTY; | 1131 | return -ENODEV; |
1122 | else | 1132 | fb = info->fbops; |
1133 | if (fb->fb_ioctl) | ||
1123 | ret = fb->fb_ioctl(info, cmd, arg); | 1134 | ret = fb->fb_ioctl(info, cmd, arg); |
1135 | else | ||
1136 | ret = -ENOTTY; | ||
1137 | unlock_fb_info(info); | ||
1124 | } | 1138 | } |
1125 | return ret; | 1139 | return ret; |
1126 | } | 1140 | } |
1127 | 1141 | ||
1128 | static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 1142 | static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
1129 | __acquires(&info->lock) | ||
1130 | __releases(&info->lock) | ||
1131 | { | 1143 | { |
1132 | struct inode *inode = file->f_path.dentry->d_inode; | 1144 | struct inode *inode = file->f_path.dentry->d_inode; |
1133 | int fbidx = iminor(inode); | 1145 | int fbidx = iminor(inode); |
1134 | struct fb_info *info; | 1146 | struct fb_info *info = registered_fb[fbidx]; |
1135 | long ret; | ||
1136 | 1147 | ||
1137 | info = registered_fb[fbidx]; | 1148 | return do_fb_ioctl(info, cmd, arg); |
1138 | mutex_lock(&info->lock); | ||
1139 | ret = do_fb_ioctl(info, cmd, arg); | ||
1140 | mutex_unlock(&info->lock); | ||
1141 | return ret; | ||
1142 | } | 1149 | } |
1143 | 1150 | ||
1144 | #ifdef CONFIG_COMPAT | 1151 | #ifdef CONFIG_COMPAT |
@@ -1257,8 +1264,6 @@ static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd, | |||
1257 | 1264 | ||
1258 | static long fb_compat_ioctl(struct file *file, unsigned int cmd, | 1265 | static long fb_compat_ioctl(struct file *file, unsigned int cmd, |
1259 | unsigned long arg) | 1266 | unsigned long arg) |
1260 | __acquires(&info->lock) | ||
1261 | __releases(&info->lock) | ||
1262 | { | 1267 | { |
1263 | struct inode *inode = file->f_path.dentry->d_inode; | 1268 | struct inode *inode = file->f_path.dentry->d_inode; |
1264 | int fbidx = iminor(inode); | 1269 | int fbidx = iminor(inode); |
@@ -1266,7 +1271,6 @@ __releases(&info->lock) | |||
1266 | struct fb_ops *fb = info->fbops; | 1271 | struct fb_ops *fb = info->fbops; |
1267 | long ret = -ENOIOCTLCMD; | 1272 | long ret = -ENOIOCTLCMD; |
1268 | 1273 | ||
1269 | mutex_lock(&info->lock); | ||
1270 | switch(cmd) { | 1274 | switch(cmd) { |
1271 | case FBIOGET_VSCREENINFO: | 1275 | case FBIOGET_VSCREENINFO: |
1272 | case FBIOPUT_VSCREENINFO: | 1276 | case FBIOPUT_VSCREENINFO: |
@@ -1292,7 +1296,6 @@ __releases(&info->lock) | |||
1292 | ret = fb->fb_compat_ioctl(info, cmd, arg); | 1296 | ret = fb->fb_compat_ioctl(info, cmd, arg); |
1293 | break; | 1297 | break; |
1294 | } | 1298 | } |
1295 | mutex_unlock(&info->lock); | ||
1296 | return ret; | 1299 | return ret; |
1297 | } | 1300 | } |
1298 | #endif | 1301 | #endif |
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index bef6b45e8a5c..330aacbdec1f 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -192,7 +192,7 @@ static irqreturn_t vp_interrupt(int irq, void *opaque) | |||
192 | drv = container_of(vp_dev->vdev.dev.driver, | 192 | drv = container_of(vp_dev->vdev.dev.driver, |
193 | struct virtio_driver, driver); | 193 | struct virtio_driver, driver); |
194 | 194 | ||
195 | if (drv->config_changed) | 195 | if (drv && drv->config_changed) |
196 | drv->config_changed(&vp_dev->vdev); | 196 | drv->config_changed(&vp_dev->vdev); |
197 | } | 197 | } |
198 | 198 | ||
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 2ba8f95516a0..efa4b363ce72 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -498,7 +498,7 @@ static ssize_t store_target_kb(struct sys_device *dev, | |||
498 | if (!capable(CAP_SYS_ADMIN)) | 498 | if (!capable(CAP_SYS_ADMIN)) |
499 | return -EPERM; | 499 | return -EPERM; |
500 | 500 | ||
501 | target_bytes = memparse(buf, &endchar); | 501 | target_bytes = simple_strtoull(buf, &endchar, 0) * 1024; |
502 | 502 | ||
503 | balloon_set_new_target(target_bytes >> PAGE_SHIFT); | 503 | balloon_set_new_target(target_bytes >> PAGE_SHIFT); |
504 | 504 | ||
@@ -508,8 +508,39 @@ static ssize_t store_target_kb(struct sys_device *dev, | |||
508 | static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, | 508 | static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, |
509 | show_target_kb, store_target_kb); | 509 | show_target_kb, store_target_kb); |
510 | 510 | ||
511 | |||
512 | static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr, | ||
513 | char *buf) | ||
514 | { | ||
515 | return sprintf(buf, "%llu\n", | ||
516 | (u64)balloon_stats.target_pages << PAGE_SHIFT); | ||
517 | } | ||
518 | |||
519 | static ssize_t store_target(struct sys_device *dev, | ||
520 | struct sysdev_attribute *attr, | ||
521 | const char *buf, | ||
522 | size_t count) | ||
523 | { | ||
524 | char *endchar; | ||
525 | unsigned long long target_bytes; | ||
526 | |||
527 | if (!capable(CAP_SYS_ADMIN)) | ||
528 | return -EPERM; | ||
529 | |||
530 | target_bytes = memparse(buf, &endchar); | ||
531 | |||
532 | balloon_set_new_target(target_bytes >> PAGE_SHIFT); | ||
533 | |||
534 | return count; | ||
535 | } | ||
536 | |||
537 | static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR, | ||
538 | show_target, store_target); | ||
539 | |||
540 | |||
511 | static struct sysdev_attribute *balloon_attrs[] = { | 541 | static struct sysdev_attribute *balloon_attrs[] = { |
512 | &attr_target_kb, | 542 | &attr_target_kb, |
543 | &attr_target, | ||
513 | }; | 544 | }; |
514 | 545 | ||
515 | static struct attribute *balloon_info_attrs[] = { | 546 | static struct attribute *balloon_info_attrs[] = { |