diff options
Diffstat (limited to 'drivers')
153 files changed, 3939 insertions, 5296 deletions
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index f8c63410bcbf..52b23471dd69 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -29,7 +29,6 @@ static u32 acpi_suspend_states[] = { | |||
29 | [PM_SUSPEND_ON] = ACPI_STATE_S0, | 29 | [PM_SUSPEND_ON] = ACPI_STATE_S0, |
30 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, | 30 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, |
31 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, | 31 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, |
32 | [PM_SUSPEND_DISK] = ACPI_STATE_S4, | ||
33 | [PM_SUSPEND_MAX] = ACPI_STATE_S5 | 32 | [PM_SUSPEND_MAX] = ACPI_STATE_S5 |
34 | }; | 33 | }; |
35 | 34 | ||
@@ -94,14 +93,6 @@ static int acpi_pm_enter(suspend_state_t pm_state) | |||
94 | do_suspend_lowlevel(); | 93 | do_suspend_lowlevel(); |
95 | break; | 94 | break; |
96 | 95 | ||
97 | case PM_SUSPEND_DISK: | ||
98 | if (acpi_pm_ops.pm_disk_mode == PM_DISK_PLATFORM) | ||
99 | status = acpi_enter_sleep_state(acpi_state); | ||
100 | break; | ||
101 | case PM_SUSPEND_MAX: | ||
102 | acpi_power_off(); | ||
103 | break; | ||
104 | |||
105 | default: | 96 | default: |
106 | return -EINVAL; | 97 | return -EINVAL; |
107 | } | 98 | } |
@@ -157,12 +148,13 @@ int acpi_suspend(u32 acpi_state) | |||
157 | suspend_state_t states[] = { | 148 | suspend_state_t states[] = { |
158 | [1] = PM_SUSPEND_STANDBY, | 149 | [1] = PM_SUSPEND_STANDBY, |
159 | [3] = PM_SUSPEND_MEM, | 150 | [3] = PM_SUSPEND_MEM, |
160 | [4] = PM_SUSPEND_DISK, | ||
161 | [5] = PM_SUSPEND_MAX | 151 | [5] = PM_SUSPEND_MAX |
162 | }; | 152 | }; |
163 | 153 | ||
164 | if (acpi_state < 6 && states[acpi_state]) | 154 | if (acpi_state < 6 && states[acpi_state]) |
165 | return pm_suspend(states[acpi_state]); | 155 | return pm_suspend(states[acpi_state]); |
156 | if (acpi_state == 4) | ||
157 | return hibernate(); | ||
166 | return -EINVAL; | 158 | return -EINVAL; |
167 | } | 159 | } |
168 | 160 | ||
@@ -189,6 +181,49 @@ static struct pm_ops acpi_pm_ops = { | |||
189 | .finish = acpi_pm_finish, | 181 | .finish = acpi_pm_finish, |
190 | }; | 182 | }; |
191 | 183 | ||
184 | #ifdef CONFIG_SOFTWARE_SUSPEND | ||
185 | static int acpi_hibernation_prepare(void) | ||
186 | { | ||
187 | return acpi_sleep_prepare(ACPI_STATE_S4); | ||
188 | } | ||
189 | |||
190 | static int acpi_hibernation_enter(void) | ||
191 | { | ||
192 | acpi_status status = AE_OK; | ||
193 | unsigned long flags = 0; | ||
194 | |||
195 | ACPI_FLUSH_CPU_CACHE(); | ||
196 | |||
197 | local_irq_save(flags); | ||
198 | acpi_enable_wakeup_device(ACPI_STATE_S4); | ||
199 | /* This shouldn't return. If it returns, we have a problem */ | ||
200 | status = acpi_enter_sleep_state(ACPI_STATE_S4); | ||
201 | local_irq_restore(flags); | ||
202 | |||
203 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; | ||
204 | } | ||
205 | |||
206 | static void acpi_hibernation_finish(void) | ||
207 | { | ||
208 | acpi_leave_sleep_state(ACPI_STATE_S4); | ||
209 | acpi_disable_wakeup_device(ACPI_STATE_S4); | ||
210 | |||
211 | /* reset firmware waking vector */ | ||
212 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); | ||
213 | |||
214 | if (init_8259A_after_S1) { | ||
215 | printk("Broken toshiba laptop -> kicking interrupts\n"); | ||
216 | init_8259A(0); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | static struct hibernation_ops acpi_hibernation_ops = { | ||
221 | .prepare = acpi_hibernation_prepare, | ||
222 | .enter = acpi_hibernation_enter, | ||
223 | .finish = acpi_hibernation_finish, | ||
224 | }; | ||
225 | #endif /* CONFIG_SOFTWARE_SUSPEND */ | ||
226 | |||
192 | /* | 227 | /* |
193 | * Toshiba fails to preserve interrupts over S1, reinitialization | 228 | * Toshiba fails to preserve interrupts over S1, reinitialization |
194 | * of 8259 is needed after S1 resume. | 229 | * of 8259 is needed after S1 resume. |
@@ -227,14 +262,18 @@ int __init acpi_sleep_init(void) | |||
227 | sleep_states[i] = 1; | 262 | sleep_states[i] = 1; |
228 | printk(" S%d", i); | 263 | printk(" S%d", i); |
229 | } | 264 | } |
230 | if (i == ACPI_STATE_S4) { | ||
231 | if (sleep_states[i]) | ||
232 | acpi_pm_ops.pm_disk_mode = PM_DISK_PLATFORM; | ||
233 | } | ||
234 | } | 265 | } |
235 | printk(")\n"); | 266 | printk(")\n"); |
236 | 267 | ||
237 | pm_set_ops(&acpi_pm_ops); | 268 | pm_set_ops(&acpi_pm_ops); |
269 | |||
270 | #ifdef CONFIG_SOFTWARE_SUSPEND | ||
271 | if (sleep_states[ACPI_STATE_S4]) | ||
272 | hibernation_set_ops(&acpi_hibernation_ops); | ||
273 | #else | ||
274 | sleep_states[ACPI_STATE_S4] = 0; | ||
275 | #endif | ||
276 | |||
238 | return 0; | 277 | return 0; |
239 | } | 278 | } |
240 | 279 | ||
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 5a76e5be61d5..76b45f0b8341 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c | |||
@@ -60,7 +60,7 @@ acpi_system_write_sleep(struct file *file, | |||
60 | state = simple_strtoul(str, NULL, 0); | 60 | state = simple_strtoul(str, NULL, 0); |
61 | #ifdef CONFIG_SOFTWARE_SUSPEND | 61 | #ifdef CONFIG_SOFTWARE_SUSPEND |
62 | if (state == 4) { | 62 | if (state == 4) { |
63 | error = pm_suspend(PM_SUSPEND_DISK); | 63 | error = hibernate(); |
64 | goto Done; | 64 | goto Done; |
65 | } | 65 | } |
66 | #endif | 66 | #endif |
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 45dbdc14915f..c7219663f2b9 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -435,7 +435,7 @@ config PATA_OPTIDMA | |||
435 | help | 435 | help |
436 | This option enables DMA/PIO support for the later OPTi | 436 | This option enables DMA/PIO support for the later OPTi |
437 | controllers found on some old motherboards and in some | 437 | controllers found on some old motherboards and in some |
438 | latops | 438 | laptops. |
439 | 439 | ||
440 | If unsure, say N. | 440 | If unsure, say N. |
441 | 441 | ||
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index a7950885d18e..fef87dd70d17 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1316,7 +1316,7 @@ void ata_port_flush_task(struct ata_port *ap) | |||
1316 | spin_unlock_irqrestore(ap->lock, flags); | 1316 | spin_unlock_irqrestore(ap->lock, flags); |
1317 | 1317 | ||
1318 | DPRINTK("flush #1\n"); | 1318 | DPRINTK("flush #1\n"); |
1319 | flush_workqueue(ata_wq); | 1319 | cancel_work_sync(&ap->port_task.work); /* akpm: seems unneeded */ |
1320 | 1320 | ||
1321 | /* | 1321 | /* |
1322 | * At this point, if a task is running, it's guaranteed to see | 1322 | * At this point, if a task is running, it's guaranteed to see |
@@ -1327,7 +1327,7 @@ void ata_port_flush_task(struct ata_port *ap) | |||
1327 | if (ata_msg_ctl(ap)) | 1327 | if (ata_msg_ctl(ap)) |
1328 | ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n", | 1328 | ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n", |
1329 | __FUNCTION__); | 1329 | __FUNCTION__); |
1330 | flush_workqueue(ata_wq); | 1330 | cancel_work_sync(&ap->port_task.work); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | spin_lock_irqsave(ap->lock, flags); | 1333 | spin_lock_irqsave(ap->lock, flags); |
@@ -6475,9 +6475,9 @@ void ata_port_detach(struct ata_port *ap) | |||
6475 | /* Flush hotplug task. The sequence is similar to | 6475 | /* Flush hotplug task. The sequence is similar to |
6476 | * ata_port_flush_task(). | 6476 | * ata_port_flush_task(). |
6477 | */ | 6477 | */ |
6478 | flush_workqueue(ata_aux_wq); | 6478 | cancel_work_sync(&ap->hotplug_task.work); /* akpm: why? */ |
6479 | cancel_delayed_work(&ap->hotplug_task); | 6479 | cancel_delayed_work(&ap->hotplug_task); |
6480 | flush_workqueue(ata_aux_wq); | 6480 | cancel_work_sync(&ap->hotplug_task.work); |
6481 | 6481 | ||
6482 | skip_eh: | 6482 | skip_eh: |
6483 | /* remove the associated SCSI host */ | 6483 | /* remove the associated SCSI host */ |
diff --git a/drivers/base/devres.c b/drivers/base/devres.c index e177c9533b6c..e1c0730a3b99 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c | |||
@@ -101,19 +101,6 @@ static void add_dr(struct device *dev, struct devres_node *node) | |||
101 | list_add_tail(&node->entry, &dev->devres_head); | 101 | list_add_tail(&node->entry, &dev->devres_head); |
102 | } | 102 | } |
103 | 103 | ||
104 | /** | ||
105 | * devres_alloc - Allocate device resource data | ||
106 | * @release: Release function devres will be associated with | ||
107 | * @size: Allocation size | ||
108 | * @gfp: Allocation flags | ||
109 | * | ||
110 | * allocate devres of @size bytes. The allocated area is zeroed, then | ||
111 | * associated with @release. The returned pointer can be passed to | ||
112 | * other devres_*() functions. | ||
113 | * | ||
114 | * RETURNS: | ||
115 | * Pointer to allocated devres on success, NULL on failure. | ||
116 | */ | ||
117 | #ifdef CONFIG_DEBUG_DEVRES | 104 | #ifdef CONFIG_DEBUG_DEVRES |
118 | void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp, | 105 | void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp, |
119 | const char *name) | 106 | const char *name) |
@@ -128,6 +115,19 @@ void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp, | |||
128 | } | 115 | } |
129 | EXPORT_SYMBOL_GPL(__devres_alloc); | 116 | EXPORT_SYMBOL_GPL(__devres_alloc); |
130 | #else | 117 | #else |
118 | /** | ||
119 | * devres_alloc - Allocate device resource data | ||
120 | * @release: Release function devres will be associated with | ||
121 | * @size: Allocation size | ||
122 | * @gfp: Allocation flags | ||
123 | * | ||
124 | * Allocate devres of @size bytes. The allocated area is zeroed, then | ||
125 | * associated with @release. The returned pointer can be passed to | ||
126 | * other devres_*() functions. | ||
127 | * | ||
128 | * RETURNS: | ||
129 | * Pointer to allocated devres on success, NULL on failure. | ||
130 | */ | ||
131 | void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp) | 131 | void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp) |
132 | { | 132 | { |
133 | struct devres *dr; | 133 | struct devres *dr; |
@@ -416,7 +416,7 @@ static int release_nodes(struct device *dev, struct list_head *first, | |||
416 | } | 416 | } |
417 | 417 | ||
418 | /** | 418 | /** |
419 | * devres_release_all - Release all resources | 419 | * devres_release_all - Release all managed resources |
420 | * @dev: Device to release resources for | 420 | * @dev: Device to release resources for |
421 | * | 421 | * |
422 | * Release all resources associated with @dev. This function is | 422 | * Release all resources associated with @dev. This function is |
@@ -600,7 +600,7 @@ static int devm_kzalloc_match(struct device *dev, void *res, void *data) | |||
600 | } | 600 | } |
601 | 601 | ||
602 | /** | 602 | /** |
603 | * devm_kzalloc - Managed kzalloc | 603 | * devm_kzalloc - Resource-managed kzalloc |
604 | * @dev: Device to allocate memory for | 604 | * @dev: Device to allocate memory for |
605 | * @size: Allocation size | 605 | * @size: Allocation size |
606 | * @gfp: Allocation gfp flags | 606 | * @gfp: Allocation gfp flags |
@@ -628,7 +628,7 @@ void * devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) | |||
628 | EXPORT_SYMBOL_GPL(devm_kzalloc); | 628 | EXPORT_SYMBOL_GPL(devm_kzalloc); |
629 | 629 | ||
630 | /** | 630 | /** |
631 | * devm_kfree - Managed kfree | 631 | * devm_kfree - Resource-managed kfree |
632 | * @dev: Device this memory belongs to | 632 | * @dev: Device this memory belongs to |
633 | * @p: Memory to free | 633 | * @p: Memory to free |
634 | * | 634 | * |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index eb84d9d44645..869ff8c00146 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -360,7 +360,7 @@ EXPORT_SYMBOL_GPL(platform_device_unregister); | |||
360 | * This function creates a simple platform device that requires minimal | 360 | * This function creates a simple platform device that requires minimal |
361 | * resource and memory management. Canned release function freeing | 361 | * resource and memory management. Canned release function freeing |
362 | * memory allocated for the device allows drivers using such devices | 362 | * memory allocated for the device allows drivers using such devices |
363 | * to be unloaded iwithout waiting for the last reference to the device | 363 | * to be unloaded without waiting for the last reference to the device |
364 | * to be dropped. | 364 | * to be dropped. |
365 | * | 365 | * |
366 | * This interface is primarily intended for use with legacy drivers | 366 | * This interface is primarily intended for use with legacy drivers |
diff --git a/drivers/base/topology.c b/drivers/base/topology.c index 067a9e8bc377..8d8cdfec6529 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c | |||
@@ -126,10 +126,13 @@ static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, | |||
126 | 126 | ||
127 | switch (action) { | 127 | switch (action) { |
128 | case CPU_UP_PREPARE: | 128 | case CPU_UP_PREPARE: |
129 | case CPU_UP_PREPARE_FROZEN: | ||
129 | rc = topology_add_dev(cpu); | 130 | rc = topology_add_dev(cpu); |
130 | break; | 131 | break; |
131 | case CPU_UP_CANCELED: | 132 | case CPU_UP_CANCELED: |
133 | case CPU_UP_CANCELED_FROZEN: | ||
132 | case CPU_DEAD: | 134 | case CPU_DEAD: |
135 | case CPU_DEAD_FROZEN: | ||
133 | topology_remove_dev(cpu); | 136 | topology_remove_dev(cpu); |
134 | break; | 137 | break; |
135 | } | 138 | } |
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index af6d7274a7cc..18cdd8c77626 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -243,17 +243,13 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, | |||
243 | transfer_result = lo_do_transfer(lo, WRITE, page, offset, | 243 | transfer_result = lo_do_transfer(lo, WRITE, page, offset, |
244 | bvec->bv_page, bv_offs, size, IV); | 244 | bvec->bv_page, bv_offs, size, IV); |
245 | if (unlikely(transfer_result)) { | 245 | if (unlikely(transfer_result)) { |
246 | char *kaddr; | ||
247 | |||
248 | /* | 246 | /* |
249 | * The transfer failed, but we still write the data to | 247 | * The transfer failed, but we still write the data to |
250 | * keep prepare/commit calls balanced. | 248 | * keep prepare/commit calls balanced. |
251 | */ | 249 | */ |
252 | printk(KERN_ERR "loop: transfer error block %llu\n", | 250 | printk(KERN_ERR "loop: transfer error block %llu\n", |
253 | (unsigned long long)index); | 251 | (unsigned long long)index); |
254 | kaddr = kmap_atomic(page, KM_USER0); | 252 | zero_user_page(page, offset, size, KM_USER0); |
255 | memset(kaddr + offset, 0, size); | ||
256 | kunmap_atomic(kaddr, KM_USER0); | ||
257 | } | 253 | } |
258 | flush_dcache_page(page); | 254 | flush_dcache_page(page); |
259 | ret = aops->commit_write(file, page, offset, | 255 | ret = aops->commit_write(file, page, offset, |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 090796bef78f..069ae39a9cd9 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -366,20 +366,25 @@ static struct disk_attribute pid_attr = { | |||
366 | .show = pid_show, | 366 | .show = pid_show, |
367 | }; | 367 | }; |
368 | 368 | ||
369 | static void nbd_do_it(struct nbd_device *lo) | 369 | static int nbd_do_it(struct nbd_device *lo) |
370 | { | 370 | { |
371 | struct request *req; | 371 | struct request *req; |
372 | int ret; | ||
372 | 373 | ||
373 | BUG_ON(lo->magic != LO_MAGIC); | 374 | BUG_ON(lo->magic != LO_MAGIC); |
374 | 375 | ||
375 | lo->pid = current->pid; | 376 | lo->pid = current->pid; |
376 | sysfs_create_file(&lo->disk->kobj, &pid_attr.attr); | 377 | ret = sysfs_create_file(&lo->disk->kobj, &pid_attr.attr); |
378 | if (ret) { | ||
379 | printk(KERN_ERR "nbd: sysfs_create_file failed!"); | ||
380 | return ret; | ||
381 | } | ||
377 | 382 | ||
378 | while ((req = nbd_read_stat(lo)) != NULL) | 383 | while ((req = nbd_read_stat(lo)) != NULL) |
379 | nbd_end_request(req); | 384 | nbd_end_request(req); |
380 | 385 | ||
381 | sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr); | 386 | sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr); |
382 | return; | 387 | return 0; |
383 | } | 388 | } |
384 | 389 | ||
385 | static void nbd_clear_que(struct nbd_device *lo) | 390 | static void nbd_clear_que(struct nbd_device *lo) |
@@ -569,7 +574,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
569 | case NBD_DO_IT: | 574 | case NBD_DO_IT: |
570 | if (!lo->file) | 575 | if (!lo->file) |
571 | return -EINVAL; | 576 | return -EINVAL; |
572 | nbd_do_it(lo); | 577 | error = nbd_do_it(lo); |
578 | if (error) | ||
579 | return error; | ||
573 | /* on return tidy up in case we have a signal */ | 580 | /* on return tidy up in case we have a signal */ |
574 | /* Forcibly shutdown the socket causing all listeners | 581 | /* Forcibly shutdown the socket causing all listeners |
575 | * to error | 582 | * to error |
diff --git a/drivers/block/rd.c b/drivers/block/rd.c index 43d4ebcb3b44..a1512da32410 100644 --- a/drivers/block/rd.c +++ b/drivers/block/rd.c | |||
@@ -151,7 +151,7 @@ static int ramdisk_commit_write(struct file *file, struct page *page, | |||
151 | } | 151 | } |
152 | 152 | ||
153 | /* | 153 | /* |
154 | * ->writepage to the the blockdev's mapping has to redirty the page so that the | 154 | * ->writepage to the blockdev's mapping has to redirty the page so that the |
155 | * VM doesn't go and steal it. We return AOP_WRITEPAGE_ACTIVATE so that the VM | 155 | * VM doesn't go and steal it. We return AOP_WRITEPAGE_ACTIVATE so that the VM |
156 | * won't try to (pointlessly) write the page again for a while. | 156 | * won't try to (pointlessly) write the page again for a while. |
157 | * | 157 | * |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 1e32fb834eb8..2df42fdcdc91 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -631,7 +631,8 @@ config HVC_CONSOLE | |||
631 | 631 | ||
632 | config HVC_ISERIES | 632 | config HVC_ISERIES |
633 | bool "iSeries Hypervisor Virtual Console support" | 633 | bool "iSeries Hypervisor Virtual Console support" |
634 | depends on PPC_ISERIES && !VIOCONS | 634 | depends on PPC_ISERIES |
635 | default y | ||
635 | select HVC_DRIVER | 636 | select HVC_DRIVER |
636 | help | 637 | help |
637 | iSeries machines support a hypervisor virtual console. | 638 | iSeries machines support a hypervisor virtual console. |
diff --git a/drivers/char/drm/drm_dma.c b/drivers/char/drm/drm_dma.c index 892db7096986..32ed19c9ec1c 100644 --- a/drivers/char/drm/drm_dma.c +++ b/drivers/char/drm/drm_dma.c | |||
@@ -65,7 +65,7 @@ int drm_dma_setup(drm_device_t * dev) | |||
65 | * \param dev DRM device. | 65 | * \param dev DRM device. |
66 | * | 66 | * |
67 | * Free all pages associated with DMA buffers, the buffers and pages lists, and | 67 | * Free all pages associated with DMA buffers, the buffers and pages lists, and |
68 | * finally the the drm_device::dma structure itself. | 68 | * finally the drm_device::dma structure itself. |
69 | */ | 69 | */ |
70 | void drm_dma_takedown(drm_device_t * dev) | 70 | void drm_dma_takedown(drm_device_t * dev) |
71 | { | 71 | { |
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c index 35540cfb43dd..b5c5b9fa84c3 100644 --- a/drivers/char/drm/drm_vm.c +++ b/drivers/char/drm/drm_vm.c | |||
@@ -157,7 +157,7 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, | |||
157 | * \param address access address. | 157 | * \param address access address. |
158 | * \return pointer to the page structure. | 158 | * \return pointer to the page structure. |
159 | * | 159 | * |
160 | * Get the the mapping, find the real physical page to map, get the page, and | 160 | * Get the mapping, find the real physical page to map, get the page, and |
161 | * return it. | 161 | * return it. |
162 | */ | 162 | */ |
163 | static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma, | 163 | static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma, |
diff --git a/drivers/char/drm/r300_reg.h b/drivers/char/drm/r300_reg.h index a881f96c983e..ecda760ae8c0 100644 --- a/drivers/char/drm/r300_reg.h +++ b/drivers/char/drm/r300_reg.h | |||
@@ -293,7 +293,7 @@ I am fairly certain that they are correct unless stated otherwise in comments. | |||
293 | # define R300_PVS_CNTL_1_PROGRAM_START_SHIFT 0 | 293 | # define R300_PVS_CNTL_1_PROGRAM_START_SHIFT 0 |
294 | # define R300_PVS_CNTL_1_POS_END_SHIFT 10 | 294 | # define R300_PVS_CNTL_1_POS_END_SHIFT 10 |
295 | # define R300_PVS_CNTL_1_PROGRAM_END_SHIFT 20 | 295 | # define R300_PVS_CNTL_1_PROGRAM_END_SHIFT 20 |
296 | /* Addresses are relative the the vertex program parameters area. */ | 296 | /* Addresses are relative to the vertex program parameters area. */ |
297 | #define R300_VAP_PVS_CNTL_2 0x22D4 | 297 | #define R300_VAP_PVS_CNTL_2 0x22D4 |
298 | # define R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT 0 | 298 | # define R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT 0 |
299 | # define R300_PVS_CNTL_2_PARAM_COUNT_SHIFT 16 | 299 | # define R300_PVS_CNTL_2_PARAM_COUNT_SHIFT 16 |
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c index 49f914e79216..9e1fc02967ff 100644 --- a/drivers/char/genrtc.c +++ b/drivers/char/genrtc.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * | 12 | * |
13 | * This driver allows use of the real time clock (built into | 13 | * This driver allows use of the real time clock (built into |
14 | * nearly all computers) from user space. It exports the /dev/rtc | 14 | * nearly all computers) from user space. It exports the /dev/rtc |
15 | * interface supporting various ioctl() and also the /proc/dev/rtc | 15 | * interface supporting various ioctl() and also the /proc/driver/rtc |
16 | * pseudo-file for status information. | 16 | * pseudo-file for status information. |
17 | * | 17 | * |
18 | * The ioctls can be used to set the interrupt behaviour where | 18 | * The ioctls can be used to set the interrupt behaviour where |
@@ -377,7 +377,7 @@ static int gen_rtc_release(struct inode *inode, struct file *file) | |||
377 | #ifdef CONFIG_PROC_FS | 377 | #ifdef CONFIG_PROC_FS |
378 | 378 | ||
379 | /* | 379 | /* |
380 | * Info exported via "/proc/rtc". | 380 | * Info exported via "/proc/driver/rtc". |
381 | */ | 381 | */ |
382 | 382 | ||
383 | static int gen_rtc_proc_output(char *buf) | 383 | static int gen_rtc_proc_output(char *buf) |
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 5f3acd8e64b8..7cda04b33534 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig | |||
@@ -91,3 +91,17 @@ config HW_RANDOM_OMAP | |||
91 | module will be called omap-rng. | 91 | module will be called omap-rng. |
92 | 92 | ||
93 | If unsure, say Y. | 93 | If unsure, say Y. |
94 | |||
95 | config HW_RANDOM_PASEMI | ||
96 | tristate "PA Semi HW Random Number Generator support" | ||
97 | depends on HW_RANDOM && PPC_PASEMI | ||
98 | default HW_RANDOM | ||
99 | ---help--- | ||
100 | This driver provides kernel-side support for the Random Number | ||
101 | Generator hardware found on PA6T-1682M processor. | ||
102 | |||
103 | To compile this driver as a module, choose M here: the | ||
104 | module will be called pasemi-rng. | ||
105 | |||
106 | If unsure, say Y. | ||
107 | |||
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index c41fa19454e3..c8b7300e2fb1 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile | |||
@@ -10,3 +10,4 @@ obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o | |||
10 | obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o | 10 | obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o |
11 | obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o | 11 | obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o |
12 | obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o | 12 | obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o |
13 | obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o | ||
diff --git a/drivers/char/hw_random/pasemi-rng.c b/drivers/char/hw_random/pasemi-rng.c new file mode 100644 index 000000000000..fa6040b6c8f2 --- /dev/null +++ b/drivers/char/hw_random/pasemi-rng.c | |||
@@ -0,0 +1,156 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006-2007 PA Semi, Inc | ||
3 | * | ||
4 | * Maintained by: Olof Johansson <olof@lixom.net> | ||
5 | * | ||
6 | * Driver for the PWRficient onchip rng | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/hw_random.h> | ||
26 | #include <asm/of_platform.h> | ||
27 | #include <asm/io.h> | ||
28 | |||
29 | #define SDCRNG_CTL_REG 0x00 | ||
30 | #define SDCRNG_CTL_FVLD_M 0x0000f000 | ||
31 | #define SDCRNG_CTL_FVLD_S 12 | ||
32 | #define SDCRNG_CTL_KSZ 0x00000800 | ||
33 | #define SDCRNG_CTL_RSRC_CRG 0x00000010 | ||
34 | #define SDCRNG_CTL_RSRC_RRG 0x00000000 | ||
35 | #define SDCRNG_CTL_CE 0x00000004 | ||
36 | #define SDCRNG_CTL_RE 0x00000002 | ||
37 | #define SDCRNG_CTL_DR 0x00000001 | ||
38 | #define SDCRNG_CTL_SELECT_RRG_RNG (SDCRNG_CTL_RE | SDCRNG_CTL_RSRC_RRG) | ||
39 | #define SDCRNG_CTL_SELECT_CRG_RNG (SDCRNG_CTL_CE | SDCRNG_CTL_RSRC_CRG) | ||
40 | #define SDCRNG_VAL_REG 0x20 | ||
41 | |||
42 | #define MODULE_NAME "pasemi_rng" | ||
43 | |||
44 | static int pasemi_rng_data_present(struct hwrng *rng) | ||
45 | { | ||
46 | void __iomem *rng_regs = (void __iomem *)rng->priv; | ||
47 | |||
48 | return (in_le32(rng_regs + SDCRNG_CTL_REG) | ||
49 | & SDCRNG_CTL_FVLD_M) ? 1 : 0; | ||
50 | } | ||
51 | |||
52 | static int pasemi_rng_data_read(struct hwrng *rng, u32 *data) | ||
53 | { | ||
54 | void __iomem *rng_regs = (void __iomem *)rng->priv; | ||
55 | *data = in_le32(rng_regs + SDCRNG_VAL_REG); | ||
56 | return 4; | ||
57 | } | ||
58 | |||
59 | static int pasemi_rng_init(struct hwrng *rng) | ||
60 | { | ||
61 | void __iomem *rng_regs = (void __iomem *)rng->priv; | ||
62 | u32 ctl; | ||
63 | |||
64 | ctl = SDCRNG_CTL_DR | SDCRNG_CTL_SELECT_RRG_RNG | SDCRNG_CTL_KSZ; | ||
65 | out_le32(rng_regs + SDCRNG_CTL_REG, ctl); | ||
66 | out_le32(rng_regs + SDCRNG_CTL_REG, ctl & ~SDCRNG_CTL_DR); | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static void pasemi_rng_cleanup(struct hwrng *rng) | ||
72 | { | ||
73 | void __iomem *rng_regs = (void __iomem *)rng->priv; | ||
74 | u32 ctl; | ||
75 | |||
76 | ctl = SDCRNG_CTL_RE | SDCRNG_CTL_CE; | ||
77 | out_le32(rng_regs + SDCRNG_CTL_REG, | ||
78 | in_le32(rng_regs + SDCRNG_CTL_REG) & ~ctl); | ||
79 | } | ||
80 | |||
81 | static struct hwrng pasemi_rng = { | ||
82 | .name = MODULE_NAME, | ||
83 | .init = pasemi_rng_init, | ||
84 | .cleanup = pasemi_rng_cleanup, | ||
85 | .data_present = pasemi_rng_data_present, | ||
86 | .data_read = pasemi_rng_data_read, | ||
87 | }; | ||
88 | |||
89 | static int __devinit rng_probe(struct of_device *ofdev, | ||
90 | const struct of_device_id *match) | ||
91 | { | ||
92 | void __iomem *rng_regs; | ||
93 | struct device_node *rng_np = ofdev->node; | ||
94 | struct resource res; | ||
95 | int err = 0; | ||
96 | |||
97 | err = of_address_to_resource(rng_np, 0, &res); | ||
98 | if (err) | ||
99 | return -ENODEV; | ||
100 | |||
101 | rng_regs = ioremap(res.start, 0x100); | ||
102 | |||
103 | if (!rng_regs) | ||
104 | return -ENOMEM; | ||
105 | |||
106 | pasemi_rng.priv = (unsigned long)rng_regs; | ||
107 | |||
108 | printk(KERN_INFO "Registering PA Semi RNG\n"); | ||
109 | |||
110 | err = hwrng_register(&pasemi_rng); | ||
111 | |||
112 | if (err) | ||
113 | iounmap(rng_regs); | ||
114 | |||
115 | return err; | ||
116 | } | ||
117 | |||
118 | static int __devexit rng_remove(struct of_device *dev) | ||
119 | { | ||
120 | void __iomem *rng_regs = (void __iomem *)pasemi_rng.priv; | ||
121 | |||
122 | hwrng_unregister(&pasemi_rng); | ||
123 | iounmap(rng_regs); | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static struct of_device_id rng_match[] = { | ||
129 | { | ||
130 | .compatible = "1682m-rng", | ||
131 | }, | ||
132 | {}, | ||
133 | }; | ||
134 | |||
135 | static struct of_platform_driver rng_driver = { | ||
136 | .name = "pasemi-rng", | ||
137 | .match_table = rng_match, | ||
138 | .probe = rng_probe, | ||
139 | .remove = rng_remove, | ||
140 | }; | ||
141 | |||
142 | static int __init rng_init(void) | ||
143 | { | ||
144 | return of_register_platform_driver(&rng_driver); | ||
145 | } | ||
146 | module_init(rng_init); | ||
147 | |||
148 | static void __exit rng_exit(void) | ||
149 | { | ||
150 | of_unregister_platform_driver(&rng_driver); | ||
151 | } | ||
152 | module_exit(rng_exit); | ||
153 | |||
154 | MODULE_LICENSE("GPL"); | ||
155 | MODULE_AUTHOR("Egor Martovetsky <egor@pasemi.com>"); | ||
156 | MODULE_DESCRIPTION("H/W RNG driver for PA Semi processor"); | ||
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index c09160383a53..6e55cfb9c65a 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c | |||
@@ -705,15 +705,13 @@ static int __init mmtimer_init(void) | |||
705 | maxn++; | 705 | maxn++; |
706 | 706 | ||
707 | /* Allocate list of node ptrs to mmtimer_t's */ | 707 | /* Allocate list of node ptrs to mmtimer_t's */ |
708 | timers = kmalloc(sizeof(mmtimer_t *)*maxn, GFP_KERNEL); | 708 | timers = kzalloc(sizeof(mmtimer_t *)*maxn, GFP_KERNEL); |
709 | if (timers == NULL) { | 709 | if (timers == NULL) { |
710 | printk(KERN_ERR "%s: failed to allocate memory for device\n", | 710 | printk(KERN_ERR "%s: failed to allocate memory for device\n", |
711 | MMTIMER_NAME); | 711 | MMTIMER_NAME); |
712 | goto out3; | 712 | goto out3; |
713 | } | 713 | } |
714 | 714 | ||
715 | memset(timers,0,(sizeof(mmtimer_t *)*maxn)); | ||
716 | |||
717 | /* Allocate mmtimer_t's for each online node */ | 715 | /* Allocate mmtimer_t's for each online node */ |
718 | for_each_online_node(node) { | 716 | for_each_online_node(node) { |
719 | timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node); | 717 | timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node); |
diff --git a/drivers/char/pcmcia/Kconfig b/drivers/char/pcmcia/Kconfig index 27c1179ee527..f25facd97bb4 100644 --- a/drivers/char/pcmcia/Kconfig +++ b/drivers/char/pcmcia/Kconfig | |||
@@ -21,6 +21,7 @@ config SYNCLINK_CS | |||
21 | config CARDMAN_4000 | 21 | config CARDMAN_4000 |
22 | tristate "Omnikey Cardman 4000 support" | 22 | tristate "Omnikey Cardman 4000 support" |
23 | depends on PCMCIA | 23 | depends on PCMCIA |
24 | select BITREVERSE | ||
24 | help | 25 | help |
25 | Enable support for the Omnikey Cardman 4000 PCMCIA Smartcard | 26 | Enable support for the Omnikey Cardman 4000 PCMCIA Smartcard |
26 | reader. | 27 | reader. |
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index e91b43a014b0..fee58e03dbe2 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/fs.h> | 32 | #include <linux/fs.h> |
33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/bitrev.h> | ||
34 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
35 | #include <asm/io.h> | 36 | #include <asm/io.h> |
36 | 37 | ||
@@ -194,41 +195,17 @@ static inline unsigned char xinb(unsigned short port) | |||
194 | } | 195 | } |
195 | #endif | 196 | #endif |
196 | 197 | ||
197 | #define b_0000 15 | 198 | static inline unsigned char invert_revert(unsigned char ch) |
198 | #define b_0001 14 | 199 | { |
199 | #define b_0010 13 | 200 | return bitrev8(~ch); |
200 | #define b_0011 12 | 201 | } |
201 | #define b_0100 11 | ||
202 | #define b_0101 10 | ||
203 | #define b_0110 9 | ||
204 | #define b_0111 8 | ||
205 | #define b_1000 7 | ||
206 | #define b_1001 6 | ||
207 | #define b_1010 5 | ||
208 | #define b_1011 4 | ||
209 | #define b_1100 3 | ||
210 | #define b_1101 2 | ||
211 | #define b_1110 1 | ||
212 | #define b_1111 0 | ||
213 | |||
214 | static unsigned char irtab[16] = { | ||
215 | b_0000, b_1000, b_0100, b_1100, | ||
216 | b_0010, b_1010, b_0110, b_1110, | ||
217 | b_0001, b_1001, b_0101, b_1101, | ||
218 | b_0011, b_1011, b_0111, b_1111 | ||
219 | }; | ||
220 | 202 | ||
221 | static void str_invert_revert(unsigned char *b, int len) | 203 | static void str_invert_revert(unsigned char *b, int len) |
222 | { | 204 | { |
223 | int i; | 205 | int i; |
224 | 206 | ||
225 | for (i = 0; i < len; i++) | 207 | for (i = 0; i < len; i++) |
226 | b[i] = (irtab[b[i] & 0x0f] << 4) | irtab[b[i] >> 4]; | 208 | b[i] = invert_revert(b[i]); |
227 | } | ||
228 | |||
229 | static unsigned char invert_revert(unsigned char ch) | ||
230 | { | ||
231 | return (irtab[ch & 0x0f] << 4) | irtab[ch >> 4]; | ||
232 | } | 209 | } |
233 | 210 | ||
234 | #define ATRLENCK(dev,pos) \ | 211 | #define ATRLENCK(dev,pos) \ |
@@ -1114,7 +1091,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf, | |||
1114 | /* | 1091 | /* |
1115 | * wait for atr to become valid. | 1092 | * wait for atr to become valid. |
1116 | * note: it is important to lock this code. if we dont, the monitor | 1093 | * note: it is important to lock this code. if we dont, the monitor |
1117 | * could be run between test_bit and the the call the sleep on the | 1094 | * could be run between test_bit and the call to sleep on the |
1118 | * atr-queue. if *then* the monitor detects atr valid, it will wake up | 1095 | * atr-queue. if *then* the monitor detects atr valid, it will wake up |
1119 | * any process on the atr-queue, *but* since we have been interrupted, | 1096 | * any process on the atr-queue, *but* since we have been interrupted, |
1120 | * we do not yet sleep on this queue. this would result in a missed | 1097 | * we do not yet sleep on this queue. this would result in a missed |
@@ -1881,8 +1858,11 @@ static int cm4000_probe(struct pcmcia_device *link) | |||
1881 | init_waitqueue_head(&dev->readq); | 1858 | init_waitqueue_head(&dev->readq); |
1882 | 1859 | ||
1883 | ret = cm4000_config(link, i); | 1860 | ret = cm4000_config(link, i); |
1884 | if (ret) | 1861 | if (ret) { |
1862 | dev_table[i] = NULL; | ||
1863 | kfree(dev); | ||
1885 | return ret; | 1864 | return ret; |
1865 | } | ||
1886 | 1866 | ||
1887 | class_device_create(cmm_class, NULL, MKDEV(major, i), NULL, | 1867 | class_device_create(cmm_class, NULL, MKDEV(major, i), NULL, |
1888 | "cmm%d", i); | 1868 | "cmm%d", i); |
@@ -1907,7 +1887,7 @@ static void cm4000_detach(struct pcmcia_device *link) | |||
1907 | cm4000_release(link); | 1887 | cm4000_release(link); |
1908 | 1888 | ||
1909 | dev_table[devno] = NULL; | 1889 | dev_table[devno] = NULL; |
1910 | kfree(dev); | 1890 | kfree(dev); |
1911 | 1891 | ||
1912 | class_device_destroy(cmm_class, MKDEV(major, devno)); | 1892 | class_device_destroy(cmm_class, MKDEV(major, devno)); |
1913 | 1893 | ||
@@ -1956,12 +1936,14 @@ static int __init cmm_init(void) | |||
1956 | if (major < 0) { | 1936 | if (major < 0) { |
1957 | printk(KERN_WARNING MODULE_NAME | 1937 | printk(KERN_WARNING MODULE_NAME |
1958 | ": could not get major number\n"); | 1938 | ": could not get major number\n"); |
1939 | class_destroy(cmm_class); | ||
1959 | return major; | 1940 | return major; |
1960 | } | 1941 | } |
1961 | 1942 | ||
1962 | rc = pcmcia_register_driver(&cm4000_driver); | 1943 | rc = pcmcia_register_driver(&cm4000_driver); |
1963 | if (rc < 0) { | 1944 | if (rc < 0) { |
1964 | unregister_chrdev(major, DEVICE_NAME); | 1945 | unregister_chrdev(major, DEVICE_NAME); |
1946 | class_destroy(cmm_class); | ||
1965 | return rc; | 1947 | return rc; |
1966 | } | 1948 | } |
1967 | 1949 | ||
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index f2e4ec4fd407..af88181a17f4 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c | |||
@@ -636,8 +636,11 @@ static int reader_probe(struct pcmcia_device *link) | |||
636 | setup_timer(&dev->poll_timer, cm4040_do_poll, 0); | 636 | setup_timer(&dev->poll_timer, cm4040_do_poll, 0); |
637 | 637 | ||
638 | ret = reader_config(link, i); | 638 | ret = reader_config(link, i); |
639 | if (ret) | 639 | if (ret) { |
640 | dev_table[i] = NULL; | ||
641 | kfree(dev); | ||
640 | return ret; | 642 | return ret; |
643 | } | ||
641 | 644 | ||
642 | class_device_create(cmx_class, NULL, MKDEV(major, i), NULL, | 645 | class_device_create(cmx_class, NULL, MKDEV(major, i), NULL, |
643 | "cmx%d", i); | 646 | "cmx%d", i); |
@@ -708,12 +711,14 @@ static int __init cm4040_init(void) | |||
708 | if (major < 0) { | 711 | if (major < 0) { |
709 | printk(KERN_WARNING MODULE_NAME | 712 | printk(KERN_WARNING MODULE_NAME |
710 | ": could not get major number\n"); | 713 | ": could not get major number\n"); |
714 | class_destroy(cmx_class); | ||
711 | return major; | 715 | return major; |
712 | } | 716 | } |
713 | 717 | ||
714 | rc = pcmcia_register_driver(&reader_driver); | 718 | rc = pcmcia_register_driver(&reader_driver); |
715 | if (rc < 0) { | 719 | if (rc < 0) { |
716 | unregister_chrdev(major, DEVICE_NAME); | 720 | unregister_chrdev(major, DEVICE_NAME); |
721 | class_destroy(cmx_class); | ||
717 | return rc; | 722 | return rc; |
718 | } | 723 | } |
719 | 724 | ||
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index fe00c7dfb649..11089be0691b 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig | |||
@@ -33,7 +33,7 @@ config TCG_NSC | |||
33 | tristate "National Semiconductor TPM Interface" | 33 | tristate "National Semiconductor TPM Interface" |
34 | depends on TCG_TPM && PNPACPI | 34 | depends on TCG_TPM && PNPACPI |
35 | ---help--- | 35 | ---help--- |
36 | If you have a TPM security chip from National Semicondutor | 36 | If you have a TPM security chip from National Semiconductor |
37 | say Yes and it will be accessible from within Linux. To | 37 | say Yes and it will be accessible from within Linux. To |
38 | compile this driver as a module, choose M here; the module | 38 | compile this driver as a module, choose M here; the module |
39 | will be called tpm_nsc. | 39 | will be called tpm_nsc. |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 7710a6a77d97..fc662e4ce58a 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -934,13 +934,6 @@ restart: | |||
934 | return -EINVAL; | 934 | return -EINVAL; |
935 | 935 | ||
936 | /* | 936 | /* |
937 | * No more input please, we are switching. The new ldisc | ||
938 | * will update this value in the ldisc open function | ||
939 | */ | ||
940 | |||
941 | tty->receive_room = 0; | ||
942 | |||
943 | /* | ||
944 | * Problem: What do we do if this blocks ? | 937 | * Problem: What do we do if this blocks ? |
945 | */ | 938 | */ |
946 | 939 | ||
@@ -951,6 +944,13 @@ restart: | |||
951 | return 0; | 944 | return 0; |
952 | } | 945 | } |
953 | 946 | ||
947 | /* | ||
948 | * No more input please, we are switching. The new ldisc | ||
949 | * will update this value in the ldisc open function | ||
950 | */ | ||
951 | |||
952 | tty->receive_room = 0; | ||
953 | |||
954 | o_ldisc = tty->ldisc; | 954 | o_ldisc = tty->ldisc; |
955 | o_tty = tty->link; | 955 | o_tty = tty->link; |
956 | 956 | ||
@@ -1573,11 +1573,11 @@ void no_tty(void) | |||
1573 | 1573 | ||
1574 | 1574 | ||
1575 | /** | 1575 | /** |
1576 | * stop_tty - propogate flow control | 1576 | * stop_tty - propagate flow control |
1577 | * @tty: tty to stop | 1577 | * @tty: tty to stop |
1578 | * | 1578 | * |
1579 | * Perform flow control to the driver. For PTY/TTY pairs we | 1579 | * Perform flow control to the driver. For PTY/TTY pairs we |
1580 | * must also propogate the TIOCKPKT status. May be called | 1580 | * must also propagate the TIOCKPKT status. May be called |
1581 | * on an already stopped device and will not re-call the driver | 1581 | * on an already stopped device and will not re-call the driver |
1582 | * method. | 1582 | * method. |
1583 | * | 1583 | * |
@@ -1607,11 +1607,11 @@ void stop_tty(struct tty_struct *tty) | |||
1607 | EXPORT_SYMBOL(stop_tty); | 1607 | EXPORT_SYMBOL(stop_tty); |
1608 | 1608 | ||
1609 | /** | 1609 | /** |
1610 | * start_tty - propogate flow control | 1610 | * start_tty - propagate flow control |
1611 | * @tty: tty to start | 1611 | * @tty: tty to start |
1612 | * | 1612 | * |
1613 | * Start a tty that has been stopped if at all possible. Perform | 1613 | * Start a tty that has been stopped if at all possible. Perform |
1614 | * any neccessary wakeups and propogate the TIOCPKT status. If this | 1614 | * any neccessary wakeups and propagate the TIOCPKT status. If this |
1615 | * is the tty was previous stopped and is being started then the | 1615 | * is the tty was previous stopped and is being started then the |
1616 | * driver start method is invoked and the line discipline woken. | 1616 | * driver start method is invoked and the line discipline woken. |
1617 | * | 1617 | * |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 893dbaf386fb..eb37fba9b7ef 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1685,9 +1685,11 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1685 | if (sys_dev) { | 1685 | if (sys_dev) { |
1686 | switch (action) { | 1686 | switch (action) { |
1687 | case CPU_ONLINE: | 1687 | case CPU_ONLINE: |
1688 | case CPU_ONLINE_FROZEN: | ||
1688 | cpufreq_add_dev(sys_dev); | 1689 | cpufreq_add_dev(sys_dev); |
1689 | break; | 1690 | break; |
1690 | case CPU_DOWN_PREPARE: | 1691 | case CPU_DOWN_PREPARE: |
1692 | case CPU_DOWN_PREPARE_FROZEN: | ||
1691 | if (unlikely(lock_policy_rwsem_write(cpu))) | 1693 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1692 | BUG(); | 1694 | BUG(); |
1693 | 1695 | ||
@@ -1699,6 +1701,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1699 | __cpufreq_remove_dev(sys_dev); | 1701 | __cpufreq_remove_dev(sys_dev); |
1700 | break; | 1702 | break; |
1701 | case CPU_DOWN_FAILED: | 1703 | case CPU_DOWN_FAILED: |
1704 | case CPU_DOWN_FAILED_FROZEN: | ||
1702 | cpufreq_add_dev(sys_dev); | 1705 | cpufreq_add_dev(sys_dev); |
1703 | break; | 1706 | break; |
1704 | } | 1707 | } |
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index d1c7cac9316c..d2f0cbd8b8f3 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -313,9 +313,11 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb, | |||
313 | 313 | ||
314 | switch (action) { | 314 | switch (action) { |
315 | case CPU_ONLINE: | 315 | case CPU_ONLINE: |
316 | case CPU_ONLINE_FROZEN: | ||
316 | cpufreq_update_policy(cpu); | 317 | cpufreq_update_policy(cpu); |
317 | break; | 318 | break; |
318 | case CPU_DEAD: | 319 | case CPU_DEAD: |
320 | case CPU_DEAD_FROZEN: | ||
319 | cpufreq_stats_free_table(cpu); | 321 | cpufreq_stats_free_table(cpu); |
320 | break; | 322 | break; |
321 | } | 323 | } |
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index f21fe66c9eef..f4c634504d1a 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig | |||
@@ -51,7 +51,7 @@ config CRYPTO_DEV_GEODE | |||
51 | default m | 51 | default m |
52 | help | 52 | help |
53 | Say 'Y' here to use the AMD Geode LX processor on-board AES | 53 | Say 'Y' here to use the AMD Geode LX processor on-board AES |
54 | engine for the CryptoAPI AES alogrithm. | 54 | engine for the CryptoAPI AES algorithm. |
55 | 55 | ||
56 | To compile this driver as a module, choose M here: the module | 56 | To compile this driver as a module, choose M here: the module |
57 | will be called geode-aes. | 57 | will be called geode-aes. |
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 03b1f650d1c4..75e3911810a3 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
@@ -309,9 +309,11 @@ static int coretemp_cpu_callback(struct notifier_block *nfb, | |||
309 | 309 | ||
310 | switch (action) { | 310 | switch (action) { |
311 | case CPU_ONLINE: | 311 | case CPU_ONLINE: |
312 | case CPU_ONLINE_FROZEN: | ||
312 | coretemp_device_add(cpu); | 313 | coretemp_device_add(cpu); |
313 | break; | 314 | break; |
314 | case CPU_DEAD: | 315 | case CPU_DEAD: |
316 | case CPU_DEAD_FROZEN: | ||
315 | coretemp_device_remove(cpu); | 317 | coretemp_device_remove(cpu); |
316 | break; | 318 | break; |
317 | } | 319 | } |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 7ed92dc3d833..3c3f2ebf3fc9 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -354,7 +354,7 @@ static void tps65010_interrupt(struct tps65010 *tps) | |||
354 | * also needs to get error handling and probably | 354 | * also needs to get error handling and probably |
355 | * an #ifdef CONFIG_SOFTWARE_SUSPEND | 355 | * an #ifdef CONFIG_SOFTWARE_SUSPEND |
356 | */ | 356 | */ |
357 | pm_suspend(PM_SUSPEND_DISK); | 357 | hibernate(); |
358 | #endif | 358 | #endif |
359 | poll = 1; | 359 | poll = 1; |
360 | } | 360 | } |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 5314ec913724..d09e74c2996e 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -827,7 +827,7 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
827 | 827 | ||
828 | /* | 828 | /* |
829 | * Now set up the hw. We have to do this ourselves as | 829 | * Now set up the hw. We have to do this ourselves as |
830 | * the MMIO layout isnt the same as the the standard port | 830 | * the MMIO layout isnt the same as the standard port |
831 | * based I/O | 831 | * based I/O |
832 | */ | 832 | */ |
833 | 833 | ||
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 6a1a0572275e..835937e38529 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c | |||
@@ -1702,7 +1702,7 @@ static int nodemgr_host_thread(void *__hi) | |||
1702 | generation = get_hpsb_generation(host); | 1702 | generation = get_hpsb_generation(host); |
1703 | 1703 | ||
1704 | /* If we get a reset before we are done waiting, then | 1704 | /* If we get a reset before we are done waiting, then |
1705 | * start the the waiting over again */ | 1705 | * start the waiting over again */ |
1706 | if (generation != g) | 1706 | if (generation != g) |
1707 | g = generation, i = 0; | 1707 | g = generation, i = 0; |
1708 | } | 1708 | } |
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c index f284be1c9166..82dda2faf4d0 100644 --- a/drivers/infiniband/hw/ehca/ehca_irq.c +++ b/drivers/infiniband/hw/ehca/ehca_irq.c | |||
@@ -745,6 +745,7 @@ static int comp_pool_callback(struct notifier_block *nfb, | |||
745 | 745 | ||
746 | switch (action) { | 746 | switch (action) { |
747 | case CPU_UP_PREPARE: | 747 | case CPU_UP_PREPARE: |
748 | case CPU_UP_PREPARE_FROZEN: | ||
748 | ehca_gen_dbg("CPU: %x (CPU_PREPARE)", cpu); | 749 | ehca_gen_dbg("CPU: %x (CPU_PREPARE)", cpu); |
749 | if(!create_comp_task(pool, cpu)) { | 750 | if(!create_comp_task(pool, cpu)) { |
750 | ehca_gen_err("Can't create comp_task for cpu: %x", cpu); | 751 | ehca_gen_err("Can't create comp_task for cpu: %x", cpu); |
@@ -752,24 +753,29 @@ static int comp_pool_callback(struct notifier_block *nfb, | |||
752 | } | 753 | } |
753 | break; | 754 | break; |
754 | case CPU_UP_CANCELED: | 755 | case CPU_UP_CANCELED: |
756 | case CPU_UP_CANCELED_FROZEN: | ||
755 | ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu); | 757 | ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu); |
756 | cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); | 758 | cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); |
757 | kthread_bind(cct->task, any_online_cpu(cpu_online_map)); | 759 | kthread_bind(cct->task, any_online_cpu(cpu_online_map)); |
758 | destroy_comp_task(pool, cpu); | 760 | destroy_comp_task(pool, cpu); |
759 | break; | 761 | break; |
760 | case CPU_ONLINE: | 762 | case CPU_ONLINE: |
763 | case CPU_ONLINE_FROZEN: | ||
761 | ehca_gen_dbg("CPU: %x (CPU_ONLINE)", cpu); | 764 | ehca_gen_dbg("CPU: %x (CPU_ONLINE)", cpu); |
762 | cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); | 765 | cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); |
763 | kthread_bind(cct->task, cpu); | 766 | kthread_bind(cct->task, cpu); |
764 | wake_up_process(cct->task); | 767 | wake_up_process(cct->task); |
765 | break; | 768 | break; |
766 | case CPU_DOWN_PREPARE: | 769 | case CPU_DOWN_PREPARE: |
770 | case CPU_DOWN_PREPARE_FROZEN: | ||
767 | ehca_gen_dbg("CPU: %x (CPU_DOWN_PREPARE)", cpu); | 771 | ehca_gen_dbg("CPU: %x (CPU_DOWN_PREPARE)", cpu); |
768 | break; | 772 | break; |
769 | case CPU_DOWN_FAILED: | 773 | case CPU_DOWN_FAILED: |
774 | case CPU_DOWN_FAILED_FROZEN: | ||
770 | ehca_gen_dbg("CPU: %x (CPU_DOWN_FAILED)", cpu); | 775 | ehca_gen_dbg("CPU: %x (CPU_DOWN_FAILED)", cpu); |
771 | break; | 776 | break; |
772 | case CPU_DEAD: | 777 | case CPU_DEAD: |
778 | case CPU_DEAD_FROZEN: | ||
773 | ehca_gen_dbg("CPU: %x (CPU_DEAD)", cpu); | 779 | ehca_gen_dbg("CPU: %x (CPU_DEAD)", cpu); |
774 | destroy_comp_task(pool, cpu); | 780 | destroy_comp_task(pool, cpu); |
775 | take_over_work(pool, cpu); | 781 | take_over_work(pool, cpu); |
diff --git a/drivers/isdn/capi/Kconfig b/drivers/isdn/capi/Kconfig index c921d6c522f5..c92f9d764fce 100644 --- a/drivers/isdn/capi/Kconfig +++ b/drivers/isdn/capi/Kconfig | |||
@@ -17,7 +17,7 @@ config CAPI_TRACE | |||
17 | help | 17 | help |
18 | If you say Y here, the kernelcapi driver can make verbose traces | 18 | If you say Y here, the kernelcapi driver can make verbose traces |
19 | of CAPI messages. This feature can be enabled/disabled via IOCTL for | 19 | of CAPI messages. This feature can be enabled/disabled via IOCTL for |
20 | every controler (default disabled). | 20 | every controller (default disabled). |
21 | This will increase the size of the kernelcapi module by 20 KB. | 21 | This will increase the size of the kernelcapi module by 20 KB. |
22 | If unsure, say Y. | 22 | If unsure, say Y. |
23 | 23 | ||
diff --git a/drivers/isdn/hardware/eicon/divasync.h b/drivers/isdn/hardware/eicon/divasync.h index af3eb9e795b5..85784a7ffb25 100644 --- a/drivers/isdn/hardware/eicon/divasync.h +++ b/drivers/isdn/hardware/eicon/divasync.h | |||
@@ -216,7 +216,7 @@ typedef struct | |||
216 | #define SERIAL_HOOK_RING 0x85 | 216 | #define SERIAL_HOOK_RING 0x85 |
217 | #define SERIAL_HOOK_DETACH 0x8f | 217 | #define SERIAL_HOOK_DETACH 0x8f |
218 | unsigned char Flags; /* function refinements */ | 218 | unsigned char Flags; /* function refinements */ |
219 | /* parameters passed by the the ATTACH request */ | 219 | /* parameters passed by the ATTACH request */ |
220 | SERIAL_INT_CB InterruptHandler; /* called on each interrupt */ | 220 | SERIAL_INT_CB InterruptHandler; /* called on each interrupt */ |
221 | SERIAL_DPC_CB DeferredHandler; /* called on hook state changes */ | 221 | SERIAL_DPC_CB DeferredHandler; /* called on hook state changes */ |
222 | void *HandlerContext; /* context for both handlers */ | 222 | void *HandlerContext; /* context for both handlers */ |
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c index 99e70d4103b6..1f18f1993387 100644 --- a/drivers/isdn/hisax/hfc_usb.c +++ b/drivers/isdn/hisax/hfc_usb.c | |||
@@ -1217,11 +1217,11 @@ usb_init(hfcusb_data * hfc) | |||
1217 | /* aux = output, reset off */ | 1217 | /* aux = output, reset off */ |
1218 | write_usb(hfc, HFCUSB_CIRM, 0x10); | 1218 | write_usb(hfc, HFCUSB_CIRM, 0x10); |
1219 | 1219 | ||
1220 | /* set USB_SIZE to match the the wMaxPacketSize for INT or BULK transfers */ | 1220 | /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */ |
1221 | write_usb(hfc, HFCUSB_USB_SIZE, | 1221 | write_usb(hfc, HFCUSB_USB_SIZE, |
1222 | (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4)); | 1222 | (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4)); |
1223 | 1223 | ||
1224 | /* set USB_SIZE_I to match the the wMaxPacketSize for ISO transfers */ | 1224 | /* set USB_SIZE_I to match the wMaxPacketSize for ISO transfers */ |
1225 | write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size); | 1225 | write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size); |
1226 | 1226 | ||
1227 | /* enable PCM/GCI master mode */ | 1227 | /* enable PCM/GCI master mode */ |
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index c8b8cfa332bb..0d892600ff00 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -2889,7 +2889,9 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, | |||
2889 | 2889 | ||
2890 | switch (val) { | 2890 | switch (val) { |
2891 | case CPU_DOWN_PREPARE: | 2891 | case CPU_DOWN_PREPARE: |
2892 | case CPU_DOWN_PREPARE_FROZEN: | ||
2892 | case CPU_UP_CANCELED: | 2893 | case CPU_UP_CANCELED: |
2894 | case CPU_UP_CANCELED_FROZEN: | ||
2893 | printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n", | 2895 | printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n", |
2894 | cpu); | 2896 | cpu); |
2895 | decache_vcpus_on_cpu(cpu); | 2897 | decache_vcpus_on_cpu(cpu); |
@@ -2897,6 +2899,7 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, | |||
2897 | NULL, 0, 1); | 2899 | NULL, 0, 1); |
2898 | break; | 2900 | break; |
2899 | case CPU_ONLINE: | 2901 | case CPU_ONLINE: |
2902 | case CPU_ONLINE_FROZEN: | ||
2900 | printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n", | 2903 | printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n", |
2901 | cpu); | 2904 | cpu); |
2902 | smp_call_function_single(cpu, kvm_arch_ops->hardware_enable, | 2905 | smp_call_function_single(cpu, kvm_arch_ops->hardware_enable, |
diff --git a/drivers/leds/leds-h1940.c b/drivers/leds/leds-h1940.c index 1d49d2ade557..677c99325be5 100644 --- a/drivers/leds/leds-h1940.c +++ b/drivers/leds/leds-h1940.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/leds/h1940-leds.c | 2 | * drivers/leds/leds-h1940.c |
3 | * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org> | 3 | * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org> |
4 | * | 4 | * |
5 | * This file is subject to the terms and conditions of the GNU General Public | 5 | * This file is subject to the terms and conditions of the GNU General Public |
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig index a32c91e27b3c..58926da0ae18 100644 --- a/drivers/macintosh/Kconfig +++ b/drivers/macintosh/Kconfig | |||
@@ -237,7 +237,7 @@ config PMAC_RACKMETER | |||
237 | tristate "Support for Apple XServe front panel LEDs" | 237 | tristate "Support for Apple XServe front panel LEDs" |
238 | depends on PPC_PMAC | 238 | depends on PPC_PMAC |
239 | help | 239 | help |
240 | This driver procides some support to control the front panel | 240 | This driver provides some support to control the front panel |
241 | blue LEDs "vu-meter" of the XServer macs. | 241 | blue LEDs "vu-meter" of the XServer macs. |
242 | 242 | ||
243 | endif # MACINTOSH_DRIVERS | 243 | endif # MACINTOSH_DRIVERS |
diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c index da862e4632dd..67b8e9453b19 100644 --- a/drivers/mca/mca-bus.c +++ b/drivers/mca/mca-bus.c | |||
@@ -47,19 +47,25 @@ static int mca_bus_match (struct device *dev, struct device_driver *drv) | |||
47 | { | 47 | { |
48 | struct mca_device *mca_dev = to_mca_device (dev); | 48 | struct mca_device *mca_dev = to_mca_device (dev); |
49 | struct mca_driver *mca_drv = to_mca_driver (drv); | 49 | struct mca_driver *mca_drv = to_mca_driver (drv); |
50 | const short *mca_ids = mca_drv->id_table; | 50 | const unsigned short *mca_ids = mca_drv->id_table; |
51 | int i; | 51 | int i = 0; |
52 | 52 | ||
53 | if (!mca_ids) | 53 | if (mca_ids) { |
54 | return 0; | 54 | for(i = 0; mca_ids[i]; i++) { |
55 | 55 | if (mca_ids[i] == mca_dev->pos_id) { | |
56 | for(i = 0; mca_ids[i]; i++) { | 56 | mca_dev->index = i; |
57 | if (mca_ids[i] == mca_dev->pos_id) { | 57 | return 1; |
58 | mca_dev->index = i; | 58 | } |
59 | return 1; | ||
60 | } | 59 | } |
61 | } | 60 | } |
62 | 61 | /* If the integrated id is present, treat it as though it were an | |
62 | * additional id in the id_table (it can't be because by definition, | ||
63 | * integrated id's overflow a short */ | ||
64 | if (mca_drv->integrated_id && mca_dev->pos_id == | ||
65 | mca_drv->integrated_id) { | ||
66 | mca_dev->index = i; | ||
67 | return 1; | ||
68 | } | ||
63 | return 0; | 69 | return 0; |
64 | } | 70 | } |
65 | 71 | ||
diff --git a/drivers/mca/mca-driver.c b/drivers/mca/mca-driver.c index 2223466b3d8a..32cd39bcc715 100644 --- a/drivers/mca/mca-driver.c +++ b/drivers/mca/mca-driver.c | |||
@@ -36,12 +36,25 @@ int mca_register_driver(struct mca_driver *mca_drv) | |||
36 | mca_drv->driver.bus = &mca_bus_type; | 36 | mca_drv->driver.bus = &mca_bus_type; |
37 | if ((r = driver_register(&mca_drv->driver)) < 0) | 37 | if ((r = driver_register(&mca_drv->driver)) < 0) |
38 | return r; | 38 | return r; |
39 | mca_drv->integrated_id = 0; | ||
39 | } | 40 | } |
40 | 41 | ||
41 | return 0; | 42 | return 0; |
42 | } | 43 | } |
43 | EXPORT_SYMBOL(mca_register_driver); | 44 | EXPORT_SYMBOL(mca_register_driver); |
44 | 45 | ||
46 | int mca_register_driver_integrated(struct mca_driver *mca_driver, | ||
47 | int integrated_id) | ||
48 | { | ||
49 | int r = mca_register_driver(mca_driver); | ||
50 | |||
51 | if (!r) | ||
52 | mca_driver->integrated_id = integrated_id; | ||
53 | |||
54 | return r; | ||
55 | } | ||
56 | EXPORT_SYMBOL(mca_register_driver_integrated); | ||
57 | |||
45 | void mca_unregister_driver(struct mca_driver *mca_drv) | 58 | void mca_unregister_driver(struct mca_driver *mca_drv) |
46 | { | 59 | { |
47 | if (MCA_bus) | 60 | if (MCA_bus) |
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4540ade6b6b5..7df934d69134 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig | |||
@@ -262,6 +262,15 @@ config DM_MULTIPATH_EMC | |||
262 | ---help--- | 262 | ---help--- |
263 | Multipath support for EMC CX/AX series hardware. | 263 | Multipath support for EMC CX/AX series hardware. |
264 | 264 | ||
265 | config DM_DELAY | ||
266 | tristate "I/O delaying target (EXPERIMENTAL)" | ||
267 | depends on BLK_DEV_DM && EXPERIMENTAL | ||
268 | ---help--- | ||
269 | A target that delays reads and/or writes and can send | ||
270 | them to different devices. Useful for testing. | ||
271 | |||
272 | If unsure, say N. | ||
273 | |||
265 | endmenu | 274 | endmenu |
266 | 275 | ||
267 | endif | 276 | endif |
diff --git a/drivers/md/Makefile b/drivers/md/Makefile index 34957a68d921..38754084eac7 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile | |||
@@ -31,6 +31,7 @@ obj-$(CONFIG_MD_FAULTY) += faulty.o | |||
31 | obj-$(CONFIG_BLK_DEV_MD) += md-mod.o | 31 | obj-$(CONFIG_BLK_DEV_MD) += md-mod.o |
32 | obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o | 32 | obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o |
33 | obj-$(CONFIG_DM_CRYPT) += dm-crypt.o | 33 | obj-$(CONFIG_DM_CRYPT) += dm-crypt.o |
34 | obj-$(CONFIG_DM_DELAY) += dm-delay.o | ||
34 | obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o | 35 | obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o |
35 | obj-$(CONFIG_DM_MULTIPATH_EMC) += dm-emc.o | 36 | obj-$(CONFIG_DM_MULTIPATH_EMC) += dm-emc.o |
36 | obj-$(CONFIG_DM_SNAPSHOT) += dm-snapshot.o | 37 | obj-$(CONFIG_DM_SNAPSHOT) += dm-snapshot.o |
diff --git a/drivers/md/dm-bio-list.h b/drivers/md/dm-bio-list.h index da4349649f7f..c6be88826fae 100644 --- a/drivers/md/dm-bio-list.h +++ b/drivers/md/dm-bio-list.h | |||
@@ -8,17 +8,43 @@ | |||
8 | #define DM_BIO_LIST_H | 8 | #define DM_BIO_LIST_H |
9 | 9 | ||
10 | #include <linux/bio.h> | 10 | #include <linux/bio.h> |
11 | #include <linux/prefetch.h> | ||
11 | 12 | ||
12 | struct bio_list { | 13 | struct bio_list { |
13 | struct bio *head; | 14 | struct bio *head; |
14 | struct bio *tail; | 15 | struct bio *tail; |
15 | }; | 16 | }; |
16 | 17 | ||
18 | static inline int bio_list_empty(const struct bio_list *bl) | ||
19 | { | ||
20 | return bl->head == NULL; | ||
21 | } | ||
22 | |||
23 | #define BIO_LIST_INIT { .head = NULL, .tail = NULL } | ||
24 | |||
25 | #define BIO_LIST(bl) \ | ||
26 | struct bio_list bl = BIO_LIST_INIT | ||
27 | |||
17 | static inline void bio_list_init(struct bio_list *bl) | 28 | static inline void bio_list_init(struct bio_list *bl) |
18 | { | 29 | { |
19 | bl->head = bl->tail = NULL; | 30 | bl->head = bl->tail = NULL; |
20 | } | 31 | } |
21 | 32 | ||
33 | #define bio_list_for_each(bio, bl) \ | ||
34 | for (bio = (bl)->head; bio && ({ prefetch(bio->bi_next); 1; }); \ | ||
35 | bio = bio->bi_next) | ||
36 | |||
37 | static inline unsigned bio_list_size(const struct bio_list *bl) | ||
38 | { | ||
39 | unsigned sz = 0; | ||
40 | struct bio *bio; | ||
41 | |||
42 | bio_list_for_each(bio, bl) | ||
43 | sz++; | ||
44 | |||
45 | return sz; | ||
46 | } | ||
47 | |||
22 | static inline void bio_list_add(struct bio_list *bl, struct bio *bio) | 48 | static inline void bio_list_add(struct bio_list *bl, struct bio *bio) |
23 | { | 49 | { |
24 | bio->bi_next = NULL; | 50 | bio->bi_next = NULL; |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index d8121234c347..7b0fcfc9eaa5 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -33,7 +33,6 @@ | |||
33 | struct crypt_io { | 33 | struct crypt_io { |
34 | struct dm_target *target; | 34 | struct dm_target *target; |
35 | struct bio *base_bio; | 35 | struct bio *base_bio; |
36 | struct bio *first_clone; | ||
37 | struct work_struct work; | 36 | struct work_struct work; |
38 | atomic_t pending; | 37 | atomic_t pending; |
39 | int error; | 38 | int error; |
@@ -107,6 +106,8 @@ struct crypt_config { | |||
107 | 106 | ||
108 | static struct kmem_cache *_crypt_io_pool; | 107 | static struct kmem_cache *_crypt_io_pool; |
109 | 108 | ||
109 | static void clone_init(struct crypt_io *, struct bio *); | ||
110 | |||
110 | /* | 111 | /* |
111 | * Different IV generation algorithms: | 112 | * Different IV generation algorithms: |
112 | * | 113 | * |
@@ -120,6 +121,9 @@ static struct kmem_cache *_crypt_io_pool; | |||
120 | * benbi: the 64-bit "big-endian 'narrow block'-count", starting at 1 | 121 | * benbi: the 64-bit "big-endian 'narrow block'-count", starting at 1 |
121 | * (needed for LRW-32-AES and possible other narrow block modes) | 122 | * (needed for LRW-32-AES and possible other narrow block modes) |
122 | * | 123 | * |
124 | * null: the initial vector is always zero. Provides compatibility with | ||
125 | * obsolete loop_fish2 devices. Do not use for new devices. | ||
126 | * | ||
123 | * plumb: unimplemented, see: | 127 | * plumb: unimplemented, see: |
124 | * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454 | 128 | * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454 |
125 | */ | 129 | */ |
@@ -256,6 +260,13 @@ static int crypt_iv_benbi_gen(struct crypt_config *cc, u8 *iv, sector_t sector) | |||
256 | return 0; | 260 | return 0; |
257 | } | 261 | } |
258 | 262 | ||
263 | static int crypt_iv_null_gen(struct crypt_config *cc, u8 *iv, sector_t sector) | ||
264 | { | ||
265 | memset(iv, 0, cc->iv_size); | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
259 | static struct crypt_iv_operations crypt_iv_plain_ops = { | 270 | static struct crypt_iv_operations crypt_iv_plain_ops = { |
260 | .generator = crypt_iv_plain_gen | 271 | .generator = crypt_iv_plain_gen |
261 | }; | 272 | }; |
@@ -272,6 +283,10 @@ static struct crypt_iv_operations crypt_iv_benbi_ops = { | |||
272 | .generator = crypt_iv_benbi_gen | 283 | .generator = crypt_iv_benbi_gen |
273 | }; | 284 | }; |
274 | 285 | ||
286 | static struct crypt_iv_operations crypt_iv_null_ops = { | ||
287 | .generator = crypt_iv_null_gen | ||
288 | }; | ||
289 | |||
275 | static int | 290 | static int |
276 | crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out, | 291 | crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out, |
277 | struct scatterlist *in, unsigned int length, | 292 | struct scatterlist *in, unsigned int length, |
@@ -378,36 +393,21 @@ static int crypt_convert(struct crypt_config *cc, | |||
378 | * This should never violate the device limitations | 393 | * This should never violate the device limitations |
379 | * May return a smaller bio when running out of pages | 394 | * May return a smaller bio when running out of pages |
380 | */ | 395 | */ |
381 | static struct bio * | 396 | static struct bio *crypt_alloc_buffer(struct crypt_io *io, unsigned int size) |
382 | crypt_alloc_buffer(struct crypt_config *cc, unsigned int size, | ||
383 | struct bio *base_bio, unsigned int *bio_vec_idx) | ||
384 | { | 397 | { |
398 | struct crypt_config *cc = io->target->private; | ||
385 | struct bio *clone; | 399 | struct bio *clone; |
386 | unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; | 400 | unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; |
387 | gfp_t gfp_mask = GFP_NOIO | __GFP_HIGHMEM; | 401 | gfp_t gfp_mask = GFP_NOIO | __GFP_HIGHMEM; |
388 | unsigned int i; | 402 | unsigned int i; |
389 | 403 | ||
390 | if (base_bio) { | 404 | clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs); |
391 | clone = bio_alloc_bioset(GFP_NOIO, base_bio->bi_max_vecs, cc->bs); | ||
392 | __bio_clone(clone, base_bio); | ||
393 | } else | ||
394 | clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs); | ||
395 | |||
396 | if (!clone) | 405 | if (!clone) |
397 | return NULL; | 406 | return NULL; |
398 | 407 | ||
399 | clone->bi_destructor = dm_crypt_bio_destructor; | 408 | clone_init(io, clone); |
400 | |||
401 | /* if the last bio was not complete, continue where that one ended */ | ||
402 | clone->bi_idx = *bio_vec_idx; | ||
403 | clone->bi_vcnt = *bio_vec_idx; | ||
404 | clone->bi_size = 0; | ||
405 | clone->bi_flags &= ~(1 << BIO_SEG_VALID); | ||
406 | |||
407 | /* clone->bi_idx pages have already been allocated */ | ||
408 | size -= clone->bi_idx * PAGE_SIZE; | ||
409 | 409 | ||
410 | for (i = clone->bi_idx; i < nr_iovecs; i++) { | 410 | for (i = 0; i < nr_iovecs; i++) { |
411 | struct bio_vec *bv = bio_iovec_idx(clone, i); | 411 | struct bio_vec *bv = bio_iovec_idx(clone, i); |
412 | 412 | ||
413 | bv->bv_page = mempool_alloc(cc->page_pool, gfp_mask); | 413 | bv->bv_page = mempool_alloc(cc->page_pool, gfp_mask); |
@@ -419,7 +419,7 @@ crypt_alloc_buffer(struct crypt_config *cc, unsigned int size, | |||
419 | * return a partially allocated bio, the caller will then try | 419 | * return a partially allocated bio, the caller will then try |
420 | * to allocate additional bios while submitting this partial bio | 420 | * to allocate additional bios while submitting this partial bio |
421 | */ | 421 | */ |
422 | if ((i - clone->bi_idx) == (MIN_BIO_PAGES - 1)) | 422 | if (i == (MIN_BIO_PAGES - 1)) |
423 | gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT; | 423 | gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT; |
424 | 424 | ||
425 | bv->bv_offset = 0; | 425 | bv->bv_offset = 0; |
@@ -438,12 +438,6 @@ crypt_alloc_buffer(struct crypt_config *cc, unsigned int size, | |||
438 | return NULL; | 438 | return NULL; |
439 | } | 439 | } |
440 | 440 | ||
441 | /* | ||
442 | * Remember the last bio_vec allocated to be able | ||
443 | * to correctly continue after the splitting. | ||
444 | */ | ||
445 | *bio_vec_idx = clone->bi_vcnt; | ||
446 | |||
447 | return clone; | 441 | return clone; |
448 | } | 442 | } |
449 | 443 | ||
@@ -495,9 +489,6 @@ static void dec_pending(struct crypt_io *io, int error) | |||
495 | if (!atomic_dec_and_test(&io->pending)) | 489 | if (!atomic_dec_and_test(&io->pending)) |
496 | return; | 490 | return; |
497 | 491 | ||
498 | if (io->first_clone) | ||
499 | bio_put(io->first_clone); | ||
500 | |||
501 | bio_endio(io->base_bio, io->base_bio->bi_size, io->error); | 492 | bio_endio(io->base_bio, io->base_bio->bi_size, io->error); |
502 | 493 | ||
503 | mempool_free(io, cc->io_pool); | 494 | mempool_free(io, cc->io_pool); |
@@ -562,6 +553,7 @@ static void clone_init(struct crypt_io *io, struct bio *clone) | |||
562 | clone->bi_end_io = crypt_endio; | 553 | clone->bi_end_io = crypt_endio; |
563 | clone->bi_bdev = cc->dev->bdev; | 554 | clone->bi_bdev = cc->dev->bdev; |
564 | clone->bi_rw = io->base_bio->bi_rw; | 555 | clone->bi_rw = io->base_bio->bi_rw; |
556 | clone->bi_destructor = dm_crypt_bio_destructor; | ||
565 | } | 557 | } |
566 | 558 | ||
567 | static void process_read(struct crypt_io *io) | 559 | static void process_read(struct crypt_io *io) |
@@ -585,7 +577,6 @@ static void process_read(struct crypt_io *io) | |||
585 | } | 577 | } |
586 | 578 | ||
587 | clone_init(io, clone); | 579 | clone_init(io, clone); |
588 | clone->bi_destructor = dm_crypt_bio_destructor; | ||
589 | clone->bi_idx = 0; | 580 | clone->bi_idx = 0; |
590 | clone->bi_vcnt = bio_segments(base_bio); | 581 | clone->bi_vcnt = bio_segments(base_bio); |
591 | clone->bi_size = base_bio->bi_size; | 582 | clone->bi_size = base_bio->bi_size; |
@@ -604,7 +595,6 @@ static void process_write(struct crypt_io *io) | |||
604 | struct convert_context ctx; | 595 | struct convert_context ctx; |
605 | unsigned remaining = base_bio->bi_size; | 596 | unsigned remaining = base_bio->bi_size; |
606 | sector_t sector = base_bio->bi_sector - io->target->begin; | 597 | sector_t sector = base_bio->bi_sector - io->target->begin; |
607 | unsigned bvec_idx = 0; | ||
608 | 598 | ||
609 | atomic_inc(&io->pending); | 599 | atomic_inc(&io->pending); |
610 | 600 | ||
@@ -615,14 +605,14 @@ static void process_write(struct crypt_io *io) | |||
615 | * so repeat the whole process until all the data can be handled. | 605 | * so repeat the whole process until all the data can be handled. |
616 | */ | 606 | */ |
617 | while (remaining) { | 607 | while (remaining) { |
618 | clone = crypt_alloc_buffer(cc, base_bio->bi_size, | 608 | clone = crypt_alloc_buffer(io, remaining); |
619 | io->first_clone, &bvec_idx); | ||
620 | if (unlikely(!clone)) { | 609 | if (unlikely(!clone)) { |
621 | dec_pending(io, -ENOMEM); | 610 | dec_pending(io, -ENOMEM); |
622 | return; | 611 | return; |
623 | } | 612 | } |
624 | 613 | ||
625 | ctx.bio_out = clone; | 614 | ctx.bio_out = clone; |
615 | ctx.idx_out = 0; | ||
626 | 616 | ||
627 | if (unlikely(crypt_convert(cc, &ctx) < 0)) { | 617 | if (unlikely(crypt_convert(cc, &ctx) < 0)) { |
628 | crypt_free_buffer_pages(cc, clone, clone->bi_size); | 618 | crypt_free_buffer_pages(cc, clone, clone->bi_size); |
@@ -631,31 +621,26 @@ static void process_write(struct crypt_io *io) | |||
631 | return; | 621 | return; |
632 | } | 622 | } |
633 | 623 | ||
634 | clone_init(io, clone); | 624 | /* crypt_convert should have filled the clone bio */ |
635 | clone->bi_sector = cc->start + sector; | 625 | BUG_ON(ctx.idx_out < clone->bi_vcnt); |
636 | |||
637 | if (!io->first_clone) { | ||
638 | /* | ||
639 | * hold a reference to the first clone, because it | ||
640 | * holds the bio_vec array and that can't be freed | ||
641 | * before all other clones are released | ||
642 | */ | ||
643 | bio_get(clone); | ||
644 | io->first_clone = clone; | ||
645 | } | ||
646 | 626 | ||
627 | clone->bi_sector = cc->start + sector; | ||
647 | remaining -= clone->bi_size; | 628 | remaining -= clone->bi_size; |
648 | sector += bio_sectors(clone); | 629 | sector += bio_sectors(clone); |
649 | 630 | ||
650 | /* prevent bio_put of first_clone */ | 631 | /* Grab another reference to the io struct |
632 | * before we kick off the request */ | ||
651 | if (remaining) | 633 | if (remaining) |
652 | atomic_inc(&io->pending); | 634 | atomic_inc(&io->pending); |
653 | 635 | ||
654 | generic_make_request(clone); | 636 | generic_make_request(clone); |
655 | 637 | ||
638 | /* Do not reference clone after this - it | ||
639 | * may be gone already. */ | ||
640 | |||
656 | /* out of memory -> run queues */ | 641 | /* out of memory -> run queues */ |
657 | if (remaining) | 642 | if (remaining) |
658 | congestion_wait(bio_data_dir(clone), HZ/100); | 643 | congestion_wait(WRITE, HZ/100); |
659 | } | 644 | } |
660 | } | 645 | } |
661 | 646 | ||
@@ -832,6 +817,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
832 | cc->iv_gen_ops = &crypt_iv_essiv_ops; | 817 | cc->iv_gen_ops = &crypt_iv_essiv_ops; |
833 | else if (strcmp(ivmode, "benbi") == 0) | 818 | else if (strcmp(ivmode, "benbi") == 0) |
834 | cc->iv_gen_ops = &crypt_iv_benbi_ops; | 819 | cc->iv_gen_ops = &crypt_iv_benbi_ops; |
820 | else if (strcmp(ivmode, "null") == 0) | ||
821 | cc->iv_gen_ops = &crypt_iv_null_ops; | ||
835 | else { | 822 | else { |
836 | ti->error = "Invalid IV mode"; | 823 | ti->error = "Invalid IV mode"; |
837 | goto bad2; | 824 | goto bad2; |
@@ -954,10 +941,12 @@ static int crypt_map(struct dm_target *ti, struct bio *bio, | |||
954 | struct crypt_config *cc = ti->private; | 941 | struct crypt_config *cc = ti->private; |
955 | struct crypt_io *io; | 942 | struct crypt_io *io; |
956 | 943 | ||
944 | if (bio_barrier(bio)) | ||
945 | return -EOPNOTSUPP; | ||
946 | |||
957 | io = mempool_alloc(cc->io_pool, GFP_NOIO); | 947 | io = mempool_alloc(cc->io_pool, GFP_NOIO); |
958 | io->target = ti; | 948 | io->target = ti; |
959 | io->base_bio = bio; | 949 | io->base_bio = bio; |
960 | io->first_clone = NULL; | ||
961 | io->error = io->post_process = 0; | 950 | io->error = io->post_process = 0; |
962 | atomic_set(&io->pending, 0); | 951 | atomic_set(&io->pending, 0); |
963 | kcryptd_queue_io(io); | 952 | kcryptd_queue_io(io); |
@@ -1057,7 +1046,7 @@ error: | |||
1057 | 1046 | ||
1058 | static struct target_type crypt_target = { | 1047 | static struct target_type crypt_target = { |
1059 | .name = "crypt", | 1048 | .name = "crypt", |
1060 | .version= {1, 3, 0}, | 1049 | .version= {1, 5, 0}, |
1061 | .module = THIS_MODULE, | 1050 | .module = THIS_MODULE, |
1062 | .ctr = crypt_ctr, | 1051 | .ctr = crypt_ctr, |
1063 | .dtr = crypt_dtr, | 1052 | .dtr = crypt_dtr, |
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c new file mode 100644 index 000000000000..52c7cf9e5803 --- /dev/null +++ b/drivers/md/dm-delay.c | |||
@@ -0,0 +1,383 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005-2007 Red Hat GmbH | ||
3 | * | ||
4 | * A target that delays reads and/or writes and can send | ||
5 | * them to different devices. | ||
6 | * | ||
7 | * This file is released under the GPL. | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/blkdev.h> | ||
13 | #include <linux/bio.h> | ||
14 | #include <linux/slab.h> | ||
15 | |||
16 | #include "dm.h" | ||
17 | #include "dm-bio-list.h" | ||
18 | |||
19 | #define DM_MSG_PREFIX "delay" | ||
20 | |||
21 | struct delay_c { | ||
22 | struct timer_list delay_timer; | ||
23 | struct semaphore timer_lock; | ||
24 | struct work_struct flush_expired_bios; | ||
25 | struct list_head delayed_bios; | ||
26 | atomic_t may_delay; | ||
27 | mempool_t *delayed_pool; | ||
28 | |||
29 | struct dm_dev *dev_read; | ||
30 | sector_t start_read; | ||
31 | unsigned read_delay; | ||
32 | unsigned reads; | ||
33 | |||
34 | struct dm_dev *dev_write; | ||
35 | sector_t start_write; | ||
36 | unsigned write_delay; | ||
37 | unsigned writes; | ||
38 | }; | ||
39 | |||
40 | struct delay_info { | ||
41 | struct delay_c *context; | ||
42 | struct list_head list; | ||
43 | struct bio *bio; | ||
44 | unsigned long expires; | ||
45 | }; | ||
46 | |||
47 | static DEFINE_MUTEX(delayed_bios_lock); | ||
48 | |||
49 | static struct workqueue_struct *kdelayd_wq; | ||
50 | static struct kmem_cache *delayed_cache; | ||
51 | |||
52 | static void handle_delayed_timer(unsigned long data) | ||
53 | { | ||
54 | struct delay_c *dc = (struct delay_c *)data; | ||
55 | |||
56 | queue_work(kdelayd_wq, &dc->flush_expired_bios); | ||
57 | } | ||
58 | |||
59 | static void queue_timeout(struct delay_c *dc, unsigned long expires) | ||
60 | { | ||
61 | down(&dc->timer_lock); | ||
62 | |||
63 | if (!timer_pending(&dc->delay_timer) || expires < dc->delay_timer.expires) | ||
64 | mod_timer(&dc->delay_timer, expires); | ||
65 | |||
66 | up(&dc->timer_lock); | ||
67 | } | ||
68 | |||
69 | static void flush_bios(struct bio *bio) | ||
70 | { | ||
71 | struct bio *n; | ||
72 | |||
73 | while (bio) { | ||
74 | n = bio->bi_next; | ||
75 | bio->bi_next = NULL; | ||
76 | generic_make_request(bio); | ||
77 | bio = n; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | static struct bio *flush_delayed_bios(struct delay_c *dc, int flush_all) | ||
82 | { | ||
83 | struct delay_info *delayed, *next; | ||
84 | unsigned long next_expires = 0; | ||
85 | int start_timer = 0; | ||
86 | BIO_LIST(flush_bios); | ||
87 | |||
88 | mutex_lock(&delayed_bios_lock); | ||
89 | list_for_each_entry_safe(delayed, next, &dc->delayed_bios, list) { | ||
90 | if (flush_all || time_after_eq(jiffies, delayed->expires)) { | ||
91 | list_del(&delayed->list); | ||
92 | bio_list_add(&flush_bios, delayed->bio); | ||
93 | if ((bio_data_dir(delayed->bio) == WRITE)) | ||
94 | delayed->context->writes--; | ||
95 | else | ||
96 | delayed->context->reads--; | ||
97 | mempool_free(delayed, dc->delayed_pool); | ||
98 | continue; | ||
99 | } | ||
100 | |||
101 | if (!start_timer) { | ||
102 | start_timer = 1; | ||
103 | next_expires = delayed->expires; | ||
104 | } else | ||
105 | next_expires = min(next_expires, delayed->expires); | ||
106 | } | ||
107 | |||
108 | mutex_unlock(&delayed_bios_lock); | ||
109 | |||
110 | if (start_timer) | ||
111 | queue_timeout(dc, next_expires); | ||
112 | |||
113 | return bio_list_get(&flush_bios); | ||
114 | } | ||
115 | |||
116 | static void flush_expired_bios(struct work_struct *work) | ||
117 | { | ||
118 | struct delay_c *dc; | ||
119 | |||
120 | dc = container_of(work, struct delay_c, flush_expired_bios); | ||
121 | flush_bios(flush_delayed_bios(dc, 0)); | ||
122 | } | ||
123 | |||
124 | /* | ||
125 | * Mapping parameters: | ||
126 | * <device> <offset> <delay> [<write_device> <write_offset> <write_delay>] | ||
127 | * | ||
128 | * With separate write parameters, the first set is only used for reads. | ||
129 | * Delays are specified in milliseconds. | ||
130 | */ | ||
131 | static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv) | ||
132 | { | ||
133 | struct delay_c *dc; | ||
134 | unsigned long long tmpll; | ||
135 | |||
136 | if (argc != 3 && argc != 6) { | ||
137 | ti->error = "requires exactly 3 or 6 arguments"; | ||
138 | return -EINVAL; | ||
139 | } | ||
140 | |||
141 | dc = kmalloc(sizeof(*dc), GFP_KERNEL); | ||
142 | if (!dc) { | ||
143 | ti->error = "Cannot allocate context"; | ||
144 | return -ENOMEM; | ||
145 | } | ||
146 | |||
147 | dc->reads = dc->writes = 0; | ||
148 | |||
149 | if (sscanf(argv[1], "%llu", &tmpll) != 1) { | ||
150 | ti->error = "Invalid device sector"; | ||
151 | goto bad; | ||
152 | } | ||
153 | dc->start_read = tmpll; | ||
154 | |||
155 | if (sscanf(argv[2], "%u", &dc->read_delay) != 1) { | ||
156 | ti->error = "Invalid delay"; | ||
157 | goto bad; | ||
158 | } | ||
159 | |||
160 | if (dm_get_device(ti, argv[0], dc->start_read, ti->len, | ||
161 | dm_table_get_mode(ti->table), &dc->dev_read)) { | ||
162 | ti->error = "Device lookup failed"; | ||
163 | goto bad; | ||
164 | } | ||
165 | |||
166 | if (argc == 3) { | ||
167 | dc->dev_write = NULL; | ||
168 | goto out; | ||
169 | } | ||
170 | |||
171 | if (sscanf(argv[4], "%llu", &tmpll) != 1) { | ||
172 | ti->error = "Invalid write device sector"; | ||
173 | goto bad; | ||
174 | } | ||
175 | dc->start_write = tmpll; | ||
176 | |||
177 | if (sscanf(argv[5], "%u", &dc->write_delay) != 1) { | ||
178 | ti->error = "Invalid write delay"; | ||
179 | goto bad; | ||
180 | } | ||
181 | |||
182 | if (dm_get_device(ti, argv[3], dc->start_write, ti->len, | ||
183 | dm_table_get_mode(ti->table), &dc->dev_write)) { | ||
184 | ti->error = "Write device lookup failed"; | ||
185 | dm_put_device(ti, dc->dev_read); | ||
186 | goto bad; | ||
187 | } | ||
188 | |||
189 | out: | ||
190 | dc->delayed_pool = mempool_create_slab_pool(128, delayed_cache); | ||
191 | if (!dc->delayed_pool) { | ||
192 | DMERR("Couldn't create delayed bio pool."); | ||
193 | goto bad; | ||
194 | } | ||
195 | |||
196 | init_timer(&dc->delay_timer); | ||
197 | dc->delay_timer.function = handle_delayed_timer; | ||
198 | dc->delay_timer.data = (unsigned long)dc; | ||
199 | |||
200 | INIT_WORK(&dc->flush_expired_bios, flush_expired_bios); | ||
201 | INIT_LIST_HEAD(&dc->delayed_bios); | ||
202 | init_MUTEX(&dc->timer_lock); | ||
203 | atomic_set(&dc->may_delay, 1); | ||
204 | |||
205 | ti->private = dc; | ||
206 | return 0; | ||
207 | |||
208 | bad: | ||
209 | kfree(dc); | ||
210 | return -EINVAL; | ||
211 | } | ||
212 | |||
213 | static void delay_dtr(struct dm_target *ti) | ||
214 | { | ||
215 | struct delay_c *dc = ti->private; | ||
216 | |||
217 | flush_workqueue(kdelayd_wq); | ||
218 | |||
219 | dm_put_device(ti, dc->dev_read); | ||
220 | |||
221 | if (dc->dev_write) | ||
222 | dm_put_device(ti, dc->dev_write); | ||
223 | |||
224 | mempool_destroy(dc->delayed_pool); | ||
225 | kfree(dc); | ||
226 | } | ||
227 | |||
228 | static int delay_bio(struct delay_c *dc, int delay, struct bio *bio) | ||
229 | { | ||
230 | struct delay_info *delayed; | ||
231 | unsigned long expires = 0; | ||
232 | |||
233 | if (!delay || !atomic_read(&dc->may_delay)) | ||
234 | return 1; | ||
235 | |||
236 | delayed = mempool_alloc(dc->delayed_pool, GFP_NOIO); | ||
237 | |||
238 | delayed->context = dc; | ||
239 | delayed->bio = bio; | ||
240 | delayed->expires = expires = jiffies + (delay * HZ / 1000); | ||
241 | |||
242 | mutex_lock(&delayed_bios_lock); | ||
243 | |||
244 | if (bio_data_dir(bio) == WRITE) | ||
245 | dc->writes++; | ||
246 | else | ||
247 | dc->reads++; | ||
248 | |||
249 | list_add_tail(&delayed->list, &dc->delayed_bios); | ||
250 | |||
251 | mutex_unlock(&delayed_bios_lock); | ||
252 | |||
253 | queue_timeout(dc, expires); | ||
254 | |||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | static void delay_presuspend(struct dm_target *ti) | ||
259 | { | ||
260 | struct delay_c *dc = ti->private; | ||
261 | |||
262 | atomic_set(&dc->may_delay, 0); | ||
263 | del_timer_sync(&dc->delay_timer); | ||
264 | flush_bios(flush_delayed_bios(dc, 1)); | ||
265 | } | ||
266 | |||
267 | static void delay_resume(struct dm_target *ti) | ||
268 | { | ||
269 | struct delay_c *dc = ti->private; | ||
270 | |||
271 | atomic_set(&dc->may_delay, 1); | ||
272 | } | ||
273 | |||
274 | static int delay_map(struct dm_target *ti, struct bio *bio, | ||
275 | union map_info *map_context) | ||
276 | { | ||
277 | struct delay_c *dc = ti->private; | ||
278 | |||
279 | if ((bio_data_dir(bio) == WRITE) && (dc->dev_write)) { | ||
280 | bio->bi_bdev = dc->dev_write->bdev; | ||
281 | bio->bi_sector = dc->start_write + | ||
282 | (bio->bi_sector - ti->begin); | ||
283 | |||
284 | return delay_bio(dc, dc->write_delay, bio); | ||
285 | } | ||
286 | |||
287 | bio->bi_bdev = dc->dev_read->bdev; | ||
288 | bio->bi_sector = dc->start_read + | ||
289 | (bio->bi_sector - ti->begin); | ||
290 | |||
291 | return delay_bio(dc, dc->read_delay, bio); | ||
292 | } | ||
293 | |||
294 | static int delay_status(struct dm_target *ti, status_type_t type, | ||
295 | char *result, unsigned maxlen) | ||
296 | { | ||
297 | struct delay_c *dc = ti->private; | ||
298 | int sz = 0; | ||
299 | |||
300 | switch (type) { | ||
301 | case STATUSTYPE_INFO: | ||
302 | DMEMIT("%u %u", dc->reads, dc->writes); | ||
303 | break; | ||
304 | |||
305 | case STATUSTYPE_TABLE: | ||
306 | DMEMIT("%s %llu %u", dc->dev_read->name, | ||
307 | (unsigned long long) dc->start_read, | ||
308 | dc->read_delay); | ||
309 | if (dc->dev_write) | ||
310 | DMEMIT("%s %llu %u", dc->dev_write->name, | ||
311 | (unsigned long long) dc->start_write, | ||
312 | dc->write_delay); | ||
313 | break; | ||
314 | } | ||
315 | |||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | static struct target_type delay_target = { | ||
320 | .name = "delay", | ||
321 | .version = {1, 0, 2}, | ||
322 | .module = THIS_MODULE, | ||
323 | .ctr = delay_ctr, | ||
324 | .dtr = delay_dtr, | ||
325 | .map = delay_map, | ||
326 | .presuspend = delay_presuspend, | ||
327 | .resume = delay_resume, | ||
328 | .status = delay_status, | ||
329 | }; | ||
330 | |||
331 | static int __init dm_delay_init(void) | ||
332 | { | ||
333 | int r = -ENOMEM; | ||
334 | |||
335 | kdelayd_wq = create_workqueue("kdelayd"); | ||
336 | if (!kdelayd_wq) { | ||
337 | DMERR("Couldn't start kdelayd"); | ||
338 | goto bad_queue; | ||
339 | } | ||
340 | |||
341 | delayed_cache = kmem_cache_create("dm-delay", | ||
342 | sizeof(struct delay_info), | ||
343 | __alignof__(struct delay_info), | ||
344 | 0, NULL, NULL); | ||
345 | if (!delayed_cache) { | ||
346 | DMERR("Couldn't create delayed bio cache."); | ||
347 | goto bad_memcache; | ||
348 | } | ||
349 | |||
350 | r = dm_register_target(&delay_target); | ||
351 | if (r < 0) { | ||
352 | DMERR("register failed %d", r); | ||
353 | goto bad_register; | ||
354 | } | ||
355 | |||
356 | return 0; | ||
357 | |||
358 | bad_register: | ||
359 | kmem_cache_destroy(delayed_cache); | ||
360 | bad_memcache: | ||
361 | destroy_workqueue(kdelayd_wq); | ||
362 | bad_queue: | ||
363 | return r; | ||
364 | } | ||
365 | |||
366 | static void __exit dm_delay_exit(void) | ||
367 | { | ||
368 | int r = dm_unregister_target(&delay_target); | ||
369 | |||
370 | if (r < 0) | ||
371 | DMERR("unregister failed %d", r); | ||
372 | |||
373 | kmem_cache_destroy(delayed_cache); | ||
374 | destroy_workqueue(kdelayd_wq); | ||
375 | } | ||
376 | |||
377 | /* Module hooks */ | ||
378 | module_init(dm_delay_init); | ||
379 | module_exit(dm_delay_exit); | ||
380 | |||
381 | MODULE_DESCRIPTION(DM_NAME " delay target"); | ||
382 | MODULE_AUTHOR("Heinz Mauelshagen <mauelshagen@redhat.com>"); | ||
383 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c index 99cdffa7fbfe..07e0a0c84f6e 100644 --- a/drivers/md/dm-exception-store.c +++ b/drivers/md/dm-exception-store.c | |||
@@ -1,7 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * dm-snapshot.c | 2 | * dm-exception-store.c |
3 | * | 3 | * |
4 | * Copyright (C) 2001-2002 Sistina Software (UK) Limited. | 4 | * Copyright (C) 2001-2002 Sistina Software (UK) Limited. |
5 | * Copyright (C) 2006 Red Hat GmbH | ||
5 | * | 6 | * |
6 | * This file is released under the GPL. | 7 | * This file is released under the GPL. |
7 | */ | 8 | */ |
@@ -123,6 +124,7 @@ struct pstore { | |||
123 | atomic_t pending_count; | 124 | atomic_t pending_count; |
124 | uint32_t callback_count; | 125 | uint32_t callback_count; |
125 | struct commit_callback *callbacks; | 126 | struct commit_callback *callbacks; |
127 | struct dm_io_client *io_client; | ||
126 | }; | 128 | }; |
127 | 129 | ||
128 | static inline unsigned int sectors_to_pages(unsigned int sectors) | 130 | static inline unsigned int sectors_to_pages(unsigned int sectors) |
@@ -159,14 +161,20 @@ static void free_area(struct pstore *ps) | |||
159 | */ | 161 | */ |
160 | static int chunk_io(struct pstore *ps, uint32_t chunk, int rw) | 162 | static int chunk_io(struct pstore *ps, uint32_t chunk, int rw) |
161 | { | 163 | { |
162 | struct io_region where; | 164 | struct io_region where = { |
163 | unsigned long bits; | 165 | .bdev = ps->snap->cow->bdev, |
164 | 166 | .sector = ps->snap->chunk_size * chunk, | |
165 | where.bdev = ps->snap->cow->bdev; | 167 | .count = ps->snap->chunk_size, |
166 | where.sector = ps->snap->chunk_size * chunk; | 168 | }; |
167 | where.count = ps->snap->chunk_size; | 169 | struct dm_io_request io_req = { |
168 | 170 | .bi_rw = rw, | |
169 | return dm_io_sync_vm(1, &where, rw, ps->area, &bits); | 171 | .mem.type = DM_IO_VMA, |
172 | .mem.ptr.vma = ps->area, | ||
173 | .client = ps->io_client, | ||
174 | .notify.fn = NULL, | ||
175 | }; | ||
176 | |||
177 | return dm_io(&io_req, 1, &where, NULL); | ||
170 | } | 178 | } |
171 | 179 | ||
172 | /* | 180 | /* |
@@ -213,17 +221,18 @@ static int read_header(struct pstore *ps, int *new_snapshot) | |||
213 | chunk_size_supplied = 0; | 221 | chunk_size_supplied = 0; |
214 | } | 222 | } |
215 | 223 | ||
216 | r = dm_io_get(sectors_to_pages(ps->snap->chunk_size)); | 224 | ps->io_client = dm_io_client_create(sectors_to_pages(ps->snap-> |
217 | if (r) | 225 | chunk_size)); |
218 | return r; | 226 | if (IS_ERR(ps->io_client)) |
227 | return PTR_ERR(ps->io_client); | ||
219 | 228 | ||
220 | r = alloc_area(ps); | 229 | r = alloc_area(ps); |
221 | if (r) | 230 | if (r) |
222 | goto bad1; | 231 | return r; |
223 | 232 | ||
224 | r = chunk_io(ps, 0, READ); | 233 | r = chunk_io(ps, 0, READ); |
225 | if (r) | 234 | if (r) |
226 | goto bad2; | 235 | goto bad; |
227 | 236 | ||
228 | dh = (struct disk_header *) ps->area; | 237 | dh = (struct disk_header *) ps->area; |
229 | 238 | ||
@@ -235,7 +244,7 @@ static int read_header(struct pstore *ps, int *new_snapshot) | |||
235 | if (le32_to_cpu(dh->magic) != SNAP_MAGIC) { | 244 | if (le32_to_cpu(dh->magic) != SNAP_MAGIC) { |
236 | DMWARN("Invalid or corrupt snapshot"); | 245 | DMWARN("Invalid or corrupt snapshot"); |
237 | r = -ENXIO; | 246 | r = -ENXIO; |
238 | goto bad2; | 247 | goto bad; |
239 | } | 248 | } |
240 | 249 | ||
241 | *new_snapshot = 0; | 250 | *new_snapshot = 0; |
@@ -252,27 +261,22 @@ static int read_header(struct pstore *ps, int *new_snapshot) | |||
252 | (unsigned long long)ps->snap->chunk_size); | 261 | (unsigned long long)ps->snap->chunk_size); |
253 | 262 | ||
254 | /* We had a bogus chunk_size. Fix stuff up. */ | 263 | /* We had a bogus chunk_size. Fix stuff up. */ |
255 | dm_io_put(sectors_to_pages(ps->snap->chunk_size)); | ||
256 | free_area(ps); | 264 | free_area(ps); |
257 | 265 | ||
258 | ps->snap->chunk_size = chunk_size; | 266 | ps->snap->chunk_size = chunk_size; |
259 | ps->snap->chunk_mask = chunk_size - 1; | 267 | ps->snap->chunk_mask = chunk_size - 1; |
260 | ps->snap->chunk_shift = ffs(chunk_size) - 1; | 268 | ps->snap->chunk_shift = ffs(chunk_size) - 1; |
261 | 269 | ||
262 | r = dm_io_get(sectors_to_pages(chunk_size)); | 270 | r = dm_io_client_resize(sectors_to_pages(ps->snap->chunk_size), |
271 | ps->io_client); | ||
263 | if (r) | 272 | if (r) |
264 | return r; | 273 | return r; |
265 | 274 | ||
266 | r = alloc_area(ps); | 275 | r = alloc_area(ps); |
267 | if (r) | 276 | return r; |
268 | goto bad1; | ||
269 | |||
270 | return 0; | ||
271 | 277 | ||
272 | bad2: | 278 | bad: |
273 | free_area(ps); | 279 | free_area(ps); |
274 | bad1: | ||
275 | dm_io_put(sectors_to_pages(ps->snap->chunk_size)); | ||
276 | return r; | 280 | return r; |
277 | } | 281 | } |
278 | 282 | ||
@@ -405,7 +409,7 @@ static void persistent_destroy(struct exception_store *store) | |||
405 | { | 409 | { |
406 | struct pstore *ps = get_info(store); | 410 | struct pstore *ps = get_info(store); |
407 | 411 | ||
408 | dm_io_put(sectors_to_pages(ps->snap->chunk_size)); | 412 | dm_io_client_destroy(ps->io_client); |
409 | vfree(ps->callbacks); | 413 | vfree(ps->callbacks); |
410 | free_area(ps); | 414 | free_area(ps); |
411 | kfree(ps); | 415 | kfree(ps); |
diff --git a/drivers/md/dm-hw-handler.h b/drivers/md/dm-hw-handler.h index 32eff28e4adc..e0832e6fcf36 100644 --- a/drivers/md/dm-hw-handler.h +++ b/drivers/md/dm-hw-handler.h | |||
@@ -16,6 +16,7 @@ | |||
16 | struct hw_handler_type; | 16 | struct hw_handler_type; |
17 | struct hw_handler { | 17 | struct hw_handler { |
18 | struct hw_handler_type *type; | 18 | struct hw_handler_type *type; |
19 | struct mapped_device *md; | ||
19 | void *context; | 20 | void *context; |
20 | }; | 21 | }; |
21 | 22 | ||
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index 8bdc8a87b249..352c6fbeac53 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 Sistina Software | 2 | * Copyright (C) 2003 Sistina Software |
3 | * Copyright (C) 2006 Red Hat GmbH | ||
3 | * | 4 | * |
4 | * This file is released under the GPL. | 5 | * This file is released under the GPL. |
5 | */ | 6 | */ |
@@ -12,13 +13,17 @@ | |||
12 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
13 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
14 | 15 | ||
15 | static struct bio_set *_bios; | 16 | struct dm_io_client { |
17 | mempool_t *pool; | ||
18 | struct bio_set *bios; | ||
19 | }; | ||
16 | 20 | ||
17 | /* FIXME: can we shrink this ? */ | 21 | /* FIXME: can we shrink this ? */ |
18 | struct io { | 22 | struct io { |
19 | unsigned long error; | 23 | unsigned long error; |
20 | atomic_t count; | 24 | atomic_t count; |
21 | struct task_struct *sleeper; | 25 | struct task_struct *sleeper; |
26 | struct dm_io_client *client; | ||
22 | io_notify_fn callback; | 27 | io_notify_fn callback; |
23 | void *context; | 28 | void *context; |
24 | }; | 29 | }; |
@@ -26,63 +31,58 @@ struct io { | |||
26 | /* | 31 | /* |
27 | * io contexts are only dynamically allocated for asynchronous | 32 | * io contexts are only dynamically allocated for asynchronous |
28 | * io. Since async io is likely to be the majority of io we'll | 33 | * io. Since async io is likely to be the majority of io we'll |
29 | * have the same number of io contexts as buffer heads ! (FIXME: | 34 | * have the same number of io contexts as bios! (FIXME: must reduce this). |
30 | * must reduce this). | ||
31 | */ | 35 | */ |
32 | static unsigned _num_ios; | ||
33 | static mempool_t *_io_pool; | ||
34 | 36 | ||
35 | static unsigned int pages_to_ios(unsigned int pages) | 37 | static unsigned int pages_to_ios(unsigned int pages) |
36 | { | 38 | { |
37 | return 4 * pages; /* too many ? */ | 39 | return 4 * pages; /* too many ? */ |
38 | } | 40 | } |
39 | 41 | ||
40 | static int resize_pool(unsigned int new_ios) | 42 | /* |
43 | * Create a client with mempool and bioset. | ||
44 | */ | ||
45 | struct dm_io_client *dm_io_client_create(unsigned num_pages) | ||
41 | { | 46 | { |
42 | int r = 0; | 47 | unsigned ios = pages_to_ios(num_pages); |
43 | 48 | struct dm_io_client *client; | |
44 | if (_io_pool) { | ||
45 | if (new_ios == 0) { | ||
46 | /* free off the pool */ | ||
47 | mempool_destroy(_io_pool); | ||
48 | _io_pool = NULL; | ||
49 | bioset_free(_bios); | ||
50 | |||
51 | } else { | ||
52 | /* resize the pool */ | ||
53 | r = mempool_resize(_io_pool, new_ios, GFP_KERNEL); | ||
54 | } | ||
55 | 49 | ||
56 | } else { | 50 | client = kmalloc(sizeof(*client), GFP_KERNEL); |
57 | /* create new pool */ | 51 | if (!client) |
58 | _io_pool = mempool_create_kmalloc_pool(new_ios, | 52 | return ERR_PTR(-ENOMEM); |
59 | sizeof(struct io)); | 53 | |
60 | if (!_io_pool) | 54 | client->pool = mempool_create_kmalloc_pool(ios, sizeof(struct io)); |
61 | return -ENOMEM; | 55 | if (!client->pool) |
62 | 56 | goto bad; | |
63 | _bios = bioset_create(16, 16); | ||
64 | if (!_bios) { | ||
65 | mempool_destroy(_io_pool); | ||
66 | _io_pool = NULL; | ||
67 | return -ENOMEM; | ||
68 | } | ||
69 | } | ||
70 | 57 | ||
71 | if (!r) | 58 | client->bios = bioset_create(16, 16); |
72 | _num_ios = new_ios; | 59 | if (!client->bios) |
60 | goto bad; | ||
73 | 61 | ||
74 | return r; | 62 | return client; |
63 | |||
64 | bad: | ||
65 | if (client->pool) | ||
66 | mempool_destroy(client->pool); | ||
67 | kfree(client); | ||
68 | return ERR_PTR(-ENOMEM); | ||
75 | } | 69 | } |
70 | EXPORT_SYMBOL(dm_io_client_create); | ||
76 | 71 | ||
77 | int dm_io_get(unsigned int num_pages) | 72 | int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client) |
78 | { | 73 | { |
79 | return resize_pool(_num_ios + pages_to_ios(num_pages)); | 74 | return mempool_resize(client->pool, pages_to_ios(num_pages), |
75 | GFP_KERNEL); | ||
80 | } | 76 | } |
77 | EXPORT_SYMBOL(dm_io_client_resize); | ||
81 | 78 | ||
82 | void dm_io_put(unsigned int num_pages) | 79 | void dm_io_client_destroy(struct dm_io_client *client) |
83 | { | 80 | { |
84 | resize_pool(_num_ios - pages_to_ios(num_pages)); | 81 | mempool_destroy(client->pool); |
82 | bioset_free(client->bios); | ||
83 | kfree(client); | ||
85 | } | 84 | } |
85 | EXPORT_SYMBOL(dm_io_client_destroy); | ||
86 | 86 | ||
87 | /*----------------------------------------------------------------- | 87 | /*----------------------------------------------------------------- |
88 | * We need to keep track of which region a bio is doing io for. | 88 | * We need to keep track of which region a bio is doing io for. |
@@ -118,7 +118,7 @@ static void dec_count(struct io *io, unsigned int region, int error) | |||
118 | io_notify_fn fn = io->callback; | 118 | io_notify_fn fn = io->callback; |
119 | void *context = io->context; | 119 | void *context = io->context; |
120 | 120 | ||
121 | mempool_free(io, _io_pool); | 121 | mempool_free(io, io->client->pool); |
122 | fn(r, context); | 122 | fn(r, context); |
123 | } | 123 | } |
124 | } | 124 | } |
@@ -126,7 +126,8 @@ static void dec_count(struct io *io, unsigned int region, int error) | |||
126 | 126 | ||
127 | static int endio(struct bio *bio, unsigned int done, int error) | 127 | static int endio(struct bio *bio, unsigned int done, int error) |
128 | { | 128 | { |
129 | struct io *io = (struct io *) bio->bi_private; | 129 | struct io *io; |
130 | unsigned region; | ||
130 | 131 | ||
131 | /* keep going until we've finished */ | 132 | /* keep going until we've finished */ |
132 | if (bio->bi_size) | 133 | if (bio->bi_size) |
@@ -135,10 +136,17 @@ static int endio(struct bio *bio, unsigned int done, int error) | |||
135 | if (error && bio_data_dir(bio) == READ) | 136 | if (error && bio_data_dir(bio) == READ) |
136 | zero_fill_bio(bio); | 137 | zero_fill_bio(bio); |
137 | 138 | ||
138 | dec_count(io, bio_get_region(bio), error); | 139 | /* |
140 | * The bio destructor in bio_put() may use the io object. | ||
141 | */ | ||
142 | io = bio->bi_private; | ||
143 | region = bio_get_region(bio); | ||
144 | |||
139 | bio->bi_max_vecs++; | 145 | bio->bi_max_vecs++; |
140 | bio_put(bio); | 146 | bio_put(bio); |
141 | 147 | ||
148 | dec_count(io, region, error); | ||
149 | |||
142 | return 0; | 150 | return 0; |
143 | } | 151 | } |
144 | 152 | ||
@@ -209,6 +217,9 @@ static void bvec_dp_init(struct dpages *dp, struct bio_vec *bvec) | |||
209 | dp->context_ptr = bvec; | 217 | dp->context_ptr = bvec; |
210 | } | 218 | } |
211 | 219 | ||
220 | /* | ||
221 | * Functions for getting the pages from a VMA. | ||
222 | */ | ||
212 | static void vm_get_page(struct dpages *dp, | 223 | static void vm_get_page(struct dpages *dp, |
213 | struct page **p, unsigned long *len, unsigned *offset) | 224 | struct page **p, unsigned long *len, unsigned *offset) |
214 | { | 225 | { |
@@ -233,7 +244,34 @@ static void vm_dp_init(struct dpages *dp, void *data) | |||
233 | 244 | ||
234 | static void dm_bio_destructor(struct bio *bio) | 245 | static void dm_bio_destructor(struct bio *bio) |
235 | { | 246 | { |
236 | bio_free(bio, _bios); | 247 | struct io *io = bio->bi_private; |
248 | |||
249 | bio_free(bio, io->client->bios); | ||
250 | } | ||
251 | |||
252 | /* | ||
253 | * Functions for getting the pages from kernel memory. | ||
254 | */ | ||
255 | static void km_get_page(struct dpages *dp, struct page **p, unsigned long *len, | ||
256 | unsigned *offset) | ||
257 | { | ||
258 | *p = virt_to_page(dp->context_ptr); | ||
259 | *offset = dp->context_u; | ||
260 | *len = PAGE_SIZE - dp->context_u; | ||
261 | } | ||
262 | |||
263 | static void km_next_page(struct dpages *dp) | ||
264 | { | ||
265 | dp->context_ptr += PAGE_SIZE - dp->context_u; | ||
266 | dp->context_u = 0; | ||
267 | } | ||
268 | |||
269 | static void km_dp_init(struct dpages *dp, void *data) | ||
270 | { | ||
271 | dp->get_page = km_get_page; | ||
272 | dp->next_page = km_next_page; | ||
273 | dp->context_u = ((unsigned long) data) & (PAGE_SIZE - 1); | ||
274 | dp->context_ptr = data; | ||
237 | } | 275 | } |
238 | 276 | ||
239 | /*----------------------------------------------------------------- | 277 | /*----------------------------------------------------------------- |
@@ -256,7 +294,7 @@ static void do_region(int rw, unsigned int region, struct io_region *where, | |||
256 | * to hide it from bio_add_page(). | 294 | * to hide it from bio_add_page(). |
257 | */ | 295 | */ |
258 | num_bvecs = (remaining / (PAGE_SIZE >> SECTOR_SHIFT)) + 2; | 296 | num_bvecs = (remaining / (PAGE_SIZE >> SECTOR_SHIFT)) + 2; |
259 | bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, _bios); | 297 | bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios); |
260 | bio->bi_sector = where->sector + (where->count - remaining); | 298 | bio->bi_sector = where->sector + (where->count - remaining); |
261 | bio->bi_bdev = where->bdev; | 299 | bio->bi_bdev = where->bdev; |
262 | bio->bi_end_io = endio; | 300 | bio->bi_end_io = endio; |
@@ -311,8 +349,9 @@ static void dispatch_io(int rw, unsigned int num_regions, | |||
311 | dec_count(io, 0, 0); | 349 | dec_count(io, 0, 0); |
312 | } | 350 | } |
313 | 351 | ||
314 | static int sync_io(unsigned int num_regions, struct io_region *where, | 352 | static int sync_io(struct dm_io_client *client, unsigned int num_regions, |
315 | int rw, struct dpages *dp, unsigned long *error_bits) | 353 | struct io_region *where, int rw, struct dpages *dp, |
354 | unsigned long *error_bits) | ||
316 | { | 355 | { |
317 | struct io io; | 356 | struct io io; |
318 | 357 | ||
@@ -324,6 +363,7 @@ static int sync_io(unsigned int num_regions, struct io_region *where, | |||
324 | io.error = 0; | 363 | io.error = 0; |
325 | atomic_set(&io.count, 1); /* see dispatch_io() */ | 364 | atomic_set(&io.count, 1); /* see dispatch_io() */ |
326 | io.sleeper = current; | 365 | io.sleeper = current; |
366 | io.client = client; | ||
327 | 367 | ||
328 | dispatch_io(rw, num_regions, where, dp, &io, 1); | 368 | dispatch_io(rw, num_regions, where, dp, &io, 1); |
329 | 369 | ||
@@ -340,12 +380,15 @@ static int sync_io(unsigned int num_regions, struct io_region *where, | |||
340 | if (atomic_read(&io.count)) | 380 | if (atomic_read(&io.count)) |
341 | return -EINTR; | 381 | return -EINTR; |
342 | 382 | ||
343 | *error_bits = io.error; | 383 | if (error_bits) |
384 | *error_bits = io.error; | ||
385 | |||
344 | return io.error ? -EIO : 0; | 386 | return io.error ? -EIO : 0; |
345 | } | 387 | } |
346 | 388 | ||
347 | static int async_io(unsigned int num_regions, struct io_region *where, int rw, | 389 | static int async_io(struct dm_io_client *client, unsigned int num_regions, |
348 | struct dpages *dp, io_notify_fn fn, void *context) | 390 | struct io_region *where, int rw, struct dpages *dp, |
391 | io_notify_fn fn, void *context) | ||
349 | { | 392 | { |
350 | struct io *io; | 393 | struct io *io; |
351 | 394 | ||
@@ -355,10 +398,11 @@ static int async_io(unsigned int num_regions, struct io_region *where, int rw, | |||
355 | return -EIO; | 398 | return -EIO; |
356 | } | 399 | } |
357 | 400 | ||
358 | io = mempool_alloc(_io_pool, GFP_NOIO); | 401 | io = mempool_alloc(client->pool, GFP_NOIO); |
359 | io->error = 0; | 402 | io->error = 0; |
360 | atomic_set(&io->count, 1); /* see dispatch_io() */ | 403 | atomic_set(&io->count, 1); /* see dispatch_io() */ |
361 | io->sleeper = NULL; | 404 | io->sleeper = NULL; |
405 | io->client = client; | ||
362 | io->callback = fn; | 406 | io->callback = fn; |
363 | io->context = context; | 407 | io->context = context; |
364 | 408 | ||
@@ -366,61 +410,51 @@ static int async_io(unsigned int num_regions, struct io_region *where, int rw, | |||
366 | return 0; | 410 | return 0; |
367 | } | 411 | } |
368 | 412 | ||
369 | int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw, | 413 | static int dp_init(struct dm_io_request *io_req, struct dpages *dp) |
370 | struct page_list *pl, unsigned int offset, | ||
371 | unsigned long *error_bits) | ||
372 | { | 414 | { |
373 | struct dpages dp; | 415 | /* Set up dpages based on memory type */ |
374 | list_dp_init(&dp, pl, offset); | 416 | switch (io_req->mem.type) { |
375 | return sync_io(num_regions, where, rw, &dp, error_bits); | 417 | case DM_IO_PAGE_LIST: |
376 | } | 418 | list_dp_init(dp, io_req->mem.ptr.pl, io_req->mem.offset); |
419 | break; | ||
420 | |||
421 | case DM_IO_BVEC: | ||
422 | bvec_dp_init(dp, io_req->mem.ptr.bvec); | ||
423 | break; | ||
424 | |||
425 | case DM_IO_VMA: | ||
426 | vm_dp_init(dp, io_req->mem.ptr.vma); | ||
427 | break; | ||
428 | |||
429 | case DM_IO_KMEM: | ||
430 | km_dp_init(dp, io_req->mem.ptr.addr); | ||
431 | break; | ||
432 | |||
433 | default: | ||
434 | return -EINVAL; | ||
435 | } | ||
377 | 436 | ||
378 | int dm_io_sync_bvec(unsigned int num_regions, struct io_region *where, int rw, | 437 | return 0; |
379 | struct bio_vec *bvec, unsigned long *error_bits) | ||
380 | { | ||
381 | struct dpages dp; | ||
382 | bvec_dp_init(&dp, bvec); | ||
383 | return sync_io(num_regions, where, rw, &dp, error_bits); | ||
384 | } | 438 | } |
385 | 439 | ||
386 | int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw, | 440 | /* |
387 | void *data, unsigned long *error_bits) | 441 | * New collapsed (a)synchronous interface |
442 | */ | ||
443 | int dm_io(struct dm_io_request *io_req, unsigned num_regions, | ||
444 | struct io_region *where, unsigned long *sync_error_bits) | ||
388 | { | 445 | { |
446 | int r; | ||
389 | struct dpages dp; | 447 | struct dpages dp; |
390 | vm_dp_init(&dp, data); | ||
391 | return sync_io(num_regions, where, rw, &dp, error_bits); | ||
392 | } | ||
393 | 448 | ||
394 | int dm_io_async(unsigned int num_regions, struct io_region *where, int rw, | 449 | r = dp_init(io_req, &dp); |
395 | struct page_list *pl, unsigned int offset, | 450 | if (r) |
396 | io_notify_fn fn, void *context) | 451 | return r; |
397 | { | ||
398 | struct dpages dp; | ||
399 | list_dp_init(&dp, pl, offset); | ||
400 | return async_io(num_regions, where, rw, &dp, fn, context); | ||
401 | } | ||
402 | 452 | ||
403 | int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw, | 453 | if (!io_req->notify.fn) |
404 | struct bio_vec *bvec, io_notify_fn fn, void *context) | 454 | return sync_io(io_req->client, num_regions, where, |
405 | { | 455 | io_req->bi_rw, &dp, sync_error_bits); |
406 | struct dpages dp; | ||
407 | bvec_dp_init(&dp, bvec); | ||
408 | return async_io(num_regions, where, rw, &dp, fn, context); | ||
409 | } | ||
410 | 456 | ||
411 | int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw, | 457 | return async_io(io_req->client, num_regions, where, io_req->bi_rw, |
412 | void *data, io_notify_fn fn, void *context) | 458 | &dp, io_req->notify.fn, io_req->notify.context); |
413 | { | ||
414 | struct dpages dp; | ||
415 | vm_dp_init(&dp, data); | ||
416 | return async_io(num_regions, where, rw, &dp, fn, context); | ||
417 | } | 459 | } |
418 | 460 | EXPORT_SYMBOL(dm_io); | |
419 | EXPORT_SYMBOL(dm_io_get); | ||
420 | EXPORT_SYMBOL(dm_io_put); | ||
421 | EXPORT_SYMBOL(dm_io_sync); | ||
422 | EXPORT_SYMBOL(dm_io_async); | ||
423 | EXPORT_SYMBOL(dm_io_sync_bvec); | ||
424 | EXPORT_SYMBOL(dm_io_async_bvec); | ||
425 | EXPORT_SYMBOL(dm_io_sync_vm); | ||
426 | EXPORT_SYMBOL(dm_io_async_vm); | ||
diff --git a/drivers/md/dm-io.h b/drivers/md/dm-io.h index f9035bfd1a9f..f647e2cceaa6 100644 --- a/drivers/md/dm-io.h +++ b/drivers/md/dm-io.h | |||
@@ -12,7 +12,7 @@ | |||
12 | struct io_region { | 12 | struct io_region { |
13 | struct block_device *bdev; | 13 | struct block_device *bdev; |
14 | sector_t sector; | 14 | sector_t sector; |
15 | sector_t count; | 15 | sector_t count; /* If this is zero the region is ignored. */ |
16 | }; | 16 | }; |
17 | 17 | ||
18 | struct page_list { | 18 | struct page_list { |
@@ -20,55 +20,60 @@ struct page_list { | |||
20 | struct page *page; | 20 | struct page *page; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | |||
24 | /* | ||
25 | * 'error' is a bitset, with each bit indicating whether an error | ||
26 | * occurred doing io to the corresponding region. | ||
27 | */ | ||
28 | typedef void (*io_notify_fn)(unsigned long error, void *context); | 23 | typedef void (*io_notify_fn)(unsigned long error, void *context); |
29 | 24 | ||
25 | enum dm_io_mem_type { | ||
26 | DM_IO_PAGE_LIST,/* Page list */ | ||
27 | DM_IO_BVEC, /* Bio vector */ | ||
28 | DM_IO_VMA, /* Virtual memory area */ | ||
29 | DM_IO_KMEM, /* Kernel memory */ | ||
30 | }; | ||
31 | |||
32 | struct dm_io_memory { | ||
33 | enum dm_io_mem_type type; | ||
34 | |||
35 | union { | ||
36 | struct page_list *pl; | ||
37 | struct bio_vec *bvec; | ||
38 | void *vma; | ||
39 | void *addr; | ||
40 | } ptr; | ||
41 | |||
42 | unsigned offset; | ||
43 | }; | ||
44 | |||
45 | struct dm_io_notify { | ||
46 | io_notify_fn fn; /* Callback for asynchronous requests */ | ||
47 | void *context; /* Passed to callback */ | ||
48 | }; | ||
30 | 49 | ||
31 | /* | 50 | /* |
32 | * Before anyone uses the IO interface they should call | 51 | * IO request structure |
33 | * dm_io_get(), specifying roughly how many pages they are | ||
34 | * expecting to perform io on concurrently. | ||
35 | * | ||
36 | * This function may block. | ||
37 | */ | 52 | */ |
38 | int dm_io_get(unsigned int num_pages); | 53 | struct dm_io_client; |
39 | void dm_io_put(unsigned int num_pages); | 54 | struct dm_io_request { |
55 | int bi_rw; /* READ|WRITE - not READA */ | ||
56 | struct dm_io_memory mem; /* Memory to use for io */ | ||
57 | struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */ | ||
58 | struct dm_io_client *client; /* Client memory handler */ | ||
59 | }; | ||
40 | 60 | ||
41 | /* | 61 | /* |
42 | * Synchronous IO. | 62 | * For async io calls, users can alternatively use the dm_io() function below |
63 | * and dm_io_client_create() to create private mempools for the client. | ||
43 | * | 64 | * |
44 | * Please ensure that the rw flag in the next two functions is | 65 | * Create/destroy may block. |
45 | * either READ or WRITE, ie. we don't take READA. Any | ||
46 | * regions with a zero count field will be ignored. | ||
47 | */ | 66 | */ |
48 | int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw, | 67 | struct dm_io_client *dm_io_client_create(unsigned num_pages); |
49 | struct page_list *pl, unsigned int offset, | 68 | int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client); |
50 | unsigned long *error_bits); | 69 | void dm_io_client_destroy(struct dm_io_client *client); |
51 | |||
52 | int dm_io_sync_bvec(unsigned int num_regions, struct io_region *where, int rw, | ||
53 | struct bio_vec *bvec, unsigned long *error_bits); | ||
54 | |||
55 | int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw, | ||
56 | void *data, unsigned long *error_bits); | ||
57 | 70 | ||
58 | /* | 71 | /* |
59 | * Aynchronous IO. | 72 | * IO interface using private per-client pools. |
60 | * | 73 | * Each bit in the optional 'sync_error_bits' bitset indicates whether an |
61 | * The 'where' array may be safely allocated on the stack since | 74 | * error occurred doing io to the corresponding region. |
62 | * the function takes a copy. | ||
63 | */ | 75 | */ |
64 | int dm_io_async(unsigned int num_regions, struct io_region *where, int rw, | 76 | int dm_io(struct dm_io_request *io_req, unsigned num_regions, |
65 | struct page_list *pl, unsigned int offset, | 77 | struct io_region *region, unsigned long *sync_error_bits); |
66 | io_notify_fn fn, void *context); | ||
67 | |||
68 | int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw, | ||
69 | struct bio_vec *bvec, io_notify_fn fn, void *context); | ||
70 | |||
71 | int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw, | ||
72 | void *data, io_notify_fn fn, void *context); | ||
73 | 78 | ||
74 | #endif | 79 | #endif |
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 6a9261351848..a66428d860fe 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c | |||
@@ -149,9 +149,12 @@ struct log_c { | |||
149 | FORCESYNC, /* Force a sync to happen */ | 149 | FORCESYNC, /* Force a sync to happen */ |
150 | } sync; | 150 | } sync; |
151 | 151 | ||
152 | struct dm_io_request io_req; | ||
153 | |||
152 | /* | 154 | /* |
153 | * Disk log fields | 155 | * Disk log fields |
154 | */ | 156 | */ |
157 | int log_dev_failed; | ||
155 | struct dm_dev *log_dev; | 158 | struct dm_dev *log_dev; |
156 | struct log_header header; | 159 | struct log_header header; |
157 | 160 | ||
@@ -199,13 +202,20 @@ static void header_from_disk(struct log_header *core, struct log_header *disk) | |||
199 | core->nr_regions = le64_to_cpu(disk->nr_regions); | 202 | core->nr_regions = le64_to_cpu(disk->nr_regions); |
200 | } | 203 | } |
201 | 204 | ||
205 | static int rw_header(struct log_c *lc, int rw) | ||
206 | { | ||
207 | lc->io_req.bi_rw = rw; | ||
208 | lc->io_req.mem.ptr.vma = lc->disk_header; | ||
209 | lc->io_req.notify.fn = NULL; | ||
210 | |||
211 | return dm_io(&lc->io_req, 1, &lc->header_location, NULL); | ||
212 | } | ||
213 | |||
202 | static int read_header(struct log_c *log) | 214 | static int read_header(struct log_c *log) |
203 | { | 215 | { |
204 | int r; | 216 | int r; |
205 | unsigned long ebits; | ||
206 | 217 | ||
207 | r = dm_io_sync_vm(1, &log->header_location, READ, | 218 | r = rw_header(log, READ); |
208 | log->disk_header, &ebits); | ||
209 | if (r) | 219 | if (r) |
210 | return r; | 220 | return r; |
211 | 221 | ||
@@ -233,11 +243,8 @@ static int read_header(struct log_c *log) | |||
233 | 243 | ||
234 | static inline int write_header(struct log_c *log) | 244 | static inline int write_header(struct log_c *log) |
235 | { | 245 | { |
236 | unsigned long ebits; | ||
237 | |||
238 | header_to_disk(&log->header, log->disk_header); | 246 | header_to_disk(&log->header, log->disk_header); |
239 | return dm_io_sync_vm(1, &log->header_location, WRITE, | 247 | return rw_header(log, WRITE); |
240 | log->disk_header, &ebits); | ||
241 | } | 248 | } |
242 | 249 | ||
243 | /*---------------------------------------------------------------- | 250 | /*---------------------------------------------------------------- |
@@ -256,6 +263,7 @@ static int create_log_context(struct dirty_log *log, struct dm_target *ti, | |||
256 | uint32_t region_size; | 263 | uint32_t region_size; |
257 | unsigned int region_count; | 264 | unsigned int region_count; |
258 | size_t bitset_size, buf_size; | 265 | size_t bitset_size, buf_size; |
266 | int r; | ||
259 | 267 | ||
260 | if (argc < 1 || argc > 2) { | 268 | if (argc < 1 || argc > 2) { |
261 | DMWARN("wrong number of arguments to mirror log"); | 269 | DMWARN("wrong number of arguments to mirror log"); |
@@ -315,6 +323,7 @@ static int create_log_context(struct dirty_log *log, struct dm_target *ti, | |||
315 | lc->disk_header = NULL; | 323 | lc->disk_header = NULL; |
316 | } else { | 324 | } else { |
317 | lc->log_dev = dev; | 325 | lc->log_dev = dev; |
326 | lc->log_dev_failed = 0; | ||
318 | lc->header_location.bdev = lc->log_dev->bdev; | 327 | lc->header_location.bdev = lc->log_dev->bdev; |
319 | lc->header_location.sector = 0; | 328 | lc->header_location.sector = 0; |
320 | 329 | ||
@@ -324,6 +333,15 @@ static int create_log_context(struct dirty_log *log, struct dm_target *ti, | |||
324 | buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + | 333 | buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + |
325 | bitset_size, ti->limits.hardsect_size); | 334 | bitset_size, ti->limits.hardsect_size); |
326 | lc->header_location.count = buf_size >> SECTOR_SHIFT; | 335 | lc->header_location.count = buf_size >> SECTOR_SHIFT; |
336 | lc->io_req.mem.type = DM_IO_VMA; | ||
337 | lc->io_req.client = dm_io_client_create(dm_div_up(buf_size, | ||
338 | PAGE_SIZE)); | ||
339 | if (IS_ERR(lc->io_req.client)) { | ||
340 | r = PTR_ERR(lc->io_req.client); | ||
341 | DMWARN("couldn't allocate disk io client"); | ||
342 | kfree(lc); | ||
343 | return -ENOMEM; | ||
344 | } | ||
327 | 345 | ||
328 | lc->disk_header = vmalloc(buf_size); | 346 | lc->disk_header = vmalloc(buf_size); |
329 | if (!lc->disk_header) { | 347 | if (!lc->disk_header) { |
@@ -424,6 +442,7 @@ static void disk_dtr(struct dirty_log *log) | |||
424 | 442 | ||
425 | dm_put_device(lc->ti, lc->log_dev); | 443 | dm_put_device(lc->ti, lc->log_dev); |
426 | vfree(lc->disk_header); | 444 | vfree(lc->disk_header); |
445 | dm_io_client_destroy(lc->io_req.client); | ||
427 | destroy_log_context(lc); | 446 | destroy_log_context(lc); |
428 | } | 447 | } |
429 | 448 | ||
@@ -437,6 +456,15 @@ static int count_bits32(uint32_t *addr, unsigned size) | |||
437 | return count; | 456 | return count; |
438 | } | 457 | } |
439 | 458 | ||
459 | static void fail_log_device(struct log_c *lc) | ||
460 | { | ||
461 | if (lc->log_dev_failed) | ||
462 | return; | ||
463 | |||
464 | lc->log_dev_failed = 1; | ||
465 | dm_table_event(lc->ti->table); | ||
466 | } | ||
467 | |||
440 | static int disk_resume(struct dirty_log *log) | 468 | static int disk_resume(struct dirty_log *log) |
441 | { | 469 | { |
442 | int r; | 470 | int r; |
@@ -446,8 +474,19 @@ static int disk_resume(struct dirty_log *log) | |||
446 | 474 | ||
447 | /* read the disk header */ | 475 | /* read the disk header */ |
448 | r = read_header(lc); | 476 | r = read_header(lc); |
449 | if (r) | 477 | if (r) { |
450 | return r; | 478 | DMWARN("%s: Failed to read header on mirror log device", |
479 | lc->log_dev->name); | ||
480 | fail_log_device(lc); | ||
481 | /* | ||
482 | * If the log device cannot be read, we must assume | ||
483 | * all regions are out-of-sync. If we simply return | ||
484 | * here, the state will be uninitialized and could | ||
485 | * lead us to return 'in-sync' status for regions | ||
486 | * that are actually 'out-of-sync'. | ||
487 | */ | ||
488 | lc->header.nr_regions = 0; | ||
489 | } | ||
451 | 490 | ||
452 | /* set or clear any new bits -- device has grown */ | 491 | /* set or clear any new bits -- device has grown */ |
453 | if (lc->sync == NOSYNC) | 492 | if (lc->sync == NOSYNC) |
@@ -472,7 +511,14 @@ static int disk_resume(struct dirty_log *log) | |||
472 | lc->header.nr_regions = lc->region_count; | 511 | lc->header.nr_regions = lc->region_count; |
473 | 512 | ||
474 | /* write the new header */ | 513 | /* write the new header */ |
475 | return write_header(lc); | 514 | r = write_header(lc); |
515 | if (r) { | ||
516 | DMWARN("%s: Failed to write header on mirror log device", | ||
517 | lc->log_dev->name); | ||
518 | fail_log_device(lc); | ||
519 | } | ||
520 | |||
521 | return r; | ||
476 | } | 522 | } |
477 | 523 | ||
478 | static uint32_t core_get_region_size(struct dirty_log *log) | 524 | static uint32_t core_get_region_size(struct dirty_log *log) |
@@ -516,7 +562,9 @@ static int disk_flush(struct dirty_log *log) | |||
516 | return 0; | 562 | return 0; |
517 | 563 | ||
518 | r = write_header(lc); | 564 | r = write_header(lc); |
519 | if (!r) | 565 | if (r) |
566 | fail_log_device(lc); | ||
567 | else | ||
520 | lc->touched = 0; | 568 | lc->touched = 0; |
521 | 569 | ||
522 | return r; | 570 | return r; |
@@ -591,6 +639,7 @@ static int core_status(struct dirty_log *log, status_type_t status, | |||
591 | 639 | ||
592 | switch(status) { | 640 | switch(status) { |
593 | case STATUSTYPE_INFO: | 641 | case STATUSTYPE_INFO: |
642 | DMEMIT("1 %s", log->type->name); | ||
594 | break; | 643 | break; |
595 | 644 | ||
596 | case STATUSTYPE_TABLE: | 645 | case STATUSTYPE_TABLE: |
@@ -606,17 +655,17 @@ static int disk_status(struct dirty_log *log, status_type_t status, | |||
606 | char *result, unsigned int maxlen) | 655 | char *result, unsigned int maxlen) |
607 | { | 656 | { |
608 | int sz = 0; | 657 | int sz = 0; |
609 | char buffer[16]; | ||
610 | struct log_c *lc = log->context; | 658 | struct log_c *lc = log->context; |
611 | 659 | ||
612 | switch(status) { | 660 | switch(status) { |
613 | case STATUSTYPE_INFO: | 661 | case STATUSTYPE_INFO: |
662 | DMEMIT("3 %s %s %c", log->type->name, lc->log_dev->name, | ||
663 | lc->log_dev_failed ? 'D' : 'A'); | ||
614 | break; | 664 | break; |
615 | 665 | ||
616 | case STATUSTYPE_TABLE: | 666 | case STATUSTYPE_TABLE: |
617 | format_dev_t(buffer, lc->log_dev->bdev->bd_dev); | ||
618 | DMEMIT("%s %u %s %u ", log->type->name, | 667 | DMEMIT("%s %u %s %u ", log->type->name, |
619 | lc->sync == DEFAULTSYNC ? 2 : 3, buffer, | 668 | lc->sync == DEFAULTSYNC ? 2 : 3, lc->log_dev->name, |
620 | lc->region_size); | 669 | lc->region_size); |
621 | DMEMIT_SYNC; | 670 | DMEMIT_SYNC; |
622 | } | 671 | } |
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 3aa013506967..de54b39e6ffe 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -668,6 +668,9 @@ static int parse_hw_handler(struct arg_set *as, struct multipath *m) | |||
668 | return -EINVAL; | 668 | return -EINVAL; |
669 | } | 669 | } |
670 | 670 | ||
671 | m->hw_handler.md = dm_table_get_md(ti->table); | ||
672 | dm_put(m->hw_handler.md); | ||
673 | |||
671 | r = hwht->create(&m->hw_handler, hw_argc - 1, as->argv); | 674 | r = hwht->create(&m->hw_handler, hw_argc - 1, as->argv); |
672 | if (r) { | 675 | if (r) { |
673 | dm_put_hw_handler(hwht); | 676 | dm_put_hw_handler(hwht); |
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 23a642619bed..ef124b71ccc8 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -21,15 +21,11 @@ | |||
21 | #include <linux/workqueue.h> | 21 | #include <linux/workqueue.h> |
22 | 22 | ||
23 | #define DM_MSG_PREFIX "raid1" | 23 | #define DM_MSG_PREFIX "raid1" |
24 | #define DM_IO_PAGES 64 | ||
24 | 25 | ||
25 | static struct workqueue_struct *_kmirrord_wq; | 26 | #define DM_RAID1_HANDLE_ERRORS 0x01 |
26 | static struct work_struct _kmirrord_work; | ||
27 | static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped); | ||
28 | 27 | ||
29 | static inline void wake(void) | 28 | static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped); |
30 | { | ||
31 | queue_work(_kmirrord_wq, &_kmirrord_work); | ||
32 | } | ||
33 | 29 | ||
34 | /*----------------------------------------------------------------- | 30 | /*----------------------------------------------------------------- |
35 | * Region hash | 31 | * Region hash |
@@ -125,17 +121,23 @@ struct mirror_set { | |||
125 | struct list_head list; | 121 | struct list_head list; |
126 | struct region_hash rh; | 122 | struct region_hash rh; |
127 | struct kcopyd_client *kcopyd_client; | 123 | struct kcopyd_client *kcopyd_client; |
124 | uint64_t features; | ||
128 | 125 | ||
129 | spinlock_t lock; /* protects the next two lists */ | 126 | spinlock_t lock; /* protects the next two lists */ |
130 | struct bio_list reads; | 127 | struct bio_list reads; |
131 | struct bio_list writes; | 128 | struct bio_list writes; |
132 | 129 | ||
130 | struct dm_io_client *io_client; | ||
131 | |||
133 | /* recovery */ | 132 | /* recovery */ |
134 | region_t nr_regions; | 133 | region_t nr_regions; |
135 | int in_sync; | 134 | int in_sync; |
136 | 135 | ||
137 | struct mirror *default_mirror; /* Default mirror */ | 136 | struct mirror *default_mirror; /* Default mirror */ |
138 | 137 | ||
138 | struct workqueue_struct *kmirrord_wq; | ||
139 | struct work_struct kmirrord_work; | ||
140 | |||
139 | unsigned int nr_mirrors; | 141 | unsigned int nr_mirrors; |
140 | struct mirror mirror[0]; | 142 | struct mirror mirror[0]; |
141 | }; | 143 | }; |
@@ -153,6 +155,11 @@ static inline sector_t region_to_sector(struct region_hash *rh, region_t region) | |||
153 | return region << rh->region_shift; | 155 | return region << rh->region_shift; |
154 | } | 156 | } |
155 | 157 | ||
158 | static void wake(struct mirror_set *ms) | ||
159 | { | ||
160 | queue_work(ms->kmirrord_wq, &ms->kmirrord_work); | ||
161 | } | ||
162 | |||
156 | /* FIXME move this */ | 163 | /* FIXME move this */ |
157 | static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw); | 164 | static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw); |
158 | 165 | ||
@@ -398,8 +405,7 @@ static void rh_update_states(struct region_hash *rh) | |||
398 | mempool_free(reg, rh->region_pool); | 405 | mempool_free(reg, rh->region_pool); |
399 | } | 406 | } |
400 | 407 | ||
401 | if (!list_empty(&recovered)) | 408 | rh->log->type->flush(rh->log); |
402 | rh->log->type->flush(rh->log); | ||
403 | 409 | ||
404 | list_for_each_entry_safe (reg, next, &clean, list) | 410 | list_for_each_entry_safe (reg, next, &clean, list) |
405 | mempool_free(reg, rh->region_pool); | 411 | mempool_free(reg, rh->region_pool); |
@@ -471,7 +477,7 @@ static void rh_dec(struct region_hash *rh, region_t region) | |||
471 | spin_unlock_irqrestore(&rh->region_lock, flags); | 477 | spin_unlock_irqrestore(&rh->region_lock, flags); |
472 | 478 | ||
473 | if (should_wake) | 479 | if (should_wake) |
474 | wake(); | 480 | wake(rh->ms); |
475 | } | 481 | } |
476 | 482 | ||
477 | /* | 483 | /* |
@@ -558,7 +564,7 @@ static void rh_recovery_end(struct region *reg, int success) | |||
558 | list_add(®->list, ®->rh->recovered_regions); | 564 | list_add(®->list, ®->rh->recovered_regions); |
559 | spin_unlock_irq(&rh->region_lock); | 565 | spin_unlock_irq(&rh->region_lock); |
560 | 566 | ||
561 | wake(); | 567 | wake(rh->ms); |
562 | } | 568 | } |
563 | 569 | ||
564 | static void rh_flush(struct region_hash *rh) | 570 | static void rh_flush(struct region_hash *rh) |
@@ -592,7 +598,7 @@ static void rh_start_recovery(struct region_hash *rh) | |||
592 | for (i = 0; i < MAX_RECOVERY; i++) | 598 | for (i = 0; i < MAX_RECOVERY; i++) |
593 | up(&rh->recovery_count); | 599 | up(&rh->recovery_count); |
594 | 600 | ||
595 | wake(); | 601 | wake(rh->ms); |
596 | } | 602 | } |
597 | 603 | ||
598 | /* | 604 | /* |
@@ -735,7 +741,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads) | |||
735 | /* | 741 | /* |
736 | * We can only read balance if the region is in sync. | 742 | * We can only read balance if the region is in sync. |
737 | */ | 743 | */ |
738 | if (rh_in_sync(&ms->rh, region, 0)) | 744 | if (rh_in_sync(&ms->rh, region, 1)) |
739 | m = choose_mirror(ms, bio->bi_sector); | 745 | m = choose_mirror(ms, bio->bi_sector); |
740 | else | 746 | else |
741 | m = ms->default_mirror; | 747 | m = ms->default_mirror; |
@@ -792,6 +798,14 @@ static void do_write(struct mirror_set *ms, struct bio *bio) | |||
792 | unsigned int i; | 798 | unsigned int i; |
793 | struct io_region io[KCOPYD_MAX_REGIONS+1]; | 799 | struct io_region io[KCOPYD_MAX_REGIONS+1]; |
794 | struct mirror *m; | 800 | struct mirror *m; |
801 | struct dm_io_request io_req = { | ||
802 | .bi_rw = WRITE, | ||
803 | .mem.type = DM_IO_BVEC, | ||
804 | .mem.ptr.bvec = bio->bi_io_vec + bio->bi_idx, | ||
805 | .notify.fn = write_callback, | ||
806 | .notify.context = bio, | ||
807 | .client = ms->io_client, | ||
808 | }; | ||
795 | 809 | ||
796 | for (i = 0; i < ms->nr_mirrors; i++) { | 810 | for (i = 0; i < ms->nr_mirrors; i++) { |
797 | m = ms->mirror + i; | 811 | m = ms->mirror + i; |
@@ -802,9 +816,8 @@ static void do_write(struct mirror_set *ms, struct bio *bio) | |||
802 | } | 816 | } |
803 | 817 | ||
804 | bio_set_ms(bio, ms); | 818 | bio_set_ms(bio, ms); |
805 | dm_io_async_bvec(ms->nr_mirrors, io, WRITE, | 819 | |
806 | bio->bi_io_vec + bio->bi_idx, | 820 | (void) dm_io(&io_req, ms->nr_mirrors, io, NULL); |
807 | write_callback, bio); | ||
808 | } | 821 | } |
809 | 822 | ||
810 | static void do_writes(struct mirror_set *ms, struct bio_list *writes) | 823 | static void do_writes(struct mirror_set *ms, struct bio_list *writes) |
@@ -870,11 +883,10 @@ static void do_writes(struct mirror_set *ms, struct bio_list *writes) | |||
870 | /*----------------------------------------------------------------- | 883 | /*----------------------------------------------------------------- |
871 | * kmirrord | 884 | * kmirrord |
872 | *---------------------------------------------------------------*/ | 885 | *---------------------------------------------------------------*/ |
873 | static LIST_HEAD(_mirror_sets); | 886 | static void do_mirror(struct work_struct *work) |
874 | static DECLARE_RWSEM(_mirror_sets_lock); | ||
875 | |||
876 | static void do_mirror(struct mirror_set *ms) | ||
877 | { | 887 | { |
888 | struct mirror_set *ms =container_of(work, struct mirror_set, | ||
889 | kmirrord_work); | ||
878 | struct bio_list reads, writes; | 890 | struct bio_list reads, writes; |
879 | 891 | ||
880 | spin_lock(&ms->lock); | 892 | spin_lock(&ms->lock); |
@@ -890,16 +902,6 @@ static void do_mirror(struct mirror_set *ms) | |||
890 | do_writes(ms, &writes); | 902 | do_writes(ms, &writes); |
891 | } | 903 | } |
892 | 904 | ||
893 | static void do_work(struct work_struct *ignored) | ||
894 | { | ||
895 | struct mirror_set *ms; | ||
896 | |||
897 | down_read(&_mirror_sets_lock); | ||
898 | list_for_each_entry (ms, &_mirror_sets, list) | ||
899 | do_mirror(ms); | ||
900 | up_read(&_mirror_sets_lock); | ||
901 | } | ||
902 | |||
903 | /*----------------------------------------------------------------- | 905 | /*----------------------------------------------------------------- |
904 | * Target functions | 906 | * Target functions |
905 | *---------------------------------------------------------------*/ | 907 | *---------------------------------------------------------------*/ |
@@ -931,6 +933,13 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, | |||
931 | ms->in_sync = 0; | 933 | ms->in_sync = 0; |
932 | ms->default_mirror = &ms->mirror[DEFAULT_MIRROR]; | 934 | ms->default_mirror = &ms->mirror[DEFAULT_MIRROR]; |
933 | 935 | ||
936 | ms->io_client = dm_io_client_create(DM_IO_PAGES); | ||
937 | if (IS_ERR(ms->io_client)) { | ||
938 | ti->error = "Error creating dm_io client"; | ||
939 | kfree(ms); | ||
940 | return NULL; | ||
941 | } | ||
942 | |||
934 | if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) { | 943 | if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) { |
935 | ti->error = "Error creating dirty region hash"; | 944 | ti->error = "Error creating dirty region hash"; |
936 | kfree(ms); | 945 | kfree(ms); |
@@ -946,6 +955,7 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti, | |||
946 | while (m--) | 955 | while (m--) |
947 | dm_put_device(ti, ms->mirror[m].dev); | 956 | dm_put_device(ti, ms->mirror[m].dev); |
948 | 957 | ||
958 | dm_io_client_destroy(ms->io_client); | ||
949 | rh_exit(&ms->rh); | 959 | rh_exit(&ms->rh); |
950 | kfree(ms); | 960 | kfree(ms); |
951 | } | 961 | } |
@@ -978,23 +988,6 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti, | |||
978 | return 0; | 988 | return 0; |
979 | } | 989 | } |
980 | 990 | ||
981 | static int add_mirror_set(struct mirror_set *ms) | ||
982 | { | ||
983 | down_write(&_mirror_sets_lock); | ||
984 | list_add_tail(&ms->list, &_mirror_sets); | ||
985 | up_write(&_mirror_sets_lock); | ||
986 | wake(); | ||
987 | |||
988 | return 0; | ||
989 | } | ||
990 | |||
991 | static void del_mirror_set(struct mirror_set *ms) | ||
992 | { | ||
993 | down_write(&_mirror_sets_lock); | ||
994 | list_del(&ms->list); | ||
995 | up_write(&_mirror_sets_lock); | ||
996 | } | ||
997 | |||
998 | /* | 991 | /* |
999 | * Create dirty log: log_type #log_params <log_params> | 992 | * Create dirty log: log_type #log_params <log_params> |
1000 | */ | 993 | */ |
@@ -1037,16 +1030,55 @@ static struct dirty_log *create_dirty_log(struct dm_target *ti, | |||
1037 | return dl; | 1030 | return dl; |
1038 | } | 1031 | } |
1039 | 1032 | ||
1033 | static int parse_features(struct mirror_set *ms, unsigned argc, char **argv, | ||
1034 | unsigned *args_used) | ||
1035 | { | ||
1036 | unsigned num_features; | ||
1037 | struct dm_target *ti = ms->ti; | ||
1038 | |||
1039 | *args_used = 0; | ||
1040 | |||
1041 | if (!argc) | ||
1042 | return 0; | ||
1043 | |||
1044 | if (sscanf(argv[0], "%u", &num_features) != 1) { | ||
1045 | ti->error = "Invalid number of features"; | ||
1046 | return -EINVAL; | ||
1047 | } | ||
1048 | |||
1049 | argc--; | ||
1050 | argv++; | ||
1051 | (*args_used)++; | ||
1052 | |||
1053 | if (num_features > argc) { | ||
1054 | ti->error = "Not enough arguments to support feature count"; | ||
1055 | return -EINVAL; | ||
1056 | } | ||
1057 | |||
1058 | if (!strcmp("handle_errors", argv[0])) | ||
1059 | ms->features |= DM_RAID1_HANDLE_ERRORS; | ||
1060 | else { | ||
1061 | ti->error = "Unrecognised feature requested"; | ||
1062 | return -EINVAL; | ||
1063 | } | ||
1064 | |||
1065 | (*args_used)++; | ||
1066 | |||
1067 | return 0; | ||
1068 | } | ||
1069 | |||
1040 | /* | 1070 | /* |
1041 | * Construct a mirror mapping: | 1071 | * Construct a mirror mapping: |
1042 | * | 1072 | * |
1043 | * log_type #log_params <log_params> | 1073 | * log_type #log_params <log_params> |
1044 | * #mirrors [mirror_path offset]{2,} | 1074 | * #mirrors [mirror_path offset]{2,} |
1075 | * [#features <features>] | ||
1045 | * | 1076 | * |
1046 | * log_type is "core" or "disk" | 1077 | * log_type is "core" or "disk" |
1047 | * #log_params is between 1 and 3 | 1078 | * #log_params is between 1 and 3 |
1079 | * | ||
1080 | * If present, features must be "handle_errors". | ||
1048 | */ | 1081 | */ |
1049 | #define DM_IO_PAGES 64 | ||
1050 | static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) | 1082 | static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) |
1051 | { | 1083 | { |
1052 | int r; | 1084 | int r; |
@@ -1070,8 +1102,8 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
1070 | 1102 | ||
1071 | argv++, argc--; | 1103 | argv++, argc--; |
1072 | 1104 | ||
1073 | if (argc != nr_mirrors * 2) { | 1105 | if (argc < nr_mirrors * 2) { |
1074 | ti->error = "Wrong number of mirror arguments"; | 1106 | ti->error = "Too few mirror arguments"; |
1075 | dm_destroy_dirty_log(dl); | 1107 | dm_destroy_dirty_log(dl); |
1076 | return -EINVAL; | 1108 | return -EINVAL; |
1077 | } | 1109 | } |
@@ -1096,13 +1128,37 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
1096 | ti->private = ms; | 1128 | ti->private = ms; |
1097 | ti->split_io = ms->rh.region_size; | 1129 | ti->split_io = ms->rh.region_size; |
1098 | 1130 | ||
1131 | ms->kmirrord_wq = create_singlethread_workqueue("kmirrord"); | ||
1132 | if (!ms->kmirrord_wq) { | ||
1133 | DMERR("couldn't start kmirrord"); | ||
1134 | free_context(ms, ti, m); | ||
1135 | return -ENOMEM; | ||
1136 | } | ||
1137 | INIT_WORK(&ms->kmirrord_work, do_mirror); | ||
1138 | |||
1139 | r = parse_features(ms, argc, argv, &args_used); | ||
1140 | if (r) { | ||
1141 | free_context(ms, ti, ms->nr_mirrors); | ||
1142 | return r; | ||
1143 | } | ||
1144 | |||
1145 | argv += args_used; | ||
1146 | argc -= args_used; | ||
1147 | |||
1148 | if (argc) { | ||
1149 | ti->error = "Too many mirror arguments"; | ||
1150 | free_context(ms, ti, ms->nr_mirrors); | ||
1151 | return -EINVAL; | ||
1152 | } | ||
1153 | |||
1099 | r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client); | 1154 | r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client); |
1100 | if (r) { | 1155 | if (r) { |
1156 | destroy_workqueue(ms->kmirrord_wq); | ||
1101 | free_context(ms, ti, ms->nr_mirrors); | 1157 | free_context(ms, ti, ms->nr_mirrors); |
1102 | return r; | 1158 | return r; |
1103 | } | 1159 | } |
1104 | 1160 | ||
1105 | add_mirror_set(ms); | 1161 | wake(ms); |
1106 | return 0; | 1162 | return 0; |
1107 | } | 1163 | } |
1108 | 1164 | ||
@@ -1110,8 +1166,9 @@ static void mirror_dtr(struct dm_target *ti) | |||
1110 | { | 1166 | { |
1111 | struct mirror_set *ms = (struct mirror_set *) ti->private; | 1167 | struct mirror_set *ms = (struct mirror_set *) ti->private; |
1112 | 1168 | ||
1113 | del_mirror_set(ms); | 1169 | flush_workqueue(ms->kmirrord_wq); |
1114 | kcopyd_client_destroy(ms->kcopyd_client); | 1170 | kcopyd_client_destroy(ms->kcopyd_client); |
1171 | destroy_workqueue(ms->kmirrord_wq); | ||
1115 | free_context(ms, ti, ms->nr_mirrors); | 1172 | free_context(ms, ti, ms->nr_mirrors); |
1116 | } | 1173 | } |
1117 | 1174 | ||
@@ -1127,7 +1184,7 @@ static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw) | |||
1127 | spin_unlock(&ms->lock); | 1184 | spin_unlock(&ms->lock); |
1128 | 1185 | ||
1129 | if (should_wake) | 1186 | if (should_wake) |
1130 | wake(); | 1187 | wake(ms); |
1131 | } | 1188 | } |
1132 | 1189 | ||
1133 | /* | 1190 | /* |
@@ -1222,11 +1279,9 @@ static void mirror_resume(struct dm_target *ti) | |||
1222 | static int mirror_status(struct dm_target *ti, status_type_t type, | 1279 | static int mirror_status(struct dm_target *ti, status_type_t type, |
1223 | char *result, unsigned int maxlen) | 1280 | char *result, unsigned int maxlen) |
1224 | { | 1281 | { |
1225 | unsigned int m, sz; | 1282 | unsigned int m, sz = 0; |
1226 | struct mirror_set *ms = (struct mirror_set *) ti->private; | 1283 | struct mirror_set *ms = (struct mirror_set *) ti->private; |
1227 | 1284 | ||
1228 | sz = ms->rh.log->type->status(ms->rh.log, type, result, maxlen); | ||
1229 | |||
1230 | switch (type) { | 1285 | switch (type) { |
1231 | case STATUSTYPE_INFO: | 1286 | case STATUSTYPE_INFO: |
1232 | DMEMIT("%d ", ms->nr_mirrors); | 1287 | DMEMIT("%d ", ms->nr_mirrors); |
@@ -1237,13 +1292,21 @@ static int mirror_status(struct dm_target *ti, status_type_t type, | |||
1237 | (unsigned long long)ms->rh.log->type-> | 1292 | (unsigned long long)ms->rh.log->type-> |
1238 | get_sync_count(ms->rh.log), | 1293 | get_sync_count(ms->rh.log), |
1239 | (unsigned long long)ms->nr_regions); | 1294 | (unsigned long long)ms->nr_regions); |
1295 | |||
1296 | sz = ms->rh.log->type->status(ms->rh.log, type, result, maxlen); | ||
1297 | |||
1240 | break; | 1298 | break; |
1241 | 1299 | ||
1242 | case STATUSTYPE_TABLE: | 1300 | case STATUSTYPE_TABLE: |
1301 | sz = ms->rh.log->type->status(ms->rh.log, type, result, maxlen); | ||
1302 | |||
1243 | DMEMIT("%d", ms->nr_mirrors); | 1303 | DMEMIT("%d", ms->nr_mirrors); |
1244 | for (m = 0; m < ms->nr_mirrors; m++) | 1304 | for (m = 0; m < ms->nr_mirrors; m++) |
1245 | DMEMIT(" %s %llu", ms->mirror[m].dev->name, | 1305 | DMEMIT(" %s %llu", ms->mirror[m].dev->name, |
1246 | (unsigned long long)ms->mirror[m].offset); | 1306 | (unsigned long long)ms->mirror[m].offset); |
1307 | |||
1308 | if (ms->features & DM_RAID1_HANDLE_ERRORS) | ||
1309 | DMEMIT(" 1 handle_errors"); | ||
1247 | } | 1310 | } |
1248 | 1311 | ||
1249 | return 0; | 1312 | return 0; |
@@ -1251,7 +1314,7 @@ static int mirror_status(struct dm_target *ti, status_type_t type, | |||
1251 | 1314 | ||
1252 | static struct target_type mirror_target = { | 1315 | static struct target_type mirror_target = { |
1253 | .name = "mirror", | 1316 | .name = "mirror", |
1254 | .version = {1, 0, 2}, | 1317 | .version = {1, 0, 3}, |
1255 | .module = THIS_MODULE, | 1318 | .module = THIS_MODULE, |
1256 | .ctr = mirror_ctr, | 1319 | .ctr = mirror_ctr, |
1257 | .dtr = mirror_dtr, | 1320 | .dtr = mirror_dtr, |
@@ -1270,20 +1333,11 @@ static int __init dm_mirror_init(void) | |||
1270 | if (r) | 1333 | if (r) |
1271 | return r; | 1334 | return r; |
1272 | 1335 | ||
1273 | _kmirrord_wq = create_singlethread_workqueue("kmirrord"); | ||
1274 | if (!_kmirrord_wq) { | ||
1275 | DMERR("couldn't start kmirrord"); | ||
1276 | dm_dirty_log_exit(); | ||
1277 | return r; | ||
1278 | } | ||
1279 | INIT_WORK(&_kmirrord_work, do_work); | ||
1280 | |||
1281 | r = dm_register_target(&mirror_target); | 1336 | r = dm_register_target(&mirror_target); |
1282 | if (r < 0) { | 1337 | if (r < 0) { |
1283 | DMERR("%s: Failed to register mirror target", | 1338 | DMERR("%s: Failed to register mirror target", |
1284 | mirror_target.name); | 1339 | mirror_target.name); |
1285 | dm_dirty_log_exit(); | 1340 | dm_dirty_log_exit(); |
1286 | destroy_workqueue(_kmirrord_wq); | ||
1287 | } | 1341 | } |
1288 | 1342 | ||
1289 | return r; | 1343 | return r; |
@@ -1297,7 +1351,6 @@ static void __exit dm_mirror_exit(void) | |||
1297 | if (r < 0) | 1351 | if (r < 0) |
1298 | DMERR("%s: unregister failed %d", mirror_target.name, r); | 1352 | DMERR("%s: unregister failed %d", mirror_target.name, r); |
1299 | 1353 | ||
1300 | destroy_workqueue(_kmirrord_wq); | ||
1301 | dm_dirty_log_exit(); | 1354 | dm_dirty_log_exit(); |
1302 | } | 1355 | } |
1303 | 1356 | ||
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 05befa91807a..2fc199b0016b 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -425,13 +425,15 @@ static void close_dev(struct dm_dev *d, struct mapped_device *md) | |||
425 | } | 425 | } |
426 | 426 | ||
427 | /* | 427 | /* |
428 | * If possible (ie. blk_size[major] is set), this checks an area | 428 | * If possible, this checks an area of a destination device is valid. |
429 | * of a destination device is valid. | ||
430 | */ | 429 | */ |
431 | static int check_device_area(struct dm_dev *dd, sector_t start, sector_t len) | 430 | static int check_device_area(struct dm_dev *dd, sector_t start, sector_t len) |
432 | { | 431 | { |
433 | sector_t dev_size; | 432 | sector_t dev_size = dd->bdev->bd_inode->i_size >> SECTOR_SHIFT; |
434 | dev_size = dd->bdev->bd_inode->i_size >> SECTOR_SHIFT; | 433 | |
434 | if (!dev_size) | ||
435 | return 1; | ||
436 | |||
435 | return ((start < dev_size) && (len <= (dev_size - start))); | 437 | return ((start < dev_size) && (len <= (dev_size - start))); |
436 | } | 438 | } |
437 | 439 | ||
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 11a98df298ec..2717a355dc5b 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -1236,6 +1236,7 @@ void dm_put(struct mapped_device *md) | |||
1236 | free_dev(md); | 1236 | free_dev(md); |
1237 | } | 1237 | } |
1238 | } | 1238 | } |
1239 | EXPORT_SYMBOL_GPL(dm_put); | ||
1239 | 1240 | ||
1240 | /* | 1241 | /* |
1241 | * Process the deferred bios | 1242 | * Process the deferred bios |
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c index b46f6c575f7e..dbc234e3c69f 100644 --- a/drivers/md/kcopyd.c +++ b/drivers/md/kcopyd.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Sistina Software (UK) Limited. | 2 | * Copyright (C) 2002 Sistina Software (UK) Limited. |
3 | * Copyright (C) 2006 Red Hat GmbH | ||
3 | * | 4 | * |
4 | * This file is released under the GPL. | 5 | * This file is released under the GPL. |
5 | * | 6 | * |
@@ -45,6 +46,8 @@ struct kcopyd_client { | |||
45 | unsigned int nr_pages; | 46 | unsigned int nr_pages; |
46 | unsigned int nr_free_pages; | 47 | unsigned int nr_free_pages; |
47 | 48 | ||
49 | struct dm_io_client *io_client; | ||
50 | |||
48 | wait_queue_head_t destroyq; | 51 | wait_queue_head_t destroyq; |
49 | atomic_t nr_jobs; | 52 | atomic_t nr_jobs; |
50 | }; | 53 | }; |
@@ -342,16 +345,20 @@ static void complete_io(unsigned long error, void *context) | |||
342 | static int run_io_job(struct kcopyd_job *job) | 345 | static int run_io_job(struct kcopyd_job *job) |
343 | { | 346 | { |
344 | int r; | 347 | int r; |
348 | struct dm_io_request io_req = { | ||
349 | .bi_rw = job->rw, | ||
350 | .mem.type = DM_IO_PAGE_LIST, | ||
351 | .mem.ptr.pl = job->pages, | ||
352 | .mem.offset = job->offset, | ||
353 | .notify.fn = complete_io, | ||
354 | .notify.context = job, | ||
355 | .client = job->kc->io_client, | ||
356 | }; | ||
345 | 357 | ||
346 | if (job->rw == READ) | 358 | if (job->rw == READ) |
347 | r = dm_io_async(1, &job->source, job->rw, | 359 | r = dm_io(&io_req, 1, &job->source, NULL); |
348 | job->pages, | ||
349 | job->offset, complete_io, job); | ||
350 | |||
351 | else | 360 | else |
352 | r = dm_io_async(job->num_dests, job->dests, job->rw, | 361 | r = dm_io(&io_req, job->num_dests, job->dests, NULL); |
353 | job->pages, | ||
354 | job->offset, complete_io, job); | ||
355 | 362 | ||
356 | return r; | 363 | return r; |
357 | } | 364 | } |
@@ -670,8 +677,9 @@ int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) | |||
670 | return r; | 677 | return r; |
671 | } | 678 | } |
672 | 679 | ||
673 | r = dm_io_get(nr_pages); | 680 | kc->io_client = dm_io_client_create(nr_pages); |
674 | if (r) { | 681 | if (IS_ERR(kc->io_client)) { |
682 | r = PTR_ERR(kc->io_client); | ||
675 | client_free_pages(kc); | 683 | client_free_pages(kc); |
676 | kfree(kc); | 684 | kfree(kc); |
677 | kcopyd_exit(); | 685 | kcopyd_exit(); |
@@ -691,7 +699,7 @@ void kcopyd_client_destroy(struct kcopyd_client *kc) | |||
691 | /* Wait for completion of all jobs submitted by this client. */ | 699 | /* Wait for completion of all jobs submitted by this client. */ |
692 | wait_event(kc->destroyq, !atomic_read(&kc->nr_jobs)); | 700 | wait_event(kc->destroyq, !atomic_read(&kc->nr_jobs)); |
693 | 701 | ||
694 | dm_io_put(kc->nr_pages); | 702 | dm_io_client_destroy(kc->io_client); |
695 | client_free_pages(kc); | 703 | client_free_pages(kc); |
696 | client_del(kc); | 704 | client_del(kc); |
697 | kfree(kc); | 705 | kfree(kc); |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 2b4315d7e5d6..2901d0c0ee9e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -33,6 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/kernel.h> | ||
36 | #include <linux/kthread.h> | 37 | #include <linux/kthread.h> |
37 | #include <linux/linkage.h> | 38 | #include <linux/linkage.h> |
38 | #include <linux/raid/md.h> | 39 | #include <linux/raid/md.h> |
@@ -273,6 +274,7 @@ static mddev_t * mddev_find(dev_t unit) | |||
273 | atomic_set(&new->active, 1); | 274 | atomic_set(&new->active, 1); |
274 | spin_lock_init(&new->write_lock); | 275 | spin_lock_init(&new->write_lock); |
275 | init_waitqueue_head(&new->sb_wait); | 276 | init_waitqueue_head(&new->sb_wait); |
277 | new->reshape_position = MaxSector; | ||
276 | 278 | ||
277 | new->queue = blk_alloc_queue(GFP_KERNEL); | 279 | new->queue = blk_alloc_queue(GFP_KERNEL); |
278 | if (!new->queue) { | 280 | if (!new->queue) { |
@@ -589,14 +591,41 @@ abort: | |||
589 | return ret; | 591 | return ret; |
590 | } | 592 | } |
591 | 593 | ||
594 | |||
595 | static u32 md_csum_fold(u32 csum) | ||
596 | { | ||
597 | csum = (csum & 0xffff) + (csum >> 16); | ||
598 | return (csum & 0xffff) + (csum >> 16); | ||
599 | } | ||
600 | |||
592 | static unsigned int calc_sb_csum(mdp_super_t * sb) | 601 | static unsigned int calc_sb_csum(mdp_super_t * sb) |
593 | { | 602 | { |
603 | u64 newcsum = 0; | ||
604 | u32 *sb32 = (u32*)sb; | ||
605 | int i; | ||
594 | unsigned int disk_csum, csum; | 606 | unsigned int disk_csum, csum; |
595 | 607 | ||
596 | disk_csum = sb->sb_csum; | 608 | disk_csum = sb->sb_csum; |
597 | sb->sb_csum = 0; | 609 | sb->sb_csum = 0; |
598 | csum = csum_partial((void *)sb, MD_SB_BYTES, 0); | 610 | |
611 | for (i = 0; i < MD_SB_BYTES/4 ; i++) | ||
612 | newcsum += sb32[i]; | ||
613 | csum = (newcsum & 0xffffffff) + (newcsum>>32); | ||
614 | |||
615 | |||
616 | #ifdef CONFIG_ALPHA | ||
617 | /* This used to use csum_partial, which was wrong for several | ||
618 | * reasons including that different results are returned on | ||
619 | * different architectures. It isn't critical that we get exactly | ||
620 | * the same return value as before (we always csum_fold before | ||
621 | * testing, and that removes any differences). However as we | ||
622 | * know that csum_partial always returned a 16bit value on | ||
623 | * alphas, do a fold to maximise conformity to previous behaviour. | ||
624 | */ | ||
625 | sb->sb_csum = md_csum_fold(disk_csum); | ||
626 | #else | ||
599 | sb->sb_csum = disk_csum; | 627 | sb->sb_csum = disk_csum; |
628 | #endif | ||
600 | return csum; | 629 | return csum; |
601 | } | 630 | } |
602 | 631 | ||
@@ -684,7 +713,7 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version | |||
684 | if (sb->raid_disks <= 0) | 713 | if (sb->raid_disks <= 0) |
685 | goto abort; | 714 | goto abort; |
686 | 715 | ||
687 | if (csum_fold(calc_sb_csum(sb)) != csum_fold(sb->sb_csum)) { | 716 | if (md_csum_fold(calc_sb_csum(sb)) != md_csum_fold(sb->sb_csum)) { |
688 | printk(KERN_WARNING "md: invalid superblock checksum on %s\n", | 717 | printk(KERN_WARNING "md: invalid superblock checksum on %s\n", |
689 | b); | 718 | b); |
690 | goto abort; | 719 | goto abort; |
@@ -694,6 +723,17 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version | |||
694 | rdev->data_offset = 0; | 723 | rdev->data_offset = 0; |
695 | rdev->sb_size = MD_SB_BYTES; | 724 | rdev->sb_size = MD_SB_BYTES; |
696 | 725 | ||
726 | if (sb->state & (1<<MD_SB_BITMAP_PRESENT)) { | ||
727 | if (sb->level != 1 && sb->level != 4 | ||
728 | && sb->level != 5 && sb->level != 6 | ||
729 | && sb->level != 10) { | ||
730 | /* FIXME use a better test */ | ||
731 | printk(KERN_WARNING | ||
732 | "md: bitmaps not supported for this level.\n"); | ||
733 | goto abort; | ||
734 | } | ||
735 | } | ||
736 | |||
697 | if (sb->level == LEVEL_MULTIPATH) | 737 | if (sb->level == LEVEL_MULTIPATH) |
698 | rdev->desc_nr = -1; | 738 | rdev->desc_nr = -1; |
699 | else | 739 | else |
@@ -792,16 +832,8 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
792 | mddev->max_disks = MD_SB_DISKS; | 832 | mddev->max_disks = MD_SB_DISKS; |
793 | 833 | ||
794 | if (sb->state & (1<<MD_SB_BITMAP_PRESENT) && | 834 | if (sb->state & (1<<MD_SB_BITMAP_PRESENT) && |
795 | mddev->bitmap_file == NULL) { | 835 | mddev->bitmap_file == NULL) |
796 | if (mddev->level != 1 && mddev->level != 4 | ||
797 | && mddev->level != 5 && mddev->level != 6 | ||
798 | && mddev->level != 10) { | ||
799 | /* FIXME use a better test */ | ||
800 | printk(KERN_WARNING "md: bitmaps not supported for this level.\n"); | ||
801 | return -EINVAL; | ||
802 | } | ||
803 | mddev->bitmap_offset = mddev->default_bitmap_offset; | 836 | mddev->bitmap_offset = mddev->default_bitmap_offset; |
804 | } | ||
805 | 837 | ||
806 | } else if (mddev->pers == NULL) { | 838 | } else if (mddev->pers == NULL) { |
807 | /* Insist on good event counter while assembling */ | 839 | /* Insist on good event counter while assembling */ |
@@ -1058,6 +1090,18 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version) | |||
1058 | bdevname(rdev->bdev,b)); | 1090 | bdevname(rdev->bdev,b)); |
1059 | return -EINVAL; | 1091 | return -EINVAL; |
1060 | } | 1092 | } |
1093 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET)) { | ||
1094 | if (sb->level != cpu_to_le32(1) && | ||
1095 | sb->level != cpu_to_le32(4) && | ||
1096 | sb->level != cpu_to_le32(5) && | ||
1097 | sb->level != cpu_to_le32(6) && | ||
1098 | sb->level != cpu_to_le32(10)) { | ||
1099 | printk(KERN_WARNING | ||
1100 | "md: bitmaps not supported for this level.\n"); | ||
1101 | return -EINVAL; | ||
1102 | } | ||
1103 | } | ||
1104 | |||
1061 | rdev->preferred_minor = 0xffff; | 1105 | rdev->preferred_minor = 0xffff; |
1062 | rdev->data_offset = le64_to_cpu(sb->data_offset); | 1106 | rdev->data_offset = le64_to_cpu(sb->data_offset); |
1063 | atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read)); | 1107 | atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read)); |
@@ -1141,14 +1185,9 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1141 | mddev->max_disks = (4096-256)/2; | 1185 | mddev->max_disks = (4096-256)/2; |
1142 | 1186 | ||
1143 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) && | 1187 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) && |
1144 | mddev->bitmap_file == NULL ) { | 1188 | mddev->bitmap_file == NULL ) |
1145 | if (mddev->level != 1 && mddev->level != 5 && mddev->level != 6 | ||
1146 | && mddev->level != 10) { | ||
1147 | printk(KERN_WARNING "md: bitmaps not supported for this level.\n"); | ||
1148 | return -EINVAL; | ||
1149 | } | ||
1150 | mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset); | 1189 | mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset); |
1151 | } | 1190 | |
1152 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE)) { | 1191 | if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE)) { |
1153 | mddev->reshape_position = le64_to_cpu(sb->reshape_position); | 1192 | mddev->reshape_position = le64_to_cpu(sb->reshape_position); |
1154 | mddev->delta_disks = le32_to_cpu(sb->delta_disks); | 1193 | mddev->delta_disks = le32_to_cpu(sb->delta_disks); |
@@ -2204,6 +2243,10 @@ static ssize_t | |||
2204 | layout_show(mddev_t *mddev, char *page) | 2243 | layout_show(mddev_t *mddev, char *page) |
2205 | { | 2244 | { |
2206 | /* just a number, not meaningful for all levels */ | 2245 | /* just a number, not meaningful for all levels */ |
2246 | if (mddev->reshape_position != MaxSector && | ||
2247 | mddev->layout != mddev->new_layout) | ||
2248 | return sprintf(page, "%d (%d)\n", | ||
2249 | mddev->new_layout, mddev->layout); | ||
2207 | return sprintf(page, "%d\n", mddev->layout); | 2250 | return sprintf(page, "%d\n", mddev->layout); |
2208 | } | 2251 | } |
2209 | 2252 | ||
@@ -2212,13 +2255,16 @@ layout_store(mddev_t *mddev, const char *buf, size_t len) | |||
2212 | { | 2255 | { |
2213 | char *e; | 2256 | char *e; |
2214 | unsigned long n = simple_strtoul(buf, &e, 10); | 2257 | unsigned long n = simple_strtoul(buf, &e, 10); |
2215 | if (mddev->pers) | ||
2216 | return -EBUSY; | ||
2217 | 2258 | ||
2218 | if (!*buf || (*e && *e != '\n')) | 2259 | if (!*buf || (*e && *e != '\n')) |
2219 | return -EINVAL; | 2260 | return -EINVAL; |
2220 | 2261 | ||
2221 | mddev->layout = n; | 2262 | if (mddev->pers) |
2263 | return -EBUSY; | ||
2264 | if (mddev->reshape_position != MaxSector) | ||
2265 | mddev->new_layout = n; | ||
2266 | else | ||
2267 | mddev->layout = n; | ||
2222 | return len; | 2268 | return len; |
2223 | } | 2269 | } |
2224 | static struct md_sysfs_entry md_layout = | 2270 | static struct md_sysfs_entry md_layout = |
@@ -2230,6 +2276,10 @@ raid_disks_show(mddev_t *mddev, char *page) | |||
2230 | { | 2276 | { |
2231 | if (mddev->raid_disks == 0) | 2277 | if (mddev->raid_disks == 0) |
2232 | return 0; | 2278 | return 0; |
2279 | if (mddev->reshape_position != MaxSector && | ||
2280 | mddev->delta_disks != 0) | ||
2281 | return sprintf(page, "%d (%d)\n", mddev->raid_disks, | ||
2282 | mddev->raid_disks - mddev->delta_disks); | ||
2233 | return sprintf(page, "%d\n", mddev->raid_disks); | 2283 | return sprintf(page, "%d\n", mddev->raid_disks); |
2234 | } | 2284 | } |
2235 | 2285 | ||
@@ -2247,7 +2297,11 @@ raid_disks_store(mddev_t *mddev, const char *buf, size_t len) | |||
2247 | 2297 | ||
2248 | if (mddev->pers) | 2298 | if (mddev->pers) |
2249 | rv = update_raid_disks(mddev, n); | 2299 | rv = update_raid_disks(mddev, n); |
2250 | else | 2300 | else if (mddev->reshape_position != MaxSector) { |
2301 | int olddisks = mddev->raid_disks - mddev->delta_disks; | ||
2302 | mddev->delta_disks = n - olddisks; | ||
2303 | mddev->raid_disks = n; | ||
2304 | } else | ||
2251 | mddev->raid_disks = n; | 2305 | mddev->raid_disks = n; |
2252 | return rv ? rv : len; | 2306 | return rv ? rv : len; |
2253 | } | 2307 | } |
@@ -2257,6 +2311,10 @@ __ATTR(raid_disks, S_IRUGO|S_IWUSR, raid_disks_show, raid_disks_store); | |||
2257 | static ssize_t | 2311 | static ssize_t |
2258 | chunk_size_show(mddev_t *mddev, char *page) | 2312 | chunk_size_show(mddev_t *mddev, char *page) |
2259 | { | 2313 | { |
2314 | if (mddev->reshape_position != MaxSector && | ||
2315 | mddev->chunk_size != mddev->new_chunk) | ||
2316 | return sprintf(page, "%d (%d)\n", mddev->new_chunk, | ||
2317 | mddev->chunk_size); | ||
2260 | return sprintf(page, "%d\n", mddev->chunk_size); | 2318 | return sprintf(page, "%d\n", mddev->chunk_size); |
2261 | } | 2319 | } |
2262 | 2320 | ||
@@ -2267,12 +2325,15 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len) | |||
2267 | char *e; | 2325 | char *e; |
2268 | unsigned long n = simple_strtoul(buf, &e, 10); | 2326 | unsigned long n = simple_strtoul(buf, &e, 10); |
2269 | 2327 | ||
2270 | if (mddev->pers) | ||
2271 | return -EBUSY; | ||
2272 | if (!*buf || (*e && *e != '\n')) | 2328 | if (!*buf || (*e && *e != '\n')) |
2273 | return -EINVAL; | 2329 | return -EINVAL; |
2274 | 2330 | ||
2275 | mddev->chunk_size = n; | 2331 | if (mddev->pers) |
2332 | return -EBUSY; | ||
2333 | else if (mddev->reshape_position != MaxSector) | ||
2334 | mddev->new_chunk = n; | ||
2335 | else | ||
2336 | mddev->chunk_size = n; | ||
2276 | return len; | 2337 | return len; |
2277 | } | 2338 | } |
2278 | static struct md_sysfs_entry md_chunk_size = | 2339 | static struct md_sysfs_entry md_chunk_size = |
@@ -2637,8 +2698,7 @@ metadata_store(mddev_t *mddev, const char *buf, size_t len) | |||
2637 | minor = simple_strtoul(buf, &e, 10); | 2698 | minor = simple_strtoul(buf, &e, 10); |
2638 | if (e==buf || (*e && *e != '\n') ) | 2699 | if (e==buf || (*e && *e != '\n') ) |
2639 | return -EINVAL; | 2700 | return -EINVAL; |
2640 | if (major >= sizeof(super_types)/sizeof(super_types[0]) || | 2701 | if (major >= ARRAY_SIZE(super_types) || super_types[major].name == NULL) |
2641 | super_types[major].name == NULL) | ||
2642 | return -ENOENT; | 2702 | return -ENOENT; |
2643 | mddev->major_version = major; | 2703 | mddev->major_version = major; |
2644 | mddev->minor_version = minor; | 2704 | mddev->minor_version = minor; |
@@ -2859,6 +2919,37 @@ suspend_hi_store(mddev_t *mddev, const char *buf, size_t len) | |||
2859 | static struct md_sysfs_entry md_suspend_hi = | 2919 | static struct md_sysfs_entry md_suspend_hi = |
2860 | __ATTR(suspend_hi, S_IRUGO|S_IWUSR, suspend_hi_show, suspend_hi_store); | 2920 | __ATTR(suspend_hi, S_IRUGO|S_IWUSR, suspend_hi_show, suspend_hi_store); |
2861 | 2921 | ||
2922 | static ssize_t | ||
2923 | reshape_position_show(mddev_t *mddev, char *page) | ||
2924 | { | ||
2925 | if (mddev->reshape_position != MaxSector) | ||
2926 | return sprintf(page, "%llu\n", | ||
2927 | (unsigned long long)mddev->reshape_position); | ||
2928 | strcpy(page, "none\n"); | ||
2929 | return 5; | ||
2930 | } | ||
2931 | |||
2932 | static ssize_t | ||
2933 | reshape_position_store(mddev_t *mddev, const char *buf, size_t len) | ||
2934 | { | ||
2935 | char *e; | ||
2936 | unsigned long long new = simple_strtoull(buf, &e, 10); | ||
2937 | if (mddev->pers) | ||
2938 | return -EBUSY; | ||
2939 | if (buf == e || (*e && *e != '\n')) | ||
2940 | return -EINVAL; | ||
2941 | mddev->reshape_position = new; | ||
2942 | mddev->delta_disks = 0; | ||
2943 | mddev->new_level = mddev->level; | ||
2944 | mddev->new_layout = mddev->layout; | ||
2945 | mddev->new_chunk = mddev->chunk_size; | ||
2946 | return len; | ||
2947 | } | ||
2948 | |||
2949 | static struct md_sysfs_entry md_reshape_position = | ||
2950 | __ATTR(reshape_position, S_IRUGO|S_IWUSR, reshape_position_show, | ||
2951 | reshape_position_store); | ||
2952 | |||
2862 | 2953 | ||
2863 | static struct attribute *md_default_attrs[] = { | 2954 | static struct attribute *md_default_attrs[] = { |
2864 | &md_level.attr, | 2955 | &md_level.attr, |
@@ -2871,6 +2962,7 @@ static struct attribute *md_default_attrs[] = { | |||
2871 | &md_new_device.attr, | 2962 | &md_new_device.attr, |
2872 | &md_safe_delay.attr, | 2963 | &md_safe_delay.attr, |
2873 | &md_array_state.attr, | 2964 | &md_array_state.attr, |
2965 | &md_reshape_position.attr, | ||
2874 | NULL, | 2966 | NULL, |
2875 | }; | 2967 | }; |
2876 | 2968 | ||
@@ -3012,6 +3104,7 @@ static int do_md_run(mddev_t * mddev) | |||
3012 | struct gendisk *disk; | 3104 | struct gendisk *disk; |
3013 | struct mdk_personality *pers; | 3105 | struct mdk_personality *pers; |
3014 | char b[BDEVNAME_SIZE]; | 3106 | char b[BDEVNAME_SIZE]; |
3107 | struct block_device *bdev; | ||
3015 | 3108 | ||
3016 | if (list_empty(&mddev->disks)) | 3109 | if (list_empty(&mddev->disks)) |
3017 | /* cannot run an array with no devices.. */ | 3110 | /* cannot run an array with no devices.. */ |
@@ -3239,7 +3332,13 @@ static int do_md_run(mddev_t * mddev) | |||
3239 | md_wakeup_thread(mddev->thread); | 3332 | md_wakeup_thread(mddev->thread); |
3240 | md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ | 3333 | md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ |
3241 | 3334 | ||
3242 | mddev->changed = 1; | 3335 | bdev = bdget_disk(mddev->gendisk, 0); |
3336 | if (bdev) { | ||
3337 | bd_set_size(bdev, mddev->array_size << 1); | ||
3338 | blkdev_ioctl(bdev->bd_inode, NULL, BLKRRPART, 0); | ||
3339 | bdput(bdev); | ||
3340 | } | ||
3341 | |||
3243 | md_new_event(mddev); | 3342 | md_new_event(mddev); |
3244 | kobject_uevent(&mddev->gendisk->kobj, KOBJ_CHANGE); | 3343 | kobject_uevent(&mddev->gendisk->kobj, KOBJ_CHANGE); |
3245 | return 0; | 3344 | return 0; |
@@ -3361,7 +3460,6 @@ static int do_md_stop(mddev_t * mddev, int mode) | |||
3361 | mddev->pers = NULL; | 3460 | mddev->pers = NULL; |
3362 | 3461 | ||
3363 | set_capacity(disk, 0); | 3462 | set_capacity(disk, 0); |
3364 | mddev->changed = 1; | ||
3365 | 3463 | ||
3366 | if (mddev->ro) | 3464 | if (mddev->ro) |
3367 | mddev->ro = 0; | 3465 | mddev->ro = 0; |
@@ -3409,6 +3507,7 @@ static int do_md_stop(mddev_t * mddev, int mode) | |||
3409 | mddev->size = 0; | 3507 | mddev->size = 0; |
3410 | mddev->raid_disks = 0; | 3508 | mddev->raid_disks = 0; |
3411 | mddev->recovery_cp = 0; | 3509 | mddev->recovery_cp = 0; |
3510 | mddev->reshape_position = MaxSector; | ||
3412 | 3511 | ||
3413 | } else if (mddev->pers) | 3512 | } else if (mddev->pers) |
3414 | printk(KERN_INFO "md: %s switched to read-only mode.\n", | 3513 | printk(KERN_INFO "md: %s switched to read-only mode.\n", |
@@ -4019,7 +4118,7 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info) | |||
4019 | if (info->raid_disks == 0) { | 4118 | if (info->raid_disks == 0) { |
4020 | /* just setting version number for superblock loading */ | 4119 | /* just setting version number for superblock loading */ |
4021 | if (info->major_version < 0 || | 4120 | if (info->major_version < 0 || |
4022 | info->major_version >= sizeof(super_types)/sizeof(super_types[0]) || | 4121 | info->major_version >= ARRAY_SIZE(super_types) || |
4023 | super_types[info->major_version].name == NULL) { | 4122 | super_types[info->major_version].name == NULL) { |
4024 | /* maybe try to auto-load a module? */ | 4123 | /* maybe try to auto-load a module? */ |
4025 | printk(KERN_INFO | 4124 | printk(KERN_INFO |
@@ -4500,20 +4599,6 @@ static int md_release(struct inode *inode, struct file * file) | |||
4500 | return 0; | 4599 | return 0; |
4501 | } | 4600 | } |
4502 | 4601 | ||
4503 | static int md_media_changed(struct gendisk *disk) | ||
4504 | { | ||
4505 | mddev_t *mddev = disk->private_data; | ||
4506 | |||
4507 | return mddev->changed; | ||
4508 | } | ||
4509 | |||
4510 | static int md_revalidate(struct gendisk *disk) | ||
4511 | { | ||
4512 | mddev_t *mddev = disk->private_data; | ||
4513 | |||
4514 | mddev->changed = 0; | ||
4515 | return 0; | ||
4516 | } | ||
4517 | static struct block_device_operations md_fops = | 4602 | static struct block_device_operations md_fops = |
4518 | { | 4603 | { |
4519 | .owner = THIS_MODULE, | 4604 | .owner = THIS_MODULE, |
@@ -4521,8 +4606,6 @@ static struct block_device_operations md_fops = | |||
4521 | .release = md_release, | 4606 | .release = md_release, |
4522 | .ioctl = md_ioctl, | 4607 | .ioctl = md_ioctl, |
4523 | .getgeo = md_getgeo, | 4608 | .getgeo = md_getgeo, |
4524 | .media_changed = md_media_changed, | ||
4525 | .revalidate_disk= md_revalidate, | ||
4526 | }; | 4609 | }; |
4527 | 4610 | ||
4528 | static int md_thread(void * arg) | 4611 | static int md_thread(void * arg) |
@@ -4941,15 +5024,6 @@ static int md_seq_open(struct inode *inode, struct file *file) | |||
4941 | return error; | 5024 | return error; |
4942 | } | 5025 | } |
4943 | 5026 | ||
4944 | static int md_seq_release(struct inode *inode, struct file *file) | ||
4945 | { | ||
4946 | struct seq_file *m = file->private_data; | ||
4947 | struct mdstat_info *mi = m->private; | ||
4948 | m->private = NULL; | ||
4949 | kfree(mi); | ||
4950 | return seq_release(inode, file); | ||
4951 | } | ||
4952 | |||
4953 | static unsigned int mdstat_poll(struct file *filp, poll_table *wait) | 5027 | static unsigned int mdstat_poll(struct file *filp, poll_table *wait) |
4954 | { | 5028 | { |
4955 | struct seq_file *m = filp->private_data; | 5029 | struct seq_file *m = filp->private_data; |
@@ -4971,7 +5045,7 @@ static const struct file_operations md_seq_fops = { | |||
4971 | .open = md_seq_open, | 5045 | .open = md_seq_open, |
4972 | .read = seq_read, | 5046 | .read = seq_read, |
4973 | .llseek = seq_lseek, | 5047 | .llseek = seq_lseek, |
4974 | .release = md_seq_release, | 5048 | .release = seq_release_private, |
4975 | .poll = mdstat_poll, | 5049 | .poll = mdstat_poll, |
4976 | }; | 5050 | }; |
4977 | 5051 | ||
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 97ee870b265d..1b7130cad21f 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -2063,7 +2063,6 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors) | |||
2063 | */ | 2063 | */ |
2064 | mddev->array_size = sectors>>1; | 2064 | mddev->array_size = sectors>>1; |
2065 | set_capacity(mddev->gendisk, mddev->array_size << 1); | 2065 | set_capacity(mddev->gendisk, mddev->array_size << 1); |
2066 | mddev->changed = 1; | ||
2067 | if (mddev->array_size > mddev->size && mddev->recovery_cp == MaxSector) { | 2066 | if (mddev->array_size > mddev->size && mddev->recovery_cp == MaxSector) { |
2068 | mddev->recovery_cp = mddev->size << 1; | 2067 | mddev->recovery_cp = mddev->size << 1; |
2069 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | 2068 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 8d59914f2057..a72e70ad0975 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -353,8 +353,8 @@ static int grow_stripes(raid5_conf_t *conf, int num) | |||
353 | struct kmem_cache *sc; | 353 | struct kmem_cache *sc; |
354 | int devs = conf->raid_disks; | 354 | int devs = conf->raid_disks; |
355 | 355 | ||
356 | sprintf(conf->cache_name[0], "raid5/%s", mdname(conf->mddev)); | 356 | sprintf(conf->cache_name[0], "raid5-%s", mdname(conf->mddev)); |
357 | sprintf(conf->cache_name[1], "raid5/%s-alt", mdname(conf->mddev)); | 357 | sprintf(conf->cache_name[1], "raid5-%s-alt", mdname(conf->mddev)); |
358 | conf->active_name = 0; | 358 | conf->active_name = 0; |
359 | sc = kmem_cache_create(conf->cache_name[conf->active_name], | 359 | sc = kmem_cache_create(conf->cache_name[conf->active_name], |
360 | sizeof(struct stripe_head)+(devs-1)*sizeof(struct r5dev), | 360 | sizeof(struct stripe_head)+(devs-1)*sizeof(struct r5dev), |
@@ -3864,7 +3864,6 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors) | |||
3864 | sectors &= ~((sector_t)mddev->chunk_size/512 - 1); | 3864 | sectors &= ~((sector_t)mddev->chunk_size/512 - 1); |
3865 | mddev->array_size = (sectors * (mddev->raid_disks-conf->max_degraded))>>1; | 3865 | mddev->array_size = (sectors * (mddev->raid_disks-conf->max_degraded))>>1; |
3866 | set_capacity(mddev->gendisk, mddev->array_size << 1); | 3866 | set_capacity(mddev->gendisk, mddev->array_size << 1); |
3867 | mddev->changed = 1; | ||
3868 | if (sectors/2 > mddev->size && mddev->recovery_cp == MaxSector) { | 3867 | if (sectors/2 > mddev->size && mddev->recovery_cp == MaxSector) { |
3869 | mddev->recovery_cp = mddev->size << 1; | 3868 | mddev->recovery_cp = mddev->size << 1; |
3870 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | 3869 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
@@ -3999,7 +3998,6 @@ static void end_reshape(raid5_conf_t *conf) | |||
3999 | conf->mddev->array_size = conf->mddev->size * | 3998 | conf->mddev->array_size = conf->mddev->size * |
4000 | (conf->raid_disks - conf->max_degraded); | 3999 | (conf->raid_disks - conf->max_degraded); |
4001 | set_capacity(conf->mddev->gendisk, conf->mddev->array_size << 1); | 4000 | set_capacity(conf->mddev->gendisk, conf->mddev->array_size << 1); |
4002 | conf->mddev->changed = 1; | ||
4003 | 4001 | ||
4004 | bdev = bdget_disk(conf->mddev->gendisk, 0); | 4002 | bdev = bdget_disk(conf->mddev->gendisk, 0); |
4005 | if (bdev) { | 4003 | if (bdev) { |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c index 68ed3a788083..9200a30dd1b9 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) | 3 | * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) |
4 | * see dvb-usb-init.c for copyright information. | 4 | * see dvb-usb-init.c for copyright information. |
5 | * | 5 | * |
6 | * This file contains functions for initializing the the input-device and for handling remote-control-queries. | 6 | * This file contains functions for initializing the input-device and for handling remote-control-queries. |
7 | */ | 7 | */ |
8 | #include "dvb-usb-common.h" | 8 | #include "dvb-usb-common.h" |
9 | #include <linux/usb/input.h> | 9 | #include <linux/usb/input.h> |
diff --git a/drivers/media/dvb/frontends/dib7000m.c b/drivers/media/dvb/frontends/dib7000m.c index f5d40aa3d27f..f64546c6aeb5 100644 --- a/drivers/media/dvb/frontends/dib7000m.c +++ b/drivers/media/dvb/frontends/dib7000m.c | |||
@@ -266,7 +266,7 @@ static int dib7000m_sad_calib(struct dib7000m_state *state) | |||
266 | { | 266 | { |
267 | 267 | ||
268 | /* internal */ | 268 | /* internal */ |
269 | // dib7000m_write_word(state, 928, (3 << 14) | (1 << 12) | (524 << 0)); // sampling clock of the SAD is writting in set_bandwidth | 269 | // dib7000m_write_word(state, 928, (3 << 14) | (1 << 12) | (524 << 0)); // sampling clock of the SAD is written in set_bandwidth |
270 | dib7000m_write_word(state, 929, (0 << 1) | (0 << 0)); | 270 | dib7000m_write_word(state, 929, (0 << 1) | (0 << 0)); |
271 | dib7000m_write_word(state, 930, 776); // 0.625*3.3 / 4096 | 271 | dib7000m_write_word(state, 930, 776); // 0.625*3.3 / 4096 |
272 | 272 | ||
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c index 0349a4b5da3f..aece458cfe12 100644 --- a/drivers/media/dvb/frontends/dib7000p.c +++ b/drivers/media/dvb/frontends/dib7000p.c | |||
@@ -223,7 +223,7 @@ static int dib7000p_set_bandwidth(struct dvb_frontend *demod, u8 BW_Idx) | |||
223 | static int dib7000p_sad_calib(struct dib7000p_state *state) | 223 | static int dib7000p_sad_calib(struct dib7000p_state *state) |
224 | { | 224 | { |
225 | /* internal */ | 225 | /* internal */ |
226 | // dib7000p_write_word(state, 72, (3 << 14) | (1 << 12) | (524 << 0)); // sampling clock of the SAD is writting in set_bandwidth | 226 | // dib7000p_write_word(state, 72, (3 << 14) | (1 << 12) | (524 << 0)); // sampling clock of the SAD is written in set_bandwidth |
227 | dib7000p_write_word(state, 73, (0 << 1) | (0 << 0)); | 227 | dib7000p_write_word(state, 73, (0 << 1) | (0 << 0)); |
228 | dib7000p_write_word(state, 74, 776); // 0.625*3.3 / 4096 | 228 | dib7000p_write_word(state, 74, 776); // 0.625*3.3 / 4096 |
229 | 229 | ||
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c index 110536843e8e..e725f612a6b7 100644 --- a/drivers/media/dvb/frontends/tda10021.c +++ b/drivers/media/dvb/frontends/tda10021.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | TDA10021 - Single Chip Cable Channel Receiver driver module | 2 | TDA10021 - Single Chip Cable Channel Receiver driver module |
3 | used on the the Siemens DVB-C cards | 3 | used on the Siemens DVB-C cards |
4 | 4 | ||
5 | Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> | 5 | Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> |
6 | Copyright (C) 2004 Markus Schulz <msc@antzsystem.de> | 6 | Copyright (C) 2004 Markus Schulz <msc@antzsystem.de> |
diff --git a/drivers/media/dvb/frontends/ves1x93.c b/drivers/media/dvb/frontends/ves1x93.c index 54d7b07571b8..23fd0303c91b 100644 --- a/drivers/media/dvb/frontends/ves1x93.c +++ b/drivers/media/dvb/frontends/ves1x93.c | |||
@@ -306,7 +306,7 @@ static int ves1x93_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
306 | * The ves1893 sometimes returns sync values that make no sense, | 306 | * The ves1893 sometimes returns sync values that make no sense, |
307 | * because, e.g., the SIGNAL bit is 0, while some of the higher | 307 | * because, e.g., the SIGNAL bit is 0, while some of the higher |
308 | * bits are 1 (and how can there be a CARRIER w/o a SIGNAL?). | 308 | * bits are 1 (and how can there be a CARRIER w/o a SIGNAL?). |
309 | * Tests showed that the the VITERBI and SYNC bits are returned | 309 | * Tests showed that the VITERBI and SYNC bits are returned |
310 | * reliably, while the SIGNAL and CARRIER bits ar sometimes wrong. | 310 | * reliably, while the SIGNAL and CARRIER bits ar sometimes wrong. |
311 | * If such a case occurs, we read the value again, until we get a | 311 | * If such a case occurs, we read the value again, until we get a |
312 | * valid value. | 312 | * valid value. |
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c index 563a8319e608..54ccc6e1f92e 100644 --- a/drivers/media/video/em28xx/em28xx-i2c.c +++ b/drivers/media/video/em28xx/em28xx-i2c.c | |||
@@ -70,7 +70,7 @@ static int em2800_i2c_send_max4(struct em28xx *dev, unsigned char addr, | |||
70 | 70 | ||
71 | ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len); | 71 | ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len); |
72 | if (ret != 2 + len) { | 72 | if (ret != 2 + len) { |
73 | em28xx_warn("writting to i2c device failed (error=%i)\n", ret); | 73 | em28xx_warn("writing to i2c device failed (error=%i)\n", ret); |
74 | return -EIO; | 74 | return -EIO; |
75 | } | 75 | } |
76 | for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0; | 76 | for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0; |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index bec67609500f..2c7b158ce7e1 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -1729,7 +1729,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
1729 | 1729 | ||
1730 | endpoint = &interface->cur_altsetting->endpoint[1].desc; | 1730 | endpoint = &interface->cur_altsetting->endpoint[1].desc; |
1731 | 1731 | ||
1732 | /* check if the the device has the iso in endpoint at the correct place */ | 1732 | /* check if the device has the iso in endpoint at the correct place */ |
1733 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != | 1733 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != |
1734 | USB_ENDPOINT_XFER_ISOC) { | 1734 | USB_ENDPOINT_XFER_ISOC) { |
1735 | em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); | 1735 | em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); |
diff --git a/drivers/media/video/pwc/philips.txt b/drivers/media/video/pwc/philips.txt index f5e848410311..f9f3584281d8 100644 --- a/drivers/media/video/pwc/philips.txt +++ b/drivers/media/video/pwc/philips.txt | |||
@@ -54,9 +54,9 @@ fps | |||
54 | Specifies the desired framerate. Is an integer in the range of 4-30. | 54 | Specifies the desired framerate. Is an integer in the range of 4-30. |
55 | 55 | ||
56 | fbufs | 56 | fbufs |
57 | This paramter specifies the number of internal buffers to use for storing | 57 | This parameter specifies the number of internal buffers to use for storing |
58 | frames from the cam. This will help if the process that reads images from | 58 | frames from the cam. This will help if the process that reads images from |
59 | the cam is a bit slow or momentarely busy. However, on slow machines it | 59 | the cam is a bit slow or momentarily busy. However, on slow machines it |
60 | only introduces lag, so choose carefully. The default is 3, which is | 60 | only introduces lag, so choose carefully. The default is 3, which is |
61 | reasonable. You can set it between 2 and 5. | 61 | reasonable. You can set it between 2 and 5. |
62 | 62 | ||
@@ -209,7 +209,7 @@ trace | |||
209 | 209 | ||
210 | 128 0x80 PWCX debugging Off | 210 | 128 0x80 PWCX debugging Off |
211 | 211 | ||
212 | For example, to trace the open() & read() fuctions, sum 8 + 4 = 12, | 212 | For example, to trace the open() & read() functions, sum 8 + 4 = 12, |
213 | so you would supply trace=12 during insmod or modprobe. If | 213 | so you would supply trace=12 during insmod or modprobe. If |
214 | you want to turn the initialization and probing tracing off, set trace=0. | 214 | you want to turn the initialization and probing tracing off, set trace=0. |
215 | The default value for trace is 35 (0x23). | 215 | The default value for trace is 35 (0x23). |
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c index 876fd2768242..982b115193f8 100644 --- a/drivers/media/video/usbvideo/vicam.c +++ b/drivers/media/video/usbvideo/vicam.c | |||
@@ -28,7 +28,7 @@ | |||
28 | * | 28 | * |
29 | * Portions of this code were also copied from usbvideo.c | 29 | * Portions of this code were also copied from usbvideo.c |
30 | * | 30 | * |
31 | * Special thanks to the the whole team at Sourceforge for help making | 31 | * Special thanks to the whole team at Sourceforge for help making |
32 | * this driver become a reality. Notably: | 32 | * this driver become a reality. Notably: |
33 | * Andy Armstrong who reverse engineered the color encoding and | 33 | * Andy Armstrong who reverse engineered the color encoding and |
34 | * Pavel Machek and Chris Cheney who worked on reverse engineering the | 34 | * Pavel Machek and Chris Cheney who worked on reverse engineering the |
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt index d6b4c607453b..ddc7ae029dd3 100644 --- a/drivers/message/fusion/lsi/mpi_history.txt +++ b/drivers/message/fusion/lsi/mpi_history.txt | |||
@@ -571,7 +571,7 @@ mpi_fc.h | |||
571 | * 11-02-00 01.01.01 Original release for post 1.0 work | 571 | * 11-02-00 01.01.01 Original release for post 1.0 work |
572 | * 12-04-00 01.01.02 Added messages for Common Transport Send and | 572 | * 12-04-00 01.01.02 Added messages for Common Transport Send and |
573 | * Primitive Send. | 573 | * Primitive Send. |
574 | * 01-09-01 01.01.03 Modifed some of the new flags to have an MPI prefix | 574 | * 01-09-01 01.01.03 Modified some of the new flags to have an MPI prefix |
575 | * and modified the FcPrimitiveSend flags. | 575 | * and modified the FcPrimitiveSend flags. |
576 | * 01-25-01 01.01.04 Move InitiatorIndex in LinkServiceRsp reply to a larger | 576 | * 01-25-01 01.01.04 Move InitiatorIndex in LinkServiceRsp reply to a larger |
577 | * field. | 577 | * field. |
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 97471af4309c..5021d1a2a1d4 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c | |||
@@ -3585,7 +3585,7 @@ initChainBuffers(MPT_ADAPTER *ioc) | |||
3585 | * index = chain_idx | 3585 | * index = chain_idx |
3586 | * | 3586 | * |
3587 | * Calculate the number of chain buffers needed(plus 1) per I/O | 3587 | * Calculate the number of chain buffers needed(plus 1) per I/O |
3588 | * then multiply the the maximum number of simultaneous cmds | 3588 | * then multiply the maximum number of simultaneous cmds |
3589 | * | 3589 | * |
3590 | * num_sge = num sge in request frame + last chain buffer | 3590 | * num_sge = num sge in request frame + last chain buffer |
3591 | * scale = num sge per chain buffer if no chain element | 3591 | * scale = num sge per chain buffer if no chain element |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index b6c16704aaab..7385acfa1dd9 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -501,9 +501,9 @@ void mmc_detect_change(struct mmc_host *host, unsigned long delay) | |||
501 | { | 501 | { |
502 | #ifdef CONFIG_MMC_DEBUG | 502 | #ifdef CONFIG_MMC_DEBUG |
503 | unsigned long flags; | 503 | unsigned long flags; |
504 | spin_lock_irqsave(host->lock, flags); | 504 | spin_lock_irqsave(&host->lock, flags); |
505 | BUG_ON(host->removed); | 505 | BUG_ON(host->removed); |
506 | spin_unlock_irqrestore(host->lock, flags); | 506 | spin_unlock_irqrestore(&host->lock, flags); |
507 | #endif | 507 | #endif |
508 | 508 | ||
509 | mmc_schedule_delayed_work(&host->detect, delay); | 509 | mmc_schedule_delayed_work(&host->detect, delay); |
diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig index d28e0fc85e12..479d32b57a1e 100644 --- a/drivers/mtd/chips/Kconfig +++ b/drivers/mtd/chips/Kconfig | |||
@@ -1,5 +1,4 @@ | |||
1 | # drivers/mtd/chips/Kconfig | 1 | # drivers/mtd/chips/Kconfig |
2 | # $Id: Kconfig,v 1.18 2005/11/07 11:14:22 gleixner Exp $ | ||
3 | 2 | ||
4 | menu "RAM/ROM/Flash chip drivers" | 3 | menu "RAM/ROM/Flash chip drivers" |
5 | depends on MTD!=n | 4 | depends on MTD!=n |
@@ -231,45 +230,6 @@ config MTD_ABSENT | |||
231 | the system regardless of media presence. Device nodes created | 230 | the system regardless of media presence. Device nodes created |
232 | with this driver will return -ENODEV upon access. | 231 | with this driver will return -ENODEV upon access. |
233 | 232 | ||
234 | config MTD_OBSOLETE_CHIPS | ||
235 | bool "Older (theoretically obsoleted now) drivers for non-CFI chips" | ||
236 | help | ||
237 | This option does not enable any code directly, but will allow you to | ||
238 | select some other chip drivers which are now considered obsolete, | ||
239 | because the generic CONFIG_JEDECPROBE code above should now detect | ||
240 | the chips which are supported by these drivers, and allow the generic | ||
241 | CFI-compatible drivers to drive the chips. Say 'N' here unless you have | ||
242 | already tried the CONFIG_JEDECPROBE method and reported its failure | ||
243 | to the MTD mailing list at <linux-mtd@lists.infradead.org> | ||
244 | |||
245 | config MTD_AMDSTD | ||
246 | tristate "AMD compatible flash chip support (non-CFI)" | ||
247 | depends on MTD_OBSOLETE_CHIPS && BROKEN | ||
248 | help | ||
249 | This option enables support for flash chips using AMD-compatible | ||
250 | commands, including some which are not CFI-compatible and hence | ||
251 | cannot be used with the CONFIG_MTD_CFI_AMDSTD option. | ||
252 | |||
253 | It also works on AMD compatible chips that do conform to CFI. | ||
254 | |||
255 | config MTD_SHARP | ||
256 | tristate "pre-CFI Sharp chip support" | ||
257 | depends on MTD_OBSOLETE_CHIPS | ||
258 | help | ||
259 | This option enables support for flash chips using Sharp-compatible | ||
260 | commands, including some which are not CFI-compatible and hence | ||
261 | cannot be used with the CONFIG_MTD_CFI_INTELxxx options. | ||
262 | |||
263 | config MTD_JEDEC | ||
264 | tristate "JEDEC device support" | ||
265 | depends on MTD_OBSOLETE_CHIPS && BROKEN | ||
266 | help | ||
267 | Enable older JEDEC flash interface devices for self | ||
268 | programming flash. It is commonly used in older AMD chips. It is | ||
269 | only called JEDEC because the JEDEC association | ||
270 | <http://www.jedec.org/> distributes the identification codes for the | ||
271 | chips. | ||
272 | |||
273 | config MTD_XIP | 233 | config MTD_XIP |
274 | bool "XIP aware MTD support" | 234 | bool "XIP aware MTD support" |
275 | depends on !SMP && (MTD_CFI_INTELEXT || MTD_CFI_AMDSTD) && EXPERIMENTAL && ARCH_MTD_XIP | 235 | depends on !SMP && (MTD_CFI_INTELEXT || MTD_CFI_AMDSTD) && EXPERIMENTAL && ARCH_MTD_XIP |
diff --git a/drivers/mtd/chips/Makefile b/drivers/mtd/chips/Makefile index 75bc1c2a0f43..36582412ccda 100644 --- a/drivers/mtd/chips/Makefile +++ b/drivers/mtd/chips/Makefile | |||
@@ -1,19 +1,15 @@ | |||
1 | # | 1 | # |
2 | # linux/drivers/chips/Makefile | 2 | # linux/drivers/chips/Makefile |
3 | # | 3 | # |
4 | # $Id: Makefile.common,v 1.5 2005/11/07 11:14:22 gleixner Exp $ | ||
5 | 4 | ||
6 | obj-$(CONFIG_MTD) += chipreg.o | 5 | obj-$(CONFIG_MTD) += chipreg.o |
7 | obj-$(CONFIG_MTD_AMDSTD) += amd_flash.o | ||
8 | obj-$(CONFIG_MTD_CFI) += cfi_probe.o | 6 | obj-$(CONFIG_MTD_CFI) += cfi_probe.o |
9 | obj-$(CONFIG_MTD_CFI_UTIL) += cfi_util.o | 7 | obj-$(CONFIG_MTD_CFI_UTIL) += cfi_util.o |
10 | obj-$(CONFIG_MTD_CFI_STAA) += cfi_cmdset_0020.o | 8 | obj-$(CONFIG_MTD_CFI_STAA) += cfi_cmdset_0020.o |
11 | obj-$(CONFIG_MTD_CFI_AMDSTD) += cfi_cmdset_0002.o | 9 | obj-$(CONFIG_MTD_CFI_AMDSTD) += cfi_cmdset_0002.o |
12 | obj-$(CONFIG_MTD_CFI_INTELEXT) += cfi_cmdset_0001.o | 10 | obj-$(CONFIG_MTD_CFI_INTELEXT) += cfi_cmdset_0001.o |
13 | obj-$(CONFIG_MTD_GEN_PROBE) += gen_probe.o | 11 | obj-$(CONFIG_MTD_GEN_PROBE) += gen_probe.o |
14 | obj-$(CONFIG_MTD_JEDEC) += jedec.o | ||
15 | obj-$(CONFIG_MTD_JEDECPROBE) += jedec_probe.o | 12 | obj-$(CONFIG_MTD_JEDECPROBE) += jedec_probe.o |
16 | obj-$(CONFIG_MTD_RAM) += map_ram.o | 13 | obj-$(CONFIG_MTD_RAM) += map_ram.o |
17 | obj-$(CONFIG_MTD_ROM) += map_rom.o | 14 | obj-$(CONFIG_MTD_ROM) += map_rom.o |
18 | obj-$(CONFIG_MTD_SHARP) += sharp.o | ||
19 | obj-$(CONFIG_MTD_ABSENT) += map_absent.o | 15 | obj-$(CONFIG_MTD_ABSENT) += map_absent.o |
diff --git a/drivers/mtd/chips/amd_flash.c b/drivers/mtd/chips/amd_flash.c deleted file mode 100644 index e7999f15d85a..000000000000 --- a/drivers/mtd/chips/amd_flash.c +++ /dev/null | |||
@@ -1,1396 +0,0 @@ | |||
1 | /* | ||
2 | * MTD map driver for AMD compatible flash chips (non-CFI) | ||
3 | * | ||
4 | * Author: Jonas Holmberg <jonas.holmberg@axis.com> | ||
5 | * | ||
6 | * $Id: amd_flash.c,v 1.28 2005/11/07 11:14:22 gleixner Exp $ | ||
7 | * | ||
8 | * Copyright (c) 2001 Axis Communications AB | ||
9 | * | ||
10 | * This file is under GPL. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/sched.h> | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/mtd/map.h> | ||
24 | #include <linux/mtd/mtd.h> | ||
25 | #include <linux/mtd/flashchip.h> | ||
26 | |||
27 | /* There's no limit. It exists only to avoid realloc. */ | ||
28 | #define MAX_AMD_CHIPS 8 | ||
29 | |||
30 | #define DEVICE_TYPE_X8 (8 / 8) | ||
31 | #define DEVICE_TYPE_X16 (16 / 8) | ||
32 | #define DEVICE_TYPE_X32 (32 / 8) | ||
33 | |||
34 | /* Addresses */ | ||
35 | #define ADDR_MANUFACTURER 0x0000 | ||
36 | #define ADDR_DEVICE_ID 0x0001 | ||
37 | #define ADDR_SECTOR_LOCK 0x0002 | ||
38 | #define ADDR_HANDSHAKE 0x0003 | ||
39 | #define ADDR_UNLOCK_1 0x0555 | ||
40 | #define ADDR_UNLOCK_2 0x02AA | ||
41 | |||
42 | /* Commands */ | ||
43 | #define CMD_UNLOCK_DATA_1 0x00AA | ||
44 | #define CMD_UNLOCK_DATA_2 0x0055 | ||
45 | #define CMD_MANUFACTURER_UNLOCK_DATA 0x0090 | ||
46 | #define CMD_UNLOCK_BYPASS_MODE 0x0020 | ||
47 | #define CMD_PROGRAM_UNLOCK_DATA 0x00A0 | ||
48 | #define CMD_RESET_DATA 0x00F0 | ||
49 | #define CMD_SECTOR_ERASE_UNLOCK_DATA 0x0080 | ||
50 | #define CMD_SECTOR_ERASE_UNLOCK_DATA_2 0x0030 | ||
51 | |||
52 | #define CMD_UNLOCK_SECTOR 0x0060 | ||
53 | |||
54 | /* Manufacturers */ | ||
55 | #define MANUFACTURER_AMD 0x0001 | ||
56 | #define MANUFACTURER_ATMEL 0x001F | ||
57 | #define MANUFACTURER_FUJITSU 0x0004 | ||
58 | #define MANUFACTURER_ST 0x0020 | ||
59 | #define MANUFACTURER_SST 0x00BF | ||
60 | #define MANUFACTURER_TOSHIBA 0x0098 | ||
61 | |||
62 | /* AMD */ | ||
63 | #define AM29F800BB 0x2258 | ||
64 | #define AM29F800BT 0x22D6 | ||
65 | #define AM29LV800BB 0x225B | ||
66 | #define AM29LV800BT 0x22DA | ||
67 | #define AM29LV160DT 0x22C4 | ||
68 | #define AM29LV160DB 0x2249 | ||
69 | #define AM29BDS323D 0x22D1 | ||
70 | |||
71 | /* Atmel */ | ||
72 | #define AT49xV16x 0x00C0 | ||
73 | #define AT49xV16xT 0x00C2 | ||
74 | |||
75 | /* Fujitsu */ | ||
76 | #define MBM29LV160TE 0x22C4 | ||
77 | #define MBM29LV160BE 0x2249 | ||
78 | #define MBM29LV800BB 0x225B | ||
79 | |||
80 | /* ST - www.st.com */ | ||
81 | #define M29W800T 0x00D7 | ||
82 | #define M29W160DT 0x22C4 | ||
83 | #define M29W160DB 0x2249 | ||
84 | |||
85 | /* SST */ | ||
86 | #define SST39LF800 0x2781 | ||
87 | #define SST39LF160 0x2782 | ||
88 | |||
89 | /* Toshiba */ | ||
90 | #define TC58FVT160 0x00C2 | ||
91 | #define TC58FVB160 0x0043 | ||
92 | |||
93 | #define D6_MASK 0x40 | ||
94 | |||
95 | struct amd_flash_private { | ||
96 | int device_type; | ||
97 | int interleave; | ||
98 | int numchips; | ||
99 | unsigned long chipshift; | ||
100 | struct flchip chips[0]; | ||
101 | }; | ||
102 | |||
103 | struct amd_flash_info { | ||
104 | const __u16 mfr_id; | ||
105 | const __u16 dev_id; | ||
106 | const char *name; | ||
107 | const u_long size; | ||
108 | const int numeraseregions; | ||
109 | const struct mtd_erase_region_info regions[4]; | ||
110 | }; | ||
111 | |||
112 | |||
113 | |||
114 | static int amd_flash_read(struct mtd_info *, loff_t, size_t, size_t *, | ||
115 | u_char *); | ||
116 | static int amd_flash_write(struct mtd_info *, loff_t, size_t, size_t *, | ||
117 | const u_char *); | ||
118 | static int amd_flash_erase(struct mtd_info *, struct erase_info *); | ||
119 | static void amd_flash_sync(struct mtd_info *); | ||
120 | static int amd_flash_suspend(struct mtd_info *); | ||
121 | static void amd_flash_resume(struct mtd_info *); | ||
122 | static void amd_flash_destroy(struct mtd_info *); | ||
123 | static struct mtd_info *amd_flash_probe(struct map_info *map); | ||
124 | |||
125 | |||
126 | static struct mtd_chip_driver amd_flash_chipdrv = { | ||
127 | .probe = amd_flash_probe, | ||
128 | .destroy = amd_flash_destroy, | ||
129 | .name = "amd_flash", | ||
130 | .module = THIS_MODULE | ||
131 | }; | ||
132 | |||
133 | static inline __u32 wide_read(struct map_info *map, __u32 addr) | ||
134 | { | ||
135 | if (map->buswidth == 1) { | ||
136 | return map_read8(map, addr); | ||
137 | } else if (map->buswidth == 2) { | ||
138 | return map_read16(map, addr); | ||
139 | } else if (map->buswidth == 4) { | ||
140 | return map_read32(map, addr); | ||
141 | } | ||
142 | |||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static inline void wide_write(struct map_info *map, __u32 val, __u32 addr) | ||
147 | { | ||
148 | if (map->buswidth == 1) { | ||
149 | map_write8(map, val, addr); | ||
150 | } else if (map->buswidth == 2) { | ||
151 | map_write16(map, val, addr); | ||
152 | } else if (map->buswidth == 4) { | ||
153 | map_write32(map, val, addr); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | static inline __u32 make_cmd(struct map_info *map, __u32 cmd) | ||
158 | { | ||
159 | const struct amd_flash_private *private = map->fldrv_priv; | ||
160 | if ((private->interleave == 2) && | ||
161 | (private->device_type == DEVICE_TYPE_X16)) { | ||
162 | cmd |= (cmd << 16); | ||
163 | } | ||
164 | |||
165 | return cmd; | ||
166 | } | ||
167 | |||
168 | static inline void send_unlock(struct map_info *map, unsigned long base) | ||
169 | { | ||
170 | wide_write(map, (CMD_UNLOCK_DATA_1 << 16) | CMD_UNLOCK_DATA_1, | ||
171 | base + (map->buswidth * ADDR_UNLOCK_1)); | ||
172 | wide_write(map, (CMD_UNLOCK_DATA_2 << 16) | CMD_UNLOCK_DATA_2, | ||
173 | base + (map->buswidth * ADDR_UNLOCK_2)); | ||
174 | } | ||
175 | |||
176 | static inline void send_cmd(struct map_info *map, unsigned long base, __u32 cmd) | ||
177 | { | ||
178 | send_unlock(map, base); | ||
179 | wide_write(map, make_cmd(map, cmd), | ||
180 | base + (map->buswidth * ADDR_UNLOCK_1)); | ||
181 | } | ||
182 | |||
183 | static inline void send_cmd_to_addr(struct map_info *map, unsigned long base, | ||
184 | __u32 cmd, unsigned long addr) | ||
185 | { | ||
186 | send_unlock(map, base); | ||
187 | wide_write(map, make_cmd(map, cmd), addr); | ||
188 | } | ||
189 | |||
190 | static inline int flash_is_busy(struct map_info *map, unsigned long addr, | ||
191 | int interleave) | ||
192 | { | ||
193 | |||
194 | if ((interleave == 2) && (map->buswidth == 4)) { | ||
195 | __u32 read1, read2; | ||
196 | |||
197 | read1 = wide_read(map, addr); | ||
198 | read2 = wide_read(map, addr); | ||
199 | |||
200 | return (((read1 >> 16) & D6_MASK) != | ||
201 | ((read2 >> 16) & D6_MASK)) || | ||
202 | (((read1 & 0xffff) & D6_MASK) != | ||
203 | ((read2 & 0xffff) & D6_MASK)); | ||
204 | } | ||
205 | |||
206 | return ((wide_read(map, addr) & D6_MASK) != | ||
207 | (wide_read(map, addr) & D6_MASK)); | ||
208 | } | ||
209 | |||
210 | static inline void unlock_sector(struct map_info *map, unsigned long sect_addr, | ||
211 | int unlock) | ||
212 | { | ||
213 | /* Sector lock address. A6 = 1 for unlock, A6 = 0 for lock */ | ||
214 | int SLA = unlock ? | ||
215 | (sect_addr | (0x40 * map->buswidth)) : | ||
216 | (sect_addr & ~(0x40 * map->buswidth)) ; | ||
217 | |||
218 | __u32 cmd = make_cmd(map, CMD_UNLOCK_SECTOR); | ||
219 | |||
220 | wide_write(map, make_cmd(map, CMD_RESET_DATA), 0); | ||
221 | wide_write(map, cmd, SLA); /* 1st cycle: write cmd to any address */ | ||
222 | wide_write(map, cmd, SLA); /* 2nd cycle: write cmd to any address */ | ||
223 | wide_write(map, cmd, SLA); /* 3rd cycle: write cmd to SLA */ | ||
224 | } | ||
225 | |||
226 | static inline int is_sector_locked(struct map_info *map, | ||
227 | unsigned long sect_addr) | ||
228 | { | ||
229 | int status; | ||
230 | |||
231 | wide_write(map, CMD_RESET_DATA, 0); | ||
232 | send_cmd(map, sect_addr, CMD_MANUFACTURER_UNLOCK_DATA); | ||
233 | |||
234 | /* status is 0x0000 for unlocked and 0x0001 for locked */ | ||
235 | status = wide_read(map, sect_addr + (map->buswidth * ADDR_SECTOR_LOCK)); | ||
236 | wide_write(map, CMD_RESET_DATA, 0); | ||
237 | return status; | ||
238 | } | ||
239 | |||
240 | static int amd_flash_do_unlock(struct mtd_info *mtd, loff_t ofs, size_t len, | ||
241 | int is_unlock) | ||
242 | { | ||
243 | struct map_info *map; | ||
244 | struct mtd_erase_region_info *merip; | ||
245 | int eraseoffset, erasesize, eraseblocks; | ||
246 | int i; | ||
247 | int retval = 0; | ||
248 | int lock_status; | ||
249 | |||
250 | map = mtd->priv; | ||
251 | |||
252 | /* Pass the whole chip through sector by sector and check for each | ||
253 | sector if the sector and the given interval overlap */ | ||
254 | for(i = 0; i < mtd->numeraseregions; i++) { | ||
255 | merip = &mtd->eraseregions[i]; | ||
256 | |||
257 | eraseoffset = merip->offset; | ||
258 | erasesize = merip->erasesize; | ||
259 | eraseblocks = merip->numblocks; | ||
260 | |||
261 | if (ofs > eraseoffset + erasesize) | ||
262 | continue; | ||
263 | |||
264 | while (eraseblocks > 0) { | ||
265 | if (ofs < eraseoffset + erasesize && ofs + len > eraseoffset) { | ||
266 | unlock_sector(map, eraseoffset, is_unlock); | ||
267 | |||
268 | lock_status = is_sector_locked(map, eraseoffset); | ||
269 | |||
270 | if (is_unlock && lock_status) { | ||
271 | printk("Cannot unlock sector at address %x length %xx\n", | ||
272 | eraseoffset, merip->erasesize); | ||
273 | retval = -1; | ||
274 | } else if (!is_unlock && !lock_status) { | ||
275 | printk("Cannot lock sector at address %x length %x\n", | ||
276 | eraseoffset, merip->erasesize); | ||
277 | retval = -1; | ||
278 | } | ||
279 | } | ||
280 | eraseoffset += erasesize; | ||
281 | eraseblocks --; | ||
282 | } | ||
283 | } | ||
284 | return retval; | ||
285 | } | ||
286 | |||
287 | static int amd_flash_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | ||
288 | { | ||
289 | return amd_flash_do_unlock(mtd, ofs, len, 1); | ||
290 | } | ||
291 | |||
292 | static int amd_flash_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | ||
293 | { | ||
294 | return amd_flash_do_unlock(mtd, ofs, len, 0); | ||
295 | } | ||
296 | |||
297 | |||
298 | /* | ||
299 | * Reads JEDEC manufacturer ID and device ID and returns the index of the first | ||
300 | * matching table entry (-1 if not found or alias for already found chip). | ||
301 | */ | ||
302 | static int probe_new_chip(struct mtd_info *mtd, __u32 base, | ||
303 | struct flchip *chips, | ||
304 | struct amd_flash_private *private, | ||
305 | const struct amd_flash_info *table, int table_size) | ||
306 | { | ||
307 | __u32 mfr_id; | ||
308 | __u32 dev_id; | ||
309 | struct map_info *map = mtd->priv; | ||
310 | struct amd_flash_private temp; | ||
311 | int i; | ||
312 | |||
313 | temp.device_type = DEVICE_TYPE_X16; // Assume X16 (FIXME) | ||
314 | temp.interleave = 2; | ||
315 | map->fldrv_priv = &temp; | ||
316 | |||
317 | /* Enter autoselect mode. */ | ||
318 | send_cmd(map, base, CMD_RESET_DATA); | ||
319 | send_cmd(map, base, CMD_MANUFACTURER_UNLOCK_DATA); | ||
320 | |||
321 | mfr_id = wide_read(map, base + (map->buswidth * ADDR_MANUFACTURER)); | ||
322 | dev_id = wide_read(map, base + (map->buswidth * ADDR_DEVICE_ID)); | ||
323 | |||
324 | if ((map->buswidth == 4) && ((mfr_id >> 16) == (mfr_id & 0xffff)) && | ||
325 | ((dev_id >> 16) == (dev_id & 0xffff))) { | ||
326 | mfr_id &= 0xffff; | ||
327 | dev_id &= 0xffff; | ||
328 | } else { | ||
329 | temp.interleave = 1; | ||
330 | } | ||
331 | |||
332 | for (i = 0; i < table_size; i++) { | ||
333 | if ((mfr_id == table[i].mfr_id) && | ||
334 | (dev_id == table[i].dev_id)) { | ||
335 | if (chips) { | ||
336 | int j; | ||
337 | |||
338 | /* Is this an alias for an already found chip? | ||
339 | * In that case that chip should be in | ||
340 | * autoselect mode now. | ||
341 | */ | ||
342 | for (j = 0; j < private->numchips; j++) { | ||
343 | __u32 mfr_id_other; | ||
344 | __u32 dev_id_other; | ||
345 | |||
346 | mfr_id_other = | ||
347 | wide_read(map, chips[j].start + | ||
348 | (map->buswidth * | ||
349 | ADDR_MANUFACTURER | ||
350 | )); | ||
351 | dev_id_other = | ||
352 | wide_read(map, chips[j].start + | ||
353 | (map->buswidth * | ||
354 | ADDR_DEVICE_ID)); | ||
355 | if (temp.interleave == 2) { | ||
356 | mfr_id_other &= 0xffff; | ||
357 | dev_id_other &= 0xffff; | ||
358 | } | ||
359 | if ((mfr_id_other == mfr_id) && | ||
360 | (dev_id_other == dev_id)) { | ||
361 | |||
362 | /* Exit autoselect mode. */ | ||
363 | send_cmd(map, base, | ||
364 | CMD_RESET_DATA); | ||
365 | |||
366 | return -1; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | if (private->numchips == MAX_AMD_CHIPS) { | ||
371 | printk(KERN_WARNING | ||
372 | "%s: Too many flash chips " | ||
373 | "detected. Increase " | ||
374 | "MAX_AMD_CHIPS from %d.\n", | ||
375 | map->name, MAX_AMD_CHIPS); | ||
376 | |||
377 | return -1; | ||
378 | } | ||
379 | |||
380 | chips[private->numchips].start = base; | ||
381 | chips[private->numchips].state = FL_READY; | ||
382 | chips[private->numchips].mutex = | ||
383 | &chips[private->numchips]._spinlock; | ||
384 | private->numchips++; | ||
385 | } | ||
386 | |||
387 | printk("%s: Found %d x %ldMiB %s at 0x%x\n", map->name, | ||
388 | temp.interleave, (table[i].size)/(1024*1024), | ||
389 | table[i].name, base); | ||
390 | |||
391 | mtd->size += table[i].size * temp.interleave; | ||
392 | mtd->numeraseregions += table[i].numeraseregions; | ||
393 | |||
394 | break; | ||
395 | } | ||
396 | } | ||
397 | |||
398 | /* Exit autoselect mode. */ | ||
399 | send_cmd(map, base, CMD_RESET_DATA); | ||
400 | |||
401 | if (i == table_size) { | ||
402 | printk(KERN_DEBUG "%s: unknown flash device at 0x%x, " | ||
403 | "mfr id 0x%x, dev id 0x%x\n", map->name, | ||
404 | base, mfr_id, dev_id); | ||
405 | map->fldrv_priv = NULL; | ||
406 | |||
407 | return -1; | ||
408 | } | ||
409 | |||
410 | private->device_type = temp.device_type; | ||
411 | private->interleave = temp.interleave; | ||
412 | |||
413 | return i; | ||
414 | } | ||
415 | |||
416 | |||
417 | |||
418 | static struct mtd_info *amd_flash_probe(struct map_info *map) | ||
419 | { | ||
420 | static const struct amd_flash_info table[] = { | ||
421 | { | ||
422 | .mfr_id = MANUFACTURER_AMD, | ||
423 | .dev_id = AM29LV160DT, | ||
424 | .name = "AMD AM29LV160DT", | ||
425 | .size = 0x00200000, | ||
426 | .numeraseregions = 4, | ||
427 | .regions = { | ||
428 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, | ||
429 | { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 }, | ||
430 | { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 }, | ||
431 | { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 } | ||
432 | } | ||
433 | }, { | ||
434 | .mfr_id = MANUFACTURER_AMD, | ||
435 | .dev_id = AM29LV160DB, | ||
436 | .name = "AMD AM29LV160DB", | ||
437 | .size = 0x00200000, | ||
438 | .numeraseregions = 4, | ||
439 | .regions = { | ||
440 | { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, | ||
441 | { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, | ||
442 | { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, | ||
443 | { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } | ||
444 | } | ||
445 | }, { | ||
446 | .mfr_id = MANUFACTURER_TOSHIBA, | ||
447 | .dev_id = TC58FVT160, | ||
448 | .name = "Toshiba TC58FVT160", | ||
449 | .size = 0x00200000, | ||
450 | .numeraseregions = 4, | ||
451 | .regions = { | ||
452 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, | ||
453 | { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 }, | ||
454 | { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 }, | ||
455 | { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 } | ||
456 | } | ||
457 | }, { | ||
458 | .mfr_id = MANUFACTURER_FUJITSU, | ||
459 | .dev_id = MBM29LV160TE, | ||
460 | .name = "Fujitsu MBM29LV160TE", | ||
461 | .size = 0x00200000, | ||
462 | .numeraseregions = 4, | ||
463 | .regions = { | ||
464 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, | ||
465 | { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 }, | ||
466 | { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 }, | ||
467 | { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 } | ||
468 | } | ||
469 | }, { | ||
470 | .mfr_id = MANUFACTURER_TOSHIBA, | ||
471 | .dev_id = TC58FVB160, | ||
472 | .name = "Toshiba TC58FVB160", | ||
473 | .size = 0x00200000, | ||
474 | .numeraseregions = 4, | ||
475 | .regions = { | ||
476 | { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, | ||
477 | { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, | ||
478 | { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, | ||
479 | { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } | ||
480 | } | ||
481 | }, { | ||
482 | .mfr_id = MANUFACTURER_FUJITSU, | ||
483 | .dev_id = MBM29LV160BE, | ||
484 | .name = "Fujitsu MBM29LV160BE", | ||
485 | .size = 0x00200000, | ||
486 | .numeraseregions = 4, | ||
487 | .regions = { | ||
488 | { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, | ||
489 | { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, | ||
490 | { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, | ||
491 | { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } | ||
492 | } | ||
493 | }, { | ||
494 | .mfr_id = MANUFACTURER_AMD, | ||
495 | .dev_id = AM29LV800BB, | ||
496 | .name = "AMD AM29LV800BB", | ||
497 | .size = 0x00100000, | ||
498 | .numeraseregions = 4, | ||
499 | .regions = { | ||
500 | { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, | ||
501 | { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, | ||
502 | { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, | ||
503 | { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 } | ||
504 | } | ||
505 | }, { | ||
506 | .mfr_id = MANUFACTURER_AMD, | ||
507 | .dev_id = AM29F800BB, | ||
508 | .name = "AMD AM29F800BB", | ||
509 | .size = 0x00100000, | ||
510 | .numeraseregions = 4, | ||
511 | .regions = { | ||
512 | { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, | ||
513 | { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, | ||
514 | { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, | ||
515 | { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 } | ||
516 | } | ||
517 | }, { | ||
518 | .mfr_id = MANUFACTURER_AMD, | ||
519 | .dev_id = AM29LV800BT, | ||
520 | .name = "AMD AM29LV800BT", | ||
521 | .size = 0x00100000, | ||
522 | .numeraseregions = 4, | ||
523 | .regions = { | ||
524 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 }, | ||
525 | { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 }, | ||
526 | { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 }, | ||
527 | { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 } | ||
528 | } | ||
529 | }, { | ||
530 | .mfr_id = MANUFACTURER_AMD, | ||
531 | .dev_id = AM29F800BT, | ||
532 | .name = "AMD AM29F800BT", | ||
533 | .size = 0x00100000, | ||
534 | .numeraseregions = 4, | ||
535 | .regions = { | ||
536 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 }, | ||
537 | { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 }, | ||
538 | { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 }, | ||
539 | { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 } | ||
540 | } | ||
541 | }, { | ||
542 | .mfr_id = MANUFACTURER_AMD, | ||
543 | .dev_id = AM29LV800BB, | ||
544 | .name = "AMD AM29LV800BB", | ||
545 | .size = 0x00100000, | ||
546 | .numeraseregions = 4, | ||
547 | .regions = { | ||
548 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 }, | ||
549 | { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 }, | ||
550 | { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 }, | ||
551 | { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 } | ||
552 | } | ||
553 | }, { | ||
554 | .mfr_id = MANUFACTURER_FUJITSU, | ||
555 | .dev_id = MBM29LV800BB, | ||
556 | .name = "Fujitsu MBM29LV800BB", | ||
557 | .size = 0x00100000, | ||
558 | .numeraseregions = 4, | ||
559 | .regions = { | ||
560 | { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, | ||
561 | { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, | ||
562 | { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, | ||
563 | { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 15 } | ||
564 | } | ||
565 | }, { | ||
566 | .mfr_id = MANUFACTURER_ST, | ||
567 | .dev_id = M29W800T, | ||
568 | .name = "ST M29W800T", | ||
569 | .size = 0x00100000, | ||
570 | .numeraseregions = 4, | ||
571 | .regions = { | ||
572 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 15 }, | ||
573 | { .offset = 0x0F0000, .erasesize = 0x08000, .numblocks = 1 }, | ||
574 | { .offset = 0x0F8000, .erasesize = 0x02000, .numblocks = 2 }, | ||
575 | { .offset = 0x0FC000, .erasesize = 0x04000, .numblocks = 1 } | ||
576 | } | ||
577 | }, { | ||
578 | .mfr_id = MANUFACTURER_ST, | ||
579 | .dev_id = M29W160DT, | ||
580 | .name = "ST M29W160DT", | ||
581 | .size = 0x00200000, | ||
582 | .numeraseregions = 4, | ||
583 | .regions = { | ||
584 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, | ||
585 | { .offset = 0x1F0000, .erasesize = 0x08000, .numblocks = 1 }, | ||
586 | { .offset = 0x1F8000, .erasesize = 0x02000, .numblocks = 2 }, | ||
587 | { .offset = 0x1FC000, .erasesize = 0x04000, .numblocks = 1 } | ||
588 | } | ||
589 | }, { | ||
590 | .mfr_id = MANUFACTURER_ST, | ||
591 | .dev_id = M29W160DB, | ||
592 | .name = "ST M29W160DB", | ||
593 | .size = 0x00200000, | ||
594 | .numeraseregions = 4, | ||
595 | .regions = { | ||
596 | { .offset = 0x000000, .erasesize = 0x04000, .numblocks = 1 }, | ||
597 | { .offset = 0x004000, .erasesize = 0x02000, .numblocks = 2 }, | ||
598 | { .offset = 0x008000, .erasesize = 0x08000, .numblocks = 1 }, | ||
599 | { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } | ||
600 | } | ||
601 | }, { | ||
602 | .mfr_id = MANUFACTURER_AMD, | ||
603 | .dev_id = AM29BDS323D, | ||
604 | .name = "AMD AM29BDS323D", | ||
605 | .size = 0x00400000, | ||
606 | .numeraseregions = 3, | ||
607 | .regions = { | ||
608 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 48 }, | ||
609 | { .offset = 0x300000, .erasesize = 0x10000, .numblocks = 15 }, | ||
610 | { .offset = 0x3f0000, .erasesize = 0x02000, .numblocks = 8 }, | ||
611 | } | ||
612 | }, { | ||
613 | .mfr_id = MANUFACTURER_ATMEL, | ||
614 | .dev_id = AT49xV16x, | ||
615 | .name = "Atmel AT49xV16x", | ||
616 | .size = 0x00200000, | ||
617 | .numeraseregions = 2, | ||
618 | .regions = { | ||
619 | { .offset = 0x000000, .erasesize = 0x02000, .numblocks = 8 }, | ||
620 | { .offset = 0x010000, .erasesize = 0x10000, .numblocks = 31 } | ||
621 | } | ||
622 | }, { | ||
623 | .mfr_id = MANUFACTURER_ATMEL, | ||
624 | .dev_id = AT49xV16xT, | ||
625 | .name = "Atmel AT49xV16xT", | ||
626 | .size = 0x00200000, | ||
627 | .numeraseregions = 2, | ||
628 | .regions = { | ||
629 | { .offset = 0x000000, .erasesize = 0x10000, .numblocks = 31 }, | ||
630 | { .offset = 0x1F0000, .erasesize = 0x02000, .numblocks = 8 } | ||
631 | } | ||
632 | } | ||
633 | }; | ||
634 | |||
635 | struct mtd_info *mtd; | ||
636 | struct flchip chips[MAX_AMD_CHIPS]; | ||
637 | int table_pos[MAX_AMD_CHIPS]; | ||
638 | struct amd_flash_private temp; | ||
639 | struct amd_flash_private *private; | ||
640 | u_long size; | ||
641 | unsigned long base; | ||
642 | int i; | ||
643 | int reg_idx; | ||
644 | int offset; | ||
645 | |||
646 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); | ||
647 | if (!mtd) { | ||
648 | printk(KERN_WARNING | ||
649 | "%s: kmalloc failed for info structure\n", map->name); | ||
650 | return NULL; | ||
651 | } | ||
652 | mtd->priv = map; | ||
653 | |||
654 | memset(&temp, 0, sizeof(temp)); | ||
655 | |||
656 | printk("%s: Probing for AMD compatible flash...\n", map->name); | ||
657 | |||
658 | if ((table_pos[0] = probe_new_chip(mtd, 0, NULL, &temp, table, | ||
659 | ARRAY_SIZE(table))) | ||
660 | == -1) { | ||
661 | printk(KERN_WARNING | ||
662 | "%s: Found no AMD compatible device at location zero\n", | ||
663 | map->name); | ||
664 | kfree(mtd); | ||
665 | |||
666 | return NULL; | ||
667 | } | ||
668 | |||
669 | chips[0].start = 0; | ||
670 | chips[0].state = FL_READY; | ||
671 | chips[0].mutex = &chips[0]._spinlock; | ||
672 | temp.numchips = 1; | ||
673 | for (size = mtd->size; size > 1; size >>= 1) { | ||
674 | temp.chipshift++; | ||
675 | } | ||
676 | switch (temp.interleave) { | ||
677 | case 2: | ||
678 | temp.chipshift += 1; | ||
679 | break; | ||
680 | case 4: | ||
681 | temp.chipshift += 2; | ||
682 | break; | ||
683 | } | ||
684 | |||
685 | /* Find out if there are any more chips in the map. */ | ||
686 | for (base = (1 << temp.chipshift); | ||
687 | base < map->size; | ||
688 | base += (1 << temp.chipshift)) { | ||
689 | int numchips = temp.numchips; | ||
690 | table_pos[numchips] = probe_new_chip(mtd, base, chips, | ||
691 | &temp, table, ARRAY_SIZE(table)); | ||
692 | } | ||
693 | |||
694 | mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * | ||
695 | mtd->numeraseregions, GFP_KERNEL); | ||
696 | if (!mtd->eraseregions) { | ||
697 | printk(KERN_WARNING "%s: Failed to allocate " | ||
698 | "memory for MTD erase region info\n", map->name); | ||
699 | kfree(mtd); | ||
700 | map->fldrv_priv = NULL; | ||
701 | return NULL; | ||
702 | } | ||
703 | |||
704 | reg_idx = 0; | ||
705 | offset = 0; | ||
706 | for (i = 0; i < temp.numchips; i++) { | ||
707 | int dev_size; | ||
708 | int j; | ||
709 | |||
710 | dev_size = 0; | ||
711 | for (j = 0; j < table[table_pos[i]].numeraseregions; j++) { | ||
712 | mtd->eraseregions[reg_idx].offset = offset + | ||
713 | (table[table_pos[i]].regions[j].offset * | ||
714 | temp.interleave); | ||
715 | mtd->eraseregions[reg_idx].erasesize = | ||
716 | table[table_pos[i]].regions[j].erasesize * | ||
717 | temp.interleave; | ||
718 | mtd->eraseregions[reg_idx].numblocks = | ||
719 | table[table_pos[i]].regions[j].numblocks; | ||
720 | if (mtd->erasesize < | ||
721 | mtd->eraseregions[reg_idx].erasesize) { | ||
722 | mtd->erasesize = | ||
723 | mtd->eraseregions[reg_idx].erasesize; | ||
724 | } | ||
725 | dev_size += mtd->eraseregions[reg_idx].erasesize * | ||
726 | mtd->eraseregions[reg_idx].numblocks; | ||
727 | reg_idx++; | ||
728 | } | ||
729 | offset += dev_size; | ||
730 | } | ||
731 | mtd->type = MTD_NORFLASH; | ||
732 | mtd->writesize = 1; | ||
733 | mtd->flags = MTD_CAP_NORFLASH; | ||
734 | mtd->name = map->name; | ||
735 | mtd->erase = amd_flash_erase; | ||
736 | mtd->read = amd_flash_read; | ||
737 | mtd->write = amd_flash_write; | ||
738 | mtd->sync = amd_flash_sync; | ||
739 | mtd->suspend = amd_flash_suspend; | ||
740 | mtd->resume = amd_flash_resume; | ||
741 | mtd->lock = amd_flash_lock; | ||
742 | mtd->unlock = amd_flash_unlock; | ||
743 | |||
744 | private = kmalloc(sizeof(*private) + (sizeof(struct flchip) * | ||
745 | temp.numchips), GFP_KERNEL); | ||
746 | if (!private) { | ||
747 | printk(KERN_WARNING | ||
748 | "%s: kmalloc failed for private structure\n", map->name); | ||
749 | kfree(mtd); | ||
750 | map->fldrv_priv = NULL; | ||
751 | return NULL; | ||
752 | } | ||
753 | memcpy(private, &temp, sizeof(temp)); | ||
754 | memcpy(private->chips, chips, | ||
755 | sizeof(struct flchip) * private->numchips); | ||
756 | for (i = 0; i < private->numchips; i++) { | ||
757 | init_waitqueue_head(&private->chips[i].wq); | ||
758 | spin_lock_init(&private->chips[i]._spinlock); | ||
759 | } | ||
760 | |||
761 | map->fldrv_priv = private; | ||
762 | |||
763 | map->fldrv = &amd_flash_chipdrv; | ||
764 | |||
765 | __module_get(THIS_MODULE); | ||
766 | return mtd; | ||
767 | } | ||
768 | |||
769 | |||
770 | |||
771 | static inline int read_one_chip(struct map_info *map, struct flchip *chip, | ||
772 | loff_t adr, size_t len, u_char *buf) | ||
773 | { | ||
774 | DECLARE_WAITQUEUE(wait, current); | ||
775 | unsigned long timeo = jiffies + HZ; | ||
776 | |||
777 | retry: | ||
778 | spin_lock_bh(chip->mutex); | ||
779 | |||
780 | if (chip->state != FL_READY){ | ||
781 | printk(KERN_INFO "%s: waiting for chip to read, state = %d\n", | ||
782 | map->name, chip->state); | ||
783 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
784 | add_wait_queue(&chip->wq, &wait); | ||
785 | |||
786 | spin_unlock_bh(chip->mutex); | ||
787 | |||
788 | schedule(); | ||
789 | remove_wait_queue(&chip->wq, &wait); | ||
790 | |||
791 | if(signal_pending(current)) { | ||
792 | return -EINTR; | ||
793 | } | ||
794 | |||
795 | timeo = jiffies + HZ; | ||
796 | |||
797 | goto retry; | ||
798 | } | ||
799 | |||
800 | adr += chip->start; | ||
801 | |||
802 | chip->state = FL_READY; | ||
803 | |||
804 | map_copy_from(map, buf, adr, len); | ||
805 | |||
806 | wake_up(&chip->wq); | ||
807 | spin_unlock_bh(chip->mutex); | ||
808 | |||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | |||
813 | |||
814 | static int amd_flash_read(struct mtd_info *mtd, loff_t from, size_t len, | ||
815 | size_t *retlen, u_char *buf) | ||
816 | { | ||
817 | struct map_info *map = mtd->priv; | ||
818 | struct amd_flash_private *private = map->fldrv_priv; | ||
819 | unsigned long ofs; | ||
820 | int chipnum; | ||
821 | int ret = 0; | ||
822 | |||
823 | if ((from + len) > mtd->size) { | ||
824 | printk(KERN_WARNING "%s: read request past end of device " | ||
825 | "(0x%lx)\n", map->name, (unsigned long)from + len); | ||
826 | |||
827 | return -EINVAL; | ||
828 | } | ||
829 | |||
830 | /* Offset within the first chip that the first read should start. */ | ||
831 | chipnum = (from >> private->chipshift); | ||
832 | ofs = from - (chipnum << private->chipshift); | ||
833 | |||
834 | *retlen = 0; | ||
835 | |||
836 | while (len) { | ||
837 | unsigned long this_len; | ||
838 | |||
839 | if (chipnum >= private->numchips) { | ||
840 | break; | ||
841 | } | ||
842 | |||
843 | if ((len + ofs - 1) >> private->chipshift) { | ||
844 | this_len = (1 << private->chipshift) - ofs; | ||
845 | } else { | ||
846 | this_len = len; | ||
847 | } | ||
848 | |||
849 | ret = read_one_chip(map, &private->chips[chipnum], ofs, | ||
850 | this_len, buf); | ||
851 | if (ret) { | ||
852 | break; | ||
853 | } | ||
854 | |||
855 | *retlen += this_len; | ||
856 | len -= this_len; | ||
857 | buf += this_len; | ||
858 | |||
859 | ofs = 0; | ||
860 | chipnum++; | ||
861 | } | ||
862 | |||
863 | return ret; | ||
864 | } | ||
865 | |||
866 | |||
867 | |||
868 | static int write_one_word(struct map_info *map, struct flchip *chip, | ||
869 | unsigned long adr, __u32 datum) | ||
870 | { | ||
871 | unsigned long timeo = jiffies + HZ; | ||
872 | struct amd_flash_private *private = map->fldrv_priv; | ||
873 | DECLARE_WAITQUEUE(wait, current); | ||
874 | int ret = 0; | ||
875 | int times_left; | ||
876 | |||
877 | retry: | ||
878 | spin_lock_bh(chip->mutex); | ||
879 | |||
880 | if (chip->state != FL_READY){ | ||
881 | printk("%s: waiting for chip to write, state = %d\n", | ||
882 | map->name, chip->state); | ||
883 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
884 | add_wait_queue(&chip->wq, &wait); | ||
885 | |||
886 | spin_unlock_bh(chip->mutex); | ||
887 | |||
888 | schedule(); | ||
889 | remove_wait_queue(&chip->wq, &wait); | ||
890 | printk(KERN_INFO "%s: woke up to write\n", map->name); | ||
891 | if(signal_pending(current)) | ||
892 | return -EINTR; | ||
893 | |||
894 | timeo = jiffies + HZ; | ||
895 | |||
896 | goto retry; | ||
897 | } | ||
898 | |||
899 | chip->state = FL_WRITING; | ||
900 | |||
901 | adr += chip->start; | ||
902 | ENABLE_VPP(map); | ||
903 | send_cmd(map, chip->start, CMD_PROGRAM_UNLOCK_DATA); | ||
904 | wide_write(map, datum, adr); | ||
905 | |||
906 | times_left = 500000; | ||
907 | while (times_left-- && flash_is_busy(map, adr, private->interleave)) { | ||
908 | if (need_resched()) { | ||
909 | spin_unlock_bh(chip->mutex); | ||
910 | schedule(); | ||
911 | spin_lock_bh(chip->mutex); | ||
912 | } | ||
913 | } | ||
914 | |||
915 | if (!times_left) { | ||
916 | printk(KERN_WARNING "%s: write to 0x%lx timed out!\n", | ||
917 | map->name, adr); | ||
918 | ret = -EIO; | ||
919 | } else { | ||
920 | __u32 verify; | ||
921 | if ((verify = wide_read(map, adr)) != datum) { | ||
922 | printk(KERN_WARNING "%s: write to 0x%lx failed. " | ||
923 | "datum = %x, verify = %x\n", | ||
924 | map->name, adr, datum, verify); | ||
925 | ret = -EIO; | ||
926 | } | ||
927 | } | ||
928 | |||
929 | DISABLE_VPP(map); | ||
930 | chip->state = FL_READY; | ||
931 | wake_up(&chip->wq); | ||
932 | spin_unlock_bh(chip->mutex); | ||
933 | |||
934 | return ret; | ||
935 | } | ||
936 | |||
937 | |||
938 | |||
939 | static int amd_flash_write(struct mtd_info *mtd, loff_t to , size_t len, | ||
940 | size_t *retlen, const u_char *buf) | ||
941 | { | ||
942 | struct map_info *map = mtd->priv; | ||
943 | struct amd_flash_private *private = map->fldrv_priv; | ||
944 | int ret = 0; | ||
945 | int chipnum; | ||
946 | unsigned long ofs; | ||
947 | unsigned long chipstart; | ||
948 | |||
949 | *retlen = 0; | ||
950 | if (!len) { | ||
951 | return 0; | ||
952 | } | ||
953 | |||
954 | chipnum = to >> private->chipshift; | ||
955 | ofs = to - (chipnum << private->chipshift); | ||
956 | chipstart = private->chips[chipnum].start; | ||
957 | |||
958 | /* If it's not bus-aligned, do the first byte write. */ | ||
959 | if (ofs & (map->buswidth - 1)) { | ||
960 | unsigned long bus_ofs = ofs & ~(map->buswidth - 1); | ||
961 | int i = ofs - bus_ofs; | ||
962 | int n = 0; | ||
963 | u_char tmp_buf[4]; | ||
964 | __u32 datum; | ||
965 | |||
966 | map_copy_from(map, tmp_buf, | ||
967 | bus_ofs + private->chips[chipnum].start, | ||
968 | map->buswidth); | ||
969 | while (len && i < map->buswidth) | ||
970 | tmp_buf[i++] = buf[n++], len--; | ||
971 | |||
972 | if (map->buswidth == 2) { | ||
973 | datum = *(__u16*)tmp_buf; | ||
974 | } else if (map->buswidth == 4) { | ||
975 | datum = *(__u32*)tmp_buf; | ||
976 | } else { | ||
977 | return -EINVAL; /* should never happen, but be safe */ | ||
978 | } | ||
979 | |||
980 | ret = write_one_word(map, &private->chips[chipnum], bus_ofs, | ||
981 | datum); | ||
982 | if (ret) { | ||
983 | return ret; | ||
984 | } | ||
985 | |||
986 | ofs += n; | ||
987 | buf += n; | ||
988 | (*retlen) += n; | ||
989 | |||
990 | if (ofs >> private->chipshift) { | ||
991 | chipnum++; | ||
992 | ofs = 0; | ||
993 | if (chipnum == private->numchips) { | ||
994 | return 0; | ||
995 | } | ||
996 | } | ||
997 | } | ||
998 | |||
999 | /* We are now aligned, write as much as possible. */ | ||
1000 | while(len >= map->buswidth) { | ||
1001 | __u32 datum; | ||
1002 | |||
1003 | if (map->buswidth == 1) { | ||
1004 | datum = *(__u8*)buf; | ||
1005 | } else if (map->buswidth == 2) { | ||
1006 | datum = *(__u16*)buf; | ||
1007 | } else if (map->buswidth == 4) { | ||
1008 | datum = *(__u32*)buf; | ||
1009 | } else { | ||
1010 | return -EINVAL; | ||
1011 | } | ||
1012 | |||
1013 | ret = write_one_word(map, &private->chips[chipnum], ofs, datum); | ||
1014 | |||
1015 | if (ret) { | ||
1016 | return ret; | ||
1017 | } | ||
1018 | |||
1019 | ofs += map->buswidth; | ||
1020 | buf += map->buswidth; | ||
1021 | (*retlen) += map->buswidth; | ||
1022 | len -= map->buswidth; | ||
1023 | |||
1024 | if (ofs >> private->chipshift) { | ||
1025 | chipnum++; | ||
1026 | ofs = 0; | ||
1027 | if (chipnum == private->numchips) { | ||
1028 | return 0; | ||
1029 | } | ||
1030 | chipstart = private->chips[chipnum].start; | ||
1031 | } | ||
1032 | } | ||
1033 | |||
1034 | if (len & (map->buswidth - 1)) { | ||
1035 | int i = 0, n = 0; | ||
1036 | u_char tmp_buf[2]; | ||
1037 | __u32 datum; | ||
1038 | |||
1039 | map_copy_from(map, tmp_buf, | ||
1040 | ofs + private->chips[chipnum].start, | ||
1041 | map->buswidth); | ||
1042 | while (len--) { | ||
1043 | tmp_buf[i++] = buf[n++]; | ||
1044 | } | ||
1045 | |||
1046 | if (map->buswidth == 2) { | ||
1047 | datum = *(__u16*)tmp_buf; | ||
1048 | } else if (map->buswidth == 4) { | ||
1049 | datum = *(__u32*)tmp_buf; | ||
1050 | } else { | ||
1051 | return -EINVAL; /* should never happen, but be safe */ | ||
1052 | } | ||
1053 | |||
1054 | ret = write_one_word(map, &private->chips[chipnum], ofs, datum); | ||
1055 | |||
1056 | if (ret) { | ||
1057 | return ret; | ||
1058 | } | ||
1059 | |||
1060 | (*retlen) += n; | ||
1061 | } | ||
1062 | |||
1063 | return 0; | ||
1064 | } | ||
1065 | |||
1066 | |||
1067 | |||
1068 | static inline int erase_one_block(struct map_info *map, struct flchip *chip, | ||
1069 | unsigned long adr, u_long size) | ||
1070 | { | ||
1071 | unsigned long timeo = jiffies + HZ; | ||
1072 | struct amd_flash_private *private = map->fldrv_priv; | ||
1073 | DECLARE_WAITQUEUE(wait, current); | ||
1074 | |||
1075 | retry: | ||
1076 | spin_lock_bh(chip->mutex); | ||
1077 | |||
1078 | if (chip->state != FL_READY){ | ||
1079 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
1080 | add_wait_queue(&chip->wq, &wait); | ||
1081 | |||
1082 | spin_unlock_bh(chip->mutex); | ||
1083 | |||
1084 | schedule(); | ||
1085 | remove_wait_queue(&chip->wq, &wait); | ||
1086 | |||
1087 | if (signal_pending(current)) { | ||
1088 | return -EINTR; | ||
1089 | } | ||
1090 | |||
1091 | timeo = jiffies + HZ; | ||
1092 | |||
1093 | goto retry; | ||
1094 | } | ||
1095 | |||
1096 | chip->state = FL_ERASING; | ||
1097 | |||
1098 | adr += chip->start; | ||
1099 | ENABLE_VPP(map); | ||
1100 | send_cmd(map, chip->start, CMD_SECTOR_ERASE_UNLOCK_DATA); | ||
1101 | send_cmd_to_addr(map, chip->start, CMD_SECTOR_ERASE_UNLOCK_DATA_2, adr); | ||
1102 | |||
1103 | timeo = jiffies + (HZ * 20); | ||
1104 | |||
1105 | spin_unlock_bh(chip->mutex); | ||
1106 | msleep(1000); | ||
1107 | spin_lock_bh(chip->mutex); | ||
1108 | |||
1109 | while (flash_is_busy(map, adr, private->interleave)) { | ||
1110 | |||
1111 | if (chip->state != FL_ERASING) { | ||
1112 | /* Someone's suspended the erase. Sleep */ | ||
1113 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
1114 | add_wait_queue(&chip->wq, &wait); | ||
1115 | |||
1116 | spin_unlock_bh(chip->mutex); | ||
1117 | printk(KERN_INFO "%s: erase suspended. Sleeping\n", | ||
1118 | map->name); | ||
1119 | schedule(); | ||
1120 | remove_wait_queue(&chip->wq, &wait); | ||
1121 | |||
1122 | if (signal_pending(current)) { | ||
1123 | return -EINTR; | ||
1124 | } | ||
1125 | |||
1126 | timeo = jiffies + (HZ*2); /* FIXME */ | ||
1127 | spin_lock_bh(chip->mutex); | ||
1128 | continue; | ||
1129 | } | ||
1130 | |||
1131 | /* OK Still waiting */ | ||
1132 | if (time_after(jiffies, timeo)) { | ||
1133 | chip->state = FL_READY; | ||
1134 | spin_unlock_bh(chip->mutex); | ||
1135 | printk(KERN_WARNING "%s: waiting for erase to complete " | ||
1136 | "timed out.\n", map->name); | ||
1137 | DISABLE_VPP(map); | ||
1138 | |||
1139 | return -EIO; | ||
1140 | } | ||
1141 | |||
1142 | /* Latency issues. Drop the lock, wait a while and retry */ | ||
1143 | spin_unlock_bh(chip->mutex); | ||
1144 | |||
1145 | if (need_resched()) | ||
1146 | schedule(); | ||
1147 | else | ||
1148 | udelay(1); | ||
1149 | |||
1150 | spin_lock_bh(chip->mutex); | ||
1151 | } | ||
1152 | |||
1153 | /* Verify every single word */ | ||
1154 | { | ||
1155 | int address; | ||
1156 | int error = 0; | ||
1157 | __u8 verify; | ||
1158 | |||
1159 | for (address = adr; address < (adr + size); address++) { | ||
1160 | if ((verify = map_read8(map, address)) != 0xFF) { | ||
1161 | error = 1; | ||
1162 | break; | ||
1163 | } | ||
1164 | } | ||
1165 | if (error) { | ||
1166 | chip->state = FL_READY; | ||
1167 | spin_unlock_bh(chip->mutex); | ||
1168 | printk(KERN_WARNING | ||
1169 | "%s: verify error at 0x%x, size %ld.\n", | ||
1170 | map->name, address, size); | ||
1171 | DISABLE_VPP(map); | ||
1172 | |||
1173 | return -EIO; | ||
1174 | } | ||
1175 | } | ||
1176 | |||
1177 | DISABLE_VPP(map); | ||
1178 | chip->state = FL_READY; | ||
1179 | wake_up(&chip->wq); | ||
1180 | spin_unlock_bh(chip->mutex); | ||
1181 | |||
1182 | return 0; | ||
1183 | } | ||
1184 | |||
1185 | |||
1186 | |||
1187 | static int amd_flash_erase(struct mtd_info *mtd, struct erase_info *instr) | ||
1188 | { | ||
1189 | struct map_info *map = mtd->priv; | ||
1190 | struct amd_flash_private *private = map->fldrv_priv; | ||
1191 | unsigned long adr, len; | ||
1192 | int chipnum; | ||
1193 | int ret = 0; | ||
1194 | int i; | ||
1195 | int first; | ||
1196 | struct mtd_erase_region_info *regions = mtd->eraseregions; | ||
1197 | |||
1198 | if (instr->addr > mtd->size) { | ||
1199 | return -EINVAL; | ||
1200 | } | ||
1201 | |||
1202 | if ((instr->len + instr->addr) > mtd->size) { | ||
1203 | return -EINVAL; | ||
1204 | } | ||
1205 | |||
1206 | /* Check that both start and end of the requested erase are | ||
1207 | * aligned with the erasesize at the appropriate addresses. | ||
1208 | */ | ||
1209 | |||
1210 | i = 0; | ||
1211 | |||
1212 | /* Skip all erase regions which are ended before the start of | ||
1213 | the requested erase. Actually, to save on the calculations, | ||
1214 | we skip to the first erase region which starts after the | ||
1215 | start of the requested erase, and then go back one. | ||
1216 | */ | ||
1217 | |||
1218 | while ((i < mtd->numeraseregions) && | ||
1219 | (instr->addr >= regions[i].offset)) { | ||
1220 | i++; | ||
1221 | } | ||
1222 | i--; | ||
1223 | |||
1224 | /* OK, now i is pointing at the erase region in which this | ||
1225 | * erase request starts. Check the start of the requested | ||
1226 | * erase range is aligned with the erase size which is in | ||
1227 | * effect here. | ||
1228 | */ | ||
1229 | |||
1230 | if (instr->addr & (regions[i].erasesize-1)) { | ||
1231 | return -EINVAL; | ||
1232 | } | ||
1233 | |||
1234 | /* Remember the erase region we start on. */ | ||
1235 | |||
1236 | first = i; | ||
1237 | |||
1238 | /* Next, check that the end of the requested erase is aligned | ||
1239 | * with the erase region at that address. | ||
1240 | */ | ||
1241 | |||
1242 | while ((i < mtd->numeraseregions) && | ||
1243 | ((instr->addr + instr->len) >= regions[i].offset)) { | ||
1244 | i++; | ||
1245 | } | ||
1246 | |||
1247 | /* As before, drop back one to point at the region in which | ||
1248 | * the address actually falls. | ||
1249 | */ | ||
1250 | |||
1251 | i--; | ||
1252 | |||
1253 | if ((instr->addr + instr->len) & (regions[i].erasesize-1)) { | ||
1254 | return -EINVAL; | ||
1255 | } | ||
1256 | |||
1257 | chipnum = instr->addr >> private->chipshift; | ||
1258 | adr = instr->addr - (chipnum << private->chipshift); | ||
1259 | len = instr->len; | ||
1260 | |||
1261 | i = first; | ||
1262 | |||
1263 | while (len) { | ||
1264 | ret = erase_one_block(map, &private->chips[chipnum], adr, | ||
1265 | regions[i].erasesize); | ||
1266 | |||
1267 | if (ret) { | ||
1268 | return ret; | ||
1269 | } | ||
1270 | |||
1271 | adr += regions[i].erasesize; | ||
1272 | len -= regions[i].erasesize; | ||
1273 | |||
1274 | if ((adr % (1 << private->chipshift)) == | ||
1275 | ((regions[i].offset + (regions[i].erasesize * | ||
1276 | regions[i].numblocks)) | ||
1277 | % (1 << private->chipshift))) { | ||
1278 | i++; | ||
1279 | } | ||
1280 | |||
1281 | if (adr >> private->chipshift) { | ||
1282 | adr = 0; | ||
1283 | chipnum++; | ||
1284 | if (chipnum >= private->numchips) { | ||
1285 | break; | ||
1286 | } | ||
1287 | } | ||
1288 | } | ||
1289 | |||
1290 | instr->state = MTD_ERASE_DONE; | ||
1291 | mtd_erase_callback(instr); | ||
1292 | |||
1293 | return 0; | ||
1294 | } | ||
1295 | |||
1296 | |||
1297 | |||
1298 | static void amd_flash_sync(struct mtd_info *mtd) | ||
1299 | { | ||
1300 | struct map_info *map = mtd->priv; | ||
1301 | struct amd_flash_private *private = map->fldrv_priv; | ||
1302 | int i; | ||
1303 | struct flchip *chip; | ||
1304 | int ret = 0; | ||
1305 | DECLARE_WAITQUEUE(wait, current); | ||
1306 | |||
1307 | for (i = 0; !ret && (i < private->numchips); i++) { | ||
1308 | chip = &private->chips[i]; | ||
1309 | |||
1310 | retry: | ||
1311 | spin_lock_bh(chip->mutex); | ||
1312 | |||
1313 | switch(chip->state) { | ||
1314 | case FL_READY: | ||
1315 | case FL_STATUS: | ||
1316 | case FL_CFI_QUERY: | ||
1317 | case FL_JEDEC_QUERY: | ||
1318 | chip->oldstate = chip->state; | ||
1319 | chip->state = FL_SYNCING; | ||
1320 | /* No need to wake_up() on this state change - | ||
1321 | * as the whole point is that nobody can do anything | ||
1322 | * with the chip now anyway. | ||
1323 | */ | ||
1324 | case FL_SYNCING: | ||
1325 | spin_unlock_bh(chip->mutex); | ||
1326 | break; | ||
1327 | |||
1328 | default: | ||
1329 | /* Not an idle state */ | ||
1330 | add_wait_queue(&chip->wq, &wait); | ||
1331 | |||
1332 | spin_unlock_bh(chip->mutex); | ||
1333 | |||
1334 | schedule(); | ||
1335 | |||
1336 | remove_wait_queue(&chip->wq, &wait); | ||
1337 | |||
1338 | goto retry; | ||
1339 | } | ||
1340 | } | ||
1341 | |||
1342 | /* Unlock the chips again */ | ||
1343 | for (i--; i >= 0; i--) { | ||
1344 | chip = &private->chips[i]; | ||
1345 | |||
1346 | spin_lock_bh(chip->mutex); | ||
1347 | |||
1348 | if (chip->state == FL_SYNCING) { | ||
1349 | chip->state = chip->oldstate; | ||
1350 | wake_up(&chip->wq); | ||
1351 | } | ||
1352 | spin_unlock_bh(chip->mutex); | ||
1353 | } | ||
1354 | } | ||
1355 | |||
1356 | |||
1357 | |||
1358 | static int amd_flash_suspend(struct mtd_info *mtd) | ||
1359 | { | ||
1360 | printk("amd_flash_suspend(): not implemented!\n"); | ||
1361 | return -EINVAL; | ||
1362 | } | ||
1363 | |||
1364 | |||
1365 | |||
1366 | static void amd_flash_resume(struct mtd_info *mtd) | ||
1367 | { | ||
1368 | printk("amd_flash_resume(): not implemented!\n"); | ||
1369 | } | ||
1370 | |||
1371 | |||
1372 | |||
1373 | static void amd_flash_destroy(struct mtd_info *mtd) | ||
1374 | { | ||
1375 | struct map_info *map = mtd->priv; | ||
1376 | struct amd_flash_private *private = map->fldrv_priv; | ||
1377 | kfree(private); | ||
1378 | } | ||
1379 | |||
1380 | int __init amd_flash_init(void) | ||
1381 | { | ||
1382 | register_mtd_chip_driver(&amd_flash_chipdrv); | ||
1383 | return 0; | ||
1384 | } | ||
1385 | |||
1386 | void __exit amd_flash_exit(void) | ||
1387 | { | ||
1388 | unregister_mtd_chip_driver(&amd_flash_chipdrv); | ||
1389 | } | ||
1390 | |||
1391 | module_init(amd_flash_init); | ||
1392 | module_exit(amd_flash_exit); | ||
1393 | |||
1394 | MODULE_LICENSE("GPL"); | ||
1395 | MODULE_AUTHOR("Jonas Holmberg <jonas.holmberg@axis.com>"); | ||
1396 | MODULE_DESCRIPTION("Old MTD chip driver for AMD flash chips"); | ||
diff --git a/drivers/mtd/chips/jedec.c b/drivers/mtd/chips/jedec.c deleted file mode 100644 index 14e57b2bf842..000000000000 --- a/drivers/mtd/chips/jedec.c +++ /dev/null | |||
@@ -1,935 +0,0 @@ | |||
1 | |||
2 | /* JEDEC Flash Interface. | ||
3 | * This is an older type of interface for self programming flash. It is | ||
4 | * commonly use in older AMD chips and is obsolete compared with CFI. | ||
5 | * It is called JEDEC because the JEDEC association distributes the ID codes | ||
6 | * for the chips. | ||
7 | * | ||
8 | * See the AMD flash databook for information on how to operate the interface. | ||
9 | * | ||
10 | * This code does not support anything wider than 8 bit flash chips, I am | ||
11 | * not going to guess how to send commands to them, plus I expect they will | ||
12 | * all speak CFI.. | ||
13 | * | ||
14 | * $Id: jedec.c,v 1.22 2005/01/05 18:05:11 dwmw2 Exp $ | ||
15 | */ | ||
16 | |||
17 | #include <linux/init.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/mtd/jedec.h> | ||
22 | #include <linux/mtd/map.h> | ||
23 | #include <linux/mtd/mtd.h> | ||
24 | #include <linux/mtd/compatmac.h> | ||
25 | |||
26 | static struct mtd_info *jedec_probe(struct map_info *); | ||
27 | static int jedec_probe8(struct map_info *map,unsigned long base, | ||
28 | struct jedec_private *priv); | ||
29 | static int jedec_probe16(struct map_info *map,unsigned long base, | ||
30 | struct jedec_private *priv); | ||
31 | static int jedec_probe32(struct map_info *map,unsigned long base, | ||
32 | struct jedec_private *priv); | ||
33 | static void jedec_flash_chip_scan(struct jedec_private *priv,unsigned long start, | ||
34 | unsigned long len); | ||
35 | static int flash_erase(struct mtd_info *mtd, struct erase_info *instr); | ||
36 | static int flash_write(struct mtd_info *mtd, loff_t start, size_t len, | ||
37 | size_t *retlen, const u_char *buf); | ||
38 | |||
39 | static unsigned long my_bank_size; | ||
40 | |||
41 | /* Listing of parts and sizes. We need this table to learn the sector | ||
42 | size of the chip and the total length */ | ||
43 | static const struct JEDECTable JEDEC_table[] = { | ||
44 | { | ||
45 | .jedec = 0x013D, | ||
46 | .name = "AMD Am29F017D", | ||
47 | .size = 2*1024*1024, | ||
48 | .sectorsize = 64*1024, | ||
49 | .capabilities = MTD_CAP_NORFLASH | ||
50 | }, | ||
51 | { | ||
52 | .jedec = 0x01AD, | ||
53 | .name = "AMD Am29F016", | ||
54 | .size = 2*1024*1024, | ||
55 | .sectorsize = 64*1024, | ||
56 | .capabilities = MTD_CAP_NORFLASH | ||
57 | }, | ||
58 | { | ||
59 | .jedec = 0x01D5, | ||
60 | .name = "AMD Am29F080", | ||
61 | .size = 1*1024*1024, | ||
62 | .sectorsize = 64*1024, | ||
63 | .capabilities = MTD_CAP_NORFLASH | ||
64 | }, | ||
65 | { | ||
66 | .jedec = 0x01A4, | ||
67 | .name = "AMD Am29F040", | ||
68 | .size = 512*1024, | ||
69 | .sectorsize = 64*1024, | ||
70 | .capabilities = MTD_CAP_NORFLASH | ||
71 | }, | ||
72 | { | ||
73 | .jedec = 0x20E3, | ||
74 | .name = "AMD Am29W040B", | ||
75 | .size = 512*1024, | ||
76 | .sectorsize = 64*1024, | ||
77 | .capabilities = MTD_CAP_NORFLASH | ||
78 | }, | ||
79 | { | ||
80 | .jedec = 0xC2AD, | ||
81 | .name = "Macronix MX29F016", | ||
82 | .size = 2*1024*1024, | ||
83 | .sectorsize = 64*1024, | ||
84 | .capabilities = MTD_CAP_NORFLASH | ||
85 | }, | ||
86 | { .jedec = 0x0 } | ||
87 | }; | ||
88 | |||
89 | static const struct JEDECTable *jedec_idtoinf(__u8 mfr,__u8 id); | ||
90 | static void jedec_sync(struct mtd_info *mtd) {}; | ||
91 | static int jedec_read(struct mtd_info *mtd, loff_t from, size_t len, | ||
92 | size_t *retlen, u_char *buf); | ||
93 | static int jedec_read_banked(struct mtd_info *mtd, loff_t from, size_t len, | ||
94 | size_t *retlen, u_char *buf); | ||
95 | |||
96 | static struct mtd_info *jedec_probe(struct map_info *map); | ||
97 | |||
98 | |||
99 | |||
100 | static struct mtd_chip_driver jedec_chipdrv = { | ||
101 | .probe = jedec_probe, | ||
102 | .name = "jedec", | ||
103 | .module = THIS_MODULE | ||
104 | }; | ||
105 | |||
106 | /* Probe entry point */ | ||
107 | |||
108 | static struct mtd_info *jedec_probe(struct map_info *map) | ||
109 | { | ||
110 | struct mtd_info *MTD; | ||
111 | struct jedec_private *priv; | ||
112 | unsigned long Base; | ||
113 | unsigned long SectorSize; | ||
114 | unsigned count; | ||
115 | unsigned I,Uniq; | ||
116 | char Part[200]; | ||
117 | memset(&priv,0,sizeof(priv)); | ||
118 | |||
119 | MTD = kzalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL); | ||
120 | if (!MTD) | ||
121 | return NULL; | ||
122 | |||
123 | priv = (struct jedec_private *)&MTD[1]; | ||
124 | |||
125 | my_bank_size = map->size; | ||
126 | |||
127 | if (map->size/my_bank_size > MAX_JEDEC_CHIPS) | ||
128 | { | ||
129 | printk("mtd: Increase MAX_JEDEC_CHIPS, too many banks.\n"); | ||
130 | kfree(MTD); | ||
131 | return NULL; | ||
132 | } | ||
133 | |||
134 | for (Base = 0; Base < map->size; Base += my_bank_size) | ||
135 | { | ||
136 | // Perhaps zero could designate all tests? | ||
137 | if (map->buswidth == 0) | ||
138 | map->buswidth = 1; | ||
139 | |||
140 | if (map->buswidth == 1){ | ||
141 | if (jedec_probe8(map,Base,priv) == 0) { | ||
142 | printk("did recognize jedec chip\n"); | ||
143 | kfree(MTD); | ||
144 | return NULL; | ||
145 | } | ||
146 | } | ||
147 | if (map->buswidth == 2) | ||
148 | jedec_probe16(map,Base,priv); | ||
149 | if (map->buswidth == 4) | ||
150 | jedec_probe32(map,Base,priv); | ||
151 | } | ||
152 | |||
153 | // Get the biggest sector size | ||
154 | SectorSize = 0; | ||
155 | for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) | ||
156 | { | ||
157 | // printk("priv->chips[%d].jedec is %x\n",I,priv->chips[I].jedec); | ||
158 | // printk("priv->chips[%d].sectorsize is %lx\n",I,priv->chips[I].sectorsize); | ||
159 | if (priv->chips[I].sectorsize > SectorSize) | ||
160 | SectorSize = priv->chips[I].sectorsize; | ||
161 | } | ||
162 | |||
163 | // Quickly ensure that the other sector sizes are factors of the largest | ||
164 | for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) | ||
165 | { | ||
166 | if ((SectorSize/priv->chips[I].sectorsize)*priv->chips[I].sectorsize != SectorSize) | ||
167 | { | ||
168 | printk("mtd: Failed. Device has incompatible mixed sector sizes\n"); | ||
169 | kfree(MTD); | ||
170 | return NULL; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | /* Generate a part name that includes the number of different chips and | ||
175 | other configuration information */ | ||
176 | count = 1; | ||
177 | strlcpy(Part,map->name,sizeof(Part)-10); | ||
178 | strcat(Part," "); | ||
179 | Uniq = 0; | ||
180 | for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) | ||
181 | { | ||
182 | const struct JEDECTable *JEDEC; | ||
183 | |||
184 | if (priv->chips[I+1].jedec == priv->chips[I].jedec) | ||
185 | { | ||
186 | count++; | ||
187 | continue; | ||
188 | } | ||
189 | |||
190 | // Locate the chip in the jedec table | ||
191 | JEDEC = jedec_idtoinf(priv->chips[I].jedec >> 8,priv->chips[I].jedec); | ||
192 | if (JEDEC == 0) | ||
193 | { | ||
194 | printk("mtd: Internal Error, JEDEC not set\n"); | ||
195 | kfree(MTD); | ||
196 | return NULL; | ||
197 | } | ||
198 | |||
199 | if (Uniq != 0) | ||
200 | strcat(Part,","); | ||
201 | Uniq++; | ||
202 | |||
203 | if (count != 1) | ||
204 | sprintf(Part+strlen(Part),"%x*[%s]",count,JEDEC->name); | ||
205 | else | ||
206 | sprintf(Part+strlen(Part),"%s",JEDEC->name); | ||
207 | if (strlen(Part) > sizeof(Part)*2/3) | ||
208 | break; | ||
209 | count = 1; | ||
210 | } | ||
211 | |||
212 | /* Determine if the chips are organized in a linear fashion, or if there | ||
213 | are empty banks. Note, the last bank does not count here, only the | ||
214 | first banks are important. Holes on non-bank boundaries can not exist | ||
215 | due to the way the detection algorithm works. */ | ||
216 | if (priv->size < my_bank_size) | ||
217 | my_bank_size = priv->size; | ||
218 | priv->is_banked = 0; | ||
219 | //printk("priv->size is %x, my_bank_size is %x\n",priv->size,my_bank_size); | ||
220 | //printk("priv->bank_fill[0] is %x\n",priv->bank_fill[0]); | ||
221 | if (!priv->size) { | ||
222 | printk("priv->size is zero\n"); | ||
223 | kfree(MTD); | ||
224 | return NULL; | ||
225 | } | ||
226 | if (priv->size/my_bank_size) { | ||
227 | if (priv->size/my_bank_size == 1) { | ||
228 | priv->size = my_bank_size; | ||
229 | } | ||
230 | else { | ||
231 | for (I = 0; I != priv->size/my_bank_size - 1; I++) | ||
232 | { | ||
233 | if (priv->bank_fill[I] != my_bank_size) | ||
234 | priv->is_banked = 1; | ||
235 | |||
236 | /* This even could be eliminated, but new de-optimized read/write | ||
237 | functions have to be written */ | ||
238 | printk("priv->bank_fill[%d] is %lx, priv->bank_fill[0] is %lx\n",I,priv->bank_fill[I],priv->bank_fill[0]); | ||
239 | if (priv->bank_fill[I] != priv->bank_fill[0]) | ||
240 | { | ||
241 | printk("mtd: Failed. Cannot handle unsymmetric banking\n"); | ||
242 | kfree(MTD); | ||
243 | return NULL; | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | if (priv->is_banked == 1) | ||
249 | strcat(Part,", banked"); | ||
250 | |||
251 | // printk("Part: '%s'\n",Part); | ||
252 | |||
253 | memset(MTD,0,sizeof(*MTD)); | ||
254 | // strlcpy(MTD->name,Part,sizeof(MTD->name)); | ||
255 | MTD->name = map->name; | ||
256 | MTD->type = MTD_NORFLASH; | ||
257 | MTD->flags = MTD_CAP_NORFLASH; | ||
258 | MTD->writesize = 1; | ||
259 | MTD->erasesize = SectorSize*(map->buswidth); | ||
260 | // printk("MTD->erasesize is %x\n",(unsigned int)MTD->erasesize); | ||
261 | MTD->size = priv->size; | ||
262 | // printk("MTD->size is %x\n",(unsigned int)MTD->size); | ||
263 | //MTD->module = THIS_MODULE; // ? Maybe this should be the low level module? | ||
264 | MTD->erase = flash_erase; | ||
265 | if (priv->is_banked == 1) | ||
266 | MTD->read = jedec_read_banked; | ||
267 | else | ||
268 | MTD->read = jedec_read; | ||
269 | MTD->write = flash_write; | ||
270 | MTD->sync = jedec_sync; | ||
271 | MTD->priv = map; | ||
272 | map->fldrv_priv = priv; | ||
273 | map->fldrv = &jedec_chipdrv; | ||
274 | __module_get(THIS_MODULE); | ||
275 | return MTD; | ||
276 | } | ||
277 | |||
278 | /* Helper for the JEDEC function, JEDEC numbers all have odd parity */ | ||
279 | static int checkparity(u_char C) | ||
280 | { | ||
281 | u_char parity = 0; | ||
282 | while (C != 0) | ||
283 | { | ||
284 | parity ^= C & 1; | ||
285 | C >>= 1; | ||
286 | } | ||
287 | |||
288 | return parity == 1; | ||
289 | } | ||
290 | |||
291 | |||
292 | /* Take an array of JEDEC numbers that represent interleved flash chips | ||
293 | and process them. Check to make sure they are good JEDEC numbers, look | ||
294 | them up and then add them to the chip list */ | ||
295 | static int handle_jedecs(struct map_info *map,__u8 *Mfg,__u8 *Id,unsigned Count, | ||
296 | unsigned long base,struct jedec_private *priv) | ||
297 | { | ||
298 | unsigned I,J; | ||
299 | unsigned long Size; | ||
300 | unsigned long SectorSize; | ||
301 | const struct JEDECTable *JEDEC; | ||
302 | |||
303 | // Test #2 JEDEC numbers exhibit odd parity | ||
304 | for (I = 0; I != Count; I++) | ||
305 | { | ||
306 | if (checkparity(Mfg[I]) == 0 || checkparity(Id[I]) == 0) | ||
307 | return 0; | ||
308 | } | ||
309 | |||
310 | // Finally, just make sure all the chip sizes are the same | ||
311 | JEDEC = jedec_idtoinf(Mfg[0],Id[0]); | ||
312 | |||
313 | if (JEDEC == 0) | ||
314 | { | ||
315 | printk("mtd: Found JEDEC flash chip, but do not have a table entry for %x:%x\n",Mfg[0],Mfg[1]); | ||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | Size = JEDEC->size; | ||
320 | SectorSize = JEDEC->sectorsize; | ||
321 | for (I = 0; I != Count; I++) | ||
322 | { | ||
323 | JEDEC = jedec_idtoinf(Mfg[0],Id[0]); | ||
324 | if (JEDEC == 0) | ||
325 | { | ||
326 | printk("mtd: Found JEDEC flash chip, but do not have a table entry for %x:%x\n",Mfg[0],Mfg[1]); | ||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | if (Size != JEDEC->size || SectorSize != JEDEC->sectorsize) | ||
331 | { | ||
332 | printk("mtd: Failed. Interleved flash does not have matching characteristics\n"); | ||
333 | return 0; | ||
334 | } | ||
335 | } | ||
336 | |||
337 | // Load the Chips | ||
338 | for (I = 0; I != MAX_JEDEC_CHIPS; I++) | ||
339 | { | ||
340 | if (priv->chips[I].jedec == 0) | ||
341 | break; | ||
342 | } | ||
343 | |||
344 | if (I + Count > MAX_JEDEC_CHIPS) | ||
345 | { | ||
346 | printk("mtd: Device has too many chips. Increase MAX_JEDEC_CHIPS\n"); | ||
347 | return 0; | ||
348 | } | ||
349 | |||
350 | // Add them to the table | ||
351 | for (J = 0; J != Count; J++) | ||
352 | { | ||
353 | unsigned long Bank; | ||
354 | |||
355 | JEDEC = jedec_idtoinf(Mfg[J],Id[J]); | ||
356 | priv->chips[I].jedec = (Mfg[J] << 8) | Id[J]; | ||
357 | priv->chips[I].size = JEDEC->size; | ||
358 | priv->chips[I].sectorsize = JEDEC->sectorsize; | ||
359 | priv->chips[I].base = base + J; | ||
360 | priv->chips[I].datashift = J*8; | ||
361 | priv->chips[I].capabilities = JEDEC->capabilities; | ||
362 | priv->chips[I].offset = priv->size + J; | ||
363 | |||
364 | // log2 n :| | ||
365 | priv->chips[I].addrshift = 0; | ||
366 | for (Bank = Count; Bank != 1; Bank >>= 1, priv->chips[I].addrshift++); | ||
367 | |||
368 | // Determine how filled this bank is. | ||
369 | Bank = base & (~(my_bank_size-1)); | ||
370 | if (priv->bank_fill[Bank/my_bank_size] < base + | ||
371 | (JEDEC->size << priv->chips[I].addrshift) - Bank) | ||
372 | priv->bank_fill[Bank/my_bank_size] = base + (JEDEC->size << priv->chips[I].addrshift) - Bank; | ||
373 | I++; | ||
374 | } | ||
375 | |||
376 | priv->size += priv->chips[I-1].size*Count; | ||
377 | |||
378 | return priv->chips[I-1].size; | ||
379 | } | ||
380 | |||
381 | /* Lookup the chip information from the JEDEC ID table. */ | ||
382 | static const struct JEDECTable *jedec_idtoinf(__u8 mfr,__u8 id) | ||
383 | { | ||
384 | __u16 Id = (mfr << 8) | id; | ||
385 | unsigned long I = 0; | ||
386 | for (I = 0; JEDEC_table[I].jedec != 0; I++) | ||
387 | if (JEDEC_table[I].jedec == Id) | ||
388 | return JEDEC_table + I; | ||
389 | return NULL; | ||
390 | } | ||
391 | |||
392 | // Look for flash using an 8 bit bus interface | ||
393 | static int jedec_probe8(struct map_info *map,unsigned long base, | ||
394 | struct jedec_private *priv) | ||
395 | { | ||
396 | #define flread(x) map_read8(map,base+x) | ||
397 | #define flwrite(v,x) map_write8(map,v,base+x) | ||
398 | |||
399 | const unsigned long AutoSel1 = 0xAA; | ||
400 | const unsigned long AutoSel2 = 0x55; | ||
401 | const unsigned long AutoSel3 = 0x90; | ||
402 | const unsigned long Reset = 0xF0; | ||
403 | __u32 OldVal; | ||
404 | __u8 Mfg[1]; | ||
405 | __u8 Id[1]; | ||
406 | unsigned I; | ||
407 | unsigned long Size; | ||
408 | |||
409 | // Wait for any write/erase operation to settle | ||
410 | OldVal = flread(base); | ||
411 | for (I = 0; OldVal != flread(base) && I < 10000; I++) | ||
412 | OldVal = flread(base); | ||
413 | |||
414 | // Reset the chip | ||
415 | flwrite(Reset,0x555); | ||
416 | |||
417 | // Send the sequence | ||
418 | flwrite(AutoSel1,0x555); | ||
419 | flwrite(AutoSel2,0x2AA); | ||
420 | flwrite(AutoSel3,0x555); | ||
421 | |||
422 | // Get the JEDEC numbers | ||
423 | Mfg[0] = flread(0); | ||
424 | Id[0] = flread(1); | ||
425 | // printk("Mfg is %x, Id is %x\n",Mfg[0],Id[0]); | ||
426 | |||
427 | Size = handle_jedecs(map,Mfg,Id,1,base,priv); | ||
428 | // printk("handle_jedecs Size is %x\n",(unsigned int)Size); | ||
429 | if (Size == 0) | ||
430 | { | ||
431 | flwrite(Reset,0x555); | ||
432 | return 0; | ||
433 | } | ||
434 | |||
435 | |||
436 | // Reset. | ||
437 | flwrite(Reset,0x555); | ||
438 | |||
439 | return 1; | ||
440 | |||
441 | #undef flread | ||
442 | #undef flwrite | ||
443 | } | ||
444 | |||
445 | // Look for flash using a 16 bit bus interface (ie 2 8-bit chips) | ||
446 | static int jedec_probe16(struct map_info *map,unsigned long base, | ||
447 | struct jedec_private *priv) | ||
448 | { | ||
449 | return 0; | ||
450 | } | ||
451 | |||
452 | // Look for flash using a 32 bit bus interface (ie 4 8-bit chips) | ||
453 | static int jedec_probe32(struct map_info *map,unsigned long base, | ||
454 | struct jedec_private *priv) | ||
455 | { | ||
456 | #define flread(x) map_read32(map,base+((x)<<2)) | ||
457 | #define flwrite(v,x) map_write32(map,v,base+((x)<<2)) | ||
458 | |||
459 | const unsigned long AutoSel1 = 0xAAAAAAAA; | ||
460 | const unsigned long AutoSel2 = 0x55555555; | ||
461 | const unsigned long AutoSel3 = 0x90909090; | ||
462 | const unsigned long Reset = 0xF0F0F0F0; | ||
463 | __u32 OldVal; | ||
464 | __u8 Mfg[4]; | ||
465 | __u8 Id[4]; | ||
466 | unsigned I; | ||
467 | unsigned long Size; | ||
468 | |||
469 | // Wait for any write/erase operation to settle | ||
470 | OldVal = flread(base); | ||
471 | for (I = 0; OldVal != flread(base) && I < 10000; I++) | ||
472 | OldVal = flread(base); | ||
473 | |||
474 | // Reset the chip | ||
475 | flwrite(Reset,0x555); | ||
476 | |||
477 | // Send the sequence | ||
478 | flwrite(AutoSel1,0x555); | ||
479 | flwrite(AutoSel2,0x2AA); | ||
480 | flwrite(AutoSel3,0x555); | ||
481 | |||
482 | // Test #1, JEDEC numbers are readable from 0x??00/0x??01 | ||
483 | if (flread(0) != flread(0x100) || | ||
484 | flread(1) != flread(0x101)) | ||
485 | { | ||
486 | flwrite(Reset,0x555); | ||
487 | return 0; | ||
488 | } | ||
489 | |||
490 | // Split up the JEDEC numbers | ||
491 | OldVal = flread(0); | ||
492 | for (I = 0; I != 4; I++) | ||
493 | Mfg[I] = (OldVal >> (I*8)); | ||
494 | OldVal = flread(1); | ||
495 | for (I = 0; I != 4; I++) | ||
496 | Id[I] = (OldVal >> (I*8)); | ||
497 | |||
498 | Size = handle_jedecs(map,Mfg,Id,4,base,priv); | ||
499 | if (Size == 0) | ||
500 | { | ||
501 | flwrite(Reset,0x555); | ||
502 | return 0; | ||
503 | } | ||
504 | |||
505 | /* Check if there is address wrap around within a single bank, if this | ||
506 | returns JEDEC numbers then we assume that it is wrap around. Notice | ||
507 | we call this routine with the JEDEC return still enabled, if two or | ||
508 | more flashes have a truncated address space the probe test will still | ||
509 | work */ | ||
510 | if (base + (Size<<2)+0x555 < map->size && | ||
511 | base + (Size<<2)+0x555 < (base & (~(my_bank_size-1))) + my_bank_size) | ||
512 | { | ||
513 | if (flread(base+Size) != flread(base+Size + 0x100) || | ||
514 | flread(base+Size + 1) != flread(base+Size + 0x101)) | ||
515 | { | ||
516 | jedec_probe32(map,base+Size,priv); | ||
517 | } | ||
518 | } | ||
519 | |||
520 | // Reset. | ||
521 | flwrite(0xF0F0F0F0,0x555); | ||
522 | |||
523 | return 1; | ||
524 | |||
525 | #undef flread | ||
526 | #undef flwrite | ||
527 | } | ||
528 | |||
529 | /* Linear read. */ | ||
530 | static int jedec_read(struct mtd_info *mtd, loff_t from, size_t len, | ||
531 | size_t *retlen, u_char *buf) | ||
532 | { | ||
533 | struct map_info *map = mtd->priv; | ||
534 | |||
535 | map_copy_from(map, buf, from, len); | ||
536 | *retlen = len; | ||
537 | return 0; | ||
538 | } | ||
539 | |||
540 | /* Banked read. Take special care to jump past the holes in the bank | ||
541 | mapping. This version assumes symetry in the holes.. */ | ||
542 | static int jedec_read_banked(struct mtd_info *mtd, loff_t from, size_t len, | ||
543 | size_t *retlen, u_char *buf) | ||
544 | { | ||
545 | struct map_info *map = mtd->priv; | ||
546 | struct jedec_private *priv = map->fldrv_priv; | ||
547 | |||
548 | *retlen = 0; | ||
549 | while (len > 0) | ||
550 | { | ||
551 | // Determine what bank and offset into that bank the first byte is | ||
552 | unsigned long bank = from & (~(priv->bank_fill[0]-1)); | ||
553 | unsigned long offset = from & (priv->bank_fill[0]-1); | ||
554 | unsigned long get = len; | ||
555 | if (priv->bank_fill[0] - offset < len) | ||
556 | get = priv->bank_fill[0] - offset; | ||
557 | |||
558 | bank /= priv->bank_fill[0]; | ||
559 | map_copy_from(map,buf + *retlen,bank*my_bank_size + offset,get); | ||
560 | |||
561 | len -= get; | ||
562 | *retlen += get; | ||
563 | from += get; | ||
564 | } | ||
565 | return 0; | ||
566 | } | ||
567 | |||
568 | /* Pass the flags value that the flash return before it re-entered read | ||
569 | mode. */ | ||
570 | static void jedec_flash_failed(unsigned char code) | ||
571 | { | ||
572 | /* Bit 5 being high indicates that there was an internal device | ||
573 | failure, erasure time limits exceeded or something */ | ||
574 | if ((code & (1 << 5)) != 0) | ||
575 | { | ||
576 | printk("mtd: Internal Flash failure\n"); | ||
577 | return; | ||
578 | } | ||
579 | printk("mtd: Programming didn't take\n"); | ||
580 | } | ||
581 | |||
582 | /* This uses the erasure function described in the AMD Flash Handbook, | ||
583 | it will work for flashes with a fixed sector size only. Flashes with | ||
584 | a selection of sector sizes (ie the AMD Am29F800B) will need a different | ||
585 | routine. This routine tries to parallize erasing multiple chips/sectors | ||
586 | where possible */ | ||
587 | static int flash_erase(struct mtd_info *mtd, struct erase_info *instr) | ||
588 | { | ||
589 | // Does IO to the currently selected chip | ||
590 | #define flread(x) map_read8(map,chip->base+((x)<<chip->addrshift)) | ||
591 | #define flwrite(v,x) map_write8(map,v,chip->base+((x)<<chip->addrshift)) | ||
592 | |||
593 | unsigned long Time = 0; | ||
594 | unsigned long NoTime = 0; | ||
595 | unsigned long start = instr->addr, len = instr->len; | ||
596 | unsigned int I; | ||
597 | struct map_info *map = mtd->priv; | ||
598 | struct jedec_private *priv = map->fldrv_priv; | ||
599 | |||
600 | // Verify the arguments.. | ||
601 | if (start + len > mtd->size || | ||
602 | (start % mtd->erasesize) != 0 || | ||
603 | (len % mtd->erasesize) != 0 || | ||
604 | (len/mtd->erasesize) == 0) | ||
605 | return -EINVAL; | ||
606 | |||
607 | jedec_flash_chip_scan(priv,start,len); | ||
608 | |||
609 | // Start the erase sequence on each chip | ||
610 | for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) | ||
611 | { | ||
612 | unsigned long off; | ||
613 | struct jedec_flash_chip *chip = priv->chips + I; | ||
614 | |||
615 | if (chip->length == 0) | ||
616 | continue; | ||
617 | |||
618 | if (chip->start + chip->length > chip->size) | ||
619 | { | ||
620 | printk("DIE\n"); | ||
621 | return -EIO; | ||
622 | } | ||
623 | |||
624 | flwrite(0xF0,chip->start + 0x555); | ||
625 | flwrite(0xAA,chip->start + 0x555); | ||
626 | flwrite(0x55,chip->start + 0x2AA); | ||
627 | flwrite(0x80,chip->start + 0x555); | ||
628 | flwrite(0xAA,chip->start + 0x555); | ||
629 | flwrite(0x55,chip->start + 0x2AA); | ||
630 | |||
631 | /* Once we start selecting the erase sectors the delay between each | ||
632 | command must not exceed 50us or it will immediately start erasing | ||
633 | and ignore the other sectors */ | ||
634 | for (off = 0; off < len; off += chip->sectorsize) | ||
635 | { | ||
636 | // Check to make sure we didn't timeout | ||
637 | flwrite(0x30,chip->start + off); | ||
638 | if (off == 0) | ||
639 | continue; | ||
640 | if ((flread(chip->start + off) & (1 << 3)) != 0) | ||
641 | { | ||
642 | printk("mtd: Ack! We timed out the erase timer!\n"); | ||
643 | return -EIO; | ||
644 | } | ||
645 | } | ||
646 | } | ||
647 | |||
648 | /* We could split this into a timer routine and return early, performing | ||
649 | background erasure.. Maybe later if the need warrents */ | ||
650 | |||
651 | /* Poll the flash for erasure completion, specs say this can take as long | ||
652 | as 480 seconds to do all the sectors (for a 2 meg flash). | ||
653 | Erasure time is dependent on chip age, temp and wear.. */ | ||
654 | |||
655 | /* This being a generic routine assumes a 32 bit bus. It does read32s | ||
656 | and bundles interleved chips into the same grouping. This will work | ||
657 | for all bus widths */ | ||
658 | Time = 0; | ||
659 | NoTime = 0; | ||
660 | for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) | ||
661 | { | ||
662 | struct jedec_flash_chip *chip = priv->chips + I; | ||
663 | unsigned long off = 0; | ||
664 | unsigned todo[4] = {0,0,0,0}; | ||
665 | unsigned todo_left = 0; | ||
666 | unsigned J; | ||
667 | |||
668 | if (chip->length == 0) | ||
669 | continue; | ||
670 | |||
671 | /* Find all chips in this data line, realistically this is all | ||
672 | or nothing up to the interleve count */ | ||
673 | for (J = 0; priv->chips[J].jedec != 0 && J < MAX_JEDEC_CHIPS; J++) | ||
674 | { | ||
675 | if ((priv->chips[J].base & (~((1<<chip->addrshift)-1))) == | ||
676 | (chip->base & (~((1<<chip->addrshift)-1)))) | ||
677 | { | ||
678 | todo_left++; | ||
679 | todo[priv->chips[J].base & ((1<<chip->addrshift)-1)] = 1; | ||
680 | } | ||
681 | } | ||
682 | |||
683 | /* printk("todo: %x %x %x %x\n",(short)todo[0],(short)todo[1], | ||
684 | (short)todo[2],(short)todo[3]); | ||
685 | */ | ||
686 | while (1) | ||
687 | { | ||
688 | __u32 Last[4]; | ||
689 | unsigned long Count = 0; | ||
690 | |||
691 | /* During erase bit 7 is held low and bit 6 toggles, we watch this, | ||
692 | should it stop toggling or go high then the erase is completed, | ||
693 | or this is not really flash ;> */ | ||
694 | switch (map->buswidth) { | ||
695 | case 1: | ||
696 | Last[0] = map_read8(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
697 | Last[1] = map_read8(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
698 | Last[2] = map_read8(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
699 | break; | ||
700 | case 2: | ||
701 | Last[0] = map_read16(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
702 | Last[1] = map_read16(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
703 | Last[2] = map_read16(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
704 | break; | ||
705 | case 3: | ||
706 | Last[0] = map_read32(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
707 | Last[1] = map_read32(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
708 | Last[2] = map_read32(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
709 | break; | ||
710 | } | ||
711 | Count = 3; | ||
712 | while (todo_left != 0) | ||
713 | { | ||
714 | for (J = 0; J != 4; J++) | ||
715 | { | ||
716 | __u8 Byte1 = (Last[(Count-1)%4] >> (J*8)) & 0xFF; | ||
717 | __u8 Byte2 = (Last[(Count-2)%4] >> (J*8)) & 0xFF; | ||
718 | __u8 Byte3 = (Last[(Count-3)%4] >> (J*8)) & 0xFF; | ||
719 | if (todo[J] == 0) | ||
720 | continue; | ||
721 | |||
722 | if ((Byte1 & (1 << 7)) == 0 && Byte1 != Byte2) | ||
723 | { | ||
724 | // printk("Check %x %x %x\n",(short)J,(short)Byte1,(short)Byte2); | ||
725 | continue; | ||
726 | } | ||
727 | |||
728 | if (Byte1 == Byte2) | ||
729 | { | ||
730 | jedec_flash_failed(Byte3); | ||
731 | return -EIO; | ||
732 | } | ||
733 | |||
734 | todo[J] = 0; | ||
735 | todo_left--; | ||
736 | } | ||
737 | |||
738 | /* if (NoTime == 0) | ||
739 | Time += HZ/10 - schedule_timeout(HZ/10);*/ | ||
740 | NoTime = 0; | ||
741 | |||
742 | switch (map->buswidth) { | ||
743 | case 1: | ||
744 | Last[Count % 4] = map_read8(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
745 | break; | ||
746 | case 2: | ||
747 | Last[Count % 4] = map_read16(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
748 | break; | ||
749 | case 4: | ||
750 | Last[Count % 4] = map_read32(map,(chip->base >> chip->addrshift) + chip->start + off); | ||
751 | break; | ||
752 | } | ||
753 | Count++; | ||
754 | |||
755 | /* // Count time, max of 15s per sector (according to AMD) | ||
756 | if (Time > 15*len/mtd->erasesize*HZ) | ||
757 | { | ||
758 | printk("mtd: Flash Erase Timed out\n"); | ||
759 | return -EIO; | ||
760 | } */ | ||
761 | } | ||
762 | |||
763 | // Skip to the next chip if we used chip erase | ||
764 | if (chip->length == chip->size) | ||
765 | off = chip->size; | ||
766 | else | ||
767 | off += chip->sectorsize; | ||
768 | |||
769 | if (off >= chip->length) | ||
770 | break; | ||
771 | NoTime = 1; | ||
772 | } | ||
773 | |||
774 | for (J = 0; priv->chips[J].jedec != 0 && J < MAX_JEDEC_CHIPS; J++) | ||
775 | { | ||
776 | if ((priv->chips[J].base & (~((1<<chip->addrshift)-1))) == | ||
777 | (chip->base & (~((1<<chip->addrshift)-1)))) | ||
778 | priv->chips[J].length = 0; | ||
779 | } | ||
780 | } | ||
781 | |||
782 | //printk("done\n"); | ||
783 | instr->state = MTD_ERASE_DONE; | ||
784 | mtd_erase_callback(instr); | ||
785 | return 0; | ||
786 | |||
787 | #undef flread | ||
788 | #undef flwrite | ||
789 | } | ||
790 | |||
791 | /* This is the simple flash writing function. It writes to every byte, in | ||
792 | sequence. It takes care of how to properly address the flash if | ||
793 | the flash is interleved. It can only be used if all the chips in the | ||
794 | array are identical!*/ | ||
795 | static int flash_write(struct mtd_info *mtd, loff_t start, size_t len, | ||
796 | size_t *retlen, const u_char *buf) | ||
797 | { | ||
798 | /* Does IO to the currently selected chip. It takes the bank addressing | ||
799 | base (which is divisible by the chip size) adds the necessary lower bits | ||
800 | of addrshift (interleave index) and then adds the control register index. */ | ||
801 | #define flread(x) map_read8(map,base+(off&((1<<chip->addrshift)-1))+((x)<<chip->addrshift)) | ||
802 | #define flwrite(v,x) map_write8(map,v,base+(off&((1<<chip->addrshift)-1))+((x)<<chip->addrshift)) | ||
803 | |||
804 | struct map_info *map = mtd->priv; | ||
805 | struct jedec_private *priv = map->fldrv_priv; | ||
806 | unsigned long base; | ||
807 | unsigned long off; | ||
808 | size_t save_len = len; | ||
809 | |||
810 | if (start + len > mtd->size) | ||
811 | return -EIO; | ||
812 | |||
813 | //printk("Here"); | ||
814 | |||
815 | //printk("flash_write: start is %x, len is %x\n",start,(unsigned long)len); | ||
816 | while (len != 0) | ||
817 | { | ||
818 | struct jedec_flash_chip *chip = priv->chips; | ||
819 | unsigned long bank; | ||
820 | unsigned long boffset; | ||
821 | |||
822 | // Compute the base of the flash. | ||
823 | off = ((unsigned long)start) % (chip->size << chip->addrshift); | ||
824 | base = start - off; | ||
825 | |||
826 | // Perform banked addressing translation. | ||
827 | bank = base & (~(priv->bank_fill[0]-1)); | ||
828 | boffset = base & (priv->bank_fill[0]-1); | ||
829 | bank = (bank/priv->bank_fill[0])*my_bank_size; | ||
830 | base = bank + boffset; | ||
831 | |||
832 | // printk("Flasing %X %X %X\n",base,chip->size,len); | ||
833 | // printk("off is %x, compare with %x\n",off,chip->size << chip->addrshift); | ||
834 | |||
835 | // Loop over this page | ||
836 | for (; off != (chip->size << chip->addrshift) && len != 0; start++, len--, off++,buf++) | ||
837 | { | ||
838 | unsigned char oldbyte = map_read8(map,base+off); | ||
839 | unsigned char Last[4]; | ||
840 | unsigned long Count = 0; | ||
841 | |||
842 | if (oldbyte == *buf) { | ||
843 | // printk("oldbyte and *buf is %x,len is %x\n",oldbyte,len); | ||
844 | continue; | ||
845 | } | ||
846 | if (((~oldbyte) & *buf) != 0) | ||
847 | printk("mtd: warn: Trying to set a 0 to a 1\n"); | ||
848 | |||
849 | // Write | ||
850 | flwrite(0xAA,0x555); | ||
851 | flwrite(0x55,0x2AA); | ||
852 | flwrite(0xA0,0x555); | ||
853 | map_write8(map,*buf,base + off); | ||
854 | Last[0] = map_read8(map,base + off); | ||
855 | Last[1] = map_read8(map,base + off); | ||
856 | Last[2] = map_read8(map,base + off); | ||
857 | |||
858 | /* Wait for the flash to finish the operation. We store the last 4 | ||
859 | status bytes that have been retrieved so we can determine why | ||
860 | it failed. The toggle bits keep toggling when there is a | ||
861 | failure */ | ||
862 | for (Count = 3; Last[(Count - 1) % 4] != Last[(Count - 2) % 4] && | ||
863 | Count < 10000; Count++) | ||
864 | Last[Count % 4] = map_read8(map,base + off); | ||
865 | if (Last[(Count - 1) % 4] != *buf) | ||
866 | { | ||
867 | jedec_flash_failed(Last[(Count - 3) % 4]); | ||
868 | return -EIO; | ||
869 | } | ||
870 | } | ||
871 | } | ||
872 | *retlen = save_len; | ||
873 | return 0; | ||
874 | } | ||
875 | |||
876 | /* This is used to enhance the speed of the erase routine, | ||
877 | when things are being done to multiple chips it is possible to | ||
878 | parallize the operations, particularly full memory erases of multi | ||
879 | chip memories benifit */ | ||
880 | static void jedec_flash_chip_scan(struct jedec_private *priv,unsigned long start, | ||
881 | unsigned long len) | ||
882 | { | ||
883 | unsigned int I; | ||
884 | |||
885 | // Zero the records | ||
886 | for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) | ||
887 | priv->chips[I].start = priv->chips[I].length = 0; | ||
888 | |||
889 | // Intersect the region with each chip | ||
890 | for (I = 0; priv->chips[I].jedec != 0 && I < MAX_JEDEC_CHIPS; I++) | ||
891 | { | ||
892 | struct jedec_flash_chip *chip = priv->chips + I; | ||
893 | unsigned long ByteStart; | ||
894 | unsigned long ChipEndByte = chip->offset + (chip->size << chip->addrshift); | ||
895 | |||
896 | // End is before this chip or the start is after it | ||
897 | if (start+len < chip->offset || | ||
898 | ChipEndByte - (1 << chip->addrshift) < start) | ||
899 | continue; | ||
900 | |||
901 | if (start < chip->offset) | ||
902 | { | ||
903 | ByteStart = chip->offset; | ||
904 | chip->start = 0; | ||
905 | } | ||
906 | else | ||
907 | { | ||
908 | chip->start = (start - chip->offset + (1 << chip->addrshift)-1) >> chip->addrshift; | ||
909 | ByteStart = start; | ||
910 | } | ||
911 | |||
912 | if (start + len >= ChipEndByte) | ||
913 | chip->length = (ChipEndByte - ByteStart) >> chip->addrshift; | ||
914 | else | ||
915 | chip->length = (start + len - ByteStart + (1 << chip->addrshift)-1) >> chip->addrshift; | ||
916 | } | ||
917 | } | ||
918 | |||
919 | int __init jedec_init(void) | ||
920 | { | ||
921 | register_mtd_chip_driver(&jedec_chipdrv); | ||
922 | return 0; | ||
923 | } | ||
924 | |||
925 | static void __exit jedec_exit(void) | ||
926 | { | ||
927 | unregister_mtd_chip_driver(&jedec_chipdrv); | ||
928 | } | ||
929 | |||
930 | module_init(jedec_init); | ||
931 | module_exit(jedec_exit); | ||
932 | |||
933 | MODULE_LICENSE("GPL"); | ||
934 | MODULE_AUTHOR("Jason Gunthorpe <jgg@deltatee.com> et al."); | ||
935 | MODULE_DESCRIPTION("Old MTD chip driver for JEDEC-compliant flash chips"); | ||
diff --git a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c deleted file mode 100644 index c9cd3d21ccfa..000000000000 --- a/drivers/mtd/chips/sharp.c +++ /dev/null | |||
@@ -1,601 +0,0 @@ | |||
1 | /* | ||
2 | * MTD chip driver for pre-CFI Sharp flash chips | ||
3 | * | ||
4 | * Copyright 2000,2001 David A. Schleef <ds@schleef.org> | ||
5 | * 2000,2001 Lineo, Inc. | ||
6 | * | ||
7 | * $Id: sharp.c,v 1.17 2005/11/29 14:28:28 gleixner Exp $ | ||
8 | * | ||
9 | * Devices supported: | ||
10 | * LH28F016SCT Symmetrical block flash memory, 2Mx8 | ||
11 | * LH28F008SCT Symmetrical block flash memory, 1Mx8 | ||
12 | * | ||
13 | * Documentation: | ||
14 | * http://www.sharpmeg.com/datasheets/memic/flashcmp/ | ||
15 | * http://www.sharpmeg.com/datasheets/memic/flashcmp/01symf/16m/016sctl9.pdf | ||
16 | * 016sctl9.pdf | ||
17 | * | ||
18 | * Limitations: | ||
19 | * This driver only supports 4x1 arrangement of chips. | ||
20 | * Not tested on anything but PowerPC. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/types.h> | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/errno.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/mtd/map.h> | ||
30 | #include <linux/mtd/mtd.h> | ||
31 | #include <linux/mtd/cfi.h> | ||
32 | #include <linux/delay.h> | ||
33 | #include <linux/init.h> | ||
34 | #include <linux/slab.h> | ||
35 | |||
36 | #define CMD_RESET 0xffffffff | ||
37 | #define CMD_READ_ID 0x90909090 | ||
38 | #define CMD_READ_STATUS 0x70707070 | ||
39 | #define CMD_CLEAR_STATUS 0x50505050 | ||
40 | #define CMD_BLOCK_ERASE_1 0x20202020 | ||
41 | #define CMD_BLOCK_ERASE_2 0xd0d0d0d0 | ||
42 | #define CMD_BYTE_WRITE 0x40404040 | ||
43 | #define CMD_SUSPEND 0xb0b0b0b0 | ||
44 | #define CMD_RESUME 0xd0d0d0d0 | ||
45 | #define CMD_SET_BLOCK_LOCK_1 0x60606060 | ||
46 | #define CMD_SET_BLOCK_LOCK_2 0x01010101 | ||
47 | #define CMD_SET_MASTER_LOCK_1 0x60606060 | ||
48 | #define CMD_SET_MASTER_LOCK_2 0xf1f1f1f1 | ||
49 | #define CMD_CLEAR_BLOCK_LOCKS_1 0x60606060 | ||
50 | #define CMD_CLEAR_BLOCK_LOCKS_2 0xd0d0d0d0 | ||
51 | |||
52 | #define SR_READY 0x80808080 // 1 = ready | ||
53 | #define SR_ERASE_SUSPEND 0x40404040 // 1 = block erase suspended | ||
54 | #define SR_ERROR_ERASE 0x20202020 // 1 = error in block erase or clear lock bits | ||
55 | #define SR_ERROR_WRITE 0x10101010 // 1 = error in byte write or set lock bit | ||
56 | #define SR_VPP 0x08080808 // 1 = Vpp is low | ||
57 | #define SR_WRITE_SUSPEND 0x04040404 // 1 = byte write suspended | ||
58 | #define SR_PROTECT 0x02020202 // 1 = lock bit set | ||
59 | #define SR_RESERVED 0x01010101 | ||
60 | |||
61 | #define SR_ERRORS (SR_ERROR_ERASE|SR_ERROR_WRITE|SR_VPP|SR_PROTECT) | ||
62 | |||
63 | /* Configuration options */ | ||
64 | |||
65 | #undef AUTOUNLOCK /* automatically unlocks blocks before erasing */ | ||
66 | |||
67 | static struct mtd_info *sharp_probe(struct map_info *); | ||
68 | |||
69 | static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd); | ||
70 | |||
71 | static int sharp_read(struct mtd_info *mtd, loff_t from, size_t len, | ||
72 | size_t *retlen, u_char *buf); | ||
73 | static int sharp_write(struct mtd_info *mtd, loff_t from, size_t len, | ||
74 | size_t *retlen, const u_char *buf); | ||
75 | static int sharp_erase(struct mtd_info *mtd, struct erase_info *instr); | ||
76 | static void sharp_sync(struct mtd_info *mtd); | ||
77 | static int sharp_suspend(struct mtd_info *mtd); | ||
78 | static void sharp_resume(struct mtd_info *mtd); | ||
79 | static void sharp_destroy(struct mtd_info *mtd); | ||
80 | |||
81 | static int sharp_write_oneword(struct map_info *map, struct flchip *chip, | ||
82 | unsigned long adr, __u32 datum); | ||
83 | static int sharp_erase_oneblock(struct map_info *map, struct flchip *chip, | ||
84 | unsigned long adr); | ||
85 | #ifdef AUTOUNLOCK | ||
86 | static void sharp_unlock_oneblock(struct map_info *map, struct flchip *chip, | ||
87 | unsigned long adr); | ||
88 | #endif | ||
89 | |||
90 | |||
91 | struct sharp_info{ | ||
92 | struct flchip *chip; | ||
93 | int bogus; | ||
94 | int chipshift; | ||
95 | int numchips; | ||
96 | struct flchip chips[1]; | ||
97 | }; | ||
98 | |||
99 | static void sharp_destroy(struct mtd_info *mtd); | ||
100 | |||
101 | static struct mtd_chip_driver sharp_chipdrv = { | ||
102 | .probe = sharp_probe, | ||
103 | .destroy = sharp_destroy, | ||
104 | .name = "sharp", | ||
105 | .module = THIS_MODULE | ||
106 | }; | ||
107 | |||
108 | |||
109 | static struct mtd_info *sharp_probe(struct map_info *map) | ||
110 | { | ||
111 | struct mtd_info *mtd = NULL; | ||
112 | struct sharp_info *sharp = NULL; | ||
113 | int width; | ||
114 | |||
115 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); | ||
116 | if(!mtd) | ||
117 | return NULL; | ||
118 | |||
119 | sharp = kzalloc(sizeof(*sharp), GFP_KERNEL); | ||
120 | if(!sharp) { | ||
121 | kfree(mtd); | ||
122 | return NULL; | ||
123 | } | ||
124 | |||
125 | width = sharp_probe_map(map,mtd); | ||
126 | if(!width){ | ||
127 | kfree(mtd); | ||
128 | kfree(sharp); | ||
129 | return NULL; | ||
130 | } | ||
131 | |||
132 | mtd->priv = map; | ||
133 | mtd->type = MTD_NORFLASH; | ||
134 | mtd->erase = sharp_erase; | ||
135 | mtd->read = sharp_read; | ||
136 | mtd->write = sharp_write; | ||
137 | mtd->sync = sharp_sync; | ||
138 | mtd->suspend = sharp_suspend; | ||
139 | mtd->resume = sharp_resume; | ||
140 | mtd->flags = MTD_CAP_NORFLASH; | ||
141 | mtd->writesize = 1; | ||
142 | mtd->name = map->name; | ||
143 | |||
144 | sharp->chipshift = 23; | ||
145 | sharp->numchips = 1; | ||
146 | sharp->chips[0].start = 0; | ||
147 | sharp->chips[0].state = FL_READY; | ||
148 | sharp->chips[0].mutex = &sharp->chips[0]._spinlock; | ||
149 | sharp->chips[0].word_write_time = 0; | ||
150 | init_waitqueue_head(&sharp->chips[0].wq); | ||
151 | spin_lock_init(&sharp->chips[0]._spinlock); | ||
152 | |||
153 | map->fldrv = &sharp_chipdrv; | ||
154 | map->fldrv_priv = sharp; | ||
155 | |||
156 | __module_get(THIS_MODULE); | ||
157 | return mtd; | ||
158 | } | ||
159 | |||
160 | static inline void sharp_send_cmd(struct map_info *map, unsigned long cmd, unsigned long adr) | ||
161 | { | ||
162 | map_word map_cmd; | ||
163 | map_cmd.x[0] = cmd; | ||
164 | map_write(map, map_cmd, adr); | ||
165 | } | ||
166 | |||
167 | static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd) | ||
168 | { | ||
169 | map_word tmp, read0, read4; | ||
170 | unsigned long base = 0; | ||
171 | int width = 4; | ||
172 | |||
173 | tmp = map_read(map, base+0); | ||
174 | |||
175 | sharp_send_cmd(map, CMD_READ_ID, base+0); | ||
176 | |||
177 | read0 = map_read(map, base+0); | ||
178 | read4 = map_read(map, base+4); | ||
179 | if(read0.x[0] == 0x89898989){ | ||
180 | printk("Looks like sharp flash\n"); | ||
181 | switch(read4.x[0]){ | ||
182 | case 0xaaaaaaaa: | ||
183 | case 0xa0a0a0a0: | ||
184 | /* aa - LH28F016SCT-L95 2Mx8, 32 64k blocks*/ | ||
185 | /* a0 - LH28F016SCT-Z4 2Mx8, 32 64k blocks*/ | ||
186 | mtd->erasesize = 0x10000 * width; | ||
187 | mtd->size = 0x200000 * width; | ||
188 | return width; | ||
189 | case 0xa6a6a6a6: | ||
190 | /* a6 - LH28F008SCT-L12 1Mx8, 16 64k blocks*/ | ||
191 | /* a6 - LH28F008SCR-L85 1Mx8, 16 64k blocks*/ | ||
192 | mtd->erasesize = 0x10000 * width; | ||
193 | mtd->size = 0x100000 * width; | ||
194 | return width; | ||
195 | #if 0 | ||
196 | case 0x00000000: /* unknown */ | ||
197 | /* XX - LH28F004SCT 512kx8, 8 64k blocks*/ | ||
198 | mtd->erasesize = 0x10000 * width; | ||
199 | mtd->size = 0x80000 * width; | ||
200 | return width; | ||
201 | #endif | ||
202 | default: | ||
203 | printk("Sort-of looks like sharp flash, 0x%08lx 0x%08lx\n", | ||
204 | read0.x[0], read4.x[0]); | ||
205 | } | ||
206 | }else if((map_read(map, base+0).x[0] == CMD_READ_ID)){ | ||
207 | /* RAM, probably */ | ||
208 | printk("Looks like RAM\n"); | ||
209 | map_write(map, tmp, base+0); | ||
210 | }else{ | ||
211 | printk("Doesn't look like sharp flash, 0x%08lx 0x%08lx\n", | ||
212 | read0.x[0], read4.x[0]); | ||
213 | } | ||
214 | |||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | /* This function returns with the chip->mutex lock held. */ | ||
219 | static int sharp_wait(struct map_info *map, struct flchip *chip) | ||
220 | { | ||
221 | int i; | ||
222 | map_word status; | ||
223 | unsigned long timeo = jiffies + HZ; | ||
224 | DECLARE_WAITQUEUE(wait, current); | ||
225 | int adr = 0; | ||
226 | |||
227 | retry: | ||
228 | spin_lock_bh(chip->mutex); | ||
229 | |||
230 | switch(chip->state){ | ||
231 | case FL_READY: | ||
232 | sharp_send_cmd(map, CMD_READ_STATUS, adr); | ||
233 | chip->state = FL_STATUS; | ||
234 | case FL_STATUS: | ||
235 | for(i=0;i<100;i++){ | ||
236 | status = map_read(map, adr); | ||
237 | if((status.x[0] & SR_READY)==SR_READY) | ||
238 | break; | ||
239 | udelay(1); | ||
240 | } | ||
241 | break; | ||
242 | default: | ||
243 | printk("Waiting for chip\n"); | ||
244 | |||
245 | set_current_state(TASK_INTERRUPTIBLE); | ||
246 | add_wait_queue(&chip->wq, &wait); | ||
247 | |||
248 | spin_unlock_bh(chip->mutex); | ||
249 | |||
250 | schedule(); | ||
251 | remove_wait_queue(&chip->wq, &wait); | ||
252 | |||
253 | if(signal_pending(current)) | ||
254 | return -EINTR; | ||
255 | |||
256 | timeo = jiffies + HZ; | ||
257 | |||
258 | goto retry; | ||
259 | } | ||
260 | |||
261 | sharp_send_cmd(map, CMD_RESET, adr); | ||
262 | |||
263 | chip->state = FL_READY; | ||
264 | |||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static void sharp_release(struct flchip *chip) | ||
269 | { | ||
270 | wake_up(&chip->wq); | ||
271 | spin_unlock_bh(chip->mutex); | ||
272 | } | ||
273 | |||
274 | static int sharp_read(struct mtd_info *mtd, loff_t from, size_t len, | ||
275 | size_t *retlen, u_char *buf) | ||
276 | { | ||
277 | struct map_info *map = mtd->priv; | ||
278 | struct sharp_info *sharp = map->fldrv_priv; | ||
279 | int chipnum; | ||
280 | int ret = 0; | ||
281 | int ofs = 0; | ||
282 | |||
283 | chipnum = (from >> sharp->chipshift); | ||
284 | ofs = from & ((1 << sharp->chipshift)-1); | ||
285 | |||
286 | *retlen = 0; | ||
287 | |||
288 | while(len){ | ||
289 | unsigned long thislen; | ||
290 | |||
291 | if(chipnum>=sharp->numchips) | ||
292 | break; | ||
293 | |||
294 | thislen = len; | ||
295 | if(ofs+thislen >= (1<<sharp->chipshift)) | ||
296 | thislen = (1<<sharp->chipshift) - ofs; | ||
297 | |||
298 | ret = sharp_wait(map,&sharp->chips[chipnum]); | ||
299 | if(ret<0) | ||
300 | break; | ||
301 | |||
302 | map_copy_from(map,buf,ofs,thislen); | ||
303 | |||
304 | sharp_release(&sharp->chips[chipnum]); | ||
305 | |||
306 | *retlen += thislen; | ||
307 | len -= thislen; | ||
308 | buf += thislen; | ||
309 | |||
310 | ofs = 0; | ||
311 | chipnum++; | ||
312 | } | ||
313 | return ret; | ||
314 | } | ||
315 | |||
316 | static int sharp_write(struct mtd_info *mtd, loff_t to, size_t len, | ||
317 | size_t *retlen, const u_char *buf) | ||
318 | { | ||
319 | struct map_info *map = mtd->priv; | ||
320 | struct sharp_info *sharp = map->fldrv_priv; | ||
321 | int ret = 0; | ||
322 | int i,j; | ||
323 | int chipnum; | ||
324 | unsigned long ofs; | ||
325 | union { u32 l; unsigned char uc[4]; } tbuf; | ||
326 | |||
327 | *retlen = 0; | ||
328 | |||
329 | while(len){ | ||
330 | tbuf.l = 0xffffffff; | ||
331 | chipnum = to >> sharp->chipshift; | ||
332 | ofs = to & ((1<<sharp->chipshift)-1); | ||
333 | |||
334 | j=0; | ||
335 | for(i=ofs&3;i<4 && len;i++){ | ||
336 | tbuf.uc[i] = *buf; | ||
337 | buf++; | ||
338 | to++; | ||
339 | len--; | ||
340 | j++; | ||
341 | } | ||
342 | sharp_write_oneword(map, &sharp->chips[chipnum], ofs&~3, tbuf.l); | ||
343 | if(ret<0) | ||
344 | return ret; | ||
345 | (*retlen)+=j; | ||
346 | } | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
351 | static int sharp_write_oneword(struct map_info *map, struct flchip *chip, | ||
352 | unsigned long adr, __u32 datum) | ||
353 | { | ||
354 | int ret; | ||
355 | int timeo; | ||
356 | int try; | ||
357 | int i; | ||
358 | map_word data, status; | ||
359 | |||
360 | status.x[0] = 0; | ||
361 | ret = sharp_wait(map,chip); | ||
362 | |||
363 | for(try=0;try<10;try++){ | ||
364 | sharp_send_cmd(map, CMD_BYTE_WRITE, adr); | ||
365 | /* cpu_to_le32 -> hack to fix the writel be->le conversion */ | ||
366 | data.x[0] = cpu_to_le32(datum); | ||
367 | map_write(map, data, adr); | ||
368 | |||
369 | chip->state = FL_WRITING; | ||
370 | |||
371 | timeo = jiffies + (HZ/2); | ||
372 | |||
373 | sharp_send_cmd(map, CMD_READ_STATUS, adr); | ||
374 | for(i=0;i<100;i++){ | ||
375 | status = map_read(map, adr); | ||
376 | if((status.x[0] & SR_READY) == SR_READY) | ||
377 | break; | ||
378 | } | ||
379 | if(i==100){ | ||
380 | printk("sharp: timed out writing\n"); | ||
381 | } | ||
382 | |||
383 | if(!(status.x[0] & SR_ERRORS)) | ||
384 | break; | ||
385 | |||
386 | printk("sharp: error writing byte at addr=%08lx status=%08lx\n", adr, status.x[0]); | ||
387 | |||
388 | sharp_send_cmd(map, CMD_CLEAR_STATUS, adr); | ||
389 | } | ||
390 | sharp_send_cmd(map, CMD_RESET, adr); | ||
391 | chip->state = FL_READY; | ||
392 | |||
393 | wake_up(&chip->wq); | ||
394 | spin_unlock_bh(chip->mutex); | ||
395 | |||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | static int sharp_erase(struct mtd_info *mtd, struct erase_info *instr) | ||
400 | { | ||
401 | struct map_info *map = mtd->priv; | ||
402 | struct sharp_info *sharp = map->fldrv_priv; | ||
403 | unsigned long adr,len; | ||
404 | int chipnum, ret=0; | ||
405 | |||
406 | //printk("sharp_erase()\n"); | ||
407 | if(instr->addr & (mtd->erasesize - 1)) | ||
408 | return -EINVAL; | ||
409 | if(instr->len & (mtd->erasesize - 1)) | ||
410 | return -EINVAL; | ||
411 | if(instr->len + instr->addr > mtd->size) | ||
412 | return -EINVAL; | ||
413 | |||
414 | chipnum = instr->addr >> sharp->chipshift; | ||
415 | adr = instr->addr & ((1<<sharp->chipshift)-1); | ||
416 | len = instr->len; | ||
417 | |||
418 | while(len){ | ||
419 | ret = sharp_erase_oneblock(map, &sharp->chips[chipnum], adr); | ||
420 | if(ret)return ret; | ||
421 | |||
422 | adr += mtd->erasesize; | ||
423 | len -= mtd->erasesize; | ||
424 | if(adr >> sharp->chipshift){ | ||
425 | adr = 0; | ||
426 | chipnum++; | ||
427 | if(chipnum>=sharp->numchips) | ||
428 | break; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | instr->state = MTD_ERASE_DONE; | ||
433 | mtd_erase_callback(instr); | ||
434 | |||
435 | return 0; | ||
436 | } | ||
437 | |||
438 | static int sharp_do_wait_for_ready(struct map_info *map, struct flchip *chip, | ||
439 | unsigned long adr) | ||
440 | { | ||
441 | int ret; | ||
442 | unsigned long timeo; | ||
443 | map_word status; | ||
444 | DECLARE_WAITQUEUE(wait, current); | ||
445 | |||
446 | sharp_send_cmd(map, CMD_READ_STATUS, adr); | ||
447 | status = map_read(map, adr); | ||
448 | |||
449 | timeo = jiffies + HZ; | ||
450 | |||
451 | while(time_before(jiffies, timeo)){ | ||
452 | sharp_send_cmd(map, CMD_READ_STATUS, adr); | ||
453 | status = map_read(map, adr); | ||
454 | if((status.x[0] & SR_READY)==SR_READY){ | ||
455 | ret = 0; | ||
456 | goto out; | ||
457 | } | ||
458 | set_current_state(TASK_INTERRUPTIBLE); | ||
459 | add_wait_queue(&chip->wq, &wait); | ||
460 | |||
461 | //spin_unlock_bh(chip->mutex); | ||
462 | |||
463 | schedule_timeout(1); | ||
464 | schedule(); | ||
465 | remove_wait_queue(&chip->wq, &wait); | ||
466 | |||
467 | //spin_lock_bh(chip->mutex); | ||
468 | |||
469 | if (signal_pending(current)){ | ||
470 | ret = -EINTR; | ||
471 | goto out; | ||
472 | } | ||
473 | |||
474 | } | ||
475 | ret = -ETIME; | ||
476 | out: | ||
477 | return ret; | ||
478 | } | ||
479 | |||
480 | static int sharp_erase_oneblock(struct map_info *map, struct flchip *chip, | ||
481 | unsigned long adr) | ||
482 | { | ||
483 | int ret; | ||
484 | //int timeo; | ||
485 | map_word status; | ||
486 | //int i; | ||
487 | |||
488 | //printk("sharp_erase_oneblock()\n"); | ||
489 | |||
490 | #ifdef AUTOUNLOCK | ||
491 | /* This seems like a good place to do an unlock */ | ||
492 | sharp_unlock_oneblock(map,chip,adr); | ||
493 | #endif | ||
494 | |||
495 | sharp_send_cmd(map, CMD_BLOCK_ERASE_1, adr); | ||
496 | sharp_send_cmd(map, CMD_BLOCK_ERASE_2, adr); | ||
497 | |||
498 | chip->state = FL_ERASING; | ||
499 | |||
500 | ret = sharp_do_wait_for_ready(map,chip,adr); | ||
501 | if(ret<0)return ret; | ||
502 | |||
503 | sharp_send_cmd(map, CMD_READ_STATUS, adr); | ||
504 | status = map_read(map, adr); | ||
505 | |||
506 | if(!(status.x[0] & SR_ERRORS)){ | ||
507 | sharp_send_cmd(map, CMD_RESET, adr); | ||
508 | chip->state = FL_READY; | ||
509 | //spin_unlock_bh(chip->mutex); | ||
510 | return 0; | ||
511 | } | ||
512 | |||
513 | printk("sharp: error erasing block at addr=%08lx status=%08lx\n", adr, status.x[0]); | ||
514 | sharp_send_cmd(map, CMD_CLEAR_STATUS, adr); | ||
515 | |||
516 | //spin_unlock_bh(chip->mutex); | ||
517 | |||
518 | return -EIO; | ||
519 | } | ||
520 | |||
521 | #ifdef AUTOUNLOCK | ||
522 | static void sharp_unlock_oneblock(struct map_info *map, struct flchip *chip, | ||
523 | unsigned long adr) | ||
524 | { | ||
525 | int i; | ||
526 | map_word status; | ||
527 | |||
528 | sharp_send_cmd(map, CMD_CLEAR_BLOCK_LOCKS_1, adr); | ||
529 | sharp_send_cmd(map, CMD_CLEAR_BLOCK_LOCKS_2, adr); | ||
530 | |||
531 | udelay(100); | ||
532 | |||
533 | status = map_read(map, adr); | ||
534 | printk("status=%08lx\n", status.x[0]); | ||
535 | |||
536 | for(i=0;i<1000;i++){ | ||
537 | //sharp_send_cmd(map, CMD_READ_STATUS, adr); | ||
538 | status = map_read(map, adr); | ||
539 | if((status.x[0] & SR_READY) == SR_READY) | ||
540 | break; | ||
541 | udelay(100); | ||
542 | } | ||
543 | if(i==1000){ | ||
544 | printk("sharp: timed out unlocking block\n"); | ||
545 | } | ||
546 | |||
547 | if(!(status.x[0] & SR_ERRORS)){ | ||
548 | sharp_send_cmd(map, CMD_RESET, adr); | ||
549 | chip->state = FL_READY; | ||
550 | return; | ||
551 | } | ||
552 | |||
553 | printk("sharp: error unlocking block at addr=%08lx status=%08lx\n", adr, status.x[0]); | ||
554 | sharp_send_cmd(map, CMD_CLEAR_STATUS, adr); | ||
555 | } | ||
556 | #endif | ||
557 | |||
558 | static void sharp_sync(struct mtd_info *mtd) | ||
559 | { | ||
560 | //printk("sharp_sync()\n"); | ||
561 | } | ||
562 | |||
563 | static int sharp_suspend(struct mtd_info *mtd) | ||
564 | { | ||
565 | printk("sharp_suspend()\n"); | ||
566 | return -EINVAL; | ||
567 | } | ||
568 | |||
569 | static void sharp_resume(struct mtd_info *mtd) | ||
570 | { | ||
571 | printk("sharp_resume()\n"); | ||
572 | |||
573 | } | ||
574 | |||
575 | static void sharp_destroy(struct mtd_info *mtd) | ||
576 | { | ||
577 | printk("sharp_destroy()\n"); | ||
578 | |||
579 | } | ||
580 | |||
581 | static int __init sharp_probe_init(void) | ||
582 | { | ||
583 | printk("MTD Sharp chip driver <ds@lineo.com>\n"); | ||
584 | |||
585 | register_mtd_chip_driver(&sharp_chipdrv); | ||
586 | |||
587 | return 0; | ||
588 | } | ||
589 | |||
590 | static void __exit sharp_probe_exit(void) | ||
591 | { | ||
592 | unregister_mtd_chip_driver(&sharp_chipdrv); | ||
593 | } | ||
594 | |||
595 | module_init(sharp_probe_init); | ||
596 | module_exit(sharp_probe_exit); | ||
597 | |||
598 | |||
599 | MODULE_LICENSE("GPL"); | ||
600 | MODULE_AUTHOR("David Schleef <ds@schleef.org>"); | ||
601 | MODULE_DESCRIPTION("Old MTD chip driver for pre-CFI Sharp flash chips"); | ||
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index fc4cc8ba9e29..be4b9948c762 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -373,7 +373,7 @@ static inline void kill_final_newline(char *str) | |||
373 | 373 | ||
374 | #ifndef MODULE | 374 | #ifndef MODULE |
375 | static int block2mtd_init_called = 0; | 375 | static int block2mtd_init_called = 0; |
376 | static __initdata char block2mtd_paramline[80 + 12]; /* 80 for device, 12 for erase size */ | 376 | static char block2mtd_paramline[80 + 12]; /* 80 for device, 12 for erase size */ |
377 | #endif | 377 | #endif |
378 | 378 | ||
379 | 379 | ||
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index d990d8141ef5..b665e4ac2208 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig | |||
@@ -60,7 +60,7 @@ config MTD_PHYSMAP_BANKWIDTH | |||
60 | (i.e., run-time calling physmap_configure()). | 60 | (i.e., run-time calling physmap_configure()). |
61 | 61 | ||
62 | config MTD_PHYSMAP_OF | 62 | config MTD_PHYSMAP_OF |
63 | tristate "Flash device in physical memory map based on OF descirption" | 63 | tristate "Flash device in physical memory map based on OF description" |
64 | depends on PPC_OF && (MTD_CFI || MTD_JEDECPROBE || MTD_ROM) | 64 | depends on PPC_OF && (MTD_CFI || MTD_JEDECPROBE || MTD_ROM) |
65 | help | 65 | help |
66 | This provides a 'mapping' driver which allows the NOR Flash and | 66 | This provides a 'mapping' driver which allows the NOR Flash and |
@@ -358,22 +358,6 @@ config MTD_CFI_FLAGADM | |||
358 | Mapping for the Flaga digital module. If you don't have one, ignore | 358 | Mapping for the Flaga digital module. If you don't have one, ignore |
359 | this setting. | 359 | this setting. |
360 | 360 | ||
361 | config MTD_BEECH | ||
362 | tristate "CFI Flash device mapped on IBM 405LP Beech" | ||
363 | depends on MTD_CFI && BEECH | ||
364 | help | ||
365 | This enables access routines for the flash chips on the IBM | ||
366 | 405LP Beech board. If you have one of these boards and would like | ||
367 | to use the flash chips on it, say 'Y'. | ||
368 | |||
369 | config MTD_ARCTIC | ||
370 | tristate "CFI Flash device mapped on IBM 405LP Arctic" | ||
371 | depends on MTD_CFI && ARCTIC2 | ||
372 | help | ||
373 | This enables access routines for the flash chips on the IBM 405LP | ||
374 | Arctic board. If you have one of these boards and would like to | ||
375 | use the flash chips on it, say 'Y'. | ||
376 | |||
377 | config MTD_WALNUT | 361 | config MTD_WALNUT |
378 | tristate "Flash device mapped on IBM 405GP Walnut" | 362 | tristate "Flash device mapped on IBM 405GP Walnut" |
379 | depends on MTD_JEDECPROBE && WALNUT | 363 | depends on MTD_JEDECPROBE && WALNUT |
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile index de036c5e6139..3acbb5d01ca4 100644 --- a/drivers/mtd/maps/Makefile +++ b/drivers/mtd/maps/Makefile | |||
@@ -58,8 +58,6 @@ obj-$(CONFIG_MTD_NETtel) += nettel.o | |||
58 | obj-$(CONFIG_MTD_SCB2_FLASH) += scb2_flash.o | 58 | obj-$(CONFIG_MTD_SCB2_FLASH) += scb2_flash.o |
59 | obj-$(CONFIG_MTD_EBONY) += ebony.o | 59 | obj-$(CONFIG_MTD_EBONY) += ebony.o |
60 | obj-$(CONFIG_MTD_OCOTEA) += ocotea.o | 60 | obj-$(CONFIG_MTD_OCOTEA) += ocotea.o |
61 | obj-$(CONFIG_MTD_BEECH) += beech-mtd.o | ||
62 | obj-$(CONFIG_MTD_ARCTIC) += arctic-mtd.o | ||
63 | obj-$(CONFIG_MTD_WALNUT) += walnut.o | 61 | obj-$(CONFIG_MTD_WALNUT) += walnut.o |
64 | obj-$(CONFIG_MTD_H720X) += h720x-flash.o | 62 | obj-$(CONFIG_MTD_H720X) += h720x-flash.o |
65 | obj-$(CONFIG_MTD_SBC8240) += sbc8240.o | 63 | obj-$(CONFIG_MTD_SBC8240) += sbc8240.o |
diff --git a/drivers/mtd/maps/arctic-mtd.c b/drivers/mtd/maps/arctic-mtd.c deleted file mode 100644 index 2cc902436275..000000000000 --- a/drivers/mtd/maps/arctic-mtd.c +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
1 | /* | ||
2 | * $Id: arctic-mtd.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $ | ||
3 | * | ||
4 | * drivers/mtd/maps/arctic-mtd.c MTD mappings and partition tables for | ||
5 | * IBM 405LP Arctic boards. | ||
6 | * | ||
7 | * 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 | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | * Copyright (C) 2002, International Business Machines Corporation | ||
22 | * All Rights Reserved. | ||
23 | * | ||
24 | * Bishop Brock | ||
25 | * IBM Research, Austin Center for Low-Power Computing | ||
26 | * bcbrock@us.ibm.com | ||
27 | * March 2002 | ||
28 | * | ||
29 | * modified for Arctic by, | ||
30 | * David Gibson | ||
31 | * IBM OzLabs, Canberra, Australia | ||
32 | * <arctic@gibson.dropbear.id.au> | ||
33 | */ | ||
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/module.h> | ||
37 | #include <linux/types.h> | ||
38 | #include <linux/init.h> | ||
39 | |||
40 | #include <linux/mtd/mtd.h> | ||
41 | #include <linux/mtd/map.h> | ||
42 | #include <linux/mtd/partitions.h> | ||
43 | |||
44 | #include <asm/io.h> | ||
45 | #include <asm/ibm4xx.h> | ||
46 | |||
47 | /* | ||
48 | * 0 : 0xFE00 0000 - 0xFEFF FFFF : Filesystem 1 (16MiB) | ||
49 | * 1 : 0xFF00 0000 - 0xFF4F FFFF : kernel (5.12MiB) | ||
50 | * 2 : 0xFF50 0000 - 0xFFF5 FFFF : Filesystem 2 (10.624MiB) (if non-XIP) | ||
51 | * 3 : 0xFFF6 0000 - 0xFFFF FFFF : PIBS Firmware (640KiB) | ||
52 | */ | ||
53 | |||
54 | #define FFS1_SIZE 0x01000000 /* 16MiB */ | ||
55 | #define KERNEL_SIZE 0x00500000 /* 5.12MiB */ | ||
56 | #define FFS2_SIZE 0x00a60000 /* 10.624MiB */ | ||
57 | #define FIRMWARE_SIZE 0x000a0000 /* 640KiB */ | ||
58 | |||
59 | |||
60 | #define NAME "Arctic Linux Flash" | ||
61 | #define PADDR SUBZERO_BOOTFLASH_PADDR | ||
62 | #define BUSWIDTH 2 | ||
63 | #define SIZE SUBZERO_BOOTFLASH_SIZE | ||
64 | #define PARTITIONS 4 | ||
65 | |||
66 | /* Flash memories on these boards are memory resources, accessed big-endian. */ | ||
67 | |||
68 | { | ||
69 | /* do nothing for now */ | ||
70 | } | ||
71 | |||
72 | static struct map_info arctic_mtd_map = { | ||
73 | .name = NAME, | ||
74 | .size = SIZE, | ||
75 | .bankwidth = BUSWIDTH, | ||
76 | .phys = PADDR, | ||
77 | }; | ||
78 | |||
79 | static struct mtd_info *arctic_mtd; | ||
80 | |||
81 | static struct mtd_partition arctic_partitions[PARTITIONS] = { | ||
82 | { .name = "Filesystem", | ||
83 | .size = FFS1_SIZE, | ||
84 | .offset = 0,}, | ||
85 | { .name = "Kernel", | ||
86 | .size = KERNEL_SIZE, | ||
87 | .offset = FFS1_SIZE,}, | ||
88 | { .name = "Filesystem", | ||
89 | .size = FFS2_SIZE, | ||
90 | .offset = FFS1_SIZE + KERNEL_SIZE,}, | ||
91 | { .name = "Firmware", | ||
92 | .size = FIRMWARE_SIZE, | ||
93 | .offset = SUBZERO_BOOTFLASH_SIZE - FIRMWARE_SIZE,}, | ||
94 | }; | ||
95 | |||
96 | static int __init | ||
97 | init_arctic_mtd(void) | ||
98 | { | ||
99 | int err; | ||
100 | |||
101 | printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); | ||
102 | |||
103 | arctic_mtd_map.virt = ioremap(PADDR, SIZE); | ||
104 | |||
105 | if (!arctic_mtd_map.virt) { | ||
106 | printk("%s: failed to ioremap 0x%x\n", NAME, PADDR); | ||
107 | return -EIO; | ||
108 | } | ||
109 | simple_map_init(&arctic_mtd_map); | ||
110 | |||
111 | printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); | ||
112 | arctic_mtd = do_map_probe("cfi_probe", &arctic_mtd_map); | ||
113 | |||
114 | if (!arctic_mtd) { | ||
115 | iounmap(arctic_mtd_map.virt); | ||
116 | return -ENXIO; | ||
117 | } | ||
118 | |||
119 | arctic_mtd->owner = THIS_MODULE; | ||
120 | |||
121 | err = add_mtd_partitions(arctic_mtd, arctic_partitions, PARTITIONS); | ||
122 | if (err) { | ||
123 | printk("%s: add_mtd_partitions failed\n", NAME); | ||
124 | iounmap(arctic_mtd_map.virt); | ||
125 | } | ||
126 | |||
127 | return err; | ||
128 | } | ||
129 | |||
130 | static void __exit | ||
131 | cleanup_arctic_mtd(void) | ||
132 | { | ||
133 | if (arctic_mtd) { | ||
134 | del_mtd_partitions(arctic_mtd); | ||
135 | map_destroy(arctic_mtd); | ||
136 | iounmap((void *) arctic_mtd_map.virt); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | module_init(init_arctic_mtd); | ||
141 | module_exit(cleanup_arctic_mtd); | ||
142 | |||
143 | MODULE_LICENSE("GPL"); | ||
144 | MODULE_AUTHOR("David Gibson <arctic@gibson.dropbear.id.au>"); | ||
145 | MODULE_DESCRIPTION("MTD map and partitions for IBM 405LP Arctic boards"); | ||
diff --git a/drivers/mtd/maps/beech-mtd.c b/drivers/mtd/maps/beech-mtd.c deleted file mode 100644 index d76d5981b863..000000000000 --- a/drivers/mtd/maps/beech-mtd.c +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | /* | ||
2 | * $Id: beech-mtd.c,v 1.11 2005/11/07 11:14:26 gleixner Exp $ | ||
3 | * | ||
4 | * drivers/mtd/maps/beech-mtd.c MTD mappings and partition tables for | ||
5 | * IBM 405LP Beech boards. | ||
6 | * | ||
7 | * 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 | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | * Copyright (C) 2002, International Business Machines Corporation | ||
22 | * All Rights Reserved. | ||
23 | * | ||
24 | * Bishop Brock | ||
25 | * IBM Research, Austin Center for Low-Power Computing | ||
26 | * bcbrock@us.ibm.com | ||
27 | * March 2002 | ||
28 | * | ||
29 | */ | ||
30 | |||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <linux/types.h> | ||
34 | #include <linux/init.h> | ||
35 | |||
36 | #include <linux/mtd/mtd.h> | ||
37 | #include <linux/mtd/map.h> | ||
38 | #include <linux/mtd/partitions.h> | ||
39 | |||
40 | #include <asm/io.h> | ||
41 | #include <asm/ibm4xx.h> | ||
42 | |||
43 | #define NAME "Beech Linux Flash" | ||
44 | #define PADDR BEECH_BIGFLASH_PADDR | ||
45 | #define SIZE BEECH_BIGFLASH_SIZE | ||
46 | #define BUSWIDTH 1 | ||
47 | |||
48 | /* Flash memories on these boards are memory resources, accessed big-endian. */ | ||
49 | |||
50 | |||
51 | static struct map_info beech_mtd_map = { | ||
52 | .name = NAME, | ||
53 | .size = SIZE, | ||
54 | .bankwidth = BUSWIDTH, | ||
55 | .phys = PADDR | ||
56 | }; | ||
57 | |||
58 | static struct mtd_info *beech_mtd; | ||
59 | |||
60 | static struct mtd_partition beech_partitions[2] = { | ||
61 | { | ||
62 | .name = "Linux Kernel", | ||
63 | .size = BEECH_KERNEL_SIZE, | ||
64 | .offset = BEECH_KERNEL_OFFSET | ||
65 | }, { | ||
66 | .name = "Free Area", | ||
67 | .size = BEECH_FREE_AREA_SIZE, | ||
68 | .offset = BEECH_FREE_AREA_OFFSET | ||
69 | } | ||
70 | }; | ||
71 | |||
72 | static int __init | ||
73 | init_beech_mtd(void) | ||
74 | { | ||
75 | int err; | ||
76 | |||
77 | printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); | ||
78 | |||
79 | beech_mtd_map.virt = ioremap(PADDR, SIZE); | ||
80 | |||
81 | if (!beech_mtd_map.virt) { | ||
82 | printk("%s: failed to ioremap 0x%x\n", NAME, PADDR); | ||
83 | return -EIO; | ||
84 | } | ||
85 | |||
86 | simple_map_init(&beech_mtd_map); | ||
87 | |||
88 | printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); | ||
89 | beech_mtd = do_map_probe("cfi_probe", &beech_mtd_map); | ||
90 | |||
91 | if (!beech_mtd) { | ||
92 | iounmap(beech_mtd_map.virt); | ||
93 | return -ENXIO; | ||
94 | } | ||
95 | |||
96 | beech_mtd->owner = THIS_MODULE; | ||
97 | |||
98 | err = add_mtd_partitions(beech_mtd, beech_partitions, 2); | ||
99 | if (err) { | ||
100 | printk("%s: add_mtd_partitions failed\n", NAME); | ||
101 | iounmap(beech_mtd_map.virt); | ||
102 | } | ||
103 | |||
104 | return err; | ||
105 | } | ||
106 | |||
107 | static void __exit | ||
108 | cleanup_beech_mtd(void) | ||
109 | { | ||
110 | if (beech_mtd) { | ||
111 | del_mtd_partitions(beech_mtd); | ||
112 | map_destroy(beech_mtd); | ||
113 | iounmap((void *) beech_mtd_map.virt); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | module_init(init_beech_mtd); | ||
118 | module_exit(cleanup_beech_mtd); | ||
119 | |||
120 | MODULE_LICENSE("GPL"); | ||
121 | MODULE_AUTHOR("Bishop Brock <bcbrock@us.ibm.com>"); | ||
122 | MODULE_DESCRIPTION("MTD map and partitions for IBM 405LP Beech boards"); | ||
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c index 9f53c655af3a..7b96cd02f82b 100644 --- a/drivers/mtd/maps/nettel.c +++ b/drivers/mtd/maps/nettel.c | |||
@@ -358,7 +358,7 @@ int __init nettel_init(void) | |||
358 | /* Turn other PAR off so the first probe doesn't find it */ | 358 | /* Turn other PAR off so the first probe doesn't find it */ |
359 | *intel1par = 0; | 359 | *intel1par = 0; |
360 | 360 | ||
361 | /* Probe for the the size of the first Intel flash */ | 361 | /* Probe for the size of the first Intel flash */ |
362 | nettel_intel_map.size = maxsize; | 362 | nettel_intel_map.size = maxsize; |
363 | nettel_intel_map.phys = intel0addr; | 363 | nettel_intel_map.phys = intel0addr; |
364 | nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize); | 364 | nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize); |
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index 72107dc06d67..bbb42c35b69b 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c | |||
@@ -186,7 +186,7 @@ static int __devinit of_physmap_probe(struct of_device *dev, const struct of_dev | |||
186 | else { | 186 | else { |
187 | if (strcmp(of_probe, "ROM")) | 187 | if (strcmp(of_probe, "ROM")) |
188 | dev_dbg(&dev->dev, "map_probe: don't know probe type " | 188 | dev_dbg(&dev->dev, "map_probe: don't know probe type " |
189 | "'%s', mapping as rom\n"); | 189 | "'%s', mapping as rom\n", of_probe); |
190 | info->mtd = do_map_probe("mtd_rom", &info->map); | 190 | info->mtd = do_map_probe("mtd_rom", &info->map); |
191 | } | 191 | } |
192 | if (info->mtd == NULL) { | 192 | if (info->mtd == NULL) { |
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 1af989023c66..9c6236852942 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -347,7 +347,6 @@ int add_mtd_partitions(struct mtd_info *master, | |||
347 | slave->mtd.subpage_sft = master->subpage_sft; | 347 | slave->mtd.subpage_sft = master->subpage_sft; |
348 | 348 | ||
349 | slave->mtd.name = parts[i].name; | 349 | slave->mtd.name = parts[i].name; |
350 | slave->mtd.bank_size = master->bank_size; | ||
351 | slave->mtd.owner = master->owner; | 350 | slave->mtd.owner = master->owner; |
352 | 351 | ||
353 | slave->mtd.read = part_read; | 352 | slave->mtd.read = part_read; |
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index d05873b8c155..f1d60b6f048e 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
@@ -232,11 +232,13 @@ config MTD_NAND_BASLER_EXCITE | |||
232 | will be named "excite_nandflash.ko". | 232 | will be named "excite_nandflash.ko". |
233 | 233 | ||
234 | config MTD_NAND_CAFE | 234 | config MTD_NAND_CAFE |
235 | tristate "NAND support for OLPC CAFÉ chip" | 235 | tristate "NAND support for OLPC CAFÉ chip" |
236 | depends on PCI | 236 | depends on PCI |
237 | help | 237 | select REED_SOLOMON |
238 | Use NAND flash attached to the CAFÉ chip designed for the $100 | 238 | select REED_SOLOMON_DEC16 |
239 | laptop. | 239 | help |
240 | Use NAND flash attached to the CAFÉ chip designed for the $100 | ||
241 | laptop. | ||
240 | 242 | ||
241 | config MTD_NAND_CS553X | 243 | config MTD_NAND_CS553X |
242 | tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)" | 244 | tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)" |
@@ -270,4 +272,13 @@ config MTD_NAND_NANDSIM | |||
270 | The simulator may simulate various NAND flash chips for the | 272 | The simulator may simulate various NAND flash chips for the |
271 | MTD nand layer. | 273 | MTD nand layer. |
272 | 274 | ||
275 | config MTD_NAND_PLATFORM | ||
276 | tristate "Support for generic platform NAND driver" | ||
277 | depends on MTD_NAND | ||
278 | help | ||
279 | This implements a generic NAND driver for on-SOC platform | ||
280 | devices. You will need to provide platform-specific functions | ||
281 | via platform_data. | ||
282 | |||
283 | |||
273 | endif # MTD_NAND | 284 | endif # MTD_NAND |
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 6872031a3fb2..edba1db14bfa 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile | |||
@@ -26,6 +26,6 @@ obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o | |||
26 | obj-$(CONFIG_MTD_NAND_AT91) += at91_nand.o | 26 | obj-$(CONFIG_MTD_NAND_AT91) += at91_nand.o |
27 | obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o | 27 | obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o |
28 | obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o | 28 | obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o |
29 | obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o | ||
29 | 30 | ||
30 | nand-objs := nand_base.o nand_bbt.o | 31 | nand-objs := nand_base.o nand_bbt.o |
31 | cafe_nand-objs := cafe.o cafe_ecc.o | ||
diff --git a/drivers/mtd/nand/at91_nand.c b/drivers/mtd/nand/at91_nand.c index 14b80cc90a7b..512e999177f7 100644 --- a/drivers/mtd/nand/at91_nand.c +++ b/drivers/mtd/nand/at91_nand.c | |||
@@ -82,6 +82,10 @@ static void at91_nand_disable(struct at91_nand_host *host) | |||
82 | at91_set_gpio_value(host->board->enable_pin, 1); | 82 | at91_set_gpio_value(host->board->enable_pin, 1); |
83 | } | 83 | } |
84 | 84 | ||
85 | #ifdef CONFIG_MTD_PARTITIONS | ||
86 | const char *part_probes[] = { "cmdlinepart", NULL }; | ||
87 | #endif | ||
88 | |||
85 | /* | 89 | /* |
86 | * Probe for the NAND device. | 90 | * Probe for the NAND device. |
87 | */ | 91 | */ |
@@ -151,6 +155,12 @@ static int __init at91_nand_probe(struct platform_device *pdev) | |||
151 | #ifdef CONFIG_MTD_PARTITIONS | 155 | #ifdef CONFIG_MTD_PARTITIONS |
152 | if (host->board->partition_info) | 156 | if (host->board->partition_info) |
153 | partitions = host->board->partition_info(mtd->size, &num_partitions); | 157 | partitions = host->board->partition_info(mtd->size, &num_partitions); |
158 | #ifdef CONFIG_MTD_CMDLINE_PARTS | ||
159 | else { | ||
160 | mtd->name = "at91_nand"; | ||
161 | num_partitions = parse_mtd_partitions(mtd, part_probes, &partitions, 0); | ||
162 | } | ||
163 | #endif | ||
154 | 164 | ||
155 | if ((!partitions) || (num_partitions == 0)) { | 165 | if ((!partitions) || (num_partitions == 0)) { |
156 | printk(KERN_ERR "at91_nand: No parititions defined, or unsupported device.\n"); | 166 | printk(KERN_ERR "at91_nand: No parititions defined, or unsupported device.\n"); |
diff --git a/drivers/mtd/nand/cafe_ecc.c b/drivers/mtd/nand/cafe_ecc.c deleted file mode 100644 index ea5c8491d2c5..000000000000 --- a/drivers/mtd/nand/cafe_ecc.c +++ /dev/null | |||
@@ -1,1381 +0,0 @@ | |||
1 | /* Error correction for CAFÉ NAND controller | ||
2 | * | ||
3 | * © 2006 Marvell, Inc. | ||
4 | * Author: Tom Chiou | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation; either version 2 of the License, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along with | ||
17 | * this program; if not, write to the Free Software Foundation, Inc., 59 | ||
18 | * Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/errno.h> | ||
24 | |||
25 | static unsigned short gf4096_mul(unsigned short, unsigned short); | ||
26 | static unsigned short gf64_mul(unsigned short, unsigned short); | ||
27 | static unsigned short gf4096_inv(unsigned short); | ||
28 | static unsigned short err_pos(unsigned short); | ||
29 | static void find_4bit_err_coefs(unsigned short, unsigned short, unsigned short, | ||
30 | unsigned short, unsigned short, unsigned short, | ||
31 | unsigned short, unsigned short, unsigned short *); | ||
32 | static void zero_4x5_col3(unsigned short[4][5]); | ||
33 | static void zero_4x5_col2(unsigned short[4][5]); | ||
34 | static void zero_4x5_col1(unsigned short[4][5]); | ||
35 | static void swap_4x5_rows(unsigned short[4][5], int, int, int); | ||
36 | static void swap_2x3_rows(unsigned short m[2][3]); | ||
37 | static void solve_4x5(unsigned short m[4][5], unsigned short *, int *); | ||
38 | static void sort_coefs(int *, unsigned short *, int); | ||
39 | static void find_4bit_err_pats(unsigned short, unsigned short, unsigned short, | ||
40 | unsigned short, unsigned short, unsigned short, | ||
41 | unsigned short, unsigned short, unsigned short *); | ||
42 | static void find_3bit_err_coefs(unsigned short, unsigned short, unsigned short, | ||
43 | unsigned short, unsigned short, unsigned short, | ||
44 | unsigned short *); | ||
45 | static void zero_3x4_col2(unsigned short[3][4]); | ||
46 | static void zero_3x4_col1(unsigned short[3][4]); | ||
47 | static void swap_3x4_rows(unsigned short[3][4], int, int, int); | ||
48 | static void solve_3x4(unsigned short[3][4], unsigned short *, int *); | ||
49 | static void find_3bit_err_pats(unsigned short, unsigned short, unsigned short, | ||
50 | unsigned short, unsigned short, unsigned short, | ||
51 | unsigned short *); | ||
52 | |||
53 | static void find_2bit_err_pats(unsigned short, unsigned short, unsigned short, | ||
54 | unsigned short, unsigned short *); | ||
55 | static void find_2x2_soln(unsigned short, unsigned short, unsigned short, | ||
56 | unsigned short, unsigned short, unsigned short, | ||
57 | unsigned short *); | ||
58 | static void solve_2x3(unsigned short[2][3], unsigned short *); | ||
59 | static int chk_no_err_only(unsigned short *, unsigned short *); | ||
60 | static int chk_1_err_only(unsigned short *, unsigned short *); | ||
61 | static int chk_2_err_only(unsigned short *, unsigned short *); | ||
62 | static int chk_3_err_only(unsigned short *, unsigned short *); | ||
63 | static int chk_4_err_only(unsigned short *, unsigned short *); | ||
64 | |||
65 | static unsigned short gf64_mul(unsigned short a, unsigned short b) | ||
66 | { | ||
67 | unsigned short tmp1, tmp2, tmp3, tmp4, tmp5; | ||
68 | unsigned short c_bit0, c_bit1, c_bit2, c_bit3, c_bit4, c_bit5, c; | ||
69 | |||
70 | tmp1 = ((a) ^ (a >> 5)); | ||
71 | tmp2 = ((a >> 4) ^ (a >> 5)); | ||
72 | tmp3 = ((a >> 3) ^ (a >> 4)); | ||
73 | tmp4 = ((a >> 2) ^ (a >> 3)); | ||
74 | tmp5 = ((a >> 1) ^ (a >> 2)); | ||
75 | |||
76 | c_bit0 = ((a & b) ^ ((a >> 5) & (b >> 1)) ^ ((a >> 4) & (b >> 2)) ^ | ||
77 | ((a >> 3) & (b >> 3)) ^ ((a >> 2) & (b >> 4)) ^ ((a >> 1) & (b >> 5))) & 0x1; | ||
78 | |||
79 | c_bit1 = (((a >> 1) & b) ^ (tmp1 & (b >> 1)) ^ (tmp2 & (b >> 2)) ^ | ||
80 | (tmp3 & (b >> 3)) ^ (tmp4 & (b >> 4)) ^ (tmp5 & (b >> 5))) & 0x1; | ||
81 | |||
82 | c_bit2 = (((a >> 2) & b) ^ ((a >> 1) & (b >> 1)) ^ (tmp1 & (b >> 2)) ^ | ||
83 | (tmp2 & (b >> 3)) ^ (tmp3 & (b >> 4)) ^ (tmp4 & (b >> 5))) & 0x1; | ||
84 | |||
85 | c_bit3 = (((a >> 3) & b) ^ ((a >> 2) & (b >> 1)) ^ ((a >> 1) & (b >> 2)) ^ | ||
86 | (tmp1 & (b >> 3)) ^ (tmp2 & (b >> 4)) ^ (tmp3 & (b >> 5))) & 0x1; | ||
87 | |||
88 | c_bit4 = (((a >> 4) & b) ^ ((a >> 3) & (b >> 1)) ^ ((a >> 2) & (b >> 2)) ^ | ||
89 | ((a >> 1) & (b >> 3)) ^ (tmp1 & (b >> 4)) ^ (tmp2 & (b >> 5))) & 0x1; | ||
90 | |||
91 | c_bit5 = (((a >> 5) & b) ^ ((a >> 4) & (b >> 1)) ^ ((a >> 3) & (b >> 2)) ^ | ||
92 | ((a >> 2) & (b >> 3)) ^ ((a >> 1) & (b >> 4)) ^ (tmp1 & (b >> 5))) & 0x1; | ||
93 | |||
94 | c = c_bit0 | (c_bit1 << 1) | (c_bit2 << 2) | (c_bit3 << 3) | (c_bit4 << 4) | (c_bit5 << 5); | ||
95 | |||
96 | return c; | ||
97 | } | ||
98 | |||
99 | static unsigned short gf4096_mul(unsigned short a, unsigned short b) | ||
100 | { | ||
101 | unsigned short ah, al, bh, bl, alxah, blxbh, ablh, albl, ahbh, ahbhB, c; | ||
102 | |||
103 | ah = (a >> 6) & 0x3f; | ||
104 | al = a & 0x3f; | ||
105 | bh = (b >> 6) & 0x3f; | ||
106 | bl = b & 0x3f; | ||
107 | alxah = al ^ ah; | ||
108 | blxbh = bl ^ bh; | ||
109 | |||
110 | ablh = gf64_mul(alxah, blxbh); | ||
111 | albl = gf64_mul(al, bl); | ||
112 | ahbh = gf64_mul(ah, bh); | ||
113 | |||
114 | ahbhB = ((ahbh & 0x1) << 5) | | ||
115 | ((ahbh & 0x20) >> 1) | | ||
116 | ((ahbh & 0x10) >> 1) | ((ahbh & 0x8) >> 1) | ((ahbh & 0x4) >> 1) | (((ahbh >> 1) ^ ahbh) & 0x1); | ||
117 | |||
118 | c = ((ablh ^ albl) << 6) | (ahbhB ^ albl); | ||
119 | return c; | ||
120 | } | ||
121 | |||
122 | static void find_2bit_err_pats(unsigned short s0, unsigned short s1, unsigned short r0, unsigned short r1, unsigned short *pats) | ||
123 | { | ||
124 | find_2x2_soln(0x1, 0x1, r0, r1, s0, s1, pats); | ||
125 | } | ||
126 | |||
127 | static void find_3bit_err_coefs(unsigned short s0, unsigned short s1, | ||
128 | unsigned short s2, unsigned short s3, unsigned short s4, unsigned short s5, unsigned short *coefs) | ||
129 | { | ||
130 | unsigned short m[3][4]; | ||
131 | int row_order[3]; | ||
132 | |||
133 | row_order[0] = 0; | ||
134 | row_order[1] = 1; | ||
135 | row_order[2] = 2; | ||
136 | m[0][0] = s2; | ||
137 | m[0][1] = s1; | ||
138 | m[0][2] = s0; | ||
139 | m[0][3] = s3; | ||
140 | m[1][0] = s3; | ||
141 | m[1][1] = s2; | ||
142 | m[1][2] = s1; | ||
143 | m[1][3] = s4; | ||
144 | m[2][0] = s4; | ||
145 | m[2][1] = s3; | ||
146 | m[2][2] = s2; | ||
147 | m[2][3] = s5; | ||
148 | |||
149 | if (m[0][2] != 0x0) { | ||
150 | zero_3x4_col2(m); | ||
151 | } else if (m[1][2] != 0x0) { | ||
152 | swap_3x4_rows(m, 0, 1, 4); | ||
153 | zero_3x4_col2(m); | ||
154 | } else if (m[2][2] != 0x0) { | ||
155 | swap_3x4_rows(m, 0, 2, 4); | ||
156 | zero_3x4_col2(m); | ||
157 | } else { | ||
158 | printk(KERN_ERR "Error: find_3bit_err_coefs, s0,s1,s2 all zeros!\n"); | ||
159 | } | ||
160 | |||
161 | if (m[1][1] != 0x0) { | ||
162 | zero_3x4_col1(m); | ||
163 | } else if (m[2][1] != 0x0) { | ||
164 | swap_3x4_rows(m, 1, 2, 4); | ||
165 | zero_3x4_col1(m); | ||
166 | } else { | ||
167 | printk(KERN_ERR "Error: find_3bit_err_coefs, cannot resolve col 1!\n"); | ||
168 | } | ||
169 | |||
170 | /* solve coefs */ | ||
171 | solve_3x4(m, coefs, row_order); | ||
172 | } | ||
173 | |||
174 | static void zero_3x4_col2(unsigned short m[3][4]) | ||
175 | { | ||
176 | unsigned short minv1, minv2; | ||
177 | |||
178 | minv1 = gf4096_mul(m[1][2], gf4096_inv(m[0][2])); | ||
179 | minv2 = gf4096_mul(m[2][2], gf4096_inv(m[0][2])); | ||
180 | m[1][0] = m[1][0] ^ gf4096_mul(m[0][0], minv1); | ||
181 | m[1][1] = m[1][1] ^ gf4096_mul(m[0][1], minv1); | ||
182 | m[1][3] = m[1][3] ^ gf4096_mul(m[0][3], minv1); | ||
183 | m[2][0] = m[2][0] ^ gf4096_mul(m[0][0], minv2); | ||
184 | m[2][1] = m[2][1] ^ gf4096_mul(m[0][1], minv2); | ||
185 | m[2][3] = m[2][3] ^ gf4096_mul(m[0][3], minv2); | ||
186 | } | ||
187 | |||
188 | static void zero_3x4_col1(unsigned short m[3][4]) | ||
189 | { | ||
190 | unsigned short minv; | ||
191 | minv = gf4096_mul(m[2][1], gf4096_inv(m[1][1])); | ||
192 | m[2][0] = m[2][0] ^ gf4096_mul(m[1][0], minv); | ||
193 | m[2][3] = m[2][3] ^ gf4096_mul(m[1][3], minv); | ||
194 | } | ||
195 | |||
196 | static void swap_3x4_rows(unsigned short m[3][4], int i, int j, int col_width) | ||
197 | { | ||
198 | unsigned short tmp0; | ||
199 | int cnt; | ||
200 | for (cnt = 0; cnt < col_width; cnt++) { | ||
201 | tmp0 = m[i][cnt]; | ||
202 | m[i][cnt] = m[j][cnt]; | ||
203 | m[j][cnt] = tmp0; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | static void solve_3x4(unsigned short m[3][4], unsigned short *coefs, int *row_order) | ||
208 | { | ||
209 | unsigned short tmp[3]; | ||
210 | tmp[0] = gf4096_mul(m[2][3], gf4096_inv(m[2][0])); | ||
211 | tmp[1] = gf4096_mul((gf4096_mul(tmp[0], m[1][0]) ^ m[1][3]), gf4096_inv(m[1][1])); | ||
212 | tmp[2] = gf4096_mul((gf4096_mul(tmp[0], m[0][0]) ^ gf4096_mul(tmp[1], m[0][1]) ^ m[0][3]), gf4096_inv(m[0][2])); | ||
213 | sort_coefs(row_order, tmp, 3); | ||
214 | coefs[0] = tmp[0]; | ||
215 | coefs[1] = tmp[1]; | ||
216 | coefs[2] = tmp[2]; | ||
217 | } | ||
218 | |||
219 | static void find_3bit_err_pats(unsigned short s0, unsigned short s1, | ||
220 | unsigned short s2, unsigned short r0, | ||
221 | unsigned short r1, unsigned short r2, | ||
222 | unsigned short *pats) | ||
223 | { | ||
224 | find_2x2_soln(r0 ^ r2, r1 ^ r2, | ||
225 | gf4096_mul(r0, r0 ^ r2), gf4096_mul(r1, r1 ^ r2), | ||
226 | gf4096_mul(s0, r2) ^ s1, gf4096_mul(s1, r2) ^ s2, pats); | ||
227 | pats[2] = s0 ^ pats[0] ^ pats[1]; | ||
228 | } | ||
229 | |||
230 | static void find_4bit_err_coefs(unsigned short s0, unsigned short s1, | ||
231 | unsigned short s2, unsigned short s3, | ||
232 | unsigned short s4, unsigned short s5, | ||
233 | unsigned short s6, unsigned short s7, | ||
234 | unsigned short *coefs) | ||
235 | { | ||
236 | unsigned short m[4][5]; | ||
237 | int row_order[4]; | ||
238 | |||
239 | row_order[0] = 0; | ||
240 | row_order[1] = 1; | ||
241 | row_order[2] = 2; | ||
242 | row_order[3] = 3; | ||
243 | |||
244 | m[0][0] = s3; | ||
245 | m[0][1] = s2; | ||
246 | m[0][2] = s1; | ||
247 | m[0][3] = s0; | ||
248 | m[0][4] = s4; | ||
249 | m[1][0] = s4; | ||
250 | m[1][1] = s3; | ||
251 | m[1][2] = s2; | ||
252 | m[1][3] = s1; | ||
253 | m[1][4] = s5; | ||
254 | m[2][0] = s5; | ||
255 | m[2][1] = s4; | ||
256 | m[2][2] = s3; | ||
257 | m[2][3] = s2; | ||
258 | m[2][4] = s6; | ||
259 | m[3][0] = s6; | ||
260 | m[3][1] = s5; | ||
261 | m[3][2] = s4; | ||
262 | m[3][3] = s3; | ||
263 | m[3][4] = s7; | ||
264 | |||
265 | if (m[0][3] != 0x0) { | ||
266 | zero_4x5_col3(m); | ||
267 | } else if (m[1][3] != 0x0) { | ||
268 | swap_4x5_rows(m, 0, 1, 5); | ||
269 | zero_4x5_col3(m); | ||
270 | } else if (m[2][3] != 0x0) { | ||
271 | swap_4x5_rows(m, 0, 2, 5); | ||
272 | zero_4x5_col3(m); | ||
273 | } else if (m[3][3] != 0x0) { | ||
274 | swap_4x5_rows(m, 0, 3, 5); | ||
275 | zero_4x5_col3(m); | ||
276 | } else { | ||
277 | printk(KERN_ERR "Error: find_4bit_err_coefs, s0,s1,s2,s3 all zeros!\n"); | ||
278 | } | ||
279 | |||
280 | if (m[1][2] != 0x0) { | ||
281 | zero_4x5_col2(m); | ||
282 | } else if (m[2][2] != 0x0) { | ||
283 | swap_4x5_rows(m, 1, 2, 5); | ||
284 | zero_4x5_col2(m); | ||
285 | } else if (m[3][2] != 0x0) { | ||
286 | swap_4x5_rows(m, 1, 3, 5); | ||
287 | zero_4x5_col2(m); | ||
288 | } else { | ||
289 | printk(KERN_ERR "Error: find_4bit_err_coefs, cannot resolve col 2!\n"); | ||
290 | } | ||
291 | |||
292 | if (m[2][1] != 0x0) { | ||
293 | zero_4x5_col1(m); | ||
294 | } else if (m[3][1] != 0x0) { | ||
295 | swap_4x5_rows(m, 2, 3, 5); | ||
296 | zero_4x5_col1(m); | ||
297 | } else { | ||
298 | printk(KERN_ERR "Error: find_4bit_err_coefs, cannot resolve col 1!\n"); | ||
299 | } | ||
300 | |||
301 | solve_4x5(m, coefs, row_order); | ||
302 | } | ||
303 | |||
304 | static void zero_4x5_col3(unsigned short m[4][5]) | ||
305 | { | ||
306 | unsigned short minv1, minv2, minv3; | ||
307 | |||
308 | minv1 = gf4096_mul(m[1][3], gf4096_inv(m[0][3])); | ||
309 | minv2 = gf4096_mul(m[2][3], gf4096_inv(m[0][3])); | ||
310 | minv3 = gf4096_mul(m[3][3], gf4096_inv(m[0][3])); | ||
311 | |||
312 | m[1][0] = m[1][0] ^ gf4096_mul(m[0][0], minv1); | ||
313 | m[1][1] = m[1][1] ^ gf4096_mul(m[0][1], minv1); | ||
314 | m[1][2] = m[1][2] ^ gf4096_mul(m[0][2], minv1); | ||
315 | m[1][4] = m[1][4] ^ gf4096_mul(m[0][4], minv1); | ||
316 | m[2][0] = m[2][0] ^ gf4096_mul(m[0][0], minv2); | ||
317 | m[2][1] = m[2][1] ^ gf4096_mul(m[0][1], minv2); | ||
318 | m[2][2] = m[2][2] ^ gf4096_mul(m[0][2], minv2); | ||
319 | m[2][4] = m[2][4] ^ gf4096_mul(m[0][4], minv2); | ||
320 | m[3][0] = m[3][0] ^ gf4096_mul(m[0][0], minv3); | ||
321 | m[3][1] = m[3][1] ^ gf4096_mul(m[0][1], minv3); | ||
322 | m[3][2] = m[3][2] ^ gf4096_mul(m[0][2], minv3); | ||
323 | m[3][4] = m[3][4] ^ gf4096_mul(m[0][4], minv3); | ||
324 | } | ||
325 | |||
326 | static void zero_4x5_col2(unsigned short m[4][5]) | ||
327 | { | ||
328 | unsigned short minv2, minv3; | ||
329 | |||
330 | minv2 = gf4096_mul(m[2][2], gf4096_inv(m[1][2])); | ||
331 | minv3 = gf4096_mul(m[3][2], gf4096_inv(m[1][2])); | ||
332 | |||
333 | m[2][0] = m[2][0] ^ gf4096_mul(m[1][0], minv2); | ||
334 | m[2][1] = m[2][1] ^ gf4096_mul(m[1][1], minv2); | ||
335 | m[2][4] = m[2][4] ^ gf4096_mul(m[1][4], minv2); | ||
336 | m[3][0] = m[3][0] ^ gf4096_mul(m[1][0], minv3); | ||
337 | m[3][1] = m[3][1] ^ gf4096_mul(m[1][1], minv3); | ||
338 | m[3][4] = m[3][4] ^ gf4096_mul(m[1][4], minv3); | ||
339 | } | ||
340 | |||
341 | static void zero_4x5_col1(unsigned short m[4][5]) | ||
342 | { | ||
343 | unsigned short minv; | ||
344 | |||
345 | minv = gf4096_mul(m[3][1], gf4096_inv(m[2][1])); | ||
346 | |||
347 | m[3][0] = m[3][0] ^ gf4096_mul(m[2][0], minv); | ||
348 | m[3][4] = m[3][4] ^ gf4096_mul(m[2][4], minv); | ||
349 | } | ||
350 | |||
351 | static void swap_4x5_rows(unsigned short m[4][5], int i, int j, int col_width) | ||
352 | { | ||
353 | unsigned short tmp0; | ||
354 | int cnt; | ||
355 | |||
356 | for (cnt = 0; cnt < col_width; cnt++) { | ||
357 | tmp0 = m[i][cnt]; | ||
358 | m[i][cnt] = m[j][cnt]; | ||
359 | m[j][cnt] = tmp0; | ||
360 | } | ||
361 | } | ||
362 | |||
363 | static void solve_4x5(unsigned short m[4][5], unsigned short *coefs, int *row_order) | ||
364 | { | ||
365 | unsigned short tmp[4]; | ||
366 | |||
367 | tmp[0] = gf4096_mul(m[3][4], gf4096_inv(m[3][0])); | ||
368 | tmp[1] = gf4096_mul((gf4096_mul(tmp[0], m[2][0]) ^ m[2][4]), gf4096_inv(m[2][1])); | ||
369 | tmp[2] = gf4096_mul((gf4096_mul(tmp[0], m[1][0]) ^ gf4096_mul(tmp[1], m[1][1]) ^ m[1][4]), gf4096_inv(m[1][2])); | ||
370 | tmp[3] = gf4096_mul((gf4096_mul(tmp[0], m[0][0]) ^ | ||
371 | gf4096_mul(tmp[1], m[0][1]) ^ gf4096_mul(tmp[2], m[0][2]) ^ m[0][4]), gf4096_inv(m[0][3])); | ||
372 | sort_coefs(row_order, tmp, 4); | ||
373 | coefs[0] = tmp[0]; | ||
374 | coefs[1] = tmp[1]; | ||
375 | coefs[2] = tmp[2]; | ||
376 | coefs[3] = tmp[3]; | ||
377 | } | ||
378 | |||
379 | static void sort_coefs(int *order, unsigned short *soln, int len) | ||
380 | { | ||
381 | int cnt, start_cnt, least_ord, least_cnt; | ||
382 | unsigned short tmp0; | ||
383 | for (start_cnt = 0; start_cnt < len; start_cnt++) { | ||
384 | for (cnt = start_cnt; cnt < len; cnt++) { | ||
385 | if (cnt == start_cnt) { | ||
386 | least_ord = order[cnt]; | ||
387 | least_cnt = start_cnt; | ||
388 | } else { | ||
389 | if (least_ord > order[cnt]) { | ||
390 | least_ord = order[cnt]; | ||
391 | least_cnt = cnt; | ||
392 | } | ||
393 | } | ||
394 | } | ||
395 | if (least_cnt != start_cnt) { | ||
396 | tmp0 = order[least_cnt]; | ||
397 | order[least_cnt] = order[start_cnt]; | ||
398 | order[start_cnt] = tmp0; | ||
399 | tmp0 = soln[least_cnt]; | ||
400 | soln[least_cnt] = soln[start_cnt]; | ||
401 | soln[start_cnt] = tmp0; | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | |||
406 | static void find_4bit_err_pats(unsigned short s0, unsigned short s1, | ||
407 | unsigned short s2, unsigned short s3, | ||
408 | unsigned short z1, unsigned short z2, | ||
409 | unsigned short z3, unsigned short z4, | ||
410 | unsigned short *pats) | ||
411 | { | ||
412 | unsigned short z4_z1, z3z4_z3z3, z4_z2, s0z4_s1, z1z4_z1z1, | ||
413 | z4_z3, z2z4_z2z2, s1z4_s2, z3z3z4_z3z3z3, z1z1z4_z1z1z1, z2z2z4_z2z2z2, s2z4_s3; | ||
414 | unsigned short tmp0, tmp1, tmp2, tmp3; | ||
415 | |||
416 | z4_z1 = z4 ^ z1; | ||
417 | z3z4_z3z3 = gf4096_mul(z3, z4) ^ gf4096_mul(z3, z3); | ||
418 | z4_z2 = z4 ^ z2; | ||
419 | s0z4_s1 = gf4096_mul(s0, z4) ^ s1; | ||
420 | z1z4_z1z1 = gf4096_mul(z1, z4) ^ gf4096_mul(z1, z1); | ||
421 | z4_z3 = z4 ^ z3; | ||
422 | z2z4_z2z2 = gf4096_mul(z2, z4) ^ gf4096_mul(z2, z2); | ||
423 | s1z4_s2 = gf4096_mul(s1, z4) ^ s2; | ||
424 | z3z3z4_z3z3z3 = gf4096_mul(gf4096_mul(z3, z3), z4) ^ gf4096_mul(gf4096_mul(z3, z3), z3); | ||
425 | z1z1z4_z1z1z1 = gf4096_mul(gf4096_mul(z1, z1), z4) ^ gf4096_mul(gf4096_mul(z1, z1), z1); | ||
426 | z2z2z4_z2z2z2 = gf4096_mul(gf4096_mul(z2, z2), z4) ^ gf4096_mul(gf4096_mul(z2, z2), z2); | ||
427 | s2z4_s3 = gf4096_mul(s2, z4) ^ s3; | ||
428 | |||
429 | //find err pat 0,1 | ||
430 | find_2x2_soln(gf4096_mul(z4_z1, z3z4_z3z3) ^ | ||
431 | gf4096_mul(z1z4_z1z1, z4_z3), gf4096_mul(z4_z2, | ||
432 | z3z4_z3z3) ^ | ||
433 | gf4096_mul(z2z4_z2z2, z4_z3), gf4096_mul(z1z4_z1z1, | ||
434 | z3z3z4_z3z3z3) ^ | ||
435 | gf4096_mul(z1z1z4_z1z1z1, z3z4_z3z3), | ||
436 | gf4096_mul(z2z4_z2z2, | ||
437 | z3z3z4_z3z3z3) ^ gf4096_mul(z2z2z4_z2z2z2, | ||
438 | z3z4_z3z3), | ||
439 | gf4096_mul(s0z4_s1, z3z4_z3z3) ^ gf4096_mul(s1z4_s2, | ||
440 | z4_z3), | ||
441 | gf4096_mul(s1z4_s2, z3z3z4_z3z3z3) ^ gf4096_mul(s2z4_s3, z3z4_z3z3), pats); | ||
442 | tmp0 = pats[0]; | ||
443 | tmp1 = pats[1]; | ||
444 | tmp2 = pats[0] ^ pats[1] ^ s0; | ||
445 | tmp3 = gf4096_mul(pats[0], z1) ^ gf4096_mul(pats[1], z2) ^ s1; | ||
446 | |||
447 | //find err pat 2,3 | ||
448 | find_2x2_soln(0x1, 0x1, z3, z4, tmp2, tmp3, pats); | ||
449 | pats[2] = pats[0]; | ||
450 | pats[3] = pats[1]; | ||
451 | pats[0] = tmp0; | ||
452 | pats[1] = tmp1; | ||
453 | } | ||
454 | |||
455 | static void find_2x2_soln(unsigned short c00, unsigned short c01, | ||
456 | unsigned short c10, unsigned short c11, | ||
457 | unsigned short lval0, unsigned short lval1, | ||
458 | unsigned short *soln) | ||
459 | { | ||
460 | unsigned short m[2][3]; | ||
461 | m[0][0] = c00; | ||
462 | m[0][1] = c01; | ||
463 | m[0][2] = lval0; | ||
464 | m[1][0] = c10; | ||
465 | m[1][1] = c11; | ||
466 | m[1][2] = lval1; | ||
467 | |||
468 | if (m[0][1] != 0x0) { | ||
469 | /* */ | ||
470 | } else if (m[1][1] != 0x0) { | ||
471 | swap_2x3_rows(m); | ||
472 | } else { | ||
473 | printk(KERN_ERR "Warning: find_2bit_err_coefs, s0,s1 all zeros!\n"); | ||
474 | } | ||
475 | |||
476 | solve_2x3(m, soln); | ||
477 | } | ||
478 | |||
479 | static void swap_2x3_rows(unsigned short m[2][3]) | ||
480 | { | ||
481 | unsigned short tmp0; | ||
482 | int cnt; | ||
483 | |||
484 | for (cnt = 0; cnt < 3; cnt++) { | ||
485 | tmp0 = m[0][cnt]; | ||
486 | m[0][cnt] = m[1][cnt]; | ||
487 | m[1][cnt] = tmp0; | ||
488 | } | ||
489 | } | ||
490 | |||
491 | static void solve_2x3(unsigned short m[2][3], unsigned short *coefs) | ||
492 | { | ||
493 | unsigned short minv; | ||
494 | |||
495 | minv = gf4096_mul(m[1][1], gf4096_inv(m[0][1])); | ||
496 | m[1][0] = m[1][0] ^ gf4096_mul(m[0][0], minv); | ||
497 | m[1][2] = m[1][2] ^ gf4096_mul(m[0][2], minv); | ||
498 | coefs[0] = gf4096_mul(m[1][2], gf4096_inv(m[1][0])); | ||
499 | coefs[1] = gf4096_mul((gf4096_mul(coefs[0], m[0][0]) ^ m[0][2]), gf4096_inv(m[0][1])); | ||
500 | } | ||
501 | |||
502 | static unsigned char gf64_inv[64] = { | ||
503 | 0, 1, 33, 62, 49, 43, 31, 44, 57, 37, 52, 28, 46, 40, 22, 25, | ||
504 | 61, 54, 51, 39, 26, 35, 14, 24, 23, 15, 20, 34, 11, 53, 45, 6, | ||
505 | 63, 2, 27, 21, 56, 9, 50, 19, 13, 47, 48, 5, 7, 30, 12, 41, | ||
506 | 42, 4, 38, 18, 10, 29, 17, 60, 36, 8, 59, 58, 55, 16, 3, 32 | ||
507 | }; | ||
508 | |||
509 | static unsigned short gf4096_inv(unsigned short din) | ||
510 | { | ||
511 | unsigned short alahxal, ah2B, deno, inv, bl, bh; | ||
512 | unsigned short ah, al, ahxal; | ||
513 | unsigned short dout; | ||
514 | |||
515 | ah = (din >> 6) & 0x3f; | ||
516 | al = din & 0x3f; | ||
517 | ahxal = ah ^ al; | ||
518 | ah2B = (((ah ^ (ah >> 3)) & 0x1) << 5) | | ||
519 | ((ah >> 1) & 0x10) | | ||
520 | ((((ah >> 5) ^ (ah >> 2)) & 0x1) << 3) | | ||
521 | ((ah >> 2) & 0x4) | ((((ah >> 4) ^ (ah >> 1)) & 0x1) << 1) | (ah & 0x1); | ||
522 | alahxal = gf64_mul(ahxal, al); | ||
523 | deno = alahxal ^ ah2B; | ||
524 | inv = gf64_inv[deno]; | ||
525 | bl = gf64_mul(inv, ahxal); | ||
526 | bh = gf64_mul(inv, ah); | ||
527 | dout = ((bh & 0x3f) << 6) | (bl & 0x3f); | ||
528 | return (((bh & 0x3f) << 6) | (bl & 0x3f)); | ||
529 | } | ||
530 | |||
531 | static unsigned short err_pos_lut[4096] = { | ||
532 | 0xfff, 0x000, 0x451, 0xfff, 0xfff, 0x3cf, 0xfff, 0x041, | ||
533 | 0xfff, 0xfff, 0xfff, 0xfff, 0x28a, 0xfff, 0x492, 0xfff, | ||
534 | 0x145, 0xfff, 0xfff, 0x514, 0xfff, 0x082, 0xfff, 0xfff, | ||
535 | 0xfff, 0x249, 0x38e, 0x410, 0xfff, 0x104, 0x208, 0x1c7, | ||
536 | 0xfff, 0xfff, 0xfff, 0xfff, 0x2cb, 0xfff, 0xfff, 0xfff, | ||
537 | 0x0c3, 0x34d, 0x4d3, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
538 | 0xfff, 0xfff, 0xfff, 0x186, 0xfff, 0xfff, 0xfff, 0xfff, | ||
539 | 0xfff, 0x30c, 0x555, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
540 | 0xfff, 0xfff, 0xfff, 0x166, 0xfff, 0xfff, 0xfff, 0xfff, | ||
541 | 0x385, 0x14e, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4e1, | ||
542 | 0xfff, 0xfff, 0xfff, 0xfff, 0x538, 0xfff, 0x16d, 0xfff, | ||
543 | 0xfff, 0xfff, 0x45b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
544 | 0xfff, 0xfff, 0xfff, 0x29c, 0x2cc, 0x30b, 0x2b3, 0xfff, | ||
545 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x0b3, 0xfff, 0x2f7, | ||
546 | 0xfff, 0x32b, 0xfff, 0xfff, 0xfff, 0xfff, 0x0a7, 0xfff, | ||
547 | 0xfff, 0x2da, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
548 | 0xfff, 0x07e, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
549 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x11c, 0xfff, 0xfff, | ||
550 | 0xfff, 0xfff, 0xfff, 0x22f, 0xfff, 0x1f4, 0xfff, 0xfff, | ||
551 | 0x2b0, 0x504, 0xfff, 0x114, 0xfff, 0xfff, 0xfff, 0x21d, | ||
552 | 0xfff, 0xfff, 0xfff, 0xfff, 0x00d, 0x3c4, 0x340, 0x10f, | ||
553 | 0xfff, 0xfff, 0x266, 0x02e, 0xfff, 0xfff, 0xfff, 0x4f8, | ||
554 | 0x337, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
555 | 0xfff, 0xfff, 0xfff, 0x07b, 0x168, 0xfff, 0xfff, 0x0fe, | ||
556 | 0xfff, 0xfff, 0x51a, 0xfff, 0x458, 0xfff, 0x36d, 0xfff, | ||
557 | 0xfff, 0xfff, 0xfff, 0x073, 0x37d, 0x415, 0x550, 0xfff, | ||
558 | 0xfff, 0xfff, 0x23b, 0x4b4, 0xfff, 0xfff, 0xfff, 0x1a1, | ||
559 | 0xfff, 0xfff, 0x3aa, 0xfff, 0x117, 0x04d, 0x341, 0xfff, | ||
560 | 0xfff, 0xfff, 0xfff, 0x518, 0x03e, 0x0f2, 0xfff, 0xfff, | ||
561 | 0xfff, 0xfff, 0xfff, 0x363, 0xfff, 0x0b9, 0xfff, 0xfff, | ||
562 | 0x241, 0xfff, 0xfff, 0x049, 0xfff, 0xfff, 0xfff, 0xfff, | ||
563 | 0x15f, 0x52d, 0xfff, 0xfff, 0xfff, 0x29e, 0xfff, 0xfff, | ||
564 | 0xfff, 0xfff, 0x4cf, 0x0fc, 0xfff, 0x36f, 0x3d3, 0xfff, | ||
565 | 0x228, 0xfff, 0xfff, 0x45e, 0xfff, 0xfff, 0xfff, 0xfff, | ||
566 | 0x238, 0xfff, 0xfff, 0xfff, 0xfff, 0x47f, 0xfff, 0xfff, | ||
567 | 0x43a, 0x265, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x3e8, | ||
568 | 0xfff, 0xfff, 0x01a, 0xfff, 0xfff, 0xfff, 0xfff, 0x21e, | ||
569 | 0x1fc, 0x40b, 0xfff, 0xfff, 0xfff, 0x2d0, 0x159, 0xfff, | ||
570 | 0xfff, 0x313, 0xfff, 0xfff, 0x05c, 0x4cc, 0xfff, 0xfff, | ||
571 | 0x0f6, 0x3d5, 0xfff, 0xfff, 0xfff, 0x54f, 0xfff, 0xfff, | ||
572 | 0xfff, 0x172, 0x1e4, 0x07c, 0xfff, 0xfff, 0xfff, 0xfff, | ||
573 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x53c, 0x1ad, 0x535, | ||
574 | 0x19b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
575 | 0xfff, 0xfff, 0x092, 0xfff, 0x2be, 0xfff, 0xfff, 0x482, | ||
576 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x0e6, 0xfff, 0xfff, | ||
577 | 0xfff, 0xfff, 0xfff, 0x476, 0xfff, 0x51d, 0xfff, 0xfff, | ||
578 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
579 | 0xfff, 0xfff, 0x342, 0x2b5, 0x22e, 0x09a, 0xfff, 0x08d, | ||
580 | 0x44f, 0x3ed, 0xfff, 0xfff, 0xfff, 0xfff, 0x3d1, 0xfff, | ||
581 | 0xfff, 0x543, 0xfff, 0x48f, 0xfff, 0x3d2, 0xfff, 0x0d5, | ||
582 | 0x113, 0x0ec, 0x427, 0xfff, 0xfff, 0xfff, 0x4c4, 0xfff, | ||
583 | 0xfff, 0x50a, 0xfff, 0x144, 0xfff, 0x105, 0x39f, 0x294, | ||
584 | 0x164, 0xfff, 0x31a, 0xfff, 0xfff, 0x49a, 0xfff, 0x130, | ||
585 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
586 | 0x1be, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
587 | 0xfff, 0xfff, 0x49e, 0x371, 0xfff, 0xfff, 0xfff, 0xfff, | ||
588 | 0xfff, 0xfff, 0xfff, 0xfff, 0x0e8, 0x49c, 0x0f4, 0xfff, | ||
589 | 0x338, 0x1a7, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
590 | 0xfff, 0x36c, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
591 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
592 | 0xfff, 0x1ae, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
593 | 0xfff, 0x31b, 0xfff, 0xfff, 0x2dd, 0x522, 0xfff, 0xfff, | ||
594 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2f4, | ||
595 | 0x3c6, 0x30d, 0xfff, 0xfff, 0xfff, 0xfff, 0x34c, 0x18f, | ||
596 | 0x30a, 0xfff, 0x01f, 0x079, 0xfff, 0xfff, 0x54d, 0x46b, | ||
597 | 0x28c, 0x37f, 0xfff, 0xfff, 0xfff, 0xfff, 0x355, 0xfff, | ||
598 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x14f, 0xfff, 0xfff, | ||
599 | 0xfff, 0xfff, 0xfff, 0x359, 0x3fe, 0x3c5, 0xfff, 0xfff, | ||
600 | 0xfff, 0xfff, 0x423, 0xfff, 0xfff, 0x34a, 0x22c, 0xfff, | ||
601 | 0x25a, 0xfff, 0xfff, 0x4ad, 0xfff, 0x28d, 0xfff, 0xfff, | ||
602 | 0xfff, 0xfff, 0xfff, 0x547, 0xfff, 0xfff, 0xfff, 0xfff, | ||
603 | 0x2e2, 0xfff, 0xfff, 0x1d5, 0xfff, 0x2a8, 0xfff, 0xfff, | ||
604 | 0x03f, 0xfff, 0xfff, 0xfff, 0xfff, 0x3eb, 0x0fa, 0xfff, | ||
605 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x55b, 0xfff, | ||
606 | 0x08e, 0xfff, 0x3ae, 0xfff, 0x3a4, 0xfff, 0x282, 0x158, | ||
607 | 0xfff, 0x382, 0xfff, 0xfff, 0x499, 0xfff, 0xfff, 0x08a, | ||
608 | 0xfff, 0xfff, 0xfff, 0x456, 0x3be, 0xfff, 0x1e2, 0xfff, | ||
609 | 0xfff, 0xfff, 0xfff, 0xfff, 0x559, 0xfff, 0x1a0, 0xfff, | ||
610 | 0xfff, 0x0b4, 0xfff, 0xfff, 0xfff, 0x2df, 0xfff, 0xfff, | ||
611 | 0xfff, 0x07f, 0x4f5, 0xfff, 0xfff, 0x27c, 0x133, 0x017, | ||
612 | 0xfff, 0x3fd, 0xfff, 0xfff, 0xfff, 0x44d, 0x4cd, 0x17a, | ||
613 | 0x0d7, 0x537, 0xfff, 0xfff, 0x353, 0xfff, 0xfff, 0x351, | ||
614 | 0x366, 0xfff, 0x44a, 0xfff, 0x1a6, 0xfff, 0xfff, 0xfff, | ||
615 | 0x291, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1e3, | ||
616 | 0xfff, 0xfff, 0xfff, 0xfff, 0x389, 0xfff, 0x07a, 0xfff, | ||
617 | 0x1b6, 0x2ed, 0xfff, 0xfff, 0xfff, 0xfff, 0x24e, 0x074, | ||
618 | 0xfff, 0xfff, 0x3dc, 0xfff, 0x4e3, 0xfff, 0xfff, 0xfff, | ||
619 | 0xfff, 0x4eb, 0xfff, 0xfff, 0x3b8, 0x4de, 0xfff, 0x19c, | ||
620 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x262, | ||
621 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x076, 0x4e8, 0x3da, | ||
622 | 0xfff, 0x531, 0xfff, 0xfff, 0x14a, 0xfff, 0x0a2, 0x433, | ||
623 | 0x3df, 0x1e9, 0xfff, 0xfff, 0xfff, 0xfff, 0x3e7, 0x285, | ||
624 | 0x2d8, 0xfff, 0xfff, 0xfff, 0x349, 0x18d, 0x098, 0xfff, | ||
625 | 0x0df, 0x4bf, 0xfff, 0xfff, 0x0b2, 0xfff, 0x346, 0x24d, | ||
626 | 0xfff, 0xfff, 0xfff, 0x24f, 0x4fa, 0x2f9, 0xfff, 0xfff, | ||
627 | 0x3c9, 0xfff, 0x2b4, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
628 | 0xfff, 0x056, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
629 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
630 | 0xfff, 0x179, 0xfff, 0x0e9, 0x3f0, 0x33d, 0xfff, 0xfff, | ||
631 | 0xfff, 0xfff, 0xfff, 0x1fd, 0xfff, 0xfff, 0x526, 0xfff, | ||
632 | 0xfff, 0xfff, 0x53d, 0xfff, 0xfff, 0xfff, 0x170, 0x331, | ||
633 | 0xfff, 0x068, 0xfff, 0xfff, 0xfff, 0x3f7, 0xfff, 0x3d8, | ||
634 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
635 | 0xfff, 0x09f, 0x556, 0xfff, 0xfff, 0x02d, 0xfff, 0xfff, | ||
636 | 0x553, 0xfff, 0xfff, 0xfff, 0x1f0, 0xfff, 0xfff, 0x4d6, | ||
637 | 0x41e, 0xfff, 0xfff, 0xfff, 0xfff, 0x4d5, 0xfff, 0xfff, | ||
638 | 0xfff, 0xfff, 0xfff, 0x248, 0xfff, 0xfff, 0xfff, 0x0a3, | ||
639 | 0xfff, 0x217, 0xfff, 0xfff, 0xfff, 0x4f1, 0x209, 0xfff, | ||
640 | 0xfff, 0x475, 0x234, 0x52b, 0x398, 0xfff, 0x08b, 0xfff, | ||
641 | 0xfff, 0xfff, 0xfff, 0x2c2, 0xfff, 0xfff, 0xfff, 0xfff, | ||
642 | 0xfff, 0xfff, 0x268, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
643 | 0xfff, 0x4a3, 0xfff, 0x0aa, 0xfff, 0x1d9, 0xfff, 0xfff, | ||
644 | 0xfff, 0xfff, 0x155, 0xfff, 0xfff, 0xfff, 0xfff, 0x0bf, | ||
645 | 0x539, 0xfff, 0xfff, 0x2f1, 0x545, 0xfff, 0xfff, 0xfff, | ||
646 | 0xfff, 0xfff, 0xfff, 0x2a7, 0x06f, 0xfff, 0x378, 0xfff, | ||
647 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x25e, 0xfff, | ||
648 | 0xfff, 0xfff, 0xfff, 0x15d, 0x02a, 0xfff, 0xfff, 0x0bc, | ||
649 | 0x235, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
650 | 0x150, 0xfff, 0x1a9, 0xfff, 0xfff, 0xfff, 0xfff, 0x381, | ||
651 | 0xfff, 0x04e, 0x270, 0x13f, 0xfff, 0xfff, 0x405, 0xfff, | ||
652 | 0x3cd, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
653 | 0xfff, 0x2ef, 0xfff, 0x06a, 0xfff, 0xfff, 0xfff, 0x34f, | ||
654 | 0x212, 0xfff, 0xfff, 0x0e2, 0xfff, 0x083, 0x298, 0xfff, | ||
655 | 0xfff, 0xfff, 0x0c2, 0xfff, 0xfff, 0x52e, 0xfff, 0x488, | ||
656 | 0xfff, 0xfff, 0xfff, 0x36b, 0xfff, 0xfff, 0xfff, 0x442, | ||
657 | 0x091, 0xfff, 0x41c, 0xfff, 0xfff, 0x3a5, 0xfff, 0x4e6, | ||
658 | 0xfff, 0xfff, 0x40d, 0x31d, 0xfff, 0xfff, 0xfff, 0x4c1, | ||
659 | 0x053, 0xfff, 0x418, 0x13c, 0xfff, 0x350, 0xfff, 0x0ae, | ||
660 | 0xfff, 0xfff, 0x41f, 0xfff, 0x470, 0xfff, 0x4ca, 0xfff, | ||
661 | 0xfff, 0xfff, 0x02b, 0x450, 0xfff, 0x1f8, 0xfff, 0xfff, | ||
662 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x293, 0xfff, | ||
663 | 0xfff, 0xfff, 0xfff, 0x411, 0xfff, 0xfff, 0xfff, 0xfff, | ||
664 | 0xfff, 0xfff, 0xfff, 0xfff, 0x0b8, 0xfff, 0xfff, 0xfff, | ||
665 | 0x3e1, 0xfff, 0xfff, 0xfff, 0xfff, 0x43c, 0xfff, 0x2b2, | ||
666 | 0x2ab, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1ec, | ||
667 | 0xfff, 0xfff, 0xfff, 0x3f8, 0x034, 0xfff, 0xfff, 0xfff, | ||
668 | 0xfff, 0xfff, 0xfff, 0x11a, 0xfff, 0x541, 0x45c, 0x134, | ||
669 | 0x1cc, 0xfff, 0xfff, 0xfff, 0x469, 0xfff, 0xfff, 0x44b, | ||
670 | 0x161, 0xfff, 0xfff, 0xfff, 0x055, 0xfff, 0xfff, 0xfff, | ||
671 | 0xfff, 0x307, 0xfff, 0xfff, 0xfff, 0xfff, 0x2d1, 0xfff, | ||
672 | 0xfff, 0xfff, 0x124, 0x37b, 0x26b, 0x336, 0xfff, 0xfff, | ||
673 | 0x2e4, 0x3cb, 0xfff, 0xfff, 0x0f8, 0x3c8, 0xfff, 0xfff, | ||
674 | 0xfff, 0x461, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4b5, | ||
675 | 0x2cf, 0xfff, 0xfff, 0xfff, 0x20f, 0xfff, 0x35a, 0xfff, | ||
676 | 0x490, 0xfff, 0x185, 0xfff, 0xfff, 0xfff, 0xfff, 0x42e, | ||
677 | 0xfff, 0xfff, 0xfff, 0xfff, 0x54b, 0xfff, 0xfff, 0xfff, | ||
678 | 0x146, 0xfff, 0x412, 0xfff, 0xfff, 0xfff, 0x1ff, 0xfff, | ||
679 | 0xfff, 0x3e0, 0xfff, 0xfff, 0xfff, 0xfff, 0x2d5, 0xfff, | ||
680 | 0x4df, 0x505, 0xfff, 0x413, 0xfff, 0x1a5, 0xfff, 0x3b2, | ||
681 | 0xfff, 0xfff, 0xfff, 0x35b, 0xfff, 0x116, 0xfff, 0xfff, | ||
682 | 0x171, 0x4d0, 0xfff, 0x154, 0x12d, 0xfff, 0xfff, 0xfff, | ||
683 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x468, 0x4db, 0xfff, | ||
684 | 0xfff, 0x1df, 0xfff, 0xfff, 0xfff, 0xfff, 0x05a, 0xfff, | ||
685 | 0x0f1, 0x403, 0xfff, 0x22b, 0x2e0, 0xfff, 0xfff, 0xfff, | ||
686 | 0x2b7, 0x373, 0xfff, 0xfff, 0xfff, 0xfff, 0x13e, 0xfff, | ||
687 | 0xfff, 0xfff, 0x0d0, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
688 | 0x329, 0x1d2, 0x3fa, 0x047, 0xfff, 0x2f2, 0xfff, 0xfff, | ||
689 | 0x141, 0x0ac, 0x1d7, 0xfff, 0x07d, 0xfff, 0xfff, 0xfff, | ||
690 | 0x1c1, 0xfff, 0x487, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
691 | 0xfff, 0xfff, 0xfff, 0x045, 0xfff, 0xfff, 0xfff, 0xfff, | ||
692 | 0x288, 0x0cd, 0xfff, 0xfff, 0xfff, 0xfff, 0x226, 0x1d8, | ||
693 | 0xfff, 0x153, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4cb, | ||
694 | 0x528, 0xfff, 0xfff, 0xfff, 0x20a, 0x343, 0x3a1, 0xfff, | ||
695 | 0xfff, 0xfff, 0x2d7, 0x2d3, 0x1aa, 0x4c5, 0xfff, 0xfff, | ||
696 | 0xfff, 0x42b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
697 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3e9, 0xfff, 0x20b, 0x260, | ||
698 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x37c, 0x2fd, | ||
699 | 0xfff, 0xfff, 0x2c8, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
700 | 0xfff, 0x31e, 0xfff, 0x335, 0xfff, 0xfff, 0xfff, 0xfff, | ||
701 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
702 | 0xfff, 0xfff, 0x135, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
703 | 0xfff, 0xfff, 0x35c, 0x4dd, 0x129, 0xfff, 0xfff, 0xfff, | ||
704 | 0xfff, 0xfff, 0x1ef, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
705 | 0xfff, 0x34e, 0xfff, 0xfff, 0xfff, 0xfff, 0x407, 0xfff, | ||
706 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3ad, 0xfff, 0xfff, 0xfff, | ||
707 | 0x379, 0xfff, 0xfff, 0x1d0, 0x38d, 0xfff, 0xfff, 0x1e8, | ||
708 | 0x184, 0x3c1, 0x1c4, 0xfff, 0x1f9, 0xfff, 0xfff, 0x424, | ||
709 | 0xfff, 0xfff, 0xfff, 0xfff, 0x1d3, 0x0d4, 0xfff, 0x4e9, | ||
710 | 0xfff, 0xfff, 0xfff, 0x530, 0x107, 0xfff, 0x106, 0x04f, | ||
711 | 0xfff, 0xfff, 0x4c7, 0x503, 0xfff, 0xfff, 0xfff, 0xfff, | ||
712 | 0xfff, 0x15c, 0xfff, 0x23f, 0xfff, 0xfff, 0xfff, 0xfff, | ||
713 | 0xfff, 0xfff, 0xfff, 0xfff, 0x4f3, 0xfff, 0xfff, 0x3c7, | ||
714 | 0xfff, 0x278, 0xfff, 0xfff, 0x0a6, 0xfff, 0xfff, 0xfff, | ||
715 | 0x122, 0x1cf, 0xfff, 0x327, 0xfff, 0x2e5, 0xfff, 0x29d, | ||
716 | 0xfff, 0xfff, 0x3f1, 0xfff, 0xfff, 0x48d, 0xfff, 0xfff, | ||
717 | 0xfff, 0xfff, 0x054, 0xfff, 0xfff, 0xfff, 0xfff, 0x178, | ||
718 | 0x27e, 0x4e0, 0x352, 0x02f, 0x09c, 0xfff, 0x2a0, 0xfff, | ||
719 | 0xfff, 0x46a, 0x457, 0xfff, 0xfff, 0x501, 0xfff, 0x2ba, | ||
720 | 0xfff, 0xfff, 0xfff, 0x54e, 0x2e7, 0xfff, 0xfff, 0xfff, | ||
721 | 0xfff, 0xfff, 0x551, 0xfff, 0xfff, 0x1db, 0x2aa, 0xfff, | ||
722 | 0xfff, 0x4bc, 0xfff, 0xfff, 0x395, 0xfff, 0x0de, 0xfff, | ||
723 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x455, 0xfff, 0x17e, | ||
724 | 0xfff, 0x221, 0x4a7, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
725 | 0x388, 0xfff, 0xfff, 0xfff, 0x308, 0xfff, 0xfff, 0xfff, | ||
726 | 0x20e, 0x4b9, 0xfff, 0x273, 0x20c, 0x09e, 0xfff, 0x057, | ||
727 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3f2, 0xfff, 0x1a8, 0x3a6, | ||
728 | 0x14c, 0xfff, 0xfff, 0x071, 0xfff, 0xfff, 0x53a, 0xfff, | ||
729 | 0xfff, 0xfff, 0xfff, 0x109, 0xfff, 0xfff, 0x399, 0xfff, | ||
730 | 0x061, 0x4f0, 0x39e, 0x244, 0xfff, 0x035, 0xfff, 0xfff, | ||
731 | 0x305, 0x47e, 0x297, 0xfff, 0xfff, 0x2b8, 0xfff, 0xfff, | ||
732 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1bc, 0xfff, 0x2fc, | ||
733 | 0xfff, 0xfff, 0x554, 0xfff, 0xfff, 0xfff, 0xfff, 0x3b6, | ||
734 | 0xfff, 0xfff, 0xfff, 0x515, 0x397, 0xfff, 0xfff, 0x12f, | ||
735 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4e5, | ||
736 | 0xfff, 0x4fc, 0xfff, 0xfff, 0x05e, 0xfff, 0xfff, 0xfff, | ||
737 | 0xfff, 0xfff, 0x0a8, 0x3af, 0x015, 0xfff, 0xfff, 0xfff, | ||
738 | 0xfff, 0x138, 0xfff, 0xfff, 0xfff, 0x540, 0xfff, 0xfff, | ||
739 | 0xfff, 0x027, 0x523, 0x2f0, 0xfff, 0xfff, 0xfff, 0xfff, | ||
740 | 0xfff, 0xfff, 0x16c, 0xfff, 0x27d, 0xfff, 0xfff, 0xfff, | ||
741 | 0xfff, 0x04c, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4dc, | ||
742 | 0xfff, 0xfff, 0x059, 0x301, 0xfff, 0xfff, 0xfff, 0xfff, | ||
743 | 0xfff, 0xfff, 0xfff, 0x1a3, 0xfff, 0x15a, 0xfff, 0xfff, | ||
744 | 0x0a5, 0xfff, 0x435, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
745 | 0xfff, 0x051, 0xfff, 0xfff, 0x131, 0xfff, 0x4f4, 0xfff, | ||
746 | 0xfff, 0xfff, 0xfff, 0x441, 0xfff, 0x4fb, 0xfff, 0x03b, | ||
747 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1ed, 0x274, | ||
748 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x0d3, 0x55e, 0x1b3, | ||
749 | 0xfff, 0x0bd, 0xfff, 0xfff, 0xfff, 0xfff, 0x225, 0xfff, | ||
750 | 0xfff, 0xfff, 0xfff, 0xfff, 0x4b7, 0xfff, 0xfff, 0x2ff, | ||
751 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4c3, 0xfff, | ||
752 | 0x383, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2f6, | ||
753 | 0xfff, 0xfff, 0x1ee, 0xfff, 0x03d, 0xfff, 0xfff, 0xfff, | ||
754 | 0xfff, 0xfff, 0x26f, 0x1dc, 0xfff, 0x0db, 0xfff, 0xfff, | ||
755 | 0xfff, 0xfff, 0xfff, 0x0ce, 0xfff, 0xfff, 0x127, 0x03a, | ||
756 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x311, 0xfff, | ||
757 | 0xfff, 0x13d, 0x09d, 0x47b, 0x2a6, 0x50d, 0x510, 0x19a, | ||
758 | 0xfff, 0x354, 0x414, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
759 | 0xfff, 0xfff, 0x44c, 0x3b0, 0xfff, 0x23d, 0x429, 0xfff, | ||
760 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
761 | 0x4c0, 0x416, 0xfff, 0x05b, 0xfff, 0xfff, 0x137, 0xfff, | ||
762 | 0x25f, 0x49f, 0xfff, 0x279, 0x013, 0xfff, 0xfff, 0xfff, | ||
763 | 0x269, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
764 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x3d0, 0xfff, 0xfff, | ||
765 | 0xfff, 0xfff, 0xfff, 0xfff, 0x077, 0xfff, 0xfff, 0x3fb, | ||
766 | 0xfff, 0xfff, 0xfff, 0xfff, 0x271, 0x3a0, 0xfff, 0xfff, | ||
767 | 0x40f, 0xfff, 0xfff, 0x3de, 0xfff, 0xfff, 0xfff, 0xfff, | ||
768 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1ab, 0x26a, | ||
769 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x489, 0xfff, 0xfff, | ||
770 | 0x252, 0xfff, 0xfff, 0xfff, 0xfff, 0x1b7, 0x42f, 0xfff, | ||
771 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x3b7, | ||
772 | 0xfff, 0x2bb, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
773 | 0xfff, 0xfff, 0xfff, 0x0f7, 0x01d, 0xfff, 0x067, 0xfff, | ||
774 | 0xfff, 0xfff, 0xfff, 0x4e2, 0xfff, 0xfff, 0x4bb, 0xfff, | ||
775 | 0xfff, 0xfff, 0x17b, 0xfff, 0x0ee, 0xfff, 0xfff, 0xfff, | ||
776 | 0xfff, 0xfff, 0x36e, 0xfff, 0xfff, 0xfff, 0x533, 0xfff, | ||
777 | 0xfff, 0xfff, 0x4d4, 0x356, 0xfff, 0xfff, 0x375, 0xfff, | ||
778 | 0xfff, 0xfff, 0xfff, 0x4a4, 0x513, 0xfff, 0xfff, 0xfff, | ||
779 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4ff, 0xfff, 0x2af, | ||
780 | 0xfff, 0xfff, 0x026, 0xfff, 0x0ad, 0xfff, 0xfff, 0xfff, | ||
781 | 0xfff, 0x26e, 0xfff, 0xfff, 0xfff, 0xfff, 0x493, 0xfff, | ||
782 | 0x463, 0x4d2, 0x4be, 0xfff, 0xfff, 0xfff, 0xfff, 0x4f2, | ||
783 | 0x0b6, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
784 | 0xfff, 0x32d, 0x315, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
785 | 0xfff, 0x13a, 0x4a1, 0xfff, 0x27a, 0xfff, 0xfff, 0xfff, | ||
786 | 0x47a, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
787 | 0x334, 0xfff, 0xfff, 0xfff, 0xfff, 0x54c, 0xfff, 0xfff, | ||
788 | 0xfff, 0x0c9, 0x007, 0xfff, 0xfff, 0x12e, 0xfff, 0x0ff, | ||
789 | 0xfff, 0xfff, 0x3f5, 0x509, 0xfff, 0xfff, 0xfff, 0xfff, | ||
790 | 0x1c3, 0x2ad, 0xfff, 0xfff, 0x47c, 0x261, 0xfff, 0xfff, | ||
791 | 0xfff, 0xfff, 0xfff, 0x152, 0xfff, 0xfff, 0xfff, 0x339, | ||
792 | 0xfff, 0x243, 0x1c0, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
793 | 0x063, 0xfff, 0xfff, 0x254, 0xfff, 0xfff, 0x173, 0xfff, | ||
794 | 0x0c7, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
795 | 0xfff, 0x362, 0x259, 0x485, 0x374, 0x0dc, 0x3ab, 0xfff, | ||
796 | 0x1c5, 0x534, 0x544, 0xfff, 0xfff, 0x508, 0xfff, 0x402, | ||
797 | 0x408, 0xfff, 0x0e7, 0xfff, 0xfff, 0x00a, 0x205, 0xfff, | ||
798 | 0xfff, 0x2b9, 0xfff, 0xfff, 0xfff, 0x465, 0xfff, 0xfff, | ||
799 | 0xfff, 0xfff, 0xfff, 0xfff, 0x23a, 0xfff, 0xfff, 0xfff, | ||
800 | 0xfff, 0x147, 0x19d, 0x115, 0x214, 0xfff, 0x090, 0x368, | ||
801 | 0xfff, 0x210, 0xfff, 0xfff, 0x280, 0x52a, 0x163, 0x148, | ||
802 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x326, 0xfff, 0xfff, | ||
803 | 0xfff, 0xfff, 0xfff, 0x2de, 0xfff, 0xfff, 0xfff, 0xfff, | ||
804 | 0x206, 0x2c1, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
805 | 0x189, 0xfff, 0xfff, 0xfff, 0xfff, 0x367, 0xfff, 0x1a4, | ||
806 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x443, 0xfff, 0x27b, | ||
807 | 0xfff, 0xfff, 0x251, 0x549, 0xfff, 0xfff, 0xfff, 0xfff, | ||
808 | 0xfff, 0xfff, 0x188, 0x04b, 0xfff, 0xfff, 0xfff, 0x31f, | ||
809 | 0x4a6, 0xfff, 0x246, 0x1de, 0x156, 0xfff, 0xfff, 0xfff, | ||
810 | 0x3a9, 0xfff, 0xfff, 0xfff, 0x2fa, 0xfff, 0x128, 0x0d1, | ||
811 | 0x449, 0x255, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
812 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
813 | 0xfff, 0xfff, 0xfff, 0xfff, 0x258, 0xfff, 0xfff, 0xfff, | ||
814 | 0x532, 0xfff, 0xfff, 0xfff, 0x303, 0x517, 0xfff, 0xfff, | ||
815 | 0x2a9, 0x24a, 0xfff, 0xfff, 0x231, 0xfff, 0xfff, 0xfff, | ||
816 | 0xfff, 0xfff, 0x4b6, 0x516, 0xfff, 0xfff, 0x0e4, 0x0eb, | ||
817 | 0xfff, 0x4e4, 0xfff, 0x275, 0xfff, 0xfff, 0x031, 0xfff, | ||
818 | 0xfff, 0xfff, 0xfff, 0xfff, 0x025, 0x21a, 0xfff, 0x0cc, | ||
819 | 0x45f, 0x3d9, 0x289, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
820 | 0xfff, 0xfff, 0x23e, 0xfff, 0xfff, 0xfff, 0x438, 0x097, | ||
821 | 0x419, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
822 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
823 | 0xfff, 0xfff, 0x0a9, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
824 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
825 | 0x37e, 0x0e0, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x431, | ||
826 | 0x372, 0xfff, 0xfff, 0xfff, 0x1ba, 0x06e, 0xfff, 0x1b1, | ||
827 | 0xfff, 0xfff, 0x12a, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
828 | 0xfff, 0xfff, 0x193, 0xfff, 0xfff, 0xfff, 0xfff, 0x10a, | ||
829 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x048, 0x1b4, | ||
830 | 0xfff, 0xfff, 0xfff, 0xfff, 0x295, 0x140, 0x108, 0xfff, | ||
831 | 0xfff, 0xfff, 0xfff, 0x16f, 0xfff, 0x0a4, 0x37a, 0xfff, | ||
832 | 0x29a, 0xfff, 0x284, 0xfff, 0xfff, 0xfff, 0xfff, 0x4c6, | ||
833 | 0x2a2, 0x3a3, 0xfff, 0x201, 0xfff, 0xfff, 0xfff, 0x4bd, | ||
834 | 0x005, 0x54a, 0x3b5, 0x204, 0x2ee, 0x11d, 0x436, 0xfff, | ||
835 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3ec, 0xfff, 0xfff, 0xfff, | ||
836 | 0xfff, 0xfff, 0xfff, 0xfff, 0x11f, 0x498, 0x21c, 0xfff, | ||
837 | 0xfff, 0xfff, 0x3d6, 0xfff, 0x4ab, 0xfff, 0x432, 0x2eb, | ||
838 | 0x542, 0x4fd, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
839 | 0xfff, 0xfff, 0xfff, 0x4ce, 0xfff, 0xfff, 0x2fb, 0xfff, | ||
840 | 0xfff, 0x2e1, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
841 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1b9, 0x037, 0x0dd, | ||
842 | 0xfff, 0xfff, 0xfff, 0x2bf, 0x521, 0x496, 0x095, 0xfff, | ||
843 | 0xfff, 0x328, 0x070, 0x1bf, 0xfff, 0x393, 0xfff, 0xfff, | ||
844 | 0x102, 0xfff, 0xfff, 0x21b, 0xfff, 0x142, 0x263, 0x519, | ||
845 | 0xfff, 0x2a5, 0x177, 0xfff, 0x14d, 0x471, 0x4ae, 0xfff, | ||
846 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
847 | 0x1f6, 0xfff, 0x481, 0xfff, 0xfff, 0xfff, 0x151, 0xfff, | ||
848 | 0xfff, 0xfff, 0x085, 0x33f, 0xfff, 0xfff, 0xfff, 0x084, | ||
849 | 0xfff, 0xfff, 0xfff, 0x345, 0x3a2, 0xfff, 0xfff, 0x0a0, | ||
850 | 0x0da, 0x024, 0xfff, 0xfff, 0xfff, 0x1bd, 0xfff, 0x55c, | ||
851 | 0x467, 0x445, 0xfff, 0xfff, 0xfff, 0x052, 0xfff, 0xfff, | ||
852 | 0xfff, 0xfff, 0x51e, 0xfff, 0xfff, 0x39d, 0xfff, 0x35f, | ||
853 | 0xfff, 0x376, 0x3ee, 0xfff, 0xfff, 0xfff, 0xfff, 0x448, | ||
854 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x16a, | ||
855 | 0xfff, 0x036, 0x38f, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
856 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x211, | ||
857 | 0xfff, 0xfff, 0xfff, 0x230, 0xfff, 0xfff, 0x3ba, 0xfff, | ||
858 | 0xfff, 0xfff, 0x3ce, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
859 | 0xfff, 0xfff, 0xfff, 0x229, 0xfff, 0x176, 0xfff, 0xfff, | ||
860 | 0xfff, 0xfff, 0xfff, 0x00b, 0xfff, 0x162, 0x018, 0xfff, | ||
861 | 0xfff, 0x233, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
862 | 0x400, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
863 | 0xfff, 0xfff, 0xfff, 0x12b, 0xfff, 0xfff, 0xfff, 0xfff, | ||
864 | 0xfff, 0x3f4, 0xfff, 0x0f0, 0xfff, 0x1ac, 0xfff, 0xfff, | ||
865 | 0x119, 0xfff, 0x2c0, 0xfff, 0xfff, 0xfff, 0x49b, 0xfff, | ||
866 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x23c, 0xfff, | ||
867 | 0x4b3, 0x010, 0x064, 0xfff, 0xfff, 0x4ba, 0xfff, 0xfff, | ||
868 | 0xfff, 0xfff, 0xfff, 0x3c2, 0xfff, 0xfff, 0xfff, 0xfff, | ||
869 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x006, 0x196, 0xfff, | ||
870 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x100, 0x191, 0xfff, | ||
871 | 0x1ea, 0x29f, 0xfff, 0xfff, 0xfff, 0x276, 0xfff, 0xfff, | ||
872 | 0x2b1, 0x3b9, 0xfff, 0x03c, 0xfff, 0xfff, 0xfff, 0x180, | ||
873 | 0xfff, 0x08f, 0xfff, 0xfff, 0x19e, 0x019, 0xfff, 0x0b0, | ||
874 | 0x0fd, 0x332, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
875 | 0xfff, 0x06b, 0x2e8, 0xfff, 0x446, 0xfff, 0xfff, 0x004, | ||
876 | 0x247, 0x197, 0xfff, 0x112, 0x169, 0x292, 0xfff, 0x302, | ||
877 | 0xfff, 0xfff, 0x33b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
878 | 0xfff, 0xfff, 0xfff, 0x287, 0x21f, 0xfff, 0x3ea, 0xfff, | ||
879 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4e7, 0xfff, 0xfff, | ||
880 | 0xfff, 0xfff, 0xfff, 0x3a8, 0xfff, 0xfff, 0x2bc, 0xfff, | ||
881 | 0x484, 0x296, 0xfff, 0x1c9, 0x08c, 0x1e5, 0x48a, 0xfff, | ||
882 | 0x360, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
883 | 0x1ca, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
884 | 0xfff, 0xfff, 0xfff, 0x10d, 0xfff, 0xfff, 0xfff, 0xfff, | ||
885 | 0xfff, 0xfff, 0x066, 0x2ea, 0x28b, 0x25b, 0xfff, 0x072, | ||
886 | 0xfff, 0xfff, 0xfff, 0xfff, 0x2b6, 0xfff, 0xfff, 0x272, | ||
887 | 0xfff, 0xfff, 0x525, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
888 | 0x2ca, 0xfff, 0xfff, 0xfff, 0x299, 0xfff, 0xfff, 0xfff, | ||
889 | 0x558, 0x41a, 0xfff, 0x4f7, 0x557, 0xfff, 0x4a0, 0x344, | ||
890 | 0x12c, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x125, | ||
891 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
892 | 0x40e, 0xfff, 0xfff, 0x502, 0xfff, 0x103, 0x3e6, 0xfff, | ||
893 | 0x527, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
894 | 0xfff, 0xfff, 0xfff, 0x45d, 0xfff, 0xfff, 0xfff, 0xfff, | ||
895 | 0x44e, 0xfff, 0xfff, 0xfff, 0xfff, 0x0d2, 0x4c9, 0x35e, | ||
896 | 0x459, 0x2d9, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x17d, | ||
897 | 0x0c4, 0xfff, 0xfff, 0xfff, 0x3ac, 0x390, 0x094, 0xfff, | ||
898 | 0x483, 0x0ab, 0xfff, 0x253, 0xfff, 0x391, 0xfff, 0xfff, | ||
899 | 0xfff, 0xfff, 0x123, 0x0ef, 0xfff, 0xfff, 0xfff, 0x330, | ||
900 | 0x38c, 0xfff, 0xfff, 0x2ae, 0xfff, 0xfff, 0xfff, 0x042, | ||
901 | 0x012, 0x06d, 0xfff, 0xfff, 0xfff, 0x32a, 0x3db, 0x364, | ||
902 | 0x2dc, 0xfff, 0x30f, 0x3d7, 0x4a5, 0x050, 0xfff, 0xfff, | ||
903 | 0x029, 0xfff, 0xfff, 0xfff, 0xfff, 0x1d1, 0xfff, 0xfff, | ||
904 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x480, 0xfff, | ||
905 | 0x4ed, 0x081, 0x0a1, 0xfff, 0xfff, 0xfff, 0x30e, 0x52f, | ||
906 | 0x257, 0xfff, 0xfff, 0x447, 0xfff, 0xfff, 0xfff, 0xfff, | ||
907 | 0xfff, 0xfff, 0xfff, 0x401, 0x3cc, 0xfff, 0xfff, 0x0fb, | ||
908 | 0x2c9, 0x42a, 0x314, 0x33e, 0x3bd, 0x318, 0xfff, 0x10e, | ||
909 | 0x2a1, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x24c, | ||
910 | 0x506, 0xfff, 0x267, 0xfff, 0xfff, 0x219, 0xfff, 0x1eb, | ||
911 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
912 | 0x309, 0x3e2, 0x46c, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
913 | 0x384, 0xfff, 0xfff, 0xfff, 0xfff, 0x50c, 0xfff, 0x24b, | ||
914 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x038, | ||
915 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x194, | ||
916 | 0x143, 0x3e3, 0xfff, 0xfff, 0xfff, 0x4c2, 0xfff, 0xfff, | ||
917 | 0x0e1, 0x25c, 0xfff, 0x237, 0xfff, 0x1fe, 0xfff, 0xfff, | ||
918 | 0xfff, 0x065, 0x2a4, 0xfff, 0x386, 0x55a, 0x11b, 0xfff, | ||
919 | 0xfff, 0x192, 0xfff, 0x183, 0x00e, 0xfff, 0xfff, 0xfff, | ||
920 | 0xfff, 0xfff, 0xfff, 0x4b2, 0x18e, 0xfff, 0xfff, 0xfff, | ||
921 | 0xfff, 0x486, 0x4ef, 0x0c6, 0x380, 0xfff, 0x4a8, 0xfff, | ||
922 | 0x0c5, 0xfff, 0xfff, 0xfff, 0xfff, 0x093, 0x1b8, 0xfff, | ||
923 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2e6, | ||
924 | 0xfff, 0x0f3, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
925 | 0x28e, 0xfff, 0x53b, 0x420, 0x22a, 0x33a, 0xfff, 0x387, | ||
926 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2a3, 0xfff, 0xfff, | ||
927 | 0xfff, 0x428, 0x500, 0xfff, 0xfff, 0x120, 0x2c6, 0x290, | ||
928 | 0x2f5, 0x0e3, 0xfff, 0x0b7, 0xfff, 0x319, 0x474, 0xfff, | ||
929 | 0xfff, 0xfff, 0x529, 0x014, 0xfff, 0x41b, 0x40a, 0x18b, | ||
930 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x0d9, | ||
931 | 0xfff, 0x38a, 0xfff, 0xfff, 0xfff, 0xfff, 0x1ce, 0xfff, | ||
932 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3b1, 0xfff, 0xfff, 0x05d, | ||
933 | 0x2c4, 0xfff, 0xfff, 0x4af, 0xfff, 0x030, 0xfff, 0xfff, | ||
934 | 0x203, 0xfff, 0x277, 0x256, 0xfff, 0xfff, 0xfff, 0x4f9, | ||
935 | 0xfff, 0x2c7, 0xfff, 0x466, 0x016, 0x1cd, 0xfff, 0x167, | ||
936 | 0xfff, 0xfff, 0x0c8, 0xfff, 0x43d, 0xfff, 0xfff, 0x020, | ||
937 | 0xfff, 0xfff, 0x232, 0x1cb, 0x1e0, 0xfff, 0xfff, 0x347, | ||
938 | 0xfff, 0x478, 0xfff, 0x365, 0xfff, 0xfff, 0xfff, 0xfff, | ||
939 | 0x358, 0xfff, 0x10b, 0xfff, 0x35d, 0xfff, 0xfff, 0xfff, | ||
940 | 0xfff, 0xfff, 0x452, 0x22d, 0xfff, 0xfff, 0x47d, 0xfff, | ||
941 | 0x2f3, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x460, 0xfff, | ||
942 | 0xfff, 0xfff, 0x50b, 0xfff, 0xfff, 0xfff, 0x2ec, 0xfff, | ||
943 | 0xfff, 0xfff, 0xfff, 0xfff, 0x4b1, 0x422, 0xfff, 0xfff, | ||
944 | 0xfff, 0x2d4, 0xfff, 0x239, 0xfff, 0xfff, 0xfff, 0x439, | ||
945 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
946 | 0xfff, 0x491, 0x075, 0xfff, 0xfff, 0xfff, 0x06c, 0xfff, | ||
947 | 0xfff, 0x0f9, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
948 | 0xfff, 0x139, 0xfff, 0x4f6, 0xfff, 0xfff, 0x409, 0xfff, | ||
949 | 0xfff, 0x15b, 0xfff, 0xfff, 0x348, 0xfff, 0xfff, 0xfff, | ||
950 | 0xfff, 0x4a2, 0x49d, 0xfff, 0x033, 0x175, 0xfff, 0x039, | ||
951 | 0xfff, 0x312, 0x40c, 0xfff, 0xfff, 0x325, 0xfff, 0xfff, | ||
952 | 0xfff, 0xfff, 0xfff, 0xfff, 0x4aa, 0xfff, 0xfff, 0xfff, | ||
953 | 0xfff, 0xfff, 0xfff, 0x165, 0x3bc, 0x48c, 0x310, 0x096, | ||
954 | 0xfff, 0xfff, 0x250, 0x1a2, 0xfff, 0xfff, 0xfff, 0xfff, | ||
955 | 0x20d, 0x2ac, 0xfff, 0xfff, 0x39b, 0xfff, 0x377, 0xfff, | ||
956 | 0x512, 0x495, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
957 | 0xfff, 0xfff, 0xfff, 0xfff, 0x357, 0x4ea, 0xfff, 0xfff, | ||
958 | 0xfff, 0xfff, 0x198, 0xfff, 0xfff, 0xfff, 0x434, 0x04a, | ||
959 | 0xfff, 0xfff, 0xfff, 0xfff, 0x062, 0xfff, 0x1d6, 0x1c8, | ||
960 | 0xfff, 0x1f3, 0x281, 0xfff, 0x462, 0xfff, 0xfff, 0xfff, | ||
961 | 0x4b0, 0xfff, 0x207, 0xfff, 0xfff, 0xfff, 0xfff, 0x3dd, | ||
962 | 0xfff, 0xfff, 0x55d, 0xfff, 0x552, 0x494, 0x1af, 0xfff, | ||
963 | 0xfff, 0xfff, 0xfff, 0xfff, 0x227, 0xfff, 0xfff, 0x069, | ||
964 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x43e, | ||
965 | 0x0b5, 0xfff, 0x524, 0x2d2, 0xfff, 0xfff, 0xfff, 0x28f, | ||
966 | 0xfff, 0x01b, 0x50e, 0xfff, 0xfff, 0x1bb, 0xfff, 0xfff, | ||
967 | 0x41d, 0xfff, 0x32e, 0x48e, 0xfff, 0x1f7, 0x224, 0xfff, | ||
968 | 0xfff, 0xfff, 0xfff, 0xfff, 0x394, 0xfff, 0xfff, 0xfff, | ||
969 | 0xfff, 0x52c, 0xfff, 0xfff, 0xfff, 0x392, 0xfff, 0x1e7, | ||
970 | 0xfff, 0xfff, 0x3f9, 0x3a7, 0xfff, 0x51f, 0xfff, 0x0bb, | ||
971 | 0x118, 0x3ca, 0xfff, 0x1dd, 0xfff, 0x48b, 0xfff, 0xfff, | ||
972 | 0xfff, 0xfff, 0x50f, 0xfff, 0x0d6, 0xfff, 0x1fa, 0xfff, | ||
973 | 0x11e, 0xfff, 0xfff, 0xfff, 0xfff, 0x4d7, 0xfff, 0x078, | ||
974 | 0x008, 0xfff, 0x25d, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
975 | 0x032, 0x33c, 0xfff, 0x4d9, 0x160, 0xfff, 0xfff, 0x300, | ||
976 | 0x0b1, 0xfff, 0x322, 0xfff, 0x4ec, 0xfff, 0xfff, 0x200, | ||
977 | 0x00c, 0x369, 0x473, 0xfff, 0xfff, 0x32c, 0xfff, 0xfff, | ||
978 | 0xfff, 0xfff, 0xfff, 0xfff, 0x53e, 0x3d4, 0x417, 0xfff, | ||
979 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
980 | 0x34b, 0x001, 0x39a, 0x02c, 0xfff, 0xfff, 0x2ce, 0x00f, | ||
981 | 0xfff, 0x0ba, 0xfff, 0xfff, 0xfff, 0xfff, 0x060, 0xfff, | ||
982 | 0x406, 0xfff, 0xfff, 0xfff, 0x4ee, 0x4ac, 0xfff, 0x43f, | ||
983 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x29b, 0xfff, 0xfff, | ||
984 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x216, | ||
985 | 0x190, 0xfff, 0x396, 0x464, 0xfff, 0xfff, 0x323, 0xfff, | ||
986 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2e9, 0xfff, 0x26d, | ||
987 | 0x2cd, 0x040, 0xfff, 0xfff, 0xfff, 0xfff, 0x38b, 0x3c0, | ||
988 | 0xfff, 0xfff, 0xfff, 0x1f2, 0xfff, 0x0ea, 0xfff, 0xfff, | ||
989 | 0x472, 0xfff, 0x1fb, 0xfff, 0xfff, 0x0af, 0x27f, 0xfff, | ||
990 | 0xfff, 0xfff, 0x479, 0x023, 0xfff, 0x0d8, 0x3b3, 0xfff, | ||
991 | 0xfff, 0xfff, 0x121, 0xfff, 0xfff, 0x3bf, 0xfff, 0xfff, | ||
992 | 0x16b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
993 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
994 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
995 | 0x45a, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
996 | 0xfff, 0x0be, 0xfff, 0xfff, 0xfff, 0x111, 0xfff, 0x220, | ||
997 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
998 | 0xfff, 0xfff, 0x09b, 0x218, 0xfff, 0x022, 0x202, 0xfff, | ||
999 | 0x4c8, 0xfff, 0x0ed, 0xfff, 0xfff, 0x182, 0xfff, 0xfff, | ||
1000 | 0xfff, 0x17f, 0x213, 0xfff, 0x321, 0x36a, 0xfff, 0x086, | ||
1001 | 0xfff, 0xfff, 0xfff, 0x43b, 0x088, 0xfff, 0xfff, 0xfff, | ||
1002 | 0xfff, 0x26c, 0xfff, 0x2f8, 0x3b4, 0xfff, 0xfff, 0xfff, | ||
1003 | 0x132, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x333, 0x444, | ||
1004 | 0x0c1, 0x4d8, 0x46d, 0x264, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1005 | 0x426, 0xfff, 0xfff, 0xfff, 0xfff, 0x2fe, 0xfff, 0xfff, | ||
1006 | 0xfff, 0xfff, 0x011, 0xfff, 0x05f, 0xfff, 0xfff, 0xfff, | ||
1007 | 0xfff, 0x10c, 0x101, 0xfff, 0xfff, 0xfff, 0xfff, 0x110, | ||
1008 | 0xfff, 0x044, 0x304, 0x361, 0x404, 0xfff, 0x51b, 0x099, | ||
1009 | 0xfff, 0x440, 0xfff, 0xfff, 0xfff, 0x222, 0xfff, 0xfff, | ||
1010 | 0xfff, 0xfff, 0x1b5, 0xfff, 0x136, 0x430, 0xfff, 0x1da, | ||
1011 | 0xfff, 0xfff, 0xfff, 0x043, 0xfff, 0x17c, 0xfff, 0xfff, | ||
1012 | 0xfff, 0x01c, 0xfff, 0xfff, 0xfff, 0x425, 0x236, 0xfff, | ||
1013 | 0x317, 0xfff, 0xfff, 0x437, 0x3fc, 0xfff, 0x1f1, 0xfff, | ||
1014 | 0x324, 0xfff, 0xfff, 0x0ca, 0x306, 0xfff, 0x548, 0xfff, | ||
1015 | 0x46e, 0xfff, 0xfff, 0xfff, 0x4b8, 0x1c2, 0x286, 0xfff, | ||
1016 | 0xfff, 0x087, 0x18a, 0x19f, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1017 | 0x18c, 0xfff, 0x215, 0xfff, 0xfff, 0xfff, 0xfff, 0x283, | ||
1018 | 0xfff, 0xfff, 0xfff, 0x126, 0xfff, 0xfff, 0x370, 0xfff, | ||
1019 | 0x53f, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x31c, 0xfff, | ||
1020 | 0x4d1, 0xfff, 0xfff, 0xfff, 0x021, 0xfff, 0x157, 0xfff, | ||
1021 | 0xfff, 0x028, 0x16e, 0xfff, 0x421, 0xfff, 0x1c6, 0xfff, | ||
1022 | 0xfff, 0x511, 0xfff, 0xfff, 0x39c, 0x46f, 0x1b2, 0xfff, | ||
1023 | 0xfff, 0x316, 0xfff, 0xfff, 0x009, 0xfff, 0xfff, 0x195, | ||
1024 | 0xfff, 0x240, 0x546, 0xfff, 0xfff, 0x520, 0xfff, 0xfff, | ||
1025 | 0xfff, 0xfff, 0xfff, 0xfff, 0x454, 0xfff, 0xfff, 0xfff, | ||
1026 | 0x3f3, 0xfff, 0xfff, 0x187, 0xfff, 0x4a9, 0xfff, 0xfff, | ||
1027 | 0xfff, 0xfff, 0xfff, 0xfff, 0x51c, 0x453, 0x1e6, 0xfff, | ||
1028 | 0xfff, 0xfff, 0x1b0, 0xfff, 0x477, 0xfff, 0xfff, 0xfff, | ||
1029 | 0x4fe, 0xfff, 0x32f, 0xfff, 0xfff, 0x15e, 0x1d4, 0xfff, | ||
1030 | 0x0e5, 0xfff, 0xfff, 0xfff, 0x242, 0x14b, 0x046, 0xfff, | ||
1031 | 0x3f6, 0x3bb, 0x3e4, 0xfff, 0xfff, 0x2e3, 0xfff, 0x245, | ||
1032 | 0xfff, 0x149, 0xfff, 0xfff, 0xfff, 0x2db, 0xfff, 0xfff, | ||
1033 | 0x181, 0xfff, 0x089, 0x2c5, 0xfff, 0x1f5, 0xfff, 0x2d6, | ||
1034 | 0x507, 0xfff, 0x42d, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1035 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1036 | 0x080, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1037 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3c3, 0x320, 0xfff, 0x1e1, | ||
1038 | 0xfff, 0x0f5, 0x13b, 0xfff, 0xfff, 0xfff, 0x003, 0x4da, | ||
1039 | 0xfff, 0xfff, 0xfff, 0x42c, 0xfff, 0xfff, 0x0cb, 0xfff, | ||
1040 | 0x536, 0x2c3, 0xfff, 0xfff, 0xfff, 0xfff, 0x199, 0xfff, | ||
1041 | 0xfff, 0x0c0, 0xfff, 0x01e, 0x497, 0xfff, 0xfff, 0x3e5, | ||
1042 | 0xfff, 0xfff, 0xfff, 0x0cf, 0xfff, 0x2bd, 0xfff, 0x223, | ||
1043 | 0xfff, 0x3ff, 0xfff, 0x058, 0x174, 0x3ef, 0xfff, 0x002 | ||
1044 | }; | ||
1045 | |||
1046 | static unsigned short err_pos(unsigned short din) | ||
1047 | { | ||
1048 | BUG_ON(din >= ARRAY_SIZE(err_pos_lut)); | ||
1049 | return err_pos_lut[din]; | ||
1050 | } | ||
1051 | static int chk_no_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1052 | { | ||
1053 | if ((chk_syndrome_list[0] | chk_syndrome_list[1] | | ||
1054 | chk_syndrome_list[2] | chk_syndrome_list[3] | | ||
1055 | chk_syndrome_list[4] | chk_syndrome_list[5] | | ||
1056 | chk_syndrome_list[6] | chk_syndrome_list[7]) != 0x0) { | ||
1057 | return -EINVAL; | ||
1058 | } else { | ||
1059 | err_info[0] = 0x0; | ||
1060 | return 0; | ||
1061 | } | ||
1062 | } | ||
1063 | static int chk_1_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1064 | { | ||
1065 | unsigned short tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; | ||
1066 | tmp0 = gf4096_mul(chk_syndrome_list[1], gf4096_inv(chk_syndrome_list[0])); | ||
1067 | tmp1 = gf4096_mul(chk_syndrome_list[2], gf4096_inv(chk_syndrome_list[1])); | ||
1068 | tmp2 = gf4096_mul(chk_syndrome_list[3], gf4096_inv(chk_syndrome_list[2])); | ||
1069 | tmp3 = gf4096_mul(chk_syndrome_list[4], gf4096_inv(chk_syndrome_list[3])); | ||
1070 | tmp4 = gf4096_mul(chk_syndrome_list[5], gf4096_inv(chk_syndrome_list[4])); | ||
1071 | tmp5 = gf4096_mul(chk_syndrome_list[6], gf4096_inv(chk_syndrome_list[5])); | ||
1072 | tmp6 = gf4096_mul(chk_syndrome_list[7], gf4096_inv(chk_syndrome_list[6])); | ||
1073 | if ((tmp0 == tmp1) & (tmp1 == tmp2) & (tmp2 == tmp3) & (tmp3 == tmp4) & (tmp4 == tmp5) & (tmp5 == tmp6)) { | ||
1074 | err_info[0] = 0x1; // encode 1-symbol error as 0x1 | ||
1075 | err_info[1] = err_pos(tmp0); | ||
1076 | err_info[1] = (unsigned short)(0x55e - err_info[1]); | ||
1077 | err_info[5] = chk_syndrome_list[0]; | ||
1078 | return 0; | ||
1079 | } else | ||
1080 | return -EINVAL; | ||
1081 | } | ||
1082 | static int chk_2_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1083 | { | ||
1084 | unsigned short tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; | ||
1085 | unsigned short coefs[4]; | ||
1086 | unsigned short err_pats[4]; | ||
1087 | int found_num_root = 0; | ||
1088 | unsigned short bit2_root0, bit2_root1; | ||
1089 | unsigned short bit2_root0_inv, bit2_root1_inv; | ||
1090 | unsigned short err_loc_eqn, test_root; | ||
1091 | unsigned short bit2_loc0, bit2_loc1; | ||
1092 | unsigned short bit2_pat0, bit2_pat1; | ||
1093 | |||
1094 | find_2x2_soln(chk_syndrome_list[1], | ||
1095 | chk_syndrome_list[0], | ||
1096 | chk_syndrome_list[2], chk_syndrome_list[1], chk_syndrome_list[2], chk_syndrome_list[3], coefs); | ||
1097 | for (test_root = 0x1; test_root < 0xfff; test_root++) { | ||
1098 | err_loc_eqn = | ||
1099 | gf4096_mul(coefs[1], gf4096_mul(test_root, test_root)) ^ gf4096_mul(coefs[0], test_root) ^ 0x1; | ||
1100 | if (err_loc_eqn == 0x0) { | ||
1101 | if (found_num_root == 0) { | ||
1102 | bit2_root0 = test_root; | ||
1103 | found_num_root = 1; | ||
1104 | } else if (found_num_root == 1) { | ||
1105 | bit2_root1 = test_root; | ||
1106 | found_num_root = 2; | ||
1107 | break; | ||
1108 | } | ||
1109 | } | ||
1110 | } | ||
1111 | if (found_num_root != 2) | ||
1112 | return -EINVAL; | ||
1113 | else { | ||
1114 | bit2_root0_inv = gf4096_inv(bit2_root0); | ||
1115 | bit2_root1_inv = gf4096_inv(bit2_root1); | ||
1116 | find_2bit_err_pats(chk_syndrome_list[0], | ||
1117 | chk_syndrome_list[1], bit2_root0_inv, bit2_root1_inv, err_pats); | ||
1118 | bit2_pat0 = err_pats[0]; | ||
1119 | bit2_pat1 = err_pats[1]; | ||
1120 | //for(x+1) | ||
1121 | tmp0 = gf4096_mul(gf4096_mul(bit2_root0_inv, bit2_root0_inv), gf4096_mul(bit2_root0_inv, bit2_root0_inv)); //rinv0^4 | ||
1122 | tmp1 = gf4096_mul(bit2_root0_inv, tmp0); //rinv0^5 | ||
1123 | tmp2 = gf4096_mul(bit2_root0_inv, tmp1); //rinv0^6 | ||
1124 | tmp3 = gf4096_mul(bit2_root0_inv, tmp2); //rinv0^7 | ||
1125 | tmp4 = gf4096_mul(gf4096_mul(bit2_root1_inv, bit2_root1_inv), gf4096_mul(bit2_root1_inv, bit2_root1_inv)); //rinv1^4 | ||
1126 | tmp5 = gf4096_mul(bit2_root1_inv, tmp4); //rinv1^5 | ||
1127 | tmp6 = gf4096_mul(bit2_root1_inv, tmp5); //rinv1^6 | ||
1128 | tmp7 = gf4096_mul(bit2_root1_inv, tmp6); //rinv1^7 | ||
1129 | //check if only 2-bit error | ||
1130 | if ((chk_syndrome_list[4] == | ||
1131 | (gf4096_mul(bit2_pat0, tmp0) ^ | ||
1132 | gf4096_mul(bit2_pat1, | ||
1133 | tmp4))) & (chk_syndrome_list[5] == | ||
1134 | (gf4096_mul(bit2_pat0, tmp1) ^ | ||
1135 | gf4096_mul(bit2_pat1, | ||
1136 | tmp5))) & | ||
1137 | (chk_syndrome_list[6] == | ||
1138 | (gf4096_mul(bit2_pat0, tmp2) ^ | ||
1139 | gf4096_mul(bit2_pat1, | ||
1140 | tmp6))) & (chk_syndrome_list[7] == | ||
1141 | (gf4096_mul(bit2_pat0, tmp3) ^ gf4096_mul(bit2_pat1, tmp7)))) { | ||
1142 | if ((err_pos(bit2_root0_inv) == 0xfff) | (err_pos(bit2_root1_inv) == 0xfff)) { | ||
1143 | return -EINVAL; | ||
1144 | } else { | ||
1145 | bit2_loc0 = 0x55e - err_pos(bit2_root0_inv); | ||
1146 | bit2_loc1 = 0x55e - err_pos(bit2_root1_inv); | ||
1147 | err_info[0] = 0x2; // encode 2-symbol error as 0x2 | ||
1148 | err_info[1] = bit2_loc0; | ||
1149 | err_info[2] = bit2_loc1; | ||
1150 | err_info[5] = bit2_pat0; | ||
1151 | err_info[6] = bit2_pat1; | ||
1152 | return 0; | ||
1153 | } | ||
1154 | } else | ||
1155 | return -EINVAL; | ||
1156 | } | ||
1157 | } | ||
1158 | static int chk_3_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1159 | { | ||
1160 | unsigned short tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; | ||
1161 | unsigned short coefs[4]; | ||
1162 | unsigned short err_pats[4]; | ||
1163 | int found_num_root = 0; | ||
1164 | unsigned short bit3_root0, bit3_root1, bit3_root2; | ||
1165 | unsigned short bit3_root0_inv, bit3_root1_inv, bit3_root2_inv; | ||
1166 | unsigned short err_loc_eqn, test_root; | ||
1167 | |||
1168 | find_3bit_err_coefs(chk_syndrome_list[0], chk_syndrome_list[1], | ||
1169 | chk_syndrome_list[2], chk_syndrome_list[3], | ||
1170 | chk_syndrome_list[4], chk_syndrome_list[5], coefs); | ||
1171 | |||
1172 | for (test_root = 0x1; test_root < 0xfff; test_root++) { | ||
1173 | err_loc_eqn = gf4096_mul(coefs[2], | ||
1174 | gf4096_mul(gf4096_mul(test_root, test_root), | ||
1175 | test_root)) ^ gf4096_mul(coefs[1], gf4096_mul(test_root, test_root)) | ||
1176 | ^ gf4096_mul(coefs[0], test_root) ^ 0x1; | ||
1177 | |||
1178 | if (err_loc_eqn == 0x0) { | ||
1179 | if (found_num_root == 0) { | ||
1180 | bit3_root0 = test_root; | ||
1181 | found_num_root = 1; | ||
1182 | } else if (found_num_root == 1) { | ||
1183 | bit3_root1 = test_root; | ||
1184 | found_num_root = 2; | ||
1185 | } else if (found_num_root == 2) { | ||
1186 | bit3_root2 = test_root; | ||
1187 | found_num_root = 3; | ||
1188 | break; | ||
1189 | } | ||
1190 | } | ||
1191 | } | ||
1192 | if (found_num_root != 3) | ||
1193 | return -EINVAL; | ||
1194 | else { | ||
1195 | bit3_root0_inv = gf4096_inv(bit3_root0); | ||
1196 | bit3_root1_inv = gf4096_inv(bit3_root1); | ||
1197 | bit3_root2_inv = gf4096_inv(bit3_root2); | ||
1198 | |||
1199 | find_3bit_err_pats(chk_syndrome_list[0], chk_syndrome_list[1], | ||
1200 | chk_syndrome_list[2], bit3_root0_inv, | ||
1201 | bit3_root1_inv, bit3_root2_inv, err_pats); | ||
1202 | |||
1203 | //check if only 3-bit error | ||
1204 | tmp0 = gf4096_mul(bit3_root0_inv, bit3_root0_inv); | ||
1205 | tmp0 = gf4096_mul(tmp0, tmp0); | ||
1206 | tmp0 = gf4096_mul(tmp0, bit3_root0_inv); | ||
1207 | tmp0 = gf4096_mul(tmp0, bit3_root0_inv); //rinv0^6 | ||
1208 | tmp1 = gf4096_mul(tmp0, bit3_root0_inv); //rinv0^7 | ||
1209 | tmp2 = gf4096_mul(bit3_root1_inv, bit3_root1_inv); | ||
1210 | tmp2 = gf4096_mul(tmp2, tmp2); | ||
1211 | tmp2 = gf4096_mul(tmp2, bit3_root1_inv); | ||
1212 | tmp2 = gf4096_mul(tmp2, bit3_root1_inv); //rinv1^6 | ||
1213 | tmp3 = gf4096_mul(tmp2, bit3_root1_inv); //rinv1^7 | ||
1214 | tmp4 = gf4096_mul(bit3_root2_inv, bit3_root2_inv); | ||
1215 | tmp4 = gf4096_mul(tmp4, tmp4); | ||
1216 | tmp4 = gf4096_mul(tmp4, bit3_root2_inv); | ||
1217 | tmp4 = gf4096_mul(tmp4, bit3_root2_inv); //rinv2^6 | ||
1218 | tmp5 = gf4096_mul(tmp4, bit3_root2_inv); //rinv2^7 | ||
1219 | |||
1220 | //check if only 3 errors | ||
1221 | if ((chk_syndrome_list[6] == (gf4096_mul(err_pats[0], tmp0) ^ | ||
1222 | gf4096_mul(err_pats[1], tmp2) ^ | ||
1223 | gf4096_mul(err_pats[2], tmp4))) & | ||
1224 | (chk_syndrome_list[7] == (gf4096_mul(err_pats[0], tmp1) ^ | ||
1225 | gf4096_mul(err_pats[1], tmp3) ^ gf4096_mul(err_pats[2], tmp5)))) { | ||
1226 | if ((err_pos(bit3_root0_inv) == 0xfff) | | ||
1227 | (err_pos(bit3_root1_inv) == 0xfff) | (err_pos(bit3_root2_inv) == 0xfff)) { | ||
1228 | return -EINVAL; | ||
1229 | } else { | ||
1230 | err_info[0] = 0x3; | ||
1231 | err_info[1] = (0x55e - err_pos(bit3_root0_inv)); | ||
1232 | err_info[2] = (0x55e - err_pos(bit3_root1_inv)); | ||
1233 | err_info[3] = (0x55e - err_pos(bit3_root2_inv)); | ||
1234 | err_info[5] = err_pats[0]; | ||
1235 | err_info[6] = err_pats[1]; | ||
1236 | err_info[7] = err_pats[2]; | ||
1237 | return 0; | ||
1238 | } | ||
1239 | } else | ||
1240 | return -EINVAL; | ||
1241 | } | ||
1242 | } | ||
1243 | static int chk_4_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1244 | { | ||
1245 | unsigned short coefs[4]; | ||
1246 | unsigned short err_pats[4]; | ||
1247 | int found_num_root = 0; | ||
1248 | unsigned short bit4_root0, bit4_root1, bit4_root2, bit4_root3; | ||
1249 | unsigned short bit4_root0_inv, bit4_root1_inv, bit4_root2_inv, bit4_root3_inv; | ||
1250 | unsigned short err_loc_eqn, test_root; | ||
1251 | |||
1252 | find_4bit_err_coefs(chk_syndrome_list[0], | ||
1253 | chk_syndrome_list[1], | ||
1254 | chk_syndrome_list[2], | ||
1255 | chk_syndrome_list[3], | ||
1256 | chk_syndrome_list[4], | ||
1257 | chk_syndrome_list[5], chk_syndrome_list[6], chk_syndrome_list[7], coefs); | ||
1258 | |||
1259 | for (test_root = 0x1; test_root < 0xfff; test_root++) { | ||
1260 | err_loc_eqn = | ||
1261 | gf4096_mul(coefs[3], | ||
1262 | gf4096_mul(gf4096_mul | ||
1263 | (gf4096_mul(test_root, test_root), | ||
1264 | test_root), | ||
1265 | test_root)) ^ gf4096_mul(coefs[2], | ||
1266 | gf4096_mul | ||
1267 | (gf4096_mul(test_root, test_root), test_root)) | ||
1268 | ^ gf4096_mul(coefs[1], gf4096_mul(test_root, test_root)) ^ gf4096_mul(coefs[0], test_root) | ||
1269 | ^ 0x1; | ||
1270 | if (err_loc_eqn == 0x0) { | ||
1271 | if (found_num_root == 0) { | ||
1272 | bit4_root0 = test_root; | ||
1273 | found_num_root = 1; | ||
1274 | } else if (found_num_root == 1) { | ||
1275 | bit4_root1 = test_root; | ||
1276 | found_num_root = 2; | ||
1277 | } else if (found_num_root == 2) { | ||
1278 | bit4_root2 = test_root; | ||
1279 | found_num_root = 3; | ||
1280 | } else { | ||
1281 | found_num_root = 4; | ||
1282 | bit4_root3 = test_root; | ||
1283 | break; | ||
1284 | } | ||
1285 | } | ||
1286 | } | ||
1287 | if (found_num_root != 4) { | ||
1288 | return -EINVAL; | ||
1289 | } else { | ||
1290 | bit4_root0_inv = gf4096_inv(bit4_root0); | ||
1291 | bit4_root1_inv = gf4096_inv(bit4_root1); | ||
1292 | bit4_root2_inv = gf4096_inv(bit4_root2); | ||
1293 | bit4_root3_inv = gf4096_inv(bit4_root3); | ||
1294 | find_4bit_err_pats(chk_syndrome_list[0], | ||
1295 | chk_syndrome_list[1], | ||
1296 | chk_syndrome_list[2], | ||
1297 | chk_syndrome_list[3], | ||
1298 | bit4_root0_inv, bit4_root1_inv, bit4_root2_inv, bit4_root3_inv, err_pats); | ||
1299 | err_info[0] = 0x4; | ||
1300 | err_info[1] = (0x55e - err_pos(bit4_root0_inv)); | ||
1301 | err_info[2] = (0x55e - err_pos(bit4_root1_inv)); | ||
1302 | err_info[3] = (0x55e - err_pos(bit4_root2_inv)); | ||
1303 | err_info[4] = (0x55e - err_pos(bit4_root3_inv)); | ||
1304 | err_info[5] = err_pats[0]; | ||
1305 | err_info[6] = err_pats[1]; | ||
1306 | err_info[7] = err_pats[2]; | ||
1307 | err_info[8] = err_pats[3]; | ||
1308 | return 0; | ||
1309 | } | ||
1310 | } | ||
1311 | |||
1312 | void correct_12bit_symbol(unsigned char *buf, unsigned short sym, | ||
1313 | unsigned short val) | ||
1314 | { | ||
1315 | if (unlikely(sym > 1366)) { | ||
1316 | printk(KERN_ERR "Error: symbol %d out of range; cannot correct\n", sym); | ||
1317 | } else if (sym == 0) { | ||
1318 | buf[0] ^= val; | ||
1319 | } else if (sym & 1) { | ||
1320 | buf[1+(3*(sym-1))/2] ^= (val >> 4); | ||
1321 | buf[2+(3*(sym-1))/2] ^= ((val & 0xf) << 4); | ||
1322 | } else { | ||
1323 | buf[2+(3*(sym-2))/2] ^= (val >> 8); | ||
1324 | buf[3+(3*(sym-2))/2] ^= (val & 0xff); | ||
1325 | } | ||
1326 | } | ||
1327 | |||
1328 | static int debugecc = 0; | ||
1329 | module_param(debugecc, int, 0644); | ||
1330 | |||
1331 | int cafe_correct_ecc(unsigned char *buf, | ||
1332 | unsigned short *chk_syndrome_list) | ||
1333 | { | ||
1334 | unsigned short err_info[9]; | ||
1335 | int i; | ||
1336 | |||
1337 | if (debugecc) { | ||
1338 | printk(KERN_WARNING "cafe_correct_ecc invoked. Syndromes %x %x %x %x %x %x %x %x\n", | ||
1339 | chk_syndrome_list[0], chk_syndrome_list[1], | ||
1340 | chk_syndrome_list[2], chk_syndrome_list[3], | ||
1341 | chk_syndrome_list[4], chk_syndrome_list[5], | ||
1342 | chk_syndrome_list[6], chk_syndrome_list[7]); | ||
1343 | for (i=0; i < 2048; i+=16) { | ||
1344 | printk(KERN_WARNING "D %04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
1345 | i, | ||
1346 | buf[i], buf[i+1], buf[i+2], buf[i+3], | ||
1347 | buf[i+4], buf[i+5], buf[i+6], buf[i+7], | ||
1348 | buf[i+8], buf[i+9], buf[i+10], buf[i+11], | ||
1349 | buf[i+12], buf[i+13], buf[i+14], buf[i+15]); | ||
1350 | } | ||
1351 | for ( ; i < 2112; i+=16) { | ||
1352 | printk(KERN_WARNING "O %02x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
1353 | i - 2048, | ||
1354 | buf[i], buf[i+1], buf[i+2], buf[i+3], | ||
1355 | buf[i+4], buf[i+5], buf[i+6], buf[i+7], | ||
1356 | buf[i+8], buf[i+9], buf[i+10], buf[i+11], | ||
1357 | buf[i+12], buf[i+13], buf[i+14], buf[i+15]); | ||
1358 | } | ||
1359 | } | ||
1360 | |||
1361 | |||
1362 | |||
1363 | if (chk_no_err_only(chk_syndrome_list, err_info) && | ||
1364 | chk_1_err_only(chk_syndrome_list, err_info) && | ||
1365 | chk_2_err_only(chk_syndrome_list, err_info) && | ||
1366 | chk_3_err_only(chk_syndrome_list, err_info) && | ||
1367 | chk_4_err_only(chk_syndrome_list, err_info)) { | ||
1368 | return -EIO; | ||
1369 | } | ||
1370 | |||
1371 | for (i=0; i < err_info[0]; i++) { | ||
1372 | if (debugecc) | ||
1373 | printk(KERN_WARNING "Correct symbol %d with 0x%03x\n", | ||
1374 | err_info[1+i], err_info[5+i]); | ||
1375 | |||
1376 | correct_12bit_symbol(buf, err_info[1+i], err_info[5+i]); | ||
1377 | } | ||
1378 | |||
1379 | return err_info[0]; | ||
1380 | } | ||
1381 | |||
diff --git a/drivers/mtd/nand/cafe.c b/drivers/mtd/nand/cafe_nand.c index c328a7514510..cff969d05d4a 100644 --- a/drivers/mtd/nand/cafe.c +++ b/drivers/mtd/nand/cafe_nand.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #undef DEBUG | 11 | #undef DEBUG |
12 | #include <linux/mtd/mtd.h> | 12 | #include <linux/mtd/mtd.h> |
13 | #include <linux/mtd/nand.h> | 13 | #include <linux/mtd/nand.h> |
14 | #include <linux/rslib.h> | ||
14 | #include <linux/pci.h> | 15 | #include <linux/pci.h> |
15 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
16 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
@@ -46,13 +47,14 @@ | |||
46 | #define CAFE_GLOBAL_IRQ_MASK 0x300c | 47 | #define CAFE_GLOBAL_IRQ_MASK 0x300c |
47 | #define CAFE_NAND_RESET 0x3034 | 48 | #define CAFE_NAND_RESET 0x3034 |
48 | 49 | ||
49 | int cafe_correct_ecc(unsigned char *buf, | 50 | /* Missing from the datasheet: bit 19 of CTRL1 sets CE0 vs. CE1 */ |
50 | unsigned short *chk_syndrome_list); | 51 | #define CTRL1_CHIPSELECT (1<<19) |
51 | 52 | ||
52 | struct cafe_priv { | 53 | struct cafe_priv { |
53 | struct nand_chip nand; | 54 | struct nand_chip nand; |
54 | struct pci_dev *pdev; | 55 | struct pci_dev *pdev; |
55 | void __iomem *mmio; | 56 | void __iomem *mmio; |
57 | struct rs_control *rs; | ||
56 | uint32_t ctl1; | 58 | uint32_t ctl1; |
57 | uint32_t ctl2; | 59 | uint32_t ctl2; |
58 | int datalen; | 60 | int datalen; |
@@ -195,8 +197,8 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, | |||
195 | 197 | ||
196 | cafe->data_pos = cafe->datalen = 0; | 198 | cafe->data_pos = cafe->datalen = 0; |
197 | 199 | ||
198 | /* Set command valid bit */ | 200 | /* Set command valid bit, mask in the chip select bit */ |
199 | ctl1 = 0x80000000 | command; | 201 | ctl1 = 0x80000000 | command | (cafe->ctl1 & CTRL1_CHIPSELECT); |
200 | 202 | ||
201 | /* Set RD or WR bits as appropriate */ | 203 | /* Set RD or WR bits as appropriate */ |
202 | if (command == NAND_CMD_READID || command == NAND_CMD_STATUS) { | 204 | if (command == NAND_CMD_READID || command == NAND_CMD_STATUS) { |
@@ -309,8 +311,16 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, | |||
309 | 311 | ||
310 | static void cafe_select_chip(struct mtd_info *mtd, int chipnr) | 312 | static void cafe_select_chip(struct mtd_info *mtd, int chipnr) |
311 | { | 313 | { |
312 | //struct cafe_priv *cafe = mtd->priv; | 314 | struct cafe_priv *cafe = mtd->priv; |
313 | // cafe_dev_dbg(&cafe->pdev->dev, "select_chip %d\n", chipnr); | 315 | |
316 | cafe_dev_dbg(&cafe->pdev->dev, "select_chip %d\n", chipnr); | ||
317 | |||
318 | /* Mask the appropriate bit into the stored value of ctl1 | ||
319 | which will be used by cafe_nand_cmdfunc() */ | ||
320 | if (chipnr) | ||
321 | cafe->ctl1 |= CTRL1_CHIPSELECT; | ||
322 | else | ||
323 | cafe->ctl1 &= ~CTRL1_CHIPSELECT; | ||
314 | } | 324 | } |
315 | 325 | ||
316 | static int cafe_nand_interrupt(int irq, void *id) | 326 | static int cafe_nand_interrupt(int irq, void *id) |
@@ -374,28 +384,66 @@ static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
374 | chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); | 384 | chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); |
375 | 385 | ||
376 | if (checkecc && cafe_readl(cafe, NAND_ECC_RESULT) & (1<<18)) { | 386 | if (checkecc && cafe_readl(cafe, NAND_ECC_RESULT) & (1<<18)) { |
377 | unsigned short syn[8]; | 387 | unsigned short syn[8], pat[4]; |
378 | int i; | 388 | int pos[4]; |
389 | u8 *oob = chip->oob_poi; | ||
390 | int i, n; | ||
379 | 391 | ||
380 | for (i=0; i<8; i+=2) { | 392 | for (i=0; i<8; i+=2) { |
381 | uint32_t tmp = cafe_readl(cafe, NAND_ECC_SYN01 + (i*2)); | 393 | uint32_t tmp = cafe_readl(cafe, NAND_ECC_SYN01 + (i*2)); |
382 | syn[i] = tmp & 0xfff; | 394 | syn[i] = cafe->rs->index_of[tmp & 0xfff]; |
383 | syn[i+1] = (tmp >> 16) & 0xfff; | 395 | syn[i+1] = cafe->rs->index_of[(tmp >> 16) & 0xfff]; |
396 | } | ||
397 | |||
398 | n = decode_rs16(cafe->rs, NULL, NULL, 1367, syn, 0, pos, 0, | ||
399 | pat); | ||
400 | |||
401 | for (i = 0; i < n; i++) { | ||
402 | int p = pos[i]; | ||
403 | |||
404 | /* The 12-bit symbols are mapped to bytes here */ | ||
405 | |||
406 | if (p > 1374) { | ||
407 | /* out of range */ | ||
408 | n = -1374; | ||
409 | } else if (p == 0) { | ||
410 | /* high four bits do not correspond to data */ | ||
411 | if (pat[i] > 0xff) | ||
412 | n = -2048; | ||
413 | else | ||
414 | buf[0] ^= pat[i]; | ||
415 | } else if (p == 1365) { | ||
416 | buf[2047] ^= pat[i] >> 4; | ||
417 | oob[0] ^= pat[i] << 4; | ||
418 | } else if (p > 1365) { | ||
419 | if ((p & 1) == 1) { | ||
420 | oob[3*p/2 - 2048] ^= pat[i] >> 4; | ||
421 | oob[3*p/2 - 2047] ^= pat[i] << 4; | ||
422 | } else { | ||
423 | oob[3*p/2 - 2049] ^= pat[i] >> 8; | ||
424 | oob[3*p/2 - 2048] ^= pat[i]; | ||
425 | } | ||
426 | } else if ((p & 1) == 1) { | ||
427 | buf[3*p/2] ^= pat[i] >> 4; | ||
428 | buf[3*p/2 + 1] ^= pat[i] << 4; | ||
429 | } else { | ||
430 | buf[3*p/2 - 1] ^= pat[i] >> 8; | ||
431 | buf[3*p/2] ^= pat[i]; | ||
432 | } | ||
384 | } | 433 | } |
385 | 434 | ||
386 | if ((i = cafe_correct_ecc(buf, syn)) < 0) { | 435 | if (n < 0) { |
387 | dev_dbg(&cafe->pdev->dev, "Failed to correct ECC at %08x\n", | 436 | dev_dbg(&cafe->pdev->dev, "Failed to correct ECC at %08x\n", |
388 | cafe_readl(cafe, NAND_ADDR2) * 2048); | 437 | cafe_readl(cafe, NAND_ADDR2) * 2048); |
389 | for (i=0; i< 0x5c; i+=4) | 438 | for (i = 0; i < 0x5c; i += 4) |
390 | printk("Register %x: %08x\n", i, readl(cafe->mmio + i)); | 439 | printk("Register %x: %08x\n", i, readl(cafe->mmio + i)); |
391 | mtd->ecc_stats.failed++; | 440 | mtd->ecc_stats.failed++; |
392 | } else { | 441 | } else { |
393 | dev_dbg(&cafe->pdev->dev, "Corrected %d symbol errors\n", i); | 442 | dev_dbg(&cafe->pdev->dev, "Corrected %d symbol errors\n", n); |
394 | mtd->ecc_stats.corrected += i; | 443 | mtd->ecc_stats.corrected += n; |
395 | } | 444 | } |
396 | } | 445 | } |
397 | 446 | ||
398 | |||
399 | return 0; | 447 | return 0; |
400 | } | 448 | } |
401 | 449 | ||
@@ -416,7 +464,7 @@ static uint8_t cafe_mirror_pattern_512[] = { 0xBC }; | |||
416 | 464 | ||
417 | static struct nand_bbt_descr cafe_bbt_main_descr_2048 = { | 465 | static struct nand_bbt_descr cafe_bbt_main_descr_2048 = { |
418 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | 466 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
419 | | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, | 467 | | NAND_BBT_2BIT | NAND_BBT_VERSION, |
420 | .offs = 14, | 468 | .offs = 14, |
421 | .len = 4, | 469 | .len = 4, |
422 | .veroffs = 18, | 470 | .veroffs = 18, |
@@ -426,7 +474,7 @@ static struct nand_bbt_descr cafe_bbt_main_descr_2048 = { | |||
426 | 474 | ||
427 | static struct nand_bbt_descr cafe_bbt_mirror_descr_2048 = { | 475 | static struct nand_bbt_descr cafe_bbt_mirror_descr_2048 = { |
428 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | 476 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
429 | | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, | 477 | | NAND_BBT_2BIT | NAND_BBT_VERSION, |
430 | .offs = 14, | 478 | .offs = 14, |
431 | .len = 4, | 479 | .len = 4, |
432 | .veroffs = 18, | 480 | .veroffs = 18, |
@@ -442,7 +490,7 @@ static struct nand_ecclayout cafe_oobinfo_512 = { | |||
442 | 490 | ||
443 | static struct nand_bbt_descr cafe_bbt_main_descr_512 = { | 491 | static struct nand_bbt_descr cafe_bbt_main_descr_512 = { |
444 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | 492 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
445 | | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, | 493 | | NAND_BBT_2BIT | NAND_BBT_VERSION, |
446 | .offs = 14, | 494 | .offs = 14, |
447 | .len = 1, | 495 | .len = 1, |
448 | .veroffs = 15, | 496 | .veroffs = 15, |
@@ -452,7 +500,7 @@ static struct nand_bbt_descr cafe_bbt_main_descr_512 = { | |||
452 | 500 | ||
453 | static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = { | 501 | static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = { |
454 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | 502 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
455 | | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, | 503 | | NAND_BBT_2BIT | NAND_BBT_VERSION, |
456 | .offs = 14, | 504 | .offs = 14, |
457 | .len = 1, | 505 | .len = 1, |
458 | .veroffs = 15, | 506 | .veroffs = 15, |
@@ -525,6 +573,48 @@ static int cafe_nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
525 | return 0; | 573 | return 0; |
526 | } | 574 | } |
527 | 575 | ||
576 | /* F_2[X]/(X**6+X+1) */ | ||
577 | static unsigned short __devinit gf64_mul(u8 a, u8 b) | ||
578 | { | ||
579 | u8 c; | ||
580 | unsigned int i; | ||
581 | |||
582 | c = 0; | ||
583 | for (i = 0; i < 6; i++) { | ||
584 | if (a & 1) | ||
585 | c ^= b; | ||
586 | a >>= 1; | ||
587 | b <<= 1; | ||
588 | if ((b & 0x40) != 0) | ||
589 | b ^= 0x43; | ||
590 | } | ||
591 | |||
592 | return c; | ||
593 | } | ||
594 | |||
595 | /* F_64[X]/(X**2+X+A**-1) with A the generator of F_64[X] */ | ||
596 | static u16 __devinit gf4096_mul(u16 a, u16 b) | ||
597 | { | ||
598 | u8 ah, al, bh, bl, ch, cl; | ||
599 | |||
600 | ah = a >> 6; | ||
601 | al = a & 0x3f; | ||
602 | bh = b >> 6; | ||
603 | bl = b & 0x3f; | ||
604 | |||
605 | ch = gf64_mul(ah ^ al, bh ^ bl) ^ gf64_mul(al, bl); | ||
606 | cl = gf64_mul(gf64_mul(ah, bh), 0x21) ^ gf64_mul(al, bl); | ||
607 | |||
608 | return (ch << 6) ^ cl; | ||
609 | } | ||
610 | |||
611 | static int __devinit cafe_mul(int x) | ||
612 | { | ||
613 | if (x == 0) | ||
614 | return 1; | ||
615 | return gf4096_mul(x, 0xe01); | ||
616 | } | ||
617 | |||
528 | static int __devinit cafe_nand_probe(struct pci_dev *pdev, | 618 | static int __devinit cafe_nand_probe(struct pci_dev *pdev, |
529 | const struct pci_device_id *ent) | 619 | const struct pci_device_id *ent) |
530 | { | 620 | { |
@@ -564,6 +654,12 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev, | |||
564 | } | 654 | } |
565 | cafe->nand.buffers = (void *)cafe->dmabuf + 2112; | 655 | cafe->nand.buffers = (void *)cafe->dmabuf + 2112; |
566 | 656 | ||
657 | cafe->rs = init_rs_non_canonical(12, &cafe_mul, 0, 1, 8); | ||
658 | if (!cafe->rs) { | ||
659 | err = -ENOMEM; | ||
660 | goto out_ior; | ||
661 | } | ||
662 | |||
567 | cafe->nand.cmdfunc = cafe_nand_cmdfunc; | 663 | cafe->nand.cmdfunc = cafe_nand_cmdfunc; |
568 | cafe->nand.dev_ready = cafe_device_ready; | 664 | cafe->nand.dev_ready = cafe_device_ready; |
569 | cafe->nand.read_byte = cafe_read_byte; | 665 | cafe->nand.read_byte = cafe_read_byte; |
@@ -646,7 +742,7 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev, | |||
646 | cafe_readl(cafe, GLOBAL_CTRL), cafe_readl(cafe, GLOBAL_IRQ_MASK)); | 742 | cafe_readl(cafe, GLOBAL_CTRL), cafe_readl(cafe, GLOBAL_IRQ_MASK)); |
647 | 743 | ||
648 | /* Scan to find existence of the device */ | 744 | /* Scan to find existence of the device */ |
649 | if (nand_scan_ident(mtd, 1)) { | 745 | if (nand_scan_ident(mtd, 2)) { |
650 | err = -ENXIO; | 746 | err = -ENXIO; |
651 | goto out_irq; | 747 | goto out_irq; |
652 | } | 748 | } |
@@ -713,6 +809,7 @@ static void __devexit cafe_nand_remove(struct pci_dev *pdev) | |||
713 | cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK); | 809 | cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK); |
714 | free_irq(pdev->irq, mtd); | 810 | free_irq(pdev->irq, mtd); |
715 | nand_release(mtd); | 811 | nand_release(mtd); |
812 | free_rs(cafe->rs); | ||
716 | pci_iounmap(pdev, cafe->mmio); | 813 | pci_iounmap(pdev, cafe->mmio); |
717 | dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); | 814 | dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); |
718 | kfree(mtd); | 815 | kfree(mtd); |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 04de315e4937..7e68203fe1ba 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -303,28 +303,27 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
303 | struct nand_chip *chip = mtd->priv; | 303 | struct nand_chip *chip = mtd->priv; |
304 | u16 bad; | 304 | u16 bad; |
305 | 305 | ||
306 | page = (int)(ofs >> chip->page_shift) & chip->pagemask; | ||
307 | |||
306 | if (getchip) { | 308 | if (getchip) { |
307 | page = (int)(ofs >> chip->page_shift); | ||
308 | chipnr = (int)(ofs >> chip->chip_shift); | 309 | chipnr = (int)(ofs >> chip->chip_shift); |
309 | 310 | ||
310 | nand_get_device(chip, mtd, FL_READING); | 311 | nand_get_device(chip, mtd, FL_READING); |
311 | 312 | ||
312 | /* Select the NAND device */ | 313 | /* Select the NAND device */ |
313 | chip->select_chip(mtd, chipnr); | 314 | chip->select_chip(mtd, chipnr); |
314 | } else | 315 | } |
315 | page = (int)(ofs >> chip->page_shift); | ||
316 | 316 | ||
317 | if (chip->options & NAND_BUSWIDTH_16) { | 317 | if (chip->options & NAND_BUSWIDTH_16) { |
318 | chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE, | 318 | chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE, |
319 | page & chip->pagemask); | 319 | page); |
320 | bad = cpu_to_le16(chip->read_word(mtd)); | 320 | bad = cpu_to_le16(chip->read_word(mtd)); |
321 | if (chip->badblockpos & 0x1) | 321 | if (chip->badblockpos & 0x1) |
322 | bad >>= 8; | 322 | bad >>= 8; |
323 | if ((bad & 0xFF) != 0xff) | 323 | if ((bad & 0xFF) != 0xff) |
324 | res = 1; | 324 | res = 1; |
325 | } else { | 325 | } else { |
326 | chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, | 326 | chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page); |
327 | page & chip->pagemask); | ||
328 | if (chip->read_byte(mtd) != 0xff) | 327 | if (chip->read_byte(mtd) != 0xff) |
329 | res = 1; | 328 | res = 1; |
330 | } | 329 | } |
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c new file mode 100644 index 000000000000..cd725fc5e813 --- /dev/null +++ b/drivers/mtd/nand/plat_nand.c | |||
@@ -0,0 +1,150 @@ | |||
1 | /* | ||
2 | * Generic NAND driver | ||
3 | * | ||
4 | * Author: Vitaly Wool <vitalywool@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/io.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/slab.h> | ||
16 | #include <linux/mtd/mtd.h> | ||
17 | #include <linux/mtd/nand.h> | ||
18 | #include <linux/mtd/partitions.h> | ||
19 | |||
20 | struct plat_nand_data { | ||
21 | struct nand_chip chip; | ||
22 | struct mtd_info mtd; | ||
23 | void __iomem *io_base; | ||
24 | #ifdef CONFIG_MTD_PARTITIONS | ||
25 | int nr_parts; | ||
26 | struct mtd_partition *parts; | ||
27 | #endif | ||
28 | }; | ||
29 | |||
30 | /* | ||
31 | * Probe for the NAND device. | ||
32 | */ | ||
33 | static int __init plat_nand_probe(struct platform_device *pdev) | ||
34 | { | ||
35 | struct platform_nand_data *pdata = pdev->dev.platform_data; | ||
36 | struct plat_nand_data *data; | ||
37 | int res = 0; | ||
38 | |||
39 | /* Allocate memory for the device structure (and zero it) */ | ||
40 | data = kzalloc(sizeof(struct plat_nand_data), GFP_KERNEL); | ||
41 | if (!data) { | ||
42 | dev_err(&pdev->dev, "failed to allocate device structure.\n"); | ||
43 | return -ENOMEM; | ||
44 | } | ||
45 | |||
46 | data->io_base = ioremap(pdev->resource[0].start, | ||
47 | pdev->resource[0].end - pdev->resource[0].start + 1); | ||
48 | if (data->io_base == NULL) { | ||
49 | dev_err(&pdev->dev, "ioremap failed\n"); | ||
50 | kfree(data); | ||
51 | return -EIO; | ||
52 | } | ||
53 | |||
54 | data->chip.priv = &data; | ||
55 | data->mtd.priv = &data->chip; | ||
56 | data->mtd.owner = THIS_MODULE; | ||
57 | |||
58 | data->chip.IO_ADDR_R = data->io_base; | ||
59 | data->chip.IO_ADDR_W = data->io_base; | ||
60 | data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl; | ||
61 | data->chip.dev_ready = pdata->ctrl.dev_ready; | ||
62 | data->chip.select_chip = pdata->ctrl.select_chip; | ||
63 | data->chip.chip_delay = pdata->chip.chip_delay; | ||
64 | data->chip.options |= pdata->chip.options; | ||
65 | |||
66 | data->chip.ecc.hwctl = pdata->ctrl.hwcontrol; | ||
67 | data->chip.ecc.layout = pdata->chip.ecclayout; | ||
68 | data->chip.ecc.mode = NAND_ECC_SOFT; | ||
69 | |||
70 | platform_set_drvdata(pdev, data); | ||
71 | |||
72 | /* Scan to find existance of the device */ | ||
73 | if (nand_scan(&data->mtd, 1)) { | ||
74 | res = -ENXIO; | ||
75 | goto out; | ||
76 | } | ||
77 | |||
78 | #ifdef CONFIG_MTD_PARTITIONS | ||
79 | if (pdata->chip.part_probe_types) { | ||
80 | res = parse_mtd_partitions(&data->mtd, | ||
81 | pdata->chip.part_probe_types, | ||
82 | &data->parts, 0); | ||
83 | if (res > 0) { | ||
84 | add_mtd_partitions(&data->mtd, data->parts, res); | ||
85 | return 0; | ||
86 | } | ||
87 | } | ||
88 | if (pdata->chip.partitions) { | ||
89 | data->parts = pdata->chip.partitions; | ||
90 | res = add_mtd_partitions(&data->mtd, data->parts, | ||
91 | pdata->chip.nr_partitions); | ||
92 | } else | ||
93 | #endif | ||
94 | res = add_mtd_device(&data->mtd); | ||
95 | |||
96 | if (!res) | ||
97 | return res; | ||
98 | |||
99 | nand_release(&data->mtd); | ||
100 | out: | ||
101 | platform_set_drvdata(pdev, NULL); | ||
102 | iounmap(data->io_base); | ||
103 | kfree(data); | ||
104 | return res; | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * Remove a NAND device. | ||
109 | */ | ||
110 | static int __devexit plat_nand_remove(struct platform_device *pdev) | ||
111 | { | ||
112 | struct plat_nand_data *data = platform_get_drvdata(pdev); | ||
113 | struct platform_nand_data *pdata = pdev->dev.platform_data; | ||
114 | |||
115 | nand_release(&data->mtd); | ||
116 | #ifdef CONFIG_MTD_PARTITIONS | ||
117 | if (data->parts && data->parts != pdata->chip.partitions) | ||
118 | kfree(data->parts); | ||
119 | #endif | ||
120 | iounmap(data->io_base); | ||
121 | kfree(data); | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | static struct platform_driver plat_nand_driver = { | ||
127 | .probe = plat_nand_probe, | ||
128 | .remove = plat_nand_remove, | ||
129 | .driver = { | ||
130 | .name = "gen_nand", | ||
131 | .owner = THIS_MODULE, | ||
132 | }, | ||
133 | }; | ||
134 | |||
135 | static int __init plat_nand_init(void) | ||
136 | { | ||
137 | return platform_driver_register(&plat_nand_driver); | ||
138 | } | ||
139 | |||
140 | static void __exit plat_nand_exit(void) | ||
141 | { | ||
142 | platform_driver_unregister(&plat_nand_driver); | ||
143 | } | ||
144 | |||
145 | module_init(plat_nand_init); | ||
146 | module_exit(plat_nand_exit); | ||
147 | |||
148 | MODULE_LICENSE("GPL"); | ||
149 | MODULE_AUTHOR("Vitaly Wool"); | ||
150 | MODULE_DESCRIPTION("Simple generic NAND driver"); | ||
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 000794c6caf5..0537fac8de74 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -2192,7 +2192,7 @@ static int onenand_check_maf(int manuf) | |||
2192 | * @param mtd MTD device structure | 2192 | * @param mtd MTD device structure |
2193 | * | 2193 | * |
2194 | * OneNAND detection method: | 2194 | * OneNAND detection method: |
2195 | * Compare the the values from command with ones from register | 2195 | * Compare the values from command with ones from register |
2196 | */ | 2196 | */ |
2197 | static int onenand_probe(struct mtd_info *mtd) | 2197 | static int onenand_probe(struct mtd_info *mtd) |
2198 | { | 2198 | { |
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c index 9588da3a30e7..127f60841b10 100644 --- a/drivers/net/3c509.c +++ b/drivers/net/3c509.c | |||
@@ -95,8 +95,7 @@ static int max_interrupt_work = 10; | |||
95 | #include <asm/io.h> | 95 | #include <asm/io.h> |
96 | #include <asm/irq.h> | 96 | #include <asm/irq.h> |
97 | 97 | ||
98 | static char versionA[] __initdata = DRV_NAME ".c:" DRV_VERSION " " DRV_RELDATE " becker@scyld.com\n"; | 98 | static char version[] __initdata = DRV_NAME ".c:" DRV_VERSION " " DRV_RELDATE " becker@scyld.com\n"; |
99 | static char versionB[] __initdata = "http://www.scyld.com/network/3c509.html\n"; | ||
100 | 99 | ||
101 | #if defined(CONFIG_PM) && (defined(CONFIG_MCA) || defined(CONFIG_EISA)) | 100 | #if defined(CONFIG_PM) && (defined(CONFIG_MCA) || defined(CONFIG_EISA)) |
102 | #define EL3_SUSPEND | 101 | #define EL3_SUSPEND |
@@ -360,7 +359,7 @@ static int __init el3_common_init(struct net_device *dev) | |||
360 | printk(", IRQ %d.\n", dev->irq); | 359 | printk(", IRQ %d.\n", dev->irq); |
361 | 360 | ||
362 | if (el3_debug > 0) | 361 | if (el3_debug > 0) |
363 | printk(KERN_INFO "%s" KERN_INFO "%s", versionA, versionB); | 362 | printk(KERN_INFO "%s", version); |
364 | return 0; | 363 | return 0; |
365 | 364 | ||
366 | } | 365 | } |
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 80924f76dee8..f26ca331615e 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c | |||
@@ -103,7 +103,7 @@ static int vortex_debug = 1; | |||
103 | 103 | ||
104 | 104 | ||
105 | static char version[] __devinitdata = | 105 | static char version[] __devinitdata = |
106 | DRV_NAME ": Donald Becker and others. www.scyld.com/network/vortex.html\n"; | 106 | DRV_NAME ": Donald Becker and others.\n"; |
107 | 107 | ||
108 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); | 108 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); |
109 | MODULE_DESCRIPTION("3Com 3c59x/3c9xx ethernet driver "); | 109 | MODULE_DESCRIPTION("3Com 3c59x/3c9xx ethernet driver "); |
diff --git a/drivers/net/atp.c b/drivers/net/atp.c index 18aba838c1ff..82d78ff8399b 100644 --- a/drivers/net/atp.c +++ b/drivers/net/atp.c | |||
@@ -31,10 +31,8 @@ | |||
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | static const char versionA[] = | 34 | static const char version[] = |
35 | "atp.c:v1.09=ac 2002/10/01 Donald Becker <becker@scyld.com>\n"; | 35 | "atp.c:v1.09=ac 2002/10/01 Donald Becker <becker@scyld.com>\n"; |
36 | static const char versionB[] = | ||
37 | " http://www.scyld.com/network/atp.html\n"; | ||
38 | 36 | ||
39 | /* The user-configurable values. | 37 | /* The user-configurable values. |
40 | These may be modified when a driver module is loaded.*/ | 38 | These may be modified when a driver module is loaded.*/ |
@@ -324,7 +322,7 @@ static int __init atp_probe1(long ioaddr) | |||
324 | 322 | ||
325 | #ifndef MODULE | 323 | #ifndef MODULE |
326 | if (net_debug) | 324 | if (net_debug) |
327 | printk(KERN_INFO "%s" KERN_INFO "%s", versionA, versionB); | 325 | printk(KERN_INFO "%s", version); |
328 | #endif | 326 | #endif |
329 | 327 | ||
330 | printk(KERN_NOTICE "%s: Pocket adapter found at %#3lx, IRQ %d, SAPROM " | 328 | printk(KERN_NOTICE "%s: Pocket adapter found at %#3lx, IRQ %d, SAPROM " |
@@ -926,7 +924,7 @@ static void set_rx_mode_8012(struct net_device *dev) | |||
926 | 924 | ||
927 | static int __init atp_init_module(void) { | 925 | static int __init atp_init_module(void) { |
928 | if (debug) /* Emit version even if no cards detected. */ | 926 | if (debug) /* Emit version even if no cards detected. */ |
929 | printk(KERN_INFO "%s" KERN_INFO "%s", versionA, versionB); | 927 | printk(KERN_INFO "%s", version); |
930 | return atp_init(); | 928 | return atp_init(); |
931 | } | 929 | } |
932 | 930 | ||
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 724bce51f936..223517dcbcfd 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -3461,7 +3461,7 @@ void bond_unregister_arp(struct bonding *bond) | |||
3461 | /*---------------------------- Hashing Policies -----------------------------*/ | 3461 | /*---------------------------- Hashing Policies -----------------------------*/ |
3462 | 3462 | ||
3463 | /* | 3463 | /* |
3464 | * Hash for the the output device based upon layer 3 and layer 4 data. If | 3464 | * Hash for the output device based upon layer 3 and layer 4 data. If |
3465 | * the packet is a frag or not TCP or UDP, just use layer 3 data. If it is | 3465 | * the packet is a frag or not TCP or UDP, just use layer 3 data. If it is |
3466 | * altogether not IP, mimic bond_xmit_hash_policy_l2() | 3466 | * altogether not IP, mimic bond_xmit_hash_policy_l2() |
3467 | */ | 3467 | */ |
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index 3a03a74c0609..637ae8f68791 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -1214,7 +1214,7 @@ e1000_remove(struct pci_dev *pdev) | |||
1214 | int i; | 1214 | int i; |
1215 | #endif | 1215 | #endif |
1216 | 1216 | ||
1217 | flush_scheduled_work(); | 1217 | cancel_work_sync(&adapter->reset_task); |
1218 | 1218 | ||
1219 | e1000_release_manageability(adapter); | 1219 | e1000_release_manageability(adapter); |
1220 | 1220 | ||
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c index 39654e1e2bed..47680237f783 100644 --- a/drivers/net/eepro.c +++ b/drivers/net/eepro.c | |||
@@ -1126,7 +1126,7 @@ static void eepro_tx_timeout (struct net_device *dev) | |||
1126 | printk (KERN_ERR "%s: transmit timed out, %s?\n", dev->name, | 1126 | printk (KERN_ERR "%s: transmit timed out, %s?\n", dev->name, |
1127 | "network cable problem"); | 1127 | "network cable problem"); |
1128 | /* This is not a duplicate. One message for the console, | 1128 | /* This is not a duplicate. One message for the console, |
1129 | one for the the log file */ | 1129 | one for the log file */ |
1130 | printk (KERN_DEBUG "%s: transmit timed out, %s?\n", dev->name, | 1130 | printk (KERN_DEBUG "%s: transmit timed out, %s?\n", dev->name, |
1131 | "network cable problem"); | 1131 | "network cable problem"); |
1132 | eepro_complete_selreset(ioaddr); | 1132 | eepro_complete_selreset(ioaddr); |
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 6c267c38df97..9800341956a2 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c | |||
@@ -28,7 +28,7 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | static const char * const version = | 30 | static const char * const version = |
31 | "eepro100.c:v1.09j-t 9/29/99 Donald Becker http://www.scyld.com/network/eepro100.html\n" | 31 | "eepro100.c:v1.09j-t 9/29/99 Donald Becker\n" |
32 | "eepro100.c: $Revision: 1.36 $ 2000/11/17 Modified by Andrey V. Savochkin <saw@saw.sw.com.sg> and others\n"; | 32 | "eepro100.c: $Revision: 1.36 $ 2000/11/17 Modified by Andrey V. Savochkin <saw@saw.sw.com.sg> and others\n"; |
33 | 33 | ||
34 | /* A few user-configurable values that apply to all boards. | 34 | /* A few user-configurable values that apply to all boards. |
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c index 4e3f14c9c717..5e517946f46a 100644 --- a/drivers/net/epic100.c +++ b/drivers/net/epic100.c | |||
@@ -93,8 +93,6 @@ static int rx_copybreak; | |||
93 | static char version[] __devinitdata = | 93 | static char version[] __devinitdata = |
94 | DRV_NAME ".c:v1.11 1/7/2001 Written by Donald Becker <becker@scyld.com>\n"; | 94 | DRV_NAME ".c:v1.11 1/7/2001 Written by Donald Becker <becker@scyld.com>\n"; |
95 | static char version2[] __devinitdata = | 95 | static char version2[] __devinitdata = |
96 | " http://www.scyld.com/network/epic100.html\n"; | ||
97 | static char version3[] __devinitdata = | ||
98 | " (unofficial 2.4.x kernel port, version " DRV_VERSION ", " DRV_RELDATE ")\n"; | 96 | " (unofficial 2.4.x kernel port, version " DRV_VERSION ", " DRV_RELDATE ")\n"; |
99 | 97 | ||
100 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); | 98 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); |
@@ -323,8 +321,8 @@ static int __devinit epic_init_one (struct pci_dev *pdev, | |||
323 | #ifndef MODULE | 321 | #ifndef MODULE |
324 | static int printed_version; | 322 | static int printed_version; |
325 | if (!printed_version++) | 323 | if (!printed_version++) |
326 | printk (KERN_INFO "%s" KERN_INFO "%s" KERN_INFO "%s", | 324 | printk (KERN_INFO "%s" KERN_INFO "%s", |
327 | version, version2, version3); | 325 | version, version2); |
328 | #endif | 326 | #endif |
329 | 327 | ||
330 | card_idx++; | 328 | card_idx++; |
@@ -1596,8 +1594,8 @@ static int __init epic_init (void) | |||
1596 | { | 1594 | { |
1597 | /* when a module, this is printed whether or not devices are found in probe */ | 1595 | /* when a module, this is printed whether or not devices are found in probe */ |
1598 | #ifdef MODULE | 1596 | #ifdef MODULE |
1599 | printk (KERN_INFO "%s" KERN_INFO "%s" KERN_INFO "%s", | 1597 | printk (KERN_INFO "%s" KERN_INFO "%s", |
1600 | version, version2, version3); | 1598 | version, version2); |
1601 | #endif | 1599 | #endif |
1602 | 1600 | ||
1603 | return pci_register_driver(&epic_driver); | 1601 | return pci_register_driver(&epic_driver); |
diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig index 6e90619b3b41..36d2c7d4f4d0 100644 --- a/drivers/net/hamradio/Kconfig +++ b/drivers/net/hamradio/Kconfig | |||
@@ -140,7 +140,7 @@ config BAYCOM_SER_HDX | |||
140 | modems that connect to a serial interface. The driver supports the | 140 | modems that connect to a serial interface. The driver supports the |
141 | ser12 design in half-duplex mode. This is the old driver. It is | 141 | ser12 design in half-duplex mode. This is the old driver. It is |
142 | still provided in case your serial interface chip does not work with | 142 | still provided in case your serial interface chip does not work with |
143 | the full-duplex driver. This driver is depreciated. To configure | 143 | the full-duplex driver. This driver is deprecated. To configure |
144 | the driver, use the sethdlc utility available in the standard ax25 | 144 | the driver, use the sethdlc utility available in the standard ax25 |
145 | utilities package. For information on the modems, see | 145 | utilities package. For information on the modems, see |
146 | <http://www.baycom.de/> and | 146 | <http://www.baycom.de/> and |
diff --git a/drivers/net/irda/donauboe.h b/drivers/net/irda/donauboe.h index 2ab173d9a0e4..1e67720f1066 100644 --- a/drivers/net/irda/donauboe.h +++ b/drivers/net/irda/donauboe.h | |||
@@ -113,7 +113,7 @@ | |||
113 | /* RxOver overflow in Recv FIFO */ | 113 | /* RxOver overflow in Recv FIFO */ |
114 | /* SipRcv received serial gap (or other condition you set) */ | 114 | /* SipRcv received serial gap (or other condition you set) */ |
115 | /* Interrupts are enabled by writing a one to the IER register */ | 115 | /* Interrupts are enabled by writing a one to the IER register */ |
116 | /* Interrupts are cleared by writting a one to the ISR register */ | 116 | /* Interrupts are cleared by writing a one to the ISR register */ |
117 | /* */ | 117 | /* */ |
118 | /* 6. The remaining registers: 0x6 and 0x3 appear to be */ | 118 | /* 6. The remaining registers: 0x6 and 0x3 appear to be */ |
119 | /* reserved parts of 16 or 32 bit registersthe remainder */ | 119 | /* reserved parts of 16 or 32 bit registersthe remainder */ |
diff --git a/drivers/net/ixgb/ixgb_ee.c b/drivers/net/ixgb/ixgb_ee.c index f15aebde7b90..52c99d01d568 100644 --- a/drivers/net/ixgb/ixgb_ee.c +++ b/drivers/net/ixgb/ixgb_ee.c | |||
@@ -315,7 +315,7 @@ ixgb_wait_eeprom_command(struct ixgb_hw *hw) | |||
315 | * hw - Struct containing variables accessed by shared code | 315 | * hw - Struct containing variables accessed by shared code |
316 | * | 316 | * |
317 | * Reads the first 64 16 bit words of the EEPROM and sums the values read. | 317 | * Reads the first 64 16 bit words of the EEPROM and sums the values read. |
318 | * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is | 318 | * If the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is |
319 | * valid. | 319 | * valid. |
320 | * | 320 | * |
321 | * Returns: | 321 | * Returns: |
diff --git a/drivers/net/meth.h b/drivers/net/meth.h index 84960dae2a22..ea3b8fc86d1e 100644 --- a/drivers/net/meth.h +++ b/drivers/net/meth.h | |||
@@ -126,7 +126,7 @@ typedef struct rx_packet { | |||
126 | /* Note: when loopback is set this bit becomes collision control. Setting this bit will */ | 126 | /* Note: when loopback is set this bit becomes collision control. Setting this bit will */ |
127 | /* cause a collision to be reported. */ | 127 | /* cause a collision to be reported. */ |
128 | 128 | ||
129 | /* Bits 5 and 6 are used to determine the the Destination address filter mode */ | 129 | /* Bits 5 and 6 are used to determine the Destination address filter mode */ |
130 | #define METH_ACCEPT_MY 0 /* 00: Accept PHY address only */ | 130 | #define METH_ACCEPT_MY 0 /* 00: Accept PHY address only */ |
131 | #define METH_ACCEPT_MCAST 0x20 /* 01: Accept physical, broadcast, and multicast filter matches only */ | 131 | #define METH_ACCEPT_MCAST 0x20 /* 01: Accept physical, broadcast, and multicast filter matches only */ |
132 | #define METH_ACCEPT_AMCAST 0x40 /* 10: Accept physical, broadcast, and all multicast packets */ | 132 | #define METH_ACCEPT_AMCAST 0x40 /* 10: Accept physical, broadcast, and all multicast packets */ |
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c index 223e0e6264ba..4cf0d3fcb519 100644 --- a/drivers/net/natsemi.c +++ b/drivers/net/natsemi.c | |||
@@ -131,7 +131,6 @@ static const char version[] __devinitdata = | |||
131 | KERN_INFO DRV_NAME " dp8381x driver, version " | 131 | KERN_INFO DRV_NAME " dp8381x driver, version " |
132 | DRV_VERSION ", " DRV_RELDATE "\n" | 132 | DRV_VERSION ", " DRV_RELDATE "\n" |
133 | KERN_INFO " originally by Donald Becker <becker@scyld.com>\n" | 133 | KERN_INFO " originally by Donald Becker <becker@scyld.com>\n" |
134 | KERN_INFO " http://www.scyld.com/network/natsemi.html\n" | ||
135 | KERN_INFO " 2.4.x kernel port by Jeff Garzik, Tjeerd Mulder\n"; | 134 | KERN_INFO " 2.4.x kernel port by Jeff Garzik, Tjeerd Mulder\n"; |
136 | 135 | ||
137 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); | 136 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); |
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c index 589785d1e762..995c0a5d4066 100644 --- a/drivers/net/ne2k-pci.c +++ b/drivers/net/ne2k-pci.c | |||
@@ -63,8 +63,7 @@ static int options[MAX_UNITS]; | |||
63 | 63 | ||
64 | /* These identify the driver base version and may not be removed. */ | 64 | /* These identify the driver base version and may not be removed. */ |
65 | static char version[] __devinitdata = | 65 | static char version[] __devinitdata = |
66 | KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " D. Becker/P. Gortmaker\n" | 66 | KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " D. Becker/P. Gortmaker\n"; |
67 | KERN_INFO " http://www.scyld.com/network/ne2k-pci.html\n"; | ||
68 | 67 | ||
69 | #if defined(__powerpc__) | 68 | #if defined(__powerpc__) |
70 | #define inl_le(addr) le32_to_cpu(inl(addr)) | 69 | #define inl_le(addr) le32_to_cpu(inl(addr)) |
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index eed433d6056a..f71dab347667 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
@@ -662,10 +662,10 @@ int phy_stop_interrupts(struct phy_device *phydev) | |||
662 | phy_error(phydev); | 662 | phy_error(phydev); |
663 | 663 | ||
664 | /* | 664 | /* |
665 | * Finish any pending work; we might have been scheduled | 665 | * Finish any pending work; we might have been scheduled to be called |
666 | * to be called from keventd ourselves, though. | 666 | * from keventd ourselves, but cancel_work_sync() handles that. |
667 | */ | 667 | */ |
668 | run_scheduled_work(&phydev->phy_queue); | 668 | cancel_work_sync(&phydev->phy_queue); |
669 | 669 | ||
670 | free_irq(phydev->irq, phydev); | 670 | free_irq(phydev->irq, phydev); |
671 | 671 | ||
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c index f51ba31970aa..e1f912d04043 100644 --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c | |||
@@ -110,8 +110,7 @@ static char *media[MAX_UNITS]; | |||
110 | 110 | ||
111 | /* These identify the driver base version and may not be removed. */ | 111 | /* These identify the driver base version and may not be removed. */ |
112 | static char version[] = | 112 | static char version[] = |
113 | KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Written by Donald Becker\n" | 113 | KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Written by Donald Becker\n"; |
114 | KERN_INFO " http://www.scyld.com/network/sundance.html\n"; | ||
115 | 114 | ||
116 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); | 115 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); |
117 | MODULE_DESCRIPTION("Sundance Alta Ethernet driver"); | 116 | MODULE_DESCRIPTION("Sundance Alta Ethernet driver"); |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index e5e901ecd808..923b9c725cc3 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -3716,10 +3716,8 @@ static void tg3_reset_task(struct work_struct *work) | |||
3716 | unsigned int restart_timer; | 3716 | unsigned int restart_timer; |
3717 | 3717 | ||
3718 | tg3_full_lock(tp, 0); | 3718 | tg3_full_lock(tp, 0); |
3719 | tp->tg3_flags |= TG3_FLAG_IN_RESET_TASK; | ||
3720 | 3719 | ||
3721 | if (!netif_running(tp->dev)) { | 3720 | if (!netif_running(tp->dev)) { |
3722 | tp->tg3_flags &= ~TG3_FLAG_IN_RESET_TASK; | ||
3723 | tg3_full_unlock(tp); | 3721 | tg3_full_unlock(tp); |
3724 | return; | 3722 | return; |
3725 | } | 3723 | } |
@@ -3750,8 +3748,6 @@ static void tg3_reset_task(struct work_struct *work) | |||
3750 | mod_timer(&tp->timer, jiffies + 1); | 3748 | mod_timer(&tp->timer, jiffies + 1); |
3751 | 3749 | ||
3752 | out: | 3750 | out: |
3753 | tp->tg3_flags &= ~TG3_FLAG_IN_RESET_TASK; | ||
3754 | |||
3755 | tg3_full_unlock(tp); | 3751 | tg3_full_unlock(tp); |
3756 | } | 3752 | } |
3757 | 3753 | ||
@@ -7390,12 +7386,7 @@ static int tg3_close(struct net_device *dev) | |||
7390 | { | 7386 | { |
7391 | struct tg3 *tp = netdev_priv(dev); | 7387 | struct tg3 *tp = netdev_priv(dev); |
7392 | 7388 | ||
7393 | /* Calling flush_scheduled_work() may deadlock because | 7389 | cancel_work_sync(&tp->reset_task); |
7394 | * linkwatch_event() may be on the workqueue and it will try to get | ||
7395 | * the rtnl_lock which we are holding. | ||
7396 | */ | ||
7397 | while (tp->tg3_flags & TG3_FLAG_IN_RESET_TASK) | ||
7398 | msleep(1); | ||
7399 | 7390 | ||
7400 | netif_stop_queue(dev); | 7391 | netif_stop_queue(dev); |
7401 | 7392 | ||
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 4d334cf5a243..bd9f4f428e5b 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -2228,7 +2228,7 @@ struct tg3 { | |||
2228 | #define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000 | 2228 | #define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000 |
2229 | #define TG3_FLAG_10_100_ONLY 0x01000000 | 2229 | #define TG3_FLAG_10_100_ONLY 0x01000000 |
2230 | #define TG3_FLAG_PAUSE_AUTONEG 0x02000000 | 2230 | #define TG3_FLAG_PAUSE_AUTONEG 0x02000000 |
2231 | #define TG3_FLAG_IN_RESET_TASK 0x04000000 | 2231 | |
2232 | #define TG3_FLAG_40BIT_DMA_BUG 0x08000000 | 2232 | #define TG3_FLAG_40BIT_DMA_BUG 0x08000000 |
2233 | #define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000 | 2233 | #define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000 |
2234 | #define TG3_FLAG_SUPPORT_MSI 0x20000000 | 2234 | #define TG3_FLAG_SUPPORT_MSI 0x20000000 |
diff --git a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c index 9b08afbd1f65..ea896777bcaf 100644 --- a/drivers/net/tulip/interrupt.c +++ b/drivers/net/tulip/interrupt.c | |||
@@ -269,7 +269,7 @@ done: | |||
269 | This would turn on IM for devices that is not contributing | 269 | This would turn on IM for devices that is not contributing |
270 | to backlog congestion with unnecessary latency. | 270 | to backlog congestion with unnecessary latency. |
271 | 271 | ||
272 | We monitor the the device RX-ring and have: | 272 | We monitor the device RX-ring and have: |
273 | 273 | ||
274 | HW Interrupt Mitigation either ON or OFF. | 274 | HW Interrupt Mitigation either ON or OFF. |
275 | 275 | ||
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c index fa440706fb4a..38f3b99716b8 100644 --- a/drivers/net/tulip/winbond-840.c +++ b/drivers/net/tulip/winbond-840.c | |||
@@ -1021,7 +1021,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1021 | np->tx_ring[entry].length |= DescEndRing; | 1021 | np->tx_ring[entry].length |= DescEndRing; |
1022 | 1022 | ||
1023 | /* Now acquire the irq spinlock. | 1023 | /* Now acquire the irq spinlock. |
1024 | * The difficult race is the the ordering between | 1024 | * The difficult race is the ordering between |
1025 | * increasing np->cur_tx and setting DescOwned: | 1025 | * increasing np->cur_tx and setting DescOwned: |
1026 | * - if np->cur_tx is increased first the interrupt | 1026 | * - if np->cur_tx is increased first the interrupt |
1027 | * handler could consider the packet as transmitted | 1027 | * handler could consider the packet as transmitted |
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c index 985a1810ca59..2470b1ee33c0 100644 --- a/drivers/net/tulip/xircom_cb.c +++ b/drivers/net/tulip/xircom_cb.c | |||
@@ -1043,7 +1043,7 @@ static int enable_promisc(struct xircom_private *card) | |||
1043 | 1043 | ||
1044 | 1044 | ||
1045 | /* | 1045 | /* |
1046 | link_status() checks the the links status and will return 0 for no link, 10 for 10mbit link and 100 for.. guess what. | 1046 | link_status() checks the links status and will return 0 for no link, 10 for 10mbit link and 100 for.. guess what. |
1047 | 1047 | ||
1048 | Must be called in locked state with interrupts disabled | 1048 | Must be called in locked state with interrupts disabled |
1049 | */ | 1049 | */ |
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c index f2dd7763cd0b..f72573594121 100644 --- a/drivers/net/typhoon.c +++ b/drivers/net/typhoon.c | |||
@@ -639,7 +639,7 @@ typhoon_issue_command(struct typhoon *tp, int num_cmd, struct cmd_desc *cmd, | |||
639 | 639 | ||
640 | typhoon_inc_cmd_index(&ring->lastWrite, num_cmd); | 640 | typhoon_inc_cmd_index(&ring->lastWrite, num_cmd); |
641 | 641 | ||
642 | /* "I feel a presence... another warrior is on the the mesa." | 642 | /* "I feel a presence... another warrior is on the mesa." |
643 | */ | 643 | */ |
644 | wmb(); | 644 | wmb(); |
645 | iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY); | 645 | iowrite32(ring->lastWrite, tp->ioaddr + TYPHOON_REG_CMD_READY); |
diff --git a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c index 38fac3bbcd82..7d5b8c2cc614 100644 --- a/drivers/net/wireless/airport.c +++ b/drivers/net/wireless/airport.c | |||
@@ -149,7 +149,7 @@ static int airport_hard_reset(struct orinoco_private *priv) | |||
149 | /* Vitally important. If we don't do this it seems we get an | 149 | /* Vitally important. If we don't do this it seems we get an |
150 | * interrupt somewhere during the power cycle, since | 150 | * interrupt somewhere during the power cycle, since |
151 | * hw_unavailable is already set it doesn't get ACKed, we get | 151 | * hw_unavailable is already set it doesn't get ACKed, we get |
152 | * into an interrupt loop and the the PMU decides to turn us | 152 | * into an interrupt loop and the PMU decides to turn us |
153 | * off. */ | 153 | * off. */ |
154 | disable_irq(dev->irq); | 154 | disable_irq(dev->irq); |
155 | 155 | ||
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index 841b3c136ad9..283be4a70524 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c | |||
@@ -3054,7 +3054,7 @@ static const iw_handler prism54_handler[] = { | |||
3054 | (iw_handler) prism54_set_wap, /* SIOCSIWAP */ | 3054 | (iw_handler) prism54_set_wap, /* SIOCSIWAP */ |
3055 | (iw_handler) prism54_get_wap, /* SIOCGIWAP */ | 3055 | (iw_handler) prism54_get_wap, /* SIOCGIWAP */ |
3056 | (iw_handler) NULL, /* -- hole -- */ | 3056 | (iw_handler) NULL, /* -- hole -- */ |
3057 | (iw_handler) NULL, /* SIOCGIWAPLIST depreciated */ | 3057 | (iw_handler) NULL, /* SIOCGIWAPLIST deprecated */ |
3058 | (iw_handler) prism54_set_scan, /* SIOCSIWSCAN */ | 3058 | (iw_handler) prism54_set_scan, /* SIOCSIWSCAN */ |
3059 | (iw_handler) prism54_get_scan, /* SIOCGIWSCAN */ | 3059 | (iw_handler) prism54_get_scan, /* SIOCGIWSCAN */ |
3060 | (iw_handler) prism54_set_essid, /* SIOCSIWESSID */ | 3060 | (iw_handler) prism54_set_essid, /* SIOCSIWESSID */ |
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c index a037b11dac9d..084795355b74 100644 --- a/drivers/net/wireless/prism54/islpci_dev.c +++ b/drivers/net/wireless/prism54/islpci_dev.c | |||
@@ -115,7 +115,7 @@ isl_upload_firmware(islpci_private *priv) | |||
115 | ISL38XX_MEMORY_WINDOW_SIZE : fw_len; | 115 | ISL38XX_MEMORY_WINDOW_SIZE : fw_len; |
116 | u32 __iomem *dev_fw_ptr = device_base + ISL38XX_DIRECT_MEM_WIN; | 116 | u32 __iomem *dev_fw_ptr = device_base + ISL38XX_DIRECT_MEM_WIN; |
117 | 117 | ||
118 | /* set the cards base address for writting the data */ | 118 | /* set the card's base address for writing the data */ |
119 | isl38xx_w32_flush(device_base, reg, | 119 | isl38xx_w32_flush(device_base, reg, |
120 | ISL38XX_DIR_MEM_BASE_REG); | 120 | ISL38XX_DIR_MEM_BASE_REG); |
121 | wmb(); /* be paranoid */ | 121 | wmb(); /* be paranoid */ |
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 67b867f837ca..5740d4d4267c 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -176,7 +176,7 @@ psa_write(struct net_device * dev, | |||
176 | volatile u_char __iomem *verify = lp->mem + PSA_ADDR + | 176 | volatile u_char __iomem *verify = lp->mem + PSA_ADDR + |
177 | (psaoff(0, psa_comp_number) << 1); | 177 | (psaoff(0, psa_comp_number) << 1); |
178 | 178 | ||
179 | /* Authorize writting to PSA */ | 179 | /* Authorize writing to PSA */ |
180 | hacr_write(base, HACR_PWR_STAT | HACR_ROM_WEN); | 180 | hacr_write(base, HACR_PWR_STAT | HACR_ROM_WEN); |
181 | 181 | ||
182 | while(n-- > 0) | 182 | while(n-- > 0) |
@@ -1676,7 +1676,7 @@ wv_set_frequency(u_long base, /* i/o port of the card */ | |||
1676 | fee_write(base, 0x60, | 1676 | fee_write(base, 0x60, |
1677 | dac, 2); | 1677 | dac, 2); |
1678 | 1678 | ||
1679 | /* We now should verify here that the EEprom writting was ok */ | 1679 | /* We now should verify here that the EEprom writing was ok */ |
1680 | 1680 | ||
1681 | /* ReRead the first area */ | 1681 | /* ReRead the first area */ |
1682 | fee_read(base, 0x00, | 1682 | fee_read(base, 0x00, |
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h index 4d1c4905c749..4b9de0093a7b 100644 --- a/drivers/net/wireless/wavelan_cs.p.h +++ b/drivers/net/wireless/wavelan_cs.p.h | |||
@@ -120,7 +120,7 @@ | |||
120 | * the Wavelan itself (NCR -> AT&T -> Lucent). | 120 | * the Wavelan itself (NCR -> AT&T -> Lucent). |
121 | * | 121 | * |
122 | * All started with Anders Klemets <klemets@paul.rutgers.edu>, | 122 | * All started with Anders Klemets <klemets@paul.rutgers.edu>, |
123 | * writting a Wavelan ISA driver for the MACH microkernel. Girish | 123 | * writing a Wavelan ISA driver for the MACH microkernel. Girish |
124 | * Welling <welling@paul.rutgers.edu> had also worked on it. | 124 | * Welling <welling@paul.rutgers.edu> had also worked on it. |
125 | * Keith Moore modify this for the Pcmcia hardware. | 125 | * Keith Moore modify this for the Pcmcia hardware. |
126 | * | 126 | * |
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c index 3f4a7cf9efea..f2a90a7fa2d6 100644 --- a/drivers/net/yellowfin.c +++ b/drivers/net/yellowfin.c | |||
@@ -109,7 +109,6 @@ static int gx_fix; | |||
109 | /* These identify the driver base version and may not be removed. */ | 109 | /* These identify the driver base version and may not be removed. */ |
110 | static char version[] __devinitdata = | 110 | static char version[] __devinitdata = |
111 | KERN_INFO DRV_NAME ".c:v1.05 1/09/2001 Written by Donald Becker <becker@scyld.com>\n" | 111 | KERN_INFO DRV_NAME ".c:v1.05 1/09/2001 Written by Donald Becker <becker@scyld.com>\n" |
112 | KERN_INFO " http://www.scyld.com/network/yellowfin.html\n" | ||
113 | KERN_INFO " (unofficial 2.4.x port, " DRV_VERSION ", " DRV_RELDATE ")\n"; | 112 | KERN_INFO " (unofficial 2.4.x port, " DRV_VERSION ", " DRV_RELDATE ")\n"; |
114 | 113 | ||
115 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); | 114 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 3bb7739d26a5..8e58ea3d95c0 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -119,7 +119,7 @@ static inline int pci_create_newid_file(struct pci_driver *drv) | |||
119 | * system is in its list of supported devices. Returns the matching | 119 | * system is in its list of supported devices. Returns the matching |
120 | * pci_device_id structure or %NULL if there is no match. | 120 | * pci_device_id structure or %NULL if there is no match. |
121 | * | 121 | * |
122 | * Depreciated, don't use this as it will not catch any dynamic ids | 122 | * Deprecated, don't use this as it will not catch any dynamic ids |
123 | * that a driver might want to check for. | 123 | * that a driver might want to check for. |
124 | */ | 124 | */ |
125 | const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, | 125 | const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 5e439836db2d..76422eded36e 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -98,7 +98,7 @@ config RTC_INTF_DEV_UIE_EMUL | |||
98 | bool "RTC UIE emulation on dev interface" | 98 | bool "RTC UIE emulation on dev interface" |
99 | depends on RTC_INTF_DEV | 99 | depends on RTC_INTF_DEV |
100 | help | 100 | help |
101 | Provides an emulation for RTC_UIE if the underlaying rtc chip | 101 | Provides an emulation for RTC_UIE if the underlying rtc chip |
102 | driver does not expose RTC_UIE ioctls. Those requests generate | 102 | driver does not expose RTC_UIE ioctls. Those requests generate |
103 | once-per-second update interrupts, used for synchronization. | 103 | once-per-second update interrupts, used for synchronization. |
104 | 104 | ||
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 6abf4811958c..e0f91dfce0f5 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -104,7 +104,7 @@ static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id) | |||
104 | 104 | ||
105 | writeb(tmp, rtc->regbase + RCR1); | 105 | writeb(tmp, rtc->regbase + RCR1); |
106 | 106 | ||
107 | rtc_update_irq(&rtc->rtc_dev, 1, events); | 107 | rtc_update_irq(rtc->rtc_dev, 1, events); |
108 | 108 | ||
109 | spin_unlock(&rtc->lock); | 109 | spin_unlock(&rtc->lock); |
110 | 110 | ||
@@ -139,7 +139,7 @@ static irqreturn_t sh_rtc_alarm(int irq, void *dev_id) | |||
139 | 139 | ||
140 | rtc->rearm_aie = 1; | 140 | rtc->rearm_aie = 1; |
141 | 141 | ||
142 | rtc_update_irq(&rtc->rtc_dev, 1, events); | 142 | rtc_update_irq(rtc->rtc_dev, 1, events); |
143 | } | 143 | } |
144 | 144 | ||
145 | spin_unlock(&rtc->lock); | 145 | spin_unlock(&rtc->lock); |
@@ -153,7 +153,7 @@ static irqreturn_t sh_rtc_periodic(int irq, void *dev_id) | |||
153 | 153 | ||
154 | spin_lock(&rtc->lock); | 154 | spin_lock(&rtc->lock); |
155 | 155 | ||
156 | rtc_update_irq(&rtc->rtc_dev, 1, RTC_PF | RTC_IRQF); | 156 | rtc_update_irq(rtc->rtc_dev, 1, RTC_PF | RTC_IRQF); |
157 | 157 | ||
158 | spin_unlock(&rtc->lock); | 158 | spin_unlock(&rtc->lock); |
159 | 159 | ||
@@ -341,7 +341,7 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
341 | tm->tm_sec--; | 341 | tm->tm_sec--; |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | dev_dbg(&dev, "%s: tm is secs=%d, mins=%d, hours=%d, " | 344 | dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " |
345 | "mday=%d, mon=%d, year=%d, wday=%d\n", | 345 | "mday=%d, mon=%d, year=%d, wday=%d\n", |
346 | __FUNCTION__, | 346 | __FUNCTION__, |
347 | tm->tm_sec, tm->tm_min, tm->tm_hour, | 347 | tm->tm_sec, tm->tm_min, tm->tm_hour, |
diff --git a/drivers/s390/char/sclp_rw.c b/drivers/s390/char/sclp_rw.c index bbd5b8b66f42..d6b06ab81188 100644 --- a/drivers/s390/char/sclp_rw.c +++ b/drivers/s390/char/sclp_rw.c | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | /* | 24 | /* |
25 | * The room for the SCCB (only for writing) is not equal to a pages size | 25 | * The room for the SCCB (only for writing) is not equal to a pages size |
26 | * (as it is specified as the maximum size in the the SCLP documentation) | 26 | * (as it is specified as the maximum size in the SCLP documentation) |
27 | * because of the additional data structure described above. | 27 | * because of the additional data structure described above. |
28 | */ | 28 | */ |
29 | #define MAX_SCCB_ROOM (PAGE_SIZE - sizeof(struct sclp_buffer)) | 29 | #define MAX_SCCB_ROOM (PAGE_SIZE - sizeof(struct sclp_buffer)) |
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index 29d176036e5c..0b96d49dd636 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c | |||
@@ -2860,7 +2860,7 @@ qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int, | |||
2860 | if (!atomic_read(&queue->set_pci_flags_count)){ | 2860 | if (!atomic_read(&queue->set_pci_flags_count)){ |
2861 | /* | 2861 | /* |
2862 | * there's no outstanding PCI any more, so we | 2862 | * there's no outstanding PCI any more, so we |
2863 | * have to request a PCI to be sure the the PCI | 2863 | * have to request a PCI to be sure that the PCI |
2864 | * will wake at some time in the future then we | 2864 | * will wake at some time in the future then we |
2865 | * can flush packed buffers that might still be | 2865 | * can flush packed buffers that might still be |
2866 | * hanging around, which can happen if no | 2866 | * hanging around, which can happen if no |
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index cb08ca3cc0f9..bdf5782b8a7a 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c | |||
@@ -222,7 +222,7 @@ zfcp_qdio_handler_error_check(struct zfcp_adapter *adapter, unsigned int status, | |||
222 | * Since we have been using this adapter, it is save to assume | 222 | * Since we have been using this adapter, it is save to assume |
223 | * that it is not failed but recoverable. The card seems to | 223 | * that it is not failed but recoverable. The card seems to |
224 | * report link-up events by self-initiated queue shutdown. | 224 | * report link-up events by self-initiated queue shutdown. |
225 | * That is why we need to clear the the link-down flag | 225 | * That is why we need to clear the link-down flag |
226 | * which is set again in case we have missed by a mile. | 226 | * which is set again in case we have missed by a mile. |
227 | */ | 227 | */ |
228 | zfcp_erp_adapter_reopen( | 228 | zfcp_erp_adapter_reopen( |
diff --git a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c index 74b999d77bbf..4fab0c23814c 100644 --- a/drivers/sbus/char/bpp.c +++ b/drivers/sbus/char/bpp.c | |||
@@ -156,7 +156,7 @@ static unsigned short get_pins(unsigned minor) | |||
156 | #define BPP_ICR 0x18 | 156 | #define BPP_ICR 0x18 |
157 | #define BPP_SIZE 0x1A | 157 | #define BPP_SIZE 0x1A |
158 | 158 | ||
159 | /* BPP_CSR. Bits of type RW1 are cleared with writting '1'. */ | 159 | /* BPP_CSR. Bits of type RW1 are cleared with writing '1'. */ |
160 | #define P_DEV_ID_MASK 0xf0000000 /* R */ | 160 | #define P_DEV_ID_MASK 0xf0000000 /* R */ |
161 | #define P_DEV_ID_ZEBRA 0x40000000 | 161 | #define P_DEV_ID_ZEBRA 0x40000000 |
162 | #define P_DEV_ID_L64854 0xa0000000 /* == NCR 89C100+89C105. Pity. */ | 162 | #define P_DEV_ID_L64854 0xa0000000 /* == NCR 89C100+89C105. Pity. */ |
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c index 8d72bbae96ad..0bada0028aa0 100644 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c | |||
@@ -966,7 +966,7 @@ ahd_aic790X_setup(struct ahd_softc *ahd) | |||
966 | | AHD_BUSFREEREV_BUG; | 966 | | AHD_BUSFREEREV_BUG; |
967 | ahd->bugs |= AHD_LQOOVERRUN_BUG|AHD_EARLY_REQ_BUG; | 967 | ahd->bugs |= AHD_LQOOVERRUN_BUG|AHD_EARLY_REQ_BUG; |
968 | 968 | ||
969 | /* If the user requested the the SLOWCRC bit to be set. */ | 969 | /* If the user requested that the SLOWCRC bit to be set. */ |
970 | if (aic79xx_slowcrc) | 970 | if (aic79xx_slowcrc) |
971 | ahd->features |= AHD_AIC79XXB_SLOWCRC; | 971 | ahd->features |= AHD_AIC79XXB_SLOWCRC; |
972 | 972 | ||
diff --git a/drivers/scsi/aic94xx/Makefile b/drivers/scsi/aic94xx/Makefile index e6b70123940c..e78ce0fa44d2 100644 --- a/drivers/scsi/aic94xx/Makefile +++ b/drivers/scsi/aic94xx/Makefile | |||
@@ -6,7 +6,7 @@ | |||
6 | # | 6 | # |
7 | # This file is licensed under GPLv2. | 7 | # This file is licensed under GPLv2. |
8 | # | 8 | # |
9 | # This file is part of the the aic94xx driver. | 9 | # This file is part of the aic94xx driver. |
10 | # | 10 | # |
11 | # The aic94xx driver is free software; you can redistribute it and/or | 11 | # The aic94xx driver is free software; you can redistribute it and/or |
12 | # modify it under the terms of the GNU General Public License as | 12 | # modify it under the terms of the GNU General Public License as |
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index a965ed3548d5..564ea90ed3a0 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c | |||
@@ -541,7 +541,7 @@ static struct ParameterData __devinitdata cfg_data[] = { | |||
541 | 541 | ||
542 | 542 | ||
543 | /* | 543 | /* |
544 | * Safe settings. If set to zero the the BIOS/default values with | 544 | * Safe settings. If set to zero the BIOS/default values with |
545 | * command line overrides will be used. If set to 1 then safe and | 545 | * command line overrides will be used. If set to 1 then safe and |
546 | * slow settings will be used. | 546 | * slow settings will be used. |
547 | */ | 547 | */ |
@@ -617,7 +617,7 @@ static void __devinit fix_settings(void) | |||
617 | 617 | ||
618 | /* | 618 | /* |
619 | * Mapping from the eeprom delay index value (index into this array) | 619 | * Mapping from the eeprom delay index value (index into this array) |
620 | * to the the number of actual seconds that the delay should be for. | 620 | * to the number of actual seconds that the delay should be for. |
621 | */ | 621 | */ |
622 | static char __devinitdata eeprom_index_to_delay_map[] = | 622 | static char __devinitdata eeprom_index_to_delay_map[] = |
623 | { 1, 3, 5, 10, 16, 30, 60, 120 }; | 623 | { 1, 3, 5, 10, 16, 30, 60, 120 }; |
@@ -4136,7 +4136,7 @@ static void __devinit trms1040_write_all(struct NvRamType *eeprom, unsigned long | |||
4136 | * @io_port: base I/O address | 4136 | * @io_port: base I/O address |
4137 | * @addr: offset into SEEPROM | 4137 | * @addr: offset into SEEPROM |
4138 | * | 4138 | * |
4139 | * Returns the the byte read. | 4139 | * Returns the byte read. |
4140 | **/ | 4140 | **/ |
4141 | static u8 __devinit trms1040_get_data(unsigned long io_port, u8 addr) | 4141 | static u8 __devinit trms1040_get_data(unsigned long io_port, u8 addr) |
4142 | { | 4142 | { |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 61fbcdcbb009..1f5a07bf2a75 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -173,7 +173,7 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason) | |||
173 | * @retries: number of times to retry request | 173 | * @retries: number of times to retry request |
174 | * @flags: or into request flags; | 174 | * @flags: or into request flags; |
175 | * | 175 | * |
176 | * returns the req->errors value which is the the scsi_cmnd result | 176 | * returns the req->errors value which is the scsi_cmnd result |
177 | * field. | 177 | * field. |
178 | **/ | 178 | **/ |
179 | int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, | 179 | int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, |
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 66e7bc985797..1d8a2f6bb8eb 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c | |||
@@ -22,10 +22,7 @@ | |||
22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
23 | #include <asm/arch/board.h> | 23 | #include <asm/arch/board.h> |
24 | #include <asm/arch/gpio.h> | 24 | #include <asm/arch/gpio.h> |
25 | |||
26 | #ifdef CONFIG_ARCH_AT91 | ||
27 | #include <asm/arch/cpu.h> | 25 | #include <asm/arch/cpu.h> |
28 | #endif | ||
29 | 26 | ||
30 | #include "atmel_spi.h" | 27 | #include "atmel_spi.h" |
31 | 28 | ||
@@ -552,10 +549,8 @@ static int __init atmel_spi_probe(struct platform_device *pdev) | |||
552 | goto out_free_buffer; | 549 | goto out_free_buffer; |
553 | as->irq = irq; | 550 | as->irq = irq; |
554 | as->clk = clk; | 551 | as->clk = clk; |
555 | #ifdef CONFIG_ARCH_AT91 | ||
556 | if (!cpu_is_at91rm9200()) | 552 | if (!cpu_is_at91rm9200()) |
557 | as->new_1 = 1; | 553 | as->new_1 = 1; |
558 | #endif | ||
559 | 554 | ||
560 | ret = request_irq(irq, atmel_spi_interrupt, 0, | 555 | ret = request_irq(irq, atmel_spi_interrupt, 0, |
561 | pdev->dev.bus_id, master); | 556 | pdev->dev.bus_id, master); |
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index b082d95bbbaa..11e9b15ca45a 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
@@ -1033,7 +1033,7 @@ static int usbatm_do_heavy_init(void *arg) | |||
1033 | 1033 | ||
1034 | static int usbatm_heavy_init(struct usbatm_data *instance) | 1034 | static int usbatm_heavy_init(struct usbatm_data *instance) |
1035 | { | 1035 | { |
1036 | int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_KERNEL); | 1036 | int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_FS | CLONE_FILES); |
1037 | 1037 | ||
1038 | if (ret < 0) { | 1038 | if (ret < 0) { |
1039 | usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret); | 1039 | usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret); |
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index b5332e679c46..88fb56d5db8f 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c | |||
@@ -1307,7 +1307,7 @@ static int auerswald_addservice (pauerswald_t cp, pauerscon_t scp) | |||
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | 1309 | ||
1310 | /* remove a service from the the device | 1310 | /* remove a service from the device |
1311 | scp->id must be set! */ | 1311 | scp->id must be set! */ |
1312 | static void auerswald_removeservice (pauerswald_t cp, pauerscon_t scp) | 1312 | static void auerswald_removeservice (pauerswald_t cp, pauerscon_t scp) |
1313 | { | 1313 | { |
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h index cbb53e065d6c..82db5a8e528e 100644 --- a/drivers/usb/net/usbnet.h +++ b/drivers/usb/net/usbnet.h | |||
@@ -129,7 +129,7 @@ extern void usbnet_disconnect(struct usb_interface *); | |||
129 | 129 | ||
130 | 130 | ||
131 | /* Drivers that reuse some of the standard USB CDC infrastructure | 131 | /* Drivers that reuse some of the standard USB CDC infrastructure |
132 | * (notably, using multiple interfaces according to the the CDC | 132 | * (notably, using multiple interfaces according to the CDC |
133 | * union descriptor) get some helper code. | 133 | * union descriptor) get some helper code. |
134 | */ | 134 | */ |
135 | struct cdc_state { | 135 | struct cdc_state { |
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index ba5d1dc03036..3efe67092f15 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -558,7 +558,7 @@ config USB_SERIAL_DEBUG | |||
558 | tristate "USB Debugging Device" | 558 | tristate "USB Debugging Device" |
559 | depends on USB_SERIAL | 559 | depends on USB_SERIAL |
560 | help | 560 | help |
561 | Say Y here if you have a USB debugging device used to recieve | 561 | Say Y here if you have a USB debugging device used to receive |
562 | debugging data from another machine. The most common of these | 562 | debugging data from another machine. The most common of these |
563 | devices is the NetChip TurboCONNECT device. | 563 | devices is the NetChip TurboCONNECT device. |
564 | 564 | ||
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index b675735bfbee..fbc8c27d5d99 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * The device works as an standard CDC device, it has 2 interfaces, the first | 9 | * The device works as an standard CDC device, it has 2 interfaces, the first |
10 | * one is for firmware access and the second is the serial one. | 10 | * one is for firmware access and the second is the serial one. |
11 | * The protocol is very simply, there are two posibilities reading or writing. | 11 | * The protocol is very simply, there are two posibilities reading or writing. |
12 | * When writting the first urb must have a Header that starts with 0x20 0x29 the | 12 | * When writing the first urb must have a Header that starts with 0x20 0x29 the |
13 | * next two bytes must say how much data will be sended. | 13 | * next two bytes must say how much data will be sended. |
14 | * When reading the process is almost equal except that the header starts with | 14 | * When reading the process is almost equal except that the header starts with |
15 | * 0x00 0x20. | 15 | * 0x00 0x20. |
@@ -18,7 +18,7 @@ | |||
18 | * buffer: The First and Second byte is used for a Header, the Third and Fourth | 18 | * buffer: The First and Second byte is used for a Header, the Third and Fourth |
19 | * tells the device the amount of information the package holds. | 19 | * tells the device the amount of information the package holds. |
20 | * Packages are 60 bytes long Header Stuff. | 20 | * Packages are 60 bytes long Header Stuff. |
21 | * When writting to the device the first two bytes of the header are 0x20 0x29 | 21 | * When writing to the device the first two bytes of the header are 0x20 0x29 |
22 | * When reading the bytes are 0x00 0x20, or 0x00 0x10, there is an strange | 22 | * When reading the bytes are 0x00 0x20, or 0x00 0x10, there is an strange |
23 | * situation, when too much data arrives to the device because it sends the data | 23 | * situation, when too much data arrives to the device because it sends the data |
24 | * but with out the header. I will use a simply hack to override this situation, | 24 | * but with out the header. I will use a simply hack to override this situation, |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 18f74ac76565..4807f960150b 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -2465,7 +2465,7 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r | |||
2465 | ((edge_serial->is_epic) && | 2465 | ((edge_serial->is_epic) && |
2466 | (!edge_serial->epic_descriptor.Supports.IOSPWriteMCR) && | 2466 | (!edge_serial->epic_descriptor.Supports.IOSPWriteMCR) && |
2467 | (regNum == MCR))) { | 2467 | (regNum == MCR))) { |
2468 | dbg("SendCmdWriteUartReg - Not writting to MCR Register"); | 2468 | dbg("SendCmdWriteUartReg - Not writing to MCR Register"); |
2469 | return 0; | 2469 | return 0; |
2470 | } | 2470 | } |
2471 | 2471 | ||
@@ -2473,7 +2473,7 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r | |||
2473 | ((edge_serial->is_epic) && | 2473 | ((edge_serial->is_epic) && |
2474 | (!edge_serial->epic_descriptor.Supports.IOSPWriteLCR) && | 2474 | (!edge_serial->epic_descriptor.Supports.IOSPWriteLCR) && |
2475 | (regNum == LCR))) { | 2475 | (regNum == LCR))) { |
2476 | dbg ("SendCmdWriteUartReg - Not writting to LCR Register"); | 2476 | dbg ("SendCmdWriteUartReg - Not writing to LCR Register"); |
2477 | return 0; | 2477 | return 0; |
2478 | } | 2478 | } |
2479 | 2479 | ||
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 1132ba5ff391..9a256d2ff9dc 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -1348,6 +1348,20 @@ config FB_VOODOO1 | |||
1348 | Please read the <file:Documentation/fb/README-sstfb.txt> for supported | 1348 | Please read the <file:Documentation/fb/README-sstfb.txt> for supported |
1349 | options and other important info support. | 1349 | options and other important info support. |
1350 | 1350 | ||
1351 | config FB_VT8623 | ||
1352 | tristate "VIA VT8623 support" | ||
1353 | depends on FB && PCI | ||
1354 | select FB_CFB_FILLRECT | ||
1355 | select FB_CFB_COPYAREA | ||
1356 | select FB_CFB_IMAGEBLIT | ||
1357 | select FB_TILEBLITTING | ||
1358 | select FB_SVGALIB | ||
1359 | select VGASTATE | ||
1360 | select FONT_8x16 if FRAMEBUFFER_CONSOLE | ||
1361 | ---help--- | ||
1362 | Driver for CastleRock integrated graphics core in the | ||
1363 | VIA VT8623 [Apollo CLE266] chipset. | ||
1364 | |||
1351 | config FB_CYBLA | 1365 | config FB_CYBLA |
1352 | tristate "Cyberblade/i1 support" | 1366 | tristate "Cyberblade/i1 support" |
1353 | depends on FB && PCI && X86_32 && !64BIT | 1367 | depends on FB && PCI && X86_32 && !64BIT |
@@ -1401,6 +1415,20 @@ config FB_TRIDENT_ACCEL | |||
1401 | This will compile the Trident frame buffer device with | 1415 | This will compile the Trident frame buffer device with |
1402 | acceleration functions. | 1416 | acceleration functions. |
1403 | 1417 | ||
1418 | config FB_ARK | ||
1419 | tristate "ARK 2000PV support" | ||
1420 | depends on FB && PCI | ||
1421 | select FB_CFB_FILLRECT | ||
1422 | select FB_CFB_COPYAREA | ||
1423 | select FB_CFB_IMAGEBLIT | ||
1424 | select FB_TILEBLITTING | ||
1425 | select FB_SVGALIB | ||
1426 | select VGASTATE | ||
1427 | select FONT_8x16 if FRAMEBUFFER_CONSOLE | ||
1428 | ---help--- | ||
1429 | Driver for PCI graphics boards with ARK 2000PV chip | ||
1430 | and ICS 5342 RAMDAC. | ||
1431 | |||
1404 | config FB_PM3 | 1432 | config FB_PM3 |
1405 | tristate "Permedia3 support" | 1433 | tristate "Permedia3 support" |
1406 | depends on FB && PCI && BROKEN | 1434 | depends on FB && PCI && BROKEN |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index a916c204274f..0b70567458fb 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -54,10 +54,12 @@ obj-$(CONFIG_FB_VALKYRIE) += valkyriefb.o | |||
54 | obj-$(CONFIG_FB_CT65550) += chipsfb.o | 54 | obj-$(CONFIG_FB_CT65550) += chipsfb.o |
55 | obj-$(CONFIG_FB_IMSTT) += imsttfb.o | 55 | obj-$(CONFIG_FB_IMSTT) += imsttfb.o |
56 | obj-$(CONFIG_FB_FM2) += fm2fb.o | 56 | obj-$(CONFIG_FB_FM2) += fm2fb.o |
57 | obj-$(CONFIG_FB_VT8623) += vt8623fb.o | ||
57 | obj-$(CONFIG_FB_CYBLA) += cyblafb.o | 58 | obj-$(CONFIG_FB_CYBLA) += cyblafb.o |
58 | obj-$(CONFIG_FB_TRIDENT) += tridentfb.o | 59 | obj-$(CONFIG_FB_TRIDENT) += tridentfb.o |
59 | obj-$(CONFIG_FB_LE80578) += vermilion/ | 60 | obj-$(CONFIG_FB_LE80578) += vermilion/ |
60 | obj-$(CONFIG_FB_S3) += s3fb.o | 61 | obj-$(CONFIG_FB_S3) += s3fb.o |
62 | obj-$(CONFIG_FB_ARK) += arkfb.o | ||
61 | obj-$(CONFIG_FB_STI) += stifb.o | 63 | obj-$(CONFIG_FB_STI) += stifb.o |
62 | obj-$(CONFIG_FB_FFB) += ffb.o sbuslib.o | 64 | obj-$(CONFIG_FB_FFB) += ffb.o sbuslib.o |
63 | obj-$(CONFIG_FB_CG6) += cg6.o sbuslib.o | 65 | obj-$(CONFIG_FB_CG6) += cg6.o sbuslib.o |
diff --git a/drivers/video/arkfb.c b/drivers/video/arkfb.c new file mode 100644 index 000000000000..ba6fede5c466 --- /dev/null +++ b/drivers/video/arkfb.c | |||
@@ -0,0 +1,1200 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/arkfb.c -- Frame buffer device driver for ARK 2000PV | ||
3 | * with ICS 5342 dac (it is easy to add support for different dacs). | ||
4 | * | ||
5 | * Copyright (c) 2007 Ondrej Zajicek <santiago@crfreenet.org> | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file COPYING in the main directory of this archive for | ||
9 | * more details. | ||
10 | * | ||
11 | * Code is based on s3fb | ||
12 | */ | ||
13 | |||
14 | #include <linux/version.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/mm.h> | ||
20 | #include <linux/tty.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/fb.h> | ||
24 | #include <linux/svga.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/pci.h> | ||
27 | #include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ | ||
28 | #include <video/vga.h> | ||
29 | |||
30 | #ifdef CONFIG_MTRR | ||
31 | #include <asm/mtrr.h> | ||
32 | #endif | ||
33 | |||
34 | struct arkfb_info { | ||
35 | int mclk_freq; | ||
36 | int mtrr_reg; | ||
37 | |||
38 | struct dac_info *dac; | ||
39 | struct vgastate state; | ||
40 | struct mutex open_lock; | ||
41 | unsigned int ref_count; | ||
42 | u32 pseudo_palette[16]; | ||
43 | }; | ||
44 | |||
45 | |||
46 | /* ------------------------------------------------------------------------- */ | ||
47 | |||
48 | |||
49 | static const struct svga_fb_format arkfb_formats[] = { | ||
50 | { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, | ||
51 | FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP4, FB_VISUAL_PSEUDOCOLOR, 8, 8}, | ||
52 | { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, | ||
53 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 16}, | ||
54 | { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 1, | ||
55 | FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 8, 16}, | ||
56 | { 8, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, | ||
57 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 8}, | ||
58 | {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0, | ||
59 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4}, | ||
60 | {16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0, | ||
61 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4}, | ||
62 | {24, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0, | ||
63 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 8, 8}, | ||
64 | {32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0, | ||
65 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 2}, | ||
66 | SVGA_FORMAT_END | ||
67 | }; | ||
68 | |||
69 | |||
70 | /* CRT timing register sets */ | ||
71 | |||
72 | static const struct vga_regset ark_h_total_regs[] = {{0x00, 0, 7}, {0x41, 7, 7}, VGA_REGSET_END}; | ||
73 | static const struct vga_regset ark_h_display_regs[] = {{0x01, 0, 7}, {0x41, 6, 6}, VGA_REGSET_END}; | ||
74 | static const struct vga_regset ark_h_blank_start_regs[] = {{0x02, 0, 7}, {0x41, 5, 5}, VGA_REGSET_END}; | ||
75 | static const struct vga_regset ark_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7 }, VGA_REGSET_END}; | ||
76 | static const struct vga_regset ark_h_sync_start_regs[] = {{0x04, 0, 7}, {0x41, 4, 4}, VGA_REGSET_END}; | ||
77 | static const struct vga_regset ark_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END}; | ||
78 | |||
79 | static const struct vga_regset ark_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x40, 7, 7}, VGA_REGSET_END}; | ||
80 | static const struct vga_regset ark_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x40, 6, 6}, VGA_REGSET_END}; | ||
81 | static const struct vga_regset ark_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x40, 5, 5}, VGA_REGSET_END}; | ||
82 | // const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 6}, VGA_REGSET_END}; | ||
83 | static const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END}; | ||
84 | static const struct vga_regset ark_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x40, 4, 4}, VGA_REGSET_END}; | ||
85 | static const struct vga_regset ark_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END}; | ||
86 | |||
87 | static const struct vga_regset ark_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, VGA_REGSET_END}; | ||
88 | static const struct vga_regset ark_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x40, 0, 2}, VGA_REGSET_END}; | ||
89 | static const struct vga_regset ark_offset_regs[] = {{0x13, 0, 7}, {0x41, 3, 3}, VGA_REGSET_END}; | ||
90 | |||
91 | static const struct svga_timing_regs ark_timing_regs = { | ||
92 | ark_h_total_regs, ark_h_display_regs, ark_h_blank_start_regs, | ||
93 | ark_h_blank_end_regs, ark_h_sync_start_regs, ark_h_sync_end_regs, | ||
94 | ark_v_total_regs, ark_v_display_regs, ark_v_blank_start_regs, | ||
95 | ark_v_blank_end_regs, ark_v_sync_start_regs, ark_v_sync_end_regs, | ||
96 | }; | ||
97 | |||
98 | |||
99 | /* ------------------------------------------------------------------------- */ | ||
100 | |||
101 | |||
102 | /* Module parameters */ | ||
103 | |||
104 | static char *mode = "640x480-8@60"; | ||
105 | |||
106 | #ifdef CONFIG_MTRR | ||
107 | static int mtrr = 1; | ||
108 | #endif | ||
109 | |||
110 | MODULE_AUTHOR("(c) 2007 Ondrej Zajicek <santiago@crfreenet.org>"); | ||
111 | MODULE_LICENSE("GPL"); | ||
112 | MODULE_DESCRIPTION("fbdev driver for ARK 2000PV"); | ||
113 | |||
114 | module_param(mode, charp, 0444); | ||
115 | MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc)"); | ||
116 | |||
117 | #ifdef CONFIG_MTRR | ||
118 | module_param(mtrr, int, 0444); | ||
119 | MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, default=1)"); | ||
120 | #endif | ||
121 | |||
122 | static int threshold = 4; | ||
123 | |||
124 | module_param(threshold, int, 0644); | ||
125 | MODULE_PARM_DESC(threshold, "FIFO threshold"); | ||
126 | |||
127 | |||
128 | /* ------------------------------------------------------------------------- */ | ||
129 | |||
130 | |||
131 | static void arkfb_settile(struct fb_info *info, struct fb_tilemap *map) | ||
132 | { | ||
133 | const u8 *font = map->data; | ||
134 | u8 __iomem *fb = (u8 __iomem *)info->screen_base; | ||
135 | int i, c; | ||
136 | |||
137 | if ((map->width != 8) || (map->height != 16) || | ||
138 | (map->depth != 1) || (map->length != 256)) { | ||
139 | printk(KERN_ERR "fb%d: unsupported font parameters: width %d, " | ||
140 | "height %d, depth %d, length %d\n", info->node, | ||
141 | map->width, map->height, map->depth, map->length); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | fb += 2; | ||
146 | for (c = 0; c < map->length; c++) { | ||
147 | for (i = 0; i < map->height; i++) { | ||
148 | fb_writeb(font[i], &fb[i * 4]); | ||
149 | fb_writeb(font[i], &fb[i * 4 + (128 * 8)]); | ||
150 | } | ||
151 | fb += 128; | ||
152 | |||
153 | if ((c % 8) == 7) | ||
154 | fb += 128*8; | ||
155 | |||
156 | font += map->height; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | static struct fb_tile_ops arkfb_tile_ops = { | ||
161 | .fb_settile = arkfb_settile, | ||
162 | .fb_tilecopy = svga_tilecopy, | ||
163 | .fb_tilefill = svga_tilefill, | ||
164 | .fb_tileblit = svga_tileblit, | ||
165 | .fb_tilecursor = svga_tilecursor, | ||
166 | .fb_get_tilemax = svga_get_tilemax, | ||
167 | }; | ||
168 | |||
169 | |||
170 | /* ------------------------------------------------------------------------- */ | ||
171 | |||
172 | |||
173 | /* image data is MSB-first, fb structure is MSB-first too */ | ||
174 | static inline u32 expand_color(u32 c) | ||
175 | { | ||
176 | return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF; | ||
177 | } | ||
178 | |||
179 | /* arkfb_iplan_imageblit silently assumes that almost everything is 8-pixel aligned */ | ||
180 | static void arkfb_iplan_imageblit(struct fb_info *info, const struct fb_image *image) | ||
181 | { | ||
182 | u32 fg = expand_color(image->fg_color); | ||
183 | u32 bg = expand_color(image->bg_color); | ||
184 | const u8 *src1, *src; | ||
185 | u8 __iomem *dst1; | ||
186 | u32 __iomem *dst; | ||
187 | u32 val; | ||
188 | int x, y; | ||
189 | |||
190 | src1 = image->data; | ||
191 | dst1 = info->screen_base + (image->dy * info->fix.line_length) | ||
192 | + ((image->dx / 8) * 4); | ||
193 | |||
194 | for (y = 0; y < image->height; y++) { | ||
195 | src = src1; | ||
196 | dst = (u32 __iomem *) dst1; | ||
197 | for (x = 0; x < image->width; x += 8) { | ||
198 | val = *(src++) * 0x01010101; | ||
199 | val = (val & fg) | (~val & bg); | ||
200 | fb_writel(val, dst++); | ||
201 | } | ||
202 | src1 += image->width / 8; | ||
203 | dst1 += info->fix.line_length; | ||
204 | } | ||
205 | |||
206 | } | ||
207 | |||
208 | /* arkfb_iplan_fillrect silently assumes that almost everything is 8-pixel aligned */ | ||
209 | static void arkfb_iplan_fillrect(struct fb_info *info, const struct fb_fillrect *rect) | ||
210 | { | ||
211 | u32 fg = expand_color(rect->color); | ||
212 | u8 __iomem *dst1; | ||
213 | u32 __iomem *dst; | ||
214 | int x, y; | ||
215 | |||
216 | dst1 = info->screen_base + (rect->dy * info->fix.line_length) | ||
217 | + ((rect->dx / 8) * 4); | ||
218 | |||
219 | for (y = 0; y < rect->height; y++) { | ||
220 | dst = (u32 __iomem *) dst1; | ||
221 | for (x = 0; x < rect->width; x += 8) { | ||
222 | fb_writel(fg, dst++); | ||
223 | } | ||
224 | dst1 += info->fix.line_length; | ||
225 | } | ||
226 | |||
227 | } | ||
228 | |||
229 | |||
230 | /* image data is MSB-first, fb structure is high-nibble-in-low-byte-first */ | ||
231 | static inline u32 expand_pixel(u32 c) | ||
232 | { | ||
233 | return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) | | ||
234 | ((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF; | ||
235 | } | ||
236 | |||
237 | /* arkfb_cfb4_imageblit silently assumes that almost everything is 8-pixel aligned */ | ||
238 | static void arkfb_cfb4_imageblit(struct fb_info *info, const struct fb_image *image) | ||
239 | { | ||
240 | u32 fg = image->fg_color * 0x11111111; | ||
241 | u32 bg = image->bg_color * 0x11111111; | ||
242 | const u8 *src1, *src; | ||
243 | u8 __iomem *dst1; | ||
244 | u32 __iomem *dst; | ||
245 | u32 val; | ||
246 | int x, y; | ||
247 | |||
248 | src1 = image->data; | ||
249 | dst1 = info->screen_base + (image->dy * info->fix.line_length) | ||
250 | + ((image->dx / 8) * 4); | ||
251 | |||
252 | for (y = 0; y < image->height; y++) { | ||
253 | src = src1; | ||
254 | dst = (u32 __iomem *) dst1; | ||
255 | for (x = 0; x < image->width; x += 8) { | ||
256 | val = expand_pixel(*(src++)); | ||
257 | val = (val & fg) | (~val & bg); | ||
258 | fb_writel(val, dst++); | ||
259 | } | ||
260 | src1 += image->width / 8; | ||
261 | dst1 += info->fix.line_length; | ||
262 | } | ||
263 | |||
264 | } | ||
265 | |||
266 | static void arkfb_imageblit(struct fb_info *info, const struct fb_image *image) | ||
267 | { | ||
268 | if ((info->var.bits_per_pixel == 4) && (image->depth == 1) | ||
269 | && ((image->width % 8) == 0) && ((image->dx % 8) == 0)) { | ||
270 | if (info->fix.type == FB_TYPE_INTERLEAVED_PLANES) | ||
271 | arkfb_iplan_imageblit(info, image); | ||
272 | else | ||
273 | arkfb_cfb4_imageblit(info, image); | ||
274 | } else | ||
275 | cfb_imageblit(info, image); | ||
276 | } | ||
277 | |||
278 | static void arkfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) | ||
279 | { | ||
280 | if ((info->var.bits_per_pixel == 4) | ||
281 | && ((rect->width % 8) == 0) && ((rect->dx % 8) == 0) | ||
282 | && (info->fix.type == FB_TYPE_INTERLEAVED_PLANES)) | ||
283 | arkfb_iplan_fillrect(info, rect); | ||
284 | else | ||
285 | cfb_fillrect(info, rect); | ||
286 | } | ||
287 | |||
288 | |||
289 | /* ------------------------------------------------------------------------- */ | ||
290 | |||
291 | |||
292 | enum | ||
293 | { | ||
294 | DAC_PSEUDO8_8, | ||
295 | DAC_RGB1555_8, | ||
296 | DAC_RGB0565_8, | ||
297 | DAC_RGB0888_8, | ||
298 | DAC_RGB8888_8, | ||
299 | DAC_PSEUDO8_16, | ||
300 | DAC_RGB1555_16, | ||
301 | DAC_RGB0565_16, | ||
302 | DAC_RGB0888_16, | ||
303 | DAC_RGB8888_16, | ||
304 | DAC_MAX | ||
305 | }; | ||
306 | |||
307 | struct dac_ops { | ||
308 | int (*dac_get_mode)(struct dac_info *info); | ||
309 | int (*dac_set_mode)(struct dac_info *info, int mode); | ||
310 | int (*dac_get_freq)(struct dac_info *info, int channel); | ||
311 | int (*dac_set_freq)(struct dac_info *info, int channel, u32 freq); | ||
312 | void (*dac_release)(struct dac_info *info); | ||
313 | }; | ||
314 | |||
315 | typedef void (*dac_read_regs_t)(void *data, u8 *code, int count); | ||
316 | typedef void (*dac_write_regs_t)(void *data, u8 *code, int count); | ||
317 | |||
318 | struct dac_info | ||
319 | { | ||
320 | struct dac_ops *dacops; | ||
321 | dac_read_regs_t dac_read_regs; | ||
322 | dac_write_regs_t dac_write_regs; | ||
323 | void *data; | ||
324 | }; | ||
325 | |||
326 | |||
327 | static inline u8 dac_read_reg(struct dac_info *info, u8 reg) | ||
328 | { | ||
329 | u8 code[2] = {reg, 0}; | ||
330 | info->dac_read_regs(info->data, code, 1); | ||
331 | return code[1]; | ||
332 | } | ||
333 | |||
334 | static inline void dac_read_regs(struct dac_info *info, u8 *code, int count) | ||
335 | { | ||
336 | info->dac_read_regs(info->data, code, count); | ||
337 | } | ||
338 | |||
339 | static inline void dac_write_reg(struct dac_info *info, u8 reg, u8 val) | ||
340 | { | ||
341 | u8 code[2] = {reg, val}; | ||
342 | info->dac_write_regs(info->data, code, 1); | ||
343 | } | ||
344 | |||
345 | static inline void dac_write_regs(struct dac_info *info, u8 *code, int count) | ||
346 | { | ||
347 | info->dac_write_regs(info->data, code, count); | ||
348 | } | ||
349 | |||
350 | static inline int dac_set_mode(struct dac_info *info, int mode) | ||
351 | { | ||
352 | return info->dacops->dac_set_mode(info, mode); | ||
353 | } | ||
354 | |||
355 | static inline int dac_set_freq(struct dac_info *info, int channel, u32 freq) | ||
356 | { | ||
357 | return info->dacops->dac_set_freq(info, channel, freq); | ||
358 | } | ||
359 | |||
360 | static inline void dac_release(struct dac_info *info) | ||
361 | { | ||
362 | info->dacops->dac_release(info); | ||
363 | } | ||
364 | |||
365 | |||
366 | /* ------------------------------------------------------------------------- */ | ||
367 | |||
368 | |||
369 | /* ICS5342 DAC */ | ||
370 | |||
371 | struct ics5342_info | ||
372 | { | ||
373 | struct dac_info dac; | ||
374 | u8 mode; | ||
375 | }; | ||
376 | |||
377 | #define DAC_PAR(info) ((struct ics5342_info *) info) | ||
378 | |||
379 | /* LSB is set to distinguish unused slots */ | ||
380 | static const u8 ics5342_mode_table[DAC_MAX] = { | ||
381 | [DAC_PSEUDO8_8] = 0x01, [DAC_RGB1555_8] = 0x21, [DAC_RGB0565_8] = 0x61, | ||
382 | [DAC_RGB0888_8] = 0x41, [DAC_PSEUDO8_16] = 0x11, [DAC_RGB1555_16] = 0x31, | ||
383 | [DAC_RGB0565_16] = 0x51, [DAC_RGB0888_16] = 0x91, [DAC_RGB8888_16] = 0x71 | ||
384 | }; | ||
385 | |||
386 | static int ics5342_set_mode(struct dac_info *info, int mode) | ||
387 | { | ||
388 | u8 code; | ||
389 | |||
390 | if (mode >= DAC_MAX) | ||
391 | return -EINVAL; | ||
392 | |||
393 | code = ics5342_mode_table[mode]; | ||
394 | |||
395 | if (! code) | ||
396 | return -EINVAL; | ||
397 | |||
398 | dac_write_reg(info, 6, code & 0xF0); | ||
399 | DAC_PAR(info)->mode = mode; | ||
400 | |||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | static const struct svga_pll ics5342_pll = {3, 129, 3, 33, 0, 3, | ||
405 | 60000, 250000, 14318}; | ||
406 | |||
407 | /* pd4 - allow only posdivider 4 (r=2) */ | ||
408 | static const struct svga_pll ics5342_pll_pd4 = {3, 129, 3, 33, 2, 2, | ||
409 | 60000, 335000, 14318}; | ||
410 | |||
411 | /* 270 MHz should be upper bound for VCO clock according to specs, | ||
412 | but that is too restrictive in pd4 case */ | ||
413 | |||
414 | static int ics5342_set_freq(struct dac_info *info, int channel, u32 freq) | ||
415 | { | ||
416 | u16 m, n, r; | ||
417 | |||
418 | /* only postdivider 4 (r=2) is valid in mode DAC_PSEUDO8_16 */ | ||
419 | int rv = svga_compute_pll((DAC_PAR(info)->mode == DAC_PSEUDO8_16) | ||
420 | ? &ics5342_pll_pd4 : &ics5342_pll, | ||
421 | freq, &m, &n, &r, 0); | ||
422 | |||
423 | if (rv < 0) { | ||
424 | return -EINVAL; | ||
425 | } else { | ||
426 | u8 code[6] = {4, 3, 5, m-2, 5, (n-2) | (r << 5)}; | ||
427 | dac_write_regs(info, code, 3); | ||
428 | return 0; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | static void ics5342_release(struct dac_info *info) | ||
433 | { | ||
434 | ics5342_set_mode(info, DAC_PSEUDO8_8); | ||
435 | kfree(info); | ||
436 | } | ||
437 | |||
438 | static struct dac_ops ics5342_ops = { | ||
439 | .dac_set_mode = ics5342_set_mode, | ||
440 | .dac_set_freq = ics5342_set_freq, | ||
441 | .dac_release = ics5342_release | ||
442 | }; | ||
443 | |||
444 | |||
445 | static struct dac_info * ics5342_init(dac_read_regs_t drr, dac_write_regs_t dwr, void *data) | ||
446 | { | ||
447 | struct dac_info *info = kzalloc(sizeof(struct ics5342_info), GFP_KERNEL); | ||
448 | |||
449 | if (! info) | ||
450 | return NULL; | ||
451 | |||
452 | info->dacops = &ics5342_ops; | ||
453 | info->dac_read_regs = drr; | ||
454 | info->dac_write_regs = dwr; | ||
455 | info->data = data; | ||
456 | DAC_PAR(info)->mode = DAC_PSEUDO8_8; /* estimation */ | ||
457 | return info; | ||
458 | } | ||
459 | |||
460 | |||
461 | /* ------------------------------------------------------------------------- */ | ||
462 | |||
463 | |||
464 | static unsigned short dac_regs[4] = {0x3c8, 0x3c9, 0x3c6, 0x3c7}; | ||
465 | |||
466 | static void ark_dac_read_regs(void *data, u8 *code, int count) | ||
467 | { | ||
468 | u8 regval = vga_rseq(NULL, 0x1C); | ||
469 | |||
470 | while (count != 0) | ||
471 | { | ||
472 | vga_wseq(NULL, 0x1C, regval | (code[0] & 4) ? 0x80 : 0); | ||
473 | code[1] = vga_r(NULL, dac_regs[code[0] & 3]); | ||
474 | count--; | ||
475 | code += 2; | ||
476 | } | ||
477 | |||
478 | vga_wseq(NULL, 0x1C, regval); | ||
479 | } | ||
480 | |||
481 | static void ark_dac_write_regs(void *data, u8 *code, int count) | ||
482 | { | ||
483 | u8 regval = vga_rseq(NULL, 0x1C); | ||
484 | |||
485 | while (count != 0) | ||
486 | { | ||
487 | vga_wseq(NULL, 0x1C, regval | (code[0] & 4) ? 0x80 : 0); | ||
488 | vga_w(NULL, dac_regs[code[0] & 3], code[1]); | ||
489 | count--; | ||
490 | code += 2; | ||
491 | } | ||
492 | |||
493 | vga_wseq(NULL, 0x1C, regval); | ||
494 | } | ||
495 | |||
496 | |||
497 | static void ark_set_pixclock(struct fb_info *info, u32 pixclock) | ||
498 | { | ||
499 | struct arkfb_info *par = info->par; | ||
500 | u8 regval; | ||
501 | |||
502 | int rv = dac_set_freq(par->dac, 0, 1000000000 / pixclock); | ||
503 | if (rv < 0) { | ||
504 | printk(KERN_ERR "fb%d: cannot set requested pixclock, keeping old value\n", info->node); | ||
505 | return; | ||
506 | } | ||
507 | |||
508 | /* Set VGA misc register */ | ||
509 | regval = vga_r(NULL, VGA_MIS_R); | ||
510 | vga_w(NULL, VGA_MIS_W, regval | VGA_MIS_ENB_PLL_LOAD); | ||
511 | } | ||
512 | |||
513 | |||
514 | /* Open framebuffer */ | ||
515 | |||
516 | static int arkfb_open(struct fb_info *info, int user) | ||
517 | { | ||
518 | struct arkfb_info *par = info->par; | ||
519 | |||
520 | mutex_lock(&(par->open_lock)); | ||
521 | if (par->ref_count == 0) { | ||
522 | memset(&(par->state), 0, sizeof(struct vgastate)); | ||
523 | par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS | VGA_SAVE_CMAP; | ||
524 | par->state.num_crtc = 0x60; | ||
525 | par->state.num_seq = 0x30; | ||
526 | save_vga(&(par->state)); | ||
527 | } | ||
528 | |||
529 | par->ref_count++; | ||
530 | mutex_unlock(&(par->open_lock)); | ||
531 | |||
532 | return 0; | ||
533 | } | ||
534 | |||
535 | /* Close framebuffer */ | ||
536 | |||
537 | static int arkfb_release(struct fb_info *info, int user) | ||
538 | { | ||
539 | struct arkfb_info *par = info->par; | ||
540 | |||
541 | mutex_lock(&(par->open_lock)); | ||
542 | if (par->ref_count == 0) { | ||
543 | mutex_unlock(&(par->open_lock)); | ||
544 | return -EINVAL; | ||
545 | } | ||
546 | |||
547 | if (par->ref_count == 1) { | ||
548 | restore_vga(&(par->state)); | ||
549 | dac_set_mode(par->dac, DAC_PSEUDO8_8); | ||
550 | } | ||
551 | |||
552 | par->ref_count--; | ||
553 | mutex_unlock(&(par->open_lock)); | ||
554 | |||
555 | return 0; | ||
556 | } | ||
557 | |||
558 | /* Validate passed in var */ | ||
559 | |||
560 | static int arkfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | ||
561 | { | ||
562 | int rv, mem, step; | ||
563 | |||
564 | /* Find appropriate format */ | ||
565 | rv = svga_match_format (arkfb_formats, var, NULL); | ||
566 | if (rv < 0) | ||
567 | { | ||
568 | printk(KERN_ERR "fb%d: unsupported mode requested\n", info->node); | ||
569 | return rv; | ||
570 | } | ||
571 | |||
572 | /* Do not allow to have real resoulution larger than virtual */ | ||
573 | if (var->xres > var->xres_virtual) | ||
574 | var->xres_virtual = var->xres; | ||
575 | |||
576 | if (var->yres > var->yres_virtual) | ||
577 | var->yres_virtual = var->yres; | ||
578 | |||
579 | /* Round up xres_virtual to have proper alignment of lines */ | ||
580 | step = arkfb_formats[rv].xresstep - 1; | ||
581 | var->xres_virtual = (var->xres_virtual+step) & ~step; | ||
582 | |||
583 | |||
584 | /* Check whether have enough memory */ | ||
585 | mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual; | ||
586 | if (mem > info->screen_size) | ||
587 | { | ||
588 | printk(KERN_ERR "fb%d: not enough framebuffer memory (%d kB requested , %d kB available)\n", info->node, mem >> 10, (unsigned int) (info->screen_size >> 10)); | ||
589 | return -EINVAL; | ||
590 | } | ||
591 | |||
592 | rv = svga_check_timings (&ark_timing_regs, var, info->node); | ||
593 | if (rv < 0) | ||
594 | { | ||
595 | printk(KERN_ERR "fb%d: invalid timings requested\n", info->node); | ||
596 | return rv; | ||
597 | } | ||
598 | |||
599 | /* Interlaced mode is broken */ | ||
600 | if (var->vmode & FB_VMODE_INTERLACED) | ||
601 | return -EINVAL; | ||
602 | |||
603 | return 0; | ||
604 | } | ||
605 | |||
606 | /* Set video mode from par */ | ||
607 | |||
608 | static int arkfb_set_par(struct fb_info *info) | ||
609 | { | ||
610 | struct arkfb_info *par = info->par; | ||
611 | u32 value, mode, hmul, hdiv, offset_value, screen_size; | ||
612 | u32 bpp = info->var.bits_per_pixel; | ||
613 | u8 regval; | ||
614 | |||
615 | if (bpp != 0) { | ||
616 | info->fix.ypanstep = 1; | ||
617 | info->fix.line_length = (info->var.xres_virtual * bpp) / 8; | ||
618 | |||
619 | info->flags &= ~FBINFO_MISC_TILEBLITTING; | ||
620 | info->tileops = NULL; | ||
621 | |||
622 | /* in 4bpp supports 8p wide tiles only, any tiles otherwise */ | ||
623 | info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0); | ||
624 | info->pixmap.blit_y = ~(u32)0; | ||
625 | |||
626 | offset_value = (info->var.xres_virtual * bpp) / 64; | ||
627 | screen_size = info->var.yres_virtual * info->fix.line_length; | ||
628 | } else { | ||
629 | info->fix.ypanstep = 16; | ||
630 | info->fix.line_length = 0; | ||
631 | |||
632 | info->flags |= FBINFO_MISC_TILEBLITTING; | ||
633 | info->tileops = &arkfb_tile_ops; | ||
634 | |||
635 | /* supports 8x16 tiles only */ | ||
636 | info->pixmap.blit_x = 1 << (8 - 1); | ||
637 | info->pixmap.blit_y = 1 << (16 - 1); | ||
638 | |||
639 | offset_value = info->var.xres_virtual / 16; | ||
640 | screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64; | ||
641 | } | ||
642 | |||
643 | info->var.xoffset = 0; | ||
644 | info->var.yoffset = 0; | ||
645 | info->var.activate = FB_ACTIVATE_NOW; | ||
646 | |||
647 | /* Unlock registers */ | ||
648 | svga_wcrt_mask(0x11, 0x00, 0x80); | ||
649 | |||
650 | /* Blank screen and turn off sync */ | ||
651 | svga_wseq_mask(0x01, 0x20, 0x20); | ||
652 | svga_wcrt_mask(0x17, 0x00, 0x80); | ||
653 | |||
654 | /* Set default values */ | ||
655 | svga_set_default_gfx_regs(); | ||
656 | svga_set_default_atc_regs(); | ||
657 | svga_set_default_seq_regs(); | ||
658 | svga_set_default_crt_regs(); | ||
659 | svga_wcrt_multi(ark_line_compare_regs, 0xFFFFFFFF); | ||
660 | svga_wcrt_multi(ark_start_address_regs, 0); | ||
661 | |||
662 | /* ARK specific initialization */ | ||
663 | svga_wseq_mask(0x10, 0x1F, 0x1F); /* enable linear framebuffer and full memory access */ | ||
664 | svga_wseq_mask(0x12, 0x03, 0x03); /* 4 MB linear framebuffer size */ | ||
665 | |||
666 | vga_wseq(NULL, 0x13, info->fix.smem_start >> 16); | ||
667 | vga_wseq(NULL, 0x14, info->fix.smem_start >> 24); | ||
668 | vga_wseq(NULL, 0x15, 0); | ||
669 | vga_wseq(NULL, 0x16, 0); | ||
670 | |||
671 | /* Set the FIFO threshold register */ | ||
672 | /* It is fascinating way to store 5-bit value in 8-bit register */ | ||
673 | regval = 0x10 | ((threshold & 0x0E) >> 1) | (threshold & 0x01) << 7 | (threshold & 0x10) << 1; | ||
674 | vga_wseq(NULL, 0x18, regval); | ||
675 | |||
676 | /* Set the offset register */ | ||
677 | pr_debug("fb%d: offset register : %d\n", info->node, offset_value); | ||
678 | svga_wcrt_multi(ark_offset_regs, offset_value); | ||
679 | |||
680 | /* fix for hi-res textmode */ | ||
681 | svga_wcrt_mask(0x40, 0x08, 0x08); | ||
682 | |||
683 | if (info->var.vmode & FB_VMODE_DOUBLE) | ||
684 | svga_wcrt_mask(0x09, 0x80, 0x80); | ||
685 | else | ||
686 | svga_wcrt_mask(0x09, 0x00, 0x80); | ||
687 | |||
688 | if (info->var.vmode & FB_VMODE_INTERLACED) | ||
689 | svga_wcrt_mask(0x44, 0x04, 0x04); | ||
690 | else | ||
691 | svga_wcrt_mask(0x44, 0x00, 0x04); | ||
692 | |||
693 | hmul = 1; | ||
694 | hdiv = 1; | ||
695 | mode = svga_match_format(arkfb_formats, &(info->var), &(info->fix)); | ||
696 | |||
697 | /* Set mode-specific register values */ | ||
698 | switch (mode) { | ||
699 | case 0: | ||
700 | pr_debug("fb%d: text mode\n", info->node); | ||
701 | svga_set_textmode_vga_regs(); | ||
702 | |||
703 | vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */ | ||
704 | svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */ | ||
705 | dac_set_mode(par->dac, DAC_PSEUDO8_8); | ||
706 | |||
707 | break; | ||
708 | case 1: | ||
709 | pr_debug("fb%d: 4 bit pseudocolor\n", info->node); | ||
710 | vga_wgfx(NULL, VGA_GFX_MODE, 0x40); | ||
711 | |||
712 | vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */ | ||
713 | svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */ | ||
714 | dac_set_mode(par->dac, DAC_PSEUDO8_8); | ||
715 | break; | ||
716 | case 2: | ||
717 | pr_debug("fb%d: 4 bit pseudocolor, planar\n", info->node); | ||
718 | |||
719 | vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */ | ||
720 | svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */ | ||
721 | dac_set_mode(par->dac, DAC_PSEUDO8_8); | ||
722 | break; | ||
723 | case 3: | ||
724 | pr_debug("fb%d: 8 bit pseudocolor\n", info->node); | ||
725 | |||
726 | vga_wseq(NULL, 0x11, 0x16); /* 8bpp accel mode */ | ||
727 | |||
728 | if (info->var.pixclock > 20000) { | ||
729 | pr_debug("fb%d: not using multiplex\n", info->node); | ||
730 | svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */ | ||
731 | dac_set_mode(par->dac, DAC_PSEUDO8_8); | ||
732 | } else { | ||
733 | pr_debug("fb%d: using multiplex\n", info->node); | ||
734 | svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */ | ||
735 | dac_set_mode(par->dac, DAC_PSEUDO8_16); | ||
736 | hdiv = 2; | ||
737 | } | ||
738 | break; | ||
739 | case 4: | ||
740 | pr_debug("fb%d: 5/5/5 truecolor\n", info->node); | ||
741 | |||
742 | vga_wseq(NULL, 0x11, 0x1A); /* 16bpp accel mode */ | ||
743 | svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */ | ||
744 | dac_set_mode(par->dac, DAC_RGB1555_16); | ||
745 | break; | ||
746 | case 5: | ||
747 | pr_debug("fb%d: 5/6/5 truecolor\n", info->node); | ||
748 | |||
749 | vga_wseq(NULL, 0x11, 0x1A); /* 16bpp accel mode */ | ||
750 | svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */ | ||
751 | dac_set_mode(par->dac, DAC_RGB0565_16); | ||
752 | break; | ||
753 | case 6: | ||
754 | pr_debug("fb%d: 8/8/8 truecolor\n", info->node); | ||
755 | |||
756 | vga_wseq(NULL, 0x11, 0x16); /* 8bpp accel mode ??? */ | ||
757 | svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */ | ||
758 | dac_set_mode(par->dac, DAC_RGB0888_16); | ||
759 | hmul = 3; | ||
760 | hdiv = 2; | ||
761 | break; | ||
762 | case 7: | ||
763 | pr_debug("fb%d: 8/8/8/8 truecolor\n", info->node); | ||
764 | |||
765 | vga_wseq(NULL, 0x11, 0x1E); /* 32bpp accel mode */ | ||
766 | svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */ | ||
767 | dac_set_mode(par->dac, DAC_RGB8888_16); | ||
768 | hmul = 2; | ||
769 | break; | ||
770 | default: | ||
771 | printk(KERN_ERR "fb%d: unsupported mode - bug\n", info->node); | ||
772 | return -EINVAL; | ||
773 | } | ||
774 | |||
775 | ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul); | ||
776 | svga_set_timings(&ark_timing_regs, &(info->var), hmul, hdiv, | ||
777 | (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, | ||
778 | (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1, | ||
779 | hmul, info->node); | ||
780 | |||
781 | /* Set interlaced mode start/end register */ | ||
782 | value = info->var.xres + info->var.left_margin + info->var.right_margin + info->var.hsync_len; | ||
783 | value = ((value * hmul / hdiv) / 8) - 5; | ||
784 | vga_wcrt(NULL, 0x42, (value + 1) / 2); | ||
785 | |||
786 | memset_io(info->screen_base, 0x00, screen_size); | ||
787 | /* Device and screen back on */ | ||
788 | svga_wcrt_mask(0x17, 0x80, 0x80); | ||
789 | svga_wseq_mask(0x01, 0x00, 0x20); | ||
790 | |||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | /* Set a colour register */ | ||
795 | |||
796 | static int arkfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | ||
797 | u_int transp, struct fb_info *fb) | ||
798 | { | ||
799 | switch (fb->var.bits_per_pixel) { | ||
800 | case 0: | ||
801 | case 4: | ||
802 | if (regno >= 16) | ||
803 | return -EINVAL; | ||
804 | |||
805 | if ((fb->var.bits_per_pixel == 4) && | ||
806 | (fb->var.nonstd == 0)) { | ||
807 | outb(0xF0, VGA_PEL_MSK); | ||
808 | outb(regno*16, VGA_PEL_IW); | ||
809 | } else { | ||
810 | outb(0x0F, VGA_PEL_MSK); | ||
811 | outb(regno, VGA_PEL_IW); | ||
812 | } | ||
813 | outb(red >> 10, VGA_PEL_D); | ||
814 | outb(green >> 10, VGA_PEL_D); | ||
815 | outb(blue >> 10, VGA_PEL_D); | ||
816 | break; | ||
817 | case 8: | ||
818 | if (regno >= 256) | ||
819 | return -EINVAL; | ||
820 | |||
821 | outb(0xFF, VGA_PEL_MSK); | ||
822 | outb(regno, VGA_PEL_IW); | ||
823 | outb(red >> 10, VGA_PEL_D); | ||
824 | outb(green >> 10, VGA_PEL_D); | ||
825 | outb(blue >> 10, VGA_PEL_D); | ||
826 | break; | ||
827 | case 16: | ||
828 | if (regno >= 16) | ||
829 | return 0; | ||
830 | |||
831 | if (fb->var.green.length == 5) | ||
832 | ((u32*)fb->pseudo_palette)[regno] = ((red & 0xF800) >> 1) | | ||
833 | ((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11); | ||
834 | else if (fb->var.green.length == 6) | ||
835 | ((u32*)fb->pseudo_palette)[regno] = (red & 0xF800) | | ||
836 | ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11); | ||
837 | else | ||
838 | return -EINVAL; | ||
839 | break; | ||
840 | case 24: | ||
841 | case 32: | ||
842 | if (regno >= 16) | ||
843 | return 0; | ||
844 | |||
845 | ((u32*)fb->pseudo_palette)[regno] = ((red & 0xFF00) << 8) | | ||
846 | (green & 0xFF00) | ((blue & 0xFF00) >> 8); | ||
847 | break; | ||
848 | default: | ||
849 | return -EINVAL; | ||
850 | } | ||
851 | |||
852 | return 0; | ||
853 | } | ||
854 | |||
855 | /* Set the display blanking state */ | ||
856 | |||
857 | static int arkfb_blank(int blank_mode, struct fb_info *info) | ||
858 | { | ||
859 | switch (blank_mode) { | ||
860 | case FB_BLANK_UNBLANK: | ||
861 | pr_debug("fb%d: unblank\n", info->node); | ||
862 | svga_wseq_mask(0x01, 0x00, 0x20); | ||
863 | svga_wcrt_mask(0x17, 0x80, 0x80); | ||
864 | break; | ||
865 | case FB_BLANK_NORMAL: | ||
866 | pr_debug("fb%d: blank\n", info->node); | ||
867 | svga_wseq_mask(0x01, 0x20, 0x20); | ||
868 | svga_wcrt_mask(0x17, 0x80, 0x80); | ||
869 | break; | ||
870 | case FB_BLANK_POWERDOWN: | ||
871 | case FB_BLANK_HSYNC_SUSPEND: | ||
872 | case FB_BLANK_VSYNC_SUSPEND: | ||
873 | pr_debug("fb%d: sync down\n", info->node); | ||
874 | svga_wseq_mask(0x01, 0x20, 0x20); | ||
875 | svga_wcrt_mask(0x17, 0x00, 0x80); | ||
876 | break; | ||
877 | } | ||
878 | return 0; | ||
879 | } | ||
880 | |||
881 | |||
882 | /* Pan the display */ | ||
883 | |||
884 | static int arkfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) | ||
885 | { | ||
886 | unsigned int offset; | ||
887 | |||
888 | /* Calculate the offset */ | ||
889 | if (var->bits_per_pixel == 0) { | ||
890 | offset = (var->yoffset / 16) * (var->xres_virtual / 2) + (var->xoffset / 2); | ||
891 | offset = offset >> 2; | ||
892 | } else { | ||
893 | offset = (var->yoffset * info->fix.line_length) + | ||
894 | (var->xoffset * var->bits_per_pixel / 8); | ||
895 | offset = offset >> ((var->bits_per_pixel == 4) ? 2 : 3); | ||
896 | } | ||
897 | |||
898 | /* Set the offset */ | ||
899 | svga_wcrt_multi(ark_start_address_regs, offset); | ||
900 | |||
901 | return 0; | ||
902 | } | ||
903 | |||
904 | |||
905 | /* ------------------------------------------------------------------------- */ | ||
906 | |||
907 | |||
908 | /* Frame buffer operations */ | ||
909 | |||
910 | static struct fb_ops arkfb_ops = { | ||
911 | .owner = THIS_MODULE, | ||
912 | .fb_open = arkfb_open, | ||
913 | .fb_release = arkfb_release, | ||
914 | .fb_check_var = arkfb_check_var, | ||
915 | .fb_set_par = arkfb_set_par, | ||
916 | .fb_setcolreg = arkfb_setcolreg, | ||
917 | .fb_blank = arkfb_blank, | ||
918 | .fb_pan_display = arkfb_pan_display, | ||
919 | .fb_fillrect = arkfb_fillrect, | ||
920 | .fb_copyarea = cfb_copyarea, | ||
921 | .fb_imageblit = arkfb_imageblit, | ||
922 | .fb_get_caps = svga_get_caps, | ||
923 | }; | ||
924 | |||
925 | |||
926 | /* ------------------------------------------------------------------------- */ | ||
927 | |||
928 | |||
929 | /* PCI probe */ | ||
930 | static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | ||
931 | { | ||
932 | struct fb_info *info; | ||
933 | struct arkfb_info *par; | ||
934 | int rc; | ||
935 | u8 regval; | ||
936 | |||
937 | /* Ignore secondary VGA device because there is no VGA arbitration */ | ||
938 | if (! svga_primary_device(dev)) { | ||
939 | dev_info(&(dev->dev), "ignoring secondary device\n"); | ||
940 | return -ENODEV; | ||
941 | } | ||
942 | |||
943 | /* Allocate and fill driver data structure */ | ||
944 | info = framebuffer_alloc(sizeof(struct arkfb_info), NULL); | ||
945 | if (! info) { | ||
946 | dev_err(&(dev->dev), "cannot allocate memory\n"); | ||
947 | return -ENOMEM; | ||
948 | } | ||
949 | |||
950 | par = info->par; | ||
951 | mutex_init(&par->open_lock); | ||
952 | |||
953 | info->flags = FBINFO_PARTIAL_PAN_OK | FBINFO_HWACCEL_YPAN; | ||
954 | info->fbops = &arkfb_ops; | ||
955 | |||
956 | /* Prepare PCI device */ | ||
957 | rc = pci_enable_device(dev); | ||
958 | if (rc < 0) { | ||
959 | dev_err(&(dev->dev), "cannot enable PCI device\n"); | ||
960 | goto err_enable_device; | ||
961 | } | ||
962 | |||
963 | rc = pci_request_regions(dev, "arkfb"); | ||
964 | if (rc < 0) { | ||
965 | dev_err(&(dev->dev), "cannot reserve framebuffer region\n"); | ||
966 | goto err_request_regions; | ||
967 | } | ||
968 | |||
969 | par->dac = ics5342_init(ark_dac_read_regs, ark_dac_write_regs, info); | ||
970 | if (! par->dac) { | ||
971 | rc = -ENOMEM; | ||
972 | dev_err(&(dev->dev), "RAMDAC initialization failed\n"); | ||
973 | goto err_dac; | ||
974 | } | ||
975 | |||
976 | info->fix.smem_start = pci_resource_start(dev, 0); | ||
977 | info->fix.smem_len = pci_resource_len(dev, 0); | ||
978 | |||
979 | /* Map physical IO memory address into kernel space */ | ||
980 | info->screen_base = pci_iomap(dev, 0, 0); | ||
981 | if (! info->screen_base) { | ||
982 | rc = -ENOMEM; | ||
983 | dev_err(&(dev->dev), "iomap for framebuffer failed\n"); | ||
984 | goto err_iomap; | ||
985 | } | ||
986 | |||
987 | /* FIXME get memsize */ | ||
988 | regval = vga_rseq(NULL, 0x10); | ||
989 | info->screen_size = (1 << (regval >> 6)) << 20; | ||
990 | info->fix.smem_len = info->screen_size; | ||
991 | |||
992 | strcpy(info->fix.id, "ARK 2000PV"); | ||
993 | info->fix.mmio_start = 0; | ||
994 | info->fix.mmio_len = 0; | ||
995 | info->fix.type = FB_TYPE_PACKED_PIXELS; | ||
996 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
997 | info->fix.ypanstep = 0; | ||
998 | info->fix.accel = FB_ACCEL_NONE; | ||
999 | info->pseudo_palette = (void*) (par->pseudo_palette); | ||
1000 | |||
1001 | /* Prepare startup mode */ | ||
1002 | rc = fb_find_mode(&(info->var), info, mode, NULL, 0, NULL, 8); | ||
1003 | if (! ((rc == 1) || (rc == 2))) { | ||
1004 | rc = -EINVAL; | ||
1005 | dev_err(&(dev->dev), "mode %s not found\n", mode); | ||
1006 | goto err_find_mode; | ||
1007 | } | ||
1008 | |||
1009 | rc = fb_alloc_cmap(&info->cmap, 256, 0); | ||
1010 | if (rc < 0) { | ||
1011 | dev_err(&(dev->dev), "cannot allocate colormap\n"); | ||
1012 | goto err_alloc_cmap; | ||
1013 | } | ||
1014 | |||
1015 | rc = register_framebuffer(info); | ||
1016 | if (rc < 0) { | ||
1017 | dev_err(&(dev->dev), "cannot register framebugger\n"); | ||
1018 | goto err_reg_fb; | ||
1019 | } | ||
1020 | |||
1021 | printk(KERN_INFO "fb%d: %s on %s, %d MB RAM\n", info->node, info->fix.id, | ||
1022 | pci_name(dev), info->fix.smem_len >> 20); | ||
1023 | |||
1024 | /* Record a reference to the driver data */ | ||
1025 | pci_set_drvdata(dev, info); | ||
1026 | |||
1027 | #ifdef CONFIG_MTRR | ||
1028 | if (mtrr) { | ||
1029 | par->mtrr_reg = -1; | ||
1030 | par->mtrr_reg = mtrr_add(info->fix.smem_start, info->fix.smem_len, MTRR_TYPE_WRCOMB, 1); | ||
1031 | } | ||
1032 | #endif | ||
1033 | |||
1034 | return 0; | ||
1035 | |||
1036 | /* Error handling */ | ||
1037 | err_reg_fb: | ||
1038 | fb_dealloc_cmap(&info->cmap); | ||
1039 | err_alloc_cmap: | ||
1040 | err_find_mode: | ||
1041 | pci_iounmap(dev, info->screen_base); | ||
1042 | err_iomap: | ||
1043 | dac_release(par->dac); | ||
1044 | err_dac: | ||
1045 | pci_release_regions(dev); | ||
1046 | err_request_regions: | ||
1047 | /* pci_disable_device(dev); */ | ||
1048 | err_enable_device: | ||
1049 | framebuffer_release(info); | ||
1050 | return rc; | ||
1051 | } | ||
1052 | |||
1053 | /* PCI remove */ | ||
1054 | |||
1055 | static void __devexit ark_pci_remove(struct pci_dev *dev) | ||
1056 | { | ||
1057 | struct fb_info *info = pci_get_drvdata(dev); | ||
1058 | struct arkfb_info *par = info->par; | ||
1059 | |||
1060 | if (info) { | ||
1061 | #ifdef CONFIG_MTRR | ||
1062 | if (par->mtrr_reg >= 0) { | ||
1063 | mtrr_del(par->mtrr_reg, 0, 0); | ||
1064 | par->mtrr_reg = -1; | ||
1065 | } | ||
1066 | #endif | ||
1067 | |||
1068 | dac_release(par->dac); | ||
1069 | unregister_framebuffer(info); | ||
1070 | fb_dealloc_cmap(&info->cmap); | ||
1071 | |||
1072 | pci_iounmap(dev, info->screen_base); | ||
1073 | pci_release_regions(dev); | ||
1074 | /* pci_disable_device(dev); */ | ||
1075 | |||
1076 | pci_set_drvdata(dev, NULL); | ||
1077 | framebuffer_release(info); | ||
1078 | } | ||
1079 | } | ||
1080 | |||
1081 | |||
1082 | #ifdef CONFIG_PM | ||
1083 | /* PCI suspend */ | ||
1084 | |||
1085 | static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state) | ||
1086 | { | ||
1087 | struct fb_info *info = pci_get_drvdata(dev); | ||
1088 | struct arkfb_info *par = info->par; | ||
1089 | |||
1090 | dev_info(&(dev->dev), "suspend\n"); | ||
1091 | |||
1092 | acquire_console_sem(); | ||
1093 | mutex_lock(&(par->open_lock)); | ||
1094 | |||
1095 | if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { | ||
1096 | mutex_unlock(&(par->open_lock)); | ||
1097 | release_console_sem(); | ||
1098 | return 0; | ||
1099 | } | ||
1100 | |||
1101 | fb_set_suspend(info, 1); | ||
1102 | |||
1103 | pci_save_state(dev); | ||
1104 | pci_disable_device(dev); | ||
1105 | pci_set_power_state(dev, pci_choose_state(dev, state)); | ||
1106 | |||
1107 | mutex_unlock(&(par->open_lock)); | ||
1108 | release_console_sem(); | ||
1109 | |||
1110 | return 0; | ||
1111 | } | ||
1112 | |||
1113 | |||
1114 | /* PCI resume */ | ||
1115 | |||
1116 | static int ark_pci_resume (struct pci_dev* dev) | ||
1117 | { | ||
1118 | struct fb_info *info = pci_get_drvdata(dev); | ||
1119 | struct arkfb_info *par = info->par; | ||
1120 | |||
1121 | dev_info(&(dev->dev), "resume\n"); | ||
1122 | |||
1123 | acquire_console_sem(); | ||
1124 | mutex_lock(&(par->open_lock)); | ||
1125 | |||
1126 | if (par->ref_count == 0) { | ||
1127 | mutex_unlock(&(par->open_lock)); | ||
1128 | release_console_sem(); | ||
1129 | return 0; | ||
1130 | } | ||
1131 | |||
1132 | pci_set_power_state(dev, PCI_D0); | ||
1133 | pci_restore_state(dev); | ||
1134 | |||
1135 | if (pci_enable_device(dev)) | ||
1136 | goto fail; | ||
1137 | |||
1138 | pci_set_master(dev); | ||
1139 | |||
1140 | arkfb_set_par(info); | ||
1141 | fb_set_suspend(info, 0); | ||
1142 | |||
1143 | mutex_unlock(&(par->open_lock)); | ||
1144 | fail: | ||
1145 | release_console_sem(); | ||
1146 | return 0; | ||
1147 | } | ||
1148 | #else | ||
1149 | #define ark_pci_suspend NULL | ||
1150 | #define ark_pci_resume NULL | ||
1151 | #endif /* CONFIG_PM */ | ||
1152 | |||
1153 | /* List of boards that we are trying to support */ | ||
1154 | |||
1155 | static struct pci_device_id ark_devices[] __devinitdata = { | ||
1156 | {PCI_DEVICE(0xEDD8, 0xA099)}, | ||
1157 | {0, 0, 0, 0, 0, 0, 0} | ||
1158 | }; | ||
1159 | |||
1160 | |||
1161 | MODULE_DEVICE_TABLE(pci, ark_devices); | ||
1162 | |||
1163 | static struct pci_driver arkfb_pci_driver = { | ||
1164 | .name = "arkfb", | ||
1165 | .id_table = ark_devices, | ||
1166 | .probe = ark_pci_probe, | ||
1167 | .remove = __devexit_p(ark_pci_remove), | ||
1168 | .suspend = ark_pci_suspend, | ||
1169 | .resume = ark_pci_resume, | ||
1170 | }; | ||
1171 | |||
1172 | /* Cleanup */ | ||
1173 | |||
1174 | static void __exit arkfb_cleanup(void) | ||
1175 | { | ||
1176 | pr_debug("arkfb: cleaning up\n"); | ||
1177 | pci_unregister_driver(&arkfb_pci_driver); | ||
1178 | } | ||
1179 | |||
1180 | /* Driver Initialisation */ | ||
1181 | |||
1182 | static int __init arkfb_init(void) | ||
1183 | { | ||
1184 | |||
1185 | #ifndef MODULE | ||
1186 | char *option = NULL; | ||
1187 | |||
1188 | if (fb_get_options("arkfb", &option)) | ||
1189 | return -ENODEV; | ||
1190 | |||
1191 | if (option && *option) | ||
1192 | mode = option; | ||
1193 | #endif | ||
1194 | |||
1195 | pr_debug("arkfb: initializing\n"); | ||
1196 | return pci_register_driver(&arkfb_pci_driver); | ||
1197 | } | ||
1198 | |||
1199 | module_init(arkfb_init); | ||
1200 | module_exit(arkfb_cleanup); | ||
diff --git a/drivers/video/console/softcursor.c b/drivers/video/console/softcursor.c index f577bd80e020..03cfb7ac5733 100644 --- a/drivers/video/console/softcursor.c +++ b/drivers/video/console/softcursor.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/video/softcursor.c | 2 | * linux/drivers/video/console/softcursor.c |
3 | * | 3 | * |
4 | * Generic software cursor for frame buffer devices | 4 | * Generic software cursor for frame buffer devices |
5 | * | 5 | * |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 08d4e11d9121..38c2e2558f5e 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -1236,6 +1236,10 @@ fb_mmap(struct file *file, struct vm_area_struct * vma) | |||
1236 | pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; | 1236 | pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; |
1237 | #elif defined(__arm__) || defined(__sh__) || defined(__m32r__) | 1237 | #elif defined(__arm__) || defined(__sh__) || defined(__m32r__) |
1238 | vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); | 1238 | vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); |
1239 | #elif defined(__avr32__) | ||
1240 | vma->vm_page_prot = __pgprot((pgprot_val(vma->vm_page_prot) | ||
1241 | & ~_PAGE_CACHABLE) | ||
1242 | | (_PAGE_BUFFER | _PAGE_DIRTY)); | ||
1239 | #elif defined(__ia64__) | 1243 | #elif defined(__ia64__) |
1240 | if (efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start)) | 1244 | if (efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start)) |
1241 | vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); | 1245 | vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); |
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c index 7e760197cf29..1a7d7789d877 100644 --- a/drivers/video/i810/i810_main.c +++ b/drivers/video/i810/i810_main.c | |||
@@ -1717,7 +1717,7 @@ static int __devinit i810_alloc_agp_mem(struct fb_info *info) | |||
1717 | * @info: pointer to device specific info structure | 1717 | * @info: pointer to device specific info structure |
1718 | * | 1718 | * |
1719 | * DESCRIPTION: | 1719 | * DESCRIPTION: |
1720 | * Sets the the user monitor's horizontal and vertical | 1720 | * Sets the user monitor's horizontal and vertical |
1721 | * frequency limits | 1721 | * frequency limits |
1722 | */ | 1722 | */ |
1723 | static void __devinit i810_init_monspecs(struct fb_info *info) | 1723 | static void __devinit i810_init_monspecs(struct fb_info *info) |
diff --git a/drivers/video/matrox/matroxfb_Ti3026.c b/drivers/video/matrox/matroxfb_Ti3026.c index a5690a5f29d5..9445cdb759b1 100644 --- a/drivers/video/matrox/matroxfb_Ti3026.c +++ b/drivers/video/matrox/matroxfb_Ti3026.c | |||
@@ -72,7 +72,7 @@ | |||
72 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> | 72 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> |
73 | * | 73 | * |
74 | * (following author is not in any relation with this code, but his ideas | 74 | * (following author is not in any relation with this code, but his ideas |
75 | * were used when writting this driver) | 75 | * were used when writing this driver) |
76 | * | 76 | * |
77 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> | 77 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> |
78 | * | 78 | * |
diff --git a/drivers/video/matrox/matroxfb_accel.c b/drivers/video/matrox/matroxfb_accel.c index a5c825d99466..c57aaadf410c 100644 --- a/drivers/video/matrox/matroxfb_accel.c +++ b/drivers/video/matrox/matroxfb_accel.c | |||
@@ -70,7 +70,7 @@ | |||
70 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> | 70 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> |
71 | * | 71 | * |
72 | * (following author is not in any relation with this code, but his ideas | 72 | * (following author is not in any relation with this code, but his ideas |
73 | * were used when writting this driver) | 73 | * were used when writing this driver) |
74 | * | 74 | * |
75 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> | 75 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> |
76 | * | 76 | * |
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c index cb2aa402ddfd..c8559a756b75 100644 --- a/drivers/video/matrox/matroxfb_base.c +++ b/drivers/video/matrox/matroxfb_base.c | |||
@@ -93,7 +93,7 @@ | |||
93 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> | 93 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> |
94 | * | 94 | * |
95 | * (following author is not in any relation with this code, but his ideas | 95 | * (following author is not in any relation with this code, but his ideas |
96 | * were used when writting this driver) | 96 | * were used when writing this driver) |
97 | * | 97 | * |
98 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> | 98 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> |
99 | * | 99 | * |
diff --git a/drivers/video/matrox/matroxfb_misc.c b/drivers/video/matrox/matroxfb_misc.c index 18886b629cb1..5948e54b9ef9 100644 --- a/drivers/video/matrox/matroxfb_misc.c +++ b/drivers/video/matrox/matroxfb_misc.c | |||
@@ -78,7 +78,7 @@ | |||
78 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> | 78 | * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> |
79 | * | 79 | * |
80 | * (following author is not in any relation with this code, but his ideas | 80 | * (following author is not in any relation with this code, but his ideas |
81 | * were used when writting this driver) | 81 | * were used when writing this driver) |
82 | * | 82 | * |
83 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> | 83 | * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> |
84 | * | 84 | * |
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c index f297c7b14a41..c627955aa124 100644 --- a/drivers/video/nvidia/nv_hw.c +++ b/drivers/video/nvidia/nv_hw.c | |||
@@ -149,8 +149,7 @@ static void nvGetClocks(struct nvidia_par *par, unsigned int *MClk, | |||
149 | pll = NV_RD32(par->PMC, 0x4024); | 149 | pll = NV_RD32(par->PMC, 0x4024); |
150 | M = pll & 0xFF; | 150 | M = pll & 0xFF; |
151 | N = (pll >> 8) & 0xFF; | 151 | N = (pll >> 8) & 0xFF; |
152 | if (((par->Chipset & 0xfff0) == 0x0290) || | 152 | if (((par->Chipset & 0xfff0) == 0x0290) || ((par->Chipset & 0xfff0) == 0x0390) || ((par->Chipset & 0xfff0) == 0x02E0)) { |
153 | ((par->Chipset & 0xfff0) == 0x0390)) { | ||
154 | MB = 1; | 153 | MB = 1; |
155 | NB = 1; | 154 | NB = 1; |
156 | } else { | 155 | } else { |
@@ -963,6 +962,7 @@ void NVLoadStateExt(struct nvidia_par *par, RIVA_HW_STATE * state) | |||
963 | 962 | ||
964 | if (((par->Chipset & 0xfff0) == 0x0090) || | 963 | if (((par->Chipset & 0xfff0) == 0x0090) || |
965 | ((par->Chipset & 0xfff0) == 0x01D0) || | 964 | ((par->Chipset & 0xfff0) == 0x01D0) || |
965 | ((par->Chipset & 0xfff0) == 0x02E0) || | ||
966 | ((par->Chipset & 0xfff0) == 0x0290)) | 966 | ((par->Chipset & 0xfff0) == 0x0290)) |
967 | regions = 15; | 967 | regions = 15; |
968 | for(i = 0; i < regions; i++) { | 968 | for(i = 0; i < regions; i++) { |
@@ -1275,6 +1275,7 @@ void NVLoadStateExt(struct nvidia_par *par, RIVA_HW_STATE * state) | |||
1275 | 0x00100000); | 1275 | 0x00100000); |
1276 | break; | 1276 | break; |
1277 | case 0x0090: | 1277 | case 0x0090: |
1278 | case 0x02E0: | ||
1278 | case 0x0290: | 1279 | case 0x0290: |
1279 | NV_WR32(par->PRAMDAC, 0x0608, | 1280 | NV_WR32(par->PRAMDAC, 0x0608, |
1280 | NV_RD32(par->PRAMDAC, 0x0608) | | 1281 | NV_RD32(par->PRAMDAC, 0x0608) | |
@@ -1352,6 +1353,7 @@ void NVLoadStateExt(struct nvidia_par *par, RIVA_HW_STATE * state) | |||
1352 | } else { | 1353 | } else { |
1353 | if (((par->Chipset & 0xfff0) == 0x0090) || | 1354 | if (((par->Chipset & 0xfff0) == 0x0090) || |
1354 | ((par->Chipset & 0xfff0) == 0x01D0) || | 1355 | ((par->Chipset & 0xfff0) == 0x01D0) || |
1356 | ((par->Chipset & 0xfff0) == 0x02E0) || | ||
1355 | ((par->Chipset & 0xfff0) == 0x0290)) { | 1357 | ((par->Chipset & 0xfff0) == 0x0290)) { |
1356 | for (i = 0; i < 60; i++) { | 1358 | for (i = 0; i < 60; i++) { |
1357 | NV_WR32(par->PGRAPH, | 1359 | NV_WR32(par->PGRAPH, |
@@ -1403,6 +1405,7 @@ void NVLoadStateExt(struct nvidia_par *par, RIVA_HW_STATE * state) | |||
1403 | } else { | 1405 | } else { |
1404 | if ((par->Chipset & 0xfff0) == 0x0090 || | 1406 | if ((par->Chipset & 0xfff0) == 0x0090 || |
1405 | (par->Chipset & 0xfff0) == 0x01D0 || | 1407 | (par->Chipset & 0xfff0) == 0x01D0 || |
1408 | (par->Chipset & 0xfff0) == 0x02E0 || | ||
1406 | (par->Chipset & 0xfff0) == 0x0290) { | 1409 | (par->Chipset & 0xfff0) == 0x0290) { |
1407 | NV_WR32(par->PGRAPH, 0x0DF0, | 1410 | NV_WR32(par->PGRAPH, 0x0DF0, |
1408 | NV_RD32(par->PFB, 0x0200)); | 1411 | NV_RD32(par->PFB, 0x0200)); |
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c index 7c36b5fe582e..f85edf084da3 100644 --- a/drivers/video/nvidia/nvidia.c +++ b/drivers/video/nvidia/nvidia.c | |||
@@ -1243,6 +1243,7 @@ static u32 __devinit nvidia_get_arch(struct fb_info *info) | |||
1243 | case 0x0140: /* GeForce 6600 */ | 1243 | case 0x0140: /* GeForce 6600 */ |
1244 | case 0x0160: /* GeForce 6200 */ | 1244 | case 0x0160: /* GeForce 6200 */ |
1245 | case 0x01D0: /* GeForce 7200, 7300, 7400 */ | 1245 | case 0x01D0: /* GeForce 7200, 7300, 7400 */ |
1246 | case 0x02E0: /* GeForce 7300 GT */ | ||
1246 | case 0x0090: /* GeForce 7800 */ | 1247 | case 0x0090: /* GeForce 7800 */ |
1247 | case 0x0210: /* GeForce 6800 */ | 1248 | case 0x0210: /* GeForce 6800 */ |
1248 | case 0x0220: /* GeForce 6200 */ | 1249 | case 0x0220: /* GeForce 6200 */ |
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c index 756fafb41d78..d11735895a01 100644 --- a/drivers/video/s3fb.c +++ b/drivers/video/s3fb.c | |||
@@ -796,23 +796,6 @@ static int s3fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) | |||
796 | return 0; | 796 | return 0; |
797 | } | 797 | } |
798 | 798 | ||
799 | /* Get capabilities of accelerator based on the mode */ | ||
800 | |||
801 | static void s3fb_get_caps(struct fb_info *info, struct fb_blit_caps *caps, | ||
802 | struct fb_var_screeninfo *var) | ||
803 | { | ||
804 | if (var->bits_per_pixel == 0) { | ||
805 | /* can only support 256 8x16 bitmap */ | ||
806 | caps->x = 1 << (8 - 1); | ||
807 | caps->y = 1 << (16 - 1); | ||
808 | caps->len = 256; | ||
809 | } else { | ||
810 | caps->x = ~(u32)0; | ||
811 | caps->y = ~(u32)0; | ||
812 | caps->len = ~(u32)0; | ||
813 | } | ||
814 | } | ||
815 | |||
816 | /* ------------------------------------------------------------------------- */ | 799 | /* ------------------------------------------------------------------------- */ |
817 | 800 | ||
818 | /* Frame buffer operations */ | 801 | /* Frame buffer operations */ |
@@ -829,7 +812,7 @@ static struct fb_ops s3fb_ops = { | |||
829 | .fb_fillrect = s3fb_fillrect, | 812 | .fb_fillrect = s3fb_fillrect, |
830 | .fb_copyarea = cfb_copyarea, | 813 | .fb_copyarea = cfb_copyarea, |
831 | .fb_imageblit = s3fb_imageblit, | 814 | .fb_imageblit = s3fb_imageblit, |
832 | .fb_get_caps = s3fb_get_caps, | 815 | .fb_get_caps = svga_get_caps, |
833 | }; | 816 | }; |
834 | 817 | ||
835 | /* ------------------------------------------------------------------------- */ | 818 | /* ------------------------------------------------------------------------- */ |
diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c index 842b5cd054c6..836a612af977 100644 --- a/drivers/video/skeletonfb.c +++ b/drivers/video/skeletonfb.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * of it. | 14 | * of it. |
15 | * | 15 | * |
16 | * First the roles of struct fb_info and struct display have changed. Struct | 16 | * First the roles of struct fb_info and struct display have changed. Struct |
17 | * display will go away. The way the the new framebuffer console code will | 17 | * display will go away. The way the new framebuffer console code will |
18 | * work is that it will act to translate data about the tty/console in | 18 | * work is that it will act to translate data about the tty/console in |
19 | * struct vc_data to data in a device independent way in struct fb_info. Then | 19 | * struct vc_data to data in a device independent way in struct fb_info. Then |
20 | * various functions in struct fb_ops will be called to store the device | 20 | * various functions in struct fb_ops will be called to store the device |
diff --git a/drivers/video/svgalib.c b/drivers/video/svgalib.c index 079cdc911e48..25df928d37d8 100644 --- a/drivers/video/svgalib.c +++ b/drivers/video/svgalib.c | |||
@@ -347,6 +347,23 @@ int svga_get_tilemax(struct fb_info *info) | |||
347 | return 256; | 347 | return 256; |
348 | } | 348 | } |
349 | 349 | ||
350 | /* Get capabilities of accelerator based on the mode */ | ||
351 | |||
352 | void svga_get_caps(struct fb_info *info, struct fb_blit_caps *caps, | ||
353 | struct fb_var_screeninfo *var) | ||
354 | { | ||
355 | if (var->bits_per_pixel == 0) { | ||
356 | /* can only support 256 8x16 bitmap */ | ||
357 | caps->x = 1 << (8 - 1); | ||
358 | caps->y = 1 << (16 - 1); | ||
359 | caps->len = 256; | ||
360 | } else { | ||
361 | caps->x = (var->bits_per_pixel == 4) ? 1 << (8 - 1) : ~(u32)0; | ||
362 | caps->y = ~(u32)0; | ||
363 | caps->len = ~(u32)0; | ||
364 | } | ||
365 | } | ||
366 | EXPORT_SYMBOL(svga_get_caps); | ||
350 | 367 | ||
351 | /* ------------------------------------------------------------------------- */ | 368 | /* ------------------------------------------------------------------------- */ |
352 | 369 | ||
diff --git a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c new file mode 100644 index 000000000000..5e9755e464a1 --- /dev/null +++ b/drivers/video/vt8623fb.c | |||
@@ -0,0 +1,927 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/vt8623fb.c - fbdev driver for | ||
3 | * integrated graphic core in VIA VT8623 [CLE266] chipset | ||
4 | * | ||
5 | * Copyright (c) 2006-2007 Ondrej Zajicek <santiago@crfreenet.org> | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file COPYING in the main directory of this archive for | ||
9 | * more details. | ||
10 | * | ||
11 | * Code is based on s3fb, some parts are from David Boucher's viafb | ||
12 | * (http://davesdomain.org.uk/viafb/) | ||
13 | */ | ||
14 | |||
15 | #include <linux/version.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/string.h> | ||
20 | #include <linux/mm.h> | ||
21 | #include <linux/tty.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/fb.h> | ||
25 | #include <linux/svga.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/pci.h> | ||
28 | #include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ | ||
29 | #include <video/vga.h> | ||
30 | |||
31 | #ifdef CONFIG_MTRR | ||
32 | #include <asm/mtrr.h> | ||
33 | #endif | ||
34 | |||
35 | struct vt8623fb_info { | ||
36 | char __iomem *mmio_base; | ||
37 | int mtrr_reg; | ||
38 | struct vgastate state; | ||
39 | struct mutex open_lock; | ||
40 | unsigned int ref_count; | ||
41 | u32 pseudo_palette[16]; | ||
42 | }; | ||
43 | |||
44 | |||
45 | |||
46 | /* ------------------------------------------------------------------------- */ | ||
47 | |||
48 | static const struct svga_fb_format vt8623fb_formats[] = { | ||
49 | { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, | ||
50 | FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP8, FB_VISUAL_PSEUDOCOLOR, 16, 16}, | ||
51 | { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, | ||
52 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 16, 16}, | ||
53 | { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 1, | ||
54 | FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 16, 16}, | ||
55 | { 8, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, | ||
56 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 8}, | ||
57 | /* {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0, | ||
58 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4}, */ | ||
59 | {16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0, | ||
60 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4}, | ||
61 | {32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0, | ||
62 | FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 2}, | ||
63 | SVGA_FORMAT_END | ||
64 | }; | ||
65 | |||
66 | static const struct svga_pll vt8623_pll = {2, 127, 2, 7, 0, 3, | ||
67 | 60000, 300000, 14318}; | ||
68 | |||
69 | /* CRT timing register sets */ | ||
70 | |||
71 | struct vga_regset vt8623_h_total_regs[] = {{0x00, 0, 7}, {0x36, 3, 3}, VGA_REGSET_END}; | ||
72 | struct vga_regset vt8623_h_display_regs[] = {{0x01, 0, 7}, VGA_REGSET_END}; | ||
73 | struct vga_regset vt8623_h_blank_start_regs[] = {{0x02, 0, 7}, VGA_REGSET_END}; | ||
74 | struct vga_regset vt8623_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7}, {0x33, 5, 5}, VGA_REGSET_END}; | ||
75 | struct vga_regset vt8623_h_sync_start_regs[] = {{0x04, 0, 7}, {0x33, 4, 4}, VGA_REGSET_END}; | ||
76 | struct vga_regset vt8623_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END}; | ||
77 | |||
78 | struct vga_regset vt8623_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x35, 0, 0}, VGA_REGSET_END}; | ||
79 | struct vga_regset vt8623_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x35, 2, 2}, VGA_REGSET_END}; | ||
80 | struct vga_regset vt8623_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x35, 3, 3}, VGA_REGSET_END}; | ||
81 | struct vga_regset vt8623_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END}; | ||
82 | struct vga_regset vt8623_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x35, 1, 1}, VGA_REGSET_END}; | ||
83 | struct vga_regset vt8623_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END}; | ||
84 | |||
85 | struct vga_regset vt8623_offset_regs[] = {{0x13, 0, 7}, {0x35, 5, 7}, VGA_REGSET_END}; | ||
86 | struct vga_regset vt8623_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, {0x33, 0, 2}, {0x35, 4, 4}, VGA_REGSET_END}; | ||
87 | struct vga_regset vt8623_fetch_count_regs[] = {{0x1C, 0, 7}, {0x1D, 0, 1}, VGA_REGSET_END}; | ||
88 | struct vga_regset vt8623_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x34, 0, 7}, {0x48, 0, 1}, VGA_REGSET_END}; | ||
89 | |||
90 | struct svga_timing_regs vt8623_timing_regs = { | ||
91 | vt8623_h_total_regs, vt8623_h_display_regs, vt8623_h_blank_start_regs, | ||
92 | vt8623_h_blank_end_regs, vt8623_h_sync_start_regs, vt8623_h_sync_end_regs, | ||
93 | vt8623_v_total_regs, vt8623_v_display_regs, vt8623_v_blank_start_regs, | ||
94 | vt8623_v_blank_end_regs, vt8623_v_sync_start_regs, vt8623_v_sync_end_regs, | ||
95 | }; | ||
96 | |||
97 | |||
98 | /* ------------------------------------------------------------------------- */ | ||
99 | |||
100 | |||
101 | /* Module parameters */ | ||
102 | |||
103 | static char *mode = "640x480-8@60"; | ||
104 | |||
105 | #ifdef CONFIG_MTRR | ||
106 | static int mtrr = 1; | ||
107 | #endif | ||
108 | |||
109 | MODULE_AUTHOR("(c) 2006 Ondrej Zajicek <santiago@crfreenet.org>"); | ||
110 | MODULE_LICENSE("GPL"); | ||
111 | MODULE_DESCRIPTION("fbdev driver for integrated graphics core in VIA VT8623 [CLE266]"); | ||
112 | |||
113 | module_param(mode, charp, 0644); | ||
114 | MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc)"); | ||
115 | |||
116 | #ifdef CONFIG_MTRR | ||
117 | module_param(mtrr, int, 0444); | ||
118 | MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, default=1)"); | ||
119 | #endif | ||
120 | |||
121 | |||
122 | /* ------------------------------------------------------------------------- */ | ||
123 | |||
124 | |||
125 | static struct fb_tile_ops vt8623fb_tile_ops = { | ||
126 | .fb_settile = svga_settile, | ||
127 | .fb_tilecopy = svga_tilecopy, | ||
128 | .fb_tilefill = svga_tilefill, | ||
129 | .fb_tileblit = svga_tileblit, | ||
130 | .fb_tilecursor = svga_tilecursor, | ||
131 | .fb_get_tilemax = svga_get_tilemax, | ||
132 | }; | ||
133 | |||
134 | |||
135 | /* ------------------------------------------------------------------------- */ | ||
136 | |||
137 | |||
138 | /* image data is MSB-first, fb structure is MSB-first too */ | ||
139 | static inline u32 expand_color(u32 c) | ||
140 | { | ||
141 | return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF; | ||
142 | } | ||
143 | |||
144 | /* vt8623fb_iplan_imageblit silently assumes that almost everything is 8-pixel aligned */ | ||
145 | static void vt8623fb_iplan_imageblit(struct fb_info *info, const struct fb_image *image) | ||
146 | { | ||
147 | u32 fg = expand_color(image->fg_color); | ||
148 | u32 bg = expand_color(image->bg_color); | ||
149 | const u8 *src1, *src; | ||
150 | u8 __iomem *dst1; | ||
151 | u32 __iomem *dst; | ||
152 | u32 val; | ||
153 | int x, y; | ||
154 | |||
155 | src1 = image->data; | ||
156 | dst1 = info->screen_base + (image->dy * info->fix.line_length) | ||
157 | + ((image->dx / 8) * 4); | ||
158 | |||
159 | for (y = 0; y < image->height; y++) { | ||
160 | src = src1; | ||
161 | dst = (u32 __iomem *) dst1; | ||
162 | for (x = 0; x < image->width; x += 8) { | ||
163 | val = *(src++) * 0x01010101; | ||
164 | val = (val & fg) | (~val & bg); | ||
165 | fb_writel(val, dst++); | ||
166 | } | ||
167 | src1 += image->width / 8; | ||
168 | dst1 += info->fix.line_length; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | /* vt8623fb_iplan_fillrect silently assumes that almost everything is 8-pixel aligned */ | ||
173 | static void vt8623fb_iplan_fillrect(struct fb_info *info, const struct fb_fillrect *rect) | ||
174 | { | ||
175 | u32 fg = expand_color(rect->color); | ||
176 | u8 __iomem *dst1; | ||
177 | u32 __iomem *dst; | ||
178 | int x, y; | ||
179 | |||
180 | dst1 = info->screen_base + (rect->dy * info->fix.line_length) | ||
181 | + ((rect->dx / 8) * 4); | ||
182 | |||
183 | for (y = 0; y < rect->height; y++) { | ||
184 | dst = (u32 __iomem *) dst1; | ||
185 | for (x = 0; x < rect->width; x += 8) { | ||
186 | fb_writel(fg, dst++); | ||
187 | } | ||
188 | dst1 += info->fix.line_length; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | |||
193 | /* image data is MSB-first, fb structure is high-nibble-in-low-byte-first */ | ||
194 | static inline u32 expand_pixel(u32 c) | ||
195 | { | ||
196 | return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) | | ||
197 | ((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF; | ||
198 | } | ||
199 | |||
200 | /* vt8623fb_cfb4_imageblit silently assumes that almost everything is 8-pixel aligned */ | ||
201 | static void vt8623fb_cfb4_imageblit(struct fb_info *info, const struct fb_image *image) | ||
202 | { | ||
203 | u32 fg = image->fg_color * 0x11111111; | ||
204 | u32 bg = image->bg_color * 0x11111111; | ||
205 | const u8 *src1, *src; | ||
206 | u8 __iomem *dst1; | ||
207 | u32 __iomem *dst; | ||
208 | u32 val; | ||
209 | int x, y; | ||
210 | |||
211 | src1 = image->data; | ||
212 | dst1 = info->screen_base + (image->dy * info->fix.line_length) | ||
213 | + ((image->dx / 8) * 4); | ||
214 | |||
215 | for (y = 0; y < image->height; y++) { | ||
216 | src = src1; | ||
217 | dst = (u32 __iomem *) dst1; | ||
218 | for (x = 0; x < image->width; x += 8) { | ||
219 | val = expand_pixel(*(src++)); | ||
220 | val = (val & fg) | (~val & bg); | ||
221 | fb_writel(val, dst++); | ||
222 | } | ||
223 | src1 += image->width / 8; | ||
224 | dst1 += info->fix.line_length; | ||
225 | } | ||
226 | } | ||
227 | |||
228 | static void vt8623fb_imageblit(struct fb_info *info, const struct fb_image *image) | ||
229 | { | ||
230 | if ((info->var.bits_per_pixel == 4) && (image->depth == 1) | ||
231 | && ((image->width % 8) == 0) && ((image->dx % 8) == 0)) { | ||
232 | if (info->fix.type == FB_TYPE_INTERLEAVED_PLANES) | ||
233 | vt8623fb_iplan_imageblit(info, image); | ||
234 | else | ||
235 | vt8623fb_cfb4_imageblit(info, image); | ||
236 | } else | ||
237 | cfb_imageblit(info, image); | ||
238 | } | ||
239 | |||
240 | static void vt8623fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) | ||
241 | { | ||
242 | if ((info->var.bits_per_pixel == 4) | ||
243 | && ((rect->width % 8) == 0) && ((rect->dx % 8) == 0) | ||
244 | && (info->fix.type == FB_TYPE_INTERLEAVED_PLANES)) | ||
245 | vt8623fb_iplan_fillrect(info, rect); | ||
246 | else | ||
247 | cfb_fillrect(info, rect); | ||
248 | } | ||
249 | |||
250 | |||
251 | /* ------------------------------------------------------------------------- */ | ||
252 | |||
253 | |||
254 | static void vt8623_set_pixclock(struct fb_info *info, u32 pixclock) | ||
255 | { | ||
256 | u16 m, n, r; | ||
257 | u8 regval; | ||
258 | int rv; | ||
259 | |||
260 | rv = svga_compute_pll(&vt8623_pll, 1000000000 / pixclock, &m, &n, &r, info->node); | ||
261 | if (rv < 0) { | ||
262 | printk(KERN_ERR "fb%d: cannot set requested pixclock, keeping old value\n", info->node); | ||
263 | return; | ||
264 | } | ||
265 | |||
266 | /* Set VGA misc register */ | ||
267 | regval = vga_r(NULL, VGA_MIS_R); | ||
268 | vga_w(NULL, VGA_MIS_W, regval | VGA_MIS_ENB_PLL_LOAD); | ||
269 | |||
270 | /* Set clock registers */ | ||
271 | vga_wseq(NULL, 0x46, (n | (r << 6))); | ||
272 | vga_wseq(NULL, 0x47, m); | ||
273 | |||
274 | udelay(1000); | ||
275 | |||
276 | /* PLL reset */ | ||
277 | svga_wseq_mask(0x40, 0x02, 0x02); | ||
278 | svga_wseq_mask(0x40, 0x00, 0x02); | ||
279 | } | ||
280 | |||
281 | |||
282 | static int vt8623fb_open(struct fb_info *info, int user) | ||
283 | { | ||
284 | struct vt8623fb_info *par = info->par; | ||
285 | |||
286 | mutex_lock(&(par->open_lock)); | ||
287 | if (par->ref_count == 0) { | ||
288 | memset(&(par->state), 0, sizeof(struct vgastate)); | ||
289 | par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS | VGA_SAVE_CMAP; | ||
290 | par->state.num_crtc = 0xA2; | ||
291 | par->state.num_seq = 0x50; | ||
292 | save_vga(&(par->state)); | ||
293 | } | ||
294 | |||
295 | par->ref_count++; | ||
296 | mutex_unlock(&(par->open_lock)); | ||
297 | |||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | static int vt8623fb_release(struct fb_info *info, int user) | ||
302 | { | ||
303 | struct vt8623fb_info *par = info->par; | ||
304 | |||
305 | mutex_lock(&(par->open_lock)); | ||
306 | if (par->ref_count == 0) { | ||
307 | mutex_unlock(&(par->open_lock)); | ||
308 | return -EINVAL; | ||
309 | } | ||
310 | |||
311 | if (par->ref_count == 1) | ||
312 | restore_vga(&(par->state)); | ||
313 | |||
314 | par->ref_count--; | ||
315 | mutex_unlock(&(par->open_lock)); | ||
316 | |||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | static int vt8623fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | ||
321 | { | ||
322 | int rv, mem, step; | ||
323 | |||
324 | /* Find appropriate format */ | ||
325 | rv = svga_match_format (vt8623fb_formats, var, NULL); | ||
326 | if (rv < 0) | ||
327 | { | ||
328 | printk(KERN_ERR "fb%d: unsupported mode requested\n", info->node); | ||
329 | return rv; | ||
330 | } | ||
331 | |||
332 | /* Do not allow to have real resoulution larger than virtual */ | ||
333 | if (var->xres > var->xres_virtual) | ||
334 | var->xres_virtual = var->xres; | ||
335 | |||
336 | if (var->yres > var->yres_virtual) | ||
337 | var->yres_virtual = var->yres; | ||
338 | |||
339 | /* Round up xres_virtual to have proper alignment of lines */ | ||
340 | step = vt8623fb_formats[rv].xresstep - 1; | ||
341 | var->xres_virtual = (var->xres_virtual+step) & ~step; | ||
342 | |||
343 | /* Check whether have enough memory */ | ||
344 | mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual; | ||
345 | if (mem > info->screen_size) | ||
346 | { | ||
347 | printk(KERN_ERR "fb%d: not enough framebuffer memory (%d kB requested , %d kB available)\n", info->node, mem >> 10, (unsigned int) (info->screen_size >> 10)); | ||
348 | return -EINVAL; | ||
349 | } | ||
350 | |||
351 | /* Text mode is limited to 256 kB of memory */ | ||
352 | if ((var->bits_per_pixel == 0) && (mem > (256*1024))) | ||
353 | { | ||
354 | printk(KERN_ERR "fb%d: text framebuffer size too large (%d kB requested, 256 kB possible)\n", info->node, mem >> 10); | ||
355 | return -EINVAL; | ||
356 | } | ||
357 | |||
358 | rv = svga_check_timings (&vt8623_timing_regs, var, info->node); | ||
359 | if (rv < 0) | ||
360 | { | ||
361 | printk(KERN_ERR "fb%d: invalid timings requested\n", info->node); | ||
362 | return rv; | ||
363 | } | ||
364 | |||
365 | /* Interlaced mode not supported */ | ||
366 | if (var->vmode & FB_VMODE_INTERLACED) | ||
367 | return -EINVAL; | ||
368 | |||
369 | return 0; | ||
370 | } | ||
371 | |||
372 | |||
373 | static int vt8623fb_set_par(struct fb_info *info) | ||
374 | { | ||
375 | u32 mode, offset_value, fetch_value, screen_size; | ||
376 | u32 bpp = info->var.bits_per_pixel; | ||
377 | |||
378 | if (bpp != 0) { | ||
379 | info->fix.ypanstep = 1; | ||
380 | info->fix.line_length = (info->var.xres_virtual * bpp) / 8; | ||
381 | |||
382 | info->flags &= ~FBINFO_MISC_TILEBLITTING; | ||
383 | info->tileops = NULL; | ||
384 | |||
385 | /* in 4bpp supports 8p wide tiles only, any tiles otherwise */ | ||
386 | info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0); | ||
387 | info->pixmap.blit_y = ~(u32)0; | ||
388 | |||
389 | offset_value = (info->var.xres_virtual * bpp) / 64; | ||
390 | fetch_value = ((info->var.xres * bpp) / 128) + 4; | ||
391 | |||
392 | if (bpp == 4) | ||
393 | fetch_value = (info->var.xres / 8) + 8; /* + 0 is OK */ | ||
394 | |||
395 | screen_size = info->var.yres_virtual * info->fix.line_length; | ||
396 | } else { | ||
397 | info->fix.ypanstep = 16; | ||
398 | info->fix.line_length = 0; | ||
399 | |||
400 | info->flags |= FBINFO_MISC_TILEBLITTING; | ||
401 | info->tileops = &vt8623fb_tile_ops; | ||
402 | |||
403 | /* supports 8x16 tiles only */ | ||
404 | info->pixmap.blit_x = 1 << (8 - 1); | ||
405 | info->pixmap.blit_y = 1 << (16 - 1); | ||
406 | |||
407 | offset_value = info->var.xres_virtual / 16; | ||
408 | fetch_value = (info->var.xres / 8) + 8; | ||
409 | screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64; | ||
410 | } | ||
411 | |||
412 | info->var.xoffset = 0; | ||
413 | info->var.yoffset = 0; | ||
414 | info->var.activate = FB_ACTIVATE_NOW; | ||
415 | |||
416 | /* Unlock registers */ | ||
417 | svga_wseq_mask(0x10, 0x01, 0x01); | ||
418 | svga_wcrt_mask(0x11, 0x00, 0x80); | ||
419 | svga_wcrt_mask(0x47, 0x00, 0x01); | ||
420 | |||
421 | /* Device, screen and sync off */ | ||
422 | svga_wseq_mask(0x01, 0x20, 0x20); | ||
423 | svga_wcrt_mask(0x36, 0x30, 0x30); | ||
424 | svga_wcrt_mask(0x17, 0x00, 0x80); | ||
425 | |||
426 | /* Set default values */ | ||
427 | svga_set_default_gfx_regs(); | ||
428 | svga_set_default_atc_regs(); | ||
429 | svga_set_default_seq_regs(); | ||
430 | svga_set_default_crt_regs(); | ||
431 | svga_wcrt_multi(vt8623_line_compare_regs, 0xFFFFFFFF); | ||
432 | svga_wcrt_multi(vt8623_start_address_regs, 0); | ||
433 | |||
434 | svga_wcrt_multi(vt8623_offset_regs, offset_value); | ||
435 | svga_wseq_multi(vt8623_fetch_count_regs, fetch_value); | ||
436 | |||
437 | if (info->var.vmode & FB_VMODE_DOUBLE) | ||
438 | svga_wcrt_mask(0x09, 0x80, 0x80); | ||
439 | else | ||
440 | svga_wcrt_mask(0x09, 0x00, 0x80); | ||
441 | |||
442 | svga_wseq_mask(0x1E, 0xF0, 0xF0); // DI/DVP bus | ||
443 | svga_wseq_mask(0x2A, 0x0F, 0x0F); // DI/DVP bus | ||
444 | svga_wseq_mask(0x16, 0x08, 0xBF); // FIFO read treshold | ||
445 | vga_wseq(NULL, 0x17, 0x1F); // FIFO depth | ||
446 | vga_wseq(NULL, 0x18, 0x4E); | ||
447 | svga_wseq_mask(0x1A, 0x08, 0x08); // enable MMIO ? | ||
448 | |||
449 | vga_wcrt(NULL, 0x32, 0x00); | ||
450 | vga_wcrt(NULL, 0x34, 0x00); | ||
451 | vga_wcrt(NULL, 0x6A, 0x80); | ||
452 | vga_wcrt(NULL, 0x6A, 0xC0); | ||
453 | |||
454 | vga_wgfx(NULL, 0x20, 0x00); | ||
455 | vga_wgfx(NULL, 0x21, 0x00); | ||
456 | vga_wgfx(NULL, 0x22, 0x00); | ||
457 | |||
458 | /* Set SR15 according to number of bits per pixel */ | ||
459 | mode = svga_match_format(vt8623fb_formats, &(info->var), &(info->fix)); | ||
460 | switch (mode) { | ||
461 | case 0: | ||
462 | pr_debug("fb%d: text mode\n", info->node); | ||
463 | svga_set_textmode_vga_regs(); | ||
464 | svga_wseq_mask(0x15, 0x00, 0xFE); | ||
465 | svga_wcrt_mask(0x11, 0x60, 0x70); | ||
466 | break; | ||
467 | case 1: | ||
468 | pr_debug("fb%d: 4 bit pseudocolor\n", info->node); | ||
469 | vga_wgfx(NULL, VGA_GFX_MODE, 0x40); | ||
470 | svga_wseq_mask(0x15, 0x20, 0xFE); | ||
471 | svga_wcrt_mask(0x11, 0x00, 0x70); | ||
472 | break; | ||
473 | case 2: | ||
474 | pr_debug("fb%d: 4 bit pseudocolor, planar\n", info->node); | ||
475 | svga_wseq_mask(0x15, 0x00, 0xFE); | ||
476 | svga_wcrt_mask(0x11, 0x00, 0x70); | ||
477 | break; | ||
478 | case 3: | ||
479 | pr_debug("fb%d: 8 bit pseudocolor\n", info->node); | ||
480 | svga_wseq_mask(0x15, 0x22, 0xFE); | ||
481 | break; | ||
482 | case 4: | ||
483 | pr_debug("fb%d: 5/6/5 truecolor\n", info->node); | ||
484 | svga_wseq_mask(0x15, 0xB6, 0xFE); | ||
485 | break; | ||
486 | case 5: | ||
487 | pr_debug("fb%d: 8/8/8 truecolor\n", info->node); | ||
488 | svga_wseq_mask(0x15, 0xAE, 0xFE); | ||
489 | break; | ||
490 | default: | ||
491 | printk(KERN_ERR "vt8623fb: unsupported mode - bug\n"); | ||
492 | return (-EINVAL); | ||
493 | } | ||
494 | |||
495 | vt8623_set_pixclock(info, info->var.pixclock); | ||
496 | svga_set_timings(&vt8623_timing_regs, &(info->var), 1, 1, | ||
497 | (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, 1, | ||
498 | 1, info->node); | ||
499 | |||
500 | memset_io(info->screen_base, 0x00, screen_size); | ||
501 | |||
502 | /* Device and screen back on */ | ||
503 | svga_wcrt_mask(0x17, 0x80, 0x80); | ||
504 | svga_wcrt_mask(0x36, 0x00, 0x30); | ||
505 | svga_wseq_mask(0x01, 0x00, 0x20); | ||
506 | |||
507 | return 0; | ||
508 | } | ||
509 | |||
510 | |||
511 | static int vt8623fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | ||
512 | u_int transp, struct fb_info *fb) | ||
513 | { | ||
514 | switch (fb->var.bits_per_pixel) { | ||
515 | case 0: | ||
516 | case 4: | ||
517 | if (regno >= 16) | ||
518 | return -EINVAL; | ||
519 | |||
520 | outb(0x0F, VGA_PEL_MSK); | ||
521 | outb(regno, VGA_PEL_IW); | ||
522 | outb(red >> 10, VGA_PEL_D); | ||
523 | outb(green >> 10, VGA_PEL_D); | ||
524 | outb(blue >> 10, VGA_PEL_D); | ||
525 | break; | ||
526 | case 8: | ||
527 | if (regno >= 256) | ||
528 | return -EINVAL; | ||
529 | |||
530 | outb(0xFF, VGA_PEL_MSK); | ||
531 | outb(regno, VGA_PEL_IW); | ||
532 | outb(red >> 10, VGA_PEL_D); | ||
533 | outb(green >> 10, VGA_PEL_D); | ||
534 | outb(blue >> 10, VGA_PEL_D); | ||
535 | break; | ||
536 | case 16: | ||
537 | if (regno >= 16) | ||
538 | return 0; | ||
539 | |||
540 | if (fb->var.green.length == 5) | ||
541 | ((u32*)fb->pseudo_palette)[regno] = ((red & 0xF800) >> 1) | | ||
542 | ((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11); | ||
543 | else if (fb->var.green.length == 6) | ||
544 | ((u32*)fb->pseudo_palette)[regno] = (red & 0xF800) | | ||
545 | ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11); | ||
546 | else | ||
547 | return -EINVAL; | ||
548 | break; | ||
549 | case 24: | ||
550 | case 32: | ||
551 | if (regno >= 16) | ||
552 | return 0; | ||
553 | |||
554 | /* ((transp & 0xFF00) << 16) */ | ||
555 | ((u32*)fb->pseudo_palette)[regno] = ((red & 0xFF00) << 8) | | ||
556 | (green & 0xFF00) | ((blue & 0xFF00) >> 8); | ||
557 | break; | ||
558 | default: | ||
559 | return -EINVAL; | ||
560 | } | ||
561 | |||
562 | return 0; | ||
563 | } | ||
564 | |||
565 | |||
566 | static int vt8623fb_blank(int blank_mode, struct fb_info *info) | ||
567 | { | ||
568 | switch (blank_mode) { | ||
569 | case FB_BLANK_UNBLANK: | ||
570 | pr_debug("fb%d: unblank\n", info->node); | ||
571 | svga_wcrt_mask(0x36, 0x00, 0x30); | ||
572 | svga_wseq_mask(0x01, 0x00, 0x20); | ||
573 | break; | ||
574 | case FB_BLANK_NORMAL: | ||
575 | pr_debug("fb%d: blank\n", info->node); | ||
576 | svga_wcrt_mask(0x36, 0x00, 0x30); | ||
577 | svga_wseq_mask(0x01, 0x20, 0x20); | ||
578 | break; | ||
579 | case FB_BLANK_HSYNC_SUSPEND: | ||
580 | pr_debug("fb%d: DPMS standby (hsync off)\n", info->node); | ||
581 | svga_wcrt_mask(0x36, 0x10, 0x30); | ||
582 | svga_wseq_mask(0x01, 0x20, 0x20); | ||
583 | break; | ||
584 | case FB_BLANK_VSYNC_SUSPEND: | ||
585 | pr_debug("fb%d: DPMS suspend (vsync off)\n", info->node); | ||
586 | svga_wcrt_mask(0x36, 0x20, 0x30); | ||
587 | svga_wseq_mask(0x01, 0x20, 0x20); | ||
588 | break; | ||
589 | case FB_BLANK_POWERDOWN: | ||
590 | pr_debug("fb%d: DPMS off (no sync)\n", info->node); | ||
591 | svga_wcrt_mask(0x36, 0x30, 0x30); | ||
592 | svga_wseq_mask(0x01, 0x20, 0x20); | ||
593 | break; | ||
594 | } | ||
595 | |||
596 | return 0; | ||
597 | } | ||
598 | |||
599 | |||
600 | static int vt8623fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) | ||
601 | { | ||
602 | unsigned int offset; | ||
603 | |||
604 | /* Calculate the offset */ | ||
605 | if (var->bits_per_pixel == 0) { | ||
606 | offset = (var->yoffset / 16) * var->xres_virtual + var->xoffset; | ||
607 | offset = offset >> 3; | ||
608 | } else { | ||
609 | offset = (var->yoffset * info->fix.line_length) + | ||
610 | (var->xoffset * var->bits_per_pixel / 8); | ||
611 | offset = offset >> ((var->bits_per_pixel == 4) ? 2 : 1); | ||
612 | } | ||
613 | |||
614 | /* Set the offset */ | ||
615 | svga_wcrt_multi(vt8623_start_address_regs, offset); | ||
616 | |||
617 | return 0; | ||
618 | } | ||
619 | |||
620 | |||
621 | /* ------------------------------------------------------------------------- */ | ||
622 | |||
623 | |||
624 | /* Frame buffer operations */ | ||
625 | |||
626 | static struct fb_ops vt8623fb_ops = { | ||
627 | .owner = THIS_MODULE, | ||
628 | .fb_open = vt8623fb_open, | ||
629 | .fb_release = vt8623fb_release, | ||
630 | .fb_check_var = vt8623fb_check_var, | ||
631 | .fb_set_par = vt8623fb_set_par, | ||
632 | .fb_setcolreg = vt8623fb_setcolreg, | ||
633 | .fb_blank = vt8623fb_blank, | ||
634 | .fb_pan_display = vt8623fb_pan_display, | ||
635 | .fb_fillrect = vt8623fb_fillrect, | ||
636 | .fb_copyarea = cfb_copyarea, | ||
637 | .fb_imageblit = vt8623fb_imageblit, | ||
638 | .fb_get_caps = svga_get_caps, | ||
639 | }; | ||
640 | |||
641 | |||
642 | /* PCI probe */ | ||
643 | |||
644 | static int __devinit vt8623_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | ||
645 | { | ||
646 | struct fb_info *info; | ||
647 | struct vt8623fb_info *par; | ||
648 | unsigned int memsize1, memsize2; | ||
649 | int rc; | ||
650 | |||
651 | /* Ignore secondary VGA device because there is no VGA arbitration */ | ||
652 | if (! svga_primary_device(dev)) { | ||
653 | dev_info(&(dev->dev), "ignoring secondary device\n"); | ||
654 | return -ENODEV; | ||
655 | } | ||
656 | |||
657 | /* Allocate and fill driver data structure */ | ||
658 | info = framebuffer_alloc(sizeof(struct vt8623fb_info), NULL); | ||
659 | if (! info) { | ||
660 | dev_err(&(dev->dev), "cannot allocate memory\n"); | ||
661 | return -ENOMEM; | ||
662 | } | ||
663 | |||
664 | par = info->par; | ||
665 | mutex_init(&par->open_lock); | ||
666 | |||
667 | info->flags = FBINFO_PARTIAL_PAN_OK | FBINFO_HWACCEL_YPAN; | ||
668 | info->fbops = &vt8623fb_ops; | ||
669 | |||
670 | /* Prepare PCI device */ | ||
671 | |||
672 | rc = pci_enable_device(dev); | ||
673 | if (rc < 0) { | ||
674 | dev_err(&(dev->dev), "cannot enable PCI device\n"); | ||
675 | goto err_enable_device; | ||
676 | } | ||
677 | |||
678 | rc = pci_request_regions(dev, "vt8623fb"); | ||
679 | if (rc < 0) { | ||
680 | dev_err(&(dev->dev), "cannot reserve framebuffer region\n"); | ||
681 | goto err_request_regions; | ||
682 | } | ||
683 | |||
684 | info->fix.smem_start = pci_resource_start(dev, 0); | ||
685 | info->fix.smem_len = pci_resource_len(dev, 0); | ||
686 | info->fix.mmio_start = pci_resource_start(dev, 1); | ||
687 | info->fix.mmio_len = pci_resource_len(dev, 1); | ||
688 | |||
689 | /* Map physical IO memory address into kernel space */ | ||
690 | info->screen_base = pci_iomap(dev, 0, 0); | ||
691 | if (! info->screen_base) { | ||
692 | rc = -ENOMEM; | ||
693 | dev_err(&(dev->dev), "iomap for framebuffer failed\n"); | ||
694 | goto err_iomap_1; | ||
695 | } | ||
696 | |||
697 | par->mmio_base = pci_iomap(dev, 1, 0); | ||
698 | if (! par->mmio_base) { | ||
699 | rc = -ENOMEM; | ||
700 | dev_err(&(dev->dev), "iomap for MMIO failed\n"); | ||
701 | goto err_iomap_2; | ||
702 | } | ||
703 | |||
704 | /* Find how many physical memory there is on card */ | ||
705 | memsize1 = (vga_rseq(NULL, 0x34) + 1) >> 1; | ||
706 | memsize2 = vga_rseq(NULL, 0x39) << 2; | ||
707 | |||
708 | if ((16 <= memsize1) && (memsize1 <= 64) && (memsize1 == memsize2)) | ||
709 | info->screen_size = memsize1 << 20; | ||
710 | else { | ||
711 | dev_err(&(dev->dev), "memory size detection failed (%x %x), suppose 16 MB\n", memsize1, memsize2); | ||
712 | info->screen_size = 16 << 20; | ||
713 | } | ||
714 | |||
715 | info->fix.smem_len = info->screen_size; | ||
716 | strcpy(info->fix.id, "VIA VT8623"); | ||
717 | info->fix.type = FB_TYPE_PACKED_PIXELS; | ||
718 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
719 | info->fix.ypanstep = 0; | ||
720 | info->fix.accel = FB_ACCEL_NONE; | ||
721 | info->pseudo_palette = (void*)par->pseudo_palette; | ||
722 | |||
723 | /* Prepare startup mode */ | ||
724 | |||
725 | rc = fb_find_mode(&(info->var), info, mode, NULL, 0, NULL, 8); | ||
726 | if (! ((rc == 1) || (rc == 2))) { | ||
727 | rc = -EINVAL; | ||
728 | dev_err(&(dev->dev), "mode %s not found\n", mode); | ||
729 | goto err_find_mode; | ||
730 | } | ||
731 | |||
732 | rc = fb_alloc_cmap(&info->cmap, 256, 0); | ||
733 | if (rc < 0) { | ||
734 | dev_err(&(dev->dev), "cannot allocate colormap\n"); | ||
735 | goto err_alloc_cmap; | ||
736 | } | ||
737 | |||
738 | rc = register_framebuffer(info); | ||
739 | if (rc < 0) { | ||
740 | dev_err(&(dev->dev), "cannot register framebugger\n"); | ||
741 | goto err_reg_fb; | ||
742 | } | ||
743 | |||
744 | printk(KERN_INFO "fb%d: %s on %s, %d MB RAM\n", info->node, info->fix.id, | ||
745 | pci_name(dev), info->fix.smem_len >> 20); | ||
746 | |||
747 | /* Record a reference to the driver data */ | ||
748 | pci_set_drvdata(dev, info); | ||
749 | |||
750 | #ifdef CONFIG_MTRR | ||
751 | if (mtrr) { | ||
752 | par->mtrr_reg = -1; | ||
753 | par->mtrr_reg = mtrr_add(info->fix.smem_start, info->fix.smem_len, MTRR_TYPE_WRCOMB, 1); | ||
754 | } | ||
755 | #endif | ||
756 | |||
757 | return 0; | ||
758 | |||
759 | /* Error handling */ | ||
760 | err_reg_fb: | ||
761 | fb_dealloc_cmap(&info->cmap); | ||
762 | err_alloc_cmap: | ||
763 | err_find_mode: | ||
764 | pci_iounmap(dev, par->mmio_base); | ||
765 | err_iomap_2: | ||
766 | pci_iounmap(dev, info->screen_base); | ||
767 | err_iomap_1: | ||
768 | pci_release_regions(dev); | ||
769 | err_request_regions: | ||
770 | /* pci_disable_device(dev); */ | ||
771 | err_enable_device: | ||
772 | framebuffer_release(info); | ||
773 | return rc; | ||
774 | } | ||
775 | |||
776 | /* PCI remove */ | ||
777 | |||
778 | static void __devexit vt8623_pci_remove(struct pci_dev *dev) | ||
779 | { | ||
780 | struct fb_info *info = pci_get_drvdata(dev); | ||
781 | struct vt8623fb_info *par = info->par; | ||
782 | |||
783 | if (info) { | ||
784 | #ifdef CONFIG_MTRR | ||
785 | if (par->mtrr_reg >= 0) { | ||
786 | mtrr_del(par->mtrr_reg, 0, 0); | ||
787 | par->mtrr_reg = -1; | ||
788 | } | ||
789 | #endif | ||
790 | |||
791 | unregister_framebuffer(info); | ||
792 | fb_dealloc_cmap(&info->cmap); | ||
793 | |||
794 | pci_iounmap(dev, info->screen_base); | ||
795 | pci_iounmap(dev, par->mmio_base); | ||
796 | pci_release_regions(dev); | ||
797 | /* pci_disable_device(dev); */ | ||
798 | |||
799 | pci_set_drvdata(dev, NULL); | ||
800 | framebuffer_release(info); | ||
801 | } | ||
802 | } | ||
803 | |||
804 | |||
805 | #ifdef CONFIG_PM | ||
806 | /* PCI suspend */ | ||
807 | |||
808 | static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state) | ||
809 | { | ||
810 | struct fb_info *info = pci_get_drvdata(dev); | ||
811 | struct vt8623fb_info *par = info->par; | ||
812 | |||
813 | dev_info(&(dev->dev), "suspend\n"); | ||
814 | |||
815 | acquire_console_sem(); | ||
816 | mutex_lock(&(par->open_lock)); | ||
817 | |||
818 | if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { | ||
819 | mutex_unlock(&(par->open_lock)); | ||
820 | release_console_sem(); | ||
821 | return 0; | ||
822 | } | ||
823 | |||
824 | fb_set_suspend(info, 1); | ||
825 | |||
826 | pci_save_state(dev); | ||
827 | pci_disable_device(dev); | ||
828 | pci_set_power_state(dev, pci_choose_state(dev, state)); | ||
829 | |||
830 | mutex_unlock(&(par->open_lock)); | ||
831 | release_console_sem(); | ||
832 | |||
833 | return 0; | ||
834 | } | ||
835 | |||
836 | |||
837 | /* PCI resume */ | ||
838 | |||
839 | static int vt8623_pci_resume(struct pci_dev* dev) | ||
840 | { | ||
841 | struct fb_info *info = pci_get_drvdata(dev); | ||
842 | struct vt8623fb_info *par = info->par; | ||
843 | |||
844 | dev_info(&(dev->dev), "resume\n"); | ||
845 | |||
846 | acquire_console_sem(); | ||
847 | mutex_lock(&(par->open_lock)); | ||
848 | |||
849 | if (par->ref_count == 0) { | ||
850 | mutex_unlock(&(par->open_lock)); | ||
851 | release_console_sem(); | ||
852 | return 0; | ||
853 | } | ||
854 | |||
855 | pci_set_power_state(dev, PCI_D0); | ||
856 | pci_restore_state(dev); | ||
857 | |||
858 | if (pci_enable_device(dev)) | ||
859 | goto fail; | ||
860 | |||
861 | pci_set_master(dev); | ||
862 | |||
863 | vt8623fb_set_par(info); | ||
864 | fb_set_suspend(info, 0); | ||
865 | |||
866 | mutex_unlock(&(par->open_lock)); | ||
867 | fail: | ||
868 | release_console_sem(); | ||
869 | |||
870 | return 0; | ||
871 | } | ||
872 | #else | ||
873 | #define vt8623_pci_suspend NULL | ||
874 | #define vt8623_pci_resume NULL | ||
875 | #endif /* CONFIG_PM */ | ||
876 | |||
877 | /* List of boards that we are trying to support */ | ||
878 | |||
879 | static struct pci_device_id vt8623_devices[] __devinitdata = { | ||
880 | {PCI_DEVICE(PCI_VENDOR_ID_VIA, 0x3122)}, | ||
881 | {0, 0, 0, 0, 0, 0, 0} | ||
882 | }; | ||
883 | |||
884 | MODULE_DEVICE_TABLE(pci, vt8623_devices); | ||
885 | |||
886 | static struct pci_driver vt8623fb_pci_driver = { | ||
887 | .name = "vt8623fb", | ||
888 | .id_table = vt8623_devices, | ||
889 | .probe = vt8623_pci_probe, | ||
890 | .remove = __devexit_p(vt8623_pci_remove), | ||
891 | .suspend = vt8623_pci_suspend, | ||
892 | .resume = vt8623_pci_resume, | ||
893 | }; | ||
894 | |||
895 | /* Cleanup */ | ||
896 | |||
897 | static void __exit vt8623fb_cleanup(void) | ||
898 | { | ||
899 | pr_debug("vt8623fb: cleaning up\n"); | ||
900 | pci_unregister_driver(&vt8623fb_pci_driver); | ||
901 | } | ||
902 | |||
903 | /* Driver Initialisation */ | ||
904 | |||
905 | int __init vt8623fb_init(void) | ||
906 | { | ||
907 | |||
908 | #ifndef MODULE | ||
909 | char *option = NULL; | ||
910 | |||
911 | if (fb_get_options("vt8623fb", &option)) | ||
912 | return -ENODEV; | ||
913 | |||
914 | if (option && *option) | ||
915 | mode = option; | ||
916 | #endif | ||
917 | |||
918 | pr_debug("vt8623fb: initializing\n"); | ||
919 | return pci_register_driver(&vt8623fb_pci_driver); | ||
920 | } | ||
921 | |||
922 | /* ------------------------------------------------------------------------- */ | ||
923 | |||
924 | /* Modularization */ | ||
925 | |||
926 | module_init(vt8623fb_init); | ||
927 | module_exit(vt8623fb_cleanup); | ||