aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2010-06-16 12:08:13 -0400
committerJiri Kosina <jkosina@suse.cz>2010-06-16 12:08:13 -0400
commitf1bbbb6912662b9f6070c5bfc4ca9eb1f06a9d5b (patch)
treec2c130a74be25b0b2dff992e1a195e2728bdaadd /drivers/ide
parentfd0961ff67727482bb20ca7e8ea97b83e9de2ddb (diff)
parent7e27d6e778cd87b6f2415515d7127eba53fe5d02 (diff)
Merge branch 'master' into for-next
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/cmd640.c6
-rw-r--r--drivers/ide/gayle.c147
-rw-r--r--drivers/ide/ide-disk.c40
-rw-r--r--drivers/ide/ide-gd.c11
-rw-r--r--drivers/ide/ide_platform.c1
-rw-r--r--drivers/ide/pdc202xx_old.c5
-rw-r--r--drivers/ide/pmac.c17
7 files changed, 118 insertions, 109 deletions
diff --git a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c
index d2b8b272bc27..cb10201a15ed 100644
--- a/drivers/ide/cmd640.c
+++ b/drivers/ide/cmd640.c
@@ -633,12 +633,10 @@ static void __init cmd640_init_dev(ide_drive_t *drive)
633 633
634static int cmd640_test_irq(ide_hwif_t *hwif) 634static int cmd640_test_irq(ide_hwif_t *hwif)
635{ 635{
636 struct pci_dev *dev = to_pci_dev(hwif->dev);
637 int irq_reg = hwif->channel ? ARTTIM23 : CFR; 636 int irq_reg = hwif->channel ? ARTTIM23 : CFR;
638 u8 irq_stat, irq_mask = hwif->channel ? ARTTIM23_IDE23INTR : 637 u8 irq_mask = hwif->channel ? ARTTIM23_IDE23INTR :
639 CFR_IDE01INTR; 638 CFR_IDE01INTR;
640 639 u8 irq_stat = get_cmd640_reg(irq_reg);
641 pci_read_config_byte(dev, irq_reg, &irq_stat);
642 640
643 return (irq_stat & irq_mask) ? 1 : 0; 641 return (irq_stat & irq_mask) ? 1 : 0;
644} 642}
diff --git a/drivers/ide/gayle.c b/drivers/ide/gayle.c
index b9e517de6a82..3feaa26410be 100644
--- a/drivers/ide/gayle.c
+++ b/drivers/ide/gayle.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/zorro.h> 17#include <linux/zorro.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/platform_device.h>
19 20
20#include <asm/setup.h> 21#include <asm/setup.h>
21#include <asm/amigahw.h> 22#include <asm/amigahw.h>
@@ -24,15 +25,6 @@
24 25
25 26
26 /* 27 /*
27 * Bases of the IDE interfaces
28 */
29
30#define GAYLE_BASE_4000 0xdd2020 /* A4000/A4000T */
31#define GAYLE_BASE_1200 0xda0000 /* A1200/A600 and E-Matrix 530 */
32
33#define GAYLE_IDEREG_SIZE 0x2000
34
35 /*
36 * Offsets from one of the above bases 28 * Offsets from one of the above bases
37 */ 29 */
38 30
@@ -68,20 +60,20 @@ MODULE_PARM_DESC(doubler, "enable support for IDE doublers");
68 60
69static int gayle_test_irq(ide_hwif_t *hwif) 61static int gayle_test_irq(ide_hwif_t *hwif)
70{ 62{
71 unsigned char ch; 63 unsigned char ch;
72 64
73 ch = z_readb(hwif->io_ports.irq_addr); 65 ch = z_readb(hwif->io_ports.irq_addr);
74 if (!(ch & GAYLE_IRQ_IDE)) 66 if (!(ch & GAYLE_IRQ_IDE))
75 return 0; 67 return 0;
76 return 1; 68 return 1;
77} 69}
78 70
79static void gayle_a1200_clear_irq(ide_drive_t *drive) 71static void gayle_a1200_clear_irq(ide_drive_t *drive)
80{ 72{
81 ide_hwif_t *hwif = drive->hwif; 73 ide_hwif_t *hwif = drive->hwif;
82 74
83 (void)z_readb(hwif->io_ports.status_addr); 75 (void)z_readb(hwif->io_ports.status_addr);
84 z_writeb(0x7c, hwif->io_ports.irq_addr); 76 z_writeb(0x7c, hwif->io_ports.irq_addr);
85} 77}
86 78
87static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base, 79static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base,
@@ -122,64 +114,89 @@ static const struct ide_port_info gayle_port_info = {
122 * Probe for a Gayle IDE interface (and optionally for an IDE doubler) 114 * Probe for a Gayle IDE interface (and optionally for an IDE doubler)
123 */ 115 */
124 116
125static int __init gayle_init(void) 117static int __init amiga_gayle_ide_probe(struct platform_device *pdev)
126{ 118{
127 unsigned long phys_base, res_start, res_n; 119 struct resource *res;
128 unsigned long base, ctrlport, irqport; 120 struct gayle_ide_platform_data *pdata;
129 int a4000, i, rc; 121 unsigned long base, ctrlport, irqport;
130 struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS]; 122 unsigned int i;
131 struct ide_port_info d = gayle_port_info; 123 int error;
132 124 struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS];
133 if (!MACH_IS_AMIGA) 125 struct ide_port_info d = gayle_port_info;
134 return -ENODEV; 126 struct ide_host *host;
135 127
136 if ((a4000 = AMIGAHW_PRESENT(A4000_IDE)) || AMIGAHW_PRESENT(A1200_IDE)) 128 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
137 goto found; 129 if (!res)
138 130 return -ENODEV;
139#ifdef CONFIG_ZORRO 131
140 if (zorro_find_device(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE, 132 if (!request_mem_region(res->start, resource_size(res), "IDE"))
141 NULL)) 133 return -EBUSY;
142 goto found; 134
143#endif 135 pdata = pdev->dev.platform_data;
144 return -ENODEV; 136 pr_info("ide: Gayle IDE controller (A%u style%s)\n",
145 137 pdata->explicit_ack ? 1200 : 4000,
146found: 138 ide_doubler ? ", IDE doubler" : "");
147 printk(KERN_INFO "ide: Gayle IDE controller (A%d style%s)\n", 139
148 a4000 ? 4000 : 1200, 140 base = (unsigned long)ZTWO_VADDR(pdata->base);
149 ide_doubler ? ", IDE doubler" : ""); 141 ctrlport = 0;
150 142 irqport = (unsigned long)ZTWO_VADDR(pdata->irqport);
151 if (a4000) { 143 if (pdata->explicit_ack)
152 phys_base = GAYLE_BASE_4000; 144 d.port_ops = &gayle_a1200_port_ops;
153 irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000); 145 else
154 d.port_ops = &gayle_a4000_port_ops; 146 d.port_ops = &gayle_a4000_port_ops;
155 } else { 147
156 phys_base = GAYLE_BASE_1200; 148 for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++, base += GAYLE_NEXT_PORT) {
157 irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_1200); 149 if (GAYLE_HAS_CONTROL_REG)
158 d.port_ops = &gayle_a1200_port_ops; 150 ctrlport = base + GAYLE_CONTROL;
151
152 gayle_setup_ports(&hw[i], base, ctrlport, irqport);
153 hws[i] = &hw[i];
159 } 154 }
160 155
161 res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1); 156 error = ide_host_add(&d, hws, i, &host);
162 res_n = GAYLE_IDEREG_SIZE; 157 if (error)
158 goto out;
163 159
164 if (!request_mem_region(res_start, res_n, "IDE")) 160 platform_set_drvdata(pdev, host);
165 return -EBUSY; 161 return 0;
166 162
167 for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) { 163out:
168 base = (unsigned long)ZTWO_VADDR(phys_base + i * GAYLE_NEXT_PORT); 164 release_mem_region(res->start, resource_size(res));
169 ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0; 165 return error;
166}
167
168static int __exit amiga_gayle_ide_remove(struct platform_device *pdev)
169{
170 struct ide_host *host = platform_get_drvdata(pdev);
171 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
172
173 ide_host_remove(host);
174 release_mem_region(res->start, resource_size(res));
175 return 0;
176}
170 177
171 gayle_setup_ports(&hw[i], base, ctrlport, irqport); 178static struct platform_driver amiga_gayle_ide_driver = {
179 .remove = __exit_p(amiga_gayle_ide_remove),
180 .driver = {
181 .name = "amiga-gayle-ide",
182 .owner = THIS_MODULE,
183 },
184};
172 185
173 hws[i] = &hw[i]; 186static int __init amiga_gayle_ide_init(void)
174 } 187{
188 return platform_driver_probe(&amiga_gayle_ide_driver,
189 amiga_gayle_ide_probe);
190}
175 191
176 rc = ide_host_add(&d, hws, i, NULL); 192module_init(amiga_gayle_ide_init);
177 if (rc)
178 release_mem_region(res_start, res_n);
179 193
180 return rc; 194static void __exit amiga_gayle_ide_exit(void)
195{
196 platform_driver_unregister(&amiga_gayle_ide_driver);
181} 197}
182 198
183module_init(gayle_init); 199module_exit(amiga_gayle_ide_exit);
184 200
185MODULE_LICENSE("GPL"); 201MODULE_LICENSE("GPL");
202MODULE_ALIAS("platform:amiga-gayle-ide");
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 3b128dce9c3a..33d65039cce9 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -407,32 +407,24 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
407 return 0; 407 return 0;
408} 408}
409 409
410static u64 ide_disk_set_capacity(ide_drive_t *drive, u64 capacity) 410static void ide_disk_unlock_native_capacity(ide_drive_t *drive)
411{ 411{
412 u64 set = min(capacity, drive->probed_capacity);
413 u16 *id = drive->id; 412 u16 *id = drive->id;
414 int lba48 = ata_id_lba48_enabled(id); 413 int lba48 = ata_id_lba48_enabled(id);
415 414
416 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 || 415 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 ||
417 ata_id_hpa_enabled(id) == 0) 416 ata_id_hpa_enabled(id) == 0)
418 goto out; 417 return;
419 418
420 /* 419 /*
421 * according to the spec the SET MAX ADDRESS command shall be 420 * according to the spec the SET MAX ADDRESS command shall be
422 * immediately preceded by a READ NATIVE MAX ADDRESS command 421 * immediately preceded by a READ NATIVE MAX ADDRESS command
423 */ 422 */
424 capacity = ide_disk_hpa_get_native_capacity(drive, lba48); 423 if (!ide_disk_hpa_get_native_capacity(drive, lba48))
425 if (capacity == 0) 424 return;
426 goto out; 425
427 426 if (ide_disk_hpa_set_capacity(drive, drive->probed_capacity, lba48))
428 set = ide_disk_hpa_set_capacity(drive, set, lba48); 427 drive->dev_flags |= IDE_DFLAG_NOHPA; /* disable HPA on resume */
429 if (set) {
430 /* needed for ->resume to disable HPA */
431 drive->dev_flags |= IDE_DFLAG_NOHPA;
432 return set;
433 }
434out:
435 return drive->capacity64;
436} 428}
437 429
438static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) 430static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
@@ -783,13 +775,13 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
783} 775}
784 776
785const struct ide_disk_ops ide_ata_disk_ops = { 777const struct ide_disk_ops ide_ata_disk_ops = {
786 .check = ide_disk_check, 778 .check = ide_disk_check,
787 .set_capacity = ide_disk_set_capacity, 779 .unlock_native_capacity = ide_disk_unlock_native_capacity,
788 .get_capacity = ide_disk_get_capacity, 780 .get_capacity = ide_disk_get_capacity,
789 .setup = ide_disk_setup, 781 .setup = ide_disk_setup,
790 .flush = ide_disk_flush, 782 .flush = ide_disk_flush,
791 .init_media = ide_disk_init_media, 783 .init_media = ide_disk_init_media,
792 .set_doorlock = ide_disk_set_doorlock, 784 .set_doorlock = ide_disk_set_doorlock,
793 .do_request = ide_do_rw_disk, 785 .do_request = ide_do_rw_disk,
794 .ioctl = ide_disk_ioctl, 786 .ioctl = ide_disk_ioctl,
795}; 787};
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 27d9fe08d80b..79399534782c 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -288,17 +288,14 @@ static int ide_gd_media_changed(struct gendisk *disk)
288 return ret; 288 return ret;
289} 289}
290 290
291static unsigned long long ide_gd_set_capacity(struct gendisk *disk, 291static void ide_gd_unlock_native_capacity(struct gendisk *disk)
292 unsigned long long capacity)
293{ 292{
294 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); 293 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
295 ide_drive_t *drive = idkp->drive; 294 ide_drive_t *drive = idkp->drive;
296 const struct ide_disk_ops *disk_ops = drive->disk_ops; 295 const struct ide_disk_ops *disk_ops = drive->disk_ops;
297 296
298 if (disk_ops->set_capacity) 297 if (disk_ops->unlock_native_capacity)
299 return disk_ops->set_capacity(drive, capacity); 298 disk_ops->unlock_native_capacity(drive);
300
301 return drive->capacity64;
302} 299}
303 300
304static int ide_gd_revalidate_disk(struct gendisk *disk) 301static int ide_gd_revalidate_disk(struct gendisk *disk)
@@ -329,7 +326,7 @@ static const struct block_device_operations ide_gd_ops = {
329 .locked_ioctl = ide_gd_ioctl, 326 .locked_ioctl = ide_gd_ioctl,
330 .getgeo = ide_gd_getgeo, 327 .getgeo = ide_gd_getgeo,
331 .media_changed = ide_gd_media_changed, 328 .media_changed = ide_gd_media_changed,
332 .set_capacity = ide_gd_set_capacity, 329 .unlock_native_capacity = ide_gd_unlock_native_capacity,
333 .revalidate_disk = ide_gd_revalidate_disk 330 .revalidate_disk = ide_gd_revalidate_disk
334}; 331};
335 332
diff --git a/drivers/ide/ide_platform.c b/drivers/ide/ide_platform.c
index 42965b3e30b9..542603b394e4 100644
--- a/drivers/ide/ide_platform.c
+++ b/drivers/ide/ide_platform.c
@@ -95,6 +95,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
95 plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start); 95 plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start);
96 hw.dev = &pdev->dev; 96 hw.dev = &pdev->dev;
97 97
98 d.irq_flags = res_irq->flags;
98 if (mmio) 99 if (mmio)
99 d.host_flags |= IDE_HFLAG_MMIO; 100 d.host_flags |= IDE_HFLAG_MMIO;
100 101
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index c5f3841af360..3a35ec6193d2 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -93,13 +93,13 @@ static int pdc202xx_test_irq(ide_hwif_t *hwif)
93 * bit 7: error, bit 6: interrupting, 93 * bit 7: error, bit 6: interrupting,
94 * bit 5: FIFO full, bit 4: FIFO empty 94 * bit 5: FIFO full, bit 4: FIFO empty
95 */ 95 */
96 return ((sc1d & 0x50) == 0x50) ? 1 : 0; 96 return (sc1d & 0x40) ? 1 : 0;
97 } else { 97 } else {
98 /* 98 /*
99 * bit 3: error, bit 2: interrupting, 99 * bit 3: error, bit 2: interrupting,
100 * bit 1: FIFO full, bit 0: FIFO empty 100 * bit 1: FIFO full, bit 0: FIFO empty
101 */ 101 */
102 return ((sc1d & 0x05) == 0x05) ? 1 : 0; 102 return (sc1d & 0x04) ? 1 : 0;
103 } 103 }
104} 104}
105 105
@@ -241,6 +241,7 @@ static const struct ide_port_ops pdc20246_port_ops = {
241static const struct ide_port_ops pdc2026x_port_ops = { 241static const struct ide_port_ops pdc2026x_port_ops = {
242 .set_pio_mode = pdc202xx_set_pio_mode, 242 .set_pio_mode = pdc202xx_set_pio_mode,
243 .set_dma_mode = pdc202xx_set_mode, 243 .set_dma_mode = pdc202xx_set_mode,
244 .test_irq = pdc202xx_test_irq,
244 .cable_detect = pdc2026x_cable_detect, 245 .cable_detect = pdc2026x_cable_detect,
245}; 246};
246 247
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index 159955d16c47..ebcf8e470a97 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -1153,7 +1153,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1153 1153
1154 if (macio_resource_count(mdev) == 0) { 1154 if (macio_resource_count(mdev) == 0) {
1155 printk(KERN_WARNING "ide-pmac: no address for %s\n", 1155 printk(KERN_WARNING "ide-pmac: no address for %s\n",
1156 mdev->ofdev.node->full_name); 1156 mdev->ofdev.dev.of_node->full_name);
1157 rc = -ENXIO; 1157 rc = -ENXIO;
1158 goto out_free_pmif; 1158 goto out_free_pmif;
1159 } 1159 }
@@ -1161,7 +1161,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1161 /* Request memory resource for IO ports */ 1161 /* Request memory resource for IO ports */
1162 if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) { 1162 if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) {
1163 printk(KERN_ERR "ide-pmac: can't request MMIO resource for " 1163 printk(KERN_ERR "ide-pmac: can't request MMIO resource for "
1164 "%s!\n", mdev->ofdev.node->full_name); 1164 "%s!\n", mdev->ofdev.dev.of_node->full_name);
1165 rc = -EBUSY; 1165 rc = -EBUSY;
1166 goto out_free_pmif; 1166 goto out_free_pmif;
1167 } 1167 }
@@ -1173,7 +1173,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1173 */ 1173 */
1174 if (macio_irq_count(mdev) == 0) { 1174 if (macio_irq_count(mdev) == 0) {
1175 printk(KERN_WARNING "ide-pmac: no intrs for device %s, using " 1175 printk(KERN_WARNING "ide-pmac: no intrs for device %s, using "
1176 "13\n", mdev->ofdev.node->full_name); 1176 "13\n", mdev->ofdev.dev.of_node->full_name);
1177 irq = irq_create_mapping(NULL, 13); 1177 irq = irq_create_mapping(NULL, 13);
1178 } else 1178 } else
1179 irq = macio_irq(mdev, 0); 1179 irq = macio_irq(mdev, 0);
@@ -1182,7 +1182,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1182 regbase = (unsigned long) base; 1182 regbase = (unsigned long) base;
1183 1183
1184 pmif->mdev = mdev; 1184 pmif->mdev = mdev;
1185 pmif->node = mdev->ofdev.node; 1185 pmif->node = mdev->ofdev.dev.of_node;
1186 pmif->regbase = regbase; 1186 pmif->regbase = regbase;
1187 pmif->irq = irq; 1187 pmif->irq = irq;
1188 pmif->kauai_fcr = NULL; 1188 pmif->kauai_fcr = NULL;
@@ -1191,7 +1191,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1191 if (macio_request_resource(mdev, 1, "ide-pmac (dma)")) 1191 if (macio_request_resource(mdev, 1, "ide-pmac (dma)"))
1192 printk(KERN_WARNING "ide-pmac: can't request DMA " 1192 printk(KERN_WARNING "ide-pmac: can't request DMA "
1193 "resource for %s!\n", 1193 "resource for %s!\n",
1194 mdev->ofdev.node->full_name); 1194 mdev->ofdev.dev.of_node->full_name);
1195 else 1195 else
1196 pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000); 1196 pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000);
1197 } else 1197 } else
@@ -1400,8 +1400,11 @@ static struct of_device_id pmac_ide_macio_match[] =
1400 1400
1401static struct macio_driver pmac_ide_macio_driver = 1401static struct macio_driver pmac_ide_macio_driver =
1402{ 1402{
1403 .name = "ide-pmac", 1403 .driver = {
1404 .match_table = pmac_ide_macio_match, 1404 .name = "ide-pmac",
1405 .owner = THIS_MODULE,
1406 .of_match_table = pmac_ide_macio_match,
1407 },
1405 .probe = pmac_ide_macio_attach, 1408 .probe = pmac_ide_macio_attach,
1406 .suspend = pmac_ide_macio_suspend, 1409 .suspend = pmac_ide_macio_suspend,
1407 .resume = pmac_ide_macio_resume, 1410 .resume = pmac_ide_macio_resume,