diff options
Diffstat (limited to 'drivers')
235 files changed, 4016 insertions, 3318 deletions
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index b1ae48054dc5..b7078afddb74 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c | |||
@@ -238,7 +238,7 @@ static int __devexit ahci_remove(struct platform_device *pdev) | |||
238 | return 0; | 238 | return 0; |
239 | } | 239 | } |
240 | 240 | ||
241 | #ifdef CONFIG_PM | 241 | #ifdef CONFIG_PM_SLEEP |
242 | static int ahci_suspend(struct device *dev) | 242 | static int ahci_suspend(struct device *dev) |
243 | { | 243 | { |
244 | struct ahci_platform_data *pdata = dev_get_platdata(dev); | 244 | struct ahci_platform_data *pdata = dev_get_platdata(dev); |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index fd9ecf74e631..5b0ba3f20edc 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -1105,10 +1105,15 @@ static int ata_acpi_bind_device(struct ata_port *ap, struct scsi_device *sdev, | |||
1105 | struct acpi_device *acpi_dev; | 1105 | struct acpi_device *acpi_dev; |
1106 | struct acpi_device_power_state *states; | 1106 | struct acpi_device_power_state *states; |
1107 | 1107 | ||
1108 | if (ap->flags & ATA_FLAG_ACPI_SATA) | 1108 | if (ap->flags & ATA_FLAG_ACPI_SATA) { |
1109 | ata_dev = &ap->link.device[sdev->channel]; | 1109 | if (!sata_pmp_attached(ap)) |
1110 | else | 1110 | ata_dev = &ap->link.device[sdev->id]; |
1111 | else | ||
1112 | ata_dev = &ap->pmp_link[sdev->channel].device[sdev->id]; | ||
1113 | } | ||
1114 | else { | ||
1111 | ata_dev = &ap->link.device[sdev->id]; | 1115 | ata_dev = &ap->link.device[sdev->id]; |
1116 | } | ||
1112 | 1117 | ||
1113 | *handle = ata_dev_acpi_handle(ata_dev); | 1118 | *handle = ata_dev_acpi_handle(ata_dev); |
1114 | 1119 | ||
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 3cc7096cfda7..f46fbd3bd3fb 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -2942,6 +2942,10 @@ const struct ata_timing *ata_timing_find_mode(u8 xfer_mode) | |||
2942 | 2942 | ||
2943 | if (xfer_mode == t->mode) | 2943 | if (xfer_mode == t->mode) |
2944 | return t; | 2944 | return t; |
2945 | |||
2946 | WARN_ONCE(true, "%s: unable to find timing for xfer_mode 0x%x\n", | ||
2947 | __func__, xfer_mode); | ||
2948 | |||
2945 | return NULL; | 2949 | return NULL; |
2946 | } | 2950 | } |
2947 | 2951 | ||
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index e3bda074fa12..a6df6a351d6e 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -1052,6 +1052,8 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev) | |||
1052 | { | 1052 | { |
1053 | sdev->use_10_for_rw = 1; | 1053 | sdev->use_10_for_rw = 1; |
1054 | sdev->use_10_for_ms = 1; | 1054 | sdev->use_10_for_ms = 1; |
1055 | sdev->no_report_opcodes = 1; | ||
1056 | sdev->no_write_same = 1; | ||
1055 | 1057 | ||
1056 | /* Schedule policy is determined by ->qc_defer() callback and | 1058 | /* Schedule policy is determined by ->qc_defer() callback and |
1057 | * it needs to see every deferred qc. Set dev_blocked to 1 to | 1059 | * it needs to see every deferred qc. Set dev_blocked to 1 to |
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c index 26201ebef3ca..371fd2c698b7 100644 --- a/drivers/ata/pata_arasan_cf.c +++ b/drivers/ata/pata_arasan_cf.c | |||
@@ -317,6 +317,12 @@ static int cf_init(struct arasan_cf_dev *acdev) | |||
317 | return ret; | 317 | return ret; |
318 | } | 318 | } |
319 | 319 | ||
320 | ret = clk_set_rate(acdev->clk, 166000000); | ||
321 | if (ret) { | ||
322 | dev_warn(acdev->host->dev, "clock set rate failed"); | ||
323 | return ret; | ||
324 | } | ||
325 | |||
320 | spin_lock_irqsave(&acdev->host->lock, flags); | 326 | spin_lock_irqsave(&acdev->host->lock, flags); |
321 | /* configure CF interface clock */ | 327 | /* configure CF interface clock */ |
322 | writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk : | 328 | writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk : |
@@ -908,7 +914,7 @@ static int __devexit arasan_cf_remove(struct platform_device *pdev) | |||
908 | return 0; | 914 | return 0; |
909 | } | 915 | } |
910 | 916 | ||
911 | #ifdef CONFIG_PM | 917 | #ifdef CONFIG_PM_SLEEP |
912 | static int arasan_cf_suspend(struct device *dev) | 918 | static int arasan_cf_suspend(struct device *dev) |
913 | { | 919 | { |
914 | struct ata_host *host = dev_get_drvdata(dev); | 920 | struct ata_host *host = dev_get_drvdata(dev); |
diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c index 0d7c4c2cd26f..400bf1c3e982 100644 --- a/drivers/ata/sata_highbank.c +++ b/drivers/ata/sata_highbank.c | |||
@@ -260,7 +260,7 @@ static const struct of_device_id ahci_of_match[] = { | |||
260 | }; | 260 | }; |
261 | MODULE_DEVICE_TABLE(of, ahci_of_match); | 261 | MODULE_DEVICE_TABLE(of, ahci_of_match); |
262 | 262 | ||
263 | static int __init ahci_highbank_probe(struct platform_device *pdev) | 263 | static int __devinit ahci_highbank_probe(struct platform_device *pdev) |
264 | { | 264 | { |
265 | struct device *dev = &pdev->dev; | 265 | struct device *dev = &pdev->dev; |
266 | struct ahci_host_priv *hpriv; | 266 | struct ahci_host_priv *hpriv; |
@@ -378,7 +378,7 @@ static int __devexit ahci_highbank_remove(struct platform_device *pdev) | |||
378 | return 0; | 378 | return 0; |
379 | } | 379 | } |
380 | 380 | ||
381 | #ifdef CONFIG_PM | 381 | #ifdef CONFIG_PM_SLEEP |
382 | static int ahci_highbank_suspend(struct device *dev) | 382 | static int ahci_highbank_suspend(struct device *dev) |
383 | { | 383 | { |
384 | struct ata_host *host = dev_get_drvdata(dev); | 384 | struct ata_host *host = dev_get_drvdata(dev); |
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index 44a4256533e1..08608de87e4e 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c | |||
@@ -142,6 +142,39 @@ static int k2_sata_scr_write(struct ata_link *link, | |||
142 | return 0; | 142 | return 0; |
143 | } | 143 | } |
144 | 144 | ||
145 | static int k2_sata_softreset(struct ata_link *link, | ||
146 | unsigned int *class, unsigned long deadline) | ||
147 | { | ||
148 | u8 dmactl; | ||
149 | void __iomem *mmio = link->ap->ioaddr.bmdma_addr; | ||
150 | |||
151 | dmactl = readb(mmio + ATA_DMA_CMD); | ||
152 | |||
153 | /* Clear the start bit */ | ||
154 | if (dmactl & ATA_DMA_START) { | ||
155 | dmactl &= ~ATA_DMA_START; | ||
156 | writeb(dmactl, mmio + ATA_DMA_CMD); | ||
157 | } | ||
158 | |||
159 | return ata_sff_softreset(link, class, deadline); | ||
160 | } | ||
161 | |||
162 | static int k2_sata_hardreset(struct ata_link *link, | ||
163 | unsigned int *class, unsigned long deadline) | ||
164 | { | ||
165 | u8 dmactl; | ||
166 | void __iomem *mmio = link->ap->ioaddr.bmdma_addr; | ||
167 | |||
168 | dmactl = readb(mmio + ATA_DMA_CMD); | ||
169 | |||
170 | /* Clear the start bit */ | ||
171 | if (dmactl & ATA_DMA_START) { | ||
172 | dmactl &= ~ATA_DMA_START; | ||
173 | writeb(dmactl, mmio + ATA_DMA_CMD); | ||
174 | } | ||
175 | |||
176 | return sata_sff_hardreset(link, class, deadline); | ||
177 | } | ||
145 | 178 | ||
146 | static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | 179 | static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) |
147 | { | 180 | { |
@@ -346,6 +379,8 @@ static struct scsi_host_template k2_sata_sht = { | |||
346 | 379 | ||
347 | static struct ata_port_operations k2_sata_ops = { | 380 | static struct ata_port_operations k2_sata_ops = { |
348 | .inherits = &ata_bmdma_port_ops, | 381 | .inherits = &ata_bmdma_port_ops, |
382 | .softreset = k2_sata_softreset, | ||
383 | .hardreset = k2_sata_hardreset, | ||
349 | .sff_tf_load = k2_sata_tf_load, | 384 | .sff_tf_load = k2_sata_tf_load, |
350 | .sff_tf_read = k2_sata_tf_read, | 385 | .sff_tf_read = k2_sata_tf_read, |
351 | .sff_check_status = k2_stat_check_status, | 386 | .sff_check_status = k2_stat_check_status, |
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c index 89b30f32ba68..ff7bb8a42ed6 100644 --- a/drivers/atm/ambassador.c +++ b/drivers/atm/ambassador.c | |||
@@ -1961,6 +1961,7 @@ static int __devinit ucode_init (loader_block * lb, amb_dev * dev) { | |||
1961 | res = loader_verify(lb, dev, rec); | 1961 | res = loader_verify(lb, dev, rec); |
1962 | if (res) | 1962 | if (res) |
1963 | break; | 1963 | break; |
1964 | rec = ihex_next_binrec(rec); | ||
1964 | } | 1965 | } |
1965 | release_firmware(fw); | 1966 | release_firmware(fw); |
1966 | if (!res) | 1967 | if (!res) |
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index 74a67e0019a2..fbbd4ed2edf2 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c | |||
@@ -451,7 +451,7 @@ int dev_pm_qos_add_ancestor_request(struct device *dev, | |||
451 | if (ancestor) | 451 | if (ancestor) |
452 | error = dev_pm_qos_add_request(ancestor, req, value); | 452 | error = dev_pm_qos_add_request(ancestor, req, value); |
453 | 453 | ||
454 | if (error) | 454 | if (error < 0) |
455 | req->dev = NULL; | 455 | req->dev = NULL; |
456 | 456 | ||
457 | return error; | 457 | return error; |
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index 3804a0af3ef1..9fe4f1865558 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -935,7 +935,7 @@ aoe_end_request(struct aoedev *d, struct request *rq, int fastfail) | |||
935 | 935 | ||
936 | /* cf. http://lkml.org/lkml/2006/10/31/28 */ | 936 | /* cf. http://lkml.org/lkml/2006/10/31/28 */ |
937 | if (!fastfail) | 937 | if (!fastfail) |
938 | q->request_fn(q); | 938 | __blk_run_queue(q); |
939 | } | 939 | } |
940 | 940 | ||
941 | static void | 941 | static void |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 1c49d7173966..2ddd64a9ffde 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -4330,6 +4330,7 @@ out_unreg_region: | |||
4330 | out_unreg_blkdev: | 4330 | out_unreg_blkdev: |
4331 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 4331 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
4332 | out_put_disk: | 4332 | out_put_disk: |
4333 | destroy_workqueue(floppy_wq); | ||
4333 | for (drive = 0; drive < N_DRIVE; drive++) { | 4334 | for (drive = 0; drive < N_DRIVE; drive++) { |
4334 | if (!disks[drive]) | 4335 | if (!disks[drive]) |
4335 | break; | 4336 | break; |
@@ -4340,7 +4341,6 @@ out_put_disk: | |||
4340 | } | 4341 | } |
4341 | put_disk(disks[drive]); | 4342 | put_disk(disks[drive]); |
4342 | } | 4343 | } |
4343 | destroy_workqueue(floppy_wq); | ||
4344 | return err; | 4344 | return err; |
4345 | } | 4345 | } |
4346 | 4346 | ||
@@ -4555,6 +4555,8 @@ static void __exit floppy_module_exit(void) | |||
4555 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 4555 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
4556 | platform_driver_unregister(&floppy_driver); | 4556 | platform_driver_unregister(&floppy_driver); |
4557 | 4557 | ||
4558 | destroy_workqueue(floppy_wq); | ||
4559 | |||
4558 | for (drive = 0; drive < N_DRIVE; drive++) { | 4560 | for (drive = 0; drive < N_DRIVE; drive++) { |
4559 | del_timer_sync(&motor_off_timer[drive]); | 4561 | del_timer_sync(&motor_off_timer[drive]); |
4560 | 4562 | ||
@@ -4578,7 +4580,6 @@ static void __exit floppy_module_exit(void) | |||
4578 | 4580 | ||
4579 | cancel_delayed_work_sync(&fd_timeout); | 4581 | cancel_delayed_work_sync(&fd_timeout); |
4580 | cancel_delayed_work_sync(&fd_timer); | 4582 | cancel_delayed_work_sync(&fd_timer); |
4581 | destroy_workqueue(floppy_wq); | ||
4582 | 4583 | ||
4583 | if (atomic_read(&usage_count)) | 4584 | if (atomic_read(&usage_count)) |
4584 | floppy_release_irq_and_dma(); | 4585 | floppy_release_irq_and_dma(); |
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index adc6f36564cf..9694dd99bbbc 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c | |||
@@ -559,7 +559,7 @@ static void mtip_timeout_function(unsigned long int data) | |||
559 | struct mtip_cmd *command; | 559 | struct mtip_cmd *command; |
560 | int tag, cmdto_cnt = 0; | 560 | int tag, cmdto_cnt = 0; |
561 | unsigned int bit, group; | 561 | unsigned int bit, group; |
562 | unsigned int num_command_slots = port->dd->slot_groups * 32; | 562 | unsigned int num_command_slots; |
563 | unsigned long to, tagaccum[SLOTBITS_IN_LONGS]; | 563 | unsigned long to, tagaccum[SLOTBITS_IN_LONGS]; |
564 | 564 | ||
565 | if (unlikely(!port)) | 565 | if (unlikely(!port)) |
@@ -572,6 +572,7 @@ static void mtip_timeout_function(unsigned long int data) | |||
572 | } | 572 | } |
573 | /* clear the tag accumulator */ | 573 | /* clear the tag accumulator */ |
574 | memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long)); | 574 | memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long)); |
575 | num_command_slots = port->dd->slot_groups * 32; | ||
575 | 576 | ||
576 | for (tag = 0; tag < num_command_slots; tag++) { | 577 | for (tag = 0; tag < num_command_slots; tag++) { |
577 | /* | 578 | /* |
@@ -2218,8 +2219,8 @@ static int exec_drive_taskfile(struct driver_data *dd, | |||
2218 | fis.device); | 2219 | fis.device); |
2219 | 2220 | ||
2220 | /* check for erase mode support during secure erase.*/ | 2221 | /* check for erase mode support during secure erase.*/ |
2221 | if ((fis.command == ATA_CMD_SEC_ERASE_UNIT) | 2222 | if ((fis.command == ATA_CMD_SEC_ERASE_UNIT) && outbuf && |
2222 | && (outbuf[0] & MTIP_SEC_ERASE_MODE)) { | 2223 | (outbuf[0] & MTIP_SEC_ERASE_MODE)) { |
2223 | erasemode = 1; | 2224 | erasemode = 1; |
2224 | } | 2225 | } |
2225 | 2226 | ||
@@ -2439,7 +2440,7 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned int cmd, | |||
2439 | * return value | 2440 | * return value |
2440 | * None | 2441 | * None |
2441 | */ | 2442 | */ |
2442 | static void mtip_hw_submit_io(struct driver_data *dd, sector_t start, | 2443 | static void mtip_hw_submit_io(struct driver_data *dd, sector_t sector, |
2443 | int nsect, int nents, int tag, void *callback, | 2444 | int nsect, int nents, int tag, void *callback, |
2444 | void *data, int dir) | 2445 | void *data, int dir) |
2445 | { | 2446 | { |
@@ -2447,6 +2448,7 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start, | |||
2447 | struct mtip_port *port = dd->port; | 2448 | struct mtip_port *port = dd->port; |
2448 | struct mtip_cmd *command = &port->commands[tag]; | 2449 | struct mtip_cmd *command = &port->commands[tag]; |
2449 | int dma_dir = (dir == READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | 2450 | int dma_dir = (dir == READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; |
2451 | u64 start = sector; | ||
2450 | 2452 | ||
2451 | /* Map the scatter list for DMA access */ | 2453 | /* Map the scatter list for DMA access */ |
2452 | nents = dma_map_sg(&dd->pdev->dev, command->sg, nents, dma_dir); | 2454 | nents = dma_map_sg(&dd->pdev->dev, command->sg, nents, dma_dir); |
@@ -2465,8 +2467,12 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start, | |||
2465 | fis->opts = 1 << 7; | 2467 | fis->opts = 1 << 7; |
2466 | fis->command = | 2468 | fis->command = |
2467 | (dir == READ ? ATA_CMD_FPDMA_READ : ATA_CMD_FPDMA_WRITE); | 2469 | (dir == READ ? ATA_CMD_FPDMA_READ : ATA_CMD_FPDMA_WRITE); |
2468 | *((unsigned int *) &fis->lba_low) = (start & 0xFFFFFF); | 2470 | fis->lba_low = start & 0xFF; |
2469 | *((unsigned int *) &fis->lba_low_ex) = ((start >> 24) & 0xFFFFFF); | 2471 | fis->lba_mid = (start >> 8) & 0xFF; |
2472 | fis->lba_hi = (start >> 16) & 0xFF; | ||
2473 | fis->lba_low_ex = (start >> 24) & 0xFF; | ||
2474 | fis->lba_mid_ex = (start >> 32) & 0xFF; | ||
2475 | fis->lba_hi_ex = (start >> 40) & 0xFF; | ||
2470 | fis->device = 1 << 6; | 2476 | fis->device = 1 << 6; |
2471 | fis->features = nsect & 0xFF; | 2477 | fis->features = nsect & 0xFF; |
2472 | fis->features_ex = (nsect >> 8) & 0xFF; | 2478 | fis->features_ex = (nsect >> 8) & 0xFF; |
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h index 5f4a917bd8bb..b1742640556a 100644 --- a/drivers/block/mtip32xx/mtip32xx.h +++ b/drivers/block/mtip32xx/mtip32xx.h | |||
@@ -34,7 +34,7 @@ | |||
34 | #define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48 | 34 | #define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48 |
35 | 35 | ||
36 | /* check for erase mode support during secure erase */ | 36 | /* check for erase mode support during secure erase */ |
37 | #define MTIP_SEC_ERASE_MODE 0x3 | 37 | #define MTIP_SEC_ERASE_MODE 0x2 |
38 | 38 | ||
39 | /* # of times to retry timed out/failed IOs */ | 39 | /* # of times to retry timed out/failed IOs */ |
40 | #define MTIP_MAX_RETRIES 2 | 40 | #define MTIP_MAX_RETRIES 2 |
@@ -155,14 +155,14 @@ enum { | |||
155 | MTIP_DDF_REBUILD_FAILED_BIT = 8, | 155 | MTIP_DDF_REBUILD_FAILED_BIT = 8, |
156 | }; | 156 | }; |
157 | 157 | ||
158 | __packed struct smart_attr{ | 158 | struct smart_attr { |
159 | u8 attr_id; | 159 | u8 attr_id; |
160 | u16 flags; | 160 | u16 flags; |
161 | u8 cur; | 161 | u8 cur; |
162 | u8 worst; | 162 | u8 worst; |
163 | u32 data; | 163 | u32 data; |
164 | u8 res[3]; | 164 | u8 res[3]; |
165 | }; | 165 | } __packed; |
166 | 166 | ||
167 | /* Register Frame Information Structure (FIS), host to device. */ | 167 | /* Register Frame Information Structure (FIS), host to device. */ |
168 | struct host_to_dev_fis { | 168 | struct host_to_dev_fis { |
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index fc2de5528dcc..b00000e8aef6 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c | |||
@@ -67,6 +67,7 @@ static struct usb_device_id ath3k_table[] = { | |||
67 | { USB_DEVICE(0x13d3, 0x3304) }, | 67 | { USB_DEVICE(0x13d3, 0x3304) }, |
68 | { USB_DEVICE(0x0930, 0x0215) }, | 68 | { USB_DEVICE(0x0930, 0x0215) }, |
69 | { USB_DEVICE(0x0489, 0xE03D) }, | 69 | { USB_DEVICE(0x0489, 0xE03D) }, |
70 | { USB_DEVICE(0x0489, 0xE027) }, | ||
70 | 71 | ||
71 | /* Atheros AR9285 Malbec with sflash firmware */ | 72 | /* Atheros AR9285 Malbec with sflash firmware */ |
72 | { USB_DEVICE(0x03F0, 0x311D) }, | 73 | { USB_DEVICE(0x03F0, 0x311D) }, |
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index debda27df9b0..ee82f2fb65f0 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -124,6 +124,7 @@ static struct usb_device_id blacklist_table[] = { | |||
124 | { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE }, | 124 | { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE }, |
125 | { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE }, | 125 | { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE }, |
126 | { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE }, | 126 | { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE }, |
127 | { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE }, | ||
127 | 128 | ||
128 | /* Atheros AR9285 Malbec with sflash firmware */ | 129 | /* Atheros AR9285 Malbec with sflash firmware */ |
129 | { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE }, | 130 | { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE }, |
diff --git a/drivers/bus/omap-ocp2scp.c b/drivers/bus/omap-ocp2scp.c index ff63560b8467..0c48b0e05ed6 100644 --- a/drivers/bus/omap-ocp2scp.c +++ b/drivers/bus/omap-ocp2scp.c | |||
@@ -22,6 +22,26 @@ | |||
22 | #include <linux/pm_runtime.h> | 22 | #include <linux/pm_runtime.h> |
23 | #include <linux/of.h> | 23 | #include <linux/of.h> |
24 | #include <linux/of_platform.h> | 24 | #include <linux/of_platform.h> |
25 | #include <linux/platform_data/omap_ocp2scp.h> | ||
26 | |||
27 | /** | ||
28 | * _count_resources - count for the number of resources | ||
29 | * @res: struct resource * | ||
30 | * | ||
31 | * Count and return the number of resources populated for the device that is | ||
32 | * connected to ocp2scp. | ||
33 | */ | ||
34 | static unsigned _count_resources(struct resource *res) | ||
35 | { | ||
36 | int cnt = 0; | ||
37 | |||
38 | while (res->start != res->end) { | ||
39 | cnt++; | ||
40 | res++; | ||
41 | } | ||
42 | |||
43 | return cnt; | ||
44 | } | ||
25 | 45 | ||
26 | static int ocp2scp_remove_devices(struct device *dev, void *c) | 46 | static int ocp2scp_remove_devices(struct device *dev, void *c) |
27 | { | 47 | { |
@@ -34,20 +54,62 @@ static int ocp2scp_remove_devices(struct device *dev, void *c) | |||
34 | 54 | ||
35 | static int __devinit omap_ocp2scp_probe(struct platform_device *pdev) | 55 | static int __devinit omap_ocp2scp_probe(struct platform_device *pdev) |
36 | { | 56 | { |
37 | int ret; | 57 | int ret; |
38 | struct device_node *np = pdev->dev.of_node; | 58 | unsigned res_cnt, i; |
59 | struct device_node *np = pdev->dev.of_node; | ||
60 | struct platform_device *pdev_child; | ||
61 | struct omap_ocp2scp_platform_data *pdata = pdev->dev.platform_data; | ||
62 | struct omap_ocp2scp_dev *dev; | ||
39 | 63 | ||
40 | if (np) { | 64 | if (np) { |
41 | ret = of_platform_populate(np, NULL, NULL, &pdev->dev); | 65 | ret = of_platform_populate(np, NULL, NULL, &pdev->dev); |
42 | if (ret) { | 66 | if (ret) { |
43 | dev_err(&pdev->dev, "failed to add resources for ocp2scp child\n"); | 67 | dev_err(&pdev->dev, |
68 | "failed to add resources for ocp2scp child\n"); | ||
44 | goto err0; | 69 | goto err0; |
45 | } | 70 | } |
71 | } else if (pdata) { | ||
72 | for (i = 0, dev = *pdata->devices; i < pdata->dev_cnt; i++, | ||
73 | dev++) { | ||
74 | res_cnt = _count_resources(dev->res); | ||
75 | |||
76 | pdev_child = platform_device_alloc(dev->drv_name, | ||
77 | PLATFORM_DEVID_AUTO); | ||
78 | if (!pdev_child) { | ||
79 | dev_err(&pdev->dev, | ||
80 | "failed to allocate mem for ocp2scp child\n"); | ||
81 | goto err0; | ||
82 | } | ||
83 | |||
84 | ret = platform_device_add_resources(pdev_child, | ||
85 | dev->res, res_cnt); | ||
86 | if (ret) { | ||
87 | dev_err(&pdev->dev, | ||
88 | "failed to add resources for ocp2scp child\n"); | ||
89 | goto err1; | ||
90 | } | ||
91 | |||
92 | pdev_child->dev.parent = &pdev->dev; | ||
93 | |||
94 | ret = platform_device_add(pdev_child); | ||
95 | if (ret) { | ||
96 | dev_err(&pdev->dev, | ||
97 | "failed to register ocp2scp child device\n"); | ||
98 | goto err1; | ||
99 | } | ||
100 | } | ||
101 | } else { | ||
102 | dev_err(&pdev->dev, "OCP2SCP initialized without plat data\n"); | ||
103 | return -EINVAL; | ||
46 | } | 104 | } |
105 | |||
47 | pm_runtime_enable(&pdev->dev); | 106 | pm_runtime_enable(&pdev->dev); |
48 | 107 | ||
49 | return 0; | 108 | return 0; |
50 | 109 | ||
110 | err1: | ||
111 | platform_device_put(pdev_child); | ||
112 | |||
51 | err0: | 113 | err0: |
52 | device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices); | 114 | device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices); |
53 | 115 | ||
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index fbd9b2b850ef..c58ea9b80b1a 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig | |||
@@ -127,12 +127,12 @@ config HW_RANDOM_VIA | |||
127 | If unsure, say Y. | 127 | If unsure, say Y. |
128 | 128 | ||
129 | config HW_RANDOM_IXP4XX | 129 | config HW_RANDOM_IXP4XX |
130 | tristate "Intel IXP4xx NPU HW Random Number Generator support" | 130 | tristate "Intel IXP4xx NPU HW Pseudo-Random Number Generator support" |
131 | depends on HW_RANDOM && ARCH_IXP4XX | 131 | depends on HW_RANDOM && ARCH_IXP4XX |
132 | default HW_RANDOM | 132 | default HW_RANDOM |
133 | ---help--- | 133 | ---help--- |
134 | This driver provides kernel-side support for the Random | 134 | This driver provides kernel-side support for the Pseudo-Random |
135 | Number Generator hardware found on the Intel IXP4xx NPU. | 135 | Number Generator hardware found on the Intel IXP45x/46x NPU. |
136 | 136 | ||
137 | To compile this driver as a module, choose M here: the | 137 | To compile this driver as a module, choose M here: the |
138 | module will be called ixp4xx-rng. | 138 | module will be called ixp4xx-rng. |
diff --git a/drivers/char/hw_random/ixp4xx-rng.c b/drivers/char/hw_random/ixp4xx-rng.c index 263567f5f392..beec1627db3c 100644 --- a/drivers/char/hw_random/ixp4xx-rng.c +++ b/drivers/char/hw_random/ixp4xx-rng.c | |||
@@ -45,6 +45,9 @@ static int __init ixp4xx_rng_init(void) | |||
45 | void __iomem * rng_base; | 45 | void __iomem * rng_base; |
46 | int err; | 46 | int err; |
47 | 47 | ||
48 | if (!cpu_is_ixp46x()) /* includes IXP455 */ | ||
49 | return -ENOSYS; | ||
50 | |||
48 | rng_base = ioremap(0x70002100, 4); | 51 | rng_base = ioremap(0x70002100, 4); |
49 | if (!rng_base) | 52 | if (!rng_base) |
50 | return -ENOMEM; | 53 | return -ENOMEM; |
@@ -68,5 +71,5 @@ module_init(ixp4xx_rng_init); | |||
68 | module_exit(ixp4xx_rng_exit); | 71 | module_exit(ixp4xx_rng_exit); |
69 | 72 | ||
70 | MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>"); | 73 | MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>"); |
71 | MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for IXP4xx"); | 74 | MODULE_DESCRIPTION("H/W Pseudo-Random Number Generator (RNG) driver for IXP45x/46x"); |
72 | MODULE_LICENSE("GPL"); | 75 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index 0bb207eaef2f..54a3a6d09819 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
@@ -285,7 +285,7 @@ static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd, | |||
285 | 285 | ||
286 | static const struct file_operations raw_fops = { | 286 | static const struct file_operations raw_fops = { |
287 | .read = do_sync_read, | 287 | .read = do_sync_read, |
288 | .aio_read = blkdev_aio_read, | 288 | .aio_read = generic_file_aio_read, |
289 | .write = do_sync_write, | 289 | .write = do_sync_write, |
290 | .aio_write = blkdev_aio_write, | 290 | .aio_write = blkdev_aio_write, |
291 | .fsync = blkdev_fsync, | 291 | .fsync = blkdev_fsync, |
diff --git a/drivers/clk/ux500/u8500_clk.c b/drivers/clk/ux500/u8500_clk.c index ca4a25ed844c..e2c17d187d98 100644 --- a/drivers/clk/ux500/u8500_clk.c +++ b/drivers/clk/ux500/u8500_clk.c | |||
@@ -40,7 +40,7 @@ void u8500_clk_init(void) | |||
40 | CLK_IS_ROOT|CLK_IGNORE_UNUSED, | 40 | CLK_IS_ROOT|CLK_IGNORE_UNUSED, |
41 | 32768); | 41 | 32768); |
42 | clk_register_clkdev(clk, "clk32k", NULL); | 42 | clk_register_clkdev(clk, "clk32k", NULL); |
43 | clk_register_clkdev(clk, NULL, "rtc-pl031"); | 43 | clk_register_clkdev(clk, "apb_pclk", "rtc-pl031"); |
44 | 44 | ||
45 | /* PRCMU clocks */ | 45 | /* PRCMU clocks */ |
46 | fw_version = prcmu_get_fw_version(); | 46 | fw_version = prcmu_get_fw_version(); |
@@ -228,10 +228,17 @@ void u8500_clk_init(void) | |||
228 | 228 | ||
229 | clk = clk_reg_prcc_pclk("p1_pclk2", "per1clk", U8500_CLKRST1_BASE, | 229 | clk = clk_reg_prcc_pclk("p1_pclk2", "per1clk", U8500_CLKRST1_BASE, |
230 | BIT(2), 0); | 230 | BIT(2), 0); |
231 | clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.1"); | ||
232 | |||
231 | clk = clk_reg_prcc_pclk("p1_pclk3", "per1clk", U8500_CLKRST1_BASE, | 233 | clk = clk_reg_prcc_pclk("p1_pclk3", "per1clk", U8500_CLKRST1_BASE, |
232 | BIT(3), 0); | 234 | BIT(3), 0); |
235 | clk_register_clkdev(clk, "apb_pclk", "msp0"); | ||
236 | clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.0"); | ||
237 | |||
233 | clk = clk_reg_prcc_pclk("p1_pclk4", "per1clk", U8500_CLKRST1_BASE, | 238 | clk = clk_reg_prcc_pclk("p1_pclk4", "per1clk", U8500_CLKRST1_BASE, |
234 | BIT(4), 0); | 239 | BIT(4), 0); |
240 | clk_register_clkdev(clk, "apb_pclk", "msp1"); | ||
241 | clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.1"); | ||
235 | 242 | ||
236 | clk = clk_reg_prcc_pclk("p1_pclk5", "per1clk", U8500_CLKRST1_BASE, | 243 | clk = clk_reg_prcc_pclk("p1_pclk5", "per1clk", U8500_CLKRST1_BASE, |
237 | BIT(5), 0); | 244 | BIT(5), 0); |
@@ -239,6 +246,7 @@ void u8500_clk_init(void) | |||
239 | 246 | ||
240 | clk = clk_reg_prcc_pclk("p1_pclk6", "per1clk", U8500_CLKRST1_BASE, | 247 | clk = clk_reg_prcc_pclk("p1_pclk6", "per1clk", U8500_CLKRST1_BASE, |
241 | BIT(6), 0); | 248 | BIT(6), 0); |
249 | clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.2"); | ||
242 | 250 | ||
243 | clk = clk_reg_prcc_pclk("p1_pclk7", "per1clk", U8500_CLKRST1_BASE, | 251 | clk = clk_reg_prcc_pclk("p1_pclk7", "per1clk", U8500_CLKRST1_BASE, |
244 | BIT(7), 0); | 252 | BIT(7), 0); |
@@ -246,6 +254,7 @@ void u8500_clk_init(void) | |||
246 | 254 | ||
247 | clk = clk_reg_prcc_pclk("p1_pclk8", "per1clk", U8500_CLKRST1_BASE, | 255 | clk = clk_reg_prcc_pclk("p1_pclk8", "per1clk", U8500_CLKRST1_BASE, |
248 | BIT(8), 0); | 256 | BIT(8), 0); |
257 | clk_register_clkdev(clk, "apb_pclk", "slimbus0"); | ||
249 | 258 | ||
250 | clk = clk_reg_prcc_pclk("p1_pclk9", "per1clk", U8500_CLKRST1_BASE, | 259 | clk = clk_reg_prcc_pclk("p1_pclk9", "per1clk", U8500_CLKRST1_BASE, |
251 | BIT(9), 0); | 260 | BIT(9), 0); |
@@ -255,11 +264,16 @@ void u8500_clk_init(void) | |||
255 | 264 | ||
256 | clk = clk_reg_prcc_pclk("p1_pclk10", "per1clk", U8500_CLKRST1_BASE, | 265 | clk = clk_reg_prcc_pclk("p1_pclk10", "per1clk", U8500_CLKRST1_BASE, |
257 | BIT(10), 0); | 266 | BIT(10), 0); |
267 | clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.4"); | ||
268 | |||
258 | clk = clk_reg_prcc_pclk("p1_pclk11", "per1clk", U8500_CLKRST1_BASE, | 269 | clk = clk_reg_prcc_pclk("p1_pclk11", "per1clk", U8500_CLKRST1_BASE, |
259 | BIT(11), 0); | 270 | BIT(11), 0); |
271 | clk_register_clkdev(clk, "apb_pclk", "msp3"); | ||
272 | clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.3"); | ||
260 | 273 | ||
261 | clk = clk_reg_prcc_pclk("p2_pclk0", "per2clk", U8500_CLKRST2_BASE, | 274 | clk = clk_reg_prcc_pclk("p2_pclk0", "per2clk", U8500_CLKRST2_BASE, |
262 | BIT(0), 0); | 275 | BIT(0), 0); |
276 | clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.3"); | ||
263 | 277 | ||
264 | clk = clk_reg_prcc_pclk("p2_pclk1", "per2clk", U8500_CLKRST2_BASE, | 278 | clk = clk_reg_prcc_pclk("p2_pclk1", "per2clk", U8500_CLKRST2_BASE, |
265 | BIT(1), 0); | 279 | BIT(1), 0); |
@@ -279,12 +293,13 @@ void u8500_clk_init(void) | |||
279 | 293 | ||
280 | clk = clk_reg_prcc_pclk("p2_pclk5", "per2clk", U8500_CLKRST2_BASE, | 294 | clk = clk_reg_prcc_pclk("p2_pclk5", "per2clk", U8500_CLKRST2_BASE, |
281 | BIT(5), 0); | 295 | BIT(5), 0); |
296 | clk_register_clkdev(clk, "apb_pclk", "msp2"); | ||
297 | clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.2"); | ||
282 | 298 | ||
283 | clk = clk_reg_prcc_pclk("p2_pclk6", "per2clk", U8500_CLKRST2_BASE, | 299 | clk = clk_reg_prcc_pclk("p2_pclk6", "per2clk", U8500_CLKRST2_BASE, |
284 | BIT(6), 0); | 300 | BIT(6), 0); |
285 | clk_register_clkdev(clk, "apb_pclk", "sdi1"); | 301 | clk_register_clkdev(clk, "apb_pclk", "sdi1"); |
286 | 302 | ||
287 | |||
288 | clk = clk_reg_prcc_pclk("p2_pclk7", "per2clk", U8500_CLKRST2_BASE, | 303 | clk = clk_reg_prcc_pclk("p2_pclk7", "per2clk", U8500_CLKRST2_BASE, |
289 | BIT(7), 0); | 304 | BIT(7), 0); |
290 | clk_register_clkdev(clk, "apb_pclk", "sdi3"); | 305 | clk_register_clkdev(clk, "apb_pclk", "sdi3"); |
@@ -316,10 +331,15 @@ void u8500_clk_init(void) | |||
316 | 331 | ||
317 | clk = clk_reg_prcc_pclk("p3_pclk1", "per3clk", U8500_CLKRST3_BASE, | 332 | clk = clk_reg_prcc_pclk("p3_pclk1", "per3clk", U8500_CLKRST3_BASE, |
318 | BIT(1), 0); | 333 | BIT(1), 0); |
334 | clk_register_clkdev(clk, "apb_pclk", "ssp0"); | ||
335 | |||
319 | clk = clk_reg_prcc_pclk("p3_pclk2", "per3clk", U8500_CLKRST3_BASE, | 336 | clk = clk_reg_prcc_pclk("p3_pclk2", "per3clk", U8500_CLKRST3_BASE, |
320 | BIT(2), 0); | 337 | BIT(2), 0); |
338 | clk_register_clkdev(clk, "apb_pclk", "ssp1"); | ||
339 | |||
321 | clk = clk_reg_prcc_pclk("p3_pclk3", "per3clk", U8500_CLKRST3_BASE, | 340 | clk = clk_reg_prcc_pclk("p3_pclk3", "per3clk", U8500_CLKRST3_BASE, |
322 | BIT(3), 0); | 341 | BIT(3), 0); |
342 | clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.0"); | ||
323 | 343 | ||
324 | clk = clk_reg_prcc_pclk("p3_pclk4", "per3clk", U8500_CLKRST3_BASE, | 344 | clk = clk_reg_prcc_pclk("p3_pclk4", "per3clk", U8500_CLKRST3_BASE, |
325 | BIT(4), 0); | 345 | BIT(4), 0); |
@@ -401,10 +421,17 @@ void u8500_clk_init(void) | |||
401 | 421 | ||
402 | clk = clk_reg_prcc_kclk("p1_i2c1_kclk", "i2cclk", | 422 | clk = clk_reg_prcc_kclk("p1_i2c1_kclk", "i2cclk", |
403 | U8500_CLKRST1_BASE, BIT(2), CLK_SET_RATE_GATE); | 423 | U8500_CLKRST1_BASE, BIT(2), CLK_SET_RATE_GATE); |
424 | clk_register_clkdev(clk, NULL, "nmk-i2c.1"); | ||
425 | |||
404 | clk = clk_reg_prcc_kclk("p1_msp0_kclk", "msp02clk", | 426 | clk = clk_reg_prcc_kclk("p1_msp0_kclk", "msp02clk", |
405 | U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE); | 427 | U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE); |
428 | clk_register_clkdev(clk, NULL, "msp0"); | ||
429 | clk_register_clkdev(clk, NULL, "ux500-msp-i2s.0"); | ||
430 | |||
406 | clk = clk_reg_prcc_kclk("p1_msp1_kclk", "msp1clk", | 431 | clk = clk_reg_prcc_kclk("p1_msp1_kclk", "msp1clk", |
407 | U8500_CLKRST1_BASE, BIT(4), CLK_SET_RATE_GATE); | 432 | U8500_CLKRST1_BASE, BIT(4), CLK_SET_RATE_GATE); |
433 | clk_register_clkdev(clk, NULL, "msp1"); | ||
434 | clk_register_clkdev(clk, NULL, "ux500-msp-i2s.1"); | ||
408 | 435 | ||
409 | clk = clk_reg_prcc_kclk("p1_sdi0_kclk", "sdmmcclk", | 436 | clk = clk_reg_prcc_kclk("p1_sdi0_kclk", "sdmmcclk", |
410 | U8500_CLKRST1_BASE, BIT(5), CLK_SET_RATE_GATE); | 437 | U8500_CLKRST1_BASE, BIT(5), CLK_SET_RATE_GATE); |
@@ -412,17 +439,25 @@ void u8500_clk_init(void) | |||
412 | 439 | ||
413 | clk = clk_reg_prcc_kclk("p1_i2c2_kclk", "i2cclk", | 440 | clk = clk_reg_prcc_kclk("p1_i2c2_kclk", "i2cclk", |
414 | U8500_CLKRST1_BASE, BIT(6), CLK_SET_RATE_GATE); | 441 | U8500_CLKRST1_BASE, BIT(6), CLK_SET_RATE_GATE); |
442 | clk_register_clkdev(clk, NULL, "nmk-i2c.2"); | ||
443 | |||
415 | clk = clk_reg_prcc_kclk("p1_slimbus0_kclk", "slimclk", | 444 | clk = clk_reg_prcc_kclk("p1_slimbus0_kclk", "slimclk", |
416 | U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE); | 445 | U8500_CLKRST1_BASE, BIT(8), CLK_SET_RATE_GATE); |
417 | /* FIXME: Redefinition of BIT(3). */ | 446 | clk_register_clkdev(clk, NULL, "slimbus0"); |
447 | |||
418 | clk = clk_reg_prcc_kclk("p1_i2c4_kclk", "i2cclk", | 448 | clk = clk_reg_prcc_kclk("p1_i2c4_kclk", "i2cclk", |
419 | U8500_CLKRST1_BASE, BIT(9), CLK_SET_RATE_GATE); | 449 | U8500_CLKRST1_BASE, BIT(9), CLK_SET_RATE_GATE); |
450 | clk_register_clkdev(clk, NULL, "nmk-i2c.4"); | ||
451 | |||
420 | clk = clk_reg_prcc_kclk("p1_msp3_kclk", "msp1clk", | 452 | clk = clk_reg_prcc_kclk("p1_msp3_kclk", "msp1clk", |
421 | U8500_CLKRST1_BASE, BIT(10), CLK_SET_RATE_GATE); | 453 | U8500_CLKRST1_BASE, BIT(10), CLK_SET_RATE_GATE); |
454 | clk_register_clkdev(clk, NULL, "msp3"); | ||
455 | clk_register_clkdev(clk, NULL, "ux500-msp-i2s.3"); | ||
422 | 456 | ||
423 | /* Periph2 */ | 457 | /* Periph2 */ |
424 | clk = clk_reg_prcc_kclk("p2_i2c3_kclk", "i2cclk", | 458 | clk = clk_reg_prcc_kclk("p2_i2c3_kclk", "i2cclk", |
425 | U8500_CLKRST2_BASE, BIT(0), CLK_SET_RATE_GATE); | 459 | U8500_CLKRST2_BASE, BIT(0), CLK_SET_RATE_GATE); |
460 | clk_register_clkdev(clk, NULL, "nmk-i2c.3"); | ||
426 | 461 | ||
427 | clk = clk_reg_prcc_kclk("p2_sdi4_kclk", "sdmmcclk", | 462 | clk = clk_reg_prcc_kclk("p2_sdi4_kclk", "sdmmcclk", |
428 | U8500_CLKRST2_BASE, BIT(2), CLK_SET_RATE_GATE); | 463 | U8500_CLKRST2_BASE, BIT(2), CLK_SET_RATE_GATE); |
@@ -430,6 +465,8 @@ void u8500_clk_init(void) | |||
430 | 465 | ||
431 | clk = clk_reg_prcc_kclk("p2_msp2_kclk", "msp02clk", | 466 | clk = clk_reg_prcc_kclk("p2_msp2_kclk", "msp02clk", |
432 | U8500_CLKRST2_BASE, BIT(3), CLK_SET_RATE_GATE); | 467 | U8500_CLKRST2_BASE, BIT(3), CLK_SET_RATE_GATE); |
468 | clk_register_clkdev(clk, NULL, "msp2"); | ||
469 | clk_register_clkdev(clk, NULL, "ux500-msp-i2s.2"); | ||
433 | 470 | ||
434 | clk = clk_reg_prcc_kclk("p2_sdi1_kclk", "sdmmcclk", | 471 | clk = clk_reg_prcc_kclk("p2_sdi1_kclk", "sdmmcclk", |
435 | U8500_CLKRST2_BASE, BIT(4), CLK_SET_RATE_GATE); | 472 | U8500_CLKRST2_BASE, BIT(4), CLK_SET_RATE_GATE); |
@@ -450,10 +487,15 @@ void u8500_clk_init(void) | |||
450 | /* Periph3 */ | 487 | /* Periph3 */ |
451 | clk = clk_reg_prcc_kclk("p3_ssp0_kclk", "sspclk", | 488 | clk = clk_reg_prcc_kclk("p3_ssp0_kclk", "sspclk", |
452 | U8500_CLKRST3_BASE, BIT(1), CLK_SET_RATE_GATE); | 489 | U8500_CLKRST3_BASE, BIT(1), CLK_SET_RATE_GATE); |
490 | clk_register_clkdev(clk, NULL, "ssp0"); | ||
491 | |||
453 | clk = clk_reg_prcc_kclk("p3_ssp1_kclk", "sspclk", | 492 | clk = clk_reg_prcc_kclk("p3_ssp1_kclk", "sspclk", |
454 | U8500_CLKRST3_BASE, BIT(2), CLK_SET_RATE_GATE); | 493 | U8500_CLKRST3_BASE, BIT(2), CLK_SET_RATE_GATE); |
494 | clk_register_clkdev(clk, NULL, "ssp1"); | ||
495 | |||
455 | clk = clk_reg_prcc_kclk("p3_i2c0_kclk", "i2cclk", | 496 | clk = clk_reg_prcc_kclk("p3_i2c0_kclk", "i2cclk", |
456 | U8500_CLKRST3_BASE, BIT(3), CLK_SET_RATE_GATE); | 497 | U8500_CLKRST3_BASE, BIT(3), CLK_SET_RATE_GATE); |
498 | clk_register_clkdev(clk, NULL, "nmk-i2c.0"); | ||
457 | 499 | ||
458 | clk = clk_reg_prcc_kclk("p3_sdi2_kclk", "sdmmcclk", | 500 | clk = clk_reg_prcc_kclk("p3_sdi2_kclk", "sdmmcclk", |
459 | U8500_CLKRST3_BASE, BIT(4), CLK_SET_RATE_GATE); | 501 | U8500_CLKRST3_BASE, BIT(4), CLK_SET_RATE_GATE); |
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 308c7fb92a60..f6644f59fd9d 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig | |||
@@ -224,7 +224,7 @@ config CRYPTO_DEV_TALITOS | |||
224 | 224 | ||
225 | config CRYPTO_DEV_IXP4XX | 225 | config CRYPTO_DEV_IXP4XX |
226 | tristate "Driver for IXP4xx crypto hardware acceleration" | 226 | tristate "Driver for IXP4xx crypto hardware acceleration" |
227 | depends on ARCH_IXP4XX | 227 | depends on ARCH_IXP4XX && IXP4XX_QMGR && IXP4XX_NPE |
228 | select CRYPTO_DES | 228 | select CRYPTO_DES |
229 | select CRYPTO_ALGAPI | 229 | select CRYPTO_ALGAPI |
230 | select CRYPTO_AUTHENC | 230 | select CRYPTO_AUTHENC |
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c index 8f3f74ce8c7f..21180d6cad6e 100644 --- a/drivers/crypto/ixp4xx_crypto.c +++ b/drivers/crypto/ixp4xx_crypto.c | |||
@@ -750,12 +750,12 @@ static int setup_cipher(struct crypto_tfm *tfm, int encrypt, | |||
750 | } | 750 | } |
751 | if (cipher_cfg & MOD_AES) { | 751 | if (cipher_cfg & MOD_AES) { |
752 | switch (key_len) { | 752 | switch (key_len) { |
753 | case 16: keylen_cfg = MOD_AES128 | KEYLEN_128; break; | 753 | case 16: keylen_cfg = MOD_AES128; break; |
754 | case 24: keylen_cfg = MOD_AES192 | KEYLEN_192; break; | 754 | case 24: keylen_cfg = MOD_AES192; break; |
755 | case 32: keylen_cfg = MOD_AES256 | KEYLEN_256; break; | 755 | case 32: keylen_cfg = MOD_AES256; break; |
756 | default: | 756 | default: |
757 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | 757 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; |
758 | return -EINVAL; | 758 | return -EINVAL; |
759 | } | 759 | } |
760 | cipher_cfg |= keylen_cfg; | 760 | cipher_cfg |= keylen_cfg; |
761 | } else if (cipher_cfg & MOD_3DES) { | 761 | } else if (cipher_cfg & MOD_3DES) { |
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h index 8d4804732bac..8c4139647efc 100644 --- a/drivers/edac/amd64_edac.h +++ b/drivers/edac/amd64_edac.h | |||
@@ -33,7 +33,7 @@ | |||
33 | * detection. The mods to Rev F required more family | 33 | * detection. The mods to Rev F required more family |
34 | * information detection. | 34 | * information detection. |
35 | * | 35 | * |
36 | * Changes/Fixes by Borislav Petkov <borislav.petkov@amd.com>: | 36 | * Changes/Fixes by Borislav Petkov <bp@alien8.de>: |
37 | * - misc fixes and code cleanups | 37 | * - misc fixes and code cleanups |
38 | * | 38 | * |
39 | * This module is based on the following documents | 39 | * This module is based on the following documents |
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index 90f0b730e9bb..75c0a1a85fc3 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c | |||
@@ -416,10 +416,18 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num, | |||
416 | dimm->cschannel = chn; | 416 | dimm->cschannel = chn; |
417 | 417 | ||
418 | /* Increment csrow location */ | 418 | /* Increment csrow location */ |
419 | row++; | 419 | if (layers[0].is_virt_csrow) { |
420 | if (row == tot_csrows) { | ||
421 | row = 0; | ||
422 | chn++; | 420 | chn++; |
421 | if (chn == tot_channels) { | ||
422 | chn = 0; | ||
423 | row++; | ||
424 | } | ||
425 | } else { | ||
426 | row++; | ||
427 | if (row == tot_csrows) { | ||
428 | row = 0; | ||
429 | chn++; | ||
430 | } | ||
423 | } | 431 | } |
424 | 432 | ||
425 | /* Increment dimm location */ | 433 | /* Increment dimm location */ |
diff --git a/drivers/edac/edac_stub.c b/drivers/edac/edac_stub.c index 6c86f6e54558..351945fa2ecd 100644 --- a/drivers/edac/edac_stub.c +++ b/drivers/edac/edac_stub.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * 2007 (c) MontaVista Software, Inc. | 6 | * 2007 (c) MontaVista Software, Inc. |
7 | * 2010 (c) Advanced Micro Devices Inc. | 7 | * 2010 (c) Advanced Micro Devices Inc. |
8 | * Borislav Petkov <borislav.petkov@amd.com> | 8 | * Borislav Petkov <bp@alien8.de> |
9 | * | 9 | * |
10 | * This file is licensed under the terms of the GNU General Public | 10 | * This file is licensed under the terms of the GNU General Public |
11 | * License version 2. This program is licensed "as is" without any | 11 | * License version 2. This program is licensed "as is" without any |
diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c index a09d0667f72a..9d669cd43618 100644 --- a/drivers/edac/i7300_edac.c +++ b/drivers/edac/i7300_edac.c | |||
@@ -197,8 +197,8 @@ static const char *ferr_fat_fbd_name[] = { | |||
197 | [0] = "Memory Write error on non-redundant retry or " | 197 | [0] = "Memory Write error on non-redundant retry or " |
198 | "FBD configuration Write error on retry", | 198 | "FBD configuration Write error on retry", |
199 | }; | 199 | }; |
200 | #define GET_FBD_FAT_IDX(fbderr) (fbderr & (3 << 28)) | 200 | #define GET_FBD_FAT_IDX(fbderr) (((fbderr) >> 28) & 3) |
201 | #define FERR_FAT_FBD_ERR_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)) | 201 | #define FERR_FAT_FBD_ERR_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 22)) |
202 | 202 | ||
203 | #define FERR_NF_FBD 0xa0 | 203 | #define FERR_NF_FBD 0xa0 |
204 | static const char *ferr_nf_fbd_name[] = { | 204 | static const char *ferr_nf_fbd_name[] = { |
@@ -225,7 +225,7 @@ static const char *ferr_nf_fbd_name[] = { | |||
225 | [1] = "Aliased Uncorrectable Non-Mirrored Demand Data ECC", | 225 | [1] = "Aliased Uncorrectable Non-Mirrored Demand Data ECC", |
226 | [0] = "Uncorrectable Data ECC on Replay", | 226 | [0] = "Uncorrectable Data ECC on Replay", |
227 | }; | 227 | }; |
228 | #define GET_FBD_NF_IDX(fbderr) (fbderr & (3 << 28)) | 228 | #define GET_FBD_NF_IDX(fbderr) (((fbderr) >> 28) & 3) |
229 | #define FERR_NF_FBD_ERR_MASK ((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) |\ | 229 | #define FERR_NF_FBD_ERR_MASK ((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) |\ |
230 | (1 << 18) | (1 << 17) | (1 << 16) | (1 << 15) |\ | 230 | (1 << 18) | (1 << 17) | (1 << 16) | (1 << 15) |\ |
231 | (1 << 14) | (1 << 13) | (1 << 11) | (1 << 10) |\ | 231 | (1 << 14) | (1 << 13) | (1 << 11) | (1 << 10) |\ |
@@ -464,7 +464,7 @@ static void i7300_process_fbd_error(struct mem_ctl_info *mci) | |||
464 | errnum = find_first_bit(&errors, | 464 | errnum = find_first_bit(&errors, |
465 | ARRAY_SIZE(ferr_nf_fbd_name)); | 465 | ARRAY_SIZE(ferr_nf_fbd_name)); |
466 | specific = GET_ERR_FROM_TABLE(ferr_nf_fbd_name, errnum); | 466 | specific = GET_ERR_FROM_TABLE(ferr_nf_fbd_name, errnum); |
467 | branch = (GET_FBD_FAT_IDX(error_reg) == 2) ? 1 : 0; | 467 | branch = (GET_FBD_NF_IDX(error_reg) == 2) ? 1 : 0; |
468 | 468 | ||
469 | pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, | 469 | pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, |
470 | REDMEMA, &syndrome); | 470 | REDMEMA, &syndrome); |
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c index 3672101023bd..10c8c00d6469 100644 --- a/drivers/edac/i7core_edac.c +++ b/drivers/edac/i7core_edac.c | |||
@@ -816,7 +816,7 @@ static ssize_t i7core_inject_store_##param( \ | |||
816 | struct device_attribute *mattr, \ | 816 | struct device_attribute *mattr, \ |
817 | const char *data, size_t count) \ | 817 | const char *data, size_t count) \ |
818 | { \ | 818 | { \ |
819 | struct mem_ctl_info *mci = to_mci(dev); \ | 819 | struct mem_ctl_info *mci = dev_get_drvdata(dev); \ |
820 | struct i7core_pvt *pvt; \ | 820 | struct i7core_pvt *pvt; \ |
821 | long value; \ | 821 | long value; \ |
822 | int rc; \ | 822 | int rc; \ |
@@ -845,7 +845,7 @@ static ssize_t i7core_inject_show_##param( \ | |||
845 | struct device_attribute *mattr, \ | 845 | struct device_attribute *mattr, \ |
846 | char *data) \ | 846 | char *data) \ |
847 | { \ | 847 | { \ |
848 | struct mem_ctl_info *mci = to_mci(dev); \ | 848 | struct mem_ctl_info *mci = dev_get_drvdata(dev); \ |
849 | struct i7core_pvt *pvt; \ | 849 | struct i7core_pvt *pvt; \ |
850 | \ | 850 | \ |
851 | pvt = mci->pvt_info; \ | 851 | pvt = mci->pvt_info; \ |
@@ -1052,7 +1052,7 @@ static ssize_t i7core_show_counter_##param( \ | |||
1052 | struct device_attribute *mattr, \ | 1052 | struct device_attribute *mattr, \ |
1053 | char *data) \ | 1053 | char *data) \ |
1054 | { \ | 1054 | { \ |
1055 | struct mem_ctl_info *mci = to_mci(dev); \ | 1055 | struct mem_ctl_info *mci = dev_get_drvdata(dev); \ |
1056 | struct i7core_pvt *pvt = mci->pvt_info; \ | 1056 | struct i7core_pvt *pvt = mci->pvt_info; \ |
1057 | \ | 1057 | \ |
1058 | edac_dbg(1, "\n"); \ | 1058 | edac_dbg(1, "\n"); \ |
diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c index 069e26c11c4f..a98020409fa9 100644 --- a/drivers/edac/i82975x_edac.c +++ b/drivers/edac/i82975x_edac.c | |||
@@ -370,10 +370,6 @@ static enum dev_type i82975x_dram_type(void __iomem *mch_window, int rank) | |||
370 | static void i82975x_init_csrows(struct mem_ctl_info *mci, | 370 | static void i82975x_init_csrows(struct mem_ctl_info *mci, |
371 | struct pci_dev *pdev, void __iomem *mch_window) | 371 | struct pci_dev *pdev, void __iomem *mch_window) |
372 | { | 372 | { |
373 | static const char *labels[4] = { | ||
374 | "DIMM A1", "DIMM A2", | ||
375 | "DIMM B1", "DIMM B2" | ||
376 | }; | ||
377 | struct csrow_info *csrow; | 373 | struct csrow_info *csrow; |
378 | unsigned long last_cumul_size; | 374 | unsigned long last_cumul_size; |
379 | u8 value; | 375 | u8 value; |
@@ -423,9 +419,10 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci, | |||
423 | dimm = mci->csrows[index]->channels[chan]->dimm; | 419 | dimm = mci->csrows[index]->channels[chan]->dimm; |
424 | 420 | ||
425 | dimm->nr_pages = nr_pages / csrow->nr_channels; | 421 | dimm->nr_pages = nr_pages / csrow->nr_channels; |
426 | strncpy(csrow->channels[chan]->dimm->label, | 422 | |
427 | labels[(index >> 1) + (chan * 2)], | 423 | snprintf(csrow->channels[chan]->dimm->label, EDAC_MC_LABEL_LEN, "DIMM %c%d", |
428 | EDAC_MC_LABEL_LEN); | 424 | (chan == 0) ? 'A' : 'B', |
425 | index); | ||
429 | dimm->grain = 1 << 7; /* 128Byte cache-line resolution */ | 426 | dimm->grain = 1 << 7; /* 128Byte cache-line resolution */ |
430 | dimm->dtype = i82975x_dram_type(mch_window, index); | 427 | dimm->dtype = i82975x_dram_type(mch_window, index); |
431 | dimm->mtype = MEM_DDR2; /* I82975x supports only DDR2 */ | 428 | dimm->mtype = MEM_DDR2; /* I82975x supports only DDR2 */ |
diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c index 66b5151c1080..2ae78f20cc28 100644 --- a/drivers/edac/mce_amd_inj.c +++ b/drivers/edac/mce_amd_inj.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * This file may be distributed under the terms of the GNU General Public | 6 | * This file may be distributed under the terms of the GNU General Public |
7 | * License version 2. | 7 | * License version 2. |
8 | * | 8 | * |
9 | * Copyright (c) 2010: Borislav Petkov <borislav.petkov@amd.com> | 9 | * Copyright (c) 2010: Borislav Petkov <bp@alien8.de> |
10 | * Advanced Micro Devices Inc. | 10 | * Advanced Micro Devices Inc. |
11 | */ | 11 | */ |
12 | 12 | ||
@@ -168,6 +168,6 @@ module_init(edac_init_mce_inject); | |||
168 | module_exit(edac_exit_mce_inject); | 168 | module_exit(edac_exit_mce_inject); |
169 | 169 | ||
170 | MODULE_LICENSE("GPL"); | 170 | MODULE_LICENSE("GPL"); |
171 | MODULE_AUTHOR("Borislav Petkov <borislav.petkov@amd.com>"); | 171 | MODULE_AUTHOR("Borislav Petkov <bp@alien8.de>"); |
172 | MODULE_AUTHOR("AMD Inc."); | 172 | MODULE_AUTHOR("AMD Inc."); |
173 | MODULE_DESCRIPTION("MCE injection facility for testing MCE decoding"); | 173 | MODULE_DESCRIPTION("MCE injection facility for testing MCE decoding"); |
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index 1162d6b3bf85..bb1b392f5cda 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c | |||
@@ -1546,6 +1546,8 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev) | |||
1546 | struct sbp2_logical_unit *lu = sdev->hostdata; | 1546 | struct sbp2_logical_unit *lu = sdev->hostdata; |
1547 | 1547 | ||
1548 | sdev->use_10_for_rw = 1; | 1548 | sdev->use_10_for_rw = 1; |
1549 | sdev->no_report_opcodes = 1; | ||
1550 | sdev->no_write_same = 1; | ||
1549 | 1551 | ||
1550 | if (sbp2_param_exclusive_login) | 1552 | if (sbp2_param_exclusive_login) |
1551 | sdev->manage_start_stop = 1; | 1553 | sdev->manage_start_stop = 1; |
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index f11d8e3b4041..47150f5ded04 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -466,7 +466,7 @@ config GPIO_ADP5588_IRQ | |||
466 | 466 | ||
467 | config GPIO_ADNP | 467 | config GPIO_ADNP |
468 | tristate "Avionic Design N-bit GPIO expander" | 468 | tristate "Avionic Design N-bit GPIO expander" |
469 | depends on I2C && OF | 469 | depends on I2C && OF_GPIO |
470 | help | 470 | help |
471 | This option enables support for N GPIOs found on Avionic Design | 471 | This option enables support for N GPIOs found on Avionic Design |
472 | I2C GPIO expanders. The register space will be extended by powers | 472 | I2C GPIO expanders. The register space will be extended by powers |
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index 0f425189de11..ce1c84760076 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c | |||
@@ -77,7 +77,7 @@ struct mcp23s08_driver_data { | |||
77 | 77 | ||
78 | /*----------------------------------------------------------------------*/ | 78 | /*----------------------------------------------------------------------*/ |
79 | 79 | ||
80 | #ifdef CONFIG_I2C | 80 | #if IS_ENABLED(CONFIG_I2C) |
81 | 81 | ||
82 | static int mcp23008_read(struct mcp23s08 *mcp, unsigned reg) | 82 | static int mcp23008_read(struct mcp23s08 *mcp, unsigned reg) |
83 | { | 83 | { |
@@ -399,7 +399,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, | |||
399 | break; | 399 | break; |
400 | #endif /* CONFIG_SPI_MASTER */ | 400 | #endif /* CONFIG_SPI_MASTER */ |
401 | 401 | ||
402 | #ifdef CONFIG_I2C | 402 | #if IS_ENABLED(CONFIG_I2C) |
403 | case MCP_TYPE_008: | 403 | case MCP_TYPE_008: |
404 | mcp->ops = &mcp23008_ops; | 404 | mcp->ops = &mcp23008_ops; |
405 | mcp->chip.ngpio = 8; | 405 | mcp->chip.ngpio = 8; |
@@ -473,7 +473,7 @@ fail: | |||
473 | 473 | ||
474 | /*----------------------------------------------------------------------*/ | 474 | /*----------------------------------------------------------------------*/ |
475 | 475 | ||
476 | #ifdef CONFIG_I2C | 476 | #if IS_ENABLED(CONFIG_I2C) |
477 | 477 | ||
478 | static int __devinit mcp230xx_probe(struct i2c_client *client, | 478 | static int __devinit mcp230xx_probe(struct i2c_client *client, |
479 | const struct i2c_device_id *id) | 479 | const struct i2c_device_id *id) |
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index cf7afb9eb61a..be65c0451ad5 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
@@ -92,6 +92,11 @@ static inline void __iomem *mvebu_gpioreg_out(struct mvebu_gpio_chip *mvchip) | |||
92 | return mvchip->membase + GPIO_OUT_OFF; | 92 | return mvchip->membase + GPIO_OUT_OFF; |
93 | } | 93 | } |
94 | 94 | ||
95 | static inline void __iomem *mvebu_gpioreg_blink(struct mvebu_gpio_chip *mvchip) | ||
96 | { | ||
97 | return mvchip->membase + GPIO_BLINK_EN_OFF; | ||
98 | } | ||
99 | |||
95 | static inline void __iomem *mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip) | 100 | static inline void __iomem *mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip) |
96 | { | 101 | { |
97 | return mvchip->membase + GPIO_IO_CONF_OFF; | 102 | return mvchip->membase + GPIO_IO_CONF_OFF; |
@@ -206,6 +211,23 @@ static int mvebu_gpio_get(struct gpio_chip *chip, unsigned pin) | |||
206 | return (u >> pin) & 1; | 211 | return (u >> pin) & 1; |
207 | } | 212 | } |
208 | 213 | ||
214 | static void mvebu_gpio_blink(struct gpio_chip *chip, unsigned pin, int value) | ||
215 | { | ||
216 | struct mvebu_gpio_chip *mvchip = | ||
217 | container_of(chip, struct mvebu_gpio_chip, chip); | ||
218 | unsigned long flags; | ||
219 | u32 u; | ||
220 | |||
221 | spin_lock_irqsave(&mvchip->lock, flags); | ||
222 | u = readl_relaxed(mvebu_gpioreg_blink(mvchip)); | ||
223 | if (value) | ||
224 | u |= 1 << pin; | ||
225 | else | ||
226 | u &= ~(1 << pin); | ||
227 | writel_relaxed(u, mvebu_gpioreg_blink(mvchip)); | ||
228 | spin_unlock_irqrestore(&mvchip->lock, flags); | ||
229 | } | ||
230 | |||
209 | static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin) | 231 | static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin) |
210 | { | 232 | { |
211 | struct mvebu_gpio_chip *mvchip = | 233 | struct mvebu_gpio_chip *mvchip = |
@@ -244,6 +266,7 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin, | |||
244 | if (ret) | 266 | if (ret) |
245 | return ret; | 267 | return ret; |
246 | 268 | ||
269 | mvebu_gpio_blink(chip, pin, 0); | ||
247 | mvebu_gpio_set(chip, pin, value); | 270 | mvebu_gpio_set(chip, pin, value); |
248 | 271 | ||
249 | spin_lock_irqsave(&mvchip->lock, flags); | 272 | spin_lock_irqsave(&mvchip->lock, flags); |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.c b/drivers/gpu/drm/exynos/exynos_drm_encoder.c index 241ad1eeec64..f2df06c603f7 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_encoder.c +++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.c | |||
@@ -226,6 +226,12 @@ static void exynos_drm_encoder_commit(struct drm_encoder *encoder) | |||
226 | * already updated or not by exynos_drm_encoder_dpms function. | 226 | * already updated or not by exynos_drm_encoder_dpms function. |
227 | */ | 227 | */ |
228 | exynos_encoder->updated = true; | 228 | exynos_encoder->updated = true; |
229 | |||
230 | /* | ||
231 | * In case of setcrtc, there is no way to update encoder's dpms | ||
232 | * so update it here. | ||
233 | */ | ||
234 | exynos_encoder->dpms = DRM_MODE_DPMS_ON; | ||
229 | } | 235 | } |
230 | 236 | ||
231 | static void exynos_drm_encoder_disable(struct drm_encoder *encoder) | 237 | static void exynos_drm_encoder_disable(struct drm_encoder *encoder) |
@@ -507,6 +513,6 @@ void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data) | |||
507 | * because the setting for disabling the overlay will be updated | 513 | * because the setting for disabling the overlay will be updated |
508 | * at vsync. | 514 | * at vsync. |
509 | */ | 515 | */ |
510 | if (overlay_ops->wait_for_vblank) | 516 | if (overlay_ops && overlay_ops->wait_for_vblank) |
511 | overlay_ops->wait_for_vblank(manager->dev); | 517 | overlay_ops->wait_for_vblank(manager->dev); |
512 | } | 518 | } |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index 67eb6ba56edf..e7466c4414cb 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c | |||
@@ -87,7 +87,8 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, | |||
87 | 87 | ||
88 | dev->mode_config.fb_base = (resource_size_t)buffer->dma_addr; | 88 | dev->mode_config.fb_base = (resource_size_t)buffer->dma_addr; |
89 | fbi->screen_base = buffer->kvaddr + offset; | 89 | fbi->screen_base = buffer->kvaddr + offset; |
90 | fbi->fix.smem_start = (unsigned long)(buffer->dma_addr + offset); | 90 | fbi->fix.smem_start = (unsigned long)(page_to_phys(buffer->pages[0]) + |
91 | offset); | ||
91 | fbi->screen_size = size; | 92 | fbi->screen_size = size; |
92 | fbi->fix.smem_len = size; | 93 | fbi->fix.smem_len = size; |
93 | 94 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 130a2b510d4a..e08478f19f1a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c | |||
@@ -61,11 +61,11 @@ struct fimd_driver_data { | |||
61 | unsigned int timing_base; | 61 | unsigned int timing_base; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | struct fimd_driver_data exynos4_fimd_driver_data = { | 64 | static struct fimd_driver_data exynos4_fimd_driver_data = { |
65 | .timing_base = 0x0, | 65 | .timing_base = 0x0, |
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct fimd_driver_data exynos5_fimd_driver_data = { | 68 | static struct fimd_driver_data exynos5_fimd_driver_data = { |
69 | .timing_base = 0x20000, | 69 | .timing_base = 0x20000, |
70 | }; | 70 | }; |
71 | 71 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index 60b877a388c2..862ca1eb2102 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c | |||
@@ -204,7 +204,6 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
204 | return ret; | 204 | return ret; |
205 | 205 | ||
206 | plane->crtc = crtc; | 206 | plane->crtc = crtc; |
207 | plane->fb = crtc->fb; | ||
208 | 207 | ||
209 | exynos_plane_commit(plane); | 208 | exynos_plane_commit(plane); |
210 | exynos_plane_dpms(plane, DRM_MODE_DPMS_ON); | 209 | exynos_plane_dpms(plane, DRM_MODE_DPMS_ON); |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 107f09befe92..9b285da4449b 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -1796,7 +1796,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) | |||
1796 | */ | 1796 | */ |
1797 | mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping; | 1797 | mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping; |
1798 | gfp = mapping_gfp_mask(mapping); | 1798 | gfp = mapping_gfp_mask(mapping); |
1799 | gfp |= __GFP_NORETRY | __GFP_NOWARN; | 1799 | gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD; |
1800 | gfp &= ~(__GFP_IO | __GFP_WAIT); | 1800 | gfp &= ~(__GFP_IO | __GFP_WAIT); |
1801 | for_each_sg(st->sgl, sg, page_count, i) { | 1801 | for_each_sg(st->sgl, sg, page_count, i) { |
1802 | page = shmem_read_mapping_page_gfp(mapping, i, gfp); | 1802 | page = shmem_read_mapping_page_gfp(mapping, i, gfp); |
@@ -1809,7 +1809,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) | |||
1809 | * our own buffer, now let the real VM do its job and | 1809 | * our own buffer, now let the real VM do its job and |
1810 | * go down in flames if truly OOM. | 1810 | * go down in flames if truly OOM. |
1811 | */ | 1811 | */ |
1812 | gfp &= ~(__GFP_NORETRY | __GFP_NOWARN); | 1812 | gfp &= ~(__GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD); |
1813 | gfp |= __GFP_IO | __GFP_WAIT; | 1813 | gfp |= __GFP_IO | __GFP_WAIT; |
1814 | 1814 | ||
1815 | i915_gem_shrink_all(dev_priv); | 1815 | i915_gem_shrink_all(dev_priv); |
@@ -1817,7 +1817,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) | |||
1817 | if (IS_ERR(page)) | 1817 | if (IS_ERR(page)) |
1818 | goto err_pages; | 1818 | goto err_pages; |
1819 | 1819 | ||
1820 | gfp |= __GFP_NORETRY | __GFP_NOWARN; | 1820 | gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD; |
1821 | gfp &= ~(__GFP_IO | __GFP_WAIT); | 1821 | gfp &= ~(__GFP_IO | __GFP_WAIT); |
1822 | } | 1822 | } |
1823 | 1823 | ||
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index 0ed6baff4b0c..56846ed5ee55 100644 --- a/drivers/gpu/drm/i915/intel_bios.c +++ b/drivers/gpu/drm/i915/intel_bios.c | |||
@@ -499,12 +499,8 @@ parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb) | |||
499 | 499 | ||
500 | edp = find_section(bdb, BDB_EDP); | 500 | edp = find_section(bdb, BDB_EDP); |
501 | if (!edp) { | 501 | if (!edp) { |
502 | if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp.support) { | 502 | if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp.support) |
503 | DRM_DEBUG_KMS("No eDP BDB found but eDP panel " | 503 | DRM_DEBUG_KMS("No eDP BDB found but eDP panel supported.\n"); |
504 | "supported, assume %dbpp panel color " | ||
505 | "depth.\n", | ||
506 | dev_priv->edp.bpp); | ||
507 | } | ||
508 | return; | 504 | return; |
509 | } | 505 | } |
510 | 506 | ||
@@ -657,9 +653,6 @@ init_vbt_defaults(struct drm_i915_private *dev_priv) | |||
657 | dev_priv->lvds_use_ssc = 1; | 653 | dev_priv->lvds_use_ssc = 1; |
658 | dev_priv->lvds_ssc_freq = intel_bios_ssc_frequency(dev, 1); | 654 | dev_priv->lvds_ssc_freq = intel_bios_ssc_frequency(dev, 1); |
659 | DRM_DEBUG_KMS("Set default to SSC at %dMHz\n", dev_priv->lvds_ssc_freq); | 655 | DRM_DEBUG_KMS("Set default to SSC at %dMHz\n", dev_priv->lvds_ssc_freq); |
660 | |||
661 | /* eDP data */ | ||
662 | dev_priv->edp.bpp = 18; | ||
663 | } | 656 | } |
664 | 657 | ||
665 | static int __init intel_no_opregion_vbt_callback(const struct dmi_system_id *id) | 658 | static int __init intel_no_opregion_vbt_callback(const struct dmi_system_id *id) |
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c index b726b478a4f5..6345878ae1e7 100644 --- a/drivers/gpu/drm/i915/intel_crt.c +++ b/drivers/gpu/drm/i915/intel_crt.c | |||
@@ -143,7 +143,7 @@ static void intel_crt_dpms(struct drm_connector *connector, int mode) | |||
143 | int old_dpms; | 143 | int old_dpms; |
144 | 144 | ||
145 | /* PCH platforms and VLV only support on/off. */ | 145 | /* PCH platforms and VLV only support on/off. */ |
146 | if (INTEL_INFO(dev)->gen < 5 && mode != DRM_MODE_DPMS_ON) | 146 | if (INTEL_INFO(dev)->gen >= 5 && mode != DRM_MODE_DPMS_ON) |
147 | mode = DRM_MODE_DPMS_OFF; | 147 | mode = DRM_MODE_DPMS_OFF; |
148 | 148 | ||
149 | if (mode == connector->dpms) | 149 | if (mode == connector->dpms) |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 461a637f1ef7..b426d44a2b05 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -3841,6 +3841,17 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc, | |||
3841 | } | 3841 | } |
3842 | } | 3842 | } |
3843 | 3843 | ||
3844 | if (intel_encoder->type == INTEL_OUTPUT_EDP) { | ||
3845 | /* Use VBT settings if we have an eDP panel */ | ||
3846 | unsigned int edp_bpc = dev_priv->edp.bpp / 3; | ||
3847 | |||
3848 | if (edp_bpc && edp_bpc < display_bpc) { | ||
3849 | DRM_DEBUG_KMS("clamping display bpc (was %d) to eDP (%d)\n", display_bpc, edp_bpc); | ||
3850 | display_bpc = edp_bpc; | ||
3851 | } | ||
3852 | continue; | ||
3853 | } | ||
3854 | |||
3844 | /* | 3855 | /* |
3845 | * HDMI is either 12 or 8, so if the display lets 10bpc sneak | 3856 | * HDMI is either 12 or 8, so if the display lets 10bpc sneak |
3846 | * through, clamp it down. (Note: >12bpc will be caught below.) | 3857 | * through, clamp it down. (Note: >12bpc will be caught below.) |
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index 72f41aaa71ff..442968f8b201 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c | |||
@@ -2373,15 +2373,9 @@ int intel_enable_rc6(const struct drm_device *dev) | |||
2373 | if (i915_enable_rc6 >= 0) | 2373 | if (i915_enable_rc6 >= 0) |
2374 | return i915_enable_rc6; | 2374 | return i915_enable_rc6; |
2375 | 2375 | ||
2376 | if (INTEL_INFO(dev)->gen == 5) { | 2376 | /* Disable RC6 on Ironlake */ |
2377 | #ifdef CONFIG_INTEL_IOMMU | 2377 | if (INTEL_INFO(dev)->gen == 5) |
2378 | /* Disable rc6 on ilk if VT-d is on. */ | 2378 | return 0; |
2379 | if (intel_iommu_gfx_mapped) | ||
2380 | return false; | ||
2381 | #endif | ||
2382 | DRM_DEBUG_DRIVER("Ironlake: only RC6 available\n"); | ||
2383 | return INTEL_RC6_ENABLE; | ||
2384 | } | ||
2385 | 2379 | ||
2386 | if (IS_HASWELL(dev)) { | 2380 | if (IS_HASWELL(dev)) { |
2387 | DRM_DEBUG_DRIVER("Haswell: only RC6 available\n"); | 2381 | DRM_DEBUG_DRIVER("Haswell: only RC6 available\n"); |
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c index 79d308da29ff..a6ac0b416964 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c | |||
@@ -2201,7 +2201,6 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) | |||
2201 | connector->connector_type = DRM_MODE_CONNECTOR_HDMIA; | 2201 | connector->connector_type = DRM_MODE_CONNECTOR_HDMIA; |
2202 | intel_sdvo->is_hdmi = true; | 2202 | intel_sdvo->is_hdmi = true; |
2203 | } | 2203 | } |
2204 | intel_sdvo->base.cloneable = true; | ||
2205 | 2204 | ||
2206 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); | 2205 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); |
2207 | if (intel_sdvo->is_hdmi) | 2206 | if (intel_sdvo->is_hdmi) |
@@ -2232,7 +2231,6 @@ intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, int type) | |||
2232 | 2231 | ||
2233 | intel_sdvo->is_tv = true; | 2232 | intel_sdvo->is_tv = true; |
2234 | intel_sdvo->base.needs_tv_clock = true; | 2233 | intel_sdvo->base.needs_tv_clock = true; |
2235 | intel_sdvo->base.cloneable = false; | ||
2236 | 2234 | ||
2237 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); | 2235 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); |
2238 | 2236 | ||
@@ -2275,8 +2273,6 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device) | |||
2275 | intel_sdvo_connector->output_flag = SDVO_OUTPUT_RGB1; | 2273 | intel_sdvo_connector->output_flag = SDVO_OUTPUT_RGB1; |
2276 | } | 2274 | } |
2277 | 2275 | ||
2278 | intel_sdvo->base.cloneable = true; | ||
2279 | |||
2280 | intel_sdvo_connector_init(intel_sdvo_connector, | 2276 | intel_sdvo_connector_init(intel_sdvo_connector, |
2281 | intel_sdvo); | 2277 | intel_sdvo); |
2282 | return true; | 2278 | return true; |
@@ -2307,9 +2303,6 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device) | |||
2307 | intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1; | 2303 | intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1; |
2308 | } | 2304 | } |
2309 | 2305 | ||
2310 | /* SDVO LVDS is not cloneable because the input mode gets adjusted by the encoder */ | ||
2311 | intel_sdvo->base.cloneable = false; | ||
2312 | |||
2313 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); | 2306 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); |
2314 | if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector)) | 2307 | if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector)) |
2315 | goto err; | 2308 | goto err; |
@@ -2382,6 +2375,18 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, uint16_t flags) | |||
2382 | return true; | 2375 | return true; |
2383 | } | 2376 | } |
2384 | 2377 | ||
2378 | static void intel_sdvo_output_cleanup(struct intel_sdvo *intel_sdvo) | ||
2379 | { | ||
2380 | struct drm_device *dev = intel_sdvo->base.base.dev; | ||
2381 | struct drm_connector *connector, *tmp; | ||
2382 | |||
2383 | list_for_each_entry_safe(connector, tmp, | ||
2384 | &dev->mode_config.connector_list, head) { | ||
2385 | if (intel_attached_encoder(connector) == &intel_sdvo->base) | ||
2386 | intel_sdvo_destroy(connector); | ||
2387 | } | ||
2388 | } | ||
2389 | |||
2385 | static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo, | 2390 | static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo, |
2386 | struct intel_sdvo_connector *intel_sdvo_connector, | 2391 | struct intel_sdvo_connector *intel_sdvo_connector, |
2387 | int type) | 2392 | int type) |
@@ -2705,9 +2710,20 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob) | |||
2705 | intel_sdvo->caps.output_flags) != true) { | 2710 | intel_sdvo->caps.output_flags) != true) { |
2706 | DRM_DEBUG_KMS("SDVO output failed to setup on %s\n", | 2711 | DRM_DEBUG_KMS("SDVO output failed to setup on %s\n", |
2707 | SDVO_NAME(intel_sdvo)); | 2712 | SDVO_NAME(intel_sdvo)); |
2708 | goto err; | 2713 | /* Output_setup can leave behind connectors! */ |
2714 | goto err_output; | ||
2709 | } | 2715 | } |
2710 | 2716 | ||
2717 | /* | ||
2718 | * Cloning SDVO with anything is often impossible, since the SDVO | ||
2719 | * encoder can request a special input timing mode. And even if that's | ||
2720 | * not the case we have evidence that cloning a plain unscaled mode with | ||
2721 | * VGA doesn't really work. Furthermore the cloning flags are way too | ||
2722 | * simplistic anyway to express such constraints, so just give up on | ||
2723 | * cloning for SDVO encoders. | ||
2724 | */ | ||
2725 | intel_sdvo->base.cloneable = false; | ||
2726 | |||
2711 | /* Only enable the hotplug irq if we need it, to work around noisy | 2727 | /* Only enable the hotplug irq if we need it, to work around noisy |
2712 | * hotplug lines. | 2728 | * hotplug lines. |
2713 | */ | 2729 | */ |
@@ -2718,12 +2734,12 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob) | |||
2718 | 2734 | ||
2719 | /* Set the input timing to the screen. Assume always input 0. */ | 2735 | /* Set the input timing to the screen. Assume always input 0. */ |
2720 | if (!intel_sdvo_set_target_input(intel_sdvo)) | 2736 | if (!intel_sdvo_set_target_input(intel_sdvo)) |
2721 | goto err; | 2737 | goto err_output; |
2722 | 2738 | ||
2723 | if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo, | 2739 | if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo, |
2724 | &intel_sdvo->pixel_clock_min, | 2740 | &intel_sdvo->pixel_clock_min, |
2725 | &intel_sdvo->pixel_clock_max)) | 2741 | &intel_sdvo->pixel_clock_max)) |
2726 | goto err; | 2742 | goto err_output; |
2727 | 2743 | ||
2728 | DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, " | 2744 | DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, " |
2729 | "clock range %dMHz - %dMHz, " | 2745 | "clock range %dMHz - %dMHz, " |
@@ -2743,6 +2759,9 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob) | |||
2743 | (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); | 2759 | (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); |
2744 | return true; | 2760 | return true; |
2745 | 2761 | ||
2762 | err_output: | ||
2763 | intel_sdvo_output_cleanup(intel_sdvo); | ||
2764 | |||
2746 | err: | 2765 | err: |
2747 | drm_encoder_cleanup(&intel_encoder->base); | 2766 | drm_encoder_cleanup(&intel_encoder->base); |
2748 | i2c_del_adapter(&intel_sdvo->ddc); | 2767 | i2c_del_adapter(&intel_sdvo->ddc); |
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c index 05a909a17cee..15b182c84ce8 100644 --- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c | |||
@@ -49,13 +49,7 @@ nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc) | |||
49 | if (chan->vblank.crtc != crtc) | 49 | if (chan->vblank.crtc != crtc) |
50 | continue; | 50 | continue; |
51 | 51 | ||
52 | if (nv_device(priv)->chipset == 0x50) { | 52 | if (nv_device(priv)->chipset >= 0xc0) { |
53 | nv_wr32(priv, 0x001704, chan->vblank.channel); | ||
54 | nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma); | ||
55 | bar->flush(bar); | ||
56 | nv_wr32(priv, 0x001570, chan->vblank.offset); | ||
57 | nv_wr32(priv, 0x001574, chan->vblank.value); | ||
58 | } else { | ||
59 | nv_wr32(priv, 0x001718, 0x80000000 | chan->vblank.channel); | 53 | nv_wr32(priv, 0x001718, 0x80000000 | chan->vblank.channel); |
60 | bar->flush(bar); | 54 | bar->flush(bar); |
61 | nv_wr32(priv, 0x06000c, | 55 | nv_wr32(priv, 0x06000c, |
@@ -63,6 +57,17 @@ nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc) | |||
63 | nv_wr32(priv, 0x060010, | 57 | nv_wr32(priv, 0x060010, |
64 | lower_32_bits(chan->vblank.offset)); | 58 | lower_32_bits(chan->vblank.offset)); |
65 | nv_wr32(priv, 0x060014, chan->vblank.value); | 59 | nv_wr32(priv, 0x060014, chan->vblank.value); |
60 | } else { | ||
61 | nv_wr32(priv, 0x001704, chan->vblank.channel); | ||
62 | nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma); | ||
63 | bar->flush(bar); | ||
64 | if (nv_device(priv)->chipset == 0x50) { | ||
65 | nv_wr32(priv, 0x001570, chan->vblank.offset); | ||
66 | nv_wr32(priv, 0x001574, chan->vblank.value); | ||
67 | } else { | ||
68 | nv_wr32(priv, 0x060010, chan->vblank.offset); | ||
69 | nv_wr32(priv, 0x060014, chan->vblank.value); | ||
70 | } | ||
66 | } | 71 | } |
67 | 72 | ||
68 | list_del(&chan->vblank.head); | 73 | list_del(&chan->vblank.head); |
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c index e45035efb8ca..7bbb1e1b7a8d 100644 --- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c +++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c | |||
@@ -669,21 +669,27 @@ nv40_grctx_fill(struct nouveau_device *device, struct nouveau_gpuobj *mem) | |||
669 | }); | 669 | }); |
670 | } | 670 | } |
671 | 671 | ||
672 | void | 672 | int |
673 | nv40_grctx_init(struct nouveau_device *device, u32 *size) | 673 | nv40_grctx_init(struct nouveau_device *device, u32 *size) |
674 | { | 674 | { |
675 | u32 ctxprog[256], i; | 675 | u32 *ctxprog = kmalloc(256 * 4, GFP_KERNEL), i; |
676 | struct nouveau_grctx ctx = { | 676 | struct nouveau_grctx ctx = { |
677 | .device = device, | 677 | .device = device, |
678 | .mode = NOUVEAU_GRCTX_PROG, | 678 | .mode = NOUVEAU_GRCTX_PROG, |
679 | .data = ctxprog, | 679 | .data = ctxprog, |
680 | .ctxprog_max = ARRAY_SIZE(ctxprog) | 680 | .ctxprog_max = 256, |
681 | }; | 681 | }; |
682 | 682 | ||
683 | if (!ctxprog) | ||
684 | return -ENOMEM; | ||
685 | |||
683 | nv40_grctx_generate(&ctx); | 686 | nv40_grctx_generate(&ctx); |
684 | 687 | ||
685 | nv_wr32(device, 0x400324, 0); | 688 | nv_wr32(device, 0x400324, 0); |
686 | for (i = 0; i < ctx.ctxprog_len; i++) | 689 | for (i = 0; i < ctx.ctxprog_len; i++) |
687 | nv_wr32(device, 0x400328, ctxprog[i]); | 690 | nv_wr32(device, 0x400328, ctxprog[i]); |
688 | *size = ctx.ctxvals_pos * 4; | 691 | *size = ctx.ctxvals_pos * 4; |
692 | |||
693 | kfree(ctxprog); | ||
694 | return 0; | ||
689 | } | 695 | } |
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c index 425001204a89..cc6574eeb80e 100644 --- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c +++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c | |||
@@ -346,7 +346,9 @@ nv40_graph_init(struct nouveau_object *object) | |||
346 | return ret; | 346 | return ret; |
347 | 347 | ||
348 | /* generate and upload context program */ | 348 | /* generate and upload context program */ |
349 | nv40_grctx_init(nv_device(priv), &priv->size); | 349 | ret = nv40_grctx_init(nv_device(priv), &priv->size); |
350 | if (ret) | ||
351 | return ret; | ||
350 | 352 | ||
351 | /* No context present currently */ | 353 | /* No context present currently */ |
352 | nv_wr32(priv, NV40_PGRAPH_CTXCTL_CUR, 0x00000000); | 354 | nv_wr32(priv, NV40_PGRAPH_CTXCTL_CUR, 0x00000000); |
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h index d2ac975afc2e..7da35a4e7970 100644 --- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h +++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h | |||
@@ -15,7 +15,7 @@ nv44_graph_class(void *priv) | |||
15 | return !(0x0baf & (1 << (device->chipset & 0x0f))); | 15 | return !(0x0baf & (1 << (device->chipset & 0x0f))); |
16 | } | 16 | } |
17 | 17 | ||
18 | void nv40_grctx_init(struct nouveau_device *, u32 *size); | 18 | int nv40_grctx_init(struct nouveau_device *, u32 *size); |
19 | void nv40_grctx_fill(struct nouveau_device *, struct nouveau_gpuobj *); | 19 | void nv40_grctx_fill(struct nouveau_device *, struct nouveau_gpuobj *); |
20 | 20 | ||
21 | #endif | 21 | #endif |
diff --git a/drivers/gpu/drm/nouveau/core/include/core/object.h b/drivers/gpu/drm/nouveau/core/include/core/object.h index 818feabbf4a0..486f1a9217fd 100644 --- a/drivers/gpu/drm/nouveau/core/include/core/object.h +++ b/drivers/gpu/drm/nouveau/core/include/core/object.h | |||
@@ -175,14 +175,18 @@ nv_mo32(void *obj, u32 addr, u32 mask, u32 data) | |||
175 | return temp; | 175 | return temp; |
176 | } | 176 | } |
177 | 177 | ||
178 | static inline bool | 178 | static inline int |
179 | nv_strncmp(void *obj, u32 addr, u32 len, const char *str) | 179 | nv_memcmp(void *obj, u32 addr, const char *str, u32 len) |
180 | { | 180 | { |
181 | unsigned char c1, c2; | ||
182 | |||
181 | while (len--) { | 183 | while (len--) { |
182 | if (nv_ro08(obj, addr++) != *(str++)) | 184 | c1 = nv_ro08(obj, addr++); |
183 | return false; | 185 | c2 = *(str++); |
186 | if (c1 != c2) | ||
187 | return c1 - c2; | ||
184 | } | 188 | } |
185 | return true; | 189 | return 0; |
186 | } | 190 | } |
187 | 191 | ||
188 | #endif | 192 | #endif |
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h index 39e73b91d360..41b7a6a76f19 100644 --- a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h +++ b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h | |||
@@ -54,6 +54,7 @@ int nv04_clock_pll_calc(struct nouveau_clock *, struct nvbios_pll *, | |||
54 | int clk, struct nouveau_pll_vals *); | 54 | int clk, struct nouveau_pll_vals *); |
55 | int nv04_clock_pll_prog(struct nouveau_clock *, u32 reg1, | 55 | int nv04_clock_pll_prog(struct nouveau_clock *, u32 reg1, |
56 | struct nouveau_pll_vals *); | 56 | struct nouveau_pll_vals *); |
57 | 57 | int nva3_clock_pll_calc(struct nouveau_clock *, struct nvbios_pll *, | |
58 | int clk, struct nouveau_pll_vals *); | ||
58 | 59 | ||
59 | #endif | 60 | #endif |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c index 7d750382a833..c51197157749 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c | |||
@@ -64,7 +64,7 @@ dcb_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len) | |||
64 | } | 64 | } |
65 | } else | 65 | } else |
66 | if (*ver >= 0x15) { | 66 | if (*ver >= 0x15) { |
67 | if (!nv_strncmp(bios, dcb - 7, 7, "DEV_REC")) { | 67 | if (!nv_memcmp(bios, dcb - 7, "DEV_REC", 7)) { |
68 | u16 i2c = nv_ro16(bios, dcb + 2); | 68 | u16 i2c = nv_ro16(bios, dcb + 2); |
69 | *hdr = 4; | 69 | *hdr = 4; |
70 | *cnt = (i2c - dcb) / 10; | 70 | *cnt = (i2c - dcb) / 10; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c index cc8d7d162d7c..9068c98b96f6 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c | |||
@@ -66,6 +66,24 @@ nva3_clock_pll_set(struct nouveau_clock *clk, u32 type, u32 freq) | |||
66 | return ret; | 66 | return ret; |
67 | } | 67 | } |
68 | 68 | ||
69 | int | ||
70 | nva3_clock_pll_calc(struct nouveau_clock *clock, struct nvbios_pll *info, | ||
71 | int clk, struct nouveau_pll_vals *pv) | ||
72 | { | ||
73 | int ret, N, M, P; | ||
74 | |||
75 | ret = nva3_pll_calc(clock, info, clk, &N, NULL, &M, &P); | ||
76 | |||
77 | if (ret > 0) { | ||
78 | pv->refclk = info->refclk; | ||
79 | pv->N1 = N; | ||
80 | pv->M1 = M; | ||
81 | pv->log2P = P; | ||
82 | } | ||
83 | return ret; | ||
84 | } | ||
85 | |||
86 | |||
69 | static int | 87 | static int |
70 | nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | 88 | nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
71 | struct nouveau_oclass *oclass, void *data, u32 size, | 89 | struct nouveau_oclass *oclass, void *data, u32 size, |
@@ -80,6 +98,7 @@ nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
80 | return ret; | 98 | return ret; |
81 | 99 | ||
82 | priv->base.pll_set = nva3_clock_pll_set; | 100 | priv->base.pll_set = nva3_clock_pll_set; |
101 | priv->base.pll_calc = nva3_clock_pll_calc; | ||
83 | return 0; | 102 | return 0; |
84 | } | 103 | } |
85 | 104 | ||
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c index 5ccce0b17bf3..f6962c9b6c36 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c | |||
@@ -79,6 +79,7 @@ nvc0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
79 | return ret; | 79 | return ret; |
80 | 80 | ||
81 | priv->base.pll_set = nvc0_clock_pll_set; | 81 | priv->base.pll_set = nvc0_clock_pll_set; |
82 | priv->base.pll_calc = nva3_clock_pll_calc; | ||
82 | return 0; | 83 | return 0; |
83 | } | 84 | } |
84 | 85 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c index cc79c796afee..cbf1fc60a386 100644 --- a/drivers/gpu/drm/nouveau/nouveau_abi16.c +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c | |||
@@ -241,6 +241,10 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) | |||
241 | 241 | ||
242 | if (unlikely(!abi16)) | 242 | if (unlikely(!abi16)) |
243 | return -ENOMEM; | 243 | return -ENOMEM; |
244 | |||
245 | if (!drm->channel) | ||
246 | return nouveau_abi16_put(abi16, -ENODEV); | ||
247 | |||
244 | client = nv_client(abi16->client); | 248 | client = nv_client(abi16->client); |
245 | 249 | ||
246 | if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0) | 250 | if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0) |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 0910125cbbc3..8503b2ea570a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c | |||
@@ -129,7 +129,8 @@ nouveau_accel_init(struct nouveau_drm *drm) | |||
129 | 129 | ||
130 | /* initialise synchronisation routines */ | 130 | /* initialise synchronisation routines */ |
131 | if (device->card_type < NV_10) ret = nv04_fence_create(drm); | 131 | if (device->card_type < NV_10) ret = nv04_fence_create(drm); |
132 | else if (device->chipset < 0x84) ret = nv10_fence_create(drm); | 132 | else if (device->card_type < NV_50) ret = nv10_fence_create(drm); |
133 | else if (device->chipset < 0x84) ret = nv50_fence_create(drm); | ||
133 | else if (device->card_type < NV_C0) ret = nv84_fence_create(drm); | 134 | else if (device->card_type < NV_C0) ret = nv84_fence_create(drm); |
134 | else ret = nvc0_fence_create(drm); | 135 | else ret = nvc0_fence_create(drm); |
135 | if (ret) { | 136 | if (ret) { |
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index 3bce0299f64a..24d932f53203 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c | |||
@@ -1696,42 +1696,22 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc) | |||
1696 | return ATOM_PPLL2; | 1696 | return ATOM_PPLL2; |
1697 | DRM_ERROR("unable to allocate a PPLL\n"); | 1697 | DRM_ERROR("unable to allocate a PPLL\n"); |
1698 | return ATOM_PPLL_INVALID; | 1698 | return ATOM_PPLL_INVALID; |
1699 | } else if (ASIC_IS_AVIVO(rdev)) { | ||
1700 | /* in DP mode, the DP ref clock can come from either PPLL | ||
1701 | * depending on the asic: | ||
1702 | * DCE3: PPLL1 or PPLL2 | ||
1703 | */ | ||
1704 | if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(radeon_crtc->encoder))) { | ||
1705 | /* use the same PPLL for all DP monitors */ | ||
1706 | pll = radeon_get_shared_dp_ppll(crtc); | ||
1707 | if (pll != ATOM_PPLL_INVALID) | ||
1708 | return pll; | ||
1709 | } else { | ||
1710 | /* use the same PPLL for all monitors with the same clock */ | ||
1711 | pll = radeon_get_shared_nondp_ppll(crtc); | ||
1712 | if (pll != ATOM_PPLL_INVALID) | ||
1713 | return pll; | ||
1714 | } | ||
1715 | /* all other cases */ | ||
1716 | pll_in_use = radeon_get_pll_use_mask(crtc); | ||
1717 | /* the order shouldn't matter here, but we probably | ||
1718 | * need this until we have atomic modeset | ||
1719 | */ | ||
1720 | if (rdev->flags & RADEON_IS_IGP) { | ||
1721 | if (!(pll_in_use & (1 << ATOM_PPLL1))) | ||
1722 | return ATOM_PPLL1; | ||
1723 | if (!(pll_in_use & (1 << ATOM_PPLL2))) | ||
1724 | return ATOM_PPLL2; | ||
1725 | } else { | ||
1726 | if (!(pll_in_use & (1 << ATOM_PPLL2))) | ||
1727 | return ATOM_PPLL2; | ||
1728 | if (!(pll_in_use & (1 << ATOM_PPLL1))) | ||
1729 | return ATOM_PPLL1; | ||
1730 | } | ||
1731 | DRM_ERROR("unable to allocate a PPLL\n"); | ||
1732 | return ATOM_PPLL_INVALID; | ||
1733 | } else { | 1699 | } else { |
1734 | /* on pre-R5xx asics, the crtc to pll mapping is hardcoded */ | 1700 | /* on pre-R5xx asics, the crtc to pll mapping is hardcoded */ |
1701 | /* some atombios (observed in some DCE2/DCE3) code have a bug, | ||
1702 | * the matching btw pll and crtc is done through | ||
1703 | * PCLK_CRTC[1|2]_CNTL (0x480/0x484) but atombios code use the | ||
1704 | * pll (1 or 2) to select which register to write. ie if using | ||
1705 | * pll1 it will use PCLK_CRTC1_CNTL (0x480) and if using pll2 | ||
1706 | * it will use PCLK_CRTC2_CNTL (0x484), it then use crtc id to | ||
1707 | * choose which value to write. Which is reverse order from | ||
1708 | * register logic. So only case that works is when pllid is | ||
1709 | * same as crtcid or when both pll and crtc are enabled and | ||
1710 | * both use same clock. | ||
1711 | * | ||
1712 | * So just return crtc id as if crtc and pll were hard linked | ||
1713 | * together even if they aren't | ||
1714 | */ | ||
1735 | return radeon_crtc->crtc_id; | 1715 | return radeon_crtc->crtc_id; |
1736 | } | 1716 | } |
1737 | } | 1717 | } |
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c index ba498f8e47a2..010bae19554a 100644 --- a/drivers/gpu/drm/radeon/atombios_encoders.c +++ b/drivers/gpu/drm/radeon/atombios_encoders.c | |||
@@ -1625,7 +1625,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode) | |||
1625 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); | 1625 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); |
1626 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); | 1626 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); |
1627 | /* some early dce3.2 boards have a bug in their transmitter control table */ | 1627 | /* some early dce3.2 boards have a bug in their transmitter control table */ |
1628 | if ((rdev->family != CHIP_RV710) || (rdev->family != CHIP_RV730)) | 1628 | if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730)) |
1629 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); | 1629 | atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); |
1630 | } | 1630 | } |
1631 | if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { | 1631 | if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index af31f829f4a8..219942c660d7 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
@@ -1330,6 +1330,8 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav | |||
1330 | break; | 1330 | break; |
1331 | udelay(1); | 1331 | udelay(1); |
1332 | } | 1332 | } |
1333 | } else { | ||
1334 | save->crtc_enabled[i] = false; | ||
1333 | } | 1335 | } |
1334 | } | 1336 | } |
1335 | 1337 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_agp.c b/drivers/gpu/drm/radeon/radeon_agp.c index 10ea17a6b2a6..42433344cb1b 100644 --- a/drivers/gpu/drm/radeon/radeon_agp.c +++ b/drivers/gpu/drm/radeon/radeon_agp.c | |||
@@ -69,9 +69,12 @@ static struct radeon_agpmode_quirk radeon_agpmode_quirk_list[] = { | |||
69 | /* Intel 82830 830 Chipset Host Bridge / Mobility M6 LY Needs AGPMode 2 (fdo #17360)*/ | 69 | /* Intel 82830 830 Chipset Host Bridge / Mobility M6 LY Needs AGPMode 2 (fdo #17360)*/ |
70 | { PCI_VENDOR_ID_INTEL, 0x3575, PCI_VENDOR_ID_ATI, 0x4c59, | 70 | { PCI_VENDOR_ID_INTEL, 0x3575, PCI_VENDOR_ID_ATI, 0x4c59, |
71 | PCI_VENDOR_ID_DELL, 0x00e3, 2}, | 71 | PCI_VENDOR_ID_DELL, 0x00e3, 2}, |
72 | /* Intel 82852/82855 host bridge / Mobility FireGL 9000 R250 Needs AGPMode 1 (lp #296617) */ | 72 | /* Intel 82852/82855 host bridge / Mobility FireGL 9000 RV250 Needs AGPMode 1 (lp #296617) */ |
73 | { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4c66, | 73 | { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4c66, |
74 | PCI_VENDOR_ID_DELL, 0x0149, 1}, | 74 | PCI_VENDOR_ID_DELL, 0x0149, 1}, |
75 | /* Intel 82855PM host bridge / Mobility FireGL 9000 RV250 Needs AGPMode 1 for suspend/resume */ | ||
76 | { PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4c66, | ||
77 | PCI_VENDOR_ID_IBM, 0x0531, 1}, | ||
75 | /* Intel 82852/82855 host bridge / Mobility 9600 M10 RV350 Needs AGPMode 1 (deb #467460) */ | 78 | /* Intel 82852/82855 host bridge / Mobility 9600 M10 RV350 Needs AGPMode 1 (deb #467460) */ |
76 | { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4e50, | 79 | { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4e50, |
77 | 0x1025, 0x0061, 1}, | 80 | 0x1025, 0x0061, 1}, |
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 860dc4813e99..bd2a3b40cd12 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c | |||
@@ -749,7 +749,10 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, | |||
749 | /* clear the pages coming from the pool if requested */ | 749 | /* clear the pages coming from the pool if requested */ |
750 | if (flags & TTM_PAGE_FLAG_ZERO_ALLOC) { | 750 | if (flags & TTM_PAGE_FLAG_ZERO_ALLOC) { |
751 | list_for_each_entry(p, &plist, lru) { | 751 | list_for_each_entry(p, &plist, lru) { |
752 | clear_page(page_address(p)); | 752 | if (PageHighMem(p)) |
753 | clear_highpage(p); | ||
754 | else | ||
755 | clear_page(page_address(p)); | ||
753 | } | 756 | } |
754 | } | 757 | } |
755 | 758 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index bf8260133ea9..7d759a430294 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c | |||
@@ -308,9 +308,7 @@ int ttm_tt_swapin(struct ttm_tt *ttm) | |||
308 | if (unlikely(to_page == NULL)) | 308 | if (unlikely(to_page == NULL)) |
309 | goto out_err; | 309 | goto out_err; |
310 | 310 | ||
311 | preempt_disable(); | ||
312 | copy_highpage(to_page, from_page); | 311 | copy_highpage(to_page, from_page); |
313 | preempt_enable(); | ||
314 | page_cache_release(from_page); | 312 | page_cache_release(from_page); |
315 | } | 313 | } |
316 | 314 | ||
@@ -358,9 +356,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) | |||
358 | ret = PTR_ERR(to_page); | 356 | ret = PTR_ERR(to_page); |
359 | goto out_err; | 357 | goto out_err; |
360 | } | 358 | } |
361 | preempt_disable(); | ||
362 | copy_highpage(to_page, from_page); | 359 | copy_highpage(to_page, from_page); |
363 | preempt_enable(); | ||
364 | set_page_dirty(to_page); | 360 | set_page_dirty(to_page); |
365 | mark_page_accessed(to_page); | 361 | mark_page_accessed(to_page); |
366 | page_cache_release(to_page); | 362 | page_cache_release(to_page); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c index b07ca2e4d04b..7290811f89be 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | |||
@@ -110,6 +110,8 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, | |||
110 | memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size); | 110 | memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size); |
111 | 111 | ||
112 | ret = copy_to_user(buffer, bounce, size); | 112 | ret = copy_to_user(buffer, bounce, size); |
113 | if (ret) | ||
114 | ret = -EFAULT; | ||
113 | vfree(bounce); | 115 | vfree(bounce); |
114 | 116 | ||
115 | if (unlikely(ret != 0)) | 117 | if (unlikely(ret != 0)) |
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c index f676c01bb471..6fcd466d0825 100644 --- a/drivers/hid/hid-microsoft.c +++ b/drivers/hid/hid-microsoft.c | |||
@@ -46,9 +46,9 @@ static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
46 | rdesc[559] = 0x45; | 46 | rdesc[559] = 0x45; |
47 | } | 47 | } |
48 | /* the same as above (s/usage/physical/) */ | 48 | /* the same as above (s/usage/physical/) */ |
49 | if ((quirks & MS_RDESC_3K) && *rsize == 106 && | 49 | if ((quirks & MS_RDESC_3K) && *rsize == 106 && rdesc[94] == 0x19 && |
50 | !memcmp((char []){ 0x19, 0x00, 0x29, 0xff }, | 50 | rdesc[95] == 0x00 && rdesc[96] == 0x29 && |
51 | &rdesc[94], 4)) { | 51 | rdesc[97] == 0xff) { |
52 | rdesc[94] = 0x35; | 52 | rdesc[94] = 0x35; |
53 | rdesc[96] = 0x45; | 53 | rdesc[96] = 0x45; |
54 | } | 54 | } |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index c4633de64465..4800d4c2a7b7 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -334,6 +334,16 @@ config SENSORS_DA9052_ADC | |||
334 | This driver can also be built as module. If so, the module | 334 | This driver can also be built as module. If so, the module |
335 | will be called da9052-hwmon. | 335 | will be called da9052-hwmon. |
336 | 336 | ||
337 | config SENSORS_DA9055 | ||
338 | tristate "Dialog Semiconductor DA9055 ADC" | ||
339 | depends on MFD_DA9055 | ||
340 | help | ||
341 | If you say yes here you get support for ADC on the Dialog | ||
342 | Semiconductor DA9055 PMIC. | ||
343 | |||
344 | This driver can also be built as a module. If so, the module | ||
345 | will be called da9055-hwmon. | ||
346 | |||
337 | config SENSORS_I5K_AMB | 347 | config SENSORS_I5K_AMB |
338 | tristate "FB-DIMM AMB temperature sensor on Intel 5000 series chipsets" | 348 | tristate "FB-DIMM AMB temperature sensor on Intel 5000 series chipsets" |
339 | depends on PCI | 349 | depends on PCI |
@@ -455,7 +465,7 @@ config SENSORS_HIH6130 | |||
455 | 465 | ||
456 | config SENSORS_CORETEMP | 466 | config SENSORS_CORETEMP |
457 | tristate "Intel Core/Core2/Atom temperature sensor" | 467 | tristate "Intel Core/Core2/Atom temperature sensor" |
458 | depends on X86 && PCI | 468 | depends on X86 |
459 | help | 469 | help |
460 | If you say yes here you get support for the temperature | 470 | If you say yes here you get support for the temperature |
461 | sensor inside your CPU. Most of the family 6 CPUs | 471 | sensor inside your CPU. Most of the family 6 CPUs |
@@ -1106,11 +1116,12 @@ config SENSORS_ADS1015 | |||
1106 | will be called ads1015. | 1116 | will be called ads1015. |
1107 | 1117 | ||
1108 | config SENSORS_ADS7828 | 1118 | config SENSORS_ADS7828 |
1109 | tristate "Texas Instruments ADS7828" | 1119 | tristate "Texas Instruments ADS7828 and compatibles" |
1110 | depends on I2C | 1120 | depends on I2C |
1111 | help | 1121 | help |
1112 | If you say yes here you get support for Texas Instruments ADS7828 | 1122 | If you say yes here you get support for Texas Instruments ADS7828 and |
1113 | 12-bit 8-channel ADC device. | 1123 | ADS7830 8-channel A/D converters. ADS7828 resolution is 12-bit, while |
1124 | it is 8-bit on ADS7830. | ||
1114 | 1125 | ||
1115 | This driver can also be built as a module. If so, the module | 1126 | This driver can also be built as a module. If so, the module |
1116 | will be called ads7828. | 1127 | will be called ads7828. |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 8d5fcb5e8e9f..a930f0997d25 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -44,6 +44,7 @@ obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o | |||
44 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o | 44 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o |
45 | obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o | 45 | obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o |
46 | obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o | 46 | obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o |
47 | obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o | ||
47 | obj-$(CONFIG_SENSORS_DME1737) += dme1737.o | 48 | obj-$(CONFIG_SENSORS_DME1737) += dme1737.o |
48 | obj-$(CONFIG_SENSORS_DS620) += ds620.o | 49 | obj-$(CONFIG_SENSORS_DS620) += ds620.o |
49 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o | 50 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o |
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c index 1f9e8af0f322..409b5c16defb 100644 --- a/drivers/hwmon/ads7828.c +++ b/drivers/hwmon/ads7828.c | |||
@@ -1,12 +1,14 @@ | |||
1 | /* | 1 | /* |
2 | * ads7828.c - lm_sensors driver for ads7828 12-bit 8-channel ADC | 2 | * ads7828.c - driver for TI ADS7828 8-channel A/D converter and compatibles |
3 | * (C) 2007 EADS Astrium | 3 | * (C) 2007 EADS Astrium |
4 | * | 4 | * |
5 | * This driver is based on the lm75 and other lm_sensors/hwmon drivers | 5 | * This driver is based on the lm75 and other lm_sensors/hwmon drivers |
6 | * | 6 | * |
7 | * Written by Steve Hardy <shardy@redhat.com> | 7 | * Written by Steve Hardy <shardy@redhat.com> |
8 | * | 8 | * |
9 | * Datasheet available at: http://focus.ti.com/lit/ds/symlink/ads7828.pdf | 9 | * ADS7830 support, by Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> |
10 | * | ||
11 | * For further information, see the Documentation/hwmon/ads7828 file. | ||
10 | * | 12 | * |
11 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 14 | * it under the terms of the GNU General Public License as published by |
@@ -23,63 +25,48 @@ | |||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 26 | */ |
25 | 27 | ||
26 | #include <linux/module.h> | 28 | #include <linux/err.h> |
27 | #include <linux/init.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/jiffies.h> | ||
30 | #include <linux/i2c.h> | ||
31 | #include <linux/hwmon.h> | 29 | #include <linux/hwmon.h> |
32 | #include <linux/hwmon-sysfs.h> | 30 | #include <linux/hwmon-sysfs.h> |
33 | #include <linux/err.h> | 31 | #include <linux/i2c.h> |
32 | #include <linux/init.h> | ||
33 | #include <linux/jiffies.h> | ||
34 | #include <linux/module.h> | ||
34 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
36 | #include <linux/platform_data/ads7828.h> | ||
37 | #include <linux/slab.h> | ||
35 | 38 | ||
36 | /* The ADS7828 registers */ | 39 | /* The ADS7828 registers */ |
37 | #define ADS7828_NCH 8 /* 8 channels of 12-bit A-D supported */ | 40 | #define ADS7828_NCH 8 /* 8 channels supported */ |
38 | #define ADS7828_CMD_SD_SE 0x80 /* Single ended inputs */ | 41 | #define ADS7828_CMD_SD_SE 0x80 /* Single ended inputs */ |
39 | #define ADS7828_CMD_SD_DIFF 0x00 /* Differential inputs */ | 42 | #define ADS7828_CMD_PD1 0x04 /* Internal vref OFF && A/D ON */ |
40 | #define ADS7828_CMD_PD0 0x0 /* Power Down between A-D conversions */ | 43 | #define ADS7828_CMD_PD3 0x0C /* Internal vref ON && A/D ON */ |
41 | #define ADS7828_CMD_PD1 0x04 /* Internal ref OFF && A-D ON */ | 44 | #define ADS7828_INT_VREF_MV 2500 /* Internal vref is 2.5V, 2500mV */ |
42 | #define ADS7828_CMD_PD2 0x08 /* Internal ref ON && A-D OFF */ | 45 | #define ADS7828_EXT_VREF_MV_MIN 50 /* External vref min value 0.05V */ |
43 | #define ADS7828_CMD_PD3 0x0C /* Internal ref ON && A-D ON */ | 46 | #define ADS7828_EXT_VREF_MV_MAX 5250 /* External vref max value 5.25V */ |
44 | #define ADS7828_INT_VREF_MV 2500 /* Internal vref is 2.5V, 2500mV */ | 47 | |
45 | 48 | /* List of supported devices */ | |
46 | /* Addresses to scan */ | 49 | enum ads7828_chips { ads7828, ads7830 }; |
47 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, | 50 | |
48 | I2C_CLIENT_END }; | 51 | /* Client specific data */ |
49 | |||
50 | /* Module parameters */ | ||
51 | static bool se_input = 1; /* Default is SE, 0 == diff */ | ||
52 | static bool int_vref = 1; /* Default is internal ref ON */ | ||
53 | static int vref_mv = ADS7828_INT_VREF_MV; /* set if vref != 2.5V */ | ||
54 | module_param(se_input, bool, S_IRUGO); | ||
55 | module_param(int_vref, bool, S_IRUGO); | ||
56 | module_param(vref_mv, int, S_IRUGO); | ||
57 | |||
58 | /* Global Variables */ | ||
59 | static u8 ads7828_cmd_byte; /* cmd byte without channel bits */ | ||
60 | static unsigned int ads7828_lsb_resol; /* resolution of the ADC sample lsb */ | ||
61 | |||
62 | /* Each client has this additional data */ | ||
63 | struct ads7828_data { | 52 | struct ads7828_data { |
64 | struct device *hwmon_dev; | 53 | struct device *hwmon_dev; |
65 | struct mutex update_lock; /* mutex protect updates */ | 54 | struct mutex update_lock; /* Mutex protecting updates */ |
66 | char valid; /* !=0 if following fields are valid */ | 55 | unsigned long last_updated; /* Last updated time (in jiffies) */ |
67 | unsigned long last_updated; /* In jiffies */ | 56 | u16 adc_input[ADS7828_NCH]; /* ADS7828_NCH samples */ |
68 | u16 adc_input[ADS7828_NCH]; /* ADS7828_NCH 12-bit samples */ | 57 | bool valid; /* Validity flag */ |
58 | bool diff_input; /* Differential input */ | ||
59 | bool ext_vref; /* External voltage reference */ | ||
60 | unsigned int vref_mv; /* voltage reference value */ | ||
61 | u8 cmd_byte; /* Command byte without channel bits */ | ||
62 | unsigned int lsb_resol; /* Resolution of the ADC sample LSB */ | ||
63 | s32 (*read_channel)(const struct i2c_client *client, u8 command); | ||
69 | }; | 64 | }; |
70 | 65 | ||
71 | /* Function declaration - necessary due to function dependencies */ | 66 | /* Command byte C2,C1,C0 - see datasheet */ |
72 | static int ads7828_detect(struct i2c_client *client, | 67 | static inline u8 ads7828_cmd_byte(u8 cmd, int ch) |
73 | struct i2c_board_info *info); | ||
74 | static int ads7828_probe(struct i2c_client *client, | ||
75 | const struct i2c_device_id *id); | ||
76 | |||
77 | static inline u8 channel_cmd_byte(int ch) | ||
78 | { | 68 | { |
79 | /* cmd byte C2,C1,C0 - see datasheet */ | 69 | return cmd | (((ch >> 1) | (ch & 0x01) << 2) << 4); |
80 | u8 cmd = (((ch>>1) | (ch&0x01)<<2)<<4); | ||
81 | cmd |= ads7828_cmd_byte; | ||
82 | return cmd; | ||
83 | } | 70 | } |
84 | 71 | ||
85 | /* Update data for the device (all 8 channels) */ | 72 | /* Update data for the device (all 8 channels) */ |
@@ -96,12 +83,11 @@ static struct ads7828_data *ads7828_update_device(struct device *dev) | |||
96 | dev_dbg(&client->dev, "Starting ads7828 update\n"); | 83 | dev_dbg(&client->dev, "Starting ads7828 update\n"); |
97 | 84 | ||
98 | for (ch = 0; ch < ADS7828_NCH; ch++) { | 85 | for (ch = 0; ch < ADS7828_NCH; ch++) { |
99 | u8 cmd = channel_cmd_byte(ch); | 86 | u8 cmd = ads7828_cmd_byte(data->cmd_byte, ch); |
100 | data->adc_input[ch] = | 87 | data->adc_input[ch] = data->read_channel(client, cmd); |
101 | i2c_smbus_read_word_swapped(client, cmd); | ||
102 | } | 88 | } |
103 | data->last_updated = jiffies; | 89 | data->last_updated = jiffies; |
104 | data->valid = 1; | 90 | data->valid = true; |
105 | } | 91 | } |
106 | 92 | ||
107 | mutex_unlock(&data->update_lock); | 93 | mutex_unlock(&data->update_lock); |
@@ -110,28 +96,25 @@ static struct ads7828_data *ads7828_update_device(struct device *dev) | |||
110 | } | 96 | } |
111 | 97 | ||
112 | /* sysfs callback function */ | 98 | /* sysfs callback function */ |
113 | static ssize_t show_in(struct device *dev, struct device_attribute *da, | 99 | static ssize_t ads7828_show_in(struct device *dev, struct device_attribute *da, |
114 | char *buf) | 100 | char *buf) |
115 | { | 101 | { |
116 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | 102 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
117 | struct ads7828_data *data = ads7828_update_device(dev); | 103 | struct ads7828_data *data = ads7828_update_device(dev); |
118 | /* Print value (in mV as specified in sysfs-interface documentation) */ | 104 | unsigned int value = DIV_ROUND_CLOSEST(data->adc_input[attr->index] * |
119 | return sprintf(buf, "%d\n", (data->adc_input[attr->index] * | 105 | data->lsb_resol, 1000); |
120 | ads7828_lsb_resol)/1000); | ||
121 | } | ||
122 | 106 | ||
123 | #define in_reg(offset)\ | 107 | return sprintf(buf, "%d\n", value); |
124 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in,\ | 108 | } |
125 | NULL, offset) | ||
126 | 109 | ||
127 | in_reg(0); | 110 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, ads7828_show_in, NULL, 0); |
128 | in_reg(1); | 111 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ads7828_show_in, NULL, 1); |
129 | in_reg(2); | 112 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ads7828_show_in, NULL, 2); |
130 | in_reg(3); | 113 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ads7828_show_in, NULL, 3); |
131 | in_reg(4); | 114 | static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ads7828_show_in, NULL, 4); |
132 | in_reg(5); | 115 | static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, ads7828_show_in, NULL, 5); |
133 | in_reg(6); | 116 | static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, ads7828_show_in, NULL, 6); |
134 | in_reg(7); | 117 | static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, ads7828_show_in, NULL, 7); |
135 | 118 | ||
136 | static struct attribute *ads7828_attributes[] = { | 119 | static struct attribute *ads7828_attributes[] = { |
137 | &sensor_dev_attr_in0_input.dev_attr.attr, | 120 | &sensor_dev_attr_in0_input.dev_attr.attr, |
@@ -152,60 +135,9 @@ static const struct attribute_group ads7828_group = { | |||
152 | static int ads7828_remove(struct i2c_client *client) | 135 | static int ads7828_remove(struct i2c_client *client) |
153 | { | 136 | { |
154 | struct ads7828_data *data = i2c_get_clientdata(client); | 137 | struct ads7828_data *data = i2c_get_clientdata(client); |
138 | |||
155 | hwmon_device_unregister(data->hwmon_dev); | 139 | hwmon_device_unregister(data->hwmon_dev); |
156 | sysfs_remove_group(&client->dev.kobj, &ads7828_group); | 140 | sysfs_remove_group(&client->dev.kobj, &ads7828_group); |
157 | return 0; | ||
158 | } | ||
159 | |||
160 | static const struct i2c_device_id ads7828_id[] = { | ||
161 | { "ads7828", 0 }, | ||
162 | { } | ||
163 | }; | ||
164 | MODULE_DEVICE_TABLE(i2c, ads7828_id); | ||
165 | |||
166 | /* This is the driver that will be inserted */ | ||
167 | static struct i2c_driver ads7828_driver = { | ||
168 | .class = I2C_CLASS_HWMON, | ||
169 | .driver = { | ||
170 | .name = "ads7828", | ||
171 | }, | ||
172 | .probe = ads7828_probe, | ||
173 | .remove = ads7828_remove, | ||
174 | .id_table = ads7828_id, | ||
175 | .detect = ads7828_detect, | ||
176 | .address_list = normal_i2c, | ||
177 | }; | ||
178 | |||
179 | /* Return 0 if detection is successful, -ENODEV otherwise */ | ||
180 | static int ads7828_detect(struct i2c_client *client, | ||
181 | struct i2c_board_info *info) | ||
182 | { | ||
183 | struct i2c_adapter *adapter = client->adapter; | ||
184 | int ch; | ||
185 | |||
186 | /* Check we have a valid client */ | ||
187 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)) | ||
188 | return -ENODEV; | ||
189 | |||
190 | /* | ||
191 | * Now, we do the remaining detection. There is no identification | ||
192 | * dedicated register so attempt to sanity check using knowledge of | ||
193 | * the chip | ||
194 | * - Read from the 8 channel addresses | ||
195 | * - Check the top 4 bits of each result are not set (12 data bits) | ||
196 | */ | ||
197 | for (ch = 0; ch < ADS7828_NCH; ch++) { | ||
198 | u16 in_data; | ||
199 | u8 cmd = channel_cmd_byte(ch); | ||
200 | in_data = i2c_smbus_read_word_swapped(client, cmd); | ||
201 | if (in_data & 0xF000) { | ||
202 | pr_debug("%s : Doesn't look like an ads7828 device\n", | ||
203 | __func__); | ||
204 | return -ENODEV; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | strlcpy(info->type, "ads7828", I2C_NAME_SIZE); | ||
209 | 141 | ||
210 | return 0; | 142 | return 0; |
211 | } | 143 | } |
@@ -213,6 +145,7 @@ static int ads7828_detect(struct i2c_client *client, | |||
213 | static int ads7828_probe(struct i2c_client *client, | 145 | static int ads7828_probe(struct i2c_client *client, |
214 | const struct i2c_device_id *id) | 146 | const struct i2c_device_id *id) |
215 | { | 147 | { |
148 | struct ads7828_platform_data *pdata = client->dev.platform_data; | ||
216 | struct ads7828_data *data; | 149 | struct ads7828_data *data; |
217 | int err; | 150 | int err; |
218 | 151 | ||
@@ -221,10 +154,37 @@ static int ads7828_probe(struct i2c_client *client, | |||
221 | if (!data) | 154 | if (!data) |
222 | return -ENOMEM; | 155 | return -ENOMEM; |
223 | 156 | ||
157 | if (pdata) { | ||
158 | data->diff_input = pdata->diff_input; | ||
159 | data->ext_vref = pdata->ext_vref; | ||
160 | if (data->ext_vref) | ||
161 | data->vref_mv = pdata->vref_mv; | ||
162 | } | ||
163 | |||
164 | /* Bound Vref with min/max values if it was provided */ | ||
165 | if (data->vref_mv) | ||
166 | data->vref_mv = SENSORS_LIMIT(data->vref_mv, | ||
167 | ADS7828_EXT_VREF_MV_MIN, | ||
168 | ADS7828_EXT_VREF_MV_MAX); | ||
169 | else | ||
170 | data->vref_mv = ADS7828_INT_VREF_MV; | ||
171 | |||
172 | /* ADS7828 uses 12-bit samples, while ADS7830 is 8-bit */ | ||
173 | if (id->driver_data == ads7828) { | ||
174 | data->lsb_resol = DIV_ROUND_CLOSEST(data->vref_mv * 1000, 4096); | ||
175 | data->read_channel = i2c_smbus_read_word_swapped; | ||
176 | } else { | ||
177 | data->lsb_resol = DIV_ROUND_CLOSEST(data->vref_mv * 1000, 256); | ||
178 | data->read_channel = i2c_smbus_read_byte_data; | ||
179 | } | ||
180 | |||
181 | data->cmd_byte = data->ext_vref ? ADS7828_CMD_PD1 : ADS7828_CMD_PD3; | ||
182 | if (!data->diff_input) | ||
183 | data->cmd_byte |= ADS7828_CMD_SD_SE; | ||
184 | |||
224 | i2c_set_clientdata(client, data); | 185 | i2c_set_clientdata(client, data); |
225 | mutex_init(&data->update_lock); | 186 | mutex_init(&data->update_lock); |
226 | 187 | ||
227 | /* Register sysfs hooks */ | ||
228 | err = sysfs_create_group(&client->dev.kobj, &ads7828_group); | 188 | err = sysfs_create_group(&client->dev.kobj, &ads7828_group); |
229 | if (err) | 189 | if (err) |
230 | return err; | 190 | return err; |
@@ -232,38 +192,35 @@ static int ads7828_probe(struct i2c_client *client, | |||
232 | data->hwmon_dev = hwmon_device_register(&client->dev); | 192 | data->hwmon_dev = hwmon_device_register(&client->dev); |
233 | if (IS_ERR(data->hwmon_dev)) { | 193 | if (IS_ERR(data->hwmon_dev)) { |
234 | err = PTR_ERR(data->hwmon_dev); | 194 | err = PTR_ERR(data->hwmon_dev); |
235 | goto exit_remove; | 195 | goto error; |
236 | } | 196 | } |
237 | 197 | ||
238 | return 0; | 198 | return 0; |
239 | 199 | ||
240 | exit_remove: | 200 | error: |
241 | sysfs_remove_group(&client->dev.kobj, &ads7828_group); | 201 | sysfs_remove_group(&client->dev.kobj, &ads7828_group); |
242 | return err; | 202 | return err; |
243 | } | 203 | } |
244 | 204 | ||
245 | static int __init sensors_ads7828_init(void) | 205 | static const struct i2c_device_id ads7828_device_ids[] = { |
246 | { | 206 | { "ads7828", ads7828 }, |
247 | /* Initialize the command byte according to module parameters */ | 207 | { "ads7830", ads7830 }, |
248 | ads7828_cmd_byte = se_input ? | 208 | { } |
249 | ADS7828_CMD_SD_SE : ADS7828_CMD_SD_DIFF; | 209 | }; |
250 | ads7828_cmd_byte |= int_vref ? | 210 | MODULE_DEVICE_TABLE(i2c, ads7828_device_ids); |
251 | ADS7828_CMD_PD3 : ADS7828_CMD_PD1; | ||
252 | 211 | ||
253 | /* Calculate the LSB resolution */ | 212 | static struct i2c_driver ads7828_driver = { |
254 | ads7828_lsb_resol = (vref_mv*1000)/4096; | 213 | .driver = { |
214 | .name = "ads7828", | ||
215 | }, | ||
255 | 216 | ||
256 | return i2c_add_driver(&ads7828_driver); | 217 | .id_table = ads7828_device_ids, |
257 | } | 218 | .probe = ads7828_probe, |
219 | .remove = ads7828_remove, | ||
220 | }; | ||
258 | 221 | ||
259 | static void __exit sensors_ads7828_exit(void) | 222 | module_i2c_driver(ads7828_driver); |
260 | { | ||
261 | i2c_del_driver(&ads7828_driver); | ||
262 | } | ||
263 | 223 | ||
264 | MODULE_AUTHOR("Steve Hardy <shardy@redhat.com>"); | ||
265 | MODULE_DESCRIPTION("ADS7828 driver"); | ||
266 | MODULE_LICENSE("GPL"); | 224 | MODULE_LICENSE("GPL"); |
267 | 225 | MODULE_AUTHOR("Steve Hardy <shardy@redhat.com>"); | |
268 | module_init(sensors_ads7828_init); | 226 | MODULE_DESCRIPTION("Driver for TI ADS7828 A/D converter and compatibles"); |
269 | module_exit(sensors_ads7828_exit); | ||
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 47b8d84b489d..24426a785ad5 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/platform_device.h> | 35 | #include <linux/platform_device.h> |
36 | #include <linux/cpu.h> | 36 | #include <linux/cpu.h> |
37 | #include <linux/pci.h> | ||
38 | #include <linux/smp.h> | 37 | #include <linux/smp.h> |
39 | #include <linux/moduleparam.h> | 38 | #include <linux/moduleparam.h> |
40 | #include <asm/msr.h> | 39 | #include <asm/msr.h> |
@@ -197,14 +196,6 @@ struct tjmax { | |||
197 | }; | 196 | }; |
198 | 197 | ||
199 | static const struct tjmax __cpuinitconst tjmax_table[] = { | 198 | static const struct tjmax __cpuinitconst tjmax_table[] = { |
200 | { "CPU D410", 100000 }, | ||
201 | { "CPU D425", 100000 }, | ||
202 | { "CPU D510", 100000 }, | ||
203 | { "CPU D525", 100000 }, | ||
204 | { "CPU N450", 100000 }, | ||
205 | { "CPU N455", 100000 }, | ||
206 | { "CPU N470", 100000 }, | ||
207 | { "CPU N475", 100000 }, | ||
208 | { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */ | 199 | { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */ |
209 | { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */ | 200 | { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */ |
210 | { "CPU CE4110", 110000 }, /* Model 0x1c, stepping 10 */ | 201 | { "CPU CE4110", 110000 }, /* Model 0x1c, stepping 10 */ |
@@ -212,6 +203,28 @@ static const struct tjmax __cpuinitconst tjmax_table[] = { | |||
212 | { "CPU CE4170", 110000 }, /* Model 0x1c, stepping 10 */ | 203 | { "CPU CE4170", 110000 }, /* Model 0x1c, stepping 10 */ |
213 | }; | 204 | }; |
214 | 205 | ||
206 | struct tjmax_model { | ||
207 | u8 model; | ||
208 | u8 mask; | ||
209 | int tjmax; | ||
210 | }; | ||
211 | |||
212 | #define ANY 0xff | ||
213 | |||
214 | static const struct tjmax_model __cpuinitconst tjmax_model_table[] = { | ||
215 | { 0x1c, 10, 100000 }, /* D4xx, N4xx, D5xx, N5xx */ | ||
216 | { 0x1c, ANY, 90000 }, /* Z5xx, N2xx, possibly others | ||
217 | * Note: Also matches 230 and 330, | ||
218 | * which are covered by tjmax_table | ||
219 | */ | ||
220 | { 0x26, ANY, 90000 }, /* Atom Tunnel Creek (Exx), Lincroft (Z6xx) | ||
221 | * Note: TjMax for E6xxT is 110C, but CPU type | ||
222 | * is undetectable by software | ||
223 | */ | ||
224 | { 0x27, ANY, 90000 }, /* Atom Medfield (Z2460) */ | ||
225 | { 0x36, ANY, 100000 }, /* Atom Cedar Trail/Cedarview (N2xxx, D2xxx) */ | ||
226 | }; | ||
227 | |||
215 | static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, | 228 | static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, |
216 | struct device *dev) | 229 | struct device *dev) |
217 | { | 230 | { |
@@ -222,7 +235,6 @@ static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, | |||
222 | int usemsr_ee = 1; | 235 | int usemsr_ee = 1; |
223 | int err; | 236 | int err; |
224 | u32 eax, edx; | 237 | u32 eax, edx; |
225 | struct pci_dev *host_bridge; | ||
226 | int i; | 238 | int i; |
227 | 239 | ||
228 | /* explicit tjmax table entries override heuristics */ | 240 | /* explicit tjmax table entries override heuristics */ |
@@ -231,32 +243,18 @@ static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, | |||
231 | return tjmax_table[i].tjmax; | 243 | return tjmax_table[i].tjmax; |
232 | } | 244 | } |
233 | 245 | ||
246 | for (i = 0; i < ARRAY_SIZE(tjmax_model_table); i++) { | ||
247 | const struct tjmax_model *tm = &tjmax_model_table[i]; | ||
248 | if (c->x86_model == tm->model && | ||
249 | (tm->mask == ANY || c->x86_mask == tm->mask)) | ||
250 | return tm->tjmax; | ||
251 | } | ||
252 | |||
234 | /* Early chips have no MSR for TjMax */ | 253 | /* Early chips have no MSR for TjMax */ |
235 | 254 | ||
236 | if (c->x86_model == 0xf && c->x86_mask < 4) | 255 | if (c->x86_model == 0xf && c->x86_mask < 4) |
237 | usemsr_ee = 0; | 256 | usemsr_ee = 0; |
238 | 257 | ||
239 | /* Atom CPUs */ | ||
240 | |||
241 | if (c->x86_model == 0x1c || c->x86_model == 0x26 | ||
242 | || c->x86_model == 0x27) { | ||
243 | usemsr_ee = 0; | ||
244 | |||
245 | host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)); | ||
246 | |||
247 | if (host_bridge && host_bridge->vendor == PCI_VENDOR_ID_INTEL | ||
248 | && (host_bridge->device == 0xa000 /* NM10 based nettop */ | ||
249 | || host_bridge->device == 0xa010)) /* NM10 based netbook */ | ||
250 | tjmax = 100000; | ||
251 | else | ||
252 | tjmax = 90000; | ||
253 | |||
254 | pci_dev_put(host_bridge); | ||
255 | } else if (c->x86_model == 0x36) { | ||
256 | usemsr_ee = 0; | ||
257 | tjmax = 100000; | ||
258 | } | ||
259 | |||
260 | if (c->x86_model > 0xe && usemsr_ee) { | 258 | if (c->x86_model > 0xe && usemsr_ee) { |
261 | u8 platform_id; | 259 | u8 platform_id; |
262 | 260 | ||
diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c index b8d01c5f5713..19704948801c 100644 --- a/drivers/hwmon/da9052-hwmon.c +++ b/drivers/hwmon/da9052-hwmon.c | |||
@@ -60,30 +60,17 @@ static inline int vbbat_reg_to_mV(int value) | |||
60 | return DIV_ROUND_CLOSEST(value * 2500, 512); | 60 | return DIV_ROUND_CLOSEST(value * 2500, 512); |
61 | } | 61 | } |
62 | 62 | ||
63 | static int da9052_enable_vddout_channel(struct da9052 *da9052) | 63 | static inline int da9052_enable_vddout_channel(struct da9052 *da9052) |
64 | { | 64 | { |
65 | int ret; | 65 | return da9052_reg_update(da9052, DA9052_ADC_CONT_REG, |
66 | 66 | DA9052_ADCCONT_AUTOVDDEN, | |
67 | ret = da9052_reg_read(da9052, DA9052_ADC_CONT_REG); | 67 | DA9052_ADCCONT_AUTOVDDEN); |
68 | if (ret < 0) | ||
69 | return ret; | ||
70 | |||
71 | ret |= DA9052_ADCCONT_AUTOVDDEN; | ||
72 | |||
73 | return da9052_reg_write(da9052, DA9052_ADC_CONT_REG, ret); | ||
74 | } | 68 | } |
75 | 69 | ||
76 | static int da9052_disable_vddout_channel(struct da9052 *da9052) | 70 | static inline int da9052_disable_vddout_channel(struct da9052 *da9052) |
77 | { | 71 | { |
78 | int ret; | 72 | return da9052_reg_update(da9052, DA9052_ADC_CONT_REG, |
79 | 73 | DA9052_ADCCONT_AUTOVDDEN, 0); | |
80 | ret = da9052_reg_read(da9052, DA9052_ADC_CONT_REG); | ||
81 | if (ret < 0) | ||
82 | return ret; | ||
83 | |||
84 | ret &= ~DA9052_ADCCONT_AUTOVDDEN; | ||
85 | |||
86 | return da9052_reg_write(da9052, DA9052_ADC_CONT_REG, ret); | ||
87 | } | 74 | } |
88 | 75 | ||
89 | static ssize_t da9052_read_vddout(struct device *dev, | 76 | static ssize_t da9052_read_vddout(struct device *dev, |
diff --git a/drivers/hwmon/da9055-hwmon.c b/drivers/hwmon/da9055-hwmon.c new file mode 100644 index 000000000000..9465c050c326 --- /dev/null +++ b/drivers/hwmon/da9055-hwmon.c | |||
@@ -0,0 +1,336 @@ | |||
1 | /* | ||
2 | * HWMON Driver for Dialog DA9055 | ||
3 | * | ||
4 | * Copyright(c) 2012 Dialog Semiconductor Ltd. | ||
5 | * | ||
6 | * Author: David Dajun Chen <dchen@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/delay.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/hwmon.h> | ||
18 | #include <linux/hwmon-sysfs.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/completion.h> | ||
24 | |||
25 | #include <linux/mfd/da9055/core.h> | ||
26 | #include <linux/mfd/da9055/reg.h> | ||
27 | |||
28 | #define DA9055_ADCIN_DIV 102 | ||
29 | #define DA9055_VSYS_DIV 85 | ||
30 | |||
31 | #define DA9055_ADC_VSYS 0 | ||
32 | #define DA9055_ADC_ADCIN1 1 | ||
33 | #define DA9055_ADC_ADCIN2 2 | ||
34 | #define DA9055_ADC_ADCIN3 3 | ||
35 | #define DA9055_ADC_TJUNC 4 | ||
36 | |||
37 | struct da9055_hwmon { | ||
38 | struct da9055 *da9055; | ||
39 | struct device *class_device; | ||
40 | struct mutex hwmon_lock; | ||
41 | struct mutex irq_lock; | ||
42 | struct completion done; | ||
43 | }; | ||
44 | |||
45 | static const char * const input_names[] = { | ||
46 | [DA9055_ADC_VSYS] = "VSYS", | ||
47 | [DA9055_ADC_ADCIN1] = "ADC IN1", | ||
48 | [DA9055_ADC_ADCIN2] = "ADC IN2", | ||
49 | [DA9055_ADC_ADCIN3] = "ADC IN3", | ||
50 | [DA9055_ADC_TJUNC] = "CHIP TEMP", | ||
51 | }; | ||
52 | |||
53 | static const u8 chan_mux[DA9055_ADC_TJUNC + 1] = { | ||
54 | [DA9055_ADC_VSYS] = DA9055_ADC_MUX_VSYS, | ||
55 | [DA9055_ADC_ADCIN1] = DA9055_ADC_MUX_ADCIN1, | ||
56 | [DA9055_ADC_ADCIN2] = DA9055_ADC_MUX_ADCIN2, | ||
57 | [DA9055_ADC_ADCIN3] = DA9055_ADC_MUX_ADCIN3, | ||
58 | [DA9055_ADC_TJUNC] = DA9055_ADC_MUX_T_SENSE, | ||
59 | }; | ||
60 | |||
61 | static int da9055_adc_manual_read(struct da9055_hwmon *hwmon, | ||
62 | unsigned char channel) | ||
63 | { | ||
64 | int ret; | ||
65 | unsigned short calc_data; | ||
66 | unsigned short data; | ||
67 | unsigned char mux_sel; | ||
68 | struct da9055 *da9055 = hwmon->da9055; | ||
69 | |||
70 | if (channel > DA9055_ADC_TJUNC) | ||
71 | return -EINVAL; | ||
72 | |||
73 | mutex_lock(&hwmon->irq_lock); | ||
74 | |||
75 | /* Selects desired MUX for manual conversion */ | ||
76 | mux_sel = chan_mux[channel] | DA9055_ADC_MAN_CONV; | ||
77 | |||
78 | ret = da9055_reg_write(da9055, DA9055_REG_ADC_MAN, mux_sel); | ||
79 | if (ret < 0) | ||
80 | goto err; | ||
81 | |||
82 | /* Wait for an interrupt */ | ||
83 | if (!wait_for_completion_timeout(&hwmon->done, | ||
84 | msecs_to_jiffies(500))) { | ||
85 | dev_err(da9055->dev, | ||
86 | "timeout waiting for ADC conversion interrupt\n"); | ||
87 | ret = -ETIMEDOUT; | ||
88 | goto err; | ||
89 | } | ||
90 | |||
91 | ret = da9055_reg_read(da9055, DA9055_REG_ADC_RES_H); | ||
92 | if (ret < 0) | ||
93 | goto err; | ||
94 | |||
95 | calc_data = (unsigned short)ret; | ||
96 | data = calc_data << 2; | ||
97 | |||
98 | ret = da9055_reg_read(da9055, DA9055_REG_ADC_RES_L); | ||
99 | if (ret < 0) | ||
100 | goto err; | ||
101 | |||
102 | calc_data = (unsigned short)(ret & DA9055_ADC_LSB_MASK); | ||
103 | data |= calc_data; | ||
104 | |||
105 | ret = data; | ||
106 | |||
107 | err: | ||
108 | mutex_unlock(&hwmon->irq_lock); | ||
109 | return ret; | ||
110 | } | ||
111 | |||
112 | static irqreturn_t da9055_auxadc_irq(int irq, void *irq_data) | ||
113 | { | ||
114 | struct da9055_hwmon *hwmon = irq_data; | ||
115 | |||
116 | complete(&hwmon->done); | ||
117 | |||
118 | return IRQ_HANDLED; | ||
119 | } | ||
120 | |||
121 | /* Conversion function for VSYS and ADCINx */ | ||
122 | static inline int volt_reg_to_mV(int value, int channel) | ||
123 | { | ||
124 | if (channel == DA9055_ADC_VSYS) | ||
125 | return DIV_ROUND_CLOSEST(value * 1000, DA9055_VSYS_DIV) + 2500; | ||
126 | else | ||
127 | return DIV_ROUND_CLOSEST(value * 1000, DA9055_ADCIN_DIV); | ||
128 | } | ||
129 | |||
130 | static int da9055_enable_auto_mode(struct da9055 *da9055, int channel) | ||
131 | { | ||
132 | |||
133 | return da9055_reg_update(da9055, DA9055_REG_ADC_CONT, 1 << channel, | ||
134 | 1 << channel); | ||
135 | |||
136 | } | ||
137 | |||
138 | static int da9055_disable_auto_mode(struct da9055 *da9055, int channel) | ||
139 | { | ||
140 | |||
141 | return da9055_reg_update(da9055, DA9055_REG_ADC_CONT, 1 << channel, 0); | ||
142 | } | ||
143 | |||
144 | static ssize_t da9055_read_auto_ch(struct device *dev, | ||
145 | struct device_attribute *devattr, char *buf) | ||
146 | { | ||
147 | struct da9055_hwmon *hwmon = dev_get_drvdata(dev); | ||
148 | int ret, adc; | ||
149 | int channel = to_sensor_dev_attr(devattr)->index; | ||
150 | |||
151 | mutex_lock(&hwmon->hwmon_lock); | ||
152 | |||
153 | ret = da9055_enable_auto_mode(hwmon->da9055, channel); | ||
154 | if (ret < 0) | ||
155 | goto hwmon_err; | ||
156 | |||
157 | usleep_range(10000, 10500); | ||
158 | |||
159 | adc = da9055_reg_read(hwmon->da9055, DA9055_REG_VSYS_RES + channel); | ||
160 | if (adc < 0) { | ||
161 | ret = adc; | ||
162 | goto hwmon_err_release; | ||
163 | } | ||
164 | |||
165 | ret = da9055_disable_auto_mode(hwmon->da9055, channel); | ||
166 | if (ret < 0) | ||
167 | goto hwmon_err; | ||
168 | |||
169 | mutex_unlock(&hwmon->hwmon_lock); | ||
170 | |||
171 | return sprintf(buf, "%d\n", volt_reg_to_mV(adc, channel)); | ||
172 | |||
173 | hwmon_err_release: | ||
174 | da9055_disable_auto_mode(hwmon->da9055, channel); | ||
175 | hwmon_err: | ||
176 | mutex_unlock(&hwmon->hwmon_lock); | ||
177 | return ret; | ||
178 | } | ||
179 | |||
180 | static ssize_t da9055_read_tjunc(struct device *dev, | ||
181 | struct device_attribute *devattr, char *buf) | ||
182 | { | ||
183 | struct da9055_hwmon *hwmon = dev_get_drvdata(dev); | ||
184 | int tjunc; | ||
185 | int toffset; | ||
186 | |||
187 | tjunc = da9055_adc_manual_read(hwmon, DA9055_ADC_TJUNC); | ||
188 | if (tjunc < 0) | ||
189 | return tjunc; | ||
190 | |||
191 | toffset = da9055_reg_read(hwmon->da9055, DA9055_REG_T_OFFSET); | ||
192 | if (toffset < 0) | ||
193 | return toffset; | ||
194 | |||
195 | /* | ||
196 | * Degrees celsius = -0.4084 * (ADC_RES - T_OFFSET) + 307.6332 | ||
197 | * T_OFFSET is a trim value used to improve accuracy of the result | ||
198 | */ | ||
199 | return sprintf(buf, "%d\n", DIV_ROUND_CLOSEST(-4084 * (tjunc - toffset) | ||
200 | + 3076332, 10000)); | ||
201 | } | ||
202 | |||
203 | static ssize_t da9055_hwmon_show_name(struct device *dev, | ||
204 | struct device_attribute *devattr, | ||
205 | char *buf) | ||
206 | { | ||
207 | return sprintf(buf, "da9055-hwmon\n"); | ||
208 | } | ||
209 | |||
210 | static ssize_t show_label(struct device *dev, | ||
211 | struct device_attribute *devattr, char *buf) | ||
212 | { | ||
213 | return sprintf(buf, "%s\n", | ||
214 | input_names[to_sensor_dev_attr(devattr)->index]); | ||
215 | } | ||
216 | |||
217 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, da9055_read_auto_ch, NULL, | ||
218 | DA9055_ADC_VSYS); | ||
219 | static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, | ||
220 | DA9055_ADC_VSYS); | ||
221 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, da9055_read_auto_ch, NULL, | ||
222 | DA9055_ADC_ADCIN1); | ||
223 | static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_label, NULL, | ||
224 | DA9055_ADC_ADCIN1); | ||
225 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, da9055_read_auto_ch, NULL, | ||
226 | DA9055_ADC_ADCIN2); | ||
227 | static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_label, NULL, | ||
228 | DA9055_ADC_ADCIN2); | ||
229 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, da9055_read_auto_ch, NULL, | ||
230 | DA9055_ADC_ADCIN3); | ||
231 | static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, | ||
232 | DA9055_ADC_ADCIN3); | ||
233 | |||
234 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, da9055_read_tjunc, NULL, | ||
235 | DA9055_ADC_TJUNC); | ||
236 | static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_label, NULL, | ||
237 | DA9055_ADC_TJUNC); | ||
238 | |||
239 | static DEVICE_ATTR(name, S_IRUGO, da9055_hwmon_show_name, NULL); | ||
240 | |||
241 | static struct attribute *da9055_attr[] = { | ||
242 | &dev_attr_name.attr, | ||
243 | &sensor_dev_attr_in0_input.dev_attr.attr, | ||
244 | &sensor_dev_attr_in0_label.dev_attr.attr, | ||
245 | &sensor_dev_attr_in1_input.dev_attr.attr, | ||
246 | &sensor_dev_attr_in1_label.dev_attr.attr, | ||
247 | &sensor_dev_attr_in2_input.dev_attr.attr, | ||
248 | &sensor_dev_attr_in2_label.dev_attr.attr, | ||
249 | &sensor_dev_attr_in3_input.dev_attr.attr, | ||
250 | &sensor_dev_attr_in3_label.dev_attr.attr, | ||
251 | |||
252 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
253 | &sensor_dev_attr_temp1_label.dev_attr.attr, | ||
254 | NULL | ||
255 | }; | ||
256 | |||
257 | static const struct attribute_group da9055_attr_group = {.attrs = da9055_attr}; | ||
258 | |||
259 | static int da9055_hwmon_probe(struct platform_device *pdev) | ||
260 | { | ||
261 | struct da9055_hwmon *hwmon; | ||
262 | int hwmon_irq, ret; | ||
263 | |||
264 | hwmon = devm_kzalloc(&pdev->dev, sizeof(struct da9055_hwmon), | ||
265 | GFP_KERNEL); | ||
266 | if (!hwmon) | ||
267 | return -ENOMEM; | ||
268 | |||
269 | mutex_init(&hwmon->hwmon_lock); | ||
270 | mutex_init(&hwmon->irq_lock); | ||
271 | |||
272 | init_completion(&hwmon->done); | ||
273 | hwmon->da9055 = dev_get_drvdata(pdev->dev.parent); | ||
274 | |||
275 | platform_set_drvdata(pdev, hwmon); | ||
276 | |||
277 | hwmon_irq = platform_get_irq_byname(pdev, "HWMON"); | ||
278 | if (hwmon_irq < 0) | ||
279 | return hwmon_irq; | ||
280 | |||
281 | hwmon_irq = regmap_irq_get_virq(hwmon->da9055->irq_data, hwmon_irq); | ||
282 | if (hwmon_irq < 0) | ||
283 | return hwmon_irq; | ||
284 | |||
285 | ret = devm_request_threaded_irq(&pdev->dev, hwmon_irq, | ||
286 | NULL, da9055_auxadc_irq, | ||
287 | IRQF_TRIGGER_HIGH | IRQF_ONESHOT, | ||
288 | "adc-irq", hwmon); | ||
289 | if (ret != 0) { | ||
290 | dev_err(hwmon->da9055->dev, "DA9055 ADC IRQ failed ret=%d\n", | ||
291 | ret); | ||
292 | return ret; | ||
293 | } | ||
294 | |||
295 | ret = sysfs_create_group(&pdev->dev.kobj, &da9055_attr_group); | ||
296 | if (ret) | ||
297 | return ret; | ||
298 | |||
299 | hwmon->class_device = hwmon_device_register(&pdev->dev); | ||
300 | if (IS_ERR(hwmon->class_device)) { | ||
301 | ret = PTR_ERR(hwmon->class_device); | ||
302 | goto err; | ||
303 | } | ||
304 | |||
305 | return 0; | ||
306 | |||
307 | err: | ||
308 | sysfs_remove_group(&pdev->dev.kobj, &da9055_attr_group); | ||
309 | return ret; | ||
310 | } | ||
311 | |||
312 | static int da9055_hwmon_remove(struct platform_device *pdev) | ||
313 | { | ||
314 | struct da9055_hwmon *hwmon = platform_get_drvdata(pdev); | ||
315 | |||
316 | sysfs_remove_group(&pdev->dev.kobj, &da9055_attr_group); | ||
317 | hwmon_device_unregister(hwmon->class_device); | ||
318 | |||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | static struct platform_driver da9055_hwmon_driver = { | ||
323 | .probe = da9055_hwmon_probe, | ||
324 | .remove = da9055_hwmon_remove, | ||
325 | .driver = { | ||
326 | .name = "da9055-hwmon", | ||
327 | .owner = THIS_MODULE, | ||
328 | }, | ||
329 | }; | ||
330 | |||
331 | module_platform_driver(da9055_hwmon_driver); | ||
332 | |||
333 | MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>"); | ||
334 | MODULE_DESCRIPTION("DA9055 HWMON driver"); | ||
335 | MODULE_LICENSE("GPL"); | ||
336 | MODULE_ALIAS("platform:da9055-hwmon"); | ||
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index 4f4110407387..34ab2a8f9654 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c | |||
@@ -31,6 +31,9 @@ MODULE_DESCRIPTION("AMD Family 15h CPU processor power monitor"); | |||
31 | MODULE_AUTHOR("Andreas Herrmann <herrmann.der.user@googlemail.com>"); | 31 | MODULE_AUTHOR("Andreas Herrmann <herrmann.der.user@googlemail.com>"); |
32 | MODULE_LICENSE("GPL"); | 32 | MODULE_LICENSE("GPL"); |
33 | 33 | ||
34 | /* Family 16h Northbridge's function 4 PCI ID */ | ||
35 | #define PCI_DEVICE_ID_AMD_16H_NB_F4 0x1534 | ||
36 | |||
34 | /* D18F3 */ | 37 | /* D18F3 */ |
35 | #define REG_NORTHBRIDGE_CAP 0xe8 | 38 | #define REG_NORTHBRIDGE_CAP 0xe8 |
36 | 39 | ||
@@ -248,6 +251,7 @@ static void __devexit fam15h_power_remove(struct pci_dev *pdev) | |||
248 | 251 | ||
249 | static DEFINE_PCI_DEVICE_TABLE(fam15h_power_id_table) = { | 252 | static DEFINE_PCI_DEVICE_TABLE(fam15h_power_id_table) = { |
250 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, | 253 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, |
254 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, | ||
251 | {} | 255 | {} |
252 | }; | 256 | }; |
253 | MODULE_DEVICE_TABLE(pci, fam15h_power_id_table); | 257 | MODULE_DEVICE_TABLE(pci, fam15h_power_id_table); |
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index 2b726346f8fa..8e7158c3ad2f 100644 --- a/drivers/hwmon/ina2xx.c +++ b/drivers/hwmon/ina2xx.c | |||
@@ -302,19 +302,8 @@ static struct i2c_driver ina2xx_driver = { | |||
302 | .id_table = ina2xx_id, | 302 | .id_table = ina2xx_id, |
303 | }; | 303 | }; |
304 | 304 | ||
305 | static int __init ina2xx_init(void) | 305 | module_i2c_driver(ina2xx_driver); |
306 | { | ||
307 | return i2c_add_driver(&ina2xx_driver); | ||
308 | } | ||
309 | |||
310 | static void __exit ina2xx_exit(void) | ||
311 | { | ||
312 | i2c_del_driver(&ina2xx_driver); | ||
313 | } | ||
314 | 306 | ||
315 | MODULE_AUTHOR("Lothar Felten <l-felten@ti.com>"); | 307 | MODULE_AUTHOR("Lothar Felten <l-felten@ti.com>"); |
316 | MODULE_DESCRIPTION("ina2xx driver"); | 308 | MODULE_DESCRIPTION("ina2xx driver"); |
317 | MODULE_LICENSE("GPL"); | 309 | MODULE_LICENSE("GPL"); |
318 | |||
319 | module_init(ina2xx_init); | ||
320 | module_exit(ina2xx_exit); | ||
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index aa59a254be2c..c02bf208084f 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #define AT91_TWI_STOP 0x0002 /* Send a Stop Condition */ | 39 | #define AT91_TWI_STOP 0x0002 /* Send a Stop Condition */ |
40 | #define AT91_TWI_MSEN 0x0004 /* Master Transfer Enable */ | 40 | #define AT91_TWI_MSEN 0x0004 /* Master Transfer Enable */ |
41 | #define AT91_TWI_SVDIS 0x0020 /* Slave Transfer Disable */ | 41 | #define AT91_TWI_SVDIS 0x0020 /* Slave Transfer Disable */ |
42 | #define AT91_TWI_QUICK 0x0040 /* SMBus quick command */ | ||
42 | #define AT91_TWI_SWRST 0x0080 /* Software Reset */ | 43 | #define AT91_TWI_SWRST 0x0080 /* Software Reset */ |
43 | 44 | ||
44 | #define AT91_TWI_MMR 0x0004 /* Master Mode Register */ | 45 | #define AT91_TWI_MMR 0x0004 /* Master Mode Register */ |
@@ -212,7 +213,11 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev) | |||
212 | 213 | ||
213 | INIT_COMPLETION(dev->cmd_complete); | 214 | INIT_COMPLETION(dev->cmd_complete); |
214 | dev->transfer_status = 0; | 215 | dev->transfer_status = 0; |
215 | if (dev->msg->flags & I2C_M_RD) { | 216 | |
217 | if (!dev->buf_len) { | ||
218 | at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_QUICK); | ||
219 | at91_twi_write(dev, AT91_TWI_IER, AT91_TWI_TXCOMP); | ||
220 | } else if (dev->msg->flags & I2C_M_RD) { | ||
216 | unsigned start_flags = AT91_TWI_START; | 221 | unsigned start_flags = AT91_TWI_START; |
217 | 222 | ||
218 | if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) { | 223 | if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) { |
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c index 286ca1917820..0670da79ee5e 100644 --- a/drivers/i2c/busses/i2c-mxs.c +++ b/drivers/i2c/busses/i2c-mxs.c | |||
@@ -287,12 +287,14 @@ read_init_dma_fail: | |||
287 | select_init_dma_fail: | 287 | select_init_dma_fail: |
288 | dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE); | 288 | dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE); |
289 | select_init_pio_fail: | 289 | select_init_pio_fail: |
290 | dmaengine_terminate_all(i2c->dmach); | ||
290 | return -EINVAL; | 291 | return -EINVAL; |
291 | 292 | ||
292 | /* Write failpath. */ | 293 | /* Write failpath. */ |
293 | write_init_dma_fail: | 294 | write_init_dma_fail: |
294 | dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE); | 295 | dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE); |
295 | write_init_pio_fail: | 296 | write_init_pio_fail: |
297 | dmaengine_terminate_all(i2c->dmach); | ||
296 | return -EINVAL; | 298 | return -EINVAL; |
297 | } | 299 | } |
298 | 300 | ||
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index db31eaed6ea5..3525c9e62cb0 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
44 | #include <linux/i2c-omap.h> | 44 | #include <linux/i2c-omap.h> |
45 | #include <linux/pm_runtime.h> | 45 | #include <linux/pm_runtime.h> |
46 | #include <linux/pm_qos.h> | ||
47 | 46 | ||
48 | /* I2C controller revisions */ | 47 | /* I2C controller revisions */ |
49 | #define OMAP_I2C_OMAP1_REV_2 0x20 | 48 | #define OMAP_I2C_OMAP1_REV_2 0x20 |
@@ -187,8 +186,9 @@ struct omap_i2c_dev { | |||
187 | int reg_shift; /* bit shift for I2C register addresses */ | 186 | int reg_shift; /* bit shift for I2C register addresses */ |
188 | struct completion cmd_complete; | 187 | struct completion cmd_complete; |
189 | struct resource *ioarea; | 188 | struct resource *ioarea; |
190 | u32 latency; /* maximum MPU wkup latency */ | 189 | u32 latency; /* maximum mpu wkup latency */ |
191 | struct pm_qos_request pm_qos_request; | 190 | void (*set_mpu_wkup_lat)(struct device *dev, |
191 | long latency); | ||
192 | u32 speed; /* Speed of bus in kHz */ | 192 | u32 speed; /* Speed of bus in kHz */ |
193 | u32 dtrev; /* extra revision from DT */ | 193 | u32 dtrev; /* extra revision from DT */ |
194 | u32 flags; | 194 | u32 flags; |
@@ -494,7 +494,9 @@ static void omap_i2c_resize_fifo(struct omap_i2c_dev *dev, u8 size, bool is_rx) | |||
494 | dev->b_hw = 1; /* Enable hardware fixes */ | 494 | dev->b_hw = 1; /* Enable hardware fixes */ |
495 | 495 | ||
496 | /* calculate wakeup latency constraint for MPU */ | 496 | /* calculate wakeup latency constraint for MPU */ |
497 | dev->latency = (1000000 * dev->threshold) / (1000 * dev->speed / 8); | 497 | if (dev->set_mpu_wkup_lat != NULL) |
498 | dev->latency = (1000000 * dev->threshold) / | ||
499 | (1000 * dev->speed / 8); | ||
498 | } | 500 | } |
499 | 501 | ||
500 | /* | 502 | /* |
@@ -522,6 +524,9 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, | |||
522 | dev->buf = msg->buf; | 524 | dev->buf = msg->buf; |
523 | dev->buf_len = msg->len; | 525 | dev->buf_len = msg->len; |
524 | 526 | ||
527 | /* make sure writes to dev->buf_len are ordered */ | ||
528 | barrier(); | ||
529 | |||
525 | omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len); | 530 | omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len); |
526 | 531 | ||
527 | /* Clear the FIFO Buffers */ | 532 | /* Clear the FIFO Buffers */ |
@@ -579,7 +584,6 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, | |||
579 | */ | 584 | */ |
580 | timeout = wait_for_completion_timeout(&dev->cmd_complete, | 585 | timeout = wait_for_completion_timeout(&dev->cmd_complete, |
581 | OMAP_I2C_TIMEOUT); | 586 | OMAP_I2C_TIMEOUT); |
582 | dev->buf_len = 0; | ||
583 | if (timeout == 0) { | 587 | if (timeout == 0) { |
584 | dev_err(dev->dev, "controller timed out\n"); | 588 | dev_err(dev->dev, "controller timed out\n"); |
585 | omap_i2c_init(dev); | 589 | omap_i2c_init(dev); |
@@ -629,16 +633,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) | |||
629 | if (r < 0) | 633 | if (r < 0) |
630 | goto out; | 634 | goto out; |
631 | 635 | ||
632 | /* | 636 | if (dev->set_mpu_wkup_lat != NULL) |
633 | * When waiting for completion of a i2c transfer, we need to | 637 | dev->set_mpu_wkup_lat(dev->dev, dev->latency); |
634 | * set a wake up latency constraint for the MPU. This is to | ||
635 | * ensure quick enough wakeup from idle, when transfer | ||
636 | * completes. | ||
637 | */ | ||
638 | if (dev->latency) | ||
639 | pm_qos_add_request(&dev->pm_qos_request, | ||
640 | PM_QOS_CPU_DMA_LATENCY, | ||
641 | dev->latency); | ||
642 | 638 | ||
643 | for (i = 0; i < num; i++) { | 639 | for (i = 0; i < num; i++) { |
644 | r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1))); | 640 | r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1))); |
@@ -646,8 +642,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) | |||
646 | break; | 642 | break; |
647 | } | 643 | } |
648 | 644 | ||
649 | if (dev->latency) | 645 | if (dev->set_mpu_wkup_lat != NULL) |
650 | pm_qos_remove_request(&dev->pm_qos_request); | 646 | dev->set_mpu_wkup_lat(dev->dev, -1); |
651 | 647 | ||
652 | if (r == 0) | 648 | if (r == 0) |
653 | r = num; | 649 | r = num; |
@@ -1104,6 +1100,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1104 | } else if (pdata != NULL) { | 1100 | } else if (pdata != NULL) { |
1105 | dev->speed = pdata->clkrate; | 1101 | dev->speed = pdata->clkrate; |
1106 | dev->flags = pdata->flags; | 1102 | dev->flags = pdata->flags; |
1103 | dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; | ||
1107 | dev->dtrev = pdata->rev; | 1104 | dev->dtrev = pdata->rev; |
1108 | } | 1105 | } |
1109 | 1106 | ||
@@ -1159,8 +1156,9 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1159 | dev->b_hw = 1; /* Enable hardware fixes */ | 1156 | dev->b_hw = 1; /* Enable hardware fixes */ |
1160 | 1157 | ||
1161 | /* calculate wakeup latency constraint for MPU */ | 1158 | /* calculate wakeup latency constraint for MPU */ |
1162 | dev->latency = (1000000 * dev->fifo_size) / | 1159 | if (dev->set_mpu_wkup_lat != NULL) |
1163 | (1000 * dev->speed / 8); | 1160 | dev->latency = (1000000 * dev->fifo_size) / |
1161 | (1000 * dev->speed / 8); | ||
1164 | } | 1162 | } |
1165 | 1163 | ||
1166 | /* reset ASAP, clearing any IRQs */ | 1164 | /* reset ASAP, clearing any IRQs */ |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 3e0335f1fc60..9d902725bac9 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -806,6 +806,7 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c) | |||
806 | dev_err(i2c->dev, "invalid gpio[%d]: %d\n", idx, gpio); | 806 | dev_err(i2c->dev, "invalid gpio[%d]: %d\n", idx, gpio); |
807 | goto free_gpio; | 807 | goto free_gpio; |
808 | } | 808 | } |
809 | i2c->gpios[idx] = gpio; | ||
809 | 810 | ||
810 | ret = gpio_request(gpio, "i2c-bus"); | 811 | ret = gpio_request(gpio, "i2c-bus"); |
811 | if (ret) { | 812 | if (ret) { |
diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c index 5f097f309b9f..7fa5b24b16db 100644 --- a/drivers/i2c/muxes/i2c-mux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c | |||
@@ -169,7 +169,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct platform_device *pdev) | |||
169 | mux->busses = devm_kzalloc(&pdev->dev, | 169 | mux->busses = devm_kzalloc(&pdev->dev, |
170 | sizeof(mux->busses) * mux->pdata->bus_count, | 170 | sizeof(mux->busses) * mux->pdata->bus_count, |
171 | GFP_KERNEL); | 171 | GFP_KERNEL); |
172 | if (!mux->states) { | 172 | if (!mux->busses) { |
173 | dev_err(&pdev->dev, "Cannot allocate busses\n"); | 173 | dev_err(&pdev->dev, "Cannot allocate busses\n"); |
174 | ret = -ENOMEM; | 174 | ret = -ENOMEM; |
175 | goto err; | 175 | goto err; |
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index c0ec7d42c3be..1abbc170d8b7 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c | |||
@@ -26,10 +26,14 @@ static void copy_abs(struct input_dev *dev, unsigned int dst, unsigned int src) | |||
26 | * input_mt_init_slots() - initialize MT input slots | 26 | * input_mt_init_slots() - initialize MT input slots |
27 | * @dev: input device supporting MT events and finger tracking | 27 | * @dev: input device supporting MT events and finger tracking |
28 | * @num_slots: number of slots used by the device | 28 | * @num_slots: number of slots used by the device |
29 | * @flags: mt tasks to handle in core | ||
29 | * | 30 | * |
30 | * This function allocates all necessary memory for MT slot handling | 31 | * This function allocates all necessary memory for MT slot handling |
31 | * in the input device, prepares the ABS_MT_SLOT and | 32 | * in the input device, prepares the ABS_MT_SLOT and |
32 | * ABS_MT_TRACKING_ID events for use and sets up appropriate buffers. | 33 | * ABS_MT_TRACKING_ID events for use and sets up appropriate buffers. |
34 | * Depending on the flags set, it also performs pointer emulation and | ||
35 | * frame synchronization. | ||
36 | * | ||
33 | * May be called repeatedly. Returns -EINVAL if attempting to | 37 | * May be called repeatedly. Returns -EINVAL if attempting to |
34 | * reinitialize with a different number of slots. | 38 | * reinitialize with a different number of slots. |
35 | */ | 39 | */ |
diff --git a/drivers/input/matrix-keymap.c b/drivers/input/matrix-keymap.c index 443ad64b7f2a..d88d9be1d1b7 100644 --- a/drivers/input/matrix-keymap.c +++ b/drivers/input/matrix-keymap.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/input.h> | 23 | #include <linux/input.h> |
24 | #include <linux/of.h> | 24 | #include <linux/of.h> |
25 | #include <linux/export.h> | 25 | #include <linux/export.h> |
26 | #include <linux/module.h> | ||
26 | #include <linux/input/matrix_keypad.h> | 27 | #include <linux/input/matrix_keypad.h> |
27 | 28 | ||
28 | static bool matrix_keypad_map_key(struct input_dev *input_dev, | 29 | static bool matrix_keypad_map_key(struct input_dev *input_dev, |
@@ -161,3 +162,5 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, | |||
161 | return 0; | 162 | return 0; |
162 | } | 163 | } |
163 | EXPORT_SYMBOL(matrix_keypad_build_keymap); | 164 | EXPORT_SYMBOL(matrix_keypad_build_keymap); |
165 | |||
166 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 8f02e3d0e712..4c842c320c2e 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -12,8 +12,8 @@ | |||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
13 | 13 | ||
14 | #define MOUSEDEV_MINOR_BASE 32 | 14 | #define MOUSEDEV_MINOR_BASE 32 |
15 | #define MOUSEDEV_MINORS 32 | 15 | #define MOUSEDEV_MINORS 31 |
16 | #define MOUSEDEV_MIX 31 | 16 | #define MOUSEDEV_MIX 63 |
17 | 17 | ||
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index f02028ec3db6..78e5d9ab0ba7 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -955,7 +955,8 @@ static int ads7846_resume(struct device *dev) | |||
955 | 955 | ||
956 | static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume); | 956 | static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume); |
957 | 957 | ||
958 | static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts) | 958 | static int __devinit ads7846_setup_pendown(struct spi_device *spi, |
959 | struct ads7846 *ts) | ||
959 | { | 960 | { |
960 | struct ads7846_platform_data *pdata = spi->dev.platform_data; | 961 | struct ads7846_platform_data *pdata = spi->dev.platform_data; |
961 | int err; | 962 | int err; |
@@ -981,6 +982,9 @@ static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads784 | |||
981 | 982 | ||
982 | ts->gpio_pendown = pdata->gpio_pendown; | 983 | ts->gpio_pendown = pdata->gpio_pendown; |
983 | 984 | ||
985 | if (pdata->gpio_pendown_debounce) | ||
986 | gpio_set_debounce(pdata->gpio_pendown, | ||
987 | pdata->gpio_pendown_debounce); | ||
984 | } else { | 988 | } else { |
985 | dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); | 989 | dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); |
986 | return -EINVAL; | 990 | return -EINVAL; |
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index d4a4cd445cab..0badfa48b32b 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -4108,7 +4108,7 @@ static void swap_pci_ref(struct pci_dev **from, struct pci_dev *to) | |||
4108 | static int intel_iommu_add_device(struct device *dev) | 4108 | static int intel_iommu_add_device(struct device *dev) |
4109 | { | 4109 | { |
4110 | struct pci_dev *pdev = to_pci_dev(dev); | 4110 | struct pci_dev *pdev = to_pci_dev(dev); |
4111 | struct pci_dev *bridge, *dma_pdev; | 4111 | struct pci_dev *bridge, *dma_pdev = NULL; |
4112 | struct iommu_group *group; | 4112 | struct iommu_group *group; |
4113 | int ret; | 4113 | int ret; |
4114 | 4114 | ||
@@ -4122,7 +4122,7 @@ static int intel_iommu_add_device(struct device *dev) | |||
4122 | dma_pdev = pci_get_domain_bus_and_slot( | 4122 | dma_pdev = pci_get_domain_bus_and_slot( |
4123 | pci_domain_nr(pdev->bus), | 4123 | pci_domain_nr(pdev->bus), |
4124 | bridge->subordinate->number, 0); | 4124 | bridge->subordinate->number, 0); |
4125 | else | 4125 | if (!dma_pdev) |
4126 | dma_pdev = pci_dev_get(bridge); | 4126 | dma_pdev = pci_dev_get(bridge); |
4127 | } else | 4127 | } else |
4128 | dma_pdev = pci_dev_get(pdev); | 4128 | dma_pdev = pci_dev_get(pdev); |
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index a649f146d17b..c0f7a4266263 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c | |||
@@ -1054,6 +1054,7 @@ static int smmu_debugfs_stats_show(struct seq_file *s, void *v) | |||
1054 | stats[i], val, offs); | 1054 | stats[i], val, offs); |
1055 | } | 1055 | } |
1056 | seq_printf(s, "\n"); | 1056 | seq_printf(s, "\n"); |
1057 | dput(dent); | ||
1057 | 1058 | ||
1058 | return 0; | 1059 | return 0; |
1059 | } | 1060 | } |
diff --git a/drivers/irqchip/irq-bcm2835.c b/drivers/irqchip/irq-bcm2835.c index dc670ccc6978..16c78f1c5ef2 100644 --- a/drivers/irqchip/irq-bcm2835.c +++ b/drivers/irqchip/irq-bcm2835.c | |||
@@ -168,7 +168,8 @@ static int __init armctrl_of_init(struct device_node *node, | |||
168 | } | 168 | } |
169 | 169 | ||
170 | static struct of_device_id irq_of_match[] __initconst = { | 170 | static struct of_device_id irq_of_match[] __initconst = { |
171 | { .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init } | 171 | { .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init }, |
172 | { } | ||
172 | }; | 173 | }; |
173 | 174 | ||
174 | void __init bcm2835_init_irq(void) | 175 | void __init bcm2835_init_irq(void) |
diff --git a/drivers/leds/ledtrig-cpu.c b/drivers/leds/ledtrig-cpu.c index b312056da14d..4239b3955ff0 100644 --- a/drivers/leds/ledtrig-cpu.c +++ b/drivers/leds/ledtrig-cpu.c | |||
@@ -33,8 +33,6 @@ | |||
33 | struct led_trigger_cpu { | 33 | struct led_trigger_cpu { |
34 | char name[MAX_NAME_LEN]; | 34 | char name[MAX_NAME_LEN]; |
35 | struct led_trigger *_trig; | 35 | struct led_trigger *_trig; |
36 | struct mutex lock; | ||
37 | int lock_is_inited; | ||
38 | }; | 36 | }; |
39 | 37 | ||
40 | static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig); | 38 | static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig); |
@@ -50,12 +48,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt) | |||
50 | { | 48 | { |
51 | struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig); | 49 | struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig); |
52 | 50 | ||
53 | /* mutex lock should be initialized before calling mutex_call() */ | ||
54 | if (!trig->lock_is_inited) | ||
55 | return; | ||
56 | |||
57 | mutex_lock(&trig->lock); | ||
58 | |||
59 | /* Locate the correct CPU LED */ | 51 | /* Locate the correct CPU LED */ |
60 | switch (ledevt) { | 52 | switch (ledevt) { |
61 | case CPU_LED_IDLE_END: | 53 | case CPU_LED_IDLE_END: |
@@ -75,8 +67,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt) | |||
75 | /* Will leave the LED as it is */ | 67 | /* Will leave the LED as it is */ |
76 | break; | 68 | break; |
77 | } | 69 | } |
78 | |||
79 | mutex_unlock(&trig->lock); | ||
80 | } | 70 | } |
81 | EXPORT_SYMBOL(ledtrig_cpu); | 71 | EXPORT_SYMBOL(ledtrig_cpu); |
82 | 72 | ||
@@ -117,14 +107,9 @@ static int __init ledtrig_cpu_init(void) | |||
117 | for_each_possible_cpu(cpu) { | 107 | for_each_possible_cpu(cpu) { |
118 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); | 108 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); |
119 | 109 | ||
120 | mutex_init(&trig->lock); | ||
121 | |||
122 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); | 110 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); |
123 | 111 | ||
124 | mutex_lock(&trig->lock); | ||
125 | led_trigger_register_simple(trig->name, &trig->_trig); | 112 | led_trigger_register_simple(trig->name, &trig->_trig); |
126 | trig->lock_is_inited = 1; | ||
127 | mutex_unlock(&trig->lock); | ||
128 | } | 113 | } |
129 | 114 | ||
130 | register_syscore_ops(&ledtrig_cpu_syscore_ops); | 115 | register_syscore_ops(&ledtrig_cpu_syscore_ops); |
@@ -142,15 +127,9 @@ static void __exit ledtrig_cpu_exit(void) | |||
142 | for_each_possible_cpu(cpu) { | 127 | for_each_possible_cpu(cpu) { |
143 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); | 128 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); |
144 | 129 | ||
145 | mutex_lock(&trig->lock); | ||
146 | |||
147 | led_trigger_unregister_simple(trig->_trig); | 130 | led_trigger_unregister_simple(trig->_trig); |
148 | trig->_trig = NULL; | 131 | trig->_trig = NULL; |
149 | memset(trig->name, 0, MAX_NAME_LEN); | 132 | memset(trig->name, 0, MAX_NAME_LEN); |
150 | trig->lock_is_inited = 0; | ||
151 | |||
152 | mutex_unlock(&trig->lock); | ||
153 | mutex_destroy(&trig->lock); | ||
154 | } | 133 | } |
155 | 134 | ||
156 | unregister_syscore_ops(&ledtrig_cpu_syscore_ops); | 135 | unregister_syscore_ops(&ledtrig_cpu_syscore_ops); |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 02db9183ca01..77e6eff41cae 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -740,8 +740,14 @@ static void rq_completed(struct mapped_device *md, int rw, int run_queue) | |||
740 | if (!md_in_flight(md)) | 740 | if (!md_in_flight(md)) |
741 | wake_up(&md->wait); | 741 | wake_up(&md->wait); |
742 | 742 | ||
743 | /* | ||
744 | * Run this off this callpath, as drivers could invoke end_io while | ||
745 | * inside their request_fn (and holding the queue lock). Calling | ||
746 | * back into ->request_fn() could deadlock attempting to grab the | ||
747 | * queue lock again. | ||
748 | */ | ||
743 | if (run_queue) | 749 | if (run_queue) |
744 | blk_run_queue(md->queue); | 750 | blk_run_queue_async(md->queue); |
745 | 751 | ||
746 | /* | 752 | /* |
747 | * dm_put() must be at the end of this function. See the comment above | 753 | * dm_put() must be at the end of this function. See the comment above |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 9ab768acfb62..61200717687b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1817,10 +1817,10 @@ retry: | |||
1817 | memset(bbp, 0xff, PAGE_SIZE); | 1817 | memset(bbp, 0xff, PAGE_SIZE); |
1818 | 1818 | ||
1819 | for (i = 0 ; i < bb->count ; i++) { | 1819 | for (i = 0 ; i < bb->count ; i++) { |
1820 | u64 internal_bb = *p++; | 1820 | u64 internal_bb = p[i]; |
1821 | u64 store_bb = ((BB_OFFSET(internal_bb) << 10) | 1821 | u64 store_bb = ((BB_OFFSET(internal_bb) << 10) |
1822 | | BB_LEN(internal_bb)); | 1822 | | BB_LEN(internal_bb)); |
1823 | *bbp++ = cpu_to_le64(store_bb); | 1823 | bbp[i] = cpu_to_le64(store_bb); |
1824 | } | 1824 | } |
1825 | bb->changed = 0; | 1825 | bb->changed = 0; |
1826 | if (read_seqretry(&bb->lock, seq)) | 1826 | if (read_seqretry(&bb->lock, seq)) |
@@ -5294,7 +5294,7 @@ void md_stop_writes(struct mddev *mddev) | |||
5294 | } | 5294 | } |
5295 | EXPORT_SYMBOL_GPL(md_stop_writes); | 5295 | EXPORT_SYMBOL_GPL(md_stop_writes); |
5296 | 5296 | ||
5297 | void md_stop(struct mddev *mddev) | 5297 | static void __md_stop(struct mddev *mddev) |
5298 | { | 5298 | { |
5299 | mddev->ready = 0; | 5299 | mddev->ready = 0; |
5300 | mddev->pers->stop(mddev); | 5300 | mddev->pers->stop(mddev); |
@@ -5304,6 +5304,18 @@ void md_stop(struct mddev *mddev) | |||
5304 | mddev->pers = NULL; | 5304 | mddev->pers = NULL; |
5305 | clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); | 5305 | clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); |
5306 | } | 5306 | } |
5307 | |||
5308 | void md_stop(struct mddev *mddev) | ||
5309 | { | ||
5310 | /* stop the array and free an attached data structures. | ||
5311 | * This is called from dm-raid | ||
5312 | */ | ||
5313 | __md_stop(mddev); | ||
5314 | bitmap_destroy(mddev); | ||
5315 | if (mddev->bio_set) | ||
5316 | bioset_free(mddev->bio_set); | ||
5317 | } | ||
5318 | |||
5307 | EXPORT_SYMBOL_GPL(md_stop); | 5319 | EXPORT_SYMBOL_GPL(md_stop); |
5308 | 5320 | ||
5309 | static int md_set_readonly(struct mddev *mddev, struct block_device *bdev) | 5321 | static int md_set_readonly(struct mddev *mddev, struct block_device *bdev) |
@@ -5364,7 +5376,7 @@ static int do_md_stop(struct mddev * mddev, int mode, | |||
5364 | set_disk_ro(disk, 0); | 5376 | set_disk_ro(disk, 0); |
5365 | 5377 | ||
5366 | __md_stop_writes(mddev); | 5378 | __md_stop_writes(mddev); |
5367 | md_stop(mddev); | 5379 | __md_stop(mddev); |
5368 | mddev->queue->merge_bvec_fn = NULL; | 5380 | mddev->queue->merge_bvec_fn = NULL; |
5369 | mddev->queue->backing_dev_info.congested_fn = NULL; | 5381 | mddev->queue->backing_dev_info.congested_fn = NULL; |
5370 | 5382 | ||
@@ -7936,9 +7948,9 @@ int md_is_badblock(struct badblocks *bb, sector_t s, int sectors, | |||
7936 | sector_t *first_bad, int *bad_sectors) | 7948 | sector_t *first_bad, int *bad_sectors) |
7937 | { | 7949 | { |
7938 | int hi; | 7950 | int hi; |
7939 | int lo = 0; | 7951 | int lo; |
7940 | u64 *p = bb->page; | 7952 | u64 *p = bb->page; |
7941 | int rv = 0; | 7953 | int rv; |
7942 | sector_t target = s + sectors; | 7954 | sector_t target = s + sectors; |
7943 | unsigned seq; | 7955 | unsigned seq; |
7944 | 7956 | ||
@@ -7953,7 +7965,8 @@ int md_is_badblock(struct badblocks *bb, sector_t s, int sectors, | |||
7953 | 7965 | ||
7954 | retry: | 7966 | retry: |
7955 | seq = read_seqbegin(&bb->lock); | 7967 | seq = read_seqbegin(&bb->lock); |
7956 | 7968 | lo = 0; | |
7969 | rv = 0; | ||
7957 | hi = bb->count; | 7970 | hi = bb->count; |
7958 | 7971 | ||
7959 | /* Binary search between lo and hi for 'target' | 7972 | /* Binary search between lo and hi for 'target' |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 636bae0405e8..a0f73092176e 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -963,7 +963,7 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule) | |||
963 | struct r1conf *conf = mddev->private; | 963 | struct r1conf *conf = mddev->private; |
964 | struct bio *bio; | 964 | struct bio *bio; |
965 | 965 | ||
966 | if (from_schedule) { | 966 | if (from_schedule || current->bio_list) { |
967 | spin_lock_irq(&conf->device_lock); | 967 | spin_lock_irq(&conf->device_lock); |
968 | bio_list_merge(&conf->pending_bio_list, &plug->pending); | 968 | bio_list_merge(&conf->pending_bio_list, &plug->pending); |
969 | conf->pending_count += plug->pending_cnt; | 969 | conf->pending_count += plug->pending_cnt; |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index d1295aff4173..c9acbd717131 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -499,7 +499,7 @@ static void raid10_end_write_request(struct bio *bio, int error) | |||
499 | */ | 499 | */ |
500 | one_write_done(r10_bio); | 500 | one_write_done(r10_bio); |
501 | if (dec_rdev) | 501 | if (dec_rdev) |
502 | rdev_dec_pending(conf->mirrors[dev].rdev, conf->mddev); | 502 | rdev_dec_pending(rdev, conf->mddev); |
503 | } | 503 | } |
504 | 504 | ||
505 | /* | 505 | /* |
@@ -1069,7 +1069,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) | |||
1069 | struct r10conf *conf = mddev->private; | 1069 | struct r10conf *conf = mddev->private; |
1070 | struct bio *bio; | 1070 | struct bio *bio; |
1071 | 1071 | ||
1072 | if (from_schedule) { | 1072 | if (from_schedule || current->bio_list) { |
1073 | spin_lock_irq(&conf->device_lock); | 1073 | spin_lock_irq(&conf->device_lock); |
1074 | bio_list_merge(&conf->pending_bio_list, &plug->pending); | 1074 | bio_list_merge(&conf->pending_bio_list, &plug->pending); |
1075 | conf->pending_count += plug->pending_cnt; | 1075 | conf->pending_count += plug->pending_cnt; |
@@ -1334,18 +1334,21 @@ retry_write: | |||
1334 | blocked_rdev = rrdev; | 1334 | blocked_rdev = rrdev; |
1335 | break; | 1335 | break; |
1336 | } | 1336 | } |
1337 | if (rdev && (test_bit(Faulty, &rdev->flags) | ||
1338 | || test_bit(Unmerged, &rdev->flags))) | ||
1339 | rdev = NULL; | ||
1337 | if (rrdev && (test_bit(Faulty, &rrdev->flags) | 1340 | if (rrdev && (test_bit(Faulty, &rrdev->flags) |
1338 | || test_bit(Unmerged, &rrdev->flags))) | 1341 | || test_bit(Unmerged, &rrdev->flags))) |
1339 | rrdev = NULL; | 1342 | rrdev = NULL; |
1340 | 1343 | ||
1341 | r10_bio->devs[i].bio = NULL; | 1344 | r10_bio->devs[i].bio = NULL; |
1342 | r10_bio->devs[i].repl_bio = NULL; | 1345 | r10_bio->devs[i].repl_bio = NULL; |
1343 | if (!rdev || test_bit(Faulty, &rdev->flags) || | 1346 | |
1344 | test_bit(Unmerged, &rdev->flags)) { | 1347 | if (!rdev && !rrdev) { |
1345 | set_bit(R10BIO_Degraded, &r10_bio->state); | 1348 | set_bit(R10BIO_Degraded, &r10_bio->state); |
1346 | continue; | 1349 | continue; |
1347 | } | 1350 | } |
1348 | if (test_bit(WriteErrorSeen, &rdev->flags)) { | 1351 | if (rdev && test_bit(WriteErrorSeen, &rdev->flags)) { |
1349 | sector_t first_bad; | 1352 | sector_t first_bad; |
1350 | sector_t dev_sector = r10_bio->devs[i].addr; | 1353 | sector_t dev_sector = r10_bio->devs[i].addr; |
1351 | int bad_sectors; | 1354 | int bad_sectors; |
@@ -1387,8 +1390,10 @@ retry_write: | |||
1387 | max_sectors = good_sectors; | 1390 | max_sectors = good_sectors; |
1388 | } | 1391 | } |
1389 | } | 1392 | } |
1390 | r10_bio->devs[i].bio = bio; | 1393 | if (rdev) { |
1391 | atomic_inc(&rdev->nr_pending); | 1394 | r10_bio->devs[i].bio = bio; |
1395 | atomic_inc(&rdev->nr_pending); | ||
1396 | } | ||
1392 | if (rrdev) { | 1397 | if (rrdev) { |
1393 | r10_bio->devs[i].repl_bio = bio; | 1398 | r10_bio->devs[i].repl_bio = bio; |
1394 | atomic_inc(&rrdev->nr_pending); | 1399 | atomic_inc(&rrdev->nr_pending); |
@@ -1444,69 +1449,71 @@ retry_write: | |||
1444 | for (i = 0; i < conf->copies; i++) { | 1449 | for (i = 0; i < conf->copies; i++) { |
1445 | struct bio *mbio; | 1450 | struct bio *mbio; |
1446 | int d = r10_bio->devs[i].devnum; | 1451 | int d = r10_bio->devs[i].devnum; |
1447 | if (!r10_bio->devs[i].bio) | 1452 | if (r10_bio->devs[i].bio) { |
1448 | continue; | 1453 | struct md_rdev *rdev = conf->mirrors[d].rdev; |
1454 | mbio = bio_clone_mddev(bio, GFP_NOIO, mddev); | ||
1455 | md_trim_bio(mbio, r10_bio->sector - bio->bi_sector, | ||
1456 | max_sectors); | ||
1457 | r10_bio->devs[i].bio = mbio; | ||
1458 | |||
1459 | mbio->bi_sector = (r10_bio->devs[i].addr+ | ||
1460 | choose_data_offset(r10_bio, | ||
1461 | rdev)); | ||
1462 | mbio->bi_bdev = rdev->bdev; | ||
1463 | mbio->bi_end_io = raid10_end_write_request; | ||
1464 | mbio->bi_rw = WRITE | do_sync | do_fua | do_discard; | ||
1465 | mbio->bi_private = r10_bio; | ||
1449 | 1466 | ||
1450 | mbio = bio_clone_mddev(bio, GFP_NOIO, mddev); | 1467 | atomic_inc(&r10_bio->remaining); |
1451 | md_trim_bio(mbio, r10_bio->sector - bio->bi_sector, | ||
1452 | max_sectors); | ||
1453 | r10_bio->devs[i].bio = mbio; | ||
1454 | 1468 | ||
1455 | mbio->bi_sector = (r10_bio->devs[i].addr+ | 1469 | cb = blk_check_plugged(raid10_unplug, mddev, |
1456 | choose_data_offset(r10_bio, | 1470 | sizeof(*plug)); |
1457 | conf->mirrors[d].rdev)); | 1471 | if (cb) |
1458 | mbio->bi_bdev = conf->mirrors[d].rdev->bdev; | 1472 | plug = container_of(cb, struct raid10_plug_cb, |
1459 | mbio->bi_end_io = raid10_end_write_request; | 1473 | cb); |
1460 | mbio->bi_rw = WRITE | do_sync | do_fua | do_discard; | 1474 | else |
1461 | mbio->bi_private = r10_bio; | 1475 | plug = NULL; |
1476 | spin_lock_irqsave(&conf->device_lock, flags); | ||
1477 | if (plug) { | ||
1478 | bio_list_add(&plug->pending, mbio); | ||
1479 | plug->pending_cnt++; | ||
1480 | } else { | ||
1481 | bio_list_add(&conf->pending_bio_list, mbio); | ||
1482 | conf->pending_count++; | ||
1483 | } | ||
1484 | spin_unlock_irqrestore(&conf->device_lock, flags); | ||
1485 | if (!plug) | ||
1486 | md_wakeup_thread(mddev->thread); | ||
1487 | } | ||
1462 | 1488 | ||
1463 | atomic_inc(&r10_bio->remaining); | 1489 | if (r10_bio->devs[i].repl_bio) { |
1490 | struct md_rdev *rdev = conf->mirrors[d].replacement; | ||
1491 | if (rdev == NULL) { | ||
1492 | /* Replacement just got moved to main 'rdev' */ | ||
1493 | smp_mb(); | ||
1494 | rdev = conf->mirrors[d].rdev; | ||
1495 | } | ||
1496 | mbio = bio_clone_mddev(bio, GFP_NOIO, mddev); | ||
1497 | md_trim_bio(mbio, r10_bio->sector - bio->bi_sector, | ||
1498 | max_sectors); | ||
1499 | r10_bio->devs[i].repl_bio = mbio; | ||
1500 | |||
1501 | mbio->bi_sector = (r10_bio->devs[i].addr + | ||
1502 | choose_data_offset( | ||
1503 | r10_bio, rdev)); | ||
1504 | mbio->bi_bdev = rdev->bdev; | ||
1505 | mbio->bi_end_io = raid10_end_write_request; | ||
1506 | mbio->bi_rw = WRITE | do_sync | do_fua | do_discard; | ||
1507 | mbio->bi_private = r10_bio; | ||
1464 | 1508 | ||
1465 | cb = blk_check_plugged(raid10_unplug, mddev, sizeof(*plug)); | 1509 | atomic_inc(&r10_bio->remaining); |
1466 | if (cb) | 1510 | spin_lock_irqsave(&conf->device_lock, flags); |
1467 | plug = container_of(cb, struct raid10_plug_cb, cb); | ||
1468 | else | ||
1469 | plug = NULL; | ||
1470 | spin_lock_irqsave(&conf->device_lock, flags); | ||
1471 | if (plug) { | ||
1472 | bio_list_add(&plug->pending, mbio); | ||
1473 | plug->pending_cnt++; | ||
1474 | } else { | ||
1475 | bio_list_add(&conf->pending_bio_list, mbio); | 1511 | bio_list_add(&conf->pending_bio_list, mbio); |
1476 | conf->pending_count++; | 1512 | conf->pending_count++; |
1513 | spin_unlock_irqrestore(&conf->device_lock, flags); | ||
1514 | if (!mddev_check_plugged(mddev)) | ||
1515 | md_wakeup_thread(mddev->thread); | ||
1477 | } | 1516 | } |
1478 | spin_unlock_irqrestore(&conf->device_lock, flags); | ||
1479 | if (!plug) | ||
1480 | md_wakeup_thread(mddev->thread); | ||
1481 | |||
1482 | if (!r10_bio->devs[i].repl_bio) | ||
1483 | continue; | ||
1484 | |||
1485 | mbio = bio_clone_mddev(bio, GFP_NOIO, mddev); | ||
1486 | md_trim_bio(mbio, r10_bio->sector - bio->bi_sector, | ||
1487 | max_sectors); | ||
1488 | r10_bio->devs[i].repl_bio = mbio; | ||
1489 | |||
1490 | /* We are actively writing to the original device | ||
1491 | * so it cannot disappear, so the replacement cannot | ||
1492 | * become NULL here | ||
1493 | */ | ||
1494 | mbio->bi_sector = (r10_bio->devs[i].addr + | ||
1495 | choose_data_offset( | ||
1496 | r10_bio, | ||
1497 | conf->mirrors[d].replacement)); | ||
1498 | mbio->bi_bdev = conf->mirrors[d].replacement->bdev; | ||
1499 | mbio->bi_end_io = raid10_end_write_request; | ||
1500 | mbio->bi_rw = WRITE | do_sync | do_fua | do_discard; | ||
1501 | mbio->bi_private = r10_bio; | ||
1502 | |||
1503 | atomic_inc(&r10_bio->remaining); | ||
1504 | spin_lock_irqsave(&conf->device_lock, flags); | ||
1505 | bio_list_add(&conf->pending_bio_list, mbio); | ||
1506 | conf->pending_count++; | ||
1507 | spin_unlock_irqrestore(&conf->device_lock, flags); | ||
1508 | if (!mddev_check_plugged(mddev)) | ||
1509 | md_wakeup_thread(mddev->thread); | ||
1510 | } | 1517 | } |
1511 | 1518 | ||
1512 | /* Don't remove the bias on 'remaining' (one_write_done) until | 1519 | /* Don't remove the bias on 'remaining' (one_write_done) until |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index c5439dce0295..a4502686e7a8 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -2774,10 +2774,12 @@ static void handle_stripe_clean_event(struct r5conf *conf, | |||
2774 | dev = &sh->dev[i]; | 2774 | dev = &sh->dev[i]; |
2775 | if (!test_bit(R5_LOCKED, &dev->flags) && | 2775 | if (!test_bit(R5_LOCKED, &dev->flags) && |
2776 | (test_bit(R5_UPTODATE, &dev->flags) || | 2776 | (test_bit(R5_UPTODATE, &dev->flags) || |
2777 | test_and_clear_bit(R5_Discard, &dev->flags))) { | 2777 | test_bit(R5_Discard, &dev->flags))) { |
2778 | /* We can return any write requests */ | 2778 | /* We can return any write requests */ |
2779 | struct bio *wbi, *wbi2; | 2779 | struct bio *wbi, *wbi2; |
2780 | pr_debug("Return write for disc %d\n", i); | 2780 | pr_debug("Return write for disc %d\n", i); |
2781 | if (test_and_clear_bit(R5_Discard, &dev->flags)) | ||
2782 | clear_bit(R5_UPTODATE, &dev->flags); | ||
2781 | wbi = dev->written; | 2783 | wbi = dev->written; |
2782 | dev->written = NULL; | 2784 | dev->written = NULL; |
2783 | while (wbi && wbi->bi_sector < | 2785 | while (wbi && wbi->bi_sector < |
@@ -2795,7 +2797,8 @@ static void handle_stripe_clean_event(struct r5conf *conf, | |||
2795 | !test_bit(STRIPE_DEGRADED, &sh->state), | 2797 | !test_bit(STRIPE_DEGRADED, &sh->state), |
2796 | 0); | 2798 | 0); |
2797 | } | 2799 | } |
2798 | } | 2800 | } else if (test_bit(R5_Discard, &sh->dev[i].flags)) |
2801 | clear_bit(R5_Discard, &sh->dev[i].flags); | ||
2799 | 2802 | ||
2800 | if (test_and_clear_bit(STRIPE_FULL_WRITE, &sh->state)) | 2803 | if (test_and_clear_bit(STRIPE_FULL_WRITE, &sh->state)) |
2801 | if (atomic_dec_and_test(&conf->pending_full_writes)) | 2804 | if (atomic_dec_and_test(&conf->pending_full_writes)) |
@@ -3490,40 +3493,6 @@ static void handle_stripe(struct stripe_head *sh) | |||
3490 | handle_failed_sync(conf, sh, &s); | 3493 | handle_failed_sync(conf, sh, &s); |
3491 | } | 3494 | } |
3492 | 3495 | ||
3493 | /* | ||
3494 | * might be able to return some write requests if the parity blocks | ||
3495 | * are safe, or on a failed drive | ||
3496 | */ | ||
3497 | pdev = &sh->dev[sh->pd_idx]; | ||
3498 | s.p_failed = (s.failed >= 1 && s.failed_num[0] == sh->pd_idx) | ||
3499 | || (s.failed >= 2 && s.failed_num[1] == sh->pd_idx); | ||
3500 | qdev = &sh->dev[sh->qd_idx]; | ||
3501 | s.q_failed = (s.failed >= 1 && s.failed_num[0] == sh->qd_idx) | ||
3502 | || (s.failed >= 2 && s.failed_num[1] == sh->qd_idx) | ||
3503 | || conf->level < 6; | ||
3504 | |||
3505 | if (s.written && | ||
3506 | (s.p_failed || ((test_bit(R5_Insync, &pdev->flags) | ||
3507 | && !test_bit(R5_LOCKED, &pdev->flags) | ||
3508 | && (test_bit(R5_UPTODATE, &pdev->flags) || | ||
3509 | test_bit(R5_Discard, &pdev->flags))))) && | ||
3510 | (s.q_failed || ((test_bit(R5_Insync, &qdev->flags) | ||
3511 | && !test_bit(R5_LOCKED, &qdev->flags) | ||
3512 | && (test_bit(R5_UPTODATE, &qdev->flags) || | ||
3513 | test_bit(R5_Discard, &qdev->flags)))))) | ||
3514 | handle_stripe_clean_event(conf, sh, disks, &s.return_bi); | ||
3515 | |||
3516 | /* Now we might consider reading some blocks, either to check/generate | ||
3517 | * parity, or to satisfy requests | ||
3518 | * or to load a block that is being partially written. | ||
3519 | */ | ||
3520 | if (s.to_read || s.non_overwrite | ||
3521 | || (conf->level == 6 && s.to_write && s.failed) | ||
3522 | || (s.syncing && (s.uptodate + s.compute < disks)) | ||
3523 | || s.replacing | ||
3524 | || s.expanding) | ||
3525 | handle_stripe_fill(sh, &s, disks); | ||
3526 | |||
3527 | /* Now we check to see if any write operations have recently | 3496 | /* Now we check to see if any write operations have recently |
3528 | * completed | 3497 | * completed |
3529 | */ | 3498 | */ |
@@ -3561,6 +3530,40 @@ static void handle_stripe(struct stripe_head *sh) | |||
3561 | s.dec_preread_active = 1; | 3530 | s.dec_preread_active = 1; |
3562 | } | 3531 | } |
3563 | 3532 | ||
3533 | /* | ||
3534 | * might be able to return some write requests if the parity blocks | ||
3535 | * are safe, or on a failed drive | ||
3536 | */ | ||
3537 | pdev = &sh->dev[sh->pd_idx]; | ||
3538 | s.p_failed = (s.failed >= 1 && s.failed_num[0] == sh->pd_idx) | ||
3539 | || (s.failed >= 2 && s.failed_num[1] == sh->pd_idx); | ||
3540 | qdev = &sh->dev[sh->qd_idx]; | ||
3541 | s.q_failed = (s.failed >= 1 && s.failed_num[0] == sh->qd_idx) | ||
3542 | || (s.failed >= 2 && s.failed_num[1] == sh->qd_idx) | ||
3543 | || conf->level < 6; | ||
3544 | |||
3545 | if (s.written && | ||
3546 | (s.p_failed || ((test_bit(R5_Insync, &pdev->flags) | ||
3547 | && !test_bit(R5_LOCKED, &pdev->flags) | ||
3548 | && (test_bit(R5_UPTODATE, &pdev->flags) || | ||
3549 | test_bit(R5_Discard, &pdev->flags))))) && | ||
3550 | (s.q_failed || ((test_bit(R5_Insync, &qdev->flags) | ||
3551 | && !test_bit(R5_LOCKED, &qdev->flags) | ||
3552 | && (test_bit(R5_UPTODATE, &qdev->flags) || | ||
3553 | test_bit(R5_Discard, &qdev->flags)))))) | ||
3554 | handle_stripe_clean_event(conf, sh, disks, &s.return_bi); | ||
3555 | |||
3556 | /* Now we might consider reading some blocks, either to check/generate | ||
3557 | * parity, or to satisfy requests | ||
3558 | * or to load a block that is being partially written. | ||
3559 | */ | ||
3560 | if (s.to_read || s.non_overwrite | ||
3561 | || (conf->level == 6 && s.to_write && s.failed) | ||
3562 | || (s.syncing && (s.uptodate + s.compute < disks)) | ||
3563 | || s.replacing | ||
3564 | || s.expanding) | ||
3565 | handle_stripe_fill(sh, &s, disks); | ||
3566 | |||
3564 | /* Now to consider new write requests and what else, if anything | 3567 | /* Now to consider new write requests and what else, if anything |
3565 | * should be read. We do not handle new writes when: | 3568 | * should be read. We do not handle new writes when: |
3566 | * 1/ A 'write' operation (copy+xor) is already in flight. | 3569 | * 1/ A 'write' operation (copy+xor) is already in flight. |
@@ -5529,6 +5532,10 @@ static int run(struct mddev *mddev) | |||
5529 | * discard data disk but write parity disk | 5532 | * discard data disk but write parity disk |
5530 | */ | 5533 | */ |
5531 | stripe = stripe * PAGE_SIZE; | 5534 | stripe = stripe * PAGE_SIZE; |
5535 | /* Round up to power of 2, as discard handling | ||
5536 | * currently assumes that */ | ||
5537 | while ((stripe-1) & stripe) | ||
5538 | stripe = (stripe | (stripe-1)) + 1; | ||
5532 | mddev->queue->limits.discard_alignment = stripe; | 5539 | mddev->queue->limits.discard_alignment = stripe; |
5533 | mddev->queue->limits.discard_granularity = stripe; | 5540 | mddev->queue->limits.discard_granularity = stripe; |
5534 | /* | 5541 | /* |
diff --git a/drivers/media/dvb-frontends/stv0900_core.c b/drivers/media/dvb-frontends/stv0900_core.c index 262dfa503c2a..b551ca350e00 100644 --- a/drivers/media/dvb-frontends/stv0900_core.c +++ b/drivers/media/dvb-frontends/stv0900_core.c | |||
@@ -300,15 +300,15 @@ static enum fe_stv0900_error stv0900_set_mclk(struct stv0900_internal *intp, u32 | |||
300 | { | 300 | { |
301 | u32 m_div, clk_sel; | 301 | u32 m_div, clk_sel; |
302 | 302 | ||
303 | dprintk("%s: Mclk set to %d, Quartz = %d\n", __func__, mclk, | ||
304 | intp->quartz); | ||
305 | |||
306 | if (intp == NULL) | 303 | if (intp == NULL) |
307 | return STV0900_INVALID_HANDLE; | 304 | return STV0900_INVALID_HANDLE; |
308 | 305 | ||
309 | if (intp->errs) | 306 | if (intp->errs) |
310 | return STV0900_I2C_ERROR; | 307 | return STV0900_I2C_ERROR; |
311 | 308 | ||
309 | dprintk("%s: Mclk set to %d, Quartz = %d\n", __func__, mclk, | ||
310 | intp->quartz); | ||
311 | |||
312 | clk_sel = ((stv0900_get_bits(intp, F0900_SELX1RATIO) == 1) ? 4 : 6); | 312 | clk_sel = ((stv0900_get_bits(intp, F0900_SELX1RATIO) == 1) ? 4 : 6); |
313 | m_div = ((clk_sel * mclk) / intp->quartz) - 1; | 313 | m_div = ((clk_sel * mclk) / intp->quartz) - 1; |
314 | stv0900_write_bits(intp, F0900_M_DIV, m_div); | 314 | stv0900_write_bits(intp, F0900_M_DIV, m_div); |
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 109bc9b12e74..05f8950f6f91 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c | |||
@@ -53,8 +53,7 @@ MODULE_LICENSE("GPL"); | |||
53 | /* ADV7604 system clock frequency */ | 53 | /* ADV7604 system clock frequency */ |
54 | #define ADV7604_fsc (28636360) | 54 | #define ADV7604_fsc (28636360) |
55 | 55 | ||
56 | #define DIGITAL_INPUT ((state->prim_mode == ADV7604_PRIM_MODE_HDMI_COMP) || \ | 56 | #define DIGITAL_INPUT (state->mode == ADV7604_MODE_HDMI) |
57 | (state->prim_mode == ADV7604_PRIM_MODE_HDMI_GR)) | ||
58 | 57 | ||
59 | /* | 58 | /* |
60 | ********************************************************************** | 59 | ********************************************************************** |
@@ -68,7 +67,7 @@ struct adv7604_state { | |||
68 | struct v4l2_subdev sd; | 67 | struct v4l2_subdev sd; |
69 | struct media_pad pad; | 68 | struct media_pad pad; |
70 | struct v4l2_ctrl_handler hdl; | 69 | struct v4l2_ctrl_handler hdl; |
71 | enum adv7604_prim_mode prim_mode; | 70 | enum adv7604_mode mode; |
72 | struct v4l2_dv_timings timings; | 71 | struct v4l2_dv_timings timings; |
73 | u8 edid[256]; | 72 | u8 edid[256]; |
74 | unsigned edid_blocks; | 73 | unsigned edid_blocks; |
@@ -77,6 +76,7 @@ struct adv7604_state { | |||
77 | struct workqueue_struct *work_queues; | 76 | struct workqueue_struct *work_queues; |
78 | struct delayed_work delayed_work_enable_hotplug; | 77 | struct delayed_work delayed_work_enable_hotplug; |
79 | bool connector_hdmi; | 78 | bool connector_hdmi; |
79 | bool restart_stdi_once; | ||
80 | 80 | ||
81 | /* i2c clients */ | 81 | /* i2c clients */ |
82 | struct i2c_client *i2c_avlink; | 82 | struct i2c_client *i2c_avlink; |
@@ -106,7 +106,6 @@ static const struct v4l2_dv_timings adv7604_timings[] = { | |||
106 | V4L2_DV_BT_CEA_720X576P50, | 106 | V4L2_DV_BT_CEA_720X576P50, |
107 | V4L2_DV_BT_CEA_1280X720P24, | 107 | V4L2_DV_BT_CEA_1280X720P24, |
108 | V4L2_DV_BT_CEA_1280X720P25, | 108 | V4L2_DV_BT_CEA_1280X720P25, |
109 | V4L2_DV_BT_CEA_1280X720P30, | ||
110 | V4L2_DV_BT_CEA_1280X720P50, | 109 | V4L2_DV_BT_CEA_1280X720P50, |
111 | V4L2_DV_BT_CEA_1280X720P60, | 110 | V4L2_DV_BT_CEA_1280X720P60, |
112 | V4L2_DV_BT_CEA_1920X1080P24, | 111 | V4L2_DV_BT_CEA_1920X1080P24, |
@@ -115,6 +114,7 @@ static const struct v4l2_dv_timings adv7604_timings[] = { | |||
115 | V4L2_DV_BT_CEA_1920X1080P50, | 114 | V4L2_DV_BT_CEA_1920X1080P50, |
116 | V4L2_DV_BT_CEA_1920X1080P60, | 115 | V4L2_DV_BT_CEA_1920X1080P60, |
117 | 116 | ||
117 | /* sorted by DMT ID */ | ||
118 | V4L2_DV_BT_DMT_640X350P85, | 118 | V4L2_DV_BT_DMT_640X350P85, |
119 | V4L2_DV_BT_DMT_640X400P85, | 119 | V4L2_DV_BT_DMT_640X400P85, |
120 | V4L2_DV_BT_DMT_720X400P85, | 120 | V4L2_DV_BT_DMT_720X400P85, |
@@ -164,6 +164,89 @@ static const struct v4l2_dv_timings adv7604_timings[] = { | |||
164 | { }, | 164 | { }, |
165 | }; | 165 | }; |
166 | 166 | ||
167 | struct adv7604_video_standards { | ||
168 | struct v4l2_dv_timings timings; | ||
169 | u8 vid_std; | ||
170 | u8 v_freq; | ||
171 | }; | ||
172 | |||
173 | /* sorted by number of lines */ | ||
174 | static const struct adv7604_video_standards adv7604_prim_mode_comp[] = { | ||
175 | /* { V4L2_DV_BT_CEA_720X480P59_94, 0x0a, 0x00 }, TODO flickering */ | ||
176 | { V4L2_DV_BT_CEA_720X576P50, 0x0b, 0x00 }, | ||
177 | { V4L2_DV_BT_CEA_1280X720P50, 0x19, 0x01 }, | ||
178 | { V4L2_DV_BT_CEA_1280X720P60, 0x19, 0x00 }, | ||
179 | { V4L2_DV_BT_CEA_1920X1080P24, 0x1e, 0x04 }, | ||
180 | { V4L2_DV_BT_CEA_1920X1080P25, 0x1e, 0x03 }, | ||
181 | { V4L2_DV_BT_CEA_1920X1080P30, 0x1e, 0x02 }, | ||
182 | { V4L2_DV_BT_CEA_1920X1080P50, 0x1e, 0x01 }, | ||
183 | { V4L2_DV_BT_CEA_1920X1080P60, 0x1e, 0x00 }, | ||
184 | /* TODO add 1920x1080P60_RB (CVT timing) */ | ||
185 | { }, | ||
186 | }; | ||
187 | |||
188 | /* sorted by number of lines */ | ||
189 | static const struct adv7604_video_standards adv7604_prim_mode_gr[] = { | ||
190 | { V4L2_DV_BT_DMT_640X480P60, 0x08, 0x00 }, | ||
191 | { V4L2_DV_BT_DMT_640X480P72, 0x09, 0x00 }, | ||
192 | { V4L2_DV_BT_DMT_640X480P75, 0x0a, 0x00 }, | ||
193 | { V4L2_DV_BT_DMT_640X480P85, 0x0b, 0x00 }, | ||
194 | { V4L2_DV_BT_DMT_800X600P56, 0x00, 0x00 }, | ||
195 | { V4L2_DV_BT_DMT_800X600P60, 0x01, 0x00 }, | ||
196 | { V4L2_DV_BT_DMT_800X600P72, 0x02, 0x00 }, | ||
197 | { V4L2_DV_BT_DMT_800X600P75, 0x03, 0x00 }, | ||
198 | { V4L2_DV_BT_DMT_800X600P85, 0x04, 0x00 }, | ||
199 | { V4L2_DV_BT_DMT_1024X768P60, 0x0c, 0x00 }, | ||
200 | { V4L2_DV_BT_DMT_1024X768P70, 0x0d, 0x00 }, | ||
201 | { V4L2_DV_BT_DMT_1024X768P75, 0x0e, 0x00 }, | ||
202 | { V4L2_DV_BT_DMT_1024X768P85, 0x0f, 0x00 }, | ||
203 | { V4L2_DV_BT_DMT_1280X1024P60, 0x05, 0x00 }, | ||
204 | { V4L2_DV_BT_DMT_1280X1024P75, 0x06, 0x00 }, | ||
205 | { V4L2_DV_BT_DMT_1360X768P60, 0x12, 0x00 }, | ||
206 | { V4L2_DV_BT_DMT_1366X768P60, 0x13, 0x00 }, | ||
207 | { V4L2_DV_BT_DMT_1400X1050P60, 0x14, 0x00 }, | ||
208 | { V4L2_DV_BT_DMT_1400X1050P75, 0x15, 0x00 }, | ||
209 | { V4L2_DV_BT_DMT_1600X1200P60, 0x16, 0x00 }, /* TODO not tested */ | ||
210 | /* TODO add 1600X1200P60_RB (not a DMT timing) */ | ||
211 | { V4L2_DV_BT_DMT_1680X1050P60, 0x18, 0x00 }, | ||
212 | { V4L2_DV_BT_DMT_1920X1200P60_RB, 0x19, 0x00 }, /* TODO not tested */ | ||
213 | { }, | ||
214 | }; | ||
215 | |||
216 | /* sorted by number of lines */ | ||
217 | static const struct adv7604_video_standards adv7604_prim_mode_hdmi_comp[] = { | ||
218 | { V4L2_DV_BT_CEA_720X480P59_94, 0x0a, 0x00 }, | ||
219 | { V4L2_DV_BT_CEA_720X576P50, 0x0b, 0x00 }, | ||
220 | { V4L2_DV_BT_CEA_1280X720P50, 0x13, 0x01 }, | ||
221 | { V4L2_DV_BT_CEA_1280X720P60, 0x13, 0x00 }, | ||
222 | { V4L2_DV_BT_CEA_1920X1080P24, 0x1e, 0x04 }, | ||
223 | { V4L2_DV_BT_CEA_1920X1080P25, 0x1e, 0x03 }, | ||
224 | { V4L2_DV_BT_CEA_1920X1080P30, 0x1e, 0x02 }, | ||
225 | { V4L2_DV_BT_CEA_1920X1080P50, 0x1e, 0x01 }, | ||
226 | { V4L2_DV_BT_CEA_1920X1080P60, 0x1e, 0x00 }, | ||
227 | { }, | ||
228 | }; | ||
229 | |||
230 | /* sorted by number of lines */ | ||
231 | static const struct adv7604_video_standards adv7604_prim_mode_hdmi_gr[] = { | ||
232 | { V4L2_DV_BT_DMT_640X480P60, 0x08, 0x00 }, | ||
233 | { V4L2_DV_BT_DMT_640X480P72, 0x09, 0x00 }, | ||
234 | { V4L2_DV_BT_DMT_640X480P75, 0x0a, 0x00 }, | ||
235 | { V4L2_DV_BT_DMT_640X480P85, 0x0b, 0x00 }, | ||
236 | { V4L2_DV_BT_DMT_800X600P56, 0x00, 0x00 }, | ||
237 | { V4L2_DV_BT_DMT_800X600P60, 0x01, 0x00 }, | ||
238 | { V4L2_DV_BT_DMT_800X600P72, 0x02, 0x00 }, | ||
239 | { V4L2_DV_BT_DMT_800X600P75, 0x03, 0x00 }, | ||
240 | { V4L2_DV_BT_DMT_800X600P85, 0x04, 0x00 }, | ||
241 | { V4L2_DV_BT_DMT_1024X768P60, 0x0c, 0x00 }, | ||
242 | { V4L2_DV_BT_DMT_1024X768P70, 0x0d, 0x00 }, | ||
243 | { V4L2_DV_BT_DMT_1024X768P75, 0x0e, 0x00 }, | ||
244 | { V4L2_DV_BT_DMT_1024X768P85, 0x0f, 0x00 }, | ||
245 | { V4L2_DV_BT_DMT_1280X1024P60, 0x05, 0x00 }, | ||
246 | { V4L2_DV_BT_DMT_1280X1024P75, 0x06, 0x00 }, | ||
247 | { }, | ||
248 | }; | ||
249 | |||
167 | /* ----------------------------------------------------------------------- */ | 250 | /* ----------------------------------------------------------------------- */ |
168 | 251 | ||
169 | static inline struct adv7604_state *to_state(struct v4l2_subdev *sd) | 252 | static inline struct adv7604_state *to_state(struct v4l2_subdev *sd) |
@@ -672,64 +755,144 @@ static int adv7604_s_detect_tx_5v_ctrl(struct v4l2_subdev *sd) | |||
672 | ((io_read(sd, 0x6f) & 0x10) >> 4)); | 755 | ((io_read(sd, 0x6f) & 0x10) >> 4)); |
673 | } | 756 | } |
674 | 757 | ||
675 | static void configure_free_run(struct v4l2_subdev *sd, const struct v4l2_bt_timings *timings) | 758 | static int find_and_set_predefined_video_timings(struct v4l2_subdev *sd, |
759 | u8 prim_mode, | ||
760 | const struct adv7604_video_standards *predef_vid_timings, | ||
761 | const struct v4l2_dv_timings *timings) | ||
762 | { | ||
763 | struct adv7604_state *state = to_state(sd); | ||
764 | int i; | ||
765 | |||
766 | for (i = 0; predef_vid_timings[i].timings.bt.width; i++) { | ||
767 | if (!v4l_match_dv_timings(timings, &predef_vid_timings[i].timings, | ||
768 | DIGITAL_INPUT ? 250000 : 1000000)) | ||
769 | continue; | ||
770 | io_write(sd, 0x00, predef_vid_timings[i].vid_std); /* video std */ | ||
771 | io_write(sd, 0x01, (predef_vid_timings[i].v_freq << 4) + | ||
772 | prim_mode); /* v_freq and prim mode */ | ||
773 | return 0; | ||
774 | } | ||
775 | |||
776 | return -1; | ||
777 | } | ||
778 | |||
779 | static int configure_predefined_video_timings(struct v4l2_subdev *sd, | ||
780 | struct v4l2_dv_timings *timings) | ||
676 | { | 781 | { |
782 | struct adv7604_state *state = to_state(sd); | ||
783 | int err; | ||
784 | |||
785 | v4l2_dbg(1, debug, sd, "%s", __func__); | ||
786 | |||
787 | /* reset to default values */ | ||
788 | io_write(sd, 0x16, 0x43); | ||
789 | io_write(sd, 0x17, 0x5a); | ||
790 | /* disable embedded syncs for auto graphics mode */ | ||
791 | cp_write_and_or(sd, 0x81, 0xef, 0x00); | ||
792 | cp_write(sd, 0x8f, 0x00); | ||
793 | cp_write(sd, 0x90, 0x00); | ||
794 | cp_write(sd, 0xa2, 0x00); | ||
795 | cp_write(sd, 0xa3, 0x00); | ||
796 | cp_write(sd, 0xa4, 0x00); | ||
797 | cp_write(sd, 0xa5, 0x00); | ||
798 | cp_write(sd, 0xa6, 0x00); | ||
799 | cp_write(sd, 0xa7, 0x00); | ||
800 | cp_write(sd, 0xab, 0x00); | ||
801 | cp_write(sd, 0xac, 0x00); | ||
802 | |||
803 | switch (state->mode) { | ||
804 | case ADV7604_MODE_COMP: | ||
805 | case ADV7604_MODE_GR: | ||
806 | err = find_and_set_predefined_video_timings(sd, | ||
807 | 0x01, adv7604_prim_mode_comp, timings); | ||
808 | if (err) | ||
809 | err = find_and_set_predefined_video_timings(sd, | ||
810 | 0x02, adv7604_prim_mode_gr, timings); | ||
811 | break; | ||
812 | case ADV7604_MODE_HDMI: | ||
813 | err = find_and_set_predefined_video_timings(sd, | ||
814 | 0x05, adv7604_prim_mode_hdmi_comp, timings); | ||
815 | if (err) | ||
816 | err = find_and_set_predefined_video_timings(sd, | ||
817 | 0x06, adv7604_prim_mode_hdmi_gr, timings); | ||
818 | break; | ||
819 | default: | ||
820 | v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n", | ||
821 | __func__, state->mode); | ||
822 | err = -1; | ||
823 | break; | ||
824 | } | ||
825 | |||
826 | |||
827 | return err; | ||
828 | } | ||
829 | |||
830 | static void configure_custom_video_timings(struct v4l2_subdev *sd, | ||
831 | const struct v4l2_bt_timings *bt) | ||
832 | { | ||
833 | struct adv7604_state *state = to_state(sd); | ||
677 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 834 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
678 | u32 width = htotal(timings); | 835 | u32 width = htotal(bt); |
679 | u32 height = vtotal(timings); | 836 | u32 height = vtotal(bt); |
680 | u16 ch1_fr_ll = (((u32)timings->pixelclock / 100) > 0) ? | 837 | u16 cp_start_sav = bt->hsync + bt->hbackporch - 4; |
681 | ((width * (ADV7604_fsc / 100)) / ((u32)timings->pixelclock / 100)) : 0; | 838 | u16 cp_start_eav = width - bt->hfrontporch; |
839 | u16 cp_start_vbi = height - bt->vfrontporch; | ||
840 | u16 cp_end_vbi = bt->vsync + bt->vbackporch; | ||
841 | u16 ch1_fr_ll = (((u32)bt->pixelclock / 100) > 0) ? | ||
842 | ((width * (ADV7604_fsc / 100)) / ((u32)bt->pixelclock / 100)) : 0; | ||
843 | const u8 pll[2] = { | ||
844 | 0xc0 | ((width >> 8) & 0x1f), | ||
845 | width & 0xff | ||
846 | }; | ||
682 | 847 | ||
683 | v4l2_dbg(2, debug, sd, "%s\n", __func__); | 848 | v4l2_dbg(2, debug, sd, "%s\n", __func__); |
684 | 849 | ||
685 | cp_write(sd, 0x8f, (ch1_fr_ll >> 8) & 0x7); /* CH1_FR_LL */ | 850 | switch (state->mode) { |
686 | cp_write(sd, 0x90, ch1_fr_ll & 0xff); /* CH1_FR_LL */ | 851 | case ADV7604_MODE_COMP: |
687 | cp_write(sd, 0xab, (height >> 4) & 0xff); /* CP_LCOUNT_MAX */ | 852 | case ADV7604_MODE_GR: |
688 | cp_write(sd, 0xac, (height & 0x0f) << 4); /* CP_LCOUNT_MAX */ | 853 | /* auto graphics */ |
689 | /* TODO support interlaced */ | 854 | io_write(sd, 0x00, 0x07); /* video std */ |
690 | cp_write(sd, 0x91, 0x10); /* INTERLACED */ | 855 | io_write(sd, 0x01, 0x02); /* prim mode */ |
691 | 856 | /* enable embedded syncs for auto graphics mode */ | |
692 | /* Should only be set in auto-graphics mode [REF_02 p. 91-92] */ | 857 | cp_write_and_or(sd, 0x81, 0xef, 0x10); |
693 | if ((io_read(sd, 0x00) == 0x07) && (io_read(sd, 0x01) == 0x02)) { | ||
694 | u16 cp_start_sav, cp_start_eav, cp_start_vbi, cp_end_vbi; | ||
695 | const u8 pll[2] = { | ||
696 | (0xc0 | ((width >> 8) & 0x1f)), | ||
697 | (width & 0xff) | ||
698 | }; | ||
699 | 858 | ||
859 | /* Should only be set in auto-graphics mode [REF_02, p. 91-92] */ | ||
700 | /* setup PLL_DIV_MAN_EN and PLL_DIV_RATIO */ | 860 | /* setup PLL_DIV_MAN_EN and PLL_DIV_RATIO */ |
701 | /* IO-map reg. 0x16 and 0x17 should be written in sequence */ | 861 | /* IO-map reg. 0x16 and 0x17 should be written in sequence */ |
702 | if (adv_smbus_write_i2c_block_data(client, 0x16, 2, pll)) { | 862 | if (adv_smbus_write_i2c_block_data(client, 0x16, 2, pll)) { |
703 | v4l2_err(sd, "writing to reg 0x16 and 0x17 failed\n"); | 863 | v4l2_err(sd, "writing to reg 0x16 and 0x17 failed\n"); |
704 | return; | 864 | break; |
705 | } | 865 | } |
706 | 866 | ||
707 | /* active video - horizontal timing */ | 867 | /* active video - horizontal timing */ |
708 | cp_start_sav = timings->hsync + timings->hbackporch - 4; | ||
709 | cp_start_eav = width - timings->hfrontporch; | ||
710 | cp_write(sd, 0xa2, (cp_start_sav >> 4) & 0xff); | 868 | cp_write(sd, 0xa2, (cp_start_sav >> 4) & 0xff); |
711 | cp_write(sd, 0xa3, ((cp_start_sav & 0x0f) << 4) | ((cp_start_eav >> 8) & 0x0f)); | 869 | cp_write(sd, 0xa3, ((cp_start_sav & 0x0f) << 4) | |
870 | ((cp_start_eav >> 8) & 0x0f)); | ||
712 | cp_write(sd, 0xa4, cp_start_eav & 0xff); | 871 | cp_write(sd, 0xa4, cp_start_eav & 0xff); |
713 | 872 | ||
714 | /* active video - vertical timing */ | 873 | /* active video - vertical timing */ |
715 | cp_start_vbi = height - timings->vfrontporch; | ||
716 | cp_end_vbi = timings->vsync + timings->vbackporch; | ||
717 | cp_write(sd, 0xa5, (cp_start_vbi >> 4) & 0xff); | 874 | cp_write(sd, 0xa5, (cp_start_vbi >> 4) & 0xff); |
718 | cp_write(sd, 0xa6, ((cp_start_vbi & 0xf) << 4) | ((cp_end_vbi >> 8) & 0xf)); | 875 | cp_write(sd, 0xa6, ((cp_start_vbi & 0xf) << 4) | |
876 | ((cp_end_vbi >> 8) & 0xf)); | ||
719 | cp_write(sd, 0xa7, cp_end_vbi & 0xff); | 877 | cp_write(sd, 0xa7, cp_end_vbi & 0xff); |
720 | } else { | 878 | break; |
721 | /* reset to default values */ | 879 | case ADV7604_MODE_HDMI: |
722 | io_write(sd, 0x16, 0x43); | 880 | /* set default prim_mode/vid_std for HDMI |
723 | io_write(sd, 0x17, 0x5a); | 881 | accoring to [REF_03, c. 4.2] */ |
724 | cp_write(sd, 0xa2, 0x00); | 882 | io_write(sd, 0x00, 0x02); /* video std */ |
725 | cp_write(sd, 0xa3, 0x00); | 883 | io_write(sd, 0x01, 0x06); /* prim mode */ |
726 | cp_write(sd, 0xa4, 0x00); | 884 | break; |
727 | cp_write(sd, 0xa5, 0x00); | 885 | default: |
728 | cp_write(sd, 0xa6, 0x00); | 886 | v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n", |
729 | cp_write(sd, 0xa7, 0x00); | 887 | __func__, state->mode); |
888 | break; | ||
730 | } | 889 | } |
731 | } | ||
732 | 890 | ||
891 | cp_write(sd, 0x8f, (ch1_fr_ll >> 8) & 0x7); | ||
892 | cp_write(sd, 0x90, ch1_fr_ll & 0xff); | ||
893 | cp_write(sd, 0xab, (height >> 4) & 0xff); | ||
894 | cp_write(sd, 0xac, (height & 0x0f) << 4); | ||
895 | } | ||
733 | 896 | ||
734 | static void set_rgb_quantization_range(struct v4l2_subdev *sd) | 897 | static void set_rgb_quantization_range(struct v4l2_subdev *sd) |
735 | { | 898 | { |
@@ -738,12 +901,7 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd) | |||
738 | switch (state->rgb_quantization_range) { | 901 | switch (state->rgb_quantization_range) { |
739 | case V4L2_DV_RGB_RANGE_AUTO: | 902 | case V4L2_DV_RGB_RANGE_AUTO: |
740 | /* automatic */ | 903 | /* automatic */ |
741 | if ((hdmi_read(sd, 0x05) & 0x80) || | 904 | if (DIGITAL_INPUT && !(hdmi_read(sd, 0x05) & 0x80)) { |
742 | (state->prim_mode == ADV7604_PRIM_MODE_COMP) || | ||
743 | (state->prim_mode == ADV7604_PRIM_MODE_RGB)) { | ||
744 | /* receiving HDMI or analog signal */ | ||
745 | io_write_and_or(sd, 0x02, 0x0f, 0xf0); | ||
746 | } else { | ||
747 | /* receiving DVI-D signal */ | 905 | /* receiving DVI-D signal */ |
748 | 906 | ||
749 | /* ADV7604 selects RGB limited range regardless of | 907 | /* ADV7604 selects RGB limited range regardless of |
@@ -756,6 +914,9 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd) | |||
756 | /* RGB full range (0-255) */ | 914 | /* RGB full range (0-255) */ |
757 | io_write_and_or(sd, 0x02, 0x0f, 0x10); | 915 | io_write_and_or(sd, 0x02, 0x0f, 0x10); |
758 | } | 916 | } |
917 | } else { | ||
918 | /* receiving HDMI or analog signal, set automode */ | ||
919 | io_write_and_or(sd, 0x02, 0x0f, 0xf0); | ||
759 | } | 920 | } |
760 | break; | 921 | break; |
761 | case V4L2_DV_RGB_RANGE_LIMITED: | 922 | case V4L2_DV_RGB_RANGE_LIMITED: |
@@ -967,8 +1128,10 @@ static int stdi2dv_timings(struct v4l2_subdev *sd, | |||
967 | state->aspect_ratio, timings)) | 1128 | state->aspect_ratio, timings)) |
968 | return 0; | 1129 | return 0; |
969 | 1130 | ||
970 | v4l2_dbg(2, debug, sd, "%s: No format candidate found for lcf=%d, bl = %d\n", | 1131 | v4l2_dbg(2, debug, sd, |
971 | __func__, stdi->lcf, stdi->bl); | 1132 | "%s: No format candidate found for lcvs = %d, lcf=%d, bl = %d, %chsync, %cvsync\n", |
1133 | __func__, stdi->lcvs, stdi->lcf, stdi->bl, | ||
1134 | stdi->hs_pol, stdi->vs_pol); | ||
972 | return -1; | 1135 | return -1; |
973 | } | 1136 | } |
974 | 1137 | ||
@@ -1123,7 +1286,7 @@ static int adv7604_query_dv_timings(struct v4l2_subdev *sd, | |||
1123 | adv7604_fill_optional_dv_timings_fields(sd, timings); | 1286 | adv7604_fill_optional_dv_timings_fields(sd, timings); |
1124 | } else { | 1287 | } else { |
1125 | /* find format | 1288 | /* find format |
1126 | * Since LCVS values are inaccurate (REF_03, page 275-276), | 1289 | * Since LCVS values are inaccurate [REF_03, p. 275-276], |
1127 | * stdi2dv_timings() is called with lcvs +-1 if the first attempt fails. | 1290 | * stdi2dv_timings() is called with lcvs +-1 if the first attempt fails. |
1128 | */ | 1291 | */ |
1129 | if (!stdi2dv_timings(sd, &stdi, timings)) | 1292 | if (!stdi2dv_timings(sd, &stdi, timings)) |
@@ -1135,9 +1298,31 @@ static int adv7604_query_dv_timings(struct v4l2_subdev *sd, | |||
1135 | stdi.lcvs -= 2; | 1298 | stdi.lcvs -= 2; |
1136 | v4l2_dbg(1, debug, sd, "%s: lcvs - 1 = %d\n", __func__, stdi.lcvs); | 1299 | v4l2_dbg(1, debug, sd, "%s: lcvs - 1 = %d\n", __func__, stdi.lcvs); |
1137 | if (stdi2dv_timings(sd, &stdi, timings)) { | 1300 | if (stdi2dv_timings(sd, &stdi, timings)) { |
1301 | /* | ||
1302 | * The STDI block may measure wrong values, especially | ||
1303 | * for lcvs and lcf. If the driver can not find any | ||
1304 | * valid timing, the STDI block is restarted to measure | ||
1305 | * the video timings again. The function will return an | ||
1306 | * error, but the restart of STDI will generate a new | ||
1307 | * STDI interrupt and the format detection process will | ||
1308 | * restart. | ||
1309 | */ | ||
1310 | if (state->restart_stdi_once) { | ||
1311 | v4l2_dbg(1, debug, sd, "%s: restart STDI\n", __func__); | ||
1312 | /* TODO restart STDI for Sync Channel 2 */ | ||
1313 | /* enter one-shot mode */ | ||
1314 | cp_write_and_or(sd, 0x86, 0xf9, 0x00); | ||
1315 | /* trigger STDI restart */ | ||
1316 | cp_write_and_or(sd, 0x86, 0xf9, 0x04); | ||
1317 | /* reset to continuous mode */ | ||
1318 | cp_write_and_or(sd, 0x86, 0xf9, 0x02); | ||
1319 | state->restart_stdi_once = false; | ||
1320 | return -ENOLINK; | ||
1321 | } | ||
1138 | v4l2_dbg(1, debug, sd, "%s: format not supported\n", __func__); | 1322 | v4l2_dbg(1, debug, sd, "%s: format not supported\n", __func__); |
1139 | return -ERANGE; | 1323 | return -ERANGE; |
1140 | } | 1324 | } |
1325 | state->restart_stdi_once = true; | ||
1141 | } | 1326 | } |
1142 | found: | 1327 | found: |
1143 | 1328 | ||
@@ -1166,6 +1351,7 @@ static int adv7604_s_dv_timings(struct v4l2_subdev *sd, | |||
1166 | { | 1351 | { |
1167 | struct adv7604_state *state = to_state(sd); | 1352 | struct adv7604_state *state = to_state(sd); |
1168 | struct v4l2_bt_timings *bt; | 1353 | struct v4l2_bt_timings *bt; |
1354 | int err; | ||
1169 | 1355 | ||
1170 | if (!timings) | 1356 | if (!timings) |
1171 | return -EINVAL; | 1357 | return -EINVAL; |
@@ -1178,12 +1364,20 @@ static int adv7604_s_dv_timings(struct v4l2_subdev *sd, | |||
1178 | __func__, (u32)bt->pixelclock); | 1364 | __func__, (u32)bt->pixelclock); |
1179 | return -ERANGE; | 1365 | return -ERANGE; |
1180 | } | 1366 | } |
1367 | |||
1181 | adv7604_fill_optional_dv_timings_fields(sd, timings); | 1368 | adv7604_fill_optional_dv_timings_fields(sd, timings); |
1182 | 1369 | ||
1183 | state->timings = *timings; | 1370 | state->timings = *timings; |
1184 | 1371 | ||
1185 | /* freerun */ | 1372 | cp_write(sd, 0x91, bt->interlaced ? 0x50 : 0x10); |
1186 | configure_free_run(sd, bt); | 1373 | |
1374 | /* Use prim_mode and vid_std when available */ | ||
1375 | err = configure_predefined_video_timings(sd, timings); | ||
1376 | if (err) { | ||
1377 | /* custom settings when the video format | ||
1378 | does not have prim_mode/vid_std */ | ||
1379 | configure_custom_video_timings(sd, bt); | ||
1380 | } | ||
1187 | 1381 | ||
1188 | set_rgb_quantization_range(sd); | 1382 | set_rgb_quantization_range(sd); |
1189 | 1383 | ||
@@ -1203,24 +1397,25 @@ static int adv7604_g_dv_timings(struct v4l2_subdev *sd, | |||
1203 | return 0; | 1397 | return 0; |
1204 | } | 1398 | } |
1205 | 1399 | ||
1206 | static void enable_input(struct v4l2_subdev *sd, enum adv7604_prim_mode prim_mode) | 1400 | static void enable_input(struct v4l2_subdev *sd) |
1207 | { | 1401 | { |
1208 | switch (prim_mode) { | 1402 | struct adv7604_state *state = to_state(sd); |
1209 | case ADV7604_PRIM_MODE_COMP: | 1403 | |
1210 | case ADV7604_PRIM_MODE_RGB: | 1404 | switch (state->mode) { |
1405 | case ADV7604_MODE_COMP: | ||
1406 | case ADV7604_MODE_GR: | ||
1211 | /* enable */ | 1407 | /* enable */ |
1212 | io_write(sd, 0x15, 0xb0); /* Disable Tristate of Pins (no audio) */ | 1408 | io_write(sd, 0x15, 0xb0); /* Disable Tristate of Pins (no audio) */ |
1213 | break; | 1409 | break; |
1214 | case ADV7604_PRIM_MODE_HDMI_COMP: | 1410 | case ADV7604_MODE_HDMI: |
1215 | case ADV7604_PRIM_MODE_HDMI_GR: | ||
1216 | /* enable */ | 1411 | /* enable */ |
1217 | hdmi_write(sd, 0x1a, 0x0a); /* Unmute audio */ | 1412 | hdmi_write(sd, 0x1a, 0x0a); /* Unmute audio */ |
1218 | hdmi_write(sd, 0x01, 0x00); /* Enable HDMI clock terminators */ | 1413 | hdmi_write(sd, 0x01, 0x00); /* Enable HDMI clock terminators */ |
1219 | io_write(sd, 0x15, 0xa0); /* Disable Tristate of Pins */ | 1414 | io_write(sd, 0x15, 0xa0); /* Disable Tristate of Pins */ |
1220 | break; | 1415 | break; |
1221 | default: | 1416 | default: |
1222 | v4l2_err(sd, "%s: reserved primary mode 0x%0x\n", | 1417 | v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n", |
1223 | __func__, prim_mode); | 1418 | __func__, state->mode); |
1224 | break; | 1419 | break; |
1225 | } | 1420 | } |
1226 | } | 1421 | } |
@@ -1233,17 +1428,13 @@ static void disable_input(struct v4l2_subdev *sd) | |||
1233 | hdmi_write(sd, 0x01, 0x78); /* Disable HDMI clock terminators */ | 1428 | hdmi_write(sd, 0x01, 0x78); /* Disable HDMI clock terminators */ |
1234 | } | 1429 | } |
1235 | 1430 | ||
1236 | static void select_input(struct v4l2_subdev *sd, enum adv7604_prim_mode prim_mode) | 1431 | static void select_input(struct v4l2_subdev *sd) |
1237 | { | 1432 | { |
1238 | switch (prim_mode) { | 1433 | struct adv7604_state *state = to_state(sd); |
1239 | case ADV7604_PRIM_MODE_COMP: | ||
1240 | case ADV7604_PRIM_MODE_RGB: | ||
1241 | /* set mode and select free run resolution */ | ||
1242 | io_write(sd, 0x00, 0x07); /* video std */ | ||
1243 | io_write(sd, 0x01, 0x02); /* prim mode */ | ||
1244 | /* enable embedded syncs for auto graphics mode */ | ||
1245 | cp_write_and_or(sd, 0x81, 0xef, 0x10); | ||
1246 | 1434 | ||
1435 | switch (state->mode) { | ||
1436 | case ADV7604_MODE_COMP: | ||
1437 | case ADV7604_MODE_GR: | ||
1247 | /* reset ADI recommended settings for HDMI: */ | 1438 | /* reset ADI recommended settings for HDMI: */ |
1248 | /* "ADV7604 Register Settings Recommendations (rev. 2.5, June 2010)" p. 4. */ | 1439 | /* "ADV7604 Register Settings Recommendations (rev. 2.5, June 2010)" p. 4. */ |
1249 | hdmi_write(sd, 0x0d, 0x04); /* HDMI filter optimization */ | 1440 | hdmi_write(sd, 0x0d, 0x04); /* HDMI filter optimization */ |
@@ -1271,16 +1462,7 @@ static void select_input(struct v4l2_subdev *sd, enum adv7604_prim_mode prim_mod | |||
1271 | cp_write(sd, 0x40, 0x5c); /* CP core pre-gain control. Graphics mode */ | 1462 | cp_write(sd, 0x40, 0x5c); /* CP core pre-gain control. Graphics mode */ |
1272 | break; | 1463 | break; |
1273 | 1464 | ||
1274 | case ADV7604_PRIM_MODE_HDMI_COMP: | 1465 | case ADV7604_MODE_HDMI: |
1275 | case ADV7604_PRIM_MODE_HDMI_GR: | ||
1276 | /* set mode and select free run resolution */ | ||
1277 | /* video std */ | ||
1278 | io_write(sd, 0x00, | ||
1279 | (prim_mode == ADV7604_PRIM_MODE_HDMI_GR) ? 0x02 : 0x1e); | ||
1280 | io_write(sd, 0x01, prim_mode); /* prim mode */ | ||
1281 | /* disable embedded syncs for auto graphics mode */ | ||
1282 | cp_write_and_or(sd, 0x81, 0xef, 0x00); | ||
1283 | |||
1284 | /* set ADI recommended settings for HDMI: */ | 1466 | /* set ADI recommended settings for HDMI: */ |
1285 | /* "ADV7604 Register Settings Recommendations (rev. 2.5, June 2010)" p. 4. */ | 1467 | /* "ADV7604 Register Settings Recommendations (rev. 2.5, June 2010)" p. 4. */ |
1286 | hdmi_write(sd, 0x0d, 0x84); /* HDMI filter optimization */ | 1468 | hdmi_write(sd, 0x0d, 0x84); /* HDMI filter optimization */ |
@@ -1309,7 +1491,8 @@ static void select_input(struct v4l2_subdev *sd, enum adv7604_prim_mode prim_mod | |||
1309 | 1491 | ||
1310 | break; | 1492 | break; |
1311 | default: | 1493 | default: |
1312 | v4l2_err(sd, "%s: reserved primary mode 0x%0x\n", __func__, prim_mode); | 1494 | v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n", |
1495 | __func__, state->mode); | ||
1313 | break; | 1496 | break; |
1314 | } | 1497 | } |
1315 | } | 1498 | } |
@@ -1321,26 +1504,13 @@ static int adv7604_s_routing(struct v4l2_subdev *sd, | |||
1321 | 1504 | ||
1322 | v4l2_dbg(2, debug, sd, "%s: input %d", __func__, input); | 1505 | v4l2_dbg(2, debug, sd, "%s: input %d", __func__, input); |
1323 | 1506 | ||
1324 | switch (input) { | 1507 | state->mode = input; |
1325 | case 0: | ||
1326 | /* TODO select HDMI_COMP or HDMI_GR */ | ||
1327 | state->prim_mode = ADV7604_PRIM_MODE_HDMI_COMP; | ||
1328 | break; | ||
1329 | case 1: | ||
1330 | state->prim_mode = ADV7604_PRIM_MODE_RGB; | ||
1331 | break; | ||
1332 | case 2: | ||
1333 | state->prim_mode = ADV7604_PRIM_MODE_COMP; | ||
1334 | break; | ||
1335 | default: | ||
1336 | return -EINVAL; | ||
1337 | } | ||
1338 | 1508 | ||
1339 | disable_input(sd); | 1509 | disable_input(sd); |
1340 | 1510 | ||
1341 | select_input(sd, state->prim_mode); | 1511 | select_input(sd); |
1342 | 1512 | ||
1343 | enable_input(sd, state->prim_mode); | 1513 | enable_input(sd); |
1344 | 1514 | ||
1345 | return 0; | 1515 | return 0; |
1346 | } | 1516 | } |
@@ -1549,8 +1719,9 @@ static int adv7604_log_status(struct v4l2_subdev *sd) | |||
1549 | v4l2_info(sd, "CP locked: %s\n", no_lock_cp(sd) ? "false" : "true"); | 1719 | v4l2_info(sd, "CP locked: %s\n", no_lock_cp(sd) ? "false" : "true"); |
1550 | v4l2_info(sd, "CP free run: %s\n", | 1720 | v4l2_info(sd, "CP free run: %s\n", |
1551 | (!!(cp_read(sd, 0xff) & 0x10) ? "on" : "off")); | 1721 | (!!(cp_read(sd, 0xff) & 0x10) ? "on" : "off")); |
1552 | v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x\n", | 1722 | v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x, v_freq = 0x%x\n", |
1553 | io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f); | 1723 | io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f, |
1724 | (io_read(sd, 0x01) & 0x70) >> 4); | ||
1554 | 1725 | ||
1555 | v4l2_info(sd, "-----Video Timings-----\n"); | 1726 | v4l2_info(sd, "-----Video Timings-----\n"); |
1556 | if (read_stdi(sd, &stdi)) | 1727 | if (read_stdi(sd, &stdi)) |
@@ -1712,9 +1883,9 @@ static int adv7604_core_init(struct v4l2_subdev *sd) | |||
1712 | cp_write(sd, 0xba, (pdata->hdmi_free_run_mode << 1) | 0x01); /* HDMI free run */ | 1883 | cp_write(sd, 0xba, (pdata->hdmi_free_run_mode << 1) | 0x01); /* HDMI free run */ |
1713 | cp_write(sd, 0xf3, 0xdc); /* Low threshold to enter/exit free run mode */ | 1884 | cp_write(sd, 0xf3, 0xdc); /* Low threshold to enter/exit free run mode */ |
1714 | cp_write(sd, 0xf9, 0x23); /* STDI ch. 1 - LCVS change threshold - | 1885 | cp_write(sd, 0xf9, 0x23); /* STDI ch. 1 - LCVS change threshold - |
1715 | ADI recommended setting [REF_01 c. 2.3.3] */ | 1886 | ADI recommended setting [REF_01, c. 2.3.3] */ |
1716 | cp_write(sd, 0x45, 0x23); /* STDI ch. 2 - LCVS change threshold - | 1887 | cp_write(sd, 0x45, 0x23); /* STDI ch. 2 - LCVS change threshold - |
1717 | ADI recommended setting [REF_01 c. 2.3.3] */ | 1888 | ADI recommended setting [REF_01, c. 2.3.3] */ |
1718 | cp_write(sd, 0xc9, 0x2d); /* use prim_mode and vid_std as free run resolution | 1889 | cp_write(sd, 0xc9, 0x2d); /* use prim_mode and vid_std as free run resolution |
1719 | for digital formats */ | 1890 | for digital formats */ |
1720 | 1891 | ||
@@ -1724,11 +1895,6 @@ static int adv7604_core_init(struct v4l2_subdev *sd) | |||
1724 | afe_write(sd, 0x02, pdata->ain_sel); /* Select analog input muxing mode */ | 1895 | afe_write(sd, 0x02, pdata->ain_sel); /* Select analog input muxing mode */ |
1725 | io_write_and_or(sd, 0x30, ~(1 << 4), pdata->output_bus_lsb_to_msb << 4); | 1896 | io_write_and_or(sd, 0x30, ~(1 << 4), pdata->output_bus_lsb_to_msb << 4); |
1726 | 1897 | ||
1727 | state->prim_mode = pdata->prim_mode; | ||
1728 | select_input(sd, pdata->prim_mode); | ||
1729 | |||
1730 | enable_input(sd, pdata->prim_mode); | ||
1731 | |||
1732 | /* interrupts */ | 1898 | /* interrupts */ |
1733 | io_write(sd, 0x40, 0xc2); /* Configure INT1 */ | 1899 | io_write(sd, 0x40, 0xc2); /* Configure INT1 */ |
1734 | io_write(sd, 0x41, 0xd7); /* STDI irq for any change, disable INT2 */ | 1900 | io_write(sd, 0x41, 0xd7); /* STDI irq for any change, disable INT2 */ |
@@ -1883,6 +2049,7 @@ static int adv7604_probe(struct i2c_client *client, | |||
1883 | v4l2_err(sd, "failed to create all i2c clients\n"); | 2049 | v4l2_err(sd, "failed to create all i2c clients\n"); |
1884 | goto err_i2c; | 2050 | goto err_i2c; |
1885 | } | 2051 | } |
2052 | state->restart_stdi_once = true; | ||
1886 | 2053 | ||
1887 | /* work queues */ | 2054 | /* work queues */ |
1888 | state->work_queues = create_singlethread_workqueue(client->name); | 2055 | state->work_queues = create_singlethread_workqueue(client->name); |
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c index 13057b966ee9..333ef178d6fb 100644 --- a/drivers/media/i2c/soc_camera/mt9v022.c +++ b/drivers/media/i2c/soc_camera/mt9v022.c | |||
@@ -263,9 +263,14 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a) | |||
263 | if (ret & 1) /* Autoexposure */ | 263 | if (ret & 1) /* Autoexposure */ |
264 | ret = reg_write(client, mt9v022->reg->max_total_shutter_width, | 264 | ret = reg_write(client, mt9v022->reg->max_total_shutter_width, |
265 | rect.height + mt9v022->y_skip_top + 43); | 265 | rect.height + mt9v022->y_skip_top + 43); |
266 | else | 266 | /* |
267 | ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH, | 267 | * If autoexposure is off, there is no need to set |
268 | rect.height + mt9v022->y_skip_top + 43); | 268 | * MT9V022_TOTAL_SHUTTER_WIDTH here. Autoexposure can be off |
269 | * only if the user has set exposure manually, using the | ||
270 | * V4L2_CID_EXPOSURE_AUTO with the value V4L2_EXPOSURE_MANUAL. | ||
271 | * In this case the register MT9V022_TOTAL_SHUTTER_WIDTH | ||
272 | * already contains the correct value. | ||
273 | */ | ||
269 | } | 274 | } |
270 | /* Setup frame format: defaults apart from width and height */ | 275 | /* Setup frame format: defaults apart from width and height */ |
271 | if (!ret) | 276 | if (!ret) |
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c index bfec9e65aefb..19cbb12a12a2 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.c +++ b/drivers/media/platform/exynos-gsc/gsc-core.c | |||
@@ -965,8 +965,10 @@ static struct platform_device_id gsc_driver_ids[] = { | |||
965 | MODULE_DEVICE_TABLE(platform, gsc_driver_ids); | 965 | MODULE_DEVICE_TABLE(platform, gsc_driver_ids); |
966 | 966 | ||
967 | static const struct of_device_id exynos_gsc_match[] = { | 967 | static const struct of_device_id exynos_gsc_match[] = { |
968 | { .compatible = "samsung,exynos5250-gsc", | 968 | { |
969 | .data = &gsc_v_100_drvdata, }, | 969 | .compatible = "samsung,exynos5-gsc", |
970 | .data = &gsc_v_100_drvdata, | ||
971 | }, | ||
970 | {}, | 972 | {}, |
971 | }; | 973 | }; |
972 | MODULE_DEVICE_TABLE(of, exynos_gsc_match); | 974 | MODULE_DEVICE_TABLE(of, exynos_gsc_match); |
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c index 3c7f00577bd9..c065d040ed94 100644 --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c | |||
@@ -657,8 +657,7 @@ static int gsc_m2m_release(struct file *file) | |||
657 | pr_debug("pid: %d, state: 0x%lx, refcnt= %d", | 657 | pr_debug("pid: %d, state: 0x%lx, refcnt= %d", |
658 | task_pid_nr(current), gsc->state, gsc->m2m.refcnt); | 658 | task_pid_nr(current), gsc->state, gsc->m2m.refcnt); |
659 | 659 | ||
660 | if (mutex_lock_interruptible(&gsc->lock)) | 660 | mutex_lock(&gsc->lock); |
661 | return -ERESTARTSYS; | ||
662 | 661 | ||
663 | v4l2_m2m_ctx_release(ctx->m2m_ctx); | 662 | v4l2_m2m_ctx_release(ctx->m2m_ctx); |
664 | gsc_ctrls_delete(ctx); | 663 | gsc_ctrls_delete(ctx); |
@@ -732,6 +731,7 @@ int gsc_register_m2m_device(struct gsc_dev *gsc) | |||
732 | gsc->vdev.ioctl_ops = &gsc_m2m_ioctl_ops; | 731 | gsc->vdev.ioctl_ops = &gsc_m2m_ioctl_ops; |
733 | gsc->vdev.release = video_device_release_empty; | 732 | gsc->vdev.release = video_device_release_empty; |
734 | gsc->vdev.lock = &gsc->lock; | 733 | gsc->vdev.lock = &gsc->lock; |
734 | gsc->vdev.vfl_dir = VFL_DIR_M2M; | ||
735 | snprintf(gsc->vdev.name, sizeof(gsc->vdev.name), "%s.%d:m2m", | 735 | snprintf(gsc->vdev.name, sizeof(gsc->vdev.name), "%s.%d:m2m", |
736 | GSC_MODULE_NAME, gsc->id); | 736 | GSC_MODULE_NAME, gsc->id); |
737 | 737 | ||
diff --git a/drivers/media/platform/exynos-gsc/gsc-regs.h b/drivers/media/platform/exynos-gsc/gsc-regs.h index 533e9947a925..4678f9a6a4fd 100644 --- a/drivers/media/platform/exynos-gsc/gsc-regs.h +++ b/drivers/media/platform/exynos-gsc/gsc-regs.h | |||
@@ -40,10 +40,10 @@ | |||
40 | #define GSC_IN_ROT_YFLIP (2 << 16) | 40 | #define GSC_IN_ROT_YFLIP (2 << 16) |
41 | #define GSC_IN_ROT_XFLIP (1 << 16) | 41 | #define GSC_IN_ROT_XFLIP (1 << 16) |
42 | #define GSC_IN_RGB_TYPE_MASK (3 << 14) | 42 | #define GSC_IN_RGB_TYPE_MASK (3 << 14) |
43 | #define GSC_IN_RGB_HD_WIDE (3 << 14) | 43 | #define GSC_IN_RGB_HD_NARROW (3 << 14) |
44 | #define GSC_IN_RGB_HD_NARROW (2 << 14) | 44 | #define GSC_IN_RGB_HD_WIDE (2 << 14) |
45 | #define GSC_IN_RGB_SD_WIDE (1 << 14) | 45 | #define GSC_IN_RGB_SD_NARROW (1 << 14) |
46 | #define GSC_IN_RGB_SD_NARROW (0 << 14) | 46 | #define GSC_IN_RGB_SD_WIDE (0 << 14) |
47 | #define GSC_IN_YUV422_1P_ORDER_MASK (1 << 13) | 47 | #define GSC_IN_YUV422_1P_ORDER_MASK (1 << 13) |
48 | #define GSC_IN_YUV422_1P_ORDER_LSB_Y (0 << 13) | 48 | #define GSC_IN_YUV422_1P_ORDER_LSB_Y (0 << 13) |
49 | #define GSC_IN_YUV422_1P_OEDER_LSB_C (1 << 13) | 49 | #define GSC_IN_YUV422_1P_OEDER_LSB_C (1 << 13) |
@@ -85,10 +85,10 @@ | |||
85 | #define GSC_OUT_GLOBAL_ALPHA_MASK (0xff << 24) | 85 | #define GSC_OUT_GLOBAL_ALPHA_MASK (0xff << 24) |
86 | #define GSC_OUT_GLOBAL_ALPHA(x) ((x) << 24) | 86 | #define GSC_OUT_GLOBAL_ALPHA(x) ((x) << 24) |
87 | #define GSC_OUT_RGB_TYPE_MASK (3 << 10) | 87 | #define GSC_OUT_RGB_TYPE_MASK (3 << 10) |
88 | #define GSC_OUT_RGB_HD_NARROW (3 << 10) | 88 | #define GSC_OUT_RGB_HD_WIDE (3 << 10) |
89 | #define GSC_OUT_RGB_HD_WIDE (2 << 10) | 89 | #define GSC_OUT_RGB_HD_NARROW (2 << 10) |
90 | #define GSC_OUT_RGB_SD_NARROW (1 << 10) | 90 | #define GSC_OUT_RGB_SD_WIDE (1 << 10) |
91 | #define GSC_OUT_RGB_SD_WIDE (0 << 10) | 91 | #define GSC_OUT_RGB_SD_NARROW (0 << 10) |
92 | #define GSC_OUT_YUV422_1P_ORDER_MASK (1 << 9) | 92 | #define GSC_OUT_YUV422_1P_ORDER_MASK (1 << 9) |
93 | #define GSC_OUT_YUV422_1P_ORDER_LSB_Y (0 << 9) | 93 | #define GSC_OUT_YUV422_1P_ORDER_LSB_Y (0 << 9) |
94 | #define GSC_OUT_YUV422_1P_OEDER_LSB_C (1 << 9) | 94 | #define GSC_OUT_YUV422_1P_OEDER_LSB_C (1 << 9) |
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 60181ab96063..aa9df9d71a7b 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c | |||
@@ -1706,7 +1706,7 @@ static long ccdc_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) | |||
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | static int ccdc_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, | 1708 | static int ccdc_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, |
1709 | const struct v4l2_event_subscription *sub) | 1709 | struct v4l2_event_subscription *sub) |
1710 | { | 1710 | { |
1711 | if (sub->type != V4L2_EVENT_FRAME_SYNC) | 1711 | if (sub->type != V4L2_EVENT_FRAME_SYNC) |
1712 | return -EINVAL; | 1712 | return -EINVAL; |
@@ -1719,7 +1719,7 @@ static int ccdc_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, | |||
1719 | } | 1719 | } |
1720 | 1720 | ||
1721 | static int ccdc_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, | 1721 | static int ccdc_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, |
1722 | const struct v4l2_event_subscription *sub) | 1722 | struct v4l2_event_subscription *sub) |
1723 | { | 1723 | { |
1724 | return v4l2_event_unsubscribe(fh, sub); | 1724 | return v4l2_event_unsubscribe(fh, sub); |
1725 | } | 1725 | } |
diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c index d7ac76b5c2ae..b8640be692f1 100644 --- a/drivers/media/platform/omap3isp/ispstat.c +++ b/drivers/media/platform/omap3isp/ispstat.c | |||
@@ -1025,7 +1025,7 @@ void omap3isp_stat_dma_isr(struct ispstat *stat) | |||
1025 | 1025 | ||
1026 | int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, | 1026 | int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, |
1027 | struct v4l2_fh *fh, | 1027 | struct v4l2_fh *fh, |
1028 | const struct v4l2_event_subscription *sub) | 1028 | struct v4l2_event_subscription *sub) |
1029 | { | 1029 | { |
1030 | struct ispstat *stat = v4l2_get_subdevdata(subdev); | 1030 | struct ispstat *stat = v4l2_get_subdevdata(subdev); |
1031 | 1031 | ||
@@ -1037,7 +1037,7 @@ int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, | |||
1037 | 1037 | ||
1038 | int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev, | 1038 | int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev, |
1039 | struct v4l2_fh *fh, | 1039 | struct v4l2_fh *fh, |
1040 | const struct v4l2_event_subscription *sub) | 1040 | struct v4l2_event_subscription *sub) |
1041 | { | 1041 | { |
1042 | return v4l2_event_unsubscribe(fh, sub); | 1042 | return v4l2_event_unsubscribe(fh, sub); |
1043 | } | 1043 | } |
diff --git a/drivers/media/platform/omap3isp/ispstat.h b/drivers/media/platform/omap3isp/ispstat.h index a6fe653eb237..9b7c8654dc8a 100644 --- a/drivers/media/platform/omap3isp/ispstat.h +++ b/drivers/media/platform/omap3isp/ispstat.h | |||
@@ -147,10 +147,10 @@ int omap3isp_stat_init(struct ispstat *stat, const char *name, | |||
147 | void omap3isp_stat_cleanup(struct ispstat *stat); | 147 | void omap3isp_stat_cleanup(struct ispstat *stat); |
148 | int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, | 148 | int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, |
149 | struct v4l2_fh *fh, | 149 | struct v4l2_fh *fh, |
150 | const struct v4l2_event_subscription *sub); | 150 | struct v4l2_event_subscription *sub); |
151 | int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev, | 151 | int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev, |
152 | struct v4l2_fh *fh, | 152 | struct v4l2_fh *fh, |
153 | const struct v4l2_event_subscription *sub); | 153 | struct v4l2_event_subscription *sub); |
154 | int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable); | 154 | int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable); |
155 | 155 | ||
156 | int omap3isp_stat_busy(struct ispstat *stat); | 156 | int omap3isp_stat_busy(struct ispstat *stat); |
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index a0b737fecf13..75cd309035f9 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c | |||
@@ -792,7 +792,7 @@ isp_video_get_crop(struct file *file, void *fh, struct v4l2_crop *crop) | |||
792 | } | 792 | } |
793 | 793 | ||
794 | static int | 794 | static int |
795 | isp_video_set_crop(struct file *file, void *fh, struct v4l2_crop *crop) | 795 | isp_video_set_crop(struct file *file, void *fh, const struct v4l2_crop *crop) |
796 | { | 796 | { |
797 | struct isp_video *video = video_drvdata(file); | 797 | struct isp_video *video = video_drvdata(file); |
798 | struct v4l2_subdev *subdev; | 798 | struct v4l2_subdev *subdev; |
diff --git a/drivers/media/platform/s5p-fimc/Kconfig b/drivers/media/platform/s5p-fimc/Kconfig index 8f090a8f270e..c16b20d86ed2 100644 --- a/drivers/media/platform/s5p-fimc/Kconfig +++ b/drivers/media/platform/s5p-fimc/Kconfig | |||
@@ -24,6 +24,7 @@ config VIDEO_S5P_FIMC | |||
24 | config VIDEO_S5P_MIPI_CSIS | 24 | config VIDEO_S5P_MIPI_CSIS |
25 | tristate "S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver" | 25 | tristate "S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver" |
26 | depends on REGULATOR | 26 | depends on REGULATOR |
27 | select S5P_SETUP_MIPIPHY | ||
27 | help | 28 | help |
28 | This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2 | 29 | This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2 |
29 | receiver (MIPI-CSIS) devices. | 30 | receiver (MIPI-CSIS) devices. |
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c index 367efd164d0f..891ee873c62b 100644 --- a/drivers/media/platform/s5p-fimc/fimc-capture.c +++ b/drivers/media/platform/s5p-fimc/fimc-capture.c | |||
@@ -556,8 +556,7 @@ static int fimc_capture_close(struct file *file) | |||
556 | 556 | ||
557 | dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); | 557 | dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); |
558 | 558 | ||
559 | if (mutex_lock_interruptible(&fimc->lock)) | 559 | mutex_lock(&fimc->lock); |
560 | return -ERESTARTSYS; | ||
561 | 560 | ||
562 | if (--fimc->vid_cap.refcnt == 0) { | 561 | if (--fimc->vid_cap.refcnt == 0) { |
563 | clear_bit(ST_CAPT_BUSY, &fimc->state); | 562 | clear_bit(ST_CAPT_BUSY, &fimc->state); |
@@ -1736,7 +1735,9 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, | |||
1736 | q->mem_ops = &vb2_dma_contig_memops; | 1735 | q->mem_ops = &vb2_dma_contig_memops; |
1737 | q->buf_struct_size = sizeof(struct fimc_vid_buffer); | 1736 | q->buf_struct_size = sizeof(struct fimc_vid_buffer); |
1738 | 1737 | ||
1739 | vb2_queue_init(q); | 1738 | ret = vb2_queue_init(q); |
1739 | if (ret) | ||
1740 | goto err_ent; | ||
1740 | 1741 | ||
1741 | vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK; | 1742 | vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK; |
1742 | ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad, 0); | 1743 | ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad, 0); |
@@ -1772,9 +1773,13 @@ static int fimc_capture_subdev_registered(struct v4l2_subdev *sd) | |||
1772 | if (ret) | 1773 | if (ret) |
1773 | return ret; | 1774 | return ret; |
1774 | 1775 | ||
1776 | fimc->pipeline_ops = v4l2_get_subdev_hostdata(sd); | ||
1777 | |||
1775 | ret = fimc_register_capture_device(fimc, sd->v4l2_dev); | 1778 | ret = fimc_register_capture_device(fimc, sd->v4l2_dev); |
1776 | if (ret) | 1779 | if (ret) { |
1777 | fimc_unregister_m2m_device(fimc); | 1780 | fimc_unregister_m2m_device(fimc); |
1781 | fimc->pipeline_ops = NULL; | ||
1782 | } | ||
1778 | 1783 | ||
1779 | return ret; | 1784 | return ret; |
1780 | } | 1785 | } |
@@ -1791,6 +1796,7 @@ static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd) | |||
1791 | if (video_is_registered(&fimc->vid_cap.vfd)) { | 1796 | if (video_is_registered(&fimc->vid_cap.vfd)) { |
1792 | video_unregister_device(&fimc->vid_cap.vfd); | 1797 | video_unregister_device(&fimc->vid_cap.vfd); |
1793 | media_entity_cleanup(&fimc->vid_cap.vfd.entity); | 1798 | media_entity_cleanup(&fimc->vid_cap.vfd.entity); |
1799 | fimc->pipeline_ops = NULL; | ||
1794 | } | 1800 | } |
1795 | kfree(fimc->vid_cap.ctx); | 1801 | kfree(fimc->vid_cap.ctx); |
1796 | fimc->vid_cap.ctx = NULL; | 1802 | fimc->vid_cap.ctx = NULL; |
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c b/drivers/media/platform/s5p-fimc/fimc-lite.c index 70bcf39de879..1b309a72f09f 100644 --- a/drivers/media/platform/s5p-fimc/fimc-lite.c +++ b/drivers/media/platform/s5p-fimc/fimc-lite.c | |||
@@ -491,8 +491,7 @@ static int fimc_lite_close(struct file *file) | |||
491 | struct fimc_lite *fimc = video_drvdata(file); | 491 | struct fimc_lite *fimc = video_drvdata(file); |
492 | int ret; | 492 | int ret; |
493 | 493 | ||
494 | if (mutex_lock_interruptible(&fimc->lock)) | 494 | mutex_lock(&fimc->lock); |
495 | return -ERESTARTSYS; | ||
496 | 495 | ||
497 | if (--fimc->ref_count == 0 && fimc->out_path == FIMC_IO_DMA) { | 496 | if (--fimc->ref_count == 0 && fimc->out_path == FIMC_IO_DMA) { |
498 | clear_bit(ST_FLITE_IN_USE, &fimc->state); | 497 | clear_bit(ST_FLITE_IN_USE, &fimc->state); |
@@ -1253,7 +1252,9 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd) | |||
1253 | q->buf_struct_size = sizeof(struct flite_buffer); | 1252 | q->buf_struct_size = sizeof(struct flite_buffer); |
1254 | q->drv_priv = fimc; | 1253 | q->drv_priv = fimc; |
1255 | 1254 | ||
1256 | vb2_queue_init(q); | 1255 | ret = vb2_queue_init(q); |
1256 | if (ret < 0) | ||
1257 | return ret; | ||
1257 | 1258 | ||
1258 | fimc->vd_pad.flags = MEDIA_PAD_FL_SINK; | 1259 | fimc->vd_pad.flags = MEDIA_PAD_FL_SINK; |
1259 | ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad, 0); | 1260 | ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad, 0); |
@@ -1261,10 +1262,12 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd) | |||
1261 | return ret; | 1262 | return ret; |
1262 | 1263 | ||
1263 | video_set_drvdata(vfd, fimc); | 1264 | video_set_drvdata(vfd, fimc); |
1265 | fimc->pipeline_ops = v4l2_get_subdev_hostdata(sd); | ||
1264 | 1266 | ||
1265 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); | 1267 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); |
1266 | if (ret < 0) { | 1268 | if (ret < 0) { |
1267 | media_entity_cleanup(&vfd->entity); | 1269 | media_entity_cleanup(&vfd->entity); |
1270 | fimc->pipeline_ops = NULL; | ||
1268 | return ret; | 1271 | return ret; |
1269 | } | 1272 | } |
1270 | 1273 | ||
@@ -1283,6 +1286,7 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd) | |||
1283 | if (video_is_registered(&fimc->vfd)) { | 1286 | if (video_is_registered(&fimc->vfd)) { |
1284 | video_unregister_device(&fimc->vfd); | 1287 | video_unregister_device(&fimc->vfd); |
1285 | media_entity_cleanup(&fimc->vfd.entity); | 1288 | media_entity_cleanup(&fimc->vfd.entity); |
1289 | fimc->pipeline_ops = NULL; | ||
1286 | } | 1290 | } |
1287 | } | 1291 | } |
1288 | 1292 | ||
diff --git a/drivers/media/platform/s5p-fimc/fimc-m2m.c b/drivers/media/platform/s5p-fimc/fimc-m2m.c index 4500e44f6857..62afed3162ea 100644 --- a/drivers/media/platform/s5p-fimc/fimc-m2m.c +++ b/drivers/media/platform/s5p-fimc/fimc-m2m.c | |||
@@ -718,8 +718,7 @@ static int fimc_m2m_release(struct file *file) | |||
718 | dbg("pid: %d, state: 0x%lx, refcnt= %d", | 718 | dbg("pid: %d, state: 0x%lx, refcnt= %d", |
719 | task_pid_nr(current), fimc->state, fimc->m2m.refcnt); | 719 | task_pid_nr(current), fimc->state, fimc->m2m.refcnt); |
720 | 720 | ||
721 | if (mutex_lock_interruptible(&fimc->lock)) | 721 | mutex_lock(&fimc->lock); |
722 | return -ERESTARTSYS; | ||
723 | 722 | ||
724 | v4l2_m2m_ctx_release(ctx->m2m_ctx); | 723 | v4l2_m2m_ctx_release(ctx->m2m_ctx); |
725 | fimc_ctrls_delete(ctx); | 724 | fimc_ctrls_delete(ctx); |
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c b/drivers/media/platform/s5p-fimc/fimc-mdevice.c index 80ada5882f62..0531ab70a94c 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c | |||
@@ -343,53 +343,50 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) | |||
343 | static int fimc_register_callback(struct device *dev, void *p) | 343 | static int fimc_register_callback(struct device *dev, void *p) |
344 | { | 344 | { |
345 | struct fimc_dev *fimc = dev_get_drvdata(dev); | 345 | struct fimc_dev *fimc = dev_get_drvdata(dev); |
346 | struct v4l2_subdev *sd = &fimc->vid_cap.subdev; | 346 | struct v4l2_subdev *sd; |
347 | struct fimc_md *fmd = p; | 347 | struct fimc_md *fmd = p; |
348 | int ret = 0; | 348 | int ret; |
349 | |||
350 | if (!fimc || !fimc->pdev) | ||
351 | return 0; | ||
352 | 349 | ||
353 | if (fimc->pdev->id < 0 || fimc->pdev->id >= FIMC_MAX_DEVS) | 350 | if (fimc == NULL || fimc->id >= FIMC_MAX_DEVS) |
354 | return 0; | 351 | return 0; |
355 | 352 | ||
356 | fimc->pipeline_ops = &fimc_pipeline_ops; | 353 | sd = &fimc->vid_cap.subdev; |
357 | fmd->fimc[fimc->pdev->id] = fimc; | ||
358 | sd->grp_id = FIMC_GROUP_ID; | 354 | sd->grp_id = FIMC_GROUP_ID; |
355 | v4l2_set_subdev_hostdata(sd, (void *)&fimc_pipeline_ops); | ||
359 | 356 | ||
360 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 357 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); |
361 | if (ret) { | 358 | if (ret) { |
362 | v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n", | 359 | v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n", |
363 | fimc->id, ret); | 360 | fimc->id, ret); |
361 | return ret; | ||
364 | } | 362 | } |
365 | 363 | ||
366 | return ret; | 364 | fmd->fimc[fimc->id] = fimc; |
365 | return 0; | ||
367 | } | 366 | } |
368 | 367 | ||
369 | static int fimc_lite_register_callback(struct device *dev, void *p) | 368 | static int fimc_lite_register_callback(struct device *dev, void *p) |
370 | { | 369 | { |
371 | struct fimc_lite *fimc = dev_get_drvdata(dev); | 370 | struct fimc_lite *fimc = dev_get_drvdata(dev); |
372 | struct v4l2_subdev *sd = &fimc->subdev; | ||
373 | struct fimc_md *fmd = p; | 371 | struct fimc_md *fmd = p; |
374 | int ret; | 372 | int ret; |
375 | 373 | ||
376 | if (fimc == NULL) | 374 | if (fimc == NULL || fimc->index >= FIMC_LITE_MAX_DEVS) |
377 | return 0; | 375 | return 0; |
378 | 376 | ||
379 | if (fimc->index >= FIMC_LITE_MAX_DEVS) | 377 | fimc->subdev.grp_id = FLITE_GROUP_ID; |
380 | return 0; | 378 | v4l2_set_subdev_hostdata(&fimc->subdev, (void *)&fimc_pipeline_ops); |
381 | |||
382 | fimc->pipeline_ops = &fimc_pipeline_ops; | ||
383 | fmd->fimc_lite[fimc->index] = fimc; | ||
384 | sd->grp_id = FLITE_GROUP_ID; | ||
385 | 379 | ||
386 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 380 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, &fimc->subdev); |
387 | if (ret) { | 381 | if (ret) { |
388 | v4l2_err(&fmd->v4l2_dev, | 382 | v4l2_err(&fmd->v4l2_dev, |
389 | "Failed to register FIMC-LITE.%d (%d)\n", | 383 | "Failed to register FIMC-LITE.%d (%d)\n", |
390 | fimc->index, ret); | 384 | fimc->index, ret); |
385 | return ret; | ||
391 | } | 386 | } |
392 | return ret; | 387 | |
388 | fmd->fimc_lite[fimc->index] = fimc; | ||
389 | return 0; | ||
393 | } | 390 | } |
394 | 391 | ||
395 | static int csis_register_callback(struct device *dev, void *p) | 392 | static int csis_register_callback(struct device *dev, void *p) |
@@ -407,10 +404,12 @@ static int csis_register_callback(struct device *dev, void *p) | |||
407 | v4l2_info(sd, "csis%d sd: %s\n", pdev->id, sd->name); | 404 | v4l2_info(sd, "csis%d sd: %s\n", pdev->id, sd->name); |
408 | 405 | ||
409 | id = pdev->id < 0 ? 0 : pdev->id; | 406 | id = pdev->id < 0 ? 0 : pdev->id; |
410 | fmd->csis[id].sd = sd; | ||
411 | sd->grp_id = CSIS_GROUP_ID; | 407 | sd->grp_id = CSIS_GROUP_ID; |
408 | |||
412 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 409 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); |
413 | if (ret) | 410 | if (!ret) |
411 | fmd->csis[id].sd = sd; | ||
412 | else | ||
414 | v4l2_err(&fmd->v4l2_dev, | 413 | v4l2_err(&fmd->v4l2_dev, |
415 | "Failed to register CSIS subdevice: %d\n", ret); | 414 | "Failed to register CSIS subdevice: %d\n", ret); |
416 | return ret; | 415 | return ret; |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 130f4ac8649e..3afe879d54d7 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c | |||
@@ -381,11 +381,8 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx, | |||
381 | ctx->consumed_stream += s5p_mfc_hw_call(dev->mfc_ops, | 381 | ctx->consumed_stream += s5p_mfc_hw_call(dev->mfc_ops, |
382 | get_consumed_stream, dev); | 382 | get_consumed_stream, dev); |
383 | if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC && | 383 | if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC && |
384 | s5p_mfc_hw_call(dev->mfc_ops, | 384 | ctx->consumed_stream + STUFF_BYTE < |
385 | get_dec_frame_type, dev) == | 385 | src_buf->b->v4l2_planes[0].bytesused) { |
386 | S5P_FIMV_DECODE_FRAME_P_FRAME | ||
387 | && ctx->consumed_stream + STUFF_BYTE < | ||
388 | src_buf->b->v4l2_planes[0].bytesused) { | ||
389 | /* Run MFC again on the same buffer */ | 386 | /* Run MFC again on the same buffer */ |
390 | mfc_debug(2, "Running again the same buffer\n"); | 387 | mfc_debug(2, "Running again the same buffer\n"); |
391 | ctx->after_packed_pb = 1; | 388 | ctx->after_packed_pb = 1; |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c index 50b5bee3c44e..3a8cfd9fc1bd 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | |||
@@ -1762,7 +1762,7 @@ int s5p_mfc_get_dspl_y_adr_v6(struct s5p_mfc_dev *dev) | |||
1762 | 1762 | ||
1763 | int s5p_mfc_get_dec_y_adr_v6(struct s5p_mfc_dev *dev) | 1763 | int s5p_mfc_get_dec_y_adr_v6(struct s5p_mfc_dev *dev) |
1764 | { | 1764 | { |
1765 | return mfc_read(dev, S5P_FIMV_D_DISPLAY_LUMA_ADDR_V6); | 1765 | return mfc_read(dev, S5P_FIMV_D_DECODED_LUMA_ADDR_V6); |
1766 | } | 1766 | } |
1767 | 1767 | ||
1768 | int s5p_mfc_get_dspl_status_v6(struct s5p_mfc_dev *dev) | 1768 | int s5p_mfc_get_dspl_status_v6(struct s5p_mfc_dev *dev) |
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c index 85fd312f0a82..a1c87f0ceaab 100644 --- a/drivers/media/platform/sh_vou.c +++ b/drivers/media/platform/sh_vou.c | |||
@@ -935,9 +935,10 @@ static int sh_vou_g_crop(struct file *file, void *fh, struct v4l2_crop *a) | |||
935 | /* Assume a dull encoder, do all the work ourselves. */ | 935 | /* Assume a dull encoder, do all the work ourselves. */ |
936 | static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a) | 936 | static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a) |
937 | { | 937 | { |
938 | struct v4l2_crop a_writable = *a; | ||
938 | struct video_device *vdev = video_devdata(file); | 939 | struct video_device *vdev = video_devdata(file); |
939 | struct sh_vou_device *vou_dev = video_get_drvdata(vdev); | 940 | struct sh_vou_device *vou_dev = video_get_drvdata(vdev); |
940 | struct v4l2_rect *rect = &a->c; | 941 | struct v4l2_rect *rect = &a_writable.c; |
941 | struct v4l2_crop sd_crop = {.type = V4L2_BUF_TYPE_VIDEO_OUTPUT}; | 942 | struct v4l2_crop sd_crop = {.type = V4L2_BUF_TYPE_VIDEO_OUTPUT}; |
942 | struct v4l2_pix_format *pix = &vou_dev->pix; | 943 | struct v4l2_pix_format *pix = &vou_dev->pix; |
943 | struct sh_vou_geometry geo; | 944 | struct sh_vou_geometry geo; |
diff --git a/drivers/media/platform/soc_camera/mx1_camera.c b/drivers/media/platform/soc_camera/mx1_camera.c index bbe70991d30b..032b8c9097f9 100644 --- a/drivers/media/platform/soc_camera/mx1_camera.c +++ b/drivers/media/platform/soc_camera/mx1_camera.c | |||
@@ -470,14 +470,6 @@ static void mx1_camera_remove_device(struct soc_camera_device *icd) | |||
470 | pcdev->icd = NULL; | 470 | pcdev->icd = NULL; |
471 | } | 471 | } |
472 | 472 | ||
473 | static int mx1_camera_set_crop(struct soc_camera_device *icd, | ||
474 | struct v4l2_crop *a) | ||
475 | { | ||
476 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | ||
477 | |||
478 | return v4l2_subdev_call(sd, video, s_crop, a); | ||
479 | } | ||
480 | |||
481 | static int mx1_camera_set_bus_param(struct soc_camera_device *icd) | 473 | static int mx1_camera_set_bus_param(struct soc_camera_device *icd) |
482 | { | 474 | { |
483 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 475 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
@@ -689,7 +681,6 @@ static struct soc_camera_host_ops mx1_soc_camera_host_ops = { | |||
689 | .add = mx1_camera_add_device, | 681 | .add = mx1_camera_add_device, |
690 | .remove = mx1_camera_remove_device, | 682 | .remove = mx1_camera_remove_device, |
691 | .set_bus_param = mx1_camera_set_bus_param, | 683 | .set_bus_param = mx1_camera_set_bus_param, |
692 | .set_crop = mx1_camera_set_crop, | ||
693 | .set_fmt = mx1_camera_set_fmt, | 684 | .set_fmt = mx1_camera_set_fmt, |
694 | .try_fmt = mx1_camera_try_fmt, | 685 | .try_fmt = mx1_camera_try_fmt, |
695 | .init_videobuf = mx1_camera_init_videobuf, | 686 | .init_videobuf = mx1_camera_init_videobuf, |
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c index 9fd9d1c5b218..9a55f4c4c7f4 100644 --- a/drivers/media/platform/soc_camera/mx2_camera.c +++ b/drivers/media/platform/soc_camera/mx2_camera.c | |||
@@ -864,8 +864,10 @@ static int mx2_start_streaming(struct vb2_queue *q, unsigned int count) | |||
864 | 864 | ||
865 | bytesperline = soc_mbus_bytes_per_line(icd->user_width, | 865 | bytesperline = soc_mbus_bytes_per_line(icd->user_width, |
866 | icd->current_fmt->host_fmt); | 866 | icd->current_fmt->host_fmt); |
867 | if (bytesperline < 0) | 867 | if (bytesperline < 0) { |
868 | spin_unlock_irqrestore(&pcdev->lock, flags); | ||
868 | return bytesperline; | 869 | return bytesperline; |
870 | } | ||
869 | 871 | ||
870 | /* | 872 | /* |
871 | * I didn't manage to properly enable/disable the prp | 873 | * I didn't manage to properly enable/disable the prp |
@@ -878,8 +880,10 @@ static int mx2_start_streaming(struct vb2_queue *q, unsigned int count) | |||
878 | pcdev->discard_buffer = dma_alloc_coherent(ici->v4l2_dev.dev, | 880 | pcdev->discard_buffer = dma_alloc_coherent(ici->v4l2_dev.dev, |
879 | pcdev->discard_size, &pcdev->discard_buffer_dma, | 881 | pcdev->discard_size, &pcdev->discard_buffer_dma, |
880 | GFP_KERNEL); | 882 | GFP_KERNEL); |
881 | if (!pcdev->discard_buffer) | 883 | if (!pcdev->discard_buffer) { |
884 | spin_unlock_irqrestore(&pcdev->lock, flags); | ||
882 | return -ENOMEM; | 885 | return -ENOMEM; |
886 | } | ||
883 | 887 | ||
884 | pcdev->buf_discard[0].discard = true; | 888 | pcdev->buf_discard[0].discard = true; |
885 | list_add_tail(&pcdev->buf_discard[0].queue, | 889 | list_add_tail(&pcdev->buf_discard[0].queue, |
@@ -1099,9 +1103,10 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) | |||
1099 | } | 1103 | } |
1100 | 1104 | ||
1101 | static int mx2_camera_set_crop(struct soc_camera_device *icd, | 1105 | static int mx2_camera_set_crop(struct soc_camera_device *icd, |
1102 | struct v4l2_crop *a) | 1106 | const struct v4l2_crop *a) |
1103 | { | 1107 | { |
1104 | struct v4l2_rect *rect = &a->c; | 1108 | struct v4l2_crop a_writable = *a; |
1109 | struct v4l2_rect *rect = &a_writable.c; | ||
1105 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 1110 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
1106 | struct v4l2_mbus_framefmt mf; | 1111 | struct v4l2_mbus_framefmt mf; |
1107 | int ret; | 1112 | int ret; |
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c index 3557ac97e430..261f6e9e1b17 100644 --- a/drivers/media/platform/soc_camera/mx3_camera.c +++ b/drivers/media/platform/soc_camera/mx3_camera.c | |||
@@ -799,9 +799,10 @@ static inline void stride_align(__u32 *width) | |||
799 | * default g_crop and cropcap from soc_camera.c | 799 | * default g_crop and cropcap from soc_camera.c |
800 | */ | 800 | */ |
801 | static int mx3_camera_set_crop(struct soc_camera_device *icd, | 801 | static int mx3_camera_set_crop(struct soc_camera_device *icd, |
802 | struct v4l2_crop *a) | 802 | const struct v4l2_crop *a) |
803 | { | 803 | { |
804 | struct v4l2_rect *rect = &a->c; | 804 | struct v4l2_crop a_writable = *a; |
805 | struct v4l2_rect *rect = &a_writable.c; | ||
805 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 806 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
806 | struct mx3_camera_dev *mx3_cam = ici->priv; | 807 | struct mx3_camera_dev *mx3_cam = ici->priv; |
807 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 808 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c index fa08c7695ccb..13636a585106 100644 --- a/drivers/media/platform/soc_camera/omap1_camera.c +++ b/drivers/media/platform/soc_camera/omap1_camera.c | |||
@@ -1215,9 +1215,9 @@ static int set_mbus_format(struct omap1_cam_dev *pcdev, struct device *dev, | |||
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | static int omap1_cam_set_crop(struct soc_camera_device *icd, | 1217 | static int omap1_cam_set_crop(struct soc_camera_device *icd, |
1218 | struct v4l2_crop *crop) | 1218 | const struct v4l2_crop *crop) |
1219 | { | 1219 | { |
1220 | struct v4l2_rect *rect = &crop->c; | 1220 | const struct v4l2_rect *rect = &crop->c; |
1221 | const struct soc_camera_format_xlate *xlate = icd->current_fmt; | 1221 | const struct soc_camera_format_xlate *xlate = icd->current_fmt; |
1222 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 1222 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
1223 | struct device *dev = icd->parent; | 1223 | struct device *dev = icd->parent; |
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c index 1e3776d08dac..3434ffe79c6e 100644 --- a/drivers/media/platform/soc_camera/pxa_camera.c +++ b/drivers/media/platform/soc_camera/pxa_camera.c | |||
@@ -1337,9 +1337,9 @@ static int pxa_camera_check_frame(u32 width, u32 height) | |||
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | static int pxa_camera_set_crop(struct soc_camera_device *icd, | 1339 | static int pxa_camera_set_crop(struct soc_camera_device *icd, |
1340 | struct v4l2_crop *a) | 1340 | const struct v4l2_crop *a) |
1341 | { | 1341 | { |
1342 | struct v4l2_rect *rect = &a->c; | 1342 | const struct v4l2_rect *rect = &a->c; |
1343 | struct device *dev = icd->parent; | 1343 | struct device *dev = icd->parent; |
1344 | struct soc_camera_host *ici = to_soc_camera_host(dev); | 1344 | struct soc_camera_host *ici = to_soc_camera_host(dev); |
1345 | struct pxa_camera_dev *pcdev = ici->priv; | 1345 | struct pxa_camera_dev *pcdev = ici->priv; |
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index 0a24253dcda2..2d8861c0e8f2 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | |||
@@ -1182,13 +1182,13 @@ static void sh_mobile_ceu_put_formats(struct soc_camera_device *icd) | |||
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | /* Check if any dimension of r1 is smaller than respective one of r2 */ | 1184 | /* Check if any dimension of r1 is smaller than respective one of r2 */ |
1185 | static bool is_smaller(struct v4l2_rect *r1, struct v4l2_rect *r2) | 1185 | static bool is_smaller(const struct v4l2_rect *r1, const struct v4l2_rect *r2) |
1186 | { | 1186 | { |
1187 | return r1->width < r2->width || r1->height < r2->height; | 1187 | return r1->width < r2->width || r1->height < r2->height; |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | /* Check if r1 fails to cover r2 */ | 1190 | /* Check if r1 fails to cover r2 */ |
1191 | static bool is_inside(struct v4l2_rect *r1, struct v4l2_rect *r2) | 1191 | static bool is_inside(const struct v4l2_rect *r1, const struct v4l2_rect *r2) |
1192 | { | 1192 | { |
1193 | return r1->left > r2->left || r1->top > r2->top || | 1193 | return r1->left > r2->left || r1->top > r2->top || |
1194 | r1->left + r1->width < r2->left + r2->width || | 1194 | r1->left + r1->width < r2->left + r2->width || |
@@ -1263,7 +1263,7 @@ static void update_subrect(struct sh_mobile_ceu_cam *cam) | |||
1263 | * 3. if (2) failed, try to request the maximum image | 1263 | * 3. if (2) failed, try to request the maximum image |
1264 | */ | 1264 | */ |
1265 | static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop, | 1265 | static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop, |
1266 | const struct v4l2_crop *cam_crop) | 1266 | struct v4l2_crop *cam_crop) |
1267 | { | 1267 | { |
1268 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 1268 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
1269 | struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c; | 1269 | struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c; |
@@ -1519,7 +1519,8 @@ static int client_scale(struct soc_camera_device *icd, | |||
1519 | static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd, | 1519 | static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd, |
1520 | const struct v4l2_crop *a) | 1520 | const struct v4l2_crop *a) |
1521 | { | 1521 | { |
1522 | struct v4l2_rect *rect = &a->c; | 1522 | struct v4l2_crop a_writable = *a; |
1523 | const struct v4l2_rect *rect = &a_writable.c; | ||
1523 | struct device *dev = icd->parent; | 1524 | struct device *dev = icd->parent; |
1524 | struct soc_camera_host *ici = to_soc_camera_host(dev); | 1525 | struct soc_camera_host *ici = to_soc_camera_host(dev); |
1525 | struct sh_mobile_ceu_dev *pcdev = ici->priv; | 1526 | struct sh_mobile_ceu_dev *pcdev = ici->priv; |
@@ -1545,7 +1546,7 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd, | |||
1545 | * 1. - 2. Apply iterative camera S_CROP for new input window, read back | 1546 | * 1. - 2. Apply iterative camera S_CROP for new input window, read back |
1546 | * actual camera rectangle. | 1547 | * actual camera rectangle. |
1547 | */ | 1548 | */ |
1548 | ret = client_s_crop(icd, a, &cam_crop); | 1549 | ret = client_s_crop(icd, &a_writable, &cam_crop); |
1549 | if (ret < 0) | 1550 | if (ret < 0) |
1550 | return ret; | 1551 | return ret; |
1551 | 1552 | ||
@@ -1946,7 +1947,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd, | |||
1946 | } | 1947 | } |
1947 | 1948 | ||
1948 | static int sh_mobile_ceu_set_livecrop(struct soc_camera_device *icd, | 1949 | static int sh_mobile_ceu_set_livecrop(struct soc_camera_device *icd, |
1949 | struct v4l2_crop *a) | 1950 | const struct v4l2_crop *a) |
1950 | { | 1951 | { |
1951 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 1952 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
1952 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 1953 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index 9859d2a2449b..ba51f65204de 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | |||
@@ -283,14 +283,13 @@ static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, | |||
283 | 283 | ||
284 | /* activate the pid on the device pid filter */ | 284 | /* activate the pid on the device pid filter */ |
285 | if (adap->props->caps & DVB_USB_ADAP_HAS_PID_FILTER && | 285 | if (adap->props->caps & DVB_USB_ADAP_HAS_PID_FILTER && |
286 | adap->pid_filtering && | 286 | adap->pid_filtering && adap->props->pid_filter) { |
287 | adap->props->pid_filter) | ||
288 | ret = adap->props->pid_filter(adap, dvbdmxfeed->index, | 287 | ret = adap->props->pid_filter(adap, dvbdmxfeed->index, |
289 | dvbdmxfeed->pid, (count == 1) ? 1 : 0); | 288 | dvbdmxfeed->pid, (count == 1) ? 1 : 0); |
290 | if (ret < 0) | 289 | if (ret < 0) |
291 | dev_err(&d->udev->dev, "%s: pid_filter() " \ | 290 | dev_err(&d->udev->dev, "%s: pid_filter() failed=%d\n", |
292 | "failed=%d\n", KBUILD_MODNAME, | 291 | KBUILD_MODNAME, ret); |
293 | ret); | 292 | } |
294 | 293 | ||
295 | /* start feeding if it is first pid */ | 294 | /* start feeding if it is first pid */ |
296 | if (adap->feed_count == 1 && count == 1) { | 295 | if (adap->feed_count == 1 && count == 1) { |
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c index 0431beed0ef4..5716662b4834 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c | |||
@@ -32,9 +32,7 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, | |||
32 | return -EINVAL; | 32 | return -EINVAL; |
33 | } | 33 | } |
34 | 34 | ||
35 | ret = mutex_lock_interruptible(&d->usb_mutex); | 35 | mutex_lock(&d->usb_mutex); |
36 | if (ret < 0) | ||
37 | return ret; | ||
38 | 36 | ||
39 | dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf); | 37 | dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf); |
40 | 38 | ||
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index adabba8d28bc..093f1acce403 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c | |||
@@ -1346,6 +1346,10 @@ static const struct usb_device_id rtl28xxu_id_table[] = { | |||
1346 | &rtl2832u_props, "DigitalNow Quad DVB-T Receiver", NULL) }, | 1346 | &rtl2832u_props, "DigitalNow Quad DVB-T Receiver", NULL) }, |
1347 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d3, | 1347 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d3, |
1348 | &rtl2832u_props, "TerraTec Cinergy T Stick RC (Rev. 3)", NULL) }, | 1348 | &rtl2832u_props, "TerraTec Cinergy T Stick RC (Rev. 3)", NULL) }, |
1349 | { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1102, | ||
1350 | &rtl2832u_props, "Dexatek DK mini DVB-T Dongle", NULL) }, | ||
1351 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d7, | ||
1352 | &rtl2832u_props, "TerraTec Cinergy T Stick+", NULL) }, | ||
1349 | { } | 1353 | { } |
1350 | }; | 1354 | }; |
1351 | MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); | 1355 | MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); |
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 1b48f2094806..f4f9bf84bc7b 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c | |||
@@ -98,9 +98,9 @@ static irqreturn_t arizona_underclocked(int irq, void *data) | |||
98 | 98 | ||
99 | if (val & ARIZONA_AIF3_UNDERCLOCKED_STS) | 99 | if (val & ARIZONA_AIF3_UNDERCLOCKED_STS) |
100 | dev_err(arizona->dev, "AIF3 underclocked\n"); | 100 | dev_err(arizona->dev, "AIF3 underclocked\n"); |
101 | if (val & ARIZONA_AIF3_UNDERCLOCKED_STS) | ||
102 | dev_err(arizona->dev, "AIF3 underclocked\n"); | ||
103 | if (val & ARIZONA_AIF2_UNDERCLOCKED_STS) | 101 | if (val & ARIZONA_AIF2_UNDERCLOCKED_STS) |
102 | dev_err(arizona->dev, "AIF2 underclocked\n"); | ||
103 | if (val & ARIZONA_AIF1_UNDERCLOCKED_STS) | ||
104 | dev_err(arizona->dev, "AIF1 underclocked\n"); | 104 | dev_err(arizona->dev, "AIF1 underclocked\n"); |
105 | if (val & ARIZONA_ISRC2_UNDERCLOCKED_STS) | 105 | if (val & ARIZONA_ISRC2_UNDERCLOCKED_STS) |
106 | dev_err(arizona->dev, "ISRC2 underclocked\n"); | 106 | dev_err(arizona->dev, "ISRC2 underclocked\n"); |
@@ -415,11 +415,19 @@ int __devinit arizona_dev_init(struct arizona *arizona) | |||
415 | 415 | ||
416 | /* If we have a /RESET GPIO we'll already be reset */ | 416 | /* If we have a /RESET GPIO we'll already be reset */ |
417 | if (!arizona->pdata.reset) { | 417 | if (!arizona->pdata.reset) { |
418 | regcache_mark_dirty(arizona->regmap); | ||
419 | |||
418 | ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0); | 420 | ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0); |
419 | if (ret != 0) { | 421 | if (ret != 0) { |
420 | dev_err(dev, "Failed to reset device: %d\n", ret); | 422 | dev_err(dev, "Failed to reset device: %d\n", ret); |
421 | goto err_reset; | 423 | goto err_reset; |
422 | } | 424 | } |
425 | |||
426 | ret = regcache_sync(arizona->regmap); | ||
427 | if (ret != 0) { | ||
428 | dev_err(dev, "Failed to sync device: %d\n", ret); | ||
429 | goto err_reset; | ||
430 | } | ||
423 | } | 431 | } |
424 | 432 | ||
425 | ret = arizona_wait_for_boot(arizona); | 433 | ret = arizona_wait_for_boot(arizona); |
@@ -520,7 +528,7 @@ int __devinit arizona_dev_init(struct arizona *arizona) | |||
520 | break; | 528 | break; |
521 | case WM5110: | 529 | case WM5110: |
522 | ret = mfd_add_devices(arizona->dev, -1, wm5110_devs, | 530 | ret = mfd_add_devices(arizona->dev, -1, wm5110_devs, |
523 | ARRAY_SIZE(wm5102_devs), NULL, 0, NULL); | 531 | ARRAY_SIZE(wm5110_devs), NULL, 0, NULL); |
524 | break; | 532 | break; |
525 | } | 533 | } |
526 | 534 | ||
diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c index ef0f2d001df2..b1b009177405 100644 --- a/drivers/mfd/arizona-irq.c +++ b/drivers/mfd/arizona-irq.c | |||
@@ -178,6 +178,7 @@ int arizona_irq_init(struct arizona *arizona) | |||
178 | 178 | ||
179 | switch (arizona->rev) { | 179 | switch (arizona->rev) { |
180 | case 0: | 180 | case 0: |
181 | case 1: | ||
181 | ctrlif_error = false; | 182 | ctrlif_error = false; |
182 | break; | 183 | break; |
183 | default: | 184 | default: |
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 4ae642320205..a071a8643a47 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c | |||
@@ -671,7 +671,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, | |||
671 | } | 671 | } |
672 | 672 | ||
673 | if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) { | 673 | if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) { |
674 | child = add_child(TWL6030_MODULE_ID1, "twl6030-pwm", NULL, 0, | 674 | child = add_child(SUB_CHIP_ID1, "twl6030-pwm", NULL, 0, |
675 | false, 0, 0); | 675 | false, 0, 0); |
676 | if (IS_ERR(child)) | 676 | if (IS_ERR(child)) |
677 | return PTR_ERR(child); | 677 | return PTR_ERR(child); |
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index ad733d76207a..cdd1173ed4e9 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c | |||
@@ -672,7 +672,8 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base) | |||
672 | irq = sih_mod + twl4030_irq_base; | 672 | irq = sih_mod + twl4030_irq_base; |
673 | irq_set_handler_data(irq, agent); | 673 | irq_set_handler_data(irq, agent); |
674 | agent->irq_name = kasprintf(GFP_KERNEL, "twl4030_%s", sih->name); | 674 | agent->irq_name = kasprintf(GFP_KERNEL, "twl4030_%s", sih->name); |
675 | status = request_threaded_irq(irq, NULL, handle_twl4030_sih, 0, | 675 | status = request_threaded_irq(irq, NULL, handle_twl4030_sih, |
676 | IRQF_EARLY_RESUME, | ||
676 | agent->irq_name ?: sih->name, NULL); | 677 | agent->irq_name ?: sih->name, NULL); |
677 | 678 | ||
678 | dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", sih->name, | 679 | dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", sih->name, |
diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c index 01b9255ed631..14490cc785d2 100644 --- a/drivers/mfd/wm5102-tables.c +++ b/drivers/mfd/wm5102-tables.c | |||
@@ -43,6 +43,7 @@ static const struct reg_default wm5102_reva_patch[] = { | |||
43 | { 0x479, 0x0A30 }, | 43 | { 0x479, 0x0A30 }, |
44 | { 0x47B, 0x0810 }, | 44 | { 0x47B, 0x0810 }, |
45 | { 0x47D, 0x0510 }, | 45 | { 0x47D, 0x0510 }, |
46 | { 0x4D1, 0x017F }, | ||
46 | { 0x500, 0x000D }, | 47 | { 0x500, 0x000D }, |
47 | { 0x507, 0x1820 }, | 48 | { 0x507, 0x1820 }, |
48 | { 0x508, 0x1820 }, | 49 | { 0x508, 0x1820 }, |
@@ -52,524 +53,6 @@ static const struct reg_default wm5102_reva_patch[] = { | |||
52 | { 0x580, 0x000D }, | 53 | { 0x580, 0x000D }, |
53 | { 0x587, 0x1820 }, | 54 | { 0x587, 0x1820 }, |
54 | { 0x588, 0x1820 }, | 55 | { 0x588, 0x1820 }, |
55 | { 0x101, 0x8140 }, | ||
56 | { 0x3000, 0x2225 }, | ||
57 | { 0x3001, 0x3a03 }, | ||
58 | { 0x3002, 0x0225 }, | ||
59 | { 0x3003, 0x0801 }, | ||
60 | { 0x3004, 0x6249 }, | ||
61 | { 0x3005, 0x0c04 }, | ||
62 | { 0x3006, 0x0225 }, | ||
63 | { 0x3007, 0x5901 }, | ||
64 | { 0x3008, 0xe249 }, | ||
65 | { 0x3009, 0x030d }, | ||
66 | { 0x300a, 0x0249 }, | ||
67 | { 0x300b, 0x2c01 }, | ||
68 | { 0x300c, 0xe249 }, | ||
69 | { 0x300d, 0x4342 }, | ||
70 | { 0x300e, 0xe249 }, | ||
71 | { 0x300f, 0x73c0 }, | ||
72 | { 0x3010, 0x4249 }, | ||
73 | { 0x3011, 0x0c00 }, | ||
74 | { 0x3012, 0x0225 }, | ||
75 | { 0x3013, 0x1f01 }, | ||
76 | { 0x3014, 0x0225 }, | ||
77 | { 0x3015, 0x1e01 }, | ||
78 | { 0x3016, 0x0225 }, | ||
79 | { 0x3017, 0xfa00 }, | ||
80 | { 0x3018, 0x0000 }, | ||
81 | { 0x3019, 0xf000 }, | ||
82 | { 0x301a, 0x0000 }, | ||
83 | { 0x301b, 0xf000 }, | ||
84 | { 0x301c, 0x0000 }, | ||
85 | { 0x301d, 0xf000 }, | ||
86 | { 0x301e, 0x0000 }, | ||
87 | { 0x301f, 0xf000 }, | ||
88 | { 0x3020, 0x0000 }, | ||
89 | { 0x3021, 0xf000 }, | ||
90 | { 0x3022, 0x0000 }, | ||
91 | { 0x3023, 0xf000 }, | ||
92 | { 0x3024, 0x0000 }, | ||
93 | { 0x3025, 0xf000 }, | ||
94 | { 0x3026, 0x0000 }, | ||
95 | { 0x3027, 0xf000 }, | ||
96 | { 0x3028, 0x0000 }, | ||
97 | { 0x3029, 0xf000 }, | ||
98 | { 0x302a, 0x0000 }, | ||
99 | { 0x302b, 0xf000 }, | ||
100 | { 0x302c, 0x0000 }, | ||
101 | { 0x302d, 0xf000 }, | ||
102 | { 0x302e, 0x0000 }, | ||
103 | { 0x302f, 0xf000 }, | ||
104 | { 0x3030, 0x0225 }, | ||
105 | { 0x3031, 0x1a01 }, | ||
106 | { 0x3032, 0x0225 }, | ||
107 | { 0x3033, 0x1e00 }, | ||
108 | { 0x3034, 0x0225 }, | ||
109 | { 0x3035, 0x1f00 }, | ||
110 | { 0x3036, 0x6225 }, | ||
111 | { 0x3037, 0xf800 }, | ||
112 | { 0x3038, 0x0000 }, | ||
113 | { 0x3039, 0xf000 }, | ||
114 | { 0x303a, 0x0000 }, | ||
115 | { 0x303b, 0xf000 }, | ||
116 | { 0x303c, 0x0000 }, | ||
117 | { 0x303d, 0xf000 }, | ||
118 | { 0x303e, 0x0000 }, | ||
119 | { 0x303f, 0xf000 }, | ||
120 | { 0x3040, 0x2226 }, | ||
121 | { 0x3041, 0x3a03 }, | ||
122 | { 0x3042, 0x0226 }, | ||
123 | { 0x3043, 0x0801 }, | ||
124 | { 0x3044, 0x6249 }, | ||
125 | { 0x3045, 0x0c06 }, | ||
126 | { 0x3046, 0x0226 }, | ||
127 | { 0x3047, 0x5901 }, | ||
128 | { 0x3048, 0xe249 }, | ||
129 | { 0x3049, 0x030d }, | ||
130 | { 0x304a, 0x0249 }, | ||
131 | { 0x304b, 0x2c01 }, | ||
132 | { 0x304c, 0xe249 }, | ||
133 | { 0x304d, 0x4342 }, | ||
134 | { 0x304e, 0xe249 }, | ||
135 | { 0x304f, 0x73c0 }, | ||
136 | { 0x3050, 0x4249 }, | ||
137 | { 0x3051, 0x0c00 }, | ||
138 | { 0x3052, 0x0226 }, | ||
139 | { 0x3053, 0x1f01 }, | ||
140 | { 0x3054, 0x0226 }, | ||
141 | { 0x3055, 0x1e01 }, | ||
142 | { 0x3056, 0x0226 }, | ||
143 | { 0x3057, 0xfa00 }, | ||
144 | { 0x3058, 0x0000 }, | ||
145 | { 0x3059, 0xf000 }, | ||
146 | { 0x305a, 0x0000 }, | ||
147 | { 0x305b, 0xf000 }, | ||
148 | { 0x305c, 0x0000 }, | ||
149 | { 0x305d, 0xf000 }, | ||
150 | { 0x305e, 0x0000 }, | ||
151 | { 0x305f, 0xf000 }, | ||
152 | { 0x3060, 0x0000 }, | ||
153 | { 0x3061, 0xf000 }, | ||
154 | { 0x3062, 0x0000 }, | ||
155 | { 0x3063, 0xf000 }, | ||
156 | { 0x3064, 0x0000 }, | ||
157 | { 0x3065, 0xf000 }, | ||
158 | { 0x3066, 0x0000 }, | ||
159 | { 0x3067, 0xf000 }, | ||
160 | { 0x3068, 0x0000 }, | ||
161 | { 0x3069, 0xf000 }, | ||
162 | { 0x306a, 0x0000 }, | ||
163 | { 0x306b, 0xf000 }, | ||
164 | { 0x306c, 0x0000 }, | ||
165 | { 0x306d, 0xf000 }, | ||
166 | { 0x306e, 0x0000 }, | ||
167 | { 0x306f, 0xf000 }, | ||
168 | { 0x3070, 0x0226 }, | ||
169 | { 0x3071, 0x1a01 }, | ||
170 | { 0x3072, 0x0226 }, | ||
171 | { 0x3073, 0x1e00 }, | ||
172 | { 0x3074, 0x0226 }, | ||
173 | { 0x3075, 0x1f00 }, | ||
174 | { 0x3076, 0x6226 }, | ||
175 | { 0x3077, 0xf800 }, | ||
176 | { 0x3078, 0x0000 }, | ||
177 | { 0x3079, 0xf000 }, | ||
178 | { 0x307a, 0x0000 }, | ||
179 | { 0x307b, 0xf000 }, | ||
180 | { 0x307c, 0x0000 }, | ||
181 | { 0x307d, 0xf000 }, | ||
182 | { 0x307e, 0x0000 }, | ||
183 | { 0x307f, 0xf000 }, | ||
184 | { 0x3080, 0x2227 }, | ||
185 | { 0x3081, 0x3a03 }, | ||
186 | { 0x3082, 0x0227 }, | ||
187 | { 0x3083, 0x0801 }, | ||
188 | { 0x3084, 0x6255 }, | ||
189 | { 0x3085, 0x0c04 }, | ||
190 | { 0x3086, 0x0227 }, | ||
191 | { 0x3087, 0x5901 }, | ||
192 | { 0x3088, 0xe255 }, | ||
193 | { 0x3089, 0x030d }, | ||
194 | { 0x308a, 0x0255 }, | ||
195 | { 0x308b, 0x2c01 }, | ||
196 | { 0x308c, 0xe255 }, | ||
197 | { 0x308d, 0x4342 }, | ||
198 | { 0x308e, 0xe255 }, | ||
199 | { 0x308f, 0x73c0 }, | ||
200 | { 0x3090, 0x4255 }, | ||
201 | { 0x3091, 0x0c00 }, | ||
202 | { 0x3092, 0x0227 }, | ||
203 | { 0x3093, 0x1f01 }, | ||
204 | { 0x3094, 0x0227 }, | ||
205 | { 0x3095, 0x1e01 }, | ||
206 | { 0x3096, 0x0227 }, | ||
207 | { 0x3097, 0xfa00 }, | ||
208 | { 0x3098, 0x0000 }, | ||
209 | { 0x3099, 0xf000 }, | ||
210 | { 0x309a, 0x0000 }, | ||
211 | { 0x309b, 0xf000 }, | ||
212 | { 0x309c, 0x0000 }, | ||
213 | { 0x309d, 0xf000 }, | ||
214 | { 0x309e, 0x0000 }, | ||
215 | { 0x309f, 0xf000 }, | ||
216 | { 0x30a0, 0x0000 }, | ||
217 | { 0x30a1, 0xf000 }, | ||
218 | { 0x30a2, 0x0000 }, | ||
219 | { 0x30a3, 0xf000 }, | ||
220 | { 0x30a4, 0x0000 }, | ||
221 | { 0x30a5, 0xf000 }, | ||
222 | { 0x30a6, 0x0000 }, | ||
223 | { 0x30a7, 0xf000 }, | ||
224 | { 0x30a8, 0x0000 }, | ||
225 | { 0x30a9, 0xf000 }, | ||
226 | { 0x30aa, 0x0000 }, | ||
227 | { 0x30ab, 0xf000 }, | ||
228 | { 0x30ac, 0x0000 }, | ||
229 | { 0x30ad, 0xf000 }, | ||
230 | { 0x30ae, 0x0000 }, | ||
231 | { 0x30af, 0xf000 }, | ||
232 | { 0x30b0, 0x0227 }, | ||
233 | { 0x30b1, 0x1a01 }, | ||
234 | { 0x30b2, 0x0227 }, | ||
235 | { 0x30b3, 0x1e00 }, | ||
236 | { 0x30b4, 0x0227 }, | ||
237 | { 0x30b5, 0x1f00 }, | ||
238 | { 0x30b6, 0x6227 }, | ||
239 | { 0x30b7, 0xf800 }, | ||
240 | { 0x30b8, 0x0000 }, | ||
241 | { 0x30b9, 0xf000 }, | ||
242 | { 0x30ba, 0x0000 }, | ||
243 | { 0x30bb, 0xf000 }, | ||
244 | { 0x30bc, 0x0000 }, | ||
245 | { 0x30bd, 0xf000 }, | ||
246 | { 0x30be, 0x0000 }, | ||
247 | { 0x30bf, 0xf000 }, | ||
248 | { 0x30c0, 0x2228 }, | ||
249 | { 0x30c1, 0x3a03 }, | ||
250 | { 0x30c2, 0x0228 }, | ||
251 | { 0x30c3, 0x0801 }, | ||
252 | { 0x30c4, 0x6255 }, | ||
253 | { 0x30c5, 0x0c06 }, | ||
254 | { 0x30c6, 0x0228 }, | ||
255 | { 0x30c7, 0x5901 }, | ||
256 | { 0x30c8, 0xe255 }, | ||
257 | { 0x30c9, 0x030d }, | ||
258 | { 0x30ca, 0x0255 }, | ||
259 | { 0x30cb, 0x2c01 }, | ||
260 | { 0x30cc, 0xe255 }, | ||
261 | { 0x30cd, 0x4342 }, | ||
262 | { 0x30ce, 0xe255 }, | ||
263 | { 0x30cf, 0x73c0 }, | ||
264 | { 0x30d0, 0x4255 }, | ||
265 | { 0x30d1, 0x0c00 }, | ||
266 | { 0x30d2, 0x0228 }, | ||
267 | { 0x30d3, 0x1f01 }, | ||
268 | { 0x30d4, 0x0228 }, | ||
269 | { 0x30d5, 0x1e01 }, | ||
270 | { 0x30d6, 0x0228 }, | ||
271 | { 0x30d7, 0xfa00 }, | ||
272 | { 0x30d8, 0x0000 }, | ||
273 | { 0x30d9, 0xf000 }, | ||
274 | { 0x30da, 0x0000 }, | ||
275 | { 0x30db, 0xf000 }, | ||
276 | { 0x30dc, 0x0000 }, | ||
277 | { 0x30dd, 0xf000 }, | ||
278 | { 0x30de, 0x0000 }, | ||
279 | { 0x30df, 0xf000 }, | ||
280 | { 0x30e0, 0x0000 }, | ||
281 | { 0x30e1, 0xf000 }, | ||
282 | { 0x30e2, 0x0000 }, | ||
283 | { 0x30e3, 0xf000 }, | ||
284 | { 0x30e4, 0x0000 }, | ||
285 | { 0x30e5, 0xf000 }, | ||
286 | { 0x30e6, 0x0000 }, | ||
287 | { 0x30e7, 0xf000 }, | ||
288 | { 0x30e8, 0x0000 }, | ||
289 | { 0x30e9, 0xf000 }, | ||
290 | { 0x30ea, 0x0000 }, | ||
291 | { 0x30eb, 0xf000 }, | ||
292 | { 0x30ec, 0x0000 }, | ||
293 | { 0x30ed, 0xf000 }, | ||
294 | { 0x30ee, 0x0000 }, | ||
295 | { 0x30ef, 0xf000 }, | ||
296 | { 0x30f0, 0x0228 }, | ||
297 | { 0x30f1, 0x1a01 }, | ||
298 | { 0x30f2, 0x0228 }, | ||
299 | { 0x30f3, 0x1e00 }, | ||
300 | { 0x30f4, 0x0228 }, | ||
301 | { 0x30f5, 0x1f00 }, | ||
302 | { 0x30f6, 0x6228 }, | ||
303 | { 0x30f7, 0xf800 }, | ||
304 | { 0x30f8, 0x0000 }, | ||
305 | { 0x30f9, 0xf000 }, | ||
306 | { 0x30fa, 0x0000 }, | ||
307 | { 0x30fb, 0xf000 }, | ||
308 | { 0x30fc, 0x0000 }, | ||
309 | { 0x30fd, 0xf000 }, | ||
310 | { 0x30fe, 0x0000 }, | ||
311 | { 0x30ff, 0xf000 }, | ||
312 | { 0x3100, 0x222b }, | ||
313 | { 0x3101, 0x3a03 }, | ||
314 | { 0x3102, 0x222b }, | ||
315 | { 0x3103, 0x5803 }, | ||
316 | { 0x3104, 0xe26f }, | ||
317 | { 0x3105, 0x030d }, | ||
318 | { 0x3106, 0x626f }, | ||
319 | { 0x3107, 0x2c01 }, | ||
320 | { 0x3108, 0xe26f }, | ||
321 | { 0x3109, 0x4342 }, | ||
322 | { 0x310a, 0xe26f }, | ||
323 | { 0x310b, 0x73c0 }, | ||
324 | { 0x310c, 0x026f }, | ||
325 | { 0x310d, 0x0c00 }, | ||
326 | { 0x310e, 0x022b }, | ||
327 | { 0x310f, 0x1f01 }, | ||
328 | { 0x3110, 0x022b }, | ||
329 | { 0x3111, 0x1e01 }, | ||
330 | { 0x3112, 0x022b }, | ||
331 | { 0x3113, 0xfa00 }, | ||
332 | { 0x3114, 0x0000 }, | ||
333 | { 0x3115, 0xf000 }, | ||
334 | { 0x3116, 0x0000 }, | ||
335 | { 0x3117, 0xf000 }, | ||
336 | { 0x3118, 0x0000 }, | ||
337 | { 0x3119, 0xf000 }, | ||
338 | { 0x311a, 0x0000 }, | ||
339 | { 0x311b, 0xf000 }, | ||
340 | { 0x311c, 0x0000 }, | ||
341 | { 0x311d, 0xf000 }, | ||
342 | { 0x311e, 0x0000 }, | ||
343 | { 0x311f, 0xf000 }, | ||
344 | { 0x3120, 0x022b }, | ||
345 | { 0x3121, 0x0a01 }, | ||
346 | { 0x3122, 0x022b }, | ||
347 | { 0x3123, 0x1e00 }, | ||
348 | { 0x3124, 0x022b }, | ||
349 | { 0x3125, 0x1f00 }, | ||
350 | { 0x3126, 0x622b }, | ||
351 | { 0x3127, 0xf800 }, | ||
352 | { 0x3128, 0x0000 }, | ||
353 | { 0x3129, 0xf000 }, | ||
354 | { 0x312a, 0x0000 }, | ||
355 | { 0x312b, 0xf000 }, | ||
356 | { 0x312c, 0x0000 }, | ||
357 | { 0x312d, 0xf000 }, | ||
358 | { 0x312e, 0x0000 }, | ||
359 | { 0x312f, 0xf000 }, | ||
360 | { 0x3130, 0x0000 }, | ||
361 | { 0x3131, 0xf000 }, | ||
362 | { 0x3132, 0x0000 }, | ||
363 | { 0x3133, 0xf000 }, | ||
364 | { 0x3134, 0x0000 }, | ||
365 | { 0x3135, 0xf000 }, | ||
366 | { 0x3136, 0x0000 }, | ||
367 | { 0x3137, 0xf000 }, | ||
368 | { 0x3138, 0x0000 }, | ||
369 | { 0x3139, 0xf000 }, | ||
370 | { 0x313a, 0x0000 }, | ||
371 | { 0x313b, 0xf000 }, | ||
372 | { 0x313c, 0x0000 }, | ||
373 | { 0x313d, 0xf000 }, | ||
374 | { 0x313e, 0x0000 }, | ||
375 | { 0x313f, 0xf000 }, | ||
376 | { 0x3140, 0x0000 }, | ||
377 | { 0x3141, 0xf000 }, | ||
378 | { 0x3142, 0x0000 }, | ||
379 | { 0x3143, 0xf000 }, | ||
380 | { 0x3144, 0x0000 }, | ||
381 | { 0x3145, 0xf000 }, | ||
382 | { 0x3146, 0x0000 }, | ||
383 | { 0x3147, 0xf000 }, | ||
384 | { 0x3148, 0x0000 }, | ||
385 | { 0x3149, 0xf000 }, | ||
386 | { 0x314a, 0x0000 }, | ||
387 | { 0x314b, 0xf000 }, | ||
388 | { 0x314c, 0x0000 }, | ||
389 | { 0x314d, 0xf000 }, | ||
390 | { 0x314e, 0x0000 }, | ||
391 | { 0x314f, 0xf000 }, | ||
392 | { 0x3150, 0x0000 }, | ||
393 | { 0x3151, 0xf000 }, | ||
394 | { 0x3152, 0x0000 }, | ||
395 | { 0x3153, 0xf000 }, | ||
396 | { 0x3154, 0x0000 }, | ||
397 | { 0x3155, 0xf000 }, | ||
398 | { 0x3156, 0x0000 }, | ||
399 | { 0x3157, 0xf000 }, | ||
400 | { 0x3158, 0x0000 }, | ||
401 | { 0x3159, 0xf000 }, | ||
402 | { 0x315a, 0x0000 }, | ||
403 | { 0x315b, 0xf000 }, | ||
404 | { 0x315c, 0x0000 }, | ||
405 | { 0x315d, 0xf000 }, | ||
406 | { 0x315e, 0x0000 }, | ||
407 | { 0x315f, 0xf000 }, | ||
408 | { 0x3160, 0x0000 }, | ||
409 | { 0x3161, 0xf000 }, | ||
410 | { 0x3162, 0x0000 }, | ||
411 | { 0x3163, 0xf000 }, | ||
412 | { 0x3164, 0x0000 }, | ||
413 | { 0x3165, 0xf000 }, | ||
414 | { 0x3166, 0x0000 }, | ||
415 | { 0x3167, 0xf000 }, | ||
416 | { 0x3168, 0x0000 }, | ||
417 | { 0x3169, 0xf000 }, | ||
418 | { 0x316a, 0x0000 }, | ||
419 | { 0x316b, 0xf000 }, | ||
420 | { 0x316c, 0x0000 }, | ||
421 | { 0x316d, 0xf000 }, | ||
422 | { 0x316e, 0x0000 }, | ||
423 | { 0x316f, 0xf000 }, | ||
424 | { 0x3170, 0x0000 }, | ||
425 | { 0x3171, 0xf000 }, | ||
426 | { 0x3172, 0x0000 }, | ||
427 | { 0x3173, 0xf000 }, | ||
428 | { 0x3174, 0x0000 }, | ||
429 | { 0x3175, 0xf000 }, | ||
430 | { 0x3176, 0x0000 }, | ||
431 | { 0x3177, 0xf000 }, | ||
432 | { 0x3178, 0x0000 }, | ||
433 | { 0x3179, 0xf000 }, | ||
434 | { 0x317a, 0x0000 }, | ||
435 | { 0x317b, 0xf000 }, | ||
436 | { 0x317c, 0x0000 }, | ||
437 | { 0x317d, 0xf000 }, | ||
438 | { 0x317e, 0x0000 }, | ||
439 | { 0x317f, 0xf000 }, | ||
440 | { 0x3180, 0x2001 }, | ||
441 | { 0x3181, 0xf101 }, | ||
442 | { 0x3182, 0x0000 }, | ||
443 | { 0x3183, 0xf000 }, | ||
444 | { 0x3184, 0x0000 }, | ||
445 | { 0x3185, 0xf000 }, | ||
446 | { 0x3186, 0x0000 }, | ||
447 | { 0x3187, 0xf000 }, | ||
448 | { 0x3188, 0x0000 }, | ||
449 | { 0x3189, 0xf000 }, | ||
450 | { 0x318a, 0x0000 }, | ||
451 | { 0x318b, 0xf000 }, | ||
452 | { 0x318c, 0x0000 }, | ||
453 | { 0x318d, 0xf000 }, | ||
454 | { 0x318e, 0x0000 }, | ||
455 | { 0x318f, 0xf000 }, | ||
456 | { 0x3190, 0x0000 }, | ||
457 | { 0x3191, 0xf000 }, | ||
458 | { 0x3192, 0x0000 }, | ||
459 | { 0x3193, 0xf000 }, | ||
460 | { 0x3194, 0x0000 }, | ||
461 | { 0x3195, 0xf000 }, | ||
462 | { 0x3196, 0x0000 }, | ||
463 | { 0x3197, 0xf000 }, | ||
464 | { 0x3198, 0x0000 }, | ||
465 | { 0x3199, 0xf000 }, | ||
466 | { 0x319a, 0x0000 }, | ||
467 | { 0x319b, 0xf000 }, | ||
468 | { 0x319c, 0x0000 }, | ||
469 | { 0x319d, 0xf000 }, | ||
470 | { 0x319e, 0x0000 }, | ||
471 | { 0x319f, 0xf000 }, | ||
472 | { 0x31a0, 0x0000 }, | ||
473 | { 0x31a1, 0xf000 }, | ||
474 | { 0x31a2, 0x0000 }, | ||
475 | { 0x31a3, 0xf000 }, | ||
476 | { 0x31a4, 0x0000 }, | ||
477 | { 0x31a5, 0xf000 }, | ||
478 | { 0x31a6, 0x0000 }, | ||
479 | { 0x31a7, 0xf000 }, | ||
480 | { 0x31a8, 0x0000 }, | ||
481 | { 0x31a9, 0xf000 }, | ||
482 | { 0x31aa, 0x0000 }, | ||
483 | { 0x31ab, 0xf000 }, | ||
484 | { 0x31ac, 0x0000 }, | ||
485 | { 0x31ad, 0xf000 }, | ||
486 | { 0x31ae, 0x0000 }, | ||
487 | { 0x31af, 0xf000 }, | ||
488 | { 0x31b0, 0x0000 }, | ||
489 | { 0x31b1, 0xf000 }, | ||
490 | { 0x31b2, 0x0000 }, | ||
491 | { 0x31b3, 0xf000 }, | ||
492 | { 0x31b4, 0x0000 }, | ||
493 | { 0x31b5, 0xf000 }, | ||
494 | { 0x31b6, 0x0000 }, | ||
495 | { 0x31b7, 0xf000 }, | ||
496 | { 0x31b8, 0x0000 }, | ||
497 | { 0x31b9, 0xf000 }, | ||
498 | { 0x31ba, 0x0000 }, | ||
499 | { 0x31bb, 0xf000 }, | ||
500 | { 0x31bc, 0x0000 }, | ||
501 | { 0x31bd, 0xf000 }, | ||
502 | { 0x31be, 0x0000 }, | ||
503 | { 0x31bf, 0xf000 }, | ||
504 | { 0x31c0, 0x0000 }, | ||
505 | { 0x31c1, 0xf000 }, | ||
506 | { 0x31c2, 0x0000 }, | ||
507 | { 0x31c3, 0xf000 }, | ||
508 | { 0x31c4, 0x0000 }, | ||
509 | { 0x31c5, 0xf000 }, | ||
510 | { 0x31c6, 0x0000 }, | ||
511 | { 0x31c7, 0xf000 }, | ||
512 | { 0x31c8, 0x0000 }, | ||
513 | { 0x31c9, 0xf000 }, | ||
514 | { 0x31ca, 0x0000 }, | ||
515 | { 0x31cb, 0xf000 }, | ||
516 | { 0x31cc, 0x0000 }, | ||
517 | { 0x31cd, 0xf000 }, | ||
518 | { 0x31ce, 0x0000 }, | ||
519 | { 0x31cf, 0xf000 }, | ||
520 | { 0x31d0, 0x0000 }, | ||
521 | { 0x31d1, 0xf000 }, | ||
522 | { 0x31d2, 0x0000 }, | ||
523 | { 0x31d3, 0xf000 }, | ||
524 | { 0x31d4, 0x0000 }, | ||
525 | { 0x31d5, 0xf000 }, | ||
526 | { 0x31d6, 0x0000 }, | ||
527 | { 0x31d7, 0xf000 }, | ||
528 | { 0x31d8, 0x0000 }, | ||
529 | { 0x31d9, 0xf000 }, | ||
530 | { 0x31da, 0x0000 }, | ||
531 | { 0x31db, 0xf000 }, | ||
532 | { 0x31dc, 0x0000 }, | ||
533 | { 0x31dd, 0xf000 }, | ||
534 | { 0x31de, 0x0000 }, | ||
535 | { 0x31df, 0xf000 }, | ||
536 | { 0x31e0, 0x0000 }, | ||
537 | { 0x31e1, 0xf000 }, | ||
538 | { 0x31e2, 0x0000 }, | ||
539 | { 0x31e3, 0xf000 }, | ||
540 | { 0x31e4, 0x0000 }, | ||
541 | { 0x31e5, 0xf000 }, | ||
542 | { 0x31e6, 0x0000 }, | ||
543 | { 0x31e7, 0xf000 }, | ||
544 | { 0x31e8, 0x0000 }, | ||
545 | { 0x31e9, 0xf000 }, | ||
546 | { 0x31ea, 0x0000 }, | ||
547 | { 0x31eb, 0xf000 }, | ||
548 | { 0x31ec, 0x0000 }, | ||
549 | { 0x31ed, 0xf000 }, | ||
550 | { 0x31ee, 0x0000 }, | ||
551 | { 0x31ef, 0xf000 }, | ||
552 | { 0x31f0, 0x0000 }, | ||
553 | { 0x31f1, 0xf000 }, | ||
554 | { 0x31f2, 0x0000 }, | ||
555 | { 0x31f3, 0xf000 }, | ||
556 | { 0x31f4, 0x0000 }, | ||
557 | { 0x31f5, 0xf000 }, | ||
558 | { 0x31f6, 0x0000 }, | ||
559 | { 0x31f7, 0xf000 }, | ||
560 | { 0x31f8, 0x0000 }, | ||
561 | { 0x31f9, 0xf000 }, | ||
562 | { 0x31fa, 0x0000 }, | ||
563 | { 0x31fb, 0xf000 }, | ||
564 | { 0x31fc, 0x0000 }, | ||
565 | { 0x31fd, 0xf000 }, | ||
566 | { 0x31fe, 0x0000 }, | ||
567 | { 0x31ff, 0xf000 }, | ||
568 | { 0x024d, 0xff50 }, | ||
569 | { 0x0252, 0xff50 }, | ||
570 | { 0x0259, 0x0112 }, | ||
571 | { 0x025e, 0x0112 }, | ||
572 | { 0x101, 0x0304 }, | ||
573 | { 0x80, 0x0000 }, | 56 | { 0x80, 0x0000 }, |
574 | }; | 57 | }; |
575 | 58 | ||
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 172a768036d8..21056b9ef0a0 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -57,6 +57,7 @@ MODULE_ALIAS("mmc:block"); | |||
57 | #define INAND_CMD38_ARG_SECERASE 0x80 | 57 | #define INAND_CMD38_ARG_SECERASE 0x80 |
58 | #define INAND_CMD38_ARG_SECTRIM1 0x81 | 58 | #define INAND_CMD38_ARG_SECTRIM1 0x81 |
59 | #define INAND_CMD38_ARG_SECTRIM2 0x88 | 59 | #define INAND_CMD38_ARG_SECTRIM2 0x88 |
60 | #define MMC_BLK_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ | ||
60 | 61 | ||
61 | static DEFINE_MUTEX(block_mutex); | 62 | static DEFINE_MUTEX(block_mutex); |
62 | 63 | ||
@@ -126,6 +127,10 @@ enum mmc_blk_status { | |||
126 | module_param(perdev_minors, int, 0444); | 127 | module_param(perdev_minors, int, 0444); |
127 | MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device"); | 128 | MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device"); |
128 | 129 | ||
130 | static inline int mmc_blk_part_switch(struct mmc_card *card, | ||
131 | struct mmc_blk_data *md); | ||
132 | static int get_card_status(struct mmc_card *card, u32 *status, int retries); | ||
133 | |||
129 | static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) | 134 | static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) |
130 | { | 135 | { |
131 | struct mmc_blk_data *md; | 136 | struct mmc_blk_data *md; |
@@ -357,6 +362,38 @@ out: | |||
357 | return ERR_PTR(err); | 362 | return ERR_PTR(err); |
358 | } | 363 | } |
359 | 364 | ||
365 | static int ioctl_rpmb_card_status_poll(struct mmc_card *card, u32 *status, | ||
366 | u32 retries_max) | ||
367 | { | ||
368 | int err; | ||
369 | u32 retry_count = 0; | ||
370 | |||
371 | if (!status || !retries_max) | ||
372 | return -EINVAL; | ||
373 | |||
374 | do { | ||
375 | err = get_card_status(card, status, 5); | ||
376 | if (err) | ||
377 | break; | ||
378 | |||
379 | if (!R1_STATUS(*status) && | ||
380 | (R1_CURRENT_STATE(*status) != R1_STATE_PRG)) | ||
381 | break; /* RPMB programming operation complete */ | ||
382 | |||
383 | /* | ||
384 | * Rechedule to give the MMC device a chance to continue | ||
385 | * processing the previous command without being polled too | ||
386 | * frequently. | ||
387 | */ | ||
388 | usleep_range(1000, 5000); | ||
389 | } while (++retry_count < retries_max); | ||
390 | |||
391 | if (retry_count == retries_max) | ||
392 | err = -EPERM; | ||
393 | |||
394 | return err; | ||
395 | } | ||
396 | |||
360 | static int mmc_blk_ioctl_cmd(struct block_device *bdev, | 397 | static int mmc_blk_ioctl_cmd(struct block_device *bdev, |
361 | struct mmc_ioc_cmd __user *ic_ptr) | 398 | struct mmc_ioc_cmd __user *ic_ptr) |
362 | { | 399 | { |
@@ -368,6 +405,8 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, | |||
368 | struct mmc_request mrq = {NULL}; | 405 | struct mmc_request mrq = {NULL}; |
369 | struct scatterlist sg; | 406 | struct scatterlist sg; |
370 | int err; | 407 | int err; |
408 | int is_rpmb = false; | ||
409 | u32 status = 0; | ||
371 | 410 | ||
372 | /* | 411 | /* |
373 | * The caller must have CAP_SYS_RAWIO, and must be calling this on the | 412 | * The caller must have CAP_SYS_RAWIO, and must be calling this on the |
@@ -387,6 +426,9 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, | |||
387 | goto cmd_err; | 426 | goto cmd_err; |
388 | } | 427 | } |
389 | 428 | ||
429 | if (md->area_type & MMC_BLK_DATA_AREA_RPMB) | ||
430 | is_rpmb = true; | ||
431 | |||
390 | card = md->queue.card; | 432 | card = md->queue.card; |
391 | if (IS_ERR(card)) { | 433 | if (IS_ERR(card)) { |
392 | err = PTR_ERR(card); | 434 | err = PTR_ERR(card); |
@@ -437,12 +479,23 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, | |||
437 | 479 | ||
438 | mmc_claim_host(card->host); | 480 | mmc_claim_host(card->host); |
439 | 481 | ||
482 | err = mmc_blk_part_switch(card, md); | ||
483 | if (err) | ||
484 | goto cmd_rel_host; | ||
485 | |||
440 | if (idata->ic.is_acmd) { | 486 | if (idata->ic.is_acmd) { |
441 | err = mmc_app_cmd(card->host, card); | 487 | err = mmc_app_cmd(card->host, card); |
442 | if (err) | 488 | if (err) |
443 | goto cmd_rel_host; | 489 | goto cmd_rel_host; |
444 | } | 490 | } |
445 | 491 | ||
492 | if (is_rpmb) { | ||
493 | err = mmc_set_blockcount(card, data.blocks, | ||
494 | idata->ic.write_flag & (1 << 31)); | ||
495 | if (err) | ||
496 | goto cmd_rel_host; | ||
497 | } | ||
498 | |||
446 | mmc_wait_for_req(card->host, &mrq); | 499 | mmc_wait_for_req(card->host, &mrq); |
447 | 500 | ||
448 | if (cmd.error) { | 501 | if (cmd.error) { |
@@ -478,6 +531,18 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, | |||
478 | } | 531 | } |
479 | } | 532 | } |
480 | 533 | ||
534 | if (is_rpmb) { | ||
535 | /* | ||
536 | * Ensure RPMB command has completed by polling CMD13 | ||
537 | * "Send Status". | ||
538 | */ | ||
539 | err = ioctl_rpmb_card_status_poll(card, &status, 5); | ||
540 | if (err) | ||
541 | dev_err(mmc_dev(card->host), | ||
542 | "%s: Card Status=0x%08X, error %d\n", | ||
543 | __func__, status, err); | ||
544 | } | ||
545 | |||
481 | cmd_rel_host: | 546 | cmd_rel_host: |
482 | mmc_release_host(card->host); | 547 | mmc_release_host(card->host); |
483 | 548 | ||
@@ -1034,6 +1099,9 @@ static int mmc_blk_err_check(struct mmc_card *card, | |||
1034 | */ | 1099 | */ |
1035 | if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { | 1100 | if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { |
1036 | u32 status; | 1101 | u32 status; |
1102 | unsigned long timeout; | ||
1103 | |||
1104 | timeout = jiffies + msecs_to_jiffies(MMC_BLK_TIMEOUT_MS); | ||
1037 | do { | 1105 | do { |
1038 | int err = get_card_status(card, &status, 5); | 1106 | int err = get_card_status(card, &status, 5); |
1039 | if (err) { | 1107 | if (err) { |
@@ -1041,6 +1109,17 @@ static int mmc_blk_err_check(struct mmc_card *card, | |||
1041 | req->rq_disk->disk_name, err); | 1109 | req->rq_disk->disk_name, err); |
1042 | return MMC_BLK_CMD_ERR; | 1110 | return MMC_BLK_CMD_ERR; |
1043 | } | 1111 | } |
1112 | |||
1113 | /* Timeout if the device never becomes ready for data | ||
1114 | * and never leaves the program state. | ||
1115 | */ | ||
1116 | if (time_after(jiffies, timeout)) { | ||
1117 | pr_err("%s: Card stuck in programming state!"\ | ||
1118 | " %s %s\n", mmc_hostname(card->host), | ||
1119 | req->rq_disk->disk_name, __func__); | ||
1120 | |||
1121 | return MMC_BLK_CMD_ERR; | ||
1122 | } | ||
1044 | /* | 1123 | /* |
1045 | * Some cards mishandle the status bits, | 1124 | * Some cards mishandle the status bits, |
1046 | * so make sure to check both the busy | 1125 | * so make sure to check both the busy |
@@ -1504,6 +1583,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, | |||
1504 | md->disk->queue = md->queue.queue; | 1583 | md->disk->queue = md->queue.queue; |
1505 | md->disk->driverfs_dev = parent; | 1584 | md->disk->driverfs_dev = parent; |
1506 | set_disk_ro(md->disk, md->read_only || default_ro); | 1585 | set_disk_ro(md->disk, md->read_only || default_ro); |
1586 | if (area_type & MMC_BLK_DATA_AREA_RPMB) | ||
1587 | md->disk->flags |= GENHD_FL_NO_PART_SCAN; | ||
1507 | 1588 | ||
1508 | /* | 1589 | /* |
1509 | * As discussed on lkml, GENHD_FL_REMOVABLE should: | 1590 | * As discussed on lkml, GENHD_FL_REMOVABLE should: |
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index e360a979857d..fadf52eb5d70 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c | |||
@@ -68,6 +68,16 @@ static int mmc_queue_thread(void *d) | |||
68 | if (req || mq->mqrq_prev->req) { | 68 | if (req || mq->mqrq_prev->req) { |
69 | set_current_state(TASK_RUNNING); | 69 | set_current_state(TASK_RUNNING); |
70 | mq->issue_fn(mq, req); | 70 | mq->issue_fn(mq, req); |
71 | |||
72 | /* | ||
73 | * Current request becomes previous request | ||
74 | * and vice versa. | ||
75 | */ | ||
76 | mq->mqrq_prev->brq.mrq.data = NULL; | ||
77 | mq->mqrq_prev->req = NULL; | ||
78 | tmp = mq->mqrq_prev; | ||
79 | mq->mqrq_prev = mq->mqrq_cur; | ||
80 | mq->mqrq_cur = tmp; | ||
71 | } else { | 81 | } else { |
72 | if (kthread_should_stop()) { | 82 | if (kthread_should_stop()) { |
73 | set_current_state(TASK_RUNNING); | 83 | set_current_state(TASK_RUNNING); |
@@ -77,13 +87,6 @@ static int mmc_queue_thread(void *d) | |||
77 | schedule(); | 87 | schedule(); |
78 | down(&mq->thread_sem); | 88 | down(&mq->thread_sem); |
79 | } | 89 | } |
80 | |||
81 | /* Current request becomes previous request and vice versa. */ | ||
82 | mq->mqrq_prev->brq.mrq.data = NULL; | ||
83 | mq->mqrq_prev->req = NULL; | ||
84 | tmp = mq->mqrq_prev; | ||
85 | mq->mqrq_prev = mq->mqrq_cur; | ||
86 | mq->mqrq_cur = tmp; | ||
87 | } while (1); | 90 | } while (1); |
88 | up(&mq->thread_sem); | 91 | up(&mq->thread_sem); |
89 | 92 | ||
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 9b68933f27e7..420cb6753c1e 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c | |||
@@ -225,8 +225,7 @@ static void mmc_release_card(struct device *dev) | |||
225 | 225 | ||
226 | sdio_free_common_cis(card); | 226 | sdio_free_common_cis(card); |
227 | 227 | ||
228 | if (card->info) | 228 | kfree(card->info); |
229 | kfree(card->info); | ||
230 | 229 | ||
231 | kfree(card); | 230 | kfree(card); |
232 | } | 231 | } |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 06c42cfb7c34..aaed7687cf09 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -42,6 +42,9 @@ | |||
42 | #include "sd_ops.h" | 42 | #include "sd_ops.h" |
43 | #include "sdio_ops.h" | 43 | #include "sdio_ops.h" |
44 | 44 | ||
45 | /* If the device is not responding */ | ||
46 | #define MMC_CORE_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ | ||
47 | |||
45 | /* | 48 | /* |
46 | * Background operations can take a long time, depending on the housekeeping | 49 | * Background operations can take a long time, depending on the housekeeping |
47 | * operations the card has to perform. | 50 | * operations the card has to perform. |
@@ -1631,6 +1634,7 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, | |||
1631 | { | 1634 | { |
1632 | struct mmc_command cmd = {0}; | 1635 | struct mmc_command cmd = {0}; |
1633 | unsigned int qty = 0; | 1636 | unsigned int qty = 0; |
1637 | unsigned long timeout; | ||
1634 | int err; | 1638 | int err; |
1635 | 1639 | ||
1636 | /* | 1640 | /* |
@@ -1708,6 +1712,7 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, | |||
1708 | if (mmc_host_is_spi(card->host)) | 1712 | if (mmc_host_is_spi(card->host)) |
1709 | goto out; | 1713 | goto out; |
1710 | 1714 | ||
1715 | timeout = jiffies + msecs_to_jiffies(MMC_CORE_TIMEOUT_MS); | ||
1711 | do { | 1716 | do { |
1712 | memset(&cmd, 0, sizeof(struct mmc_command)); | 1717 | memset(&cmd, 0, sizeof(struct mmc_command)); |
1713 | cmd.opcode = MMC_SEND_STATUS; | 1718 | cmd.opcode = MMC_SEND_STATUS; |
@@ -1721,8 +1726,19 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, | |||
1721 | err = -EIO; | 1726 | err = -EIO; |
1722 | goto out; | 1727 | goto out; |
1723 | } | 1728 | } |
1729 | |||
1730 | /* Timeout if the device never becomes ready for data and | ||
1731 | * never leaves the program state. | ||
1732 | */ | ||
1733 | if (time_after(jiffies, timeout)) { | ||
1734 | pr_err("%s: Card stuck in programming state! %s\n", | ||
1735 | mmc_hostname(card->host), __func__); | ||
1736 | err = -EIO; | ||
1737 | goto out; | ||
1738 | } | ||
1739 | |||
1724 | } while (!(cmd.resp[0] & R1_READY_FOR_DATA) || | 1740 | } while (!(cmd.resp[0] & R1_READY_FOR_DATA) || |
1725 | R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG); | 1741 | (R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG)); |
1726 | out: | 1742 | out: |
1727 | return err; | 1743 | return err; |
1728 | } | 1744 | } |
@@ -1942,6 +1958,20 @@ int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen) | |||
1942 | } | 1958 | } |
1943 | EXPORT_SYMBOL(mmc_set_blocklen); | 1959 | EXPORT_SYMBOL(mmc_set_blocklen); |
1944 | 1960 | ||
1961 | int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount, | ||
1962 | bool is_rel_write) | ||
1963 | { | ||
1964 | struct mmc_command cmd = {0}; | ||
1965 | |||
1966 | cmd.opcode = MMC_SET_BLOCK_COUNT; | ||
1967 | cmd.arg = blockcount & 0x0000FFFF; | ||
1968 | if (is_rel_write) | ||
1969 | cmd.arg |= 1 << 31; | ||
1970 | cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; | ||
1971 | return mmc_wait_for_cmd(card->host, &cmd, 5); | ||
1972 | } | ||
1973 | EXPORT_SYMBOL(mmc_set_blockcount); | ||
1974 | |||
1945 | static void mmc_hw_reset_for_init(struct mmc_host *host) | 1975 | static void mmc_hw_reset_for_init(struct mmc_host *host) |
1946 | { | 1976 | { |
1947 | if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) | 1977 | if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) |
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index d96c643dde1c..35c2f85b1956 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c | |||
@@ -144,6 +144,22 @@ static int mmc_ios_show(struct seq_file *s, void *data) | |||
144 | } | 144 | } |
145 | seq_printf(s, "timing spec:\t%u (%s)\n", ios->timing, str); | 145 | seq_printf(s, "timing spec:\t%u (%s)\n", ios->timing, str); |
146 | 146 | ||
147 | switch (ios->signal_voltage) { | ||
148 | case MMC_SIGNAL_VOLTAGE_330: | ||
149 | str = "3.30 V"; | ||
150 | break; | ||
151 | case MMC_SIGNAL_VOLTAGE_180: | ||
152 | str = "1.80 V"; | ||
153 | break; | ||
154 | case MMC_SIGNAL_VOLTAGE_120: | ||
155 | str = "1.20 V"; | ||
156 | break; | ||
157 | default: | ||
158 | str = "invalid"; | ||
159 | break; | ||
160 | } | ||
161 | seq_printf(s, "signal voltage:\t%u (%s)\n", ios->chip_select, str); | ||
162 | |||
147 | return 0; | 163 | return 0; |
148 | } | 164 | } |
149 | 165 | ||
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 7cc46382fd64..e6e39111e05b 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -239,7 +239,7 @@ static void mmc_select_card_type(struct mmc_card *card) | |||
239 | { | 239 | { |
240 | struct mmc_host *host = card->host; | 240 | struct mmc_host *host = card->host; |
241 | u8 card_type = card->ext_csd.raw_card_type & EXT_CSD_CARD_TYPE_MASK; | 241 | u8 card_type = card->ext_csd.raw_card_type & EXT_CSD_CARD_TYPE_MASK; |
242 | unsigned int caps = host->caps, caps2 = host->caps2; | 242 | u32 caps = host->caps, caps2 = host->caps2; |
243 | unsigned int hs_max_dtr = 0; | 243 | unsigned int hs_max_dtr = 0; |
244 | 244 | ||
245 | if (card_type & EXT_CSD_CARD_TYPE_26) | 245 | if (card_type & EXT_CSD_CARD_TYPE_26) |
@@ -491,6 +491,17 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) | |||
491 | 491 | ||
492 | card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM]; | 492 | card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM]; |
493 | card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION]; | 493 | card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION]; |
494 | |||
495 | /* | ||
496 | * RPMB regions are defined in multiples of 128K. | ||
497 | */ | ||
498 | card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT]; | ||
499 | if (ext_csd[EXT_CSD_RPMB_MULT]) { | ||
500 | mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17, | ||
501 | EXT_CSD_PART_CONFIG_ACC_RPMB, | ||
502 | "rpmb", 0, false, | ||
503 | MMC_BLK_DATA_AREA_RPMB); | ||
504 | } | ||
494 | } | 505 | } |
495 | 506 | ||
496 | card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT]; | 507 | card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT]; |
@@ -615,6 +626,8 @@ MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); | |||
615 | MMC_DEV_ATTR(enhanced_area_offset, "%llu\n", | 626 | MMC_DEV_ATTR(enhanced_area_offset, "%llu\n", |
616 | card->ext_csd.enhanced_area_offset); | 627 | card->ext_csd.enhanced_area_offset); |
617 | MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size); | 628 | MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size); |
629 | MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult); | ||
630 | MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors); | ||
618 | 631 | ||
619 | static struct attribute *mmc_std_attrs[] = { | 632 | static struct attribute *mmc_std_attrs[] = { |
620 | &dev_attr_cid.attr, | 633 | &dev_attr_cid.attr, |
@@ -630,6 +643,8 @@ static struct attribute *mmc_std_attrs[] = { | |||
630 | &dev_attr_serial.attr, | 643 | &dev_attr_serial.attr, |
631 | &dev_attr_enhanced_area_offset.attr, | 644 | &dev_attr_enhanced_area_offset.attr, |
632 | &dev_attr_enhanced_area_size.attr, | 645 | &dev_attr_enhanced_area_size.attr, |
646 | &dev_attr_raw_rpmb_size_mult.attr, | ||
647 | &dev_attr_rel_sectors.attr, | ||
633 | NULL, | 648 | NULL, |
634 | }; | 649 | }; |
635 | 650 | ||
@@ -1051,6 +1066,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1051 | if (mmc_card_highspeed(card) || mmc_card_hs200(card)) { | 1066 | if (mmc_card_highspeed(card) || mmc_card_hs200(card)) { |
1052 | if (max_dtr > card->ext_csd.hs_max_dtr) | 1067 | if (max_dtr > card->ext_csd.hs_max_dtr) |
1053 | max_dtr = card->ext_csd.hs_max_dtr; | 1068 | max_dtr = card->ext_csd.hs_max_dtr; |
1069 | if (mmc_card_highspeed(card) && (max_dtr > 52000000)) | ||
1070 | max_dtr = 52000000; | ||
1054 | } else if (max_dtr > card->csd.max_dtr) { | 1071 | } else if (max_dtr > card->csd.max_dtr) { |
1055 | max_dtr = card->csd.max_dtr; | 1072 | max_dtr = card->csd.max_dtr; |
1056 | } | 1073 | } |
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index a0e172042e65..6d8f7012d73a 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include "core.h" | 21 | #include "core.h" |
22 | #include "mmc_ops.h" | 22 | #include "mmc_ops.h" |
23 | 23 | ||
24 | #define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ | ||
25 | |||
24 | static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) | 26 | static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) |
25 | { | 27 | { |
26 | int err; | 28 | int err; |
@@ -409,6 +411,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
409 | { | 411 | { |
410 | int err; | 412 | int err; |
411 | struct mmc_command cmd = {0}; | 413 | struct mmc_command cmd = {0}; |
414 | unsigned long timeout; | ||
412 | u32 status; | 415 | u32 status; |
413 | 416 | ||
414 | BUG_ON(!card); | 417 | BUG_ON(!card); |
@@ -437,6 +440,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
437 | return 0; | 440 | return 0; |
438 | 441 | ||
439 | /* Must check status to be sure of no errors */ | 442 | /* Must check status to be sure of no errors */ |
443 | timeout = jiffies + msecs_to_jiffies(MMC_OPS_TIMEOUT_MS); | ||
440 | do { | 444 | do { |
441 | err = mmc_send_status(card, &status); | 445 | err = mmc_send_status(card, &status); |
442 | if (err) | 446 | if (err) |
@@ -445,6 +449,13 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
445 | break; | 449 | break; |
446 | if (mmc_host_is_spi(card->host)) | 450 | if (mmc_host_is_spi(card->host)) |
447 | break; | 451 | break; |
452 | |||
453 | /* Timeout if the device never leaves the program state. */ | ||
454 | if (time_after(jiffies, timeout)) { | ||
455 | pr_err("%s: Card stuck in programming state! %s\n", | ||
456 | mmc_hostname(card->host), __func__); | ||
457 | return -ETIMEDOUT; | ||
458 | } | ||
448 | } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); | 459 | } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); |
449 | 460 | ||
450 | if (mmc_host_is_spi(card->host)) { | 461 | if (mmc_host_is_spi(card->host)) { |
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index 6bf68799fe97..5e57048e2c1d 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c | |||
@@ -193,7 +193,21 @@ static int sdio_bus_remove(struct device *dev) | |||
193 | } | 193 | } |
194 | 194 | ||
195 | #ifdef CONFIG_PM | 195 | #ifdef CONFIG_PM |
196 | |||
197 | #ifdef CONFIG_PM_SLEEP | ||
198 | static int pm_no_operation(struct device *dev) | ||
199 | { | ||
200 | /* | ||
201 | * Prevent the PM core from calling SDIO device drivers' suspend | ||
202 | * callback routines, which it is not supposed to do, by using this | ||
203 | * empty function as the bus type suspend callaback for SDIO. | ||
204 | */ | ||
205 | return 0; | ||
206 | } | ||
207 | #endif | ||
208 | |||
196 | static const struct dev_pm_ops sdio_bus_pm_ops = { | 209 | static const struct dev_pm_ops sdio_bus_pm_ops = { |
210 | SET_SYSTEM_SLEEP_PM_OPS(pm_no_operation, pm_no_operation) | ||
197 | SET_RUNTIME_PM_OPS( | 211 | SET_RUNTIME_PM_OPS( |
198 | pm_generic_runtime_suspend, | 212 | pm_generic_runtime_suspend, |
199 | pm_generic_runtime_resume, | 213 | pm_generic_runtime_resume, |
@@ -258,8 +272,7 @@ static void sdio_release_func(struct device *dev) | |||
258 | 272 | ||
259 | sdio_free_func_cis(func); | 273 | sdio_free_func_cis(func); |
260 | 274 | ||
261 | if (func->info) | 275 | kfree(func->info); |
262 | kfree(func->info); | ||
263 | 276 | ||
264 | kfree(func); | 277 | kfree(func); |
265 | } | 278 | } |
diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c index 8f6f5ac131fc..78cb4d5d9d58 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c | |||
@@ -188,8 +188,7 @@ EXPORT_SYMBOL_GPL(sdio_set_block_size); | |||
188 | */ | 188 | */ |
189 | static inline unsigned int sdio_max_byte_size(struct sdio_func *func) | 189 | static inline unsigned int sdio_max_byte_size(struct sdio_func *func) |
190 | { | 190 | { |
191 | unsigned mval = min(func->card->host->max_seg_size, | 191 | unsigned mval = func->card->host->max_blk_size; |
192 | func->card->host->max_blk_size); | ||
193 | 192 | ||
194 | if (mmc_blksz_for_byte_mode(func->card)) | 193 | if (mmc_blksz_for_byte_mode(func->card)) |
195 | mval = min(mval, func->cur_blksize); | 194 | mval = min(mval, func->cur_blksize); |
@@ -311,11 +310,8 @@ static int sdio_io_rw_ext_helper(struct sdio_func *func, int write, | |||
311 | /* Do the bulk of the transfer using block mode (if supported). */ | 310 | /* Do the bulk of the transfer using block mode (if supported). */ |
312 | if (func->card->cccr.multi_block && (size > sdio_max_byte_size(func))) { | 311 | if (func->card->cccr.multi_block && (size > sdio_max_byte_size(func))) { |
313 | /* Blocks per command is limited by host count, host transfer | 312 | /* Blocks per command is limited by host count, host transfer |
314 | * size (we only use a single sg entry) and the maximum for | 313 | * size and the maximum for IO_RW_EXTENDED of 511 blocks. */ |
315 | * IO_RW_EXTENDED of 511 blocks. */ | 314 | max_blocks = min(func->card->host->max_blk_count, 511u); |
316 | max_blocks = min(func->card->host->max_blk_count, | ||
317 | func->card->host->max_seg_size / func->cur_blksize); | ||
318 | max_blocks = min(max_blocks, 511u); | ||
319 | 315 | ||
320 | while (remainder >= func->cur_blksize) { | 316 | while (remainder >= func->cur_blksize) { |
321 | unsigned blocks; | 317 | unsigned blocks; |
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c index d29e20630eed..62508b457c4f 100644 --- a/drivers/mmc/core/sdio_ops.c +++ b/drivers/mmc/core/sdio_ops.c | |||
@@ -124,7 +124,10 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, | |||
124 | struct mmc_request mrq = {NULL}; | 124 | struct mmc_request mrq = {NULL}; |
125 | struct mmc_command cmd = {0}; | 125 | struct mmc_command cmd = {0}; |
126 | struct mmc_data data = {0}; | 126 | struct mmc_data data = {0}; |
127 | struct scatterlist sg; | 127 | struct scatterlist sg, *sg_ptr; |
128 | struct sg_table sgtable; | ||
129 | unsigned int nents, left_size, i; | ||
130 | unsigned int seg_size = card->host->max_seg_size; | ||
128 | 131 | ||
129 | BUG_ON(!card); | 132 | BUG_ON(!card); |
130 | BUG_ON(fn > 7); | 133 | BUG_ON(fn > 7); |
@@ -152,15 +155,36 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, | |||
152 | /* Code in host drivers/fwk assumes that "blocks" always is >=1 */ | 155 | /* Code in host drivers/fwk assumes that "blocks" always is >=1 */ |
153 | data.blocks = blocks ? blocks : 1; | 156 | data.blocks = blocks ? blocks : 1; |
154 | data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; | 157 | data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; |
155 | data.sg = &sg; | ||
156 | data.sg_len = 1; | ||
157 | 158 | ||
158 | sg_init_one(&sg, buf, data.blksz * data.blocks); | 159 | left_size = data.blksz * data.blocks; |
160 | nents = (left_size - 1) / seg_size + 1; | ||
161 | if (nents > 1) { | ||
162 | if (sg_alloc_table(&sgtable, nents, GFP_KERNEL)) | ||
163 | return -ENOMEM; | ||
164 | |||
165 | data.sg = sgtable.sgl; | ||
166 | data.sg_len = nents; | ||
167 | |||
168 | for_each_sg(data.sg, sg_ptr, data.sg_len, i) { | ||
169 | sg_set_page(sg_ptr, virt_to_page(buf + (i * seg_size)), | ||
170 | min(seg_size, left_size), | ||
171 | offset_in_page(buf + (i * seg_size))); | ||
172 | left_size = left_size - seg_size; | ||
173 | } | ||
174 | } else { | ||
175 | data.sg = &sg; | ||
176 | data.sg_len = 1; | ||
177 | |||
178 | sg_init_one(&sg, buf, left_size); | ||
179 | } | ||
159 | 180 | ||
160 | mmc_set_data_timeout(&data, card); | 181 | mmc_set_data_timeout(&data, card); |
161 | 182 | ||
162 | mmc_wait_for_req(card->host, &mrq); | 183 | mmc_wait_for_req(card->host, &mrq); |
163 | 184 | ||
185 | if (nents > 1) | ||
186 | sg_free_table(&sgtable); | ||
187 | |||
164 | if (cmd.error) | 188 | if (cmd.error) |
165 | return cmd.error; | 189 | return cmd.error; |
166 | if (data.error) | 190 | if (data.error) |
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 08c6b3dfe080..16a1c0b6f264 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c | |||
@@ -27,7 +27,13 @@ struct mmc_gpio { | |||
27 | static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) | 27 | static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) |
28 | { | 28 | { |
29 | /* Schedule a card detection after a debounce timeout */ | 29 | /* Schedule a card detection after a debounce timeout */ |
30 | mmc_detect_change(dev_id, msecs_to_jiffies(100)); | 30 | struct mmc_host *host = dev_id; |
31 | |||
32 | if (host->ops->card_event) | ||
33 | host->ops->card_event(host); | ||
34 | |||
35 | mmc_detect_change(host, msecs_to_jiffies(200)); | ||
36 | |||
31 | return IRQ_HANDLED; | 37 | return IRQ_HANDLED; |
32 | } | 38 | } |
33 | 39 | ||
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 9bf10e7bbfaf..83eb1e06ff76 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -270,26 +270,8 @@ config MMC_AU1X | |||
270 | 270 | ||
271 | If unsure, say N. | 271 | If unsure, say N. |
272 | 272 | ||
273 | choice | ||
274 | prompt "Atmel SD/MMC Driver" | ||
275 | depends on AVR32 || ARCH_AT91 | ||
276 | default MMC_ATMELMCI if AVR32 | ||
277 | help | ||
278 | Choose which driver to use for the Atmel MCI Silicon | ||
279 | |||
280 | config MMC_AT91 | ||
281 | tristate "AT91 SD/MMC Card Interface support (DEPRECATED)" | ||
282 | depends on ARCH_AT91 | ||
283 | help | ||
284 | This selects the AT91 MCI controller. This driver will | ||
285 | be removed soon (for more information have a look to | ||
286 | Documentation/feature-removal-schedule.txt). Please use | ||
287 | MMC_ATMEL_MCI. | ||
288 | |||
289 | If unsure, say N. | ||
290 | |||
291 | config MMC_ATMELMCI | 273 | config MMC_ATMELMCI |
292 | tristate "Atmel Multimedia Card Interface support" | 274 | tristate "Atmel SD/MMC Driver (Multimedia Card Interface)" |
293 | depends on AVR32 || ARCH_AT91 | 275 | depends on AVR32 || ARCH_AT91 |
294 | help | 276 | help |
295 | This selects the Atmel Multimedia Card Interface driver. If | 277 | This selects the Atmel Multimedia Card Interface driver. If |
@@ -298,8 +280,6 @@ config MMC_ATMELMCI | |||
298 | 280 | ||
299 | If unsure, say N. | 281 | If unsure, say N. |
300 | 282 | ||
301 | endchoice | ||
302 | |||
303 | config MMC_ATMELMCI_DMA | 283 | config MMC_ATMELMCI_DMA |
304 | bool "Atmel MCI DMA support" | 284 | bool "Atmel MCI DMA support" |
305 | depends on MMC_ATMELMCI && (AVR32 || ARCH_AT91SAM9G45) && DMA_ENGINE | 285 | depends on MMC_ATMELMCI && (AVR32 || ARCH_AT91SAM9G45) && DMA_ENGINE |
@@ -621,3 +601,14 @@ config MMC_USHC | |||
621 | 601 | ||
622 | Note: These controllers only support SDIO cards and do not | 602 | Note: These controllers only support SDIO cards and do not |
623 | support MMC or SD memory cards. | 603 | support MMC or SD memory cards. |
604 | |||
605 | config MMC_WMT | ||
606 | tristate "Wondermedia SD/MMC Host Controller support" | ||
607 | depends on ARCH_VT8500 | ||
608 | default y | ||
609 | help | ||
610 | This selects support for the SD/MMC Host Controller on | ||
611 | Wondermedia WM8505/WM8650 based SoCs. | ||
612 | |||
613 | To compile this driver as a module, choose M here: the | ||
614 | module will be called wmt-sdmmc. | ||
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 17ad0a7ba40b..39d5e1234709 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -17,7 +17,6 @@ obj-$(CONFIG_MMC_WBSD) += wbsd.o | |||
17 | obj-$(CONFIG_MMC_AU1X) += au1xmmc.o | 17 | obj-$(CONFIG_MMC_AU1X) += au1xmmc.o |
18 | obj-$(CONFIG_MMC_OMAP) += omap.o | 18 | obj-$(CONFIG_MMC_OMAP) += omap.o |
19 | obj-$(CONFIG_MMC_OMAP_HS) += omap_hsmmc.o | 19 | obj-$(CONFIG_MMC_OMAP_HS) += omap_hsmmc.o |
20 | obj-$(CONFIG_MMC_AT91) += at91_mci.o | ||
21 | obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o | 20 | obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o |
22 | obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o | 21 | obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o |
23 | obj-$(CONFIG_MMC_MSM) += msm_sdcc.o | 22 | obj-$(CONFIG_MMC_MSM) += msm_sdcc.o |
@@ -45,6 +44,7 @@ obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o | |||
45 | obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o | 44 | obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o |
46 | obj-$(CONFIG_MMC_VUB300) += vub300.o | 45 | obj-$(CONFIG_MMC_VUB300) += vub300.o |
47 | obj-$(CONFIG_MMC_USHC) += ushc.o | 46 | obj-$(CONFIG_MMC_USHC) += ushc.o |
47 | obj-$(CONFIG_MMC_WMT) += wmt-sdmmc.o | ||
48 | 48 | ||
49 | obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o | 49 | obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o |
50 | obj-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o | 50 | obj-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o |
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c deleted file mode 100644 index 74bed0fc23e7..000000000000 --- a/drivers/mmc/host/at91_mci.c +++ /dev/null | |||
@@ -1,1219 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/mmc/host/at91_mci.c - ATMEL AT91 MCI Driver | ||
3 | * | ||
4 | * Copyright (C) 2005 Cougar Creek Computing Devices Ltd, All Rights Reserved | ||
5 | * | ||
6 | * Copyright (C) 2006 Malcolm Noyes | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | /* | ||
14 | This is the AT91 MCI driver that has been tested with both MMC cards | ||
15 | and SD-cards. Boards that support write protect are now supported. | ||
16 | The CCAT91SBC001 board does not support SD cards. | ||
17 | |||
18 | The three entry points are at91_mci_request, at91_mci_set_ios | ||
19 | and at91_mci_get_ro. | ||
20 | |||
21 | SET IOS | ||
22 | This configures the device to put it into the correct mode and clock speed | ||
23 | required. | ||
24 | |||
25 | MCI REQUEST | ||
26 | MCI request processes the commands sent in the mmc_request structure. This | ||
27 | can consist of a processing command and a stop command in the case of | ||
28 | multiple block transfers. | ||
29 | |||
30 | There are three main types of request, commands, reads and writes. | ||
31 | |||
32 | Commands are straight forward. The command is submitted to the controller and | ||
33 | the request function returns. When the controller generates an interrupt to indicate | ||
34 | the command is finished, the response to the command are read and the mmc_request_done | ||
35 | function called to end the request. | ||
36 | |||
37 | Reads and writes work in a similar manner to normal commands but involve the PDC (DMA) | ||
38 | controller to manage the transfers. | ||
39 | |||
40 | A read is done from the controller directly to the scatterlist passed in from the request. | ||
41 | Due to a bug in the AT91RM9200 controller, when a read is completed, all the words are byte | ||
42 | swapped in the scatterlist buffers. AT91SAM926x are not affected by this bug. | ||
43 | |||
44 | The sequence of read interrupts is: ENDRX, RXBUFF, CMDRDY | ||
45 | |||
46 | A write is slightly different in that the bytes to write are read from the scatterlist | ||
47 | into a dma memory buffer (this is in case the source buffer should be read only). The | ||
48 | entire write buffer is then done from this single dma memory buffer. | ||
49 | |||
50 | The sequence of write interrupts is: ENDTX, TXBUFE, NOTBUSY, CMDRDY | ||
51 | |||
52 | GET RO | ||
53 | Gets the status of the write protect pin, if available. | ||
54 | */ | ||
55 | |||
56 | #include <linux/module.h> | ||
57 | #include <linux/moduleparam.h> | ||
58 | #include <linux/init.h> | ||
59 | #include <linux/ioport.h> | ||
60 | #include <linux/platform_device.h> | ||
61 | #include <linux/interrupt.h> | ||
62 | #include <linux/blkdev.h> | ||
63 | #include <linux/delay.h> | ||
64 | #include <linux/err.h> | ||
65 | #include <linux/dma-mapping.h> | ||
66 | #include <linux/clk.h> | ||
67 | #include <linux/atmel_pdc.h> | ||
68 | #include <linux/gfp.h> | ||
69 | #include <linux/highmem.h> | ||
70 | |||
71 | #include <linux/mmc/host.h> | ||
72 | #include <linux/mmc/sdio.h> | ||
73 | |||
74 | #include <asm/io.h> | ||
75 | #include <asm/irq.h> | ||
76 | #include <asm/gpio.h> | ||
77 | |||
78 | #include <mach/board.h> | ||
79 | #include <mach/cpu.h> | ||
80 | |||
81 | #include "at91_mci.h" | ||
82 | |||
83 | #define DRIVER_NAME "at91_mci" | ||
84 | |||
85 | static inline int at91mci_is_mci1rev2xx(void) | ||
86 | { | ||
87 | return ( cpu_is_at91sam9260() | ||
88 | || cpu_is_at91sam9263() | ||
89 | || cpu_is_at91sam9rl() | ||
90 | || cpu_is_at91sam9g10() | ||
91 | || cpu_is_at91sam9g20() | ||
92 | ); | ||
93 | } | ||
94 | |||
95 | #define FL_SENT_COMMAND (1 << 0) | ||
96 | #define FL_SENT_STOP (1 << 1) | ||
97 | |||
98 | #define AT91_MCI_ERRORS (AT91_MCI_RINDE | AT91_MCI_RDIRE | AT91_MCI_RCRCE \ | ||
99 | | AT91_MCI_RENDE | AT91_MCI_RTOE | AT91_MCI_DCRCE \ | ||
100 | | AT91_MCI_DTOE | AT91_MCI_OVRE | AT91_MCI_UNRE) | ||
101 | |||
102 | #define at91_mci_read(host, reg) __raw_readl((host)->baseaddr + (reg)) | ||
103 | #define at91_mci_write(host, reg, val) __raw_writel((val), (host)->baseaddr + (reg)) | ||
104 | |||
105 | #define MCI_BLKSIZE 512 | ||
106 | #define MCI_MAXBLKSIZE 4095 | ||
107 | #define MCI_BLKATONCE 256 | ||
108 | #define MCI_BUFSIZE (MCI_BLKSIZE * MCI_BLKATONCE) | ||
109 | |||
110 | /* | ||
111 | * Low level type for this driver | ||
112 | */ | ||
113 | struct at91mci_host | ||
114 | { | ||
115 | struct mmc_host *mmc; | ||
116 | struct mmc_command *cmd; | ||
117 | struct mmc_request *request; | ||
118 | |||
119 | void __iomem *baseaddr; | ||
120 | int irq; | ||
121 | |||
122 | struct at91_mmc_data *board; | ||
123 | int present; | ||
124 | |||
125 | struct clk *mci_clk; | ||
126 | |||
127 | /* | ||
128 | * Flag indicating when the command has been sent. This is used to | ||
129 | * work out whether or not to send the stop | ||
130 | */ | ||
131 | unsigned int flags; | ||
132 | /* flag for current bus settings */ | ||
133 | u32 bus_mode; | ||
134 | |||
135 | /* DMA buffer used for transmitting */ | ||
136 | unsigned int* buffer; | ||
137 | dma_addr_t physical_address; | ||
138 | unsigned int total_length; | ||
139 | |||
140 | /* Latest in the scatterlist that has been enabled for transfer, but not freed */ | ||
141 | int in_use_index; | ||
142 | |||
143 | /* Latest in the scatterlist that has been enabled for transfer */ | ||
144 | int transfer_index; | ||
145 | |||
146 | /* Timer for timeouts */ | ||
147 | struct timer_list timer; | ||
148 | }; | ||
149 | |||
150 | /* | ||
151 | * Reset the controller and restore most of the state | ||
152 | */ | ||
153 | static void at91_reset_host(struct at91mci_host *host) | ||
154 | { | ||
155 | unsigned long flags; | ||
156 | u32 mr; | ||
157 | u32 sdcr; | ||
158 | u32 dtor; | ||
159 | u32 imr; | ||
160 | |||
161 | local_irq_save(flags); | ||
162 | imr = at91_mci_read(host, AT91_MCI_IMR); | ||
163 | |||
164 | at91_mci_write(host, AT91_MCI_IDR, 0xffffffff); | ||
165 | |||
166 | /* save current state */ | ||
167 | mr = at91_mci_read(host, AT91_MCI_MR) & 0x7fff; | ||
168 | sdcr = at91_mci_read(host, AT91_MCI_SDCR); | ||
169 | dtor = at91_mci_read(host, AT91_MCI_DTOR); | ||
170 | |||
171 | /* reset the controller */ | ||
172 | at91_mci_write(host, AT91_MCI_CR, AT91_MCI_MCIDIS | AT91_MCI_SWRST); | ||
173 | |||
174 | /* restore state */ | ||
175 | at91_mci_write(host, AT91_MCI_CR, AT91_MCI_MCIEN); | ||
176 | at91_mci_write(host, AT91_MCI_MR, mr); | ||
177 | at91_mci_write(host, AT91_MCI_SDCR, sdcr); | ||
178 | at91_mci_write(host, AT91_MCI_DTOR, dtor); | ||
179 | at91_mci_write(host, AT91_MCI_IER, imr); | ||
180 | |||
181 | /* make sure sdio interrupts will fire */ | ||
182 | at91_mci_read(host, AT91_MCI_SR); | ||
183 | |||
184 | local_irq_restore(flags); | ||
185 | } | ||
186 | |||
187 | static void at91_timeout_timer(unsigned long data) | ||
188 | { | ||
189 | struct at91mci_host *host; | ||
190 | |||
191 | host = (struct at91mci_host *)data; | ||
192 | |||
193 | if (host->request) { | ||
194 | dev_err(host->mmc->parent, "Timeout waiting end of packet\n"); | ||
195 | |||
196 | if (host->cmd && host->cmd->data) { | ||
197 | host->cmd->data->error = -ETIMEDOUT; | ||
198 | } else { | ||
199 | if (host->cmd) | ||
200 | host->cmd->error = -ETIMEDOUT; | ||
201 | else | ||
202 | host->request->cmd->error = -ETIMEDOUT; | ||
203 | } | ||
204 | |||
205 | at91_reset_host(host); | ||
206 | mmc_request_done(host->mmc, host->request); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /* | ||
211 | * Copy from sg to a dma block - used for transfers | ||
212 | */ | ||
213 | static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data *data) | ||
214 | { | ||
215 | unsigned int len, i, size; | ||
216 | unsigned *dmabuf = host->buffer; | ||
217 | |||
218 | size = data->blksz * data->blocks; | ||
219 | len = data->sg_len; | ||
220 | |||
221 | /* MCI1 rev2xx Data Write Operation and number of bytes erratum */ | ||
222 | if (at91mci_is_mci1rev2xx()) | ||
223 | if (host->total_length == 12) | ||
224 | memset(dmabuf, 0, 12); | ||
225 | |||
226 | /* | ||
227 | * Just loop through all entries. Size might not | ||
228 | * be the entire list though so make sure that | ||
229 | * we do not transfer too much. | ||
230 | */ | ||
231 | for (i = 0; i < len; i++) { | ||
232 | struct scatterlist *sg; | ||
233 | int amount; | ||
234 | unsigned int *sgbuffer; | ||
235 | |||
236 | sg = &data->sg[i]; | ||
237 | |||
238 | sgbuffer = kmap_atomic(sg_page(sg)) + sg->offset; | ||
239 | amount = min(size, sg->length); | ||
240 | size -= amount; | ||
241 | |||
242 | if (cpu_is_at91rm9200()) { /* AT91RM9200 errata */ | ||
243 | int index; | ||
244 | |||
245 | for (index = 0; index < (amount / 4); index++) | ||
246 | *dmabuf++ = swab32(sgbuffer[index]); | ||
247 | } else { | ||
248 | char *tmpv = (char *)dmabuf; | ||
249 | memcpy(tmpv, sgbuffer, amount); | ||
250 | tmpv += amount; | ||
251 | dmabuf = (unsigned *)tmpv; | ||
252 | } | ||
253 | |||
254 | kunmap_atomic(sgbuffer); | ||
255 | |||
256 | if (size == 0) | ||
257 | break; | ||
258 | } | ||
259 | |||
260 | /* | ||
261 | * Check that we didn't get a request to transfer | ||
262 | * more data than can fit into the SG list. | ||
263 | */ | ||
264 | BUG_ON(size != 0); | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | * Handle after a dma read | ||
269 | */ | ||
270 | static void at91_mci_post_dma_read(struct at91mci_host *host) | ||
271 | { | ||
272 | struct mmc_command *cmd; | ||
273 | struct mmc_data *data; | ||
274 | unsigned int len, i, size; | ||
275 | unsigned *dmabuf = host->buffer; | ||
276 | |||
277 | pr_debug("post dma read\n"); | ||
278 | |||
279 | cmd = host->cmd; | ||
280 | if (!cmd) { | ||
281 | pr_debug("no command\n"); | ||
282 | return; | ||
283 | } | ||
284 | |||
285 | data = cmd->data; | ||
286 | if (!data) { | ||
287 | pr_debug("no data\n"); | ||
288 | return; | ||
289 | } | ||
290 | |||
291 | size = data->blksz * data->blocks; | ||
292 | len = data->sg_len; | ||
293 | |||
294 | at91_mci_write(host, AT91_MCI_IDR, AT91_MCI_ENDRX); | ||
295 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_RXBUFF); | ||
296 | |||
297 | for (i = 0; i < len; i++) { | ||
298 | struct scatterlist *sg; | ||
299 | int amount; | ||
300 | unsigned int *sgbuffer; | ||
301 | |||
302 | sg = &data->sg[i]; | ||
303 | |||
304 | sgbuffer = kmap_atomic(sg_page(sg)) + sg->offset; | ||
305 | amount = min(size, sg->length); | ||
306 | size -= amount; | ||
307 | |||
308 | if (cpu_is_at91rm9200()) { /* AT91RM9200 errata */ | ||
309 | int index; | ||
310 | for (index = 0; index < (amount / 4); index++) | ||
311 | sgbuffer[index] = swab32(*dmabuf++); | ||
312 | } else { | ||
313 | char *tmpv = (char *)dmabuf; | ||
314 | memcpy(sgbuffer, tmpv, amount); | ||
315 | tmpv += amount; | ||
316 | dmabuf = (unsigned *)tmpv; | ||
317 | } | ||
318 | |||
319 | flush_kernel_dcache_page(sg_page(sg)); | ||
320 | kunmap_atomic(sgbuffer); | ||
321 | data->bytes_xfered += amount; | ||
322 | if (size == 0) | ||
323 | break; | ||
324 | } | ||
325 | |||
326 | pr_debug("post dma read done\n"); | ||
327 | } | ||
328 | |||
329 | /* | ||
330 | * Handle transmitted data | ||
331 | */ | ||
332 | static void at91_mci_handle_transmitted(struct at91mci_host *host) | ||
333 | { | ||
334 | struct mmc_command *cmd; | ||
335 | struct mmc_data *data; | ||
336 | |||
337 | pr_debug("Handling the transmit\n"); | ||
338 | |||
339 | /* Disable the transfer */ | ||
340 | at91_mci_write(host, ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS | ATMEL_PDC_TXTDIS); | ||
341 | |||
342 | /* Now wait for cmd ready */ | ||
343 | at91_mci_write(host, AT91_MCI_IDR, AT91_MCI_TXBUFE); | ||
344 | |||
345 | cmd = host->cmd; | ||
346 | if (!cmd) return; | ||
347 | |||
348 | data = cmd->data; | ||
349 | if (!data) return; | ||
350 | |||
351 | if (cmd->data->blocks > 1) { | ||
352 | pr_debug("multiple write : wait for BLKE...\n"); | ||
353 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_BLKE); | ||
354 | } else | ||
355 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_NOTBUSY); | ||
356 | } | ||
357 | |||
358 | /* | ||
359 | * Update bytes transfered count during a write operation | ||
360 | */ | ||
361 | static void at91_mci_update_bytes_xfered(struct at91mci_host *host) | ||
362 | { | ||
363 | struct mmc_data *data; | ||
364 | |||
365 | /* always deal with the effective request (and not the current cmd) */ | ||
366 | |||
367 | if (host->request->cmd && host->request->cmd->error != 0) | ||
368 | return; | ||
369 | |||
370 | if (host->request->data) { | ||
371 | data = host->request->data; | ||
372 | if (data->flags & MMC_DATA_WRITE) { | ||
373 | /* card is in IDLE mode now */ | ||
374 | pr_debug("-> bytes_xfered %d, total_length = %d\n", | ||
375 | data->bytes_xfered, host->total_length); | ||
376 | data->bytes_xfered = data->blksz * data->blocks; | ||
377 | } | ||
378 | } | ||
379 | } | ||
380 | |||
381 | |||
382 | /*Handle after command sent ready*/ | ||
383 | static int at91_mci_handle_cmdrdy(struct at91mci_host *host) | ||
384 | { | ||
385 | if (!host->cmd) | ||
386 | return 1; | ||
387 | else if (!host->cmd->data) { | ||
388 | if (host->flags & FL_SENT_STOP) { | ||
389 | /*After multi block write, we must wait for NOTBUSY*/ | ||
390 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_NOTBUSY); | ||
391 | } else return 1; | ||
392 | } else if (host->cmd->data->flags & MMC_DATA_WRITE) { | ||
393 | /*After sendding multi-block-write command, start DMA transfer*/ | ||
394 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_TXBUFE | AT91_MCI_BLKE); | ||
395 | at91_mci_write(host, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); | ||
396 | } | ||
397 | |||
398 | /* command not completed, have to wait */ | ||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | |||
403 | /* | ||
404 | * Enable the controller | ||
405 | */ | ||
406 | static void at91_mci_enable(struct at91mci_host *host) | ||
407 | { | ||
408 | unsigned int mr; | ||
409 | |||
410 | at91_mci_write(host, AT91_MCI_CR, AT91_MCI_MCIEN); | ||
411 | at91_mci_write(host, AT91_MCI_IDR, 0xffffffff); | ||
412 | at91_mci_write(host, AT91_MCI_DTOR, AT91_MCI_DTOMUL_1M | AT91_MCI_DTOCYC); | ||
413 | mr = AT91_MCI_PDCMODE | 0x34a; | ||
414 | |||
415 | if (at91mci_is_mci1rev2xx()) | ||
416 | mr |= AT91_MCI_RDPROOF | AT91_MCI_WRPROOF; | ||
417 | |||
418 | at91_mci_write(host, AT91_MCI_MR, mr); | ||
419 | |||
420 | /* use Slot A or B (only one at same time) */ | ||
421 | at91_mci_write(host, AT91_MCI_SDCR, host->board->slot_b); | ||
422 | } | ||
423 | |||
424 | /* | ||
425 | * Disable the controller | ||
426 | */ | ||
427 | static void at91_mci_disable(struct at91mci_host *host) | ||
428 | { | ||
429 | at91_mci_write(host, AT91_MCI_CR, AT91_MCI_MCIDIS | AT91_MCI_SWRST); | ||
430 | } | ||
431 | |||
432 | /* | ||
433 | * Send a command | ||
434 | */ | ||
435 | static void at91_mci_send_command(struct at91mci_host *host, struct mmc_command *cmd) | ||
436 | { | ||
437 | unsigned int cmdr, mr; | ||
438 | unsigned int block_length; | ||
439 | struct mmc_data *data = cmd->data; | ||
440 | |||
441 | unsigned int blocks; | ||
442 | unsigned int ier = 0; | ||
443 | |||
444 | host->cmd = cmd; | ||
445 | |||
446 | /* Needed for leaving busy state before CMD1 */ | ||
447 | if ((at91_mci_read(host, AT91_MCI_SR) & AT91_MCI_RTOE) && (cmd->opcode == 1)) { | ||
448 | pr_debug("Clearing timeout\n"); | ||
449 | at91_mci_write(host, AT91_MCI_ARGR, 0); | ||
450 | at91_mci_write(host, AT91_MCI_CMDR, AT91_MCI_OPDCMD); | ||
451 | while (!(at91_mci_read(host, AT91_MCI_SR) & AT91_MCI_CMDRDY)) { | ||
452 | /* spin */ | ||
453 | pr_debug("Clearing: SR = %08X\n", at91_mci_read(host, AT91_MCI_SR)); | ||
454 | } | ||
455 | } | ||
456 | |||
457 | cmdr = cmd->opcode; | ||
458 | |||
459 | if (mmc_resp_type(cmd) == MMC_RSP_NONE) | ||
460 | cmdr |= AT91_MCI_RSPTYP_NONE; | ||
461 | else { | ||
462 | /* if a response is expected then allow maximum response latancy */ | ||
463 | cmdr |= AT91_MCI_MAXLAT; | ||
464 | /* set 136 bit response for R2, 48 bit response otherwise */ | ||
465 | if (mmc_resp_type(cmd) == MMC_RSP_R2) | ||
466 | cmdr |= AT91_MCI_RSPTYP_136; | ||
467 | else | ||
468 | cmdr |= AT91_MCI_RSPTYP_48; | ||
469 | } | ||
470 | |||
471 | if (data) { | ||
472 | |||
473 | if (cpu_is_at91rm9200() || cpu_is_at91sam9261()) { | ||
474 | if (data->blksz & 0x3) { | ||
475 | pr_debug("Unsupported block size\n"); | ||
476 | cmd->error = -EINVAL; | ||
477 | mmc_request_done(host->mmc, host->request); | ||
478 | return; | ||
479 | } | ||
480 | if (data->flags & MMC_DATA_STREAM) { | ||
481 | pr_debug("Stream commands not supported\n"); | ||
482 | cmd->error = -EINVAL; | ||
483 | mmc_request_done(host->mmc, host->request); | ||
484 | return; | ||
485 | } | ||
486 | } | ||
487 | |||
488 | block_length = data->blksz; | ||
489 | blocks = data->blocks; | ||
490 | |||
491 | /* always set data start - also set direction flag for read */ | ||
492 | if (data->flags & MMC_DATA_READ) | ||
493 | cmdr |= (AT91_MCI_TRDIR | AT91_MCI_TRCMD_START); | ||
494 | else if (data->flags & MMC_DATA_WRITE) | ||
495 | cmdr |= AT91_MCI_TRCMD_START; | ||
496 | |||
497 | if (cmd->opcode == SD_IO_RW_EXTENDED) { | ||
498 | cmdr |= AT91_MCI_TRTYP_SDIO_BLOCK; | ||
499 | } else { | ||
500 | if (data->flags & MMC_DATA_STREAM) | ||
501 | cmdr |= AT91_MCI_TRTYP_STREAM; | ||
502 | if (data->blocks > 1) | ||
503 | cmdr |= AT91_MCI_TRTYP_MULTIPLE; | ||
504 | } | ||
505 | } | ||
506 | else { | ||
507 | block_length = 0; | ||
508 | blocks = 0; | ||
509 | } | ||
510 | |||
511 | if (host->flags & FL_SENT_STOP) | ||
512 | cmdr |= AT91_MCI_TRCMD_STOP; | ||
513 | |||
514 | if (host->bus_mode == MMC_BUSMODE_OPENDRAIN) | ||
515 | cmdr |= AT91_MCI_OPDCMD; | ||
516 | |||
517 | /* | ||
518 | * Set the arguments and send the command | ||
519 | */ | ||
520 | pr_debug("Sending command %d as %08X, arg = %08X, blocks = %d, length = %d (MR = %08X)\n", | ||
521 | cmd->opcode, cmdr, cmd->arg, blocks, block_length, at91_mci_read(host, AT91_MCI_MR)); | ||
522 | |||
523 | if (!data) { | ||
524 | at91_mci_write(host, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS | ATMEL_PDC_RXTDIS); | ||
525 | at91_mci_write(host, ATMEL_PDC_RPR, 0); | ||
526 | at91_mci_write(host, ATMEL_PDC_RCR, 0); | ||
527 | at91_mci_write(host, ATMEL_PDC_RNPR, 0); | ||
528 | at91_mci_write(host, ATMEL_PDC_RNCR, 0); | ||
529 | at91_mci_write(host, ATMEL_PDC_TPR, 0); | ||
530 | at91_mci_write(host, ATMEL_PDC_TCR, 0); | ||
531 | at91_mci_write(host, ATMEL_PDC_TNPR, 0); | ||
532 | at91_mci_write(host, ATMEL_PDC_TNCR, 0); | ||
533 | ier = AT91_MCI_CMDRDY; | ||
534 | } else { | ||
535 | /* zero block length and PDC mode */ | ||
536 | mr = at91_mci_read(host, AT91_MCI_MR) & 0x5fff; | ||
537 | mr |= (data->blksz & 0x3) ? AT91_MCI_PDCFBYTE : 0; | ||
538 | mr |= (block_length << 16); | ||
539 | mr |= AT91_MCI_PDCMODE; | ||
540 | at91_mci_write(host, AT91_MCI_MR, mr); | ||
541 | |||
542 | if (!(cpu_is_at91rm9200() || cpu_is_at91sam9261())) | ||
543 | at91_mci_write(host, AT91_MCI_BLKR, | ||
544 | AT91_MCI_BLKR_BCNT(blocks) | | ||
545 | AT91_MCI_BLKR_BLKLEN(block_length)); | ||
546 | |||
547 | /* | ||
548 | * Disable the PDC controller | ||
549 | */ | ||
550 | at91_mci_write(host, ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS | ATMEL_PDC_TXTDIS); | ||
551 | |||
552 | if (cmdr & AT91_MCI_TRCMD_START) { | ||
553 | data->bytes_xfered = 0; | ||
554 | host->transfer_index = 0; | ||
555 | host->in_use_index = 0; | ||
556 | if (cmdr & AT91_MCI_TRDIR) { | ||
557 | /* | ||
558 | * Handle a read | ||
559 | */ | ||
560 | host->total_length = 0; | ||
561 | |||
562 | at91_mci_write(host, ATMEL_PDC_RPR, host->physical_address); | ||
563 | at91_mci_write(host, ATMEL_PDC_RCR, (data->blksz & 0x3) ? | ||
564 | (blocks * block_length) : (blocks * block_length) / 4); | ||
565 | at91_mci_write(host, ATMEL_PDC_RNPR, 0); | ||
566 | at91_mci_write(host, ATMEL_PDC_RNCR, 0); | ||
567 | |||
568 | ier = AT91_MCI_ENDRX /* | AT91_MCI_RXBUFF */; | ||
569 | } | ||
570 | else { | ||
571 | /* | ||
572 | * Handle a write | ||
573 | */ | ||
574 | host->total_length = block_length * blocks; | ||
575 | /* | ||
576 | * MCI1 rev2xx Data Write Operation and | ||
577 | * number of bytes erratum | ||
578 | */ | ||
579 | if (at91mci_is_mci1rev2xx()) | ||
580 | if (host->total_length < 12) | ||
581 | host->total_length = 12; | ||
582 | |||
583 | at91_mci_sg_to_dma(host, data); | ||
584 | |||
585 | pr_debug("Transmitting %d bytes\n", host->total_length); | ||
586 | |||
587 | at91_mci_write(host, ATMEL_PDC_TPR, host->physical_address); | ||
588 | at91_mci_write(host, ATMEL_PDC_TCR, (data->blksz & 0x3) ? | ||
589 | host->total_length : host->total_length / 4); | ||
590 | |||
591 | ier = AT91_MCI_CMDRDY; | ||
592 | } | ||
593 | } | ||
594 | } | ||
595 | |||
596 | /* | ||
597 | * Send the command and then enable the PDC - not the other way round as | ||
598 | * the data sheet says | ||
599 | */ | ||
600 | |||
601 | at91_mci_write(host, AT91_MCI_ARGR, cmd->arg); | ||
602 | at91_mci_write(host, AT91_MCI_CMDR, cmdr); | ||
603 | |||
604 | if (cmdr & AT91_MCI_TRCMD_START) { | ||
605 | if (cmdr & AT91_MCI_TRDIR) | ||
606 | at91_mci_write(host, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); | ||
607 | } | ||
608 | |||
609 | /* Enable selected interrupts */ | ||
610 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_ERRORS | ier); | ||
611 | } | ||
612 | |||
613 | /* | ||
614 | * Process the next step in the request | ||
615 | */ | ||
616 | static void at91_mci_process_next(struct at91mci_host *host) | ||
617 | { | ||
618 | if (!(host->flags & FL_SENT_COMMAND)) { | ||
619 | host->flags |= FL_SENT_COMMAND; | ||
620 | at91_mci_send_command(host, host->request->cmd); | ||
621 | } | ||
622 | else if ((!(host->flags & FL_SENT_STOP)) && host->request->stop) { | ||
623 | host->flags |= FL_SENT_STOP; | ||
624 | at91_mci_send_command(host, host->request->stop); | ||
625 | } else { | ||
626 | del_timer(&host->timer); | ||
627 | /* the at91rm9200 mci controller hangs after some transfers, | ||
628 | * and the workaround is to reset it after each transfer. | ||
629 | */ | ||
630 | if (cpu_is_at91rm9200()) | ||
631 | at91_reset_host(host); | ||
632 | mmc_request_done(host->mmc, host->request); | ||
633 | } | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * Handle a command that has been completed | ||
638 | */ | ||
639 | static void at91_mci_completed_command(struct at91mci_host *host, unsigned int status) | ||
640 | { | ||
641 | struct mmc_command *cmd = host->cmd; | ||
642 | struct mmc_data *data = cmd->data; | ||
643 | |||
644 | at91_mci_write(host, AT91_MCI_IDR, 0xffffffff & ~(AT91_MCI_SDIOIRQA | AT91_MCI_SDIOIRQB)); | ||
645 | |||
646 | cmd->resp[0] = at91_mci_read(host, AT91_MCI_RSPR(0)); | ||
647 | cmd->resp[1] = at91_mci_read(host, AT91_MCI_RSPR(1)); | ||
648 | cmd->resp[2] = at91_mci_read(host, AT91_MCI_RSPR(2)); | ||
649 | cmd->resp[3] = at91_mci_read(host, AT91_MCI_RSPR(3)); | ||
650 | |||
651 | pr_debug("Status = %08X/%08x [%08X %08X %08X %08X]\n", | ||
652 | status, at91_mci_read(host, AT91_MCI_SR), | ||
653 | cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); | ||
654 | |||
655 | if (status & AT91_MCI_ERRORS) { | ||
656 | if ((status & AT91_MCI_RCRCE) && !(mmc_resp_type(cmd) & MMC_RSP_CRC)) { | ||
657 | cmd->error = 0; | ||
658 | } | ||
659 | else { | ||
660 | if (status & (AT91_MCI_DTOE | AT91_MCI_DCRCE)) { | ||
661 | if (data) { | ||
662 | if (status & AT91_MCI_DTOE) | ||
663 | data->error = -ETIMEDOUT; | ||
664 | else if (status & AT91_MCI_DCRCE) | ||
665 | data->error = -EILSEQ; | ||
666 | } | ||
667 | } else { | ||
668 | if (status & AT91_MCI_RTOE) | ||
669 | cmd->error = -ETIMEDOUT; | ||
670 | else if (status & AT91_MCI_RCRCE) | ||
671 | cmd->error = -EILSEQ; | ||
672 | else | ||
673 | cmd->error = -EIO; | ||
674 | } | ||
675 | |||
676 | pr_debug("Error detected and set to %d/%d (cmd = %d, retries = %d)\n", | ||
677 | cmd->error, data ? data->error : 0, | ||
678 | cmd->opcode, cmd->retries); | ||
679 | } | ||
680 | } | ||
681 | else | ||
682 | cmd->error = 0; | ||
683 | |||
684 | at91_mci_process_next(host); | ||
685 | } | ||
686 | |||
687 | /* | ||
688 | * Handle an MMC request | ||
689 | */ | ||
690 | static void at91_mci_request(struct mmc_host *mmc, struct mmc_request *mrq) | ||
691 | { | ||
692 | struct at91mci_host *host = mmc_priv(mmc); | ||
693 | host->request = mrq; | ||
694 | host->flags = 0; | ||
695 | |||
696 | /* more than 1s timeout needed with slow SD cards */ | ||
697 | mod_timer(&host->timer, jiffies + msecs_to_jiffies(2000)); | ||
698 | |||
699 | at91_mci_process_next(host); | ||
700 | } | ||
701 | |||
702 | /* | ||
703 | * Set the IOS | ||
704 | */ | ||
705 | static void at91_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | ||
706 | { | ||
707 | int clkdiv; | ||
708 | struct at91mci_host *host = mmc_priv(mmc); | ||
709 | unsigned long at91_master_clock = clk_get_rate(host->mci_clk); | ||
710 | |||
711 | host->bus_mode = ios->bus_mode; | ||
712 | |||
713 | if (ios->clock == 0) { | ||
714 | /* Disable the MCI controller */ | ||
715 | at91_mci_write(host, AT91_MCI_CR, AT91_MCI_MCIDIS); | ||
716 | clkdiv = 0; | ||
717 | } | ||
718 | else { | ||
719 | /* Enable the MCI controller */ | ||
720 | at91_mci_write(host, AT91_MCI_CR, AT91_MCI_MCIEN); | ||
721 | |||
722 | if ((at91_master_clock % (ios->clock * 2)) == 0) | ||
723 | clkdiv = ((at91_master_clock / ios->clock) / 2) - 1; | ||
724 | else | ||
725 | clkdiv = (at91_master_clock / ios->clock) / 2; | ||
726 | |||
727 | pr_debug("clkdiv = %d. mcck = %ld\n", clkdiv, | ||
728 | at91_master_clock / (2 * (clkdiv + 1))); | ||
729 | } | ||
730 | if (ios->bus_width == MMC_BUS_WIDTH_4 && host->board->wire4) { | ||
731 | pr_debug("MMC: Setting controller bus width to 4\n"); | ||
732 | at91_mci_write(host, AT91_MCI_SDCR, at91_mci_read(host, AT91_MCI_SDCR) | AT91_MCI_SDCBUS); | ||
733 | } | ||
734 | else { | ||
735 | pr_debug("MMC: Setting controller bus width to 1\n"); | ||
736 | at91_mci_write(host, AT91_MCI_SDCR, at91_mci_read(host, AT91_MCI_SDCR) & ~AT91_MCI_SDCBUS); | ||
737 | } | ||
738 | |||
739 | /* Set the clock divider */ | ||
740 | at91_mci_write(host, AT91_MCI_MR, (at91_mci_read(host, AT91_MCI_MR) & ~AT91_MCI_CLKDIV) | clkdiv); | ||
741 | |||
742 | /* maybe switch power to the card */ | ||
743 | if (gpio_is_valid(host->board->vcc_pin)) { | ||
744 | switch (ios->power_mode) { | ||
745 | case MMC_POWER_OFF: | ||
746 | gpio_set_value(host->board->vcc_pin, 0); | ||
747 | break; | ||
748 | case MMC_POWER_UP: | ||
749 | gpio_set_value(host->board->vcc_pin, 1); | ||
750 | break; | ||
751 | case MMC_POWER_ON: | ||
752 | break; | ||
753 | default: | ||
754 | WARN_ON(1); | ||
755 | } | ||
756 | } | ||
757 | } | ||
758 | |||
759 | /* | ||
760 | * Handle an interrupt | ||
761 | */ | ||
762 | static irqreturn_t at91_mci_irq(int irq, void *devid) | ||
763 | { | ||
764 | struct at91mci_host *host = devid; | ||
765 | int completed = 0; | ||
766 | unsigned int int_status, int_mask; | ||
767 | |||
768 | int_status = at91_mci_read(host, AT91_MCI_SR); | ||
769 | int_mask = at91_mci_read(host, AT91_MCI_IMR); | ||
770 | |||
771 | pr_debug("MCI irq: status = %08X, %08X, %08X\n", int_status, int_mask, | ||
772 | int_status & int_mask); | ||
773 | |||
774 | int_status = int_status & int_mask; | ||
775 | |||
776 | if (int_status & AT91_MCI_ERRORS) { | ||
777 | completed = 1; | ||
778 | |||
779 | if (int_status & AT91_MCI_UNRE) | ||
780 | pr_debug("MMC: Underrun error\n"); | ||
781 | if (int_status & AT91_MCI_OVRE) | ||
782 | pr_debug("MMC: Overrun error\n"); | ||
783 | if (int_status & AT91_MCI_DTOE) | ||
784 | pr_debug("MMC: Data timeout\n"); | ||
785 | if (int_status & AT91_MCI_DCRCE) | ||
786 | pr_debug("MMC: CRC error in data\n"); | ||
787 | if (int_status & AT91_MCI_RTOE) | ||
788 | pr_debug("MMC: Response timeout\n"); | ||
789 | if (int_status & AT91_MCI_RENDE) | ||
790 | pr_debug("MMC: Response end bit error\n"); | ||
791 | if (int_status & AT91_MCI_RCRCE) | ||
792 | pr_debug("MMC: Response CRC error\n"); | ||
793 | if (int_status & AT91_MCI_RDIRE) | ||
794 | pr_debug("MMC: Response direction error\n"); | ||
795 | if (int_status & AT91_MCI_RINDE) | ||
796 | pr_debug("MMC: Response index error\n"); | ||
797 | } else { | ||
798 | /* Only continue processing if no errors */ | ||
799 | |||
800 | if (int_status & AT91_MCI_TXBUFE) { | ||
801 | pr_debug("TX buffer empty\n"); | ||
802 | at91_mci_handle_transmitted(host); | ||
803 | } | ||
804 | |||
805 | if (int_status & AT91_MCI_ENDRX) { | ||
806 | pr_debug("ENDRX\n"); | ||
807 | at91_mci_post_dma_read(host); | ||
808 | } | ||
809 | |||
810 | if (int_status & AT91_MCI_RXBUFF) { | ||
811 | pr_debug("RX buffer full\n"); | ||
812 | at91_mci_write(host, ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS | ATMEL_PDC_TXTDIS); | ||
813 | at91_mci_write(host, AT91_MCI_IDR, AT91_MCI_RXBUFF | AT91_MCI_ENDRX); | ||
814 | completed = 1; | ||
815 | } | ||
816 | |||
817 | if (int_status & AT91_MCI_ENDTX) | ||
818 | pr_debug("Transmit has ended\n"); | ||
819 | |||
820 | if (int_status & AT91_MCI_NOTBUSY) { | ||
821 | pr_debug("Card is ready\n"); | ||
822 | at91_mci_update_bytes_xfered(host); | ||
823 | completed = 1; | ||
824 | } | ||
825 | |||
826 | if (int_status & AT91_MCI_DTIP) | ||
827 | pr_debug("Data transfer in progress\n"); | ||
828 | |||
829 | if (int_status & AT91_MCI_BLKE) { | ||
830 | pr_debug("Block transfer has ended\n"); | ||
831 | if (host->request->data && host->request->data->blocks > 1) { | ||
832 | /* multi block write : complete multi write | ||
833 | * command and send stop */ | ||
834 | completed = 1; | ||
835 | } else { | ||
836 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_NOTBUSY); | ||
837 | } | ||
838 | } | ||
839 | |||
840 | if (int_status & AT91_MCI_SDIOIRQA) | ||
841 | mmc_signal_sdio_irq(host->mmc); | ||
842 | |||
843 | if (int_status & AT91_MCI_SDIOIRQB) | ||
844 | mmc_signal_sdio_irq(host->mmc); | ||
845 | |||
846 | if (int_status & AT91_MCI_TXRDY) | ||
847 | pr_debug("Ready to transmit\n"); | ||
848 | |||
849 | if (int_status & AT91_MCI_RXRDY) | ||
850 | pr_debug("Ready to receive\n"); | ||
851 | |||
852 | if (int_status & AT91_MCI_CMDRDY) { | ||
853 | pr_debug("Command ready\n"); | ||
854 | completed = at91_mci_handle_cmdrdy(host); | ||
855 | } | ||
856 | } | ||
857 | |||
858 | if (completed) { | ||
859 | pr_debug("Completed command\n"); | ||
860 | at91_mci_write(host, AT91_MCI_IDR, 0xffffffff & ~(AT91_MCI_SDIOIRQA | AT91_MCI_SDIOIRQB)); | ||
861 | at91_mci_completed_command(host, int_status); | ||
862 | } else | ||
863 | at91_mci_write(host, AT91_MCI_IDR, int_status & ~(AT91_MCI_SDIOIRQA | AT91_MCI_SDIOIRQB)); | ||
864 | |||
865 | return IRQ_HANDLED; | ||
866 | } | ||
867 | |||
868 | static irqreturn_t at91_mmc_det_irq(int irq, void *_host) | ||
869 | { | ||
870 | struct at91mci_host *host = _host; | ||
871 | int present; | ||
872 | |||
873 | /* entering this ISR means that we have configured det_pin: | ||
874 | * we can use its value in board structure */ | ||
875 | present = !gpio_get_value(host->board->det_pin); | ||
876 | |||
877 | /* | ||
878 | * we expect this irq on both insert and remove, | ||
879 | * and use a short delay to debounce. | ||
880 | */ | ||
881 | if (present != host->present) { | ||
882 | host->present = present; | ||
883 | pr_debug("%s: card %s\n", mmc_hostname(host->mmc), | ||
884 | present ? "insert" : "remove"); | ||
885 | if (!present) { | ||
886 | pr_debug("****** Resetting SD-card bus width ******\n"); | ||
887 | at91_mci_write(host, AT91_MCI_SDCR, at91_mci_read(host, AT91_MCI_SDCR) & ~AT91_MCI_SDCBUS); | ||
888 | } | ||
889 | /* 0.5s needed because of early card detect switch firing */ | ||
890 | mmc_detect_change(host->mmc, msecs_to_jiffies(500)); | ||
891 | } | ||
892 | return IRQ_HANDLED; | ||
893 | } | ||
894 | |||
895 | static int at91_mci_get_ro(struct mmc_host *mmc) | ||
896 | { | ||
897 | struct at91mci_host *host = mmc_priv(mmc); | ||
898 | |||
899 | if (gpio_is_valid(host->board->wp_pin)) | ||
900 | return !!gpio_get_value(host->board->wp_pin); | ||
901 | /* | ||
902 | * Board doesn't support read only detection; let the mmc core | ||
903 | * decide what to do. | ||
904 | */ | ||
905 | return -ENOSYS; | ||
906 | } | ||
907 | |||
908 | static void at91_mci_enable_sdio_irq(struct mmc_host *mmc, int enable) | ||
909 | { | ||
910 | struct at91mci_host *host = mmc_priv(mmc); | ||
911 | |||
912 | pr_debug("%s: sdio_irq %c : %s\n", mmc_hostname(host->mmc), | ||
913 | host->board->slot_b ? 'B':'A', enable ? "enable" : "disable"); | ||
914 | at91_mci_write(host, enable ? AT91_MCI_IER : AT91_MCI_IDR, | ||
915 | host->board->slot_b ? AT91_MCI_SDIOIRQB : AT91_MCI_SDIOIRQA); | ||
916 | |||
917 | } | ||
918 | |||
919 | static const struct mmc_host_ops at91_mci_ops = { | ||
920 | .request = at91_mci_request, | ||
921 | .set_ios = at91_mci_set_ios, | ||
922 | .get_ro = at91_mci_get_ro, | ||
923 | .enable_sdio_irq = at91_mci_enable_sdio_irq, | ||
924 | }; | ||
925 | |||
926 | /* | ||
927 | * Probe for the device | ||
928 | */ | ||
929 | static int __init at91_mci_probe(struct platform_device *pdev) | ||
930 | { | ||
931 | struct mmc_host *mmc; | ||
932 | struct at91mci_host *host; | ||
933 | struct resource *res; | ||
934 | int ret; | ||
935 | |||
936 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
937 | if (!res) | ||
938 | return -ENXIO; | ||
939 | |||
940 | if (!request_mem_region(res->start, resource_size(res), DRIVER_NAME)) | ||
941 | return -EBUSY; | ||
942 | |||
943 | mmc = mmc_alloc_host(sizeof(struct at91mci_host), &pdev->dev); | ||
944 | if (!mmc) { | ||
945 | ret = -ENOMEM; | ||
946 | dev_dbg(&pdev->dev, "couldn't allocate mmc host\n"); | ||
947 | goto fail6; | ||
948 | } | ||
949 | |||
950 | mmc->ops = &at91_mci_ops; | ||
951 | mmc->f_min = 375000; | ||
952 | mmc->f_max = 25000000; | ||
953 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; | ||
954 | mmc->caps = 0; | ||
955 | |||
956 | mmc->max_blk_size = MCI_MAXBLKSIZE; | ||
957 | mmc->max_blk_count = MCI_BLKATONCE; | ||
958 | mmc->max_req_size = MCI_BUFSIZE; | ||
959 | mmc->max_segs = MCI_BLKATONCE; | ||
960 | mmc->max_seg_size = MCI_BUFSIZE; | ||
961 | |||
962 | host = mmc_priv(mmc); | ||
963 | host->mmc = mmc; | ||
964 | host->bus_mode = 0; | ||
965 | host->board = pdev->dev.platform_data; | ||
966 | if (host->board->wire4) { | ||
967 | if (at91mci_is_mci1rev2xx()) | ||
968 | mmc->caps |= MMC_CAP_4_BIT_DATA; | ||
969 | else | ||
970 | dev_warn(&pdev->dev, "4 wire bus mode not supported" | ||
971 | " - using 1 wire\n"); | ||
972 | } | ||
973 | |||
974 | host->buffer = dma_alloc_coherent(&pdev->dev, MCI_BUFSIZE, | ||
975 | &host->physical_address, GFP_KERNEL); | ||
976 | if (!host->buffer) { | ||
977 | ret = -ENOMEM; | ||
978 | dev_err(&pdev->dev, "Can't allocate transmit buffer\n"); | ||
979 | goto fail5; | ||
980 | } | ||
981 | |||
982 | /* Add SDIO capability when available */ | ||
983 | if (at91mci_is_mci1rev2xx()) { | ||
984 | /* at91mci MCI1 rev2xx sdio interrupt erratum */ | ||
985 | if (host->board->wire4 || !host->board->slot_b) | ||
986 | mmc->caps |= MMC_CAP_SDIO_IRQ; | ||
987 | } | ||
988 | |||
989 | /* | ||
990 | * Reserve GPIOs ... board init code makes sure these pins are set | ||
991 | * up as GPIOs with the right direction (input, except for vcc) | ||
992 | */ | ||
993 | if (gpio_is_valid(host->board->det_pin)) { | ||
994 | ret = gpio_request(host->board->det_pin, "mmc_detect"); | ||
995 | if (ret < 0) { | ||
996 | dev_dbg(&pdev->dev, "couldn't claim card detect pin\n"); | ||
997 | goto fail4b; | ||
998 | } | ||
999 | } | ||
1000 | if (gpio_is_valid(host->board->wp_pin)) { | ||
1001 | ret = gpio_request(host->board->wp_pin, "mmc_wp"); | ||
1002 | if (ret < 0) { | ||
1003 | dev_dbg(&pdev->dev, "couldn't claim wp sense pin\n"); | ||
1004 | goto fail4; | ||
1005 | } | ||
1006 | } | ||
1007 | if (gpio_is_valid(host->board->vcc_pin)) { | ||
1008 | ret = gpio_request(host->board->vcc_pin, "mmc_vcc"); | ||
1009 | if (ret < 0) { | ||
1010 | dev_dbg(&pdev->dev, "couldn't claim vcc switch pin\n"); | ||
1011 | goto fail3; | ||
1012 | } | ||
1013 | } | ||
1014 | |||
1015 | /* | ||
1016 | * Get Clock | ||
1017 | */ | ||
1018 | host->mci_clk = clk_get(&pdev->dev, "mci_clk"); | ||
1019 | if (IS_ERR(host->mci_clk)) { | ||
1020 | ret = -ENODEV; | ||
1021 | dev_dbg(&pdev->dev, "no mci_clk?\n"); | ||
1022 | goto fail2; | ||
1023 | } | ||
1024 | |||
1025 | /* | ||
1026 | * Map I/O region | ||
1027 | */ | ||
1028 | host->baseaddr = ioremap(res->start, resource_size(res)); | ||
1029 | if (!host->baseaddr) { | ||
1030 | ret = -ENOMEM; | ||
1031 | goto fail1; | ||
1032 | } | ||
1033 | |||
1034 | /* | ||
1035 | * Reset hardware | ||
1036 | */ | ||
1037 | clk_enable(host->mci_clk); /* Enable the peripheral clock */ | ||
1038 | at91_mci_disable(host); | ||
1039 | at91_mci_enable(host); | ||
1040 | |||
1041 | /* | ||
1042 | * Allocate the MCI interrupt | ||
1043 | */ | ||
1044 | host->irq = platform_get_irq(pdev, 0); | ||
1045 | ret = request_irq(host->irq, at91_mci_irq, IRQF_SHARED, | ||
1046 | mmc_hostname(mmc), host); | ||
1047 | if (ret) { | ||
1048 | dev_dbg(&pdev->dev, "request MCI interrupt failed\n"); | ||
1049 | goto fail0; | ||
1050 | } | ||
1051 | |||
1052 | setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host); | ||
1053 | |||
1054 | platform_set_drvdata(pdev, mmc); | ||
1055 | |||
1056 | /* | ||
1057 | * Add host to MMC layer | ||
1058 | */ | ||
1059 | if (gpio_is_valid(host->board->det_pin)) { | ||
1060 | host->present = !gpio_get_value(host->board->det_pin); | ||
1061 | } | ||
1062 | else | ||
1063 | host->present = -1; | ||
1064 | |||
1065 | mmc_add_host(mmc); | ||
1066 | |||
1067 | /* | ||
1068 | * monitor card insertion/removal if we can | ||
1069 | */ | ||
1070 | if (gpio_is_valid(host->board->det_pin)) { | ||
1071 | ret = request_irq(gpio_to_irq(host->board->det_pin), | ||
1072 | at91_mmc_det_irq, 0, mmc_hostname(mmc), host); | ||
1073 | if (ret) | ||
1074 | dev_warn(&pdev->dev, "request MMC detect irq failed\n"); | ||
1075 | else | ||
1076 | device_init_wakeup(&pdev->dev, 1); | ||
1077 | } | ||
1078 | |||
1079 | pr_debug("Added MCI driver\n"); | ||
1080 | |||
1081 | return 0; | ||
1082 | |||
1083 | fail0: | ||
1084 | clk_disable(host->mci_clk); | ||
1085 | iounmap(host->baseaddr); | ||
1086 | fail1: | ||
1087 | clk_put(host->mci_clk); | ||
1088 | fail2: | ||
1089 | if (gpio_is_valid(host->board->vcc_pin)) | ||
1090 | gpio_free(host->board->vcc_pin); | ||
1091 | fail3: | ||
1092 | if (gpio_is_valid(host->board->wp_pin)) | ||
1093 | gpio_free(host->board->wp_pin); | ||
1094 | fail4: | ||
1095 | if (gpio_is_valid(host->board->det_pin)) | ||
1096 | gpio_free(host->board->det_pin); | ||
1097 | fail4b: | ||
1098 | if (host->buffer) | ||
1099 | dma_free_coherent(&pdev->dev, MCI_BUFSIZE, | ||
1100 | host->buffer, host->physical_address); | ||
1101 | fail5: | ||
1102 | mmc_free_host(mmc); | ||
1103 | fail6: | ||
1104 | release_mem_region(res->start, resource_size(res)); | ||
1105 | dev_err(&pdev->dev, "probe failed, err %d\n", ret); | ||
1106 | return ret; | ||
1107 | } | ||
1108 | |||
1109 | /* | ||
1110 | * Remove a device | ||
1111 | */ | ||
1112 | static int __exit at91_mci_remove(struct platform_device *pdev) | ||
1113 | { | ||
1114 | struct mmc_host *mmc = platform_get_drvdata(pdev); | ||
1115 | struct at91mci_host *host; | ||
1116 | struct resource *res; | ||
1117 | |||
1118 | if (!mmc) | ||
1119 | return -1; | ||
1120 | |||
1121 | host = mmc_priv(mmc); | ||
1122 | |||
1123 | if (host->buffer) | ||
1124 | dma_free_coherent(&pdev->dev, MCI_BUFSIZE, | ||
1125 | host->buffer, host->physical_address); | ||
1126 | |||
1127 | if (gpio_is_valid(host->board->det_pin)) { | ||
1128 | if (device_can_wakeup(&pdev->dev)) | ||
1129 | free_irq(gpio_to_irq(host->board->det_pin), host); | ||
1130 | device_init_wakeup(&pdev->dev, 0); | ||
1131 | gpio_free(host->board->det_pin); | ||
1132 | } | ||
1133 | |||
1134 | at91_mci_disable(host); | ||
1135 | del_timer_sync(&host->timer); | ||
1136 | mmc_remove_host(mmc); | ||
1137 | free_irq(host->irq, host); | ||
1138 | |||
1139 | clk_disable(host->mci_clk); /* Disable the peripheral clock */ | ||
1140 | clk_put(host->mci_clk); | ||
1141 | |||
1142 | if (gpio_is_valid(host->board->vcc_pin)) | ||
1143 | gpio_free(host->board->vcc_pin); | ||
1144 | if (gpio_is_valid(host->board->wp_pin)) | ||
1145 | gpio_free(host->board->wp_pin); | ||
1146 | |||
1147 | iounmap(host->baseaddr); | ||
1148 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1149 | release_mem_region(res->start, resource_size(res)); | ||
1150 | |||
1151 | mmc_free_host(mmc); | ||
1152 | platform_set_drvdata(pdev, NULL); | ||
1153 | pr_debug("MCI Removed\n"); | ||
1154 | |||
1155 | return 0; | ||
1156 | } | ||
1157 | |||
1158 | #ifdef CONFIG_PM | ||
1159 | static int at91_mci_suspend(struct platform_device *pdev, pm_message_t state) | ||
1160 | { | ||
1161 | struct mmc_host *mmc = platform_get_drvdata(pdev); | ||
1162 | struct at91mci_host *host = mmc_priv(mmc); | ||
1163 | int ret = 0; | ||
1164 | |||
1165 | if (gpio_is_valid(host->board->det_pin) && device_may_wakeup(&pdev->dev)) | ||
1166 | enable_irq_wake(host->board->det_pin); | ||
1167 | |||
1168 | if (mmc) | ||
1169 | ret = mmc_suspend_host(mmc); | ||
1170 | |||
1171 | return ret; | ||
1172 | } | ||
1173 | |||
1174 | static int at91_mci_resume(struct platform_device *pdev) | ||
1175 | { | ||
1176 | struct mmc_host *mmc = platform_get_drvdata(pdev); | ||
1177 | struct at91mci_host *host = mmc_priv(mmc); | ||
1178 | int ret = 0; | ||
1179 | |||
1180 | if (gpio_is_valid(host->board->det_pin) && device_may_wakeup(&pdev->dev)) | ||
1181 | disable_irq_wake(host->board->det_pin); | ||
1182 | |||
1183 | if (mmc) | ||
1184 | ret = mmc_resume_host(mmc); | ||
1185 | |||
1186 | return ret; | ||
1187 | } | ||
1188 | #else | ||
1189 | #define at91_mci_suspend NULL | ||
1190 | #define at91_mci_resume NULL | ||
1191 | #endif | ||
1192 | |||
1193 | static struct platform_driver at91_mci_driver = { | ||
1194 | .remove = __exit_p(at91_mci_remove), | ||
1195 | .suspend = at91_mci_suspend, | ||
1196 | .resume = at91_mci_resume, | ||
1197 | .driver = { | ||
1198 | .name = DRIVER_NAME, | ||
1199 | .owner = THIS_MODULE, | ||
1200 | }, | ||
1201 | }; | ||
1202 | |||
1203 | static int __init at91_mci_init(void) | ||
1204 | { | ||
1205 | return platform_driver_probe(&at91_mci_driver, at91_mci_probe); | ||
1206 | } | ||
1207 | |||
1208 | static void __exit at91_mci_exit(void) | ||
1209 | { | ||
1210 | platform_driver_unregister(&at91_mci_driver); | ||
1211 | } | ||
1212 | |||
1213 | module_init(at91_mci_init); | ||
1214 | module_exit(at91_mci_exit); | ||
1215 | |||
1216 | MODULE_DESCRIPTION("AT91 Multimedia Card Interface driver"); | ||
1217 | MODULE_AUTHOR("Nick Randell"); | ||
1218 | MODULE_LICENSE("GPL"); | ||
1219 | MODULE_ALIAS("platform:at91_mci"); | ||
diff --git a/drivers/mmc/host/at91_mci.h b/drivers/mmc/host/at91_mci.h deleted file mode 100644 index eec3a6b1c2bc..000000000000 --- a/drivers/mmc/host/at91_mci.h +++ /dev/null | |||
@@ -1,115 +0,0 @@ | |||
1 | /* | ||
2 | * drivers/mmc/host/at91_mci.h | ||
3 | * | ||
4 | * Copyright (C) 2005 Ivan Kokshaysky | ||
5 | * Copyright (C) SAN People | ||
6 | * | ||
7 | * MultiMedia Card Interface (MCI) registers. | ||
8 | * Based on AT91RM9200 datasheet revision F. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | */ | ||
15 | |||
16 | #ifndef AT91_MCI_H | ||
17 | #define AT91_MCI_H | ||
18 | |||
19 | #define AT91_MCI_CR 0x00 /* Control Register */ | ||
20 | #define AT91_MCI_MCIEN (1 << 0) /* Multi-Media Interface Enable */ | ||
21 | #define AT91_MCI_MCIDIS (1 << 1) /* Multi-Media Interface Disable */ | ||
22 | #define AT91_MCI_PWSEN (1 << 2) /* Power Save Mode Enable */ | ||
23 | #define AT91_MCI_PWSDIS (1 << 3) /* Power Save Mode Disable */ | ||
24 | #define AT91_MCI_SWRST (1 << 7) /* Software Reset */ | ||
25 | |||
26 | #define AT91_MCI_MR 0x04 /* Mode Register */ | ||
27 | #define AT91_MCI_CLKDIV (0xff << 0) /* Clock Divider */ | ||
28 | #define AT91_MCI_PWSDIV (7 << 8) /* Power Saving Divider */ | ||
29 | #define AT91_MCI_RDPROOF (1 << 11) /* Read Proof Enable [SAM926[03] only] */ | ||
30 | #define AT91_MCI_WRPROOF (1 << 12) /* Write Proof Enable [SAM926[03] only] */ | ||
31 | #define AT91_MCI_PDCFBYTE (1 << 13) /* PDC Force Byte Transfer [SAM926[03] only] */ | ||
32 | #define AT91_MCI_PDCPADV (1 << 14) /* PDC Padding Value */ | ||
33 | #define AT91_MCI_PDCMODE (1 << 15) /* PDC-orientated Mode */ | ||
34 | #define AT91_MCI_BLKLEN (0xfff << 18) /* Data Block Length */ | ||
35 | |||
36 | #define AT91_MCI_DTOR 0x08 /* Data Timeout Register */ | ||
37 | #define AT91_MCI_DTOCYC (0xf << 0) /* Data Timeout Cycle Number */ | ||
38 | #define AT91_MCI_DTOMUL (7 << 4) /* Data Timeout Multiplier */ | ||
39 | #define AT91_MCI_DTOMUL_1 (0 << 4) | ||
40 | #define AT91_MCI_DTOMUL_16 (1 << 4) | ||
41 | #define AT91_MCI_DTOMUL_128 (2 << 4) | ||
42 | #define AT91_MCI_DTOMUL_256 (3 << 4) | ||
43 | #define AT91_MCI_DTOMUL_1K (4 << 4) | ||
44 | #define AT91_MCI_DTOMUL_4K (5 << 4) | ||
45 | #define AT91_MCI_DTOMUL_64K (6 << 4) | ||
46 | #define AT91_MCI_DTOMUL_1M (7 << 4) | ||
47 | |||
48 | #define AT91_MCI_SDCR 0x0c /* SD Card Register */ | ||
49 | #define AT91_MCI_SDCSEL (3 << 0) /* SD Card Selector */ | ||
50 | #define AT91_MCI_SDCBUS (1 << 7) /* 1-bit or 4-bit bus */ | ||
51 | |||
52 | #define AT91_MCI_ARGR 0x10 /* Argument Register */ | ||
53 | |||
54 | #define AT91_MCI_CMDR 0x14 /* Command Register */ | ||
55 | #define AT91_MCI_CMDNB (0x3f << 0) /* Command Number */ | ||
56 | #define AT91_MCI_RSPTYP (3 << 6) /* Response Type */ | ||
57 | #define AT91_MCI_RSPTYP_NONE (0 << 6) | ||
58 | #define AT91_MCI_RSPTYP_48 (1 << 6) | ||
59 | #define AT91_MCI_RSPTYP_136 (2 << 6) | ||
60 | #define AT91_MCI_SPCMD (7 << 8) /* Special Command */ | ||
61 | #define AT91_MCI_SPCMD_NONE (0 << 8) | ||
62 | #define AT91_MCI_SPCMD_INIT (1 << 8) | ||
63 | #define AT91_MCI_SPCMD_SYNC (2 << 8) | ||
64 | #define AT91_MCI_SPCMD_ICMD (4 << 8) | ||
65 | #define AT91_MCI_SPCMD_IRESP (5 << 8) | ||
66 | #define AT91_MCI_OPDCMD (1 << 11) /* Open Drain Command */ | ||
67 | #define AT91_MCI_MAXLAT (1 << 12) /* Max Latency for Command to Response */ | ||
68 | #define AT91_MCI_TRCMD (3 << 16) /* Transfer Command */ | ||
69 | #define AT91_MCI_TRCMD_NONE (0 << 16) | ||
70 | #define AT91_MCI_TRCMD_START (1 << 16) | ||
71 | #define AT91_MCI_TRCMD_STOP (2 << 16) | ||
72 | #define AT91_MCI_TRDIR (1 << 18) /* Transfer Direction */ | ||
73 | #define AT91_MCI_TRTYP (3 << 19) /* Transfer Type */ | ||
74 | #define AT91_MCI_TRTYP_BLOCK (0 << 19) | ||
75 | #define AT91_MCI_TRTYP_MULTIPLE (1 << 19) | ||
76 | #define AT91_MCI_TRTYP_STREAM (2 << 19) | ||
77 | #define AT91_MCI_TRTYP_SDIO_BYTE (4 << 19) | ||
78 | #define AT91_MCI_TRTYP_SDIO_BLOCK (5 << 19) | ||
79 | |||
80 | #define AT91_MCI_BLKR 0x18 /* Block Register */ | ||
81 | #define AT91_MCI_BLKR_BCNT(n) ((0xffff & (n)) << 0) /* Block count */ | ||
82 | #define AT91_MCI_BLKR_BLKLEN(n) ((0xffff & (n)) << 16) /* Block length */ | ||
83 | |||
84 | #define AT91_MCI_RSPR(n) (0x20 + ((n) * 4)) /* Response Registers 0-3 */ | ||
85 | #define AT91_MCR_RDR 0x30 /* Receive Data Register */ | ||
86 | #define AT91_MCR_TDR 0x34 /* Transmit Data Register */ | ||
87 | |||
88 | #define AT91_MCI_SR 0x40 /* Status Register */ | ||
89 | #define AT91_MCI_CMDRDY (1 << 0) /* Command Ready */ | ||
90 | #define AT91_MCI_RXRDY (1 << 1) /* Receiver Ready */ | ||
91 | #define AT91_MCI_TXRDY (1 << 2) /* Transmit Ready */ | ||
92 | #define AT91_MCI_BLKE (1 << 3) /* Data Block Ended */ | ||
93 | #define AT91_MCI_DTIP (1 << 4) /* Data Transfer in Progress */ | ||
94 | #define AT91_MCI_NOTBUSY (1 << 5) /* Data Not Busy */ | ||
95 | #define AT91_MCI_ENDRX (1 << 6) /* End of RX Buffer */ | ||
96 | #define AT91_MCI_ENDTX (1 << 7) /* End fo TX Buffer */ | ||
97 | #define AT91_MCI_SDIOIRQA (1 << 8) /* SDIO Interrupt for Slot A */ | ||
98 | #define AT91_MCI_SDIOIRQB (1 << 9) /* SDIO Interrupt for Slot B */ | ||
99 | #define AT91_MCI_RXBUFF (1 << 14) /* RX Buffer Full */ | ||
100 | #define AT91_MCI_TXBUFE (1 << 15) /* TX Buffer Empty */ | ||
101 | #define AT91_MCI_RINDE (1 << 16) /* Response Index Error */ | ||
102 | #define AT91_MCI_RDIRE (1 << 17) /* Response Direction Error */ | ||
103 | #define AT91_MCI_RCRCE (1 << 18) /* Response CRC Error */ | ||
104 | #define AT91_MCI_RENDE (1 << 19) /* Response End Bit Error */ | ||
105 | #define AT91_MCI_RTOE (1 << 20) /* Response Time-out Error */ | ||
106 | #define AT91_MCI_DCRCE (1 << 21) /* Data CRC Error */ | ||
107 | #define AT91_MCI_DTOE (1 << 22) /* Data Time-out Error */ | ||
108 | #define AT91_MCI_OVRE (1 << 30) /* Overrun */ | ||
109 | #define AT91_MCI_UNRE (1 << 31) /* Underrun */ | ||
110 | |||
111 | #define AT91_MCI_IER 0x44 /* Interrupt Enable Register */ | ||
112 | #define AT91_MCI_IDR 0x48 /* Interrupt Disable Register */ | ||
113 | #define AT91_MCI_IMR 0x4c /* Interrupt Mask Register */ | ||
114 | |||
115 | #endif | ||
diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c index edb37e9135ae..53a09cbb2c7c 100644 --- a/drivers/mmc/host/dw_mmc-pci.c +++ b/drivers/mmc/host/dw_mmc-pci.c | |||
@@ -134,7 +134,7 @@ static struct pci_driver dw_mci_pci_driver = { | |||
134 | .name = "dw_mmc_pci", | 134 | .name = "dw_mmc_pci", |
135 | .id_table = dw_mci_pci_id, | 135 | .id_table = dw_mci_pci_id, |
136 | .probe = dw_mci_pci_probe, | 136 | .probe = dw_mci_pci_probe, |
137 | .remove = dw_mci_pci_remove, | 137 | .remove = __devexit_p(dw_mci_pci_remove), |
138 | .driver = { | 138 | .driver = { |
139 | .pm = &dw_mci_pci_pmops | 139 | .pm = &dw_mci_pci_pmops |
140 | }, | 140 | }, |
diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index 917936bee5d5..4e133709e33d 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c | |||
@@ -119,7 +119,8 @@ static const struct of_device_id dw_mci_pltfm_match[] = { | |||
119 | MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match); | 119 | MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match); |
120 | 120 | ||
121 | static struct platform_driver dw_mci_pltfm_driver = { | 121 | static struct platform_driver dw_mci_pltfm_driver = { |
122 | .remove = __exit_p(dw_mci_pltfm_remove), | 122 | .probe = dw_mci_pltfm_probe, |
123 | .remove = __devexit_p(dw_mci_pltfm_remove), | ||
123 | .driver = { | 124 | .driver = { |
124 | .name = "dw_mmc", | 125 | .name = "dw_mmc", |
125 | .of_match_table = of_match_ptr(dw_mci_pltfm_match), | 126 | .of_match_table = of_match_ptr(dw_mci_pltfm_match), |
@@ -127,18 +128,7 @@ static struct platform_driver dw_mci_pltfm_driver = { | |||
127 | }, | 128 | }, |
128 | }; | 129 | }; |
129 | 130 | ||
130 | static int __init dw_mci_init(void) | 131 | module_platform_driver(dw_mci_pltfm_driver); |
131 | { | ||
132 | return platform_driver_probe(&dw_mci_pltfm_driver, dw_mci_pltfm_probe); | ||
133 | } | ||
134 | |||
135 | static void __exit dw_mci_exit(void) | ||
136 | { | ||
137 | platform_driver_unregister(&dw_mci_pltfm_driver); | ||
138 | } | ||
139 | |||
140 | module_init(dw_mci_init); | ||
141 | module_exit(dw_mci_exit); | ||
142 | 132 | ||
143 | MODULE_DESCRIPTION("DW Multimedia Card Interface driver"); | 133 | MODULE_DESCRIPTION("DW Multimedia Card Interface driver"); |
144 | MODULE_AUTHOR("NXP Semiconductor VietNam"); | 134 | MODULE_AUTHOR("NXP Semiconductor VietNam"); |
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index c0667c8af2bd..323c5022c2ca 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c | |||
@@ -232,7 +232,7 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd) | |||
232 | { | 232 | { |
233 | struct mmc_data *data; | 233 | struct mmc_data *data; |
234 | struct dw_mci_slot *slot = mmc_priv(mmc); | 234 | struct dw_mci_slot *slot = mmc_priv(mmc); |
235 | struct dw_mci_drv_data *drv_data = slot->host->drv_data; | 235 | const struct dw_mci_drv_data *drv_data = slot->host->drv_data; |
236 | u32 cmdr; | 236 | u32 cmdr; |
237 | cmd->error = -EINPROGRESS; | 237 | cmd->error = -EINPROGRESS; |
238 | 238 | ||
@@ -617,13 +617,13 @@ static void mci_send_cmd(struct dw_mci_slot *slot, u32 cmd, u32 arg) | |||
617 | cmd, arg, cmd_status); | 617 | cmd, arg, cmd_status); |
618 | } | 618 | } |
619 | 619 | ||
620 | static void dw_mci_setup_bus(struct dw_mci_slot *slot) | 620 | static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit) |
621 | { | 621 | { |
622 | struct dw_mci *host = slot->host; | 622 | struct dw_mci *host = slot->host; |
623 | u32 div; | 623 | u32 div; |
624 | u32 clk_en_a; | 624 | u32 clk_en_a; |
625 | 625 | ||
626 | if (slot->clock != host->current_speed) { | 626 | if (slot->clock != host->current_speed || force_clkinit) { |
627 | div = host->bus_hz / slot->clock; | 627 | div = host->bus_hz / slot->clock; |
628 | if (host->bus_hz % slot->clock && host->bus_hz > slot->clock) | 628 | if (host->bus_hz % slot->clock && host->bus_hz > slot->clock) |
629 | /* | 629 | /* |
@@ -683,9 +683,6 @@ static void __dw_mci_start_request(struct dw_mci *host, | |||
683 | if (host->pdata->select_slot) | 683 | if (host->pdata->select_slot) |
684 | host->pdata->select_slot(slot->id); | 684 | host->pdata->select_slot(slot->id); |
685 | 685 | ||
686 | /* Slot specific timing and width adjustment */ | ||
687 | dw_mci_setup_bus(slot); | ||
688 | |||
689 | host->cur_slot = slot; | 686 | host->cur_slot = slot; |
690 | host->mrq = mrq; | 687 | host->mrq = mrq; |
691 | 688 | ||
@@ -773,22 +770,19 @@ static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
773 | static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 770 | static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
774 | { | 771 | { |
775 | struct dw_mci_slot *slot = mmc_priv(mmc); | 772 | struct dw_mci_slot *slot = mmc_priv(mmc); |
776 | struct dw_mci_drv_data *drv_data = slot->host->drv_data; | 773 | const struct dw_mci_drv_data *drv_data = slot->host->drv_data; |
777 | u32 regs; | 774 | u32 regs; |
778 | 775 | ||
779 | /* set default 1 bit mode */ | ||
780 | slot->ctype = SDMMC_CTYPE_1BIT; | ||
781 | |||
782 | switch (ios->bus_width) { | 776 | switch (ios->bus_width) { |
783 | case MMC_BUS_WIDTH_1: | ||
784 | slot->ctype = SDMMC_CTYPE_1BIT; | ||
785 | break; | ||
786 | case MMC_BUS_WIDTH_4: | 777 | case MMC_BUS_WIDTH_4: |
787 | slot->ctype = SDMMC_CTYPE_4BIT; | 778 | slot->ctype = SDMMC_CTYPE_4BIT; |
788 | break; | 779 | break; |
789 | case MMC_BUS_WIDTH_8: | 780 | case MMC_BUS_WIDTH_8: |
790 | slot->ctype = SDMMC_CTYPE_8BIT; | 781 | slot->ctype = SDMMC_CTYPE_8BIT; |
791 | break; | 782 | break; |
783 | default: | ||
784 | /* set default 1 bit mode */ | ||
785 | slot->ctype = SDMMC_CTYPE_1BIT; | ||
792 | } | 786 | } |
793 | 787 | ||
794 | regs = mci_readl(slot->host, UHS_REG); | 788 | regs = mci_readl(slot->host, UHS_REG); |
@@ -812,6 +806,9 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
812 | if (drv_data && drv_data->set_ios) | 806 | if (drv_data && drv_data->set_ios) |
813 | drv_data->set_ios(slot->host, ios); | 807 | drv_data->set_ios(slot->host, ios); |
814 | 808 | ||
809 | /* Slot specific timing and width adjustment */ | ||
810 | dw_mci_setup_bus(slot, false); | ||
811 | |||
815 | switch (ios->power_mode) { | 812 | switch (ios->power_mode) { |
816 | case MMC_POWER_UP: | 813 | case MMC_POWER_UP: |
817 | set_bit(DW_MMC_CARD_NEED_INIT, &slot->flags); | 814 | set_bit(DW_MMC_CARD_NEED_INIT, &slot->flags); |
@@ -1817,7 +1814,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1817 | { | 1814 | { |
1818 | struct mmc_host *mmc; | 1815 | struct mmc_host *mmc; |
1819 | struct dw_mci_slot *slot; | 1816 | struct dw_mci_slot *slot; |
1820 | struct dw_mci_drv_data *drv_data = host->drv_data; | 1817 | const struct dw_mci_drv_data *drv_data = host->drv_data; |
1821 | int ctrl_id, ret; | 1818 | int ctrl_id, ret; |
1822 | u8 bus_width; | 1819 | u8 bus_width; |
1823 | 1820 | ||
@@ -1850,6 +1847,9 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1850 | if (host->pdata->caps) | 1847 | if (host->pdata->caps) |
1851 | mmc->caps = host->pdata->caps; | 1848 | mmc->caps = host->pdata->caps; |
1852 | 1849 | ||
1850 | if (host->pdata->pm_caps) | ||
1851 | mmc->pm_caps = host->pdata->pm_caps; | ||
1852 | |||
1853 | if (host->dev->of_node) { | 1853 | if (host->dev->of_node) { |
1854 | ctrl_id = of_alias_get_id(host->dev->of_node, "mshc"); | 1854 | ctrl_id = of_alias_get_id(host->dev->of_node, "mshc"); |
1855 | if (ctrl_id < 0) | 1855 | if (ctrl_id < 0) |
@@ -1911,7 +1911,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1911 | #endif /* CONFIG_MMC_DW_IDMAC */ | 1911 | #endif /* CONFIG_MMC_DW_IDMAC */ |
1912 | } | 1912 | } |
1913 | 1913 | ||
1914 | host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); | 1914 | host->vmmc = devm_regulator_get(mmc_dev(mmc), "vmmc"); |
1915 | if (IS_ERR(host->vmmc)) { | 1915 | if (IS_ERR(host->vmmc)) { |
1916 | pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc)); | 1916 | pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc)); |
1917 | host->vmmc = NULL; | 1917 | host->vmmc = NULL; |
@@ -1960,7 +1960,7 @@ static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, unsigned int id) | |||
1960 | static void dw_mci_init_dma(struct dw_mci *host) | 1960 | static void dw_mci_init_dma(struct dw_mci *host) |
1961 | { | 1961 | { |
1962 | /* Alloc memory for sg translation */ | 1962 | /* Alloc memory for sg translation */ |
1963 | host->sg_cpu = dma_alloc_coherent(host->dev, PAGE_SIZE, | 1963 | host->sg_cpu = dmam_alloc_coherent(host->dev, PAGE_SIZE, |
1964 | &host->sg_dma, GFP_KERNEL); | 1964 | &host->sg_dma, GFP_KERNEL); |
1965 | if (!host->sg_cpu) { | 1965 | if (!host->sg_cpu) { |
1966 | dev_err(host->dev, "%s: could not alloc DMA memory\n", | 1966 | dev_err(host->dev, "%s: could not alloc DMA memory\n", |
@@ -2038,7 +2038,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) | |||
2038 | struct dw_mci_board *pdata; | 2038 | struct dw_mci_board *pdata; |
2039 | struct device *dev = host->dev; | 2039 | struct device *dev = host->dev; |
2040 | struct device_node *np = dev->of_node; | 2040 | struct device_node *np = dev->of_node; |
2041 | struct dw_mci_drv_data *drv_data = host->drv_data; | 2041 | const struct dw_mci_drv_data *drv_data = host->drv_data; |
2042 | int idx, ret; | 2042 | int idx, ret; |
2043 | 2043 | ||
2044 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | 2044 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); |
@@ -2072,6 +2072,12 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) | |||
2072 | return ERR_PTR(ret); | 2072 | return ERR_PTR(ret); |
2073 | } | 2073 | } |
2074 | 2074 | ||
2075 | if (of_find_property(np, "keep-power-in-suspend", NULL)) | ||
2076 | pdata->pm_caps |= MMC_PM_KEEP_POWER; | ||
2077 | |||
2078 | if (of_find_property(np, "enable-sdio-wakeup", NULL)) | ||
2079 | pdata->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; | ||
2080 | |||
2075 | return pdata; | 2081 | return pdata; |
2076 | } | 2082 | } |
2077 | 2083 | ||
@@ -2084,7 +2090,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) | |||
2084 | 2090 | ||
2085 | int dw_mci_probe(struct dw_mci *host) | 2091 | int dw_mci_probe(struct dw_mci *host) |
2086 | { | 2092 | { |
2087 | struct dw_mci_drv_data *drv_data = host->drv_data; | 2093 | const struct dw_mci_drv_data *drv_data = host->drv_data; |
2088 | int width, i, ret = 0; | 2094 | int width, i, ret = 0; |
2089 | u32 fifo_size; | 2095 | u32 fifo_size; |
2090 | int init_slots = 0; | 2096 | int init_slots = 0; |
@@ -2103,26 +2109,24 @@ int dw_mci_probe(struct dw_mci *host) | |||
2103 | return -ENODEV; | 2109 | return -ENODEV; |
2104 | } | 2110 | } |
2105 | 2111 | ||
2106 | host->biu_clk = clk_get(host->dev, "biu"); | 2112 | host->biu_clk = devm_clk_get(host->dev, "biu"); |
2107 | if (IS_ERR(host->biu_clk)) { | 2113 | if (IS_ERR(host->biu_clk)) { |
2108 | dev_dbg(host->dev, "biu clock not available\n"); | 2114 | dev_dbg(host->dev, "biu clock not available\n"); |
2109 | } else { | 2115 | } else { |
2110 | ret = clk_prepare_enable(host->biu_clk); | 2116 | ret = clk_prepare_enable(host->biu_clk); |
2111 | if (ret) { | 2117 | if (ret) { |
2112 | dev_err(host->dev, "failed to enable biu clock\n"); | 2118 | dev_err(host->dev, "failed to enable biu clock\n"); |
2113 | clk_put(host->biu_clk); | ||
2114 | return ret; | 2119 | return ret; |
2115 | } | 2120 | } |
2116 | } | 2121 | } |
2117 | 2122 | ||
2118 | host->ciu_clk = clk_get(host->dev, "ciu"); | 2123 | host->ciu_clk = devm_clk_get(host->dev, "ciu"); |
2119 | if (IS_ERR(host->ciu_clk)) { | 2124 | if (IS_ERR(host->ciu_clk)) { |
2120 | dev_dbg(host->dev, "ciu clock not available\n"); | 2125 | dev_dbg(host->dev, "ciu clock not available\n"); |
2121 | } else { | 2126 | } else { |
2122 | ret = clk_prepare_enable(host->ciu_clk); | 2127 | ret = clk_prepare_enable(host->ciu_clk); |
2123 | if (ret) { | 2128 | if (ret) { |
2124 | dev_err(host->dev, "failed to enable ciu clock\n"); | 2129 | dev_err(host->dev, "failed to enable ciu clock\n"); |
2125 | clk_put(host->ciu_clk); | ||
2126 | goto err_clk_biu; | 2130 | goto err_clk_biu; |
2127 | } | 2131 | } |
2128 | } | 2132 | } |
@@ -2224,7 +2228,8 @@ int dw_mci_probe(struct dw_mci *host) | |||
2224 | if (!host->card_workqueue) | 2228 | if (!host->card_workqueue) |
2225 | goto err_dmaunmap; | 2229 | goto err_dmaunmap; |
2226 | INIT_WORK(&host->card_work, dw_mci_work_routine_card); | 2230 | INIT_WORK(&host->card_work, dw_mci_work_routine_card); |
2227 | ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host); | 2231 | ret = devm_request_irq(host->dev, host->irq, dw_mci_interrupt, |
2232 | host->irq_flags, "dw-mci", host); | ||
2228 | if (ret) | 2233 | if (ret) |
2229 | goto err_workqueue; | 2234 | goto err_workqueue; |
2230 | 2235 | ||
@@ -2262,7 +2267,7 @@ int dw_mci_probe(struct dw_mci *host) | |||
2262 | } else { | 2267 | } else { |
2263 | dev_dbg(host->dev, "attempted to initialize %d slots, " | 2268 | dev_dbg(host->dev, "attempted to initialize %d slots, " |
2264 | "but failed on all\n", host->num_slots); | 2269 | "but failed on all\n", host->num_slots); |
2265 | goto err_init_slot; | 2270 | goto err_workqueue; |
2266 | } | 2271 | } |
2267 | 2272 | ||
2268 | /* | 2273 | /* |
@@ -2282,33 +2287,24 @@ int dw_mci_probe(struct dw_mci *host) | |||
2282 | 2287 | ||
2283 | return 0; | 2288 | return 0; |
2284 | 2289 | ||
2285 | err_init_slot: | ||
2286 | free_irq(host->irq, host); | ||
2287 | |||
2288 | err_workqueue: | 2290 | err_workqueue: |
2289 | destroy_workqueue(host->card_workqueue); | 2291 | destroy_workqueue(host->card_workqueue); |
2290 | 2292 | ||
2291 | err_dmaunmap: | 2293 | err_dmaunmap: |
2292 | if (host->use_dma && host->dma_ops->exit) | 2294 | if (host->use_dma && host->dma_ops->exit) |
2293 | host->dma_ops->exit(host); | 2295 | host->dma_ops->exit(host); |
2294 | dma_free_coherent(host->dev, PAGE_SIZE, | ||
2295 | host->sg_cpu, host->sg_dma); | ||
2296 | 2296 | ||
2297 | if (host->vmmc) { | 2297 | if (host->vmmc) |
2298 | regulator_disable(host->vmmc); | 2298 | regulator_disable(host->vmmc); |
2299 | regulator_put(host->vmmc); | ||
2300 | } | ||
2301 | 2299 | ||
2302 | err_clk_ciu: | 2300 | err_clk_ciu: |
2303 | if (!IS_ERR(host->ciu_clk)) { | 2301 | if (!IS_ERR(host->ciu_clk)) |
2304 | clk_disable_unprepare(host->ciu_clk); | 2302 | clk_disable_unprepare(host->ciu_clk); |
2305 | clk_put(host->ciu_clk); | 2303 | |
2306 | } | ||
2307 | err_clk_biu: | 2304 | err_clk_biu: |
2308 | if (!IS_ERR(host->biu_clk)) { | 2305 | if (!IS_ERR(host->biu_clk)) |
2309 | clk_disable_unprepare(host->biu_clk); | 2306 | clk_disable_unprepare(host->biu_clk); |
2310 | clk_put(host->biu_clk); | 2307 | |
2311 | } | ||
2312 | return ret; | 2308 | return ret; |
2313 | } | 2309 | } |
2314 | EXPORT_SYMBOL(dw_mci_probe); | 2310 | EXPORT_SYMBOL(dw_mci_probe); |
@@ -2330,24 +2326,19 @@ void dw_mci_remove(struct dw_mci *host) | |||
2330 | mci_writel(host, CLKENA, 0); | 2326 | mci_writel(host, CLKENA, 0); |
2331 | mci_writel(host, CLKSRC, 0); | 2327 | mci_writel(host, CLKSRC, 0); |
2332 | 2328 | ||
2333 | free_irq(host->irq, host); | ||
2334 | destroy_workqueue(host->card_workqueue); | 2329 | destroy_workqueue(host->card_workqueue); |
2335 | dma_free_coherent(host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); | ||
2336 | 2330 | ||
2337 | if (host->use_dma && host->dma_ops->exit) | 2331 | if (host->use_dma && host->dma_ops->exit) |
2338 | host->dma_ops->exit(host); | 2332 | host->dma_ops->exit(host); |
2339 | 2333 | ||
2340 | if (host->vmmc) { | 2334 | if (host->vmmc) |
2341 | regulator_disable(host->vmmc); | 2335 | regulator_disable(host->vmmc); |
2342 | regulator_put(host->vmmc); | ||
2343 | } | ||
2344 | 2336 | ||
2345 | if (!IS_ERR(host->ciu_clk)) | 2337 | if (!IS_ERR(host->ciu_clk)) |
2346 | clk_disable_unprepare(host->ciu_clk); | 2338 | clk_disable_unprepare(host->ciu_clk); |
2339 | |||
2347 | if (!IS_ERR(host->biu_clk)) | 2340 | if (!IS_ERR(host->biu_clk)) |
2348 | clk_disable_unprepare(host->biu_clk); | 2341 | clk_disable_unprepare(host->biu_clk); |
2349 | clk_put(host->ciu_clk); | ||
2350 | clk_put(host->biu_clk); | ||
2351 | } | 2342 | } |
2352 | EXPORT_SYMBOL(dw_mci_remove); | 2343 | EXPORT_SYMBOL(dw_mci_remove); |
2353 | 2344 | ||
@@ -2411,6 +2402,11 @@ int dw_mci_resume(struct dw_mci *host) | |||
2411 | struct dw_mci_slot *slot = host->slot[i]; | 2402 | struct dw_mci_slot *slot = host->slot[i]; |
2412 | if (!slot) | 2403 | if (!slot) |
2413 | continue; | 2404 | continue; |
2405 | if (slot->mmc->pm_flags & MMC_PM_KEEP_POWER) { | ||
2406 | dw_mci_set_ios(slot->mmc, &slot->mmc->ios); | ||
2407 | dw_mci_setup_bus(slot, true); | ||
2408 | } | ||
2409 | |||
2414 | ret = mmc_resume_host(host->slot[i]->mmc); | 2410 | ret = mmc_resume_host(host->slot[i]->mmc); |
2415 | if (ret < 0) | 2411 | if (ret < 0) |
2416 | return ret; | 2412 | return ret; |
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 6290b7f1ccfe..29e680f193a0 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c | |||
@@ -240,7 +240,7 @@ static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data) | |||
240 | return 0; | 240 | return 0; |
241 | 241 | ||
242 | for_each_sg(data->sg, sg, data->sg_len, i) { | 242 | for_each_sg(data->sg, sg, data->sg_len, i) { |
243 | if (sg->offset & 3 || sg->length & 3) { | 243 | if (sg->offset & 3 || sg->length & 3 || sg->length < 512) { |
244 | host->do_dma = 0; | 244 | host->do_dma = 0; |
245 | return 0; | 245 | return 0; |
246 | } | 246 | } |
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index 80d1e6d4b0ae..206fe499ded5 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include <linux/module.h> | 43 | #include <linux/module.h> |
44 | #include <linux/pinctrl/consumer.h> | 44 | #include <linux/pinctrl/consumer.h> |
45 | #include <linux/stmp_device.h> | 45 | #include <linux/stmp_device.h> |
46 | #include <linux/mmc/mxs-mmc.h> | ||
47 | #include <linux/spi/mxs-spi.h> | 46 | #include <linux/spi/mxs-spi.h> |
48 | 47 | ||
49 | #define DRIVER_NAME "mxs-mmc" | 48 | #define DRIVER_NAME "mxs-mmc" |
@@ -593,13 +592,13 @@ static int mxs_mmc_probe(struct platform_device *pdev) | |||
593 | struct mxs_mmc_host *host; | 592 | struct mxs_mmc_host *host; |
594 | struct mmc_host *mmc; | 593 | struct mmc_host *mmc; |
595 | struct resource *iores, *dmares; | 594 | struct resource *iores, *dmares; |
596 | struct mxs_mmc_platform_data *pdata; | ||
597 | struct pinctrl *pinctrl; | 595 | struct pinctrl *pinctrl; |
598 | int ret = 0, irq_err, irq_dma; | 596 | int ret = 0, irq_err, irq_dma; |
599 | dma_cap_mask_t mask; | 597 | dma_cap_mask_t mask; |
600 | struct regulator *reg_vmmc; | 598 | struct regulator *reg_vmmc; |
601 | enum of_gpio_flags flags; | 599 | enum of_gpio_flags flags; |
602 | struct mxs_ssp *ssp; | 600 | struct mxs_ssp *ssp; |
601 | u32 bus_width = 0; | ||
603 | 602 | ||
604 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 603 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
605 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 604 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
@@ -682,25 +681,15 @@ static int mxs_mmc_probe(struct platform_device *pdev) | |||
682 | mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | | 681 | mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | |
683 | MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL; | 682 | MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL; |
684 | 683 | ||
685 | pdata = mmc_dev(host->mmc)->platform_data; | 684 | of_property_read_u32(np, "bus-width", &bus_width); |
686 | if (!pdata) { | 685 | if (bus_width == 4) |
687 | u32 bus_width = 0; | 686 | mmc->caps |= MMC_CAP_4_BIT_DATA; |
688 | of_property_read_u32(np, "bus-width", &bus_width); | 687 | else if (bus_width == 8) |
689 | if (bus_width == 4) | 688 | mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; |
690 | mmc->caps |= MMC_CAP_4_BIT_DATA; | 689 | host->wp_gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags); |
691 | else if (bus_width == 8) | 690 | |
692 | mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; | 691 | if (flags & OF_GPIO_ACTIVE_LOW) |
693 | host->wp_gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, | 692 | host->wp_inverted = 1; |
694 | &flags); | ||
695 | if (flags & OF_GPIO_ACTIVE_LOW) | ||
696 | host->wp_inverted = 1; | ||
697 | } else { | ||
698 | if (pdata->flags & SLOTF_8_BIT_CAPABLE) | ||
699 | mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; | ||
700 | if (pdata->flags & SLOTF_4_BIT_CAPABLE) | ||
701 | mmc->caps |= MMC_CAP_4_BIT_DATA; | ||
702 | host->wp_gpio = pdata->wp_gpio; | ||
703 | } | ||
704 | 693 | ||
705 | mmc->f_min = 400000; | 694 | mmc->f_min = 400000; |
706 | mmc->f_max = 288000000; | 695 | mmc->f_max = 288000000; |
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index fedd258cc4ea..d0a912fbad3b 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/io.h> | 37 | #include <linux/io.h> |
38 | #include <linux/gpio.h> | 38 | #include <linux/gpio.h> |
39 | #include <linux/regulator/consumer.h> | 39 | #include <linux/regulator/consumer.h> |
40 | #include <linux/pinctrl/consumer.h> | ||
40 | #include <linux/pm_runtime.h> | 41 | #include <linux/pm_runtime.h> |
41 | #include <mach/hardware.h> | 42 | #include <mach/hardware.h> |
42 | #include <plat/mmc.h> | 43 | #include <plat/mmc.h> |
@@ -62,6 +63,7 @@ | |||
62 | 63 | ||
63 | #define VS18 (1 << 26) | 64 | #define VS18 (1 << 26) |
64 | #define VS30 (1 << 25) | 65 | #define VS30 (1 << 25) |
66 | #define HSS (1 << 21) | ||
65 | #define SDVS18 (0x5 << 9) | 67 | #define SDVS18 (0x5 << 9) |
66 | #define SDVS30 (0x6 << 9) | 68 | #define SDVS30 (0x6 << 9) |
67 | #define SDVS33 (0x7 << 9) | 69 | #define SDVS33 (0x7 << 9) |
@@ -78,28 +80,17 @@ | |||
78 | #define CLKD_SHIFT 6 | 80 | #define CLKD_SHIFT 6 |
79 | #define DTO_MASK 0x000F0000 | 81 | #define DTO_MASK 0x000F0000 |
80 | #define DTO_SHIFT 16 | 82 | #define DTO_SHIFT 16 |
81 | #define INT_EN_MASK 0x307F0033 | ||
82 | #define BWR_ENABLE (1 << 4) | ||
83 | #define BRR_ENABLE (1 << 5) | ||
84 | #define DTO_ENABLE (1 << 20) | ||
85 | #define INIT_STREAM (1 << 1) | 83 | #define INIT_STREAM (1 << 1) |
86 | #define DP_SELECT (1 << 21) | 84 | #define DP_SELECT (1 << 21) |
87 | #define DDIR (1 << 4) | 85 | #define DDIR (1 << 4) |
88 | #define DMA_EN 0x1 | 86 | #define DMAE 0x1 |
89 | #define MSBS (1 << 5) | 87 | #define MSBS (1 << 5) |
90 | #define BCE (1 << 1) | 88 | #define BCE (1 << 1) |
91 | #define FOUR_BIT (1 << 1) | 89 | #define FOUR_BIT (1 << 1) |
90 | #define HSPE (1 << 2) | ||
92 | #define DDR (1 << 19) | 91 | #define DDR (1 << 19) |
93 | #define DW8 (1 << 5) | 92 | #define DW8 (1 << 5) |
94 | #define CC 0x1 | ||
95 | #define TC 0x02 | ||
96 | #define OD 0x1 | 93 | #define OD 0x1 |
97 | #define ERR (1 << 15) | ||
98 | #define CMD_TIMEOUT (1 << 16) | ||
99 | #define DATA_TIMEOUT (1 << 20) | ||
100 | #define CMD_CRC (1 << 17) | ||
101 | #define DATA_CRC (1 << 21) | ||
102 | #define CARD_ERR (1 << 28) | ||
103 | #define STAT_CLEAR 0xFFFFFFFF | 94 | #define STAT_CLEAR 0xFFFFFFFF |
104 | #define INIT_STREAM_CMD 0x00000000 | 95 | #define INIT_STREAM_CMD 0x00000000 |
105 | #define DUAL_VOLT_OCR_BIT 7 | 96 | #define DUAL_VOLT_OCR_BIT 7 |
@@ -108,6 +99,26 @@ | |||
108 | #define SOFTRESET (1 << 1) | 99 | #define SOFTRESET (1 << 1) |
109 | #define RESETDONE (1 << 0) | 100 | #define RESETDONE (1 << 0) |
110 | 101 | ||
102 | /* Interrupt masks for IE and ISE register */ | ||
103 | #define CC_EN (1 << 0) | ||
104 | #define TC_EN (1 << 1) | ||
105 | #define BWR_EN (1 << 4) | ||
106 | #define BRR_EN (1 << 5) | ||
107 | #define ERR_EN (1 << 15) | ||
108 | #define CTO_EN (1 << 16) | ||
109 | #define CCRC_EN (1 << 17) | ||
110 | #define CEB_EN (1 << 18) | ||
111 | #define CIE_EN (1 << 19) | ||
112 | #define DTO_EN (1 << 20) | ||
113 | #define DCRC_EN (1 << 21) | ||
114 | #define DEB_EN (1 << 22) | ||
115 | #define CERR_EN (1 << 28) | ||
116 | #define BADA_EN (1 << 29) | ||
117 | |||
118 | #define INT_EN_MASK (BADA_EN | CERR_EN | DEB_EN | DCRC_EN |\ | ||
119 | DTO_EN | CIE_EN | CEB_EN | CCRC_EN | CTO_EN | \ | ||
120 | BRR_EN | BWR_EN | TC_EN | CC_EN) | ||
121 | |||
111 | #define MMC_AUTOSUSPEND_DELAY 100 | 122 | #define MMC_AUTOSUSPEND_DELAY 100 |
112 | #define MMC_TIMEOUT_MS 20 | 123 | #define MMC_TIMEOUT_MS 20 |
113 | #define OMAP_MMC_MIN_CLOCK 400000 | 124 | #define OMAP_MMC_MIN_CLOCK 400000 |
@@ -302,7 +313,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | |||
302 | 313 | ||
303 | reg = regulator_get(host->dev, "vmmc"); | 314 | reg = regulator_get(host->dev, "vmmc"); |
304 | if (IS_ERR(reg)) { | 315 | if (IS_ERR(reg)) { |
305 | dev_dbg(host->dev, "vmmc regulator missing\n"); | 316 | dev_err(host->dev, "vmmc regulator missing\n"); |
306 | return PTR_ERR(reg); | 317 | return PTR_ERR(reg); |
307 | } else { | 318 | } else { |
308 | mmc_slot(host).set_power = omap_hsmmc_set_power; | 319 | mmc_slot(host).set_power = omap_hsmmc_set_power; |
@@ -455,13 +466,13 @@ static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host, | |||
455 | unsigned int irq_mask; | 466 | unsigned int irq_mask; |
456 | 467 | ||
457 | if (host->use_dma) | 468 | if (host->use_dma) |
458 | irq_mask = INT_EN_MASK & ~(BRR_ENABLE | BWR_ENABLE); | 469 | irq_mask = INT_EN_MASK & ~(BRR_EN | BWR_EN); |
459 | else | 470 | else |
460 | irq_mask = INT_EN_MASK; | 471 | irq_mask = INT_EN_MASK; |
461 | 472 | ||
462 | /* Disable timeout for erases */ | 473 | /* Disable timeout for erases */ |
463 | if (cmd->opcode == MMC_ERASE) | 474 | if (cmd->opcode == MMC_ERASE) |
464 | irq_mask &= ~DTO_ENABLE; | 475 | irq_mask &= ~DTO_EN; |
465 | 476 | ||
466 | OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); | 477 | OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); |
467 | OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); | 478 | OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); |
@@ -494,6 +505,7 @@ static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host) | |||
494 | struct mmc_ios *ios = &host->mmc->ios; | 505 | struct mmc_ios *ios = &host->mmc->ios; |
495 | unsigned long regval; | 506 | unsigned long regval; |
496 | unsigned long timeout; | 507 | unsigned long timeout; |
508 | unsigned long clkdiv; | ||
497 | 509 | ||
498 | dev_vdbg(mmc_dev(host->mmc), "Set clock to %uHz\n", ios->clock); | 510 | dev_vdbg(mmc_dev(host->mmc), "Set clock to %uHz\n", ios->clock); |
499 | 511 | ||
@@ -501,7 +513,8 @@ static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host) | |||
501 | 513 | ||
502 | regval = OMAP_HSMMC_READ(host->base, SYSCTL); | 514 | regval = OMAP_HSMMC_READ(host->base, SYSCTL); |
503 | regval = regval & ~(CLKD_MASK | DTO_MASK); | 515 | regval = regval & ~(CLKD_MASK | DTO_MASK); |
504 | regval = regval | (calc_divisor(host, ios) << 6) | (DTO << 16); | 516 | clkdiv = calc_divisor(host, ios); |
517 | regval = regval | (clkdiv << 6) | (DTO << 16); | ||
505 | OMAP_HSMMC_WRITE(host->base, SYSCTL, regval); | 518 | OMAP_HSMMC_WRITE(host->base, SYSCTL, regval); |
506 | OMAP_HSMMC_WRITE(host->base, SYSCTL, | 519 | OMAP_HSMMC_WRITE(host->base, SYSCTL, |
507 | OMAP_HSMMC_READ(host->base, SYSCTL) | ICE); | 520 | OMAP_HSMMC_READ(host->base, SYSCTL) | ICE); |
@@ -512,6 +525,27 @@ static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host) | |||
512 | && time_before(jiffies, timeout)) | 525 | && time_before(jiffies, timeout)) |
513 | cpu_relax(); | 526 | cpu_relax(); |
514 | 527 | ||
528 | /* | ||
529 | * Enable High-Speed Support | ||
530 | * Pre-Requisites | ||
531 | * - Controller should support High-Speed-Enable Bit | ||
532 | * - Controller should not be using DDR Mode | ||
533 | * - Controller should advertise that it supports High Speed | ||
534 | * in capabilities register | ||
535 | * - MMC/SD clock coming out of controller > 25MHz | ||
536 | */ | ||
537 | if ((mmc_slot(host).features & HSMMC_HAS_HSPE_SUPPORT) && | ||
538 | (ios->timing != MMC_TIMING_UHS_DDR50) && | ||
539 | ((OMAP_HSMMC_READ(host->base, CAPA) & HSS) == HSS)) { | ||
540 | regval = OMAP_HSMMC_READ(host->base, HCTL); | ||
541 | if (clkdiv && (clk_get_rate(host->fclk)/clkdiv) > 25000000) | ||
542 | regval |= HSPE; | ||
543 | else | ||
544 | regval &= ~HSPE; | ||
545 | |||
546 | OMAP_HSMMC_WRITE(host->base, HCTL, regval); | ||
547 | } | ||
548 | |||
515 | omap_hsmmc_start_clock(host); | 549 | omap_hsmmc_start_clock(host); |
516 | } | 550 | } |
517 | 551 | ||
@@ -676,8 +710,8 @@ static void send_init_stream(struct omap_hsmmc_host *host) | |||
676 | OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD); | 710 | OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD); |
677 | 711 | ||
678 | timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS); | 712 | timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS); |
679 | while ((reg != CC) && time_before(jiffies, timeout)) | 713 | while ((reg != CC_EN) && time_before(jiffies, timeout)) |
680 | reg = OMAP_HSMMC_READ(host->base, STAT) & CC; | 714 | reg = OMAP_HSMMC_READ(host->base, STAT) & CC_EN; |
681 | 715 | ||
682 | OMAP_HSMMC_WRITE(host->base, CON, | 716 | OMAP_HSMMC_WRITE(host->base, CON, |
683 | OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM); | 717 | OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM); |
@@ -768,7 +802,7 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd, | |||
768 | } | 802 | } |
769 | 803 | ||
770 | if (host->use_dma) | 804 | if (host->use_dma) |
771 | cmdreg |= DMA_EN; | 805 | cmdreg |= DMAE; |
772 | 806 | ||
773 | host->req_in_progress = 1; | 807 | host->req_in_progress = 1; |
774 | 808 | ||
@@ -968,16 +1002,20 @@ static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host, | |||
968 | __func__); | 1002 | __func__); |
969 | } | 1003 | } |
970 | 1004 | ||
971 | static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, int err) | 1005 | static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, |
1006 | int err, int end_cmd) | ||
972 | { | 1007 | { |
973 | omap_hsmmc_reset_controller_fsm(host, SRC); | 1008 | if (end_cmd) { |
974 | host->cmd->error = err; | 1009 | omap_hsmmc_reset_controller_fsm(host, SRC); |
1010 | if (host->cmd) | ||
1011 | host->cmd->error = err; | ||
1012 | } | ||
975 | 1013 | ||
976 | if (host->data) { | 1014 | if (host->data) { |
977 | omap_hsmmc_reset_controller_fsm(host, SRD); | 1015 | omap_hsmmc_reset_controller_fsm(host, SRD); |
978 | omap_hsmmc_dma_cleanup(host, err); | 1016 | omap_hsmmc_dma_cleanup(host, err); |
979 | } | 1017 | } else if (host->mrq && host->mrq->cmd) |
980 | 1018 | host->mrq->cmd->error = err; | |
981 | } | 1019 | } |
982 | 1020 | ||
983 | static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) | 1021 | static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) |
@@ -988,23 +1026,25 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) | |||
988 | data = host->data; | 1026 | data = host->data; |
989 | dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status); | 1027 | dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status); |
990 | 1028 | ||
991 | if (status & ERR) { | 1029 | if (status & ERR_EN) { |
992 | omap_hsmmc_dbg_report_irq(host, status); | 1030 | omap_hsmmc_dbg_report_irq(host, status); |
993 | if (status & (CMD_TIMEOUT | DATA_TIMEOUT)) | ||
994 | hsmmc_command_incomplete(host, -ETIMEDOUT); | ||
995 | else if (status & (CMD_CRC | DATA_CRC)) | ||
996 | hsmmc_command_incomplete(host, -EILSEQ); | ||
997 | 1031 | ||
998 | end_cmd = 1; | 1032 | if (status & (CTO_EN | CCRC_EN)) |
1033 | end_cmd = 1; | ||
1034 | if (status & (CTO_EN | DTO_EN)) | ||
1035 | hsmmc_command_incomplete(host, -ETIMEDOUT, end_cmd); | ||
1036 | else if (status & (CCRC_EN | DCRC_EN)) | ||
1037 | hsmmc_command_incomplete(host, -EILSEQ, end_cmd); | ||
1038 | |||
999 | if (host->data || host->response_busy) { | 1039 | if (host->data || host->response_busy) { |
1000 | end_trans = 1; | 1040 | end_trans = !end_cmd; |
1001 | host->response_busy = 0; | 1041 | host->response_busy = 0; |
1002 | } | 1042 | } |
1003 | } | 1043 | } |
1004 | 1044 | ||
1005 | if (end_cmd || ((status & CC) && host->cmd)) | 1045 | if (end_cmd || ((status & CC_EN) && host->cmd)) |
1006 | omap_hsmmc_cmd_done(host, host->cmd); | 1046 | omap_hsmmc_cmd_done(host, host->cmd); |
1007 | if ((end_trans || (status & TC)) && host->mrq) | 1047 | if ((end_trans || (status & TC_EN)) && host->mrq) |
1008 | omap_hsmmc_xfer_done(host, data); | 1048 | omap_hsmmc_xfer_done(host, data); |
1009 | } | 1049 | } |
1010 | 1050 | ||
@@ -1101,7 +1141,7 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd) | |||
1101 | 1141 | ||
1102 | return 0; | 1142 | return 0; |
1103 | err: | 1143 | err: |
1104 | dev_dbg(mmc_dev(host->mmc), "Unable to switch operating voltage\n"); | 1144 | dev_err(mmc_dev(host->mmc), "Unable to switch operating voltage\n"); |
1105 | return ret; | 1145 | return ret; |
1106 | } | 1146 | } |
1107 | 1147 | ||
@@ -1360,7 +1400,7 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req) | |||
1360 | if (host->use_dma) { | 1400 | if (host->use_dma) { |
1361 | ret = omap_hsmmc_start_dma_transfer(host, req); | 1401 | ret = omap_hsmmc_start_dma_transfer(host, req); |
1362 | if (ret != 0) { | 1402 | if (ret != 0) { |
1363 | dev_dbg(mmc_dev(host->mmc), "MMC start dma failure\n"); | 1403 | dev_err(mmc_dev(host->mmc), "MMC start dma failure\n"); |
1364 | return ret; | 1404 | return ret; |
1365 | } | 1405 | } |
1366 | } | 1406 | } |
@@ -1678,7 +1718,7 @@ static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev) | |||
1678 | { | 1718 | { |
1679 | struct omap_mmc_platform_data *pdata; | 1719 | struct omap_mmc_platform_data *pdata; |
1680 | struct device_node *np = dev->of_node; | 1720 | struct device_node *np = dev->of_node; |
1681 | u32 bus_width; | 1721 | u32 bus_width, max_freq; |
1682 | 1722 | ||
1683 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | 1723 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); |
1684 | if (!pdata) | 1724 | if (!pdata) |
@@ -1705,6 +1745,12 @@ static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev) | |||
1705 | if (of_find_property(np, "ti,needs-special-reset", NULL)) | 1745 | if (of_find_property(np, "ti,needs-special-reset", NULL)) |
1706 | pdata->slots[0].features |= HSMMC_HAS_UPDATED_RESET; | 1746 | pdata->slots[0].features |= HSMMC_HAS_UPDATED_RESET; |
1707 | 1747 | ||
1748 | if (!of_property_read_u32(np, "max-frequency", &max_freq)) | ||
1749 | pdata->max_freq = max_freq; | ||
1750 | |||
1751 | if (of_find_property(np, "ti,needs-special-hs-handling", NULL)) | ||
1752 | pdata->slots[0].features |= HSMMC_HAS_HSPE_SUPPORT; | ||
1753 | |||
1708 | return pdata; | 1754 | return pdata; |
1709 | } | 1755 | } |
1710 | #else | 1756 | #else |
@@ -1725,6 +1771,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) | |||
1725 | const struct of_device_id *match; | 1771 | const struct of_device_id *match; |
1726 | dma_cap_mask_t mask; | 1772 | dma_cap_mask_t mask; |
1727 | unsigned tx_req, rx_req; | 1773 | unsigned tx_req, rx_req; |
1774 | struct pinctrl *pinctrl; | ||
1728 | 1775 | ||
1729 | match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev); | 1776 | match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev); |
1730 | if (match) { | 1777 | if (match) { |
@@ -1821,7 +1868,6 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) | |||
1821 | * MMC can still work without debounce clock. | 1868 | * MMC can still work without debounce clock. |
1822 | */ | 1869 | */ |
1823 | if (IS_ERR(host->dbclk)) { | 1870 | if (IS_ERR(host->dbclk)) { |
1824 | dev_warn(mmc_dev(host->mmc), "Failed to get debounce clk\n"); | ||
1825 | host->dbclk = NULL; | 1871 | host->dbclk = NULL; |
1826 | } else if (clk_prepare_enable(host->dbclk) != 0) { | 1872 | } else if (clk_prepare_enable(host->dbclk) != 0) { |
1827 | dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n"); | 1873 | dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n"); |
@@ -1889,13 +1935,13 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) | |||
1889 | ret = request_irq(host->irq, omap_hsmmc_irq, 0, | 1935 | ret = request_irq(host->irq, omap_hsmmc_irq, 0, |
1890 | mmc_hostname(mmc), host); | 1936 | mmc_hostname(mmc), host); |
1891 | if (ret) { | 1937 | if (ret) { |
1892 | dev_dbg(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n"); | 1938 | dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n"); |
1893 | goto err_irq; | 1939 | goto err_irq; |
1894 | } | 1940 | } |
1895 | 1941 | ||
1896 | if (pdata->init != NULL) { | 1942 | if (pdata->init != NULL) { |
1897 | if (pdata->init(&pdev->dev) != 0) { | 1943 | if (pdata->init(&pdev->dev) != 0) { |
1898 | dev_dbg(mmc_dev(host->mmc), | 1944 | dev_err(mmc_dev(host->mmc), |
1899 | "Unable to configure MMC IRQs\n"); | 1945 | "Unable to configure MMC IRQs\n"); |
1900 | goto err_irq_cd_init; | 1946 | goto err_irq_cd_init; |
1901 | } | 1947 | } |
@@ -1918,7 +1964,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) | |||
1918 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | 1964 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
1919 | mmc_hostname(mmc), host); | 1965 | mmc_hostname(mmc), host); |
1920 | if (ret) { | 1966 | if (ret) { |
1921 | dev_dbg(mmc_dev(host->mmc), | 1967 | dev_err(mmc_dev(host->mmc), |
1922 | "Unable to grab MMC CD IRQ\n"); | 1968 | "Unable to grab MMC CD IRQ\n"); |
1923 | goto err_irq_cd; | 1969 | goto err_irq_cd; |
1924 | } | 1970 | } |
@@ -1928,6 +1974,11 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) | |||
1928 | 1974 | ||
1929 | omap_hsmmc_disable_irq(host); | 1975 | omap_hsmmc_disable_irq(host); |
1930 | 1976 | ||
1977 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); | ||
1978 | if (IS_ERR(pinctrl)) | ||
1979 | dev_warn(&pdev->dev, | ||
1980 | "pins are not configured from the driver\n"); | ||
1981 | |||
1931 | omap_hsmmc_protect_card(host); | 1982 | omap_hsmmc_protect_card(host); |
1932 | 1983 | ||
1933 | mmc_add_host(mmc); | 1984 | mmc_add_host(mmc); |
@@ -2027,6 +2078,25 @@ static int __devexit omap_hsmmc_remove(struct platform_device *pdev) | |||
2027 | } | 2078 | } |
2028 | 2079 | ||
2029 | #ifdef CONFIG_PM | 2080 | #ifdef CONFIG_PM |
2081 | static int omap_hsmmc_prepare(struct device *dev) | ||
2082 | { | ||
2083 | struct omap_hsmmc_host *host = dev_get_drvdata(dev); | ||
2084 | |||
2085 | if (host->pdata->suspend) | ||
2086 | return host->pdata->suspend(dev, host->slot_id); | ||
2087 | |||
2088 | return 0; | ||
2089 | } | ||
2090 | |||
2091 | static void omap_hsmmc_complete(struct device *dev) | ||
2092 | { | ||
2093 | struct omap_hsmmc_host *host = dev_get_drvdata(dev); | ||
2094 | |||
2095 | if (host->pdata->resume) | ||
2096 | host->pdata->resume(dev, host->slot_id); | ||
2097 | |||
2098 | } | ||
2099 | |||
2030 | static int omap_hsmmc_suspend(struct device *dev) | 2100 | static int omap_hsmmc_suspend(struct device *dev) |
2031 | { | 2101 | { |
2032 | int ret = 0; | 2102 | int ret = 0; |
@@ -2040,23 +2110,10 @@ static int omap_hsmmc_suspend(struct device *dev) | |||
2040 | 2110 | ||
2041 | pm_runtime_get_sync(host->dev); | 2111 | pm_runtime_get_sync(host->dev); |
2042 | host->suspended = 1; | 2112 | host->suspended = 1; |
2043 | if (host->pdata->suspend) { | ||
2044 | ret = host->pdata->suspend(dev, host->slot_id); | ||
2045 | if (ret) { | ||
2046 | dev_dbg(dev, "Unable to handle MMC board" | ||
2047 | " level suspend\n"); | ||
2048 | host->suspended = 0; | ||
2049 | return ret; | ||
2050 | } | ||
2051 | } | ||
2052 | ret = mmc_suspend_host(host->mmc); | 2113 | ret = mmc_suspend_host(host->mmc); |
2053 | 2114 | ||
2054 | if (ret) { | 2115 | if (ret) { |
2055 | host->suspended = 0; | 2116 | host->suspended = 0; |
2056 | if (host->pdata->resume) { | ||
2057 | if (host->pdata->resume(dev, host->slot_id)) | ||
2058 | dev_dbg(dev, "Unmask interrupt failed\n"); | ||
2059 | } | ||
2060 | goto err; | 2117 | goto err; |
2061 | } | 2118 | } |
2062 | 2119 | ||
@@ -2093,12 +2150,6 @@ static int omap_hsmmc_resume(struct device *dev) | |||
2093 | if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) | 2150 | if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) |
2094 | omap_hsmmc_conf_bus_power(host); | 2151 | omap_hsmmc_conf_bus_power(host); |
2095 | 2152 | ||
2096 | if (host->pdata->resume) { | ||
2097 | ret = host->pdata->resume(dev, host->slot_id); | ||
2098 | if (ret) | ||
2099 | dev_dbg(dev, "Unmask interrupt failed\n"); | ||
2100 | } | ||
2101 | |||
2102 | omap_hsmmc_protect_card(host); | 2153 | omap_hsmmc_protect_card(host); |
2103 | 2154 | ||
2104 | /* Notify the core to resume the host */ | 2155 | /* Notify the core to resume the host */ |
@@ -2114,8 +2165,10 @@ static int omap_hsmmc_resume(struct device *dev) | |||
2114 | } | 2165 | } |
2115 | 2166 | ||
2116 | #else | 2167 | #else |
2168 | #define omap_hsmmc_prepare NULL | ||
2169 | #define omap_hsmmc_complete NULL | ||
2117 | #define omap_hsmmc_suspend NULL | 2170 | #define omap_hsmmc_suspend NULL |
2118 | #define omap_hsmmc_resume NULL | 2171 | #define omap_hsmmc_resume NULL |
2119 | #endif | 2172 | #endif |
2120 | 2173 | ||
2121 | static int omap_hsmmc_runtime_suspend(struct device *dev) | 2174 | static int omap_hsmmc_runtime_suspend(struct device *dev) |
@@ -2143,6 +2196,8 @@ static int omap_hsmmc_runtime_resume(struct device *dev) | |||
2143 | static struct dev_pm_ops omap_hsmmc_dev_pm_ops = { | 2196 | static struct dev_pm_ops omap_hsmmc_dev_pm_ops = { |
2144 | .suspend = omap_hsmmc_suspend, | 2197 | .suspend = omap_hsmmc_suspend, |
2145 | .resume = omap_hsmmc_resume, | 2198 | .resume = omap_hsmmc_resume, |
2199 | .prepare = omap_hsmmc_prepare, | ||
2200 | .complete = omap_hsmmc_complete, | ||
2146 | .runtime_suspend = omap_hsmmc_runtime_suspend, | 2201 | .runtime_suspend = omap_hsmmc_runtime_suspend, |
2147 | .runtime_resume = omap_hsmmc_runtime_resume, | 2202 | .runtime_resume = omap_hsmmc_runtime_resume, |
2148 | }; | 2203 | }; |
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c index 8fd50a211037..e6214480bc98 100644 --- a/drivers/mmc/host/sdhci-dove.c +++ b/drivers/mmc/host/sdhci-dove.c | |||
@@ -19,20 +19,30 @@ | |||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/err.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
25 | #include <linux/err.h> | 23 | #include <linux/err.h> |
26 | #include <linux/module.h> | 24 | #include <linux/gpio.h> |
25 | #include <linux/io.h> | ||
27 | #include <linux/mmc/host.h> | 26 | #include <linux/mmc/host.h> |
27 | #include <linux/module.h> | ||
28 | #include <linux/of.h> | 28 | #include <linux/of.h> |
29 | #include <linux/of_gpio.h> | ||
29 | 30 | ||
30 | #include "sdhci-pltfm.h" | 31 | #include "sdhci-pltfm.h" |
31 | 32 | ||
32 | struct sdhci_dove_priv { | 33 | struct sdhci_dove_priv { |
33 | struct clk *clk; | 34 | struct clk *clk; |
35 | int gpio_cd; | ||
34 | }; | 36 | }; |
35 | 37 | ||
38 | static irqreturn_t sdhci_dove_carddetect_irq(int irq, void *data) | ||
39 | { | ||
40 | struct sdhci_host *host = data; | ||
41 | |||
42 | tasklet_schedule(&host->card_tasklet); | ||
43 | return IRQ_HANDLED; | ||
44 | } | ||
45 | |||
36 | static u16 sdhci_dove_readw(struct sdhci_host *host, int reg) | 46 | static u16 sdhci_dove_readw(struct sdhci_host *host, int reg) |
37 | { | 47 | { |
38 | u16 ret; | 48 | u16 ret; |
@@ -50,16 +60,25 @@ static u16 sdhci_dove_readw(struct sdhci_host *host, int reg) | |||
50 | 60 | ||
51 | static u32 sdhci_dove_readl(struct sdhci_host *host, int reg) | 61 | static u32 sdhci_dove_readl(struct sdhci_host *host, int reg) |
52 | { | 62 | { |
63 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | ||
64 | struct sdhci_dove_priv *priv = pltfm_host->priv; | ||
53 | u32 ret; | 65 | u32 ret; |
54 | 66 | ||
67 | ret = readl(host->ioaddr + reg); | ||
68 | |||
55 | switch (reg) { | 69 | switch (reg) { |
56 | case SDHCI_CAPABILITIES: | 70 | case SDHCI_CAPABILITIES: |
57 | ret = readl(host->ioaddr + reg); | ||
58 | /* Mask the support for 3.0V */ | 71 | /* Mask the support for 3.0V */ |
59 | ret &= ~SDHCI_CAN_VDD_300; | 72 | ret &= ~SDHCI_CAN_VDD_300; |
60 | break; | 73 | break; |
61 | default: | 74 | case SDHCI_PRESENT_STATE: |
62 | ret = readl(host->ioaddr + reg); | 75 | if (gpio_is_valid(priv->gpio_cd)) { |
76 | if (gpio_get_value(priv->gpio_cd) == 0) | ||
77 | ret |= SDHCI_CARD_PRESENT; | ||
78 | else | ||
79 | ret &= ~SDHCI_CARD_PRESENT; | ||
80 | } | ||
81 | break; | ||
63 | } | 82 | } |
64 | return ret; | 83 | return ret; |
65 | } | 84 | } |
@@ -92,25 +111,70 @@ static int __devinit sdhci_dove_probe(struct platform_device *pdev) | |||
92 | return -ENOMEM; | 111 | return -ENOMEM; |
93 | } | 112 | } |
94 | 113 | ||
95 | priv->clk = clk_get(&pdev->dev, NULL); | 114 | priv->clk = devm_clk_get(&pdev->dev, NULL); |
96 | if (!IS_ERR(priv->clk)) | ||
97 | clk_prepare_enable(priv->clk); | ||
98 | 115 | ||
99 | ret = sdhci_pltfm_register(pdev, &sdhci_dove_pdata); | 116 | if (pdev->dev.of_node) { |
100 | if (ret) | 117 | priv->gpio_cd = of_get_named_gpio(pdev->dev.of_node, |
101 | goto sdhci_dove_register_fail; | 118 | "cd-gpios", 0); |
119 | } else { | ||
120 | priv->gpio_cd = -EINVAL; | ||
121 | } | ||
122 | |||
123 | if (gpio_is_valid(priv->gpio_cd)) { | ||
124 | ret = gpio_request(priv->gpio_cd, "sdhci-cd"); | ||
125 | if (ret) { | ||
126 | dev_err(&pdev->dev, "card detect gpio request failed: %d\n", | ||
127 | ret); | ||
128 | return ret; | ||
129 | } | ||
130 | gpio_direction_input(priv->gpio_cd); | ||
131 | } | ||
132 | |||
133 | host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata); | ||
134 | if (IS_ERR(host)) { | ||
135 | ret = PTR_ERR(host); | ||
136 | goto err_sdhci_pltfm_init; | ||
137 | } | ||
102 | 138 | ||
103 | host = platform_get_drvdata(pdev); | ||
104 | pltfm_host = sdhci_priv(host); | 139 | pltfm_host = sdhci_priv(host); |
105 | pltfm_host->priv = priv; | 140 | pltfm_host->priv = priv; |
106 | 141 | ||
142 | if (!IS_ERR(priv->clk)) | ||
143 | clk_prepare_enable(priv->clk); | ||
144 | |||
145 | sdhci_get_of_property(pdev); | ||
146 | |||
147 | ret = sdhci_add_host(host); | ||
148 | if (ret) | ||
149 | goto err_sdhci_add; | ||
150 | |||
151 | /* | ||
152 | * We must request the IRQ after sdhci_add_host(), as the tasklet only | ||
153 | * gets setup in sdhci_add_host() and we oops. | ||
154 | */ | ||
155 | if (gpio_is_valid(priv->gpio_cd)) { | ||
156 | ret = request_irq(gpio_to_irq(priv->gpio_cd), | ||
157 | sdhci_dove_carddetect_irq, | ||
158 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | ||
159 | mmc_hostname(host->mmc), host); | ||
160 | if (ret) { | ||
161 | dev_err(&pdev->dev, "card detect irq request failed: %d\n", | ||
162 | ret); | ||
163 | goto err_request_irq; | ||
164 | } | ||
165 | } | ||
166 | |||
107 | return 0; | 167 | return 0; |
108 | 168 | ||
109 | sdhci_dove_register_fail: | 169 | err_request_irq: |
110 | if (!IS_ERR(priv->clk)) { | 170 | sdhci_remove_host(host, 0); |
171 | err_sdhci_add: | ||
172 | if (!IS_ERR(priv->clk)) | ||
111 | clk_disable_unprepare(priv->clk); | 173 | clk_disable_unprepare(priv->clk); |
112 | clk_put(priv->clk); | 174 | sdhci_pltfm_free(pdev); |
113 | } | 175 | err_sdhci_pltfm_init: |
176 | if (gpio_is_valid(priv->gpio_cd)) | ||
177 | gpio_free(priv->gpio_cd); | ||
114 | return ret; | 178 | return ret; |
115 | } | 179 | } |
116 | 180 | ||
@@ -122,10 +186,14 @@ static int __devexit sdhci_dove_remove(struct platform_device *pdev) | |||
122 | 186 | ||
123 | sdhci_pltfm_unregister(pdev); | 187 | sdhci_pltfm_unregister(pdev); |
124 | 188 | ||
125 | if (!IS_ERR(priv->clk)) { | 189 | if (gpio_is_valid(priv->gpio_cd)) { |
126 | clk_disable_unprepare(priv->clk); | 190 | free_irq(gpio_to_irq(priv->gpio_cd), host); |
127 | clk_put(priv->clk); | 191 | gpio_free(priv->gpio_cd); |
128 | } | 192 | } |
193 | |||
194 | if (!IS_ERR(priv->clk)) | ||
195 | clk_disable_unprepare(priv->clk); | ||
196 | |||
129 | return 0; | 197 | return 0; |
130 | } | 198 | } |
131 | 199 | ||
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index effc2acfe778..1849461c39ee 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c | |||
@@ -456,10 +456,10 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
456 | 456 | ||
457 | pltfm_host = sdhci_priv(host); | 457 | pltfm_host = sdhci_priv(host); |
458 | 458 | ||
459 | imx_data = kzalloc(sizeof(struct pltfm_imx_data), GFP_KERNEL); | 459 | imx_data = devm_kzalloc(&pdev->dev, sizeof(*imx_data), GFP_KERNEL); |
460 | if (!imx_data) { | 460 | if (!imx_data) { |
461 | err = -ENOMEM; | 461 | err = -ENOMEM; |
462 | goto err_imx_data; | 462 | goto free_sdhci; |
463 | } | 463 | } |
464 | 464 | ||
465 | if (of_id) | 465 | if (of_id) |
@@ -470,19 +470,19 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
470 | imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); | 470 | imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); |
471 | if (IS_ERR(imx_data->clk_ipg)) { | 471 | if (IS_ERR(imx_data->clk_ipg)) { |
472 | err = PTR_ERR(imx_data->clk_ipg); | 472 | err = PTR_ERR(imx_data->clk_ipg); |
473 | goto err_clk_get; | 473 | goto free_sdhci; |
474 | } | 474 | } |
475 | 475 | ||
476 | imx_data->clk_ahb = devm_clk_get(&pdev->dev, "ahb"); | 476 | imx_data->clk_ahb = devm_clk_get(&pdev->dev, "ahb"); |
477 | if (IS_ERR(imx_data->clk_ahb)) { | 477 | if (IS_ERR(imx_data->clk_ahb)) { |
478 | err = PTR_ERR(imx_data->clk_ahb); | 478 | err = PTR_ERR(imx_data->clk_ahb); |
479 | goto err_clk_get; | 479 | goto free_sdhci; |
480 | } | 480 | } |
481 | 481 | ||
482 | imx_data->clk_per = devm_clk_get(&pdev->dev, "per"); | 482 | imx_data->clk_per = devm_clk_get(&pdev->dev, "per"); |
483 | if (IS_ERR(imx_data->clk_per)) { | 483 | if (IS_ERR(imx_data->clk_per)) { |
484 | err = PTR_ERR(imx_data->clk_per); | 484 | err = PTR_ERR(imx_data->clk_per); |
485 | goto err_clk_get; | 485 | goto free_sdhci; |
486 | } | 486 | } |
487 | 487 | ||
488 | pltfm_host->clk = imx_data->clk_per; | 488 | pltfm_host->clk = imx_data->clk_per; |
@@ -494,7 +494,7 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
494 | imx_data->pinctrl = devm_pinctrl_get_select_default(&pdev->dev); | 494 | imx_data->pinctrl = devm_pinctrl_get_select_default(&pdev->dev); |
495 | if (IS_ERR(imx_data->pinctrl)) { | 495 | if (IS_ERR(imx_data->pinctrl)) { |
496 | err = PTR_ERR(imx_data->pinctrl); | 496 | err = PTR_ERR(imx_data->pinctrl); |
497 | goto pin_err; | 497 | goto disable_clk; |
498 | } | 498 | } |
499 | 499 | ||
500 | host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; | 500 | host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; |
@@ -519,7 +519,7 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
519 | if (!host->mmc->parent->platform_data) { | 519 | if (!host->mmc->parent->platform_data) { |
520 | dev_err(mmc_dev(host->mmc), "no board data!\n"); | 520 | dev_err(mmc_dev(host->mmc), "no board data!\n"); |
521 | err = -EINVAL; | 521 | err = -EINVAL; |
522 | goto no_board_data; | 522 | goto disable_clk; |
523 | } | 523 | } |
524 | imx_data->boarddata = *((struct esdhc_platform_data *) | 524 | imx_data->boarddata = *((struct esdhc_platform_data *) |
525 | host->mmc->parent->platform_data); | 525 | host->mmc->parent->platform_data); |
@@ -527,7 +527,8 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
527 | 527 | ||
528 | /* write_protect */ | 528 | /* write_protect */ |
529 | if (boarddata->wp_type == ESDHC_WP_GPIO) { | 529 | if (boarddata->wp_type == ESDHC_WP_GPIO) { |
530 | err = gpio_request_one(boarddata->wp_gpio, GPIOF_IN, "ESDHC_WP"); | 530 | err = devm_gpio_request_one(&pdev->dev, boarddata->wp_gpio, |
531 | GPIOF_IN, "ESDHC_WP"); | ||
531 | if (err) { | 532 | if (err) { |
532 | dev_warn(mmc_dev(host->mmc), | 533 | dev_warn(mmc_dev(host->mmc), |
533 | "no write-protect pin available!\n"); | 534 | "no write-protect pin available!\n"); |
@@ -543,19 +544,21 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
543 | 544 | ||
544 | switch (boarddata->cd_type) { | 545 | switch (boarddata->cd_type) { |
545 | case ESDHC_CD_GPIO: | 546 | case ESDHC_CD_GPIO: |
546 | err = gpio_request_one(boarddata->cd_gpio, GPIOF_IN, "ESDHC_CD"); | 547 | err = devm_gpio_request_one(&pdev->dev, boarddata->cd_gpio, |
548 | GPIOF_IN, "ESDHC_CD"); | ||
547 | if (err) { | 549 | if (err) { |
548 | dev_err(mmc_dev(host->mmc), | 550 | dev_err(mmc_dev(host->mmc), |
549 | "no card-detect pin available!\n"); | 551 | "no card-detect pin available!\n"); |
550 | goto no_card_detect_pin; | 552 | goto disable_clk; |
551 | } | 553 | } |
552 | 554 | ||
553 | err = request_irq(gpio_to_irq(boarddata->cd_gpio), cd_irq, | 555 | err = devm_request_irq(&pdev->dev, |
556 | gpio_to_irq(boarddata->cd_gpio), cd_irq, | ||
554 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | 557 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, |
555 | mmc_hostname(host->mmc), host); | 558 | mmc_hostname(host->mmc), host); |
556 | if (err) { | 559 | if (err) { |
557 | dev_err(mmc_dev(host->mmc), "request irq error\n"); | 560 | dev_err(mmc_dev(host->mmc), "request irq error\n"); |
558 | goto no_card_detect_irq; | 561 | goto disable_clk; |
559 | } | 562 | } |
560 | /* fall through */ | 563 | /* fall through */ |
561 | 564 | ||
@@ -574,27 +577,15 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) | |||
574 | 577 | ||
575 | err = sdhci_add_host(host); | 578 | err = sdhci_add_host(host); |
576 | if (err) | 579 | if (err) |
577 | goto err_add_host; | 580 | goto disable_clk; |
578 | 581 | ||
579 | return 0; | 582 | return 0; |
580 | 583 | ||
581 | err_add_host: | 584 | disable_clk: |
582 | if (gpio_is_valid(boarddata->cd_gpio)) | ||
583 | free_irq(gpio_to_irq(boarddata->cd_gpio), host); | ||
584 | no_card_detect_irq: | ||
585 | if (gpio_is_valid(boarddata->cd_gpio)) | ||
586 | gpio_free(boarddata->cd_gpio); | ||
587 | if (gpio_is_valid(boarddata->wp_gpio)) | ||
588 | gpio_free(boarddata->wp_gpio); | ||
589 | no_card_detect_pin: | ||
590 | no_board_data: | ||
591 | pin_err: | ||
592 | clk_disable_unprepare(imx_data->clk_per); | 585 | clk_disable_unprepare(imx_data->clk_per); |
593 | clk_disable_unprepare(imx_data->clk_ipg); | 586 | clk_disable_unprepare(imx_data->clk_ipg); |
594 | clk_disable_unprepare(imx_data->clk_ahb); | 587 | clk_disable_unprepare(imx_data->clk_ahb); |
595 | err_clk_get: | 588 | free_sdhci: |
596 | kfree(imx_data); | ||
597 | err_imx_data: | ||
598 | sdhci_pltfm_free(pdev); | 589 | sdhci_pltfm_free(pdev); |
599 | return err; | 590 | return err; |
600 | } | 591 | } |
@@ -604,25 +595,14 @@ static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev) | |||
604 | struct sdhci_host *host = platform_get_drvdata(pdev); | 595 | struct sdhci_host *host = platform_get_drvdata(pdev); |
605 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 596 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
606 | struct pltfm_imx_data *imx_data = pltfm_host->priv; | 597 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
607 | struct esdhc_platform_data *boarddata = &imx_data->boarddata; | ||
608 | int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); | 598 | int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); |
609 | 599 | ||
610 | sdhci_remove_host(host, dead); | 600 | sdhci_remove_host(host, dead); |
611 | 601 | ||
612 | if (gpio_is_valid(boarddata->wp_gpio)) | ||
613 | gpio_free(boarddata->wp_gpio); | ||
614 | |||
615 | if (gpio_is_valid(boarddata->cd_gpio)) { | ||
616 | free_irq(gpio_to_irq(boarddata->cd_gpio), host); | ||
617 | gpio_free(boarddata->cd_gpio); | ||
618 | } | ||
619 | |||
620 | clk_disable_unprepare(imx_data->clk_per); | 602 | clk_disable_unprepare(imx_data->clk_per); |
621 | clk_disable_unprepare(imx_data->clk_ipg); | 603 | clk_disable_unprepare(imx_data->clk_ipg); |
622 | clk_disable_unprepare(imx_data->clk_ahb); | 604 | clk_disable_unprepare(imx_data->clk_ahb); |
623 | 605 | ||
624 | kfree(imx_data); | ||
625 | |||
626 | sdhci_pltfm_free(pdev); | 606 | sdhci_pltfm_free(pdev); |
627 | 607 | ||
628 | return 0; | 608 | return 0; |
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index 63d219f57cae..60de2eeb39b1 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "sdhci-esdhc.h" | 22 | #include "sdhci-esdhc.h" |
23 | 23 | ||
24 | #define VENDOR_V_22 0x12 | 24 | #define VENDOR_V_22 0x12 |
25 | #define VENDOR_V_23 0x13 | ||
25 | static u32 esdhc_readl(struct sdhci_host *host, int reg) | 26 | static u32 esdhc_readl(struct sdhci_host *host, int reg) |
26 | { | 27 | { |
27 | u32 ret; | 28 | u32 ret; |
@@ -85,6 +86,18 @@ static u8 esdhc_readb(struct sdhci_host *host, int reg) | |||
85 | return ret; | 86 | return ret; |
86 | } | 87 | } |
87 | 88 | ||
89 | static void esdhc_writel(struct sdhci_host *host, u32 val, int reg) | ||
90 | { | ||
91 | /* | ||
92 | * Enable IRQSTATEN[BGESEN] is just to set IRQSTAT[BGE] | ||
93 | * when SYSCTL[RSTD]) is set for some special operations. | ||
94 | * No any impact other operation. | ||
95 | */ | ||
96 | if (reg == SDHCI_INT_ENABLE) | ||
97 | val |= SDHCI_INT_BLK_GAP; | ||
98 | sdhci_be32bs_writel(host, val, reg); | ||
99 | } | ||
100 | |||
88 | static void esdhc_writew(struct sdhci_host *host, u16 val, int reg) | 101 | static void esdhc_writew(struct sdhci_host *host, u16 val, int reg) |
89 | { | 102 | { |
90 | if (reg == SDHCI_BLOCK_SIZE) { | 103 | if (reg == SDHCI_BLOCK_SIZE) { |
@@ -121,6 +134,41 @@ static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg) | |||
121 | sdhci_be32bs_writeb(host, val, reg); | 134 | sdhci_be32bs_writeb(host, val, reg); |
122 | } | 135 | } |
123 | 136 | ||
137 | /* | ||
138 | * For Abort or Suspend after Stop at Block Gap, ignore the ADMA | ||
139 | * error(IRQSTAT[ADMAE]) if both Transfer Complete(IRQSTAT[TC]) | ||
140 | * and Block Gap Event(IRQSTAT[BGE]) are also set. | ||
141 | * For Continue, apply soft reset for data(SYSCTL[RSTD]); | ||
142 | * and re-issue the entire read transaction from beginning. | ||
143 | */ | ||
144 | static void esdhci_of_adma_workaround(struct sdhci_host *host, u32 intmask) | ||
145 | { | ||
146 | u32 tmp; | ||
147 | bool applicable; | ||
148 | dma_addr_t dmastart; | ||
149 | dma_addr_t dmanow; | ||
150 | |||
151 | tmp = in_be32(host->ioaddr + SDHCI_SLOT_INT_STATUS); | ||
152 | tmp = (tmp & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT; | ||
153 | |||
154 | applicable = (intmask & SDHCI_INT_DATA_END) && | ||
155 | (intmask & SDHCI_INT_BLK_GAP) && | ||
156 | (tmp == VENDOR_V_23); | ||
157 | if (!applicable) | ||
158 | return; | ||
159 | |||
160 | host->data->error = 0; | ||
161 | dmastart = sg_dma_address(host->data->sg); | ||
162 | dmanow = dmastart + host->data->bytes_xfered; | ||
163 | /* | ||
164 | * Force update to the next DMA block boundary. | ||
165 | */ | ||
166 | dmanow = (dmanow & ~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1)) + | ||
167 | SDHCI_DEFAULT_BOUNDARY_SIZE; | ||
168 | host->data->bytes_xfered = dmanow - dmastart; | ||
169 | sdhci_writel(host, dmanow, SDHCI_DMA_ADDRESS); | ||
170 | } | ||
171 | |||
124 | static int esdhc_of_enable_dma(struct sdhci_host *host) | 172 | static int esdhc_of_enable_dma(struct sdhci_host *host) |
125 | { | 173 | { |
126 | setbits32(host->ioaddr + ESDHC_DMA_SYSCTL, ESDHC_DMA_SNOOP); | 174 | setbits32(host->ioaddr + ESDHC_DMA_SYSCTL, ESDHC_DMA_SNOOP); |
@@ -177,13 +225,16 @@ static void esdhc_of_platform_init(struct sdhci_host *host) | |||
177 | vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT; | 225 | vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT; |
178 | if (vvn == VENDOR_V_22) | 226 | if (vvn == VENDOR_V_22) |
179 | host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23; | 227 | host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23; |
228 | |||
229 | if (vvn > VENDOR_V_22) | ||
230 | host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ; | ||
180 | } | 231 | } |
181 | 232 | ||
182 | static struct sdhci_ops sdhci_esdhc_ops = { | 233 | static struct sdhci_ops sdhci_esdhc_ops = { |
183 | .read_l = esdhc_readl, | 234 | .read_l = esdhc_readl, |
184 | .read_w = esdhc_readw, | 235 | .read_w = esdhc_readw, |
185 | .read_b = esdhc_readb, | 236 | .read_b = esdhc_readb, |
186 | .write_l = sdhci_be32bs_writel, | 237 | .write_l = esdhc_writel, |
187 | .write_w = esdhc_writew, | 238 | .write_w = esdhc_writew, |
188 | .write_b = esdhc_writeb, | 239 | .write_b = esdhc_writeb, |
189 | .set_clock = esdhc_of_set_clock, | 240 | .set_clock = esdhc_of_set_clock, |
@@ -195,6 +246,7 @@ static struct sdhci_ops sdhci_esdhc_ops = { | |||
195 | .platform_suspend = esdhc_of_suspend, | 246 | .platform_suspend = esdhc_of_suspend, |
196 | .platform_resume = esdhc_of_resume, | 247 | .platform_resume = esdhc_of_resume, |
197 | #endif | 248 | #endif |
249 | .adma_workaround = esdhci_of_adma_workaround, | ||
198 | }; | 250 | }; |
199 | 251 | ||
200 | static struct sdhci_pltfm_data sdhci_esdhc_pdata = { | 252 | static struct sdhci_pltfm_data sdhci_esdhc_pdata = { |
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 04936f353ced..0777fad997ba 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -114,6 +114,7 @@ static int ricoh_mmc_probe_slot(struct sdhci_pci_slot *slot) | |||
114 | 114 | ||
115 | SDHCI_TIMEOUT_CLK_UNIT | | 115 | SDHCI_TIMEOUT_CLK_UNIT | |
116 | SDHCI_CAN_VDD_330 | | 116 | SDHCI_CAN_VDD_330 | |
117 | SDHCI_CAN_DO_HISPD | | ||
117 | SDHCI_CAN_DO_SDMA; | 118 | SDHCI_CAN_DO_SDMA; |
118 | return 0; | 119 | return 0; |
119 | } | 120 | } |
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index 27164457f861..d4283ef5917a 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c | |||
@@ -78,6 +78,9 @@ void sdhci_get_of_property(struct platform_device *pdev) | |||
78 | if (of_get_property(np, "broken-cd", NULL)) | 78 | if (of_get_property(np, "broken-cd", NULL)) |
79 | host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; | 79 | host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; |
80 | 80 | ||
81 | if (of_get_property(np, "no-1-8-v", NULL)) | ||
82 | host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; | ||
83 | |||
81 | if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc")) | 84 | if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc")) |
82 | host->quirks |= SDHCI_QUIRK_BROKEN_DMA; | 85 | host->quirks |= SDHCI_QUIRK_BROKEN_DMA; |
83 | 86 | ||
@@ -89,6 +92,12 @@ void sdhci_get_of_property(struct platform_device *pdev) | |||
89 | clk = of_get_property(np, "clock-frequency", &size); | 92 | clk = of_get_property(np, "clock-frequency", &size); |
90 | if (clk && size == sizeof(*clk) && *clk) | 93 | if (clk && size == sizeof(*clk) && *clk) |
91 | pltfm_host->clock = be32_to_cpup(clk); | 94 | pltfm_host->clock = be32_to_cpup(clk); |
95 | |||
96 | if (of_find_property(np, "keep-power-in-suspend", NULL)) | ||
97 | host->mmc->pm_caps |= MMC_PM_KEEP_POWER; | ||
98 | |||
99 | if (of_find_property(np, "enable-sdio-wakeup", NULL)) | ||
100 | host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; | ||
92 | } | 101 | } |
93 | } | 102 | } |
94 | #else | 103 | #else |
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c index e918a2bb3af1..60829c92bcfd 100644 --- a/drivers/mmc/host/sdhci-pxav3.c +++ b/drivers/mmc/host/sdhci-pxav3.c | |||
@@ -163,10 +163,18 @@ static int pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs) | |||
163 | return 0; | 163 | return 0; |
164 | } | 164 | } |
165 | 165 | ||
166 | static u32 pxav3_get_max_clock(struct sdhci_host *host) | ||
167 | { | ||
168 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | ||
169 | |||
170 | return clk_get_rate(pltfm_host->clk); | ||
171 | } | ||
172 | |||
166 | static struct sdhci_ops pxav3_sdhci_ops = { | 173 | static struct sdhci_ops pxav3_sdhci_ops = { |
167 | .platform_reset_exit = pxav3_set_private_registers, | 174 | .platform_reset_exit = pxav3_set_private_registers, |
168 | .set_uhs_signaling = pxav3_set_uhs_signaling, | 175 | .set_uhs_signaling = pxav3_set_uhs_signaling, |
169 | .platform_send_init_74_clocks = pxav3_gen_init_74_clocks, | 176 | .platform_send_init_74_clocks = pxav3_gen_init_74_clocks, |
177 | .get_max_clock = pxav3_get_max_clock, | ||
170 | }; | 178 | }; |
171 | 179 | ||
172 | #ifdef CONFIG_OF | 180 | #ifdef CONFIG_OF |
@@ -249,7 +257,8 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev) | |||
249 | 257 | ||
250 | host->quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | 258 | host->quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
251 | | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 259 | | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC |
252 | | SDHCI_QUIRK_32BIT_ADMA_SIZE; | 260 | | SDHCI_QUIRK_32BIT_ADMA_SIZE |
261 | | SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN; | ||
253 | 262 | ||
254 | /* enable 1/8V DDR capable */ | 263 | /* enable 1/8V DDR capable */ |
255 | host->mmc->caps |= MMC_CAP_1_8V_DDR; | 264 | host->mmc->caps |= MMC_CAP_1_8V_DDR; |
@@ -271,6 +280,8 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev) | |||
271 | 280 | ||
272 | if (pdata->quirks) | 281 | if (pdata->quirks) |
273 | host->quirks |= pdata->quirks; | 282 | host->quirks |= pdata->quirks; |
283 | if (pdata->quirks2) | ||
284 | host->quirks2 |= pdata->quirks2; | ||
274 | if (pdata->host_caps) | 285 | if (pdata->host_caps) |
275 | host->mmc->caps |= pdata->host_caps; | 286 | host->mmc->caps |= pdata->host_caps; |
276 | if (pdata->host_caps2) | 287 | if (pdata->host_caps2) |
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index a54dd5d7a5f9..82b7a7ad4217 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/of_gpio.h> | 24 | #include <linux/of_gpio.h> |
25 | #include <linux/pm.h> | 25 | #include <linux/pm.h> |
26 | #include <linux/pm_runtime.h> | 26 | #include <linux/pm_runtime.h> |
27 | #include <linux/pinctrl/consumer.h> | ||
27 | 28 | ||
28 | #include <linux/mmc/host.h> | 29 | #include <linux/mmc/host.h> |
29 | 30 | ||
@@ -57,6 +58,7 @@ struct sdhci_s3c { | |||
57 | int ext_cd_irq; | 58 | int ext_cd_irq; |
58 | int ext_cd_gpio; | 59 | int ext_cd_gpio; |
59 | int *gpios; | 60 | int *gpios; |
61 | struct pinctrl *pctrl; | ||
60 | 62 | ||
61 | struct clk *clk_io; | 63 | struct clk *clk_io; |
62 | struct clk *clk_bus[MAX_BUS_CLK]; | 64 | struct clk *clk_bus[MAX_BUS_CLK]; |
@@ -373,18 +375,27 @@ static struct sdhci_ops sdhci_s3c_ops = { | |||
373 | static void sdhci_s3c_notify_change(struct platform_device *dev, int state) | 375 | static void sdhci_s3c_notify_change(struct platform_device *dev, int state) |
374 | { | 376 | { |
375 | struct sdhci_host *host = platform_get_drvdata(dev); | 377 | struct sdhci_host *host = platform_get_drvdata(dev); |
378 | #ifdef CONFIG_PM_RUNTIME | ||
379 | struct sdhci_s3c *sc = sdhci_priv(host); | ||
380 | #endif | ||
376 | unsigned long flags; | 381 | unsigned long flags; |
377 | 382 | ||
378 | if (host) { | 383 | if (host) { |
379 | spin_lock_irqsave(&host->lock, flags); | 384 | spin_lock_irqsave(&host->lock, flags); |
380 | if (state) { | 385 | if (state) { |
381 | dev_dbg(&dev->dev, "card inserted.\n"); | 386 | dev_dbg(&dev->dev, "card inserted.\n"); |
387 | #ifdef CONFIG_PM_RUNTIME | ||
388 | clk_prepare_enable(sc->clk_io); | ||
389 | #endif | ||
382 | host->flags &= ~SDHCI_DEVICE_DEAD; | 390 | host->flags &= ~SDHCI_DEVICE_DEAD; |
383 | host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; | 391 | host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; |
384 | } else { | 392 | } else { |
385 | dev_dbg(&dev->dev, "card removed.\n"); | 393 | dev_dbg(&dev->dev, "card removed.\n"); |
386 | host->flags |= SDHCI_DEVICE_DEAD; | 394 | host->flags |= SDHCI_DEVICE_DEAD; |
387 | host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; | 395 | host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; |
396 | #ifdef CONFIG_PM_RUNTIME | ||
397 | clk_disable_unprepare(sc->clk_io); | ||
398 | #endif | ||
388 | } | 399 | } |
389 | tasklet_schedule(&host->card_tasklet); | 400 | tasklet_schedule(&host->card_tasklet); |
390 | spin_unlock_irqrestore(&host->lock, flags); | 401 | spin_unlock_irqrestore(&host->lock, flags); |
@@ -406,7 +417,7 @@ static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc) | |||
406 | struct s3c_sdhci_platdata *pdata = sc->pdata; | 417 | struct s3c_sdhci_platdata *pdata = sc->pdata; |
407 | struct device *dev = &sc->pdev->dev; | 418 | struct device *dev = &sc->pdev->dev; |
408 | 419 | ||
409 | if (gpio_request(pdata->ext_cd_gpio, "SDHCI EXT CD") == 0) { | 420 | if (devm_gpio_request(dev, pdata->ext_cd_gpio, "SDHCI EXT CD") == 0) { |
410 | sc->ext_cd_gpio = pdata->ext_cd_gpio; | 421 | sc->ext_cd_gpio = pdata->ext_cd_gpio; |
411 | sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio); | 422 | sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio); |
412 | if (sc->ext_cd_irq && | 423 | if (sc->ext_cd_irq && |
@@ -449,12 +460,12 @@ static int __devinit sdhci_s3c_parse_dt(struct device *dev, | |||
449 | return -ENOMEM; | 460 | return -ENOMEM; |
450 | 461 | ||
451 | /* get the card detection method */ | 462 | /* get the card detection method */ |
452 | if (of_get_property(node, "broken-cd", 0)) { | 463 | if (of_get_property(node, "broken-cd", NULL)) { |
453 | pdata->cd_type = S3C_SDHCI_CD_NONE; | 464 | pdata->cd_type = S3C_SDHCI_CD_NONE; |
454 | goto setup_bus; | 465 | goto setup_bus; |
455 | } | 466 | } |
456 | 467 | ||
457 | if (of_get_property(node, "non-removable", 0)) { | 468 | if (of_get_property(node, "non-removable", NULL)) { |
458 | pdata->cd_type = S3C_SDHCI_CD_PERMANENT; | 469 | pdata->cd_type = S3C_SDHCI_CD_PERMANENT; |
459 | goto setup_bus; | 470 | goto setup_bus; |
460 | } | 471 | } |
@@ -477,8 +488,9 @@ static int __devinit sdhci_s3c_parse_dt(struct device *dev, | |||
477 | return -EINVAL; | 488 | return -EINVAL; |
478 | } | 489 | } |
479 | 490 | ||
480 | dev_info(dev, "assuming no card detect line available\n"); | 491 | /* assuming internal card detect that will be configured by pinctrl */ |
481 | pdata->cd_type = S3C_SDHCI_CD_NONE; | 492 | pdata->cd_type = S3C_SDHCI_CD_INTERNAL; |
493 | goto setup_bus; | ||
482 | 494 | ||
483 | found_cd: | 495 | found_cd: |
484 | if (pdata->cd_type == S3C_SDHCI_CD_GPIO) { | 496 | if (pdata->cd_type == S3C_SDHCI_CD_GPIO) { |
@@ -487,7 +499,7 @@ static int __devinit sdhci_s3c_parse_dt(struct device *dev, | |||
487 | if (of_get_property(node, "cd-inverted", NULL)) | 499 | if (of_get_property(node, "cd-inverted", NULL)) |
488 | pdata->ext_cd_gpio_invert = 1; | 500 | pdata->ext_cd_gpio_invert = 1; |
489 | } else if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { | 501 | } else if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
490 | ret = gpio_request(gpio, "sdhci-cd"); | 502 | ret = devm_gpio_request(dev, gpio, "sdhci-cd"); |
491 | if (ret) { | 503 | if (ret) { |
492 | dev_err(dev, "card detect gpio request failed\n"); | 504 | dev_err(dev, "card detect gpio request failed\n"); |
493 | return -EINVAL; | 505 | return -EINVAL; |
@@ -496,33 +508,28 @@ static int __devinit sdhci_s3c_parse_dt(struct device *dev, | |||
496 | } | 508 | } |
497 | 509 | ||
498 | setup_bus: | 510 | setup_bus: |
511 | if (!IS_ERR(ourhost->pctrl)) | ||
512 | return 0; | ||
513 | |||
499 | /* get the gpios for command, clock and data lines */ | 514 | /* get the gpios for command, clock and data lines */ |
500 | for (cnt = 0; cnt < NUM_GPIOS(pdata->max_width); cnt++) { | 515 | for (cnt = 0; cnt < NUM_GPIOS(pdata->max_width); cnt++) { |
501 | gpio = of_get_gpio(node, cnt); | 516 | gpio = of_get_gpio(node, cnt); |
502 | if (!gpio_is_valid(gpio)) { | 517 | if (!gpio_is_valid(gpio)) { |
503 | dev_err(dev, "invalid gpio[%d]\n", cnt); | 518 | dev_err(dev, "invalid gpio[%d]\n", cnt); |
504 | goto err_free_dt_cd_gpio; | 519 | return -EINVAL; |
505 | } | 520 | } |
506 | ourhost->gpios[cnt] = gpio; | 521 | ourhost->gpios[cnt] = gpio; |
507 | } | 522 | } |
508 | 523 | ||
509 | for (cnt = 0; cnt < NUM_GPIOS(pdata->max_width); cnt++) { | 524 | for (cnt = 0; cnt < NUM_GPIOS(pdata->max_width); cnt++) { |
510 | ret = gpio_request(ourhost->gpios[cnt], "sdhci-gpio"); | 525 | ret = devm_gpio_request(dev, ourhost->gpios[cnt], "sdhci-gpio"); |
511 | if (ret) { | 526 | if (ret) { |
512 | dev_err(dev, "gpio[%d] request failed\n", cnt); | 527 | dev_err(dev, "gpio[%d] request failed\n", cnt); |
513 | goto err_free_dt_gpios; | 528 | return -EINVAL; |
514 | } | 529 | } |
515 | } | 530 | } |
516 | 531 | ||
517 | return 0; | 532 | return 0; |
518 | |||
519 | err_free_dt_gpios: | ||
520 | while (--cnt >= 0) | ||
521 | gpio_free(ourhost->gpios[cnt]); | ||
522 | err_free_dt_cd_gpio: | ||
523 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) | ||
524 | gpio_free(ourhost->ext_cd_gpio); | ||
525 | return -EINVAL; | ||
526 | } | 533 | } |
527 | #else | 534 | #else |
528 | static int __devinit sdhci_s3c_parse_dt(struct device *dev, | 535 | static int __devinit sdhci_s3c_parse_dt(struct device *dev, |
@@ -579,13 +586,15 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
579 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | 586 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
580 | if (!pdata) { | 587 | if (!pdata) { |
581 | ret = -ENOMEM; | 588 | ret = -ENOMEM; |
582 | goto err_pdata; | 589 | goto err_pdata_io_clk; |
583 | } | 590 | } |
584 | 591 | ||
592 | sc->pctrl = devm_pinctrl_get_select_default(&pdev->dev); | ||
593 | |||
585 | if (pdev->dev.of_node) { | 594 | if (pdev->dev.of_node) { |
586 | ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata); | 595 | ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata); |
587 | if (ret) | 596 | if (ret) |
588 | goto err_pdata; | 597 | goto err_pdata_io_clk; |
589 | } else { | 598 | } else { |
590 | memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata)); | 599 | memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata)); |
591 | sc->ext_cd_gpio = -1; /* invalid gpio number */ | 600 | sc->ext_cd_gpio = -1; /* invalid gpio number */ |
@@ -603,7 +612,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
603 | if (IS_ERR(sc->clk_io)) { | 612 | if (IS_ERR(sc->clk_io)) { |
604 | dev_err(dev, "failed to get io clock\n"); | 613 | dev_err(dev, "failed to get io clock\n"); |
605 | ret = PTR_ERR(sc->clk_io); | 614 | ret = PTR_ERR(sc->clk_io); |
606 | goto err_io_clk; | 615 | goto err_pdata_io_clk; |
607 | } | 616 | } |
608 | 617 | ||
609 | /* enable the local io clock and keep it running for the moment. */ | 618 | /* enable the local io clock and keep it running for the moment. */ |
@@ -766,13 +775,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
766 | clk_disable_unprepare(sc->clk_io); | 775 | clk_disable_unprepare(sc->clk_io); |
767 | clk_put(sc->clk_io); | 776 | clk_put(sc->clk_io); |
768 | 777 | ||
769 | err_io_clk: | 778 | err_pdata_io_clk: |
770 | for (ptr = 0; ptr < NUM_GPIOS(sc->pdata->max_width); ptr++) | ||
771 | gpio_free(sc->gpios[ptr]); | ||
772 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) | ||
773 | gpio_free(sc->ext_cd_gpio); | ||
774 | |||
775 | err_pdata: | ||
776 | sdhci_free_host(host); | 779 | sdhci_free_host(host); |
777 | 780 | ||
778 | return ret; | 781 | return ret; |
@@ -791,9 +794,6 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) | |||
791 | if (sc->ext_cd_irq) | 794 | if (sc->ext_cd_irq) |
792 | free_irq(sc->ext_cd_irq, sc); | 795 | free_irq(sc->ext_cd_irq, sc); |
793 | 796 | ||
794 | if (gpio_is_valid(sc->ext_cd_gpio)) | ||
795 | gpio_free(sc->ext_cd_gpio); | ||
796 | |||
797 | #ifdef CONFIG_PM_RUNTIME | 797 | #ifdef CONFIG_PM_RUNTIME |
798 | if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) | 798 | if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) |
799 | clk_prepare_enable(sc->clk_io); | 799 | clk_prepare_enable(sc->clk_io); |
@@ -814,11 +814,6 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) | |||
814 | clk_disable_unprepare(sc->clk_io); | 814 | clk_disable_unprepare(sc->clk_io); |
815 | clk_put(sc->clk_io); | 815 | clk_put(sc->clk_io); |
816 | 816 | ||
817 | if (pdev->dev.of_node) { | ||
818 | for (ptr = 0; ptr < NUM_GPIOS(sc->pdata->max_width); ptr++) | ||
819 | gpio_free(sc->gpios[ptr]); | ||
820 | } | ||
821 | |||
822 | sdhci_free_host(host); | 817 | sdhci_free_host(host); |
823 | platform_set_drvdata(pdev, NULL); | 818 | platform_set_drvdata(pdev, NULL); |
824 | 819 | ||
diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index 6be89c032deb..87a700944b7d 100644 --- a/drivers/mmc/host/sdhci-spear.c +++ b/drivers/mmc/host/sdhci-spear.c | |||
@@ -146,6 +146,11 @@ static int __devinit sdhci_probe(struct platform_device *pdev) | |||
146 | goto put_clk; | 146 | goto put_clk; |
147 | } | 147 | } |
148 | 148 | ||
149 | ret = clk_set_rate(sdhci->clk, 50000000); | ||
150 | if (ret) | ||
151 | dev_dbg(&pdev->dev, "Error setting desired clk, clk=%lu\n", | ||
152 | clk_get_rate(sdhci->clk)); | ||
153 | |||
149 | if (np) { | 154 | if (np) { |
150 | sdhci->data = sdhci_probe_config_dt(pdev); | 155 | sdhci->data = sdhci_probe_config_dt(pdev); |
151 | if (IS_ERR(sdhci->data)) { | 156 | if (IS_ERR(sdhci->data)) { |
@@ -297,7 +302,7 @@ static int sdhci_suspend(struct device *dev) | |||
297 | 302 | ||
298 | ret = sdhci_suspend_host(host); | 303 | ret = sdhci_suspend_host(host); |
299 | if (!ret) | 304 | if (!ret) |
300 | clk_disable_unprepare(sdhci->clk); | 305 | clk_disable(sdhci->clk); |
301 | 306 | ||
302 | return ret; | 307 | return ret; |
303 | } | 308 | } |
@@ -308,7 +313,7 @@ static int sdhci_resume(struct device *dev) | |||
308 | struct spear_sdhci *sdhci = dev_get_platdata(dev); | 313 | struct spear_sdhci *sdhci = dev_get_platdata(dev); |
309 | int ret; | 314 | int ret; |
310 | 315 | ||
311 | ret = clk_prepare_enable(sdhci->clk); | 316 | ret = clk_enable(sdhci->clk); |
312 | if (ret) { | 317 | if (ret) { |
313 | dev_dbg(dev, "Resume: Error enabling clock\n"); | 318 | dev_dbg(dev, "Resume: Error enabling clock\n"); |
314 | return ret; | 319 | return ret; |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c7851c0aabce..6f0bfc0c8c9c 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -1618,7 +1618,7 @@ static int sdhci_do_3_3v_signal_voltage_switch(struct sdhci_host *host, | |||
1618 | sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); | 1618 | sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); |
1619 | 1619 | ||
1620 | if (host->vqmmc) { | 1620 | if (host->vqmmc) { |
1621 | ret = regulator_set_voltage(host->vqmmc, 3300000, 3300000); | 1621 | ret = regulator_set_voltage(host->vqmmc, 2700000, 3600000); |
1622 | if (ret) { | 1622 | if (ret) { |
1623 | pr_warning("%s: Switching to 3.3V signalling voltage " | 1623 | pr_warning("%s: Switching to 3.3V signalling voltage " |
1624 | " failed\n", mmc_hostname(host->mmc)); | 1624 | " failed\n", mmc_hostname(host->mmc)); |
@@ -1662,7 +1662,7 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host, | |||
1662 | */ | 1662 | */ |
1663 | if (host->vqmmc) | 1663 | if (host->vqmmc) |
1664 | ret = regulator_set_voltage(host->vqmmc, | 1664 | ret = regulator_set_voltage(host->vqmmc, |
1665 | 1800000, 1800000); | 1665 | 1700000, 1950000); |
1666 | else | 1666 | else |
1667 | ret = 0; | 1667 | ret = 0; |
1668 | 1668 | ||
@@ -1994,30 +1994,11 @@ static void sdhci_enable_preset_value(struct mmc_host *mmc, bool enable) | |||
1994 | sdhci_runtime_pm_put(host); | 1994 | sdhci_runtime_pm_put(host); |
1995 | } | 1995 | } |
1996 | 1996 | ||
1997 | static const struct mmc_host_ops sdhci_ops = { | 1997 | static void sdhci_card_event(struct mmc_host *mmc) |
1998 | .request = sdhci_request, | ||
1999 | .set_ios = sdhci_set_ios, | ||
2000 | .get_ro = sdhci_get_ro, | ||
2001 | .hw_reset = sdhci_hw_reset, | ||
2002 | .enable_sdio_irq = sdhci_enable_sdio_irq, | ||
2003 | .start_signal_voltage_switch = sdhci_start_signal_voltage_switch, | ||
2004 | .execute_tuning = sdhci_execute_tuning, | ||
2005 | .enable_preset_value = sdhci_enable_preset_value, | ||
2006 | }; | ||
2007 | |||
2008 | /*****************************************************************************\ | ||
2009 | * * | ||
2010 | * Tasklets * | ||
2011 | * * | ||
2012 | \*****************************************************************************/ | ||
2013 | |||
2014 | static void sdhci_tasklet_card(unsigned long param) | ||
2015 | { | 1998 | { |
2016 | struct sdhci_host *host; | 1999 | struct sdhci_host *host = mmc_priv(mmc); |
2017 | unsigned long flags; | 2000 | unsigned long flags; |
2018 | 2001 | ||
2019 | host = (struct sdhci_host*)param; | ||
2020 | |||
2021 | spin_lock_irqsave(&host->lock, flags); | 2002 | spin_lock_irqsave(&host->lock, flags); |
2022 | 2003 | ||
2023 | /* Check host->mrq first in case we are runtime suspended */ | 2004 | /* Check host->mrq first in case we are runtime suspended */ |
@@ -2036,6 +2017,31 @@ static void sdhci_tasklet_card(unsigned long param) | |||
2036 | } | 2017 | } |
2037 | 2018 | ||
2038 | spin_unlock_irqrestore(&host->lock, flags); | 2019 | spin_unlock_irqrestore(&host->lock, flags); |
2020 | } | ||
2021 | |||
2022 | static const struct mmc_host_ops sdhci_ops = { | ||
2023 | .request = sdhci_request, | ||
2024 | .set_ios = sdhci_set_ios, | ||
2025 | .get_ro = sdhci_get_ro, | ||
2026 | .hw_reset = sdhci_hw_reset, | ||
2027 | .enable_sdio_irq = sdhci_enable_sdio_irq, | ||
2028 | .start_signal_voltage_switch = sdhci_start_signal_voltage_switch, | ||
2029 | .execute_tuning = sdhci_execute_tuning, | ||
2030 | .enable_preset_value = sdhci_enable_preset_value, | ||
2031 | .card_event = sdhci_card_event, | ||
2032 | }; | ||
2033 | |||
2034 | /*****************************************************************************\ | ||
2035 | * * | ||
2036 | * Tasklets * | ||
2037 | * * | ||
2038 | \*****************************************************************************/ | ||
2039 | |||
2040 | static void sdhci_tasklet_card(unsigned long param) | ||
2041 | { | ||
2042 | struct sdhci_host *host = (struct sdhci_host*)param; | ||
2043 | |||
2044 | sdhci_card_event(host->mmc); | ||
2039 | 2045 | ||
2040 | mmc_detect_change(host->mmc, msecs_to_jiffies(200)); | 2046 | mmc_detect_change(host->mmc, msecs_to_jiffies(200)); |
2041 | } | 2047 | } |
@@ -2282,6 +2288,8 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) | |||
2282 | pr_err("%s: ADMA error\n", mmc_hostname(host->mmc)); | 2288 | pr_err("%s: ADMA error\n", mmc_hostname(host->mmc)); |
2283 | sdhci_show_adma_error(host); | 2289 | sdhci_show_adma_error(host); |
2284 | host->data->error = -EIO; | 2290 | host->data->error = -EIO; |
2291 | if (host->ops->adma_workaround) | ||
2292 | host->ops->adma_workaround(host, intmask); | ||
2285 | } | 2293 | } |
2286 | 2294 | ||
2287 | if (host->data->error) | 2295 | if (host->data->error) |
@@ -2858,10 +2866,16 @@ int sdhci_add_host(struct sdhci_host *host) | |||
2858 | mmc_hostname(mmc)); | 2866 | mmc_hostname(mmc)); |
2859 | host->vqmmc = NULL; | 2867 | host->vqmmc = NULL; |
2860 | } | 2868 | } |
2861 | } | 2869 | } else { |
2862 | else if (regulator_is_supported_voltage(host->vqmmc, 1800000, 1800000)) | ||
2863 | regulator_enable(host->vqmmc); | 2870 | regulator_enable(host->vqmmc); |
2864 | else | 2871 | if (!regulator_is_supported_voltage(host->vqmmc, 1700000, |
2872 | 1950000)) | ||
2873 | caps[1] &= ~(SDHCI_SUPPORT_SDR104 | | ||
2874 | SDHCI_SUPPORT_SDR50 | | ||
2875 | SDHCI_SUPPORT_DDR50); | ||
2876 | } | ||
2877 | |||
2878 | if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) | ||
2865 | caps[1] &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | | 2879 | caps[1] &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | |
2866 | SDHCI_SUPPORT_DDR50); | 2880 | SDHCI_SUPPORT_DDR50); |
2867 | 2881 | ||
@@ -2919,21 +2933,18 @@ int sdhci_add_host(struct sdhci_host *host) | |||
2919 | mmc_hostname(mmc)); | 2933 | mmc_hostname(mmc)); |
2920 | host->vmmc = NULL; | 2934 | host->vmmc = NULL; |
2921 | } | 2935 | } |
2922 | } else | 2936 | } |
2923 | regulator_enable(host->vmmc); | ||
2924 | 2937 | ||
2925 | #ifdef CONFIG_REGULATOR | 2938 | #ifdef CONFIG_REGULATOR |
2926 | if (host->vmmc) { | 2939 | if (host->vmmc) { |
2927 | ret = regulator_is_supported_voltage(host->vmmc, 3300000, | 2940 | ret = regulator_is_supported_voltage(host->vmmc, 2700000, |
2928 | 3300000); | 2941 | 3600000); |
2929 | if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_330))) | 2942 | if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_330))) |
2930 | caps[0] &= ~SDHCI_CAN_VDD_330; | 2943 | caps[0] &= ~SDHCI_CAN_VDD_330; |
2931 | ret = regulator_is_supported_voltage(host->vmmc, 3000000, | ||
2932 | 3000000); | ||
2933 | if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_300))) | 2944 | if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_300))) |
2934 | caps[0] &= ~SDHCI_CAN_VDD_300; | 2945 | caps[0] &= ~SDHCI_CAN_VDD_300; |
2935 | ret = regulator_is_supported_voltage(host->vmmc, 1800000, | 2946 | ret = regulator_is_supported_voltage(host->vmmc, 1700000, |
2936 | 1800000); | 2947 | 1950000); |
2937 | if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_180))) | 2948 | if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_180))) |
2938 | caps[0] &= ~SDHCI_CAN_VDD_180; | 2949 | caps[0] &= ~SDHCI_CAN_VDD_180; |
2939 | } | 2950 | } |
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 71a4a7ed46c5..a6d69b7bdea2 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -120,6 +120,7 @@ | |||
120 | #define SDHCI_SIGNAL_ENABLE 0x38 | 120 | #define SDHCI_SIGNAL_ENABLE 0x38 |
121 | #define SDHCI_INT_RESPONSE 0x00000001 | 121 | #define SDHCI_INT_RESPONSE 0x00000001 |
122 | #define SDHCI_INT_DATA_END 0x00000002 | 122 | #define SDHCI_INT_DATA_END 0x00000002 |
123 | #define SDHCI_INT_BLK_GAP 0x00000004 | ||
123 | #define SDHCI_INT_DMA_END 0x00000008 | 124 | #define SDHCI_INT_DMA_END 0x00000008 |
124 | #define SDHCI_INT_SPACE_AVAIL 0x00000010 | 125 | #define SDHCI_INT_SPACE_AVAIL 0x00000010 |
125 | #define SDHCI_INT_DATA_AVAIL 0x00000020 | 126 | #define SDHCI_INT_DATA_AVAIL 0x00000020 |
@@ -146,7 +147,8 @@ | |||
146 | #define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \ | 147 | #define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \ |
147 | SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \ | 148 | SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \ |
148 | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ | 149 | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ |
149 | SDHCI_INT_DATA_END_BIT | SDHCI_INT_ADMA_ERROR) | 150 | SDHCI_INT_DATA_END_BIT | SDHCI_INT_ADMA_ERROR | \ |
151 | SDHCI_INT_BLK_GAP) | ||
150 | #define SDHCI_INT_ALL_MASK ((unsigned int)-1) | 152 | #define SDHCI_INT_ALL_MASK ((unsigned int)-1) |
151 | 153 | ||
152 | #define SDHCI_ACMD12_ERR 0x3C | 154 | #define SDHCI_ACMD12_ERR 0x3C |
@@ -278,6 +280,7 @@ struct sdhci_ops { | |||
278 | void (*hw_reset)(struct sdhci_host *host); | 280 | void (*hw_reset)(struct sdhci_host *host); |
279 | void (*platform_suspend)(struct sdhci_host *host); | 281 | void (*platform_suspend)(struct sdhci_host *host); |
280 | void (*platform_resume)(struct sdhci_host *host); | 282 | void (*platform_resume)(struct sdhci_host *host); |
283 | void (*adma_workaround)(struct sdhci_host *host, u32 intmask); | ||
281 | void (*platform_init)(struct sdhci_host *host); | 284 | void (*platform_init)(struct sdhci_host *host); |
282 | }; | 285 | }; |
283 | 286 | ||
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index d25bc97dc5c6..ae795233a1d6 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c | |||
@@ -1104,7 +1104,6 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id) | |||
1104 | { | 1104 | { |
1105 | struct sh_mmcif_host *host = dev_id; | 1105 | struct sh_mmcif_host *host = dev_id; |
1106 | struct mmc_request *mrq = host->mrq; | 1106 | struct mmc_request *mrq = host->mrq; |
1107 | struct mmc_data *data = mrq->data; | ||
1108 | 1107 | ||
1109 | cancel_delayed_work_sync(&host->timeout_work); | 1108 | cancel_delayed_work_sync(&host->timeout_work); |
1110 | 1109 | ||
@@ -1152,13 +1151,14 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id) | |||
1152 | case MMCIF_WAIT_FOR_READ_END: | 1151 | case MMCIF_WAIT_FOR_READ_END: |
1153 | case MMCIF_WAIT_FOR_WRITE_END: | 1152 | case MMCIF_WAIT_FOR_WRITE_END: |
1154 | if (host->sd_error) | 1153 | if (host->sd_error) |
1155 | data->error = sh_mmcif_error_manage(host); | 1154 | mrq->data->error = sh_mmcif_error_manage(host); |
1156 | break; | 1155 | break; |
1157 | default: | 1156 | default: |
1158 | BUG(); | 1157 | BUG(); |
1159 | } | 1158 | } |
1160 | 1159 | ||
1161 | if (host->wait_for != MMCIF_WAIT_FOR_STOP) { | 1160 | if (host->wait_for != MMCIF_WAIT_FOR_STOP) { |
1161 | struct mmc_data *data = mrq->data; | ||
1162 | if (!mrq->cmd->error && data && !data->error) | 1162 | if (!mrq->cmd->error && data && !data->error) |
1163 | data->bytes_xfered = | 1163 | data->bytes_xfered = |
1164 | data->blocks * data->blksz; | 1164 | data->blocks * data->blksz; |
@@ -1231,10 +1231,6 @@ static irqreturn_t sh_mmcif_intr(int irq, void *dev_id) | |||
1231 | host->sd_error = true; | 1231 | host->sd_error = true; |
1232 | dev_dbg(&host->pd->dev, "int err state = %08x\n", state); | 1232 | dev_dbg(&host->pd->dev, "int err state = %08x\n", state); |
1233 | } | 1233 | } |
1234 | if (host->state == STATE_IDLE) { | ||
1235 | dev_info(&host->pd->dev, "Spurious IRQ status 0x%x", state); | ||
1236 | return IRQ_HANDLED; | ||
1237 | } | ||
1238 | if (state & ~(INT_CMD12RBE | INT_CMD12CRE)) { | 1234 | if (state & ~(INT_CMD12RBE | INT_CMD12CRE)) { |
1239 | if (!host->dma_active) | 1235 | if (!host->dma_active) |
1240 | return IRQ_WAKE_THREAD; | 1236 | return IRQ_WAKE_THREAD; |
@@ -1310,7 +1306,6 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
1310 | struct sh_mmcif_plat_data *pd = pdev->dev.platform_data; | 1306 | struct sh_mmcif_plat_data *pd = pdev->dev.platform_data; |
1311 | struct resource *res; | 1307 | struct resource *res; |
1312 | void __iomem *reg; | 1308 | void __iomem *reg; |
1313 | char clk_name[8]; | ||
1314 | 1309 | ||
1315 | irq[0] = platform_get_irq(pdev, 0); | 1310 | irq[0] = platform_get_irq(pdev, 0); |
1316 | irq[1] = platform_get_irq(pdev, 1); | 1311 | irq[1] = platform_get_irq(pdev, 1); |
@@ -1360,11 +1355,10 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) | |||
1360 | pm_runtime_enable(&pdev->dev); | 1355 | pm_runtime_enable(&pdev->dev); |
1361 | host->power = false; | 1356 | host->power = false; |
1362 | 1357 | ||
1363 | snprintf(clk_name, sizeof(clk_name), "mmc%d", pdev->id); | 1358 | host->hclk = clk_get(&pdev->dev, NULL); |
1364 | host->hclk = clk_get(&pdev->dev, clk_name); | ||
1365 | if (IS_ERR(host->hclk)) { | 1359 | if (IS_ERR(host->hclk)) { |
1366 | ret = PTR_ERR(host->hclk); | 1360 | ret = PTR_ERR(host->hclk); |
1367 | dev_err(&pdev->dev, "cannot get clock \"%s\": %d\n", clk_name, ret); | 1361 | dev_err(&pdev->dev, "cannot get clock: %d\n", ret); |
1368 | goto eclkget; | 1362 | goto eclkget; |
1369 | } | 1363 | } |
1370 | ret = sh_mmcif_clk_update(host); | 1364 | ret = sh_mmcif_clk_update(host); |
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 0bdc146178db..d6ff8531fb35 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c | |||
@@ -123,7 +123,6 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
123 | struct tmio_mmc_data *mmc_data; | 123 | struct tmio_mmc_data *mmc_data; |
124 | struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; | 124 | struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; |
125 | struct tmio_mmc_host *host; | 125 | struct tmio_mmc_host *host; |
126 | char clk_name[8]; | ||
127 | int irq, ret, i = 0; | 126 | int irq, ret, i = 0; |
128 | bool multiplexed_isr = true; | 127 | bool multiplexed_isr = true; |
129 | 128 | ||
@@ -144,11 +143,10 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
144 | } | 143 | } |
145 | } | 144 | } |
146 | 145 | ||
147 | snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id); | 146 | priv->clk = clk_get(&pdev->dev, NULL); |
148 | priv->clk = clk_get(&pdev->dev, clk_name); | ||
149 | if (IS_ERR(priv->clk)) { | 147 | if (IS_ERR(priv->clk)) { |
150 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | ||
151 | ret = PTR_ERR(priv->clk); | 148 | ret = PTR_ERR(priv->clk); |
149 | dev_err(&pdev->dev, "cannot get clock: %d\n", ret); | ||
152 | goto eclkget; | 150 | goto eclkget; |
153 | } | 151 | } |
154 | 152 | ||
@@ -250,7 +248,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
250 | dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n", | 248 | dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n", |
251 | mmc_hostname(host->mmc), (unsigned long) | 249 | mmc_hostname(host->mmc), (unsigned long) |
252 | (platform_get_resource(pdev, IORESOURCE_MEM, 0)->start), | 250 | (platform_get_resource(pdev, IORESOURCE_MEM, 0)->start), |
253 | mmc_data->hclk / 1000000); | 251 | host->mmc->f_max / 1000000); |
254 | 252 | ||
255 | return ret; | 253 | return ret; |
256 | 254 | ||
diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c index d5655a63eda4..cb9f361c03ab 100644 --- a/drivers/mmc/host/vub300.c +++ b/drivers/mmc/host/vub300.c | |||
@@ -2362,6 +2362,7 @@ error4: | |||
2362 | error1: | 2362 | error1: |
2363 | usb_free_urb(command_out_urb); | 2363 | usb_free_urb(command_out_urb); |
2364 | error0: | 2364 | error0: |
2365 | usb_put_dev(udev); | ||
2365 | return retval; | 2366 | return retval; |
2366 | } | 2367 | } |
2367 | 2368 | ||
diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c new file mode 100644 index 000000000000..5ba4605e4f80 --- /dev/null +++ b/drivers/mmc/host/wmt-sdmmc.c | |||
@@ -0,0 +1,1029 @@ | |||
1 | /* | ||
2 | * WM8505/WM8650 SD/MMC Host Controller | ||
3 | * | ||
4 | * Copyright (C) 2010 Tony Prisk | ||
5 | * Copyright (C) 2008 WonderMedia Technologies, Inc. | ||
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 version 2 as | ||
9 | * published by the Free Software Foundation | ||
10 | */ | ||
11 | |||
12 | #include <linux/init.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/ioport.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/dma-mapping.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <linux/irq.h> | ||
21 | #include <linux/clk.h> | ||
22 | #include <linux/gpio.h> | ||
23 | |||
24 | #include <linux/of.h> | ||
25 | #include <linux/of_address.h> | ||
26 | #include <linux/of_irq.h> | ||
27 | #include <linux/of_device.h> | ||
28 | |||
29 | #include <linux/mmc/host.h> | ||
30 | #include <linux/mmc/mmc.h> | ||
31 | #include <linux/mmc/sd.h> | ||
32 | |||
33 | #include <asm/byteorder.h> | ||
34 | |||
35 | |||
36 | #define DRIVER_NAME "wmt-sdhc" | ||
37 | |||
38 | |||
39 | /* MMC/SD controller registers */ | ||
40 | #define SDMMC_CTLR 0x00 | ||
41 | #define SDMMC_CMD 0x01 | ||
42 | #define SDMMC_RSPTYPE 0x02 | ||
43 | #define SDMMC_ARG 0x04 | ||
44 | #define SDMMC_BUSMODE 0x08 | ||
45 | #define SDMMC_BLKLEN 0x0C | ||
46 | #define SDMMC_BLKCNT 0x0E | ||
47 | #define SDMMC_RSP 0x10 | ||
48 | #define SDMMC_CBCR 0x20 | ||
49 | #define SDMMC_INTMASK0 0x24 | ||
50 | #define SDMMC_INTMASK1 0x25 | ||
51 | #define SDMMC_STS0 0x28 | ||
52 | #define SDMMC_STS1 0x29 | ||
53 | #define SDMMC_STS2 0x2A | ||
54 | #define SDMMC_STS3 0x2B | ||
55 | #define SDMMC_RSPTIMEOUT 0x2C | ||
56 | #define SDMMC_CLK 0x30 /* VT8500 only */ | ||
57 | #define SDMMC_EXTCTRL 0x34 | ||
58 | #define SDMMC_SBLKLEN 0x38 | ||
59 | #define SDMMC_DMATIMEOUT 0x3C | ||
60 | |||
61 | |||
62 | /* SDMMC_CTLR bit fields */ | ||
63 | #define CTLR_CMD_START 0x01 | ||
64 | #define CTLR_CMD_WRITE 0x04 | ||
65 | #define CTLR_FIFO_RESET 0x08 | ||
66 | |||
67 | /* SDMMC_BUSMODE bit fields */ | ||
68 | #define BM_SPI_MODE 0x01 | ||
69 | #define BM_FOURBIT_MODE 0x02 | ||
70 | #define BM_EIGHTBIT_MODE 0x04 | ||
71 | #define BM_SD_OFF 0x10 | ||
72 | #define BM_SPI_CS 0x20 | ||
73 | #define BM_SD_POWER 0x40 | ||
74 | #define BM_SOFT_RESET 0x80 | ||
75 | #define BM_ONEBIT_MASK 0xFD | ||
76 | |||
77 | /* SDMMC_BLKLEN bit fields */ | ||
78 | #define BLKL_CRCERR_ABORT 0x0800 | ||
79 | #define BLKL_CD_POL_HIGH 0x1000 | ||
80 | #define BLKL_GPI_CD 0x2000 | ||
81 | #define BLKL_DATA3_CD 0x4000 | ||
82 | #define BLKL_INT_ENABLE 0x8000 | ||
83 | |||
84 | /* SDMMC_INTMASK0 bit fields */ | ||
85 | #define INT0_MBLK_TRAN_DONE_INT_EN 0x10 | ||
86 | #define INT0_BLK_TRAN_DONE_INT_EN 0x20 | ||
87 | #define INT0_CD_INT_EN 0x40 | ||
88 | #define INT0_DI_INT_EN 0x80 | ||
89 | |||
90 | /* SDMMC_INTMASK1 bit fields */ | ||
91 | #define INT1_CMD_RES_TRAN_DONE_INT_EN 0x02 | ||
92 | #define INT1_CMD_RES_TOUT_INT_EN 0x04 | ||
93 | #define INT1_MBLK_AUTO_STOP_INT_EN 0x08 | ||
94 | #define INT1_DATA_TOUT_INT_EN 0x10 | ||
95 | #define INT1_RESCRC_ERR_INT_EN 0x20 | ||
96 | #define INT1_RCRC_ERR_INT_EN 0x40 | ||
97 | #define INT1_WCRC_ERR_INT_EN 0x80 | ||
98 | |||
99 | /* SDMMC_STS0 bit fields */ | ||
100 | #define STS0_WRITE_PROTECT 0x02 | ||
101 | #define STS0_CD_DATA3 0x04 | ||
102 | #define STS0_CD_GPI 0x08 | ||
103 | #define STS0_MBLK_DONE 0x10 | ||
104 | #define STS0_BLK_DONE 0x20 | ||
105 | #define STS0_CARD_DETECT 0x40 | ||
106 | #define STS0_DEVICE_INS 0x80 | ||
107 | |||
108 | /* SDMMC_STS1 bit fields */ | ||
109 | #define STS1_SDIO_INT 0x01 | ||
110 | #define STS1_CMDRSP_DONE 0x02 | ||
111 | #define STS1_RSP_TIMEOUT 0x04 | ||
112 | #define STS1_AUTOSTOP_DONE 0x08 | ||
113 | #define STS1_DATA_TIMEOUT 0x10 | ||
114 | #define STS1_RSP_CRC_ERR 0x20 | ||
115 | #define STS1_RCRC_ERR 0x40 | ||
116 | #define STS1_WCRC_ERR 0x80 | ||
117 | |||
118 | /* SDMMC_STS2 bit fields */ | ||
119 | #define STS2_CMD_RES_BUSY 0x10 | ||
120 | #define STS2_DATARSP_BUSY 0x20 | ||
121 | #define STS2_DIS_FORCECLK 0x80 | ||
122 | |||
123 | |||
124 | /* MMC/SD DMA Controller Registers */ | ||
125 | #define SDDMA_GCR 0x100 | ||
126 | #define SDDMA_IER 0x104 | ||
127 | #define SDDMA_ISR 0x108 | ||
128 | #define SDDMA_DESPR 0x10C | ||
129 | #define SDDMA_RBR 0x110 | ||
130 | #define SDDMA_DAR 0x114 | ||
131 | #define SDDMA_BAR 0x118 | ||
132 | #define SDDMA_CPR 0x11C | ||
133 | #define SDDMA_CCR 0x120 | ||
134 | |||
135 | |||
136 | /* SDDMA_GCR bit fields */ | ||
137 | #define DMA_GCR_DMA_EN 0x00000001 | ||
138 | #define DMA_GCR_SOFT_RESET 0x00000100 | ||
139 | |||
140 | /* SDDMA_IER bit fields */ | ||
141 | #define DMA_IER_INT_EN 0x00000001 | ||
142 | |||
143 | /* SDDMA_ISR bit fields */ | ||
144 | #define DMA_ISR_INT_STS 0x00000001 | ||
145 | |||
146 | /* SDDMA_RBR bit fields */ | ||
147 | #define DMA_RBR_FORMAT 0x40000000 | ||
148 | #define DMA_RBR_END 0x80000000 | ||
149 | |||
150 | /* SDDMA_CCR bit fields */ | ||
151 | #define DMA_CCR_RUN 0x00000080 | ||
152 | #define DMA_CCR_IF_TO_PERIPHERAL 0x00000000 | ||
153 | #define DMA_CCR_PERIPHERAL_TO_IF 0x00400000 | ||
154 | |||
155 | /* SDDMA_CCR event status */ | ||
156 | #define DMA_CCR_EVT_NO_STATUS 0x00000000 | ||
157 | #define DMA_CCR_EVT_UNDERRUN 0x00000001 | ||
158 | #define DMA_CCR_EVT_OVERRUN 0x00000002 | ||
159 | #define DMA_CCR_EVT_DESP_READ 0x00000003 | ||
160 | #define DMA_CCR_EVT_DATA_RW 0x00000004 | ||
161 | #define DMA_CCR_EVT_EARLY_END 0x00000005 | ||
162 | #define DMA_CCR_EVT_SUCCESS 0x0000000F | ||
163 | |||
164 | #define PDMA_READ 0x00 | ||
165 | #define PDMA_WRITE 0x01 | ||
166 | |||
167 | #define WMT_SD_POWER_OFF 0 | ||
168 | #define WMT_SD_POWER_ON 1 | ||
169 | |||
170 | struct wmt_dma_descriptor { | ||
171 | u32 flags; | ||
172 | u32 data_buffer_addr; | ||
173 | u32 branch_addr; | ||
174 | u32 reserved1; | ||
175 | }; | ||
176 | |||
177 | struct wmt_mci_caps { | ||
178 | unsigned int f_min; | ||
179 | unsigned int f_max; | ||
180 | u32 ocr_avail; | ||
181 | u32 caps; | ||
182 | u32 max_seg_size; | ||
183 | u32 max_segs; | ||
184 | u32 max_blk_size; | ||
185 | }; | ||
186 | |||
187 | struct wmt_mci_priv { | ||
188 | struct mmc_host *mmc; | ||
189 | void __iomem *sdmmc_base; | ||
190 | |||
191 | int irq_regular; | ||
192 | int irq_dma; | ||
193 | |||
194 | void *dma_desc_buffer; | ||
195 | dma_addr_t dma_desc_device_addr; | ||
196 | |||
197 | struct completion cmdcomp; | ||
198 | struct completion datacomp; | ||
199 | |||
200 | struct completion *comp_cmd; | ||
201 | struct completion *comp_dma; | ||
202 | |||
203 | struct mmc_request *req; | ||
204 | struct mmc_command *cmd; | ||
205 | |||
206 | struct clk *clk_sdmmc; | ||
207 | struct device *dev; | ||
208 | |||
209 | u8 power_inverted; | ||
210 | u8 cd_inverted; | ||
211 | }; | ||
212 | |||
213 | static void wmt_set_sd_power(struct wmt_mci_priv *priv, int enable) | ||
214 | { | ||
215 | u32 reg_tmp; | ||
216 | if (enable) { | ||
217 | if (priv->power_inverted) { | ||
218 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
219 | writeb(reg_tmp | BM_SD_OFF, | ||
220 | priv->sdmmc_base + SDMMC_BUSMODE); | ||
221 | } else { | ||
222 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
223 | writeb(reg_tmp & (~BM_SD_OFF), | ||
224 | priv->sdmmc_base + SDMMC_BUSMODE); | ||
225 | } | ||
226 | } else { | ||
227 | if (priv->power_inverted) { | ||
228 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
229 | writeb(reg_tmp & (~BM_SD_OFF), | ||
230 | priv->sdmmc_base + SDMMC_BUSMODE); | ||
231 | } else { | ||
232 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
233 | writeb(reg_tmp | BM_SD_OFF, | ||
234 | priv->sdmmc_base + SDMMC_BUSMODE); | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | |||
239 | static void wmt_mci_read_response(struct mmc_host *mmc) | ||
240 | { | ||
241 | struct wmt_mci_priv *priv; | ||
242 | int idx1, idx2; | ||
243 | u8 tmp_resp; | ||
244 | u32 response; | ||
245 | |||
246 | priv = mmc_priv(mmc); | ||
247 | |||
248 | for (idx1 = 0; idx1 < 4; idx1++) { | ||
249 | response = 0; | ||
250 | for (idx2 = 0; idx2 < 4; idx2++) { | ||
251 | if ((idx1 == 3) && (idx2 == 3)) | ||
252 | tmp_resp = readb(priv->sdmmc_base + SDMMC_RSP); | ||
253 | else | ||
254 | tmp_resp = readb(priv->sdmmc_base + SDMMC_RSP + | ||
255 | (idx1*4) + idx2 + 1); | ||
256 | response |= (tmp_resp << (idx2 * 8)); | ||
257 | } | ||
258 | priv->cmd->resp[idx1] = cpu_to_be32(response); | ||
259 | } | ||
260 | } | ||
261 | |||
262 | static void wmt_mci_start_command(struct wmt_mci_priv *priv) | ||
263 | { | ||
264 | u32 reg_tmp; | ||
265 | |||
266 | reg_tmp = readb(priv->sdmmc_base + SDMMC_CTLR); | ||
267 | writeb(reg_tmp | CTLR_CMD_START, priv->sdmmc_base + SDMMC_CTLR); | ||
268 | } | ||
269 | |||
270 | static int wmt_mci_send_command(struct mmc_host *mmc, u8 command, u8 cmdtype, | ||
271 | u32 arg, u8 rsptype) | ||
272 | { | ||
273 | struct wmt_mci_priv *priv; | ||
274 | u32 reg_tmp; | ||
275 | |||
276 | priv = mmc_priv(mmc); | ||
277 | |||
278 | /* write command, arg, resptype registers */ | ||
279 | writeb(command, priv->sdmmc_base + SDMMC_CMD); | ||
280 | writel(arg, priv->sdmmc_base + SDMMC_ARG); | ||
281 | writeb(rsptype, priv->sdmmc_base + SDMMC_RSPTYPE); | ||
282 | |||
283 | /* reset response FIFO */ | ||
284 | reg_tmp = readb(priv->sdmmc_base + SDMMC_CTLR); | ||
285 | writeb(reg_tmp | CTLR_FIFO_RESET, priv->sdmmc_base + SDMMC_CTLR); | ||
286 | |||
287 | /* ensure clock enabled - VT3465 */ | ||
288 | wmt_set_sd_power(priv, WMT_SD_POWER_ON); | ||
289 | |||
290 | /* clear status bits */ | ||
291 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS0); | ||
292 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS1); | ||
293 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS2); | ||
294 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS3); | ||
295 | |||
296 | /* set command type */ | ||
297 | reg_tmp = readb(priv->sdmmc_base + SDMMC_CTLR); | ||
298 | writeb((reg_tmp & 0x0F) | (cmdtype << 4), | ||
299 | priv->sdmmc_base + SDMMC_CTLR); | ||
300 | |||
301 | return 0; | ||
302 | } | ||
303 | |||
304 | static void wmt_mci_disable_dma(struct wmt_mci_priv *priv) | ||
305 | { | ||
306 | writel(DMA_ISR_INT_STS, priv->sdmmc_base + SDDMA_ISR); | ||
307 | writel(0, priv->sdmmc_base + SDDMA_IER); | ||
308 | } | ||
309 | |||
310 | static void wmt_complete_data_request(struct wmt_mci_priv *priv) | ||
311 | { | ||
312 | struct mmc_request *req; | ||
313 | req = priv->req; | ||
314 | |||
315 | req->data->bytes_xfered = req->data->blksz * req->data->blocks; | ||
316 | |||
317 | /* unmap the DMA pages used for write data */ | ||
318 | if (req->data->flags & MMC_DATA_WRITE) | ||
319 | dma_unmap_sg(mmc_dev(priv->mmc), req->data->sg, | ||
320 | req->data->sg_len, DMA_TO_DEVICE); | ||
321 | else | ||
322 | dma_unmap_sg(mmc_dev(priv->mmc), req->data->sg, | ||
323 | req->data->sg_len, DMA_FROM_DEVICE); | ||
324 | |||
325 | /* Check if the DMA ISR returned a data error */ | ||
326 | if ((req->cmd->error) || (req->data->error)) | ||
327 | mmc_request_done(priv->mmc, req); | ||
328 | else { | ||
329 | wmt_mci_read_response(priv->mmc); | ||
330 | if (!req->data->stop) { | ||
331 | /* single-block read/write requests end here */ | ||
332 | mmc_request_done(priv->mmc, req); | ||
333 | } else { | ||
334 | /* | ||
335 | * we change the priv->cmd variable so the response is | ||
336 | * stored in the stop struct rather than the original | ||
337 | * calling command struct | ||
338 | */ | ||
339 | priv->comp_cmd = &priv->cmdcomp; | ||
340 | init_completion(priv->comp_cmd); | ||
341 | priv->cmd = req->data->stop; | ||
342 | wmt_mci_send_command(priv->mmc, req->data->stop->opcode, | ||
343 | 7, req->data->stop->arg, 9); | ||
344 | wmt_mci_start_command(priv); | ||
345 | } | ||
346 | } | ||
347 | } | ||
348 | |||
349 | static irqreturn_t wmt_mci_dma_isr(int irq_num, void *data) | ||
350 | { | ||
351 | struct mmc_host *mmc; | ||
352 | struct wmt_mci_priv *priv; | ||
353 | |||
354 | int status; | ||
355 | |||
356 | priv = (struct wmt_mci_priv *)data; | ||
357 | mmc = priv->mmc; | ||
358 | |||
359 | status = readl(priv->sdmmc_base + SDDMA_CCR) & 0x0F; | ||
360 | |||
361 | if (status != DMA_CCR_EVT_SUCCESS) { | ||
362 | dev_err(priv->dev, "DMA Error: Status = %d\n", status); | ||
363 | priv->req->data->error = -ETIMEDOUT; | ||
364 | complete(priv->comp_dma); | ||
365 | return IRQ_HANDLED; | ||
366 | } | ||
367 | |||
368 | priv->req->data->error = 0; | ||
369 | |||
370 | wmt_mci_disable_dma(priv); | ||
371 | |||
372 | complete(priv->comp_dma); | ||
373 | |||
374 | if (priv->comp_cmd) { | ||
375 | if (completion_done(priv->comp_cmd)) { | ||
376 | /* | ||
377 | * if the command (regular) interrupt has already | ||
378 | * completed, finish off the request otherwise we wait | ||
379 | * for the command interrupt and finish from there. | ||
380 | */ | ||
381 | wmt_complete_data_request(priv); | ||
382 | } | ||
383 | } | ||
384 | |||
385 | return IRQ_HANDLED; | ||
386 | } | ||
387 | |||
388 | static irqreturn_t wmt_mci_regular_isr(int irq_num, void *data) | ||
389 | { | ||
390 | struct wmt_mci_priv *priv; | ||
391 | u32 status0; | ||
392 | u32 status1; | ||
393 | u32 status2; | ||
394 | u32 reg_tmp; | ||
395 | int cmd_done; | ||
396 | |||
397 | priv = (struct wmt_mci_priv *)data; | ||
398 | cmd_done = 0; | ||
399 | status0 = readb(priv->sdmmc_base + SDMMC_STS0); | ||
400 | status1 = readb(priv->sdmmc_base + SDMMC_STS1); | ||
401 | status2 = readb(priv->sdmmc_base + SDMMC_STS2); | ||
402 | |||
403 | /* Check for card insertion */ | ||
404 | reg_tmp = readb(priv->sdmmc_base + SDMMC_INTMASK0); | ||
405 | if ((reg_tmp & INT0_DI_INT_EN) && (status0 & STS0_DEVICE_INS)) { | ||
406 | mmc_detect_change(priv->mmc, 0); | ||
407 | if (priv->cmd) | ||
408 | priv->cmd->error = -ETIMEDOUT; | ||
409 | if (priv->comp_cmd) | ||
410 | complete(priv->comp_cmd); | ||
411 | if (priv->comp_dma) { | ||
412 | wmt_mci_disable_dma(priv); | ||
413 | complete(priv->comp_dma); | ||
414 | } | ||
415 | writeb(STS0_DEVICE_INS, priv->sdmmc_base + SDMMC_STS0); | ||
416 | return IRQ_HANDLED; | ||
417 | } | ||
418 | |||
419 | if ((!priv->req->data) || | ||
420 | ((priv->req->data->stop) && (priv->cmd == priv->req->data->stop))) { | ||
421 | /* handle non-data & stop_transmission requests */ | ||
422 | if (status1 & STS1_CMDRSP_DONE) { | ||
423 | priv->cmd->error = 0; | ||
424 | cmd_done = 1; | ||
425 | } else if ((status1 & STS1_RSP_TIMEOUT) || | ||
426 | (status1 & STS1_DATA_TIMEOUT)) { | ||
427 | priv->cmd->error = -ETIMEDOUT; | ||
428 | cmd_done = 1; | ||
429 | } | ||
430 | |||
431 | if (cmd_done) { | ||
432 | priv->comp_cmd = NULL; | ||
433 | |||
434 | if (!priv->cmd->error) | ||
435 | wmt_mci_read_response(priv->mmc); | ||
436 | |||
437 | priv->cmd = NULL; | ||
438 | |||
439 | mmc_request_done(priv->mmc, priv->req); | ||
440 | } | ||
441 | } else { | ||
442 | /* handle data requests */ | ||
443 | if (status1 & STS1_CMDRSP_DONE) { | ||
444 | if (priv->cmd) | ||
445 | priv->cmd->error = 0; | ||
446 | if (priv->comp_cmd) | ||
447 | complete(priv->comp_cmd); | ||
448 | } | ||
449 | |||
450 | if ((status1 & STS1_RSP_TIMEOUT) || | ||
451 | (status1 & STS1_DATA_TIMEOUT)) { | ||
452 | if (priv->cmd) | ||
453 | priv->cmd->error = -ETIMEDOUT; | ||
454 | if (priv->comp_cmd) | ||
455 | complete(priv->comp_cmd); | ||
456 | if (priv->comp_dma) { | ||
457 | wmt_mci_disable_dma(priv); | ||
458 | complete(priv->comp_dma); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | if (priv->comp_dma) { | ||
463 | /* | ||
464 | * If the dma interrupt has already completed, finish | ||
465 | * off the request; otherwise we wait for the DMA | ||
466 | * interrupt and finish from there. | ||
467 | */ | ||
468 | if (completion_done(priv->comp_dma)) | ||
469 | wmt_complete_data_request(priv); | ||
470 | } | ||
471 | } | ||
472 | |||
473 | writeb(status0, priv->sdmmc_base + SDMMC_STS0); | ||
474 | writeb(status1, priv->sdmmc_base + SDMMC_STS1); | ||
475 | writeb(status2, priv->sdmmc_base + SDMMC_STS2); | ||
476 | |||
477 | return IRQ_HANDLED; | ||
478 | } | ||
479 | |||
480 | static void wmt_reset_hardware(struct mmc_host *mmc) | ||
481 | { | ||
482 | struct wmt_mci_priv *priv; | ||
483 | u32 reg_tmp; | ||
484 | |||
485 | priv = mmc_priv(mmc); | ||
486 | |||
487 | /* reset controller */ | ||
488 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
489 | writeb(reg_tmp | BM_SOFT_RESET, priv->sdmmc_base + SDMMC_BUSMODE); | ||
490 | |||
491 | /* reset response FIFO */ | ||
492 | reg_tmp = readb(priv->sdmmc_base + SDMMC_CTLR); | ||
493 | writeb(reg_tmp | CTLR_FIFO_RESET, priv->sdmmc_base + SDMMC_CTLR); | ||
494 | |||
495 | /* enable GPI pin to detect card */ | ||
496 | writew(BLKL_INT_ENABLE | BLKL_GPI_CD, priv->sdmmc_base + SDMMC_BLKLEN); | ||
497 | |||
498 | /* clear interrupt status */ | ||
499 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS0); | ||
500 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS1); | ||
501 | |||
502 | /* setup interrupts */ | ||
503 | writeb(INT0_CD_INT_EN | INT0_DI_INT_EN, priv->sdmmc_base + | ||
504 | SDMMC_INTMASK0); | ||
505 | writeb(INT1_DATA_TOUT_INT_EN | INT1_CMD_RES_TRAN_DONE_INT_EN | | ||
506 | INT1_CMD_RES_TOUT_INT_EN, priv->sdmmc_base + SDMMC_INTMASK1); | ||
507 | |||
508 | /* set the DMA timeout */ | ||
509 | writew(8191, priv->sdmmc_base + SDMMC_DMATIMEOUT); | ||
510 | |||
511 | /* auto clock freezing enable */ | ||
512 | reg_tmp = readb(priv->sdmmc_base + SDMMC_STS2); | ||
513 | writeb(reg_tmp | STS2_DIS_FORCECLK, priv->sdmmc_base + SDMMC_STS2); | ||
514 | |||
515 | /* set a default clock speed of 400Khz */ | ||
516 | clk_set_rate(priv->clk_sdmmc, 400000); | ||
517 | } | ||
518 | |||
519 | static int wmt_dma_init(struct mmc_host *mmc) | ||
520 | { | ||
521 | struct wmt_mci_priv *priv; | ||
522 | |||
523 | priv = mmc_priv(mmc); | ||
524 | |||
525 | writel(DMA_GCR_SOFT_RESET, priv->sdmmc_base + SDDMA_GCR); | ||
526 | writel(DMA_GCR_DMA_EN, priv->sdmmc_base + SDDMA_GCR); | ||
527 | if ((readl(priv->sdmmc_base + SDDMA_GCR) & DMA_GCR_DMA_EN) != 0) | ||
528 | return 0; | ||
529 | else | ||
530 | return 1; | ||
531 | } | ||
532 | |||
533 | static void wmt_dma_init_descriptor(struct wmt_dma_descriptor *desc, | ||
534 | u16 req_count, u32 buffer_addr, u32 branch_addr, int end) | ||
535 | { | ||
536 | desc->flags = 0x40000000 | req_count; | ||
537 | if (end) | ||
538 | desc->flags |= 0x80000000; | ||
539 | desc->data_buffer_addr = buffer_addr; | ||
540 | desc->branch_addr = branch_addr; | ||
541 | } | ||
542 | |||
543 | static void wmt_dma_config(struct mmc_host *mmc, u32 descaddr, u8 dir) | ||
544 | { | ||
545 | struct wmt_mci_priv *priv; | ||
546 | u32 reg_tmp; | ||
547 | |||
548 | priv = mmc_priv(mmc); | ||
549 | |||
550 | /* Enable DMA Interrupts */ | ||
551 | writel(DMA_IER_INT_EN, priv->sdmmc_base + SDDMA_IER); | ||
552 | |||
553 | /* Write DMA Descriptor Pointer Register */ | ||
554 | writel(descaddr, priv->sdmmc_base + SDDMA_DESPR); | ||
555 | |||
556 | writel(0x00, priv->sdmmc_base + SDDMA_CCR); | ||
557 | |||
558 | if (dir == PDMA_WRITE) { | ||
559 | reg_tmp = readl(priv->sdmmc_base + SDDMA_CCR); | ||
560 | writel(reg_tmp & DMA_CCR_IF_TO_PERIPHERAL, priv->sdmmc_base + | ||
561 | SDDMA_CCR); | ||
562 | } else { | ||
563 | reg_tmp = readl(priv->sdmmc_base + SDDMA_CCR); | ||
564 | writel(reg_tmp | DMA_CCR_PERIPHERAL_TO_IF, priv->sdmmc_base + | ||
565 | SDDMA_CCR); | ||
566 | } | ||
567 | } | ||
568 | |||
569 | static void wmt_dma_start(struct wmt_mci_priv *priv) | ||
570 | { | ||
571 | u32 reg_tmp; | ||
572 | |||
573 | reg_tmp = readl(priv->sdmmc_base + SDDMA_CCR); | ||
574 | writel(reg_tmp | DMA_CCR_RUN, priv->sdmmc_base + SDDMA_CCR); | ||
575 | } | ||
576 | |||
577 | static void wmt_mci_request(struct mmc_host *mmc, struct mmc_request *req) | ||
578 | { | ||
579 | struct wmt_mci_priv *priv; | ||
580 | struct wmt_dma_descriptor *desc; | ||
581 | u8 command; | ||
582 | u8 cmdtype; | ||
583 | u32 arg; | ||
584 | u8 rsptype; | ||
585 | u32 reg_tmp; | ||
586 | |||
587 | struct scatterlist *sg; | ||
588 | int i; | ||
589 | int sg_cnt; | ||
590 | int offset; | ||
591 | u32 dma_address; | ||
592 | int desc_cnt; | ||
593 | |||
594 | priv = mmc_priv(mmc); | ||
595 | priv->req = req; | ||
596 | |||
597 | /* | ||
598 | * Use the cmd variable to pass a pointer to the resp[] structure | ||
599 | * This is required on multi-block requests to pass the pointer to the | ||
600 | * stop command | ||
601 | */ | ||
602 | priv->cmd = req->cmd; | ||
603 | |||
604 | command = req->cmd->opcode; | ||
605 | arg = req->cmd->arg; | ||
606 | rsptype = mmc_resp_type(req->cmd); | ||
607 | cmdtype = 0; | ||
608 | |||
609 | /* rsptype=7 only valid for SPI commands - should be =2 for SD */ | ||
610 | if (rsptype == 7) | ||
611 | rsptype = 2; | ||
612 | /* rsptype=21 is R1B, convert for controller */ | ||
613 | if (rsptype == 21) | ||
614 | rsptype = 9; | ||
615 | |||
616 | if (!req->data) { | ||
617 | wmt_mci_send_command(mmc, command, cmdtype, arg, rsptype); | ||
618 | wmt_mci_start_command(priv); | ||
619 | /* completion is now handled in the regular_isr() */ | ||
620 | } | ||
621 | if (req->data) { | ||
622 | priv->comp_cmd = &priv->cmdcomp; | ||
623 | init_completion(priv->comp_cmd); | ||
624 | |||
625 | wmt_dma_init(mmc); | ||
626 | |||
627 | /* set controller data length */ | ||
628 | reg_tmp = readw(priv->sdmmc_base + SDMMC_BLKLEN); | ||
629 | writew((reg_tmp & 0xF800) | (req->data->blksz - 1), | ||
630 | priv->sdmmc_base + SDMMC_BLKLEN); | ||
631 | |||
632 | /* set controller block count */ | ||
633 | writew(req->data->blocks, priv->sdmmc_base + SDMMC_BLKCNT); | ||
634 | |||
635 | desc = (struct wmt_dma_descriptor *)priv->dma_desc_buffer; | ||
636 | |||
637 | if (req->data->flags & MMC_DATA_WRITE) { | ||
638 | sg_cnt = dma_map_sg(mmc_dev(mmc), req->data->sg, | ||
639 | req->data->sg_len, DMA_TO_DEVICE); | ||
640 | cmdtype = 1; | ||
641 | if (req->data->blocks > 1) | ||
642 | cmdtype = 3; | ||
643 | } else { | ||
644 | sg_cnt = dma_map_sg(mmc_dev(mmc), req->data->sg, | ||
645 | req->data->sg_len, DMA_FROM_DEVICE); | ||
646 | cmdtype = 2; | ||
647 | if (req->data->blocks > 1) | ||
648 | cmdtype = 4; | ||
649 | } | ||
650 | |||
651 | dma_address = priv->dma_desc_device_addr + 16; | ||
652 | desc_cnt = 0; | ||
653 | |||
654 | for_each_sg(req->data->sg, sg, sg_cnt, i) { | ||
655 | offset = 0; | ||
656 | while (offset < sg_dma_len(sg)) { | ||
657 | wmt_dma_init_descriptor(desc, req->data->blksz, | ||
658 | sg_dma_address(sg)+offset, | ||
659 | dma_address, 0); | ||
660 | desc++; | ||
661 | desc_cnt++; | ||
662 | offset += req->data->blksz; | ||
663 | dma_address += 16; | ||
664 | if (desc_cnt == req->data->blocks) | ||
665 | break; | ||
666 | } | ||
667 | } | ||
668 | desc--; | ||
669 | desc->flags |= 0x80000000; | ||
670 | |||
671 | if (req->data->flags & MMC_DATA_WRITE) | ||
672 | wmt_dma_config(mmc, priv->dma_desc_device_addr, | ||
673 | PDMA_WRITE); | ||
674 | else | ||
675 | wmt_dma_config(mmc, priv->dma_desc_device_addr, | ||
676 | PDMA_READ); | ||
677 | |||
678 | wmt_mci_send_command(mmc, command, cmdtype, arg, rsptype); | ||
679 | |||
680 | priv->comp_dma = &priv->datacomp; | ||
681 | init_completion(priv->comp_dma); | ||
682 | |||
683 | wmt_dma_start(priv); | ||
684 | wmt_mci_start_command(priv); | ||
685 | } | ||
686 | } | ||
687 | |||
688 | static void wmt_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | ||
689 | { | ||
690 | struct wmt_mci_priv *priv; | ||
691 | u32 reg_tmp; | ||
692 | |||
693 | priv = mmc_priv(mmc); | ||
694 | |||
695 | if (ios->power_mode == MMC_POWER_UP) { | ||
696 | wmt_reset_hardware(mmc); | ||
697 | |||
698 | wmt_set_sd_power(priv, WMT_SD_POWER_ON); | ||
699 | } | ||
700 | if (ios->power_mode == MMC_POWER_OFF) | ||
701 | wmt_set_sd_power(priv, WMT_SD_POWER_OFF); | ||
702 | |||
703 | if (ios->clock != 0) | ||
704 | clk_set_rate(priv->clk_sdmmc, ios->clock); | ||
705 | |||
706 | switch (ios->bus_width) { | ||
707 | case MMC_BUS_WIDTH_8: | ||
708 | reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL); | ||
709 | writeb(reg_tmp | 0x04, priv->sdmmc_base + SDMMC_EXTCTRL); | ||
710 | break; | ||
711 | case MMC_BUS_WIDTH_4: | ||
712 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
713 | writeb(reg_tmp | BM_FOURBIT_MODE, priv->sdmmc_base + | ||
714 | SDMMC_BUSMODE); | ||
715 | |||
716 | reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL); | ||
717 | writeb(reg_tmp & 0xFB, priv->sdmmc_base + SDMMC_EXTCTRL); | ||
718 | break; | ||
719 | case MMC_BUS_WIDTH_1: | ||
720 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
721 | writeb(reg_tmp & BM_ONEBIT_MASK, priv->sdmmc_base + | ||
722 | SDMMC_BUSMODE); | ||
723 | |||
724 | reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL); | ||
725 | writeb(reg_tmp & 0xFB, priv->sdmmc_base + SDMMC_EXTCTRL); | ||
726 | break; | ||
727 | } | ||
728 | } | ||
729 | |||
730 | static int wmt_mci_get_ro(struct mmc_host *mmc) | ||
731 | { | ||
732 | struct wmt_mci_priv *priv = mmc_priv(mmc); | ||
733 | |||
734 | return !(readb(priv->sdmmc_base + SDMMC_STS0) & STS0_WRITE_PROTECT); | ||
735 | } | ||
736 | |||
737 | static int wmt_mci_get_cd(struct mmc_host *mmc) | ||
738 | { | ||
739 | struct wmt_mci_priv *priv = mmc_priv(mmc); | ||
740 | u32 cd = (readb(priv->sdmmc_base + SDMMC_STS0) & STS0_CD_GPI) >> 3; | ||
741 | |||
742 | return !(cd ^ priv->cd_inverted); | ||
743 | } | ||
744 | |||
745 | static struct mmc_host_ops wmt_mci_ops = { | ||
746 | .request = wmt_mci_request, | ||
747 | .set_ios = wmt_mci_set_ios, | ||
748 | .get_ro = wmt_mci_get_ro, | ||
749 | .get_cd = wmt_mci_get_cd, | ||
750 | }; | ||
751 | |||
752 | /* Controller capabilities */ | ||
753 | static struct wmt_mci_caps wm8505_caps = { | ||
754 | .f_min = 390425, | ||
755 | .f_max = 50000000, | ||
756 | .ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34, | ||
757 | .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | | ||
758 | MMC_CAP_SD_HIGHSPEED, | ||
759 | .max_seg_size = 65024, | ||
760 | .max_segs = 128, | ||
761 | .max_blk_size = 2048, | ||
762 | }; | ||
763 | |||
764 | static struct of_device_id wmt_mci_dt_ids[] = { | ||
765 | { .compatible = "wm,wm8505-sdhc", .data = &wm8505_caps }, | ||
766 | { /* Sentinel */ }, | ||
767 | }; | ||
768 | |||
769 | static int __devinit wmt_mci_probe(struct platform_device *pdev) | ||
770 | { | ||
771 | struct mmc_host *mmc; | ||
772 | struct wmt_mci_priv *priv; | ||
773 | struct device_node *np = pdev->dev.of_node; | ||
774 | const struct of_device_id *of_id = | ||
775 | of_match_device(wmt_mci_dt_ids, &pdev->dev); | ||
776 | const struct wmt_mci_caps *wmt_caps = of_id->data; | ||
777 | int ret; | ||
778 | int regular_irq, dma_irq; | ||
779 | |||
780 | if (!of_id || !of_id->data) { | ||
781 | dev_err(&pdev->dev, "Controller capabilities data missing\n"); | ||
782 | return -EFAULT; | ||
783 | } | ||
784 | |||
785 | if (!np) { | ||
786 | dev_err(&pdev->dev, "Missing SDMMC description in devicetree\n"); | ||
787 | return -EFAULT; | ||
788 | } | ||
789 | |||
790 | regular_irq = irq_of_parse_and_map(np, 0); | ||
791 | dma_irq = irq_of_parse_and_map(np, 1); | ||
792 | |||
793 | if (!regular_irq || !dma_irq) { | ||
794 | dev_err(&pdev->dev, "Getting IRQs failed!\n"); | ||
795 | ret = -ENXIO; | ||
796 | goto fail1; | ||
797 | } | ||
798 | |||
799 | mmc = mmc_alloc_host(sizeof(struct wmt_mci_priv), &pdev->dev); | ||
800 | if (!mmc) { | ||
801 | dev_err(&pdev->dev, "Failed to allocate mmc_host\n"); | ||
802 | ret = -ENOMEM; | ||
803 | goto fail1; | ||
804 | } | ||
805 | |||
806 | mmc->ops = &wmt_mci_ops; | ||
807 | mmc->f_min = wmt_caps->f_min; | ||
808 | mmc->f_max = wmt_caps->f_max; | ||
809 | mmc->ocr_avail = wmt_caps->ocr_avail; | ||
810 | mmc->caps = wmt_caps->caps; | ||
811 | |||
812 | mmc->max_seg_size = wmt_caps->max_seg_size; | ||
813 | mmc->max_segs = wmt_caps->max_segs; | ||
814 | mmc->max_blk_size = wmt_caps->max_blk_size; | ||
815 | |||
816 | mmc->max_req_size = (16*512*mmc->max_segs); | ||
817 | mmc->max_blk_count = mmc->max_req_size / 512; | ||
818 | |||
819 | priv = mmc_priv(mmc); | ||
820 | priv->mmc = mmc; | ||
821 | priv->dev = &pdev->dev; | ||
822 | |||
823 | priv->power_inverted = 0; | ||
824 | priv->cd_inverted = 0; | ||
825 | |||
826 | if (of_get_property(np, "sdon-inverted", NULL)) | ||
827 | priv->power_inverted = 1; | ||
828 | if (of_get_property(np, "cd-inverted", NULL)) | ||
829 | priv->cd_inverted = 1; | ||
830 | |||
831 | priv->sdmmc_base = of_iomap(np, 0); | ||
832 | if (!priv->sdmmc_base) { | ||
833 | dev_err(&pdev->dev, "Failed to map IO space\n"); | ||
834 | ret = -ENOMEM; | ||
835 | goto fail2; | ||
836 | } | ||
837 | |||
838 | priv->irq_regular = regular_irq; | ||
839 | priv->irq_dma = dma_irq; | ||
840 | |||
841 | ret = request_irq(regular_irq, wmt_mci_regular_isr, 0, "sdmmc", priv); | ||
842 | if (ret) { | ||
843 | dev_err(&pdev->dev, "Register regular IRQ fail\n"); | ||
844 | goto fail3; | ||
845 | } | ||
846 | |||
847 | ret = request_irq(dma_irq, wmt_mci_dma_isr, 32, "sdmmc", priv); | ||
848 | if (ret) { | ||
849 | dev_err(&pdev->dev, "Register DMA IRQ fail\n"); | ||
850 | goto fail4; | ||
851 | } | ||
852 | |||
853 | /* alloc some DMA buffers for descriptors/transfers */ | ||
854 | priv->dma_desc_buffer = dma_alloc_coherent(&pdev->dev, | ||
855 | mmc->max_blk_count * 16, | ||
856 | &priv->dma_desc_device_addr, | ||
857 | 208); | ||
858 | if (!priv->dma_desc_buffer) { | ||
859 | dev_err(&pdev->dev, "DMA alloc fail\n"); | ||
860 | ret = -EPERM; | ||
861 | goto fail5; | ||
862 | } | ||
863 | |||
864 | platform_set_drvdata(pdev, mmc); | ||
865 | |||
866 | priv->clk_sdmmc = of_clk_get(np, 0); | ||
867 | if (IS_ERR(priv->clk_sdmmc)) { | ||
868 | dev_err(&pdev->dev, "Error getting clock\n"); | ||
869 | ret = PTR_ERR(priv->clk_sdmmc); | ||
870 | goto fail5; | ||
871 | } | ||
872 | |||
873 | clk_prepare_enable(priv->clk_sdmmc); | ||
874 | |||
875 | /* configure the controller to a known 'ready' state */ | ||
876 | wmt_reset_hardware(mmc); | ||
877 | |||
878 | mmc_add_host(mmc); | ||
879 | |||
880 | dev_info(&pdev->dev, "WMT SDHC Controller initialized\n"); | ||
881 | |||
882 | return 0; | ||
883 | fail5: | ||
884 | free_irq(dma_irq, priv); | ||
885 | fail4: | ||
886 | free_irq(regular_irq, priv); | ||
887 | fail3: | ||
888 | iounmap(priv->sdmmc_base); | ||
889 | fail2: | ||
890 | mmc_free_host(mmc); | ||
891 | fail1: | ||
892 | return ret; | ||
893 | } | ||
894 | |||
895 | static int __devexit wmt_mci_remove(struct platform_device *pdev) | ||
896 | { | ||
897 | struct mmc_host *mmc; | ||
898 | struct wmt_mci_priv *priv; | ||
899 | struct resource *res; | ||
900 | u32 reg_tmp; | ||
901 | |||
902 | mmc = platform_get_drvdata(pdev); | ||
903 | priv = mmc_priv(mmc); | ||
904 | |||
905 | /* reset SD controller */ | ||
906 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
907 | writel(reg_tmp | BM_SOFT_RESET, priv->sdmmc_base + SDMMC_BUSMODE); | ||
908 | reg_tmp = readw(priv->sdmmc_base + SDMMC_BLKLEN); | ||
909 | writew(reg_tmp & ~(0xA000), priv->sdmmc_base + SDMMC_BLKLEN); | ||
910 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS0); | ||
911 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS1); | ||
912 | |||
913 | /* release the dma buffers */ | ||
914 | dma_free_coherent(&pdev->dev, priv->mmc->max_blk_count * 16, | ||
915 | priv->dma_desc_buffer, priv->dma_desc_device_addr); | ||
916 | |||
917 | mmc_remove_host(mmc); | ||
918 | |||
919 | free_irq(priv->irq_regular, priv); | ||
920 | free_irq(priv->irq_dma, priv); | ||
921 | |||
922 | iounmap(priv->sdmmc_base); | ||
923 | |||
924 | clk_disable_unprepare(priv->clk_sdmmc); | ||
925 | clk_put(priv->clk_sdmmc); | ||
926 | |||
927 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
928 | release_mem_region(res->start, res->end - res->start + 1); | ||
929 | |||
930 | mmc_free_host(mmc); | ||
931 | |||
932 | platform_set_drvdata(pdev, NULL); | ||
933 | |||
934 | dev_info(&pdev->dev, "WMT MCI device removed\n"); | ||
935 | |||
936 | return 0; | ||
937 | } | ||
938 | |||
939 | #ifdef CONFIG_PM | ||
940 | static int wmt_mci_suspend(struct device *dev) | ||
941 | { | ||
942 | u32 reg_tmp; | ||
943 | struct platform_device *pdev = to_platform_device(dev); | ||
944 | struct mmc_host *mmc = platform_get_drvdata(pdev); | ||
945 | struct wmt_mci_priv *priv; | ||
946 | int ret; | ||
947 | |||
948 | if (!mmc) | ||
949 | return 0; | ||
950 | |||
951 | priv = mmc_priv(mmc); | ||
952 | ret = mmc_suspend_host(mmc); | ||
953 | |||
954 | if (!ret) { | ||
955 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
956 | writeb(reg_tmp | BM_SOFT_RESET, priv->sdmmc_base + | ||
957 | SDMMC_BUSMODE); | ||
958 | |||
959 | reg_tmp = readw(priv->sdmmc_base + SDMMC_BLKLEN); | ||
960 | writew(reg_tmp & 0x5FFF, priv->sdmmc_base + SDMMC_BLKLEN); | ||
961 | |||
962 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS0); | ||
963 | writeb(0xFF, priv->sdmmc_base + SDMMC_STS1); | ||
964 | |||
965 | clk_disable(priv->clk_sdmmc); | ||
966 | } | ||
967 | return ret; | ||
968 | } | ||
969 | |||
970 | static int wmt_mci_resume(struct device *dev) | ||
971 | { | ||
972 | u32 reg_tmp; | ||
973 | struct platform_device *pdev = to_platform_device(dev); | ||
974 | struct mmc_host *mmc = platform_get_drvdata(pdev); | ||
975 | struct wmt_mci_priv *priv; | ||
976 | int ret = 0; | ||
977 | |||
978 | if (mmc) { | ||
979 | priv = mmc_priv(mmc); | ||
980 | clk_enable(priv->clk_sdmmc); | ||
981 | |||
982 | reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); | ||
983 | writeb(reg_tmp | BM_SOFT_RESET, priv->sdmmc_base + | ||
984 | SDMMC_BUSMODE); | ||
985 | |||
986 | reg_tmp = readw(priv->sdmmc_base + SDMMC_BLKLEN); | ||
987 | writew(reg_tmp | (BLKL_GPI_CD | BLKL_INT_ENABLE), | ||
988 | priv->sdmmc_base + SDMMC_BLKLEN); | ||
989 | |||
990 | reg_tmp = readb(priv->sdmmc_base + SDMMC_INTMASK0); | ||
991 | writeb(reg_tmp | INT0_DI_INT_EN, priv->sdmmc_base + | ||
992 | SDMMC_INTMASK0); | ||
993 | |||
994 | ret = mmc_resume_host(mmc); | ||
995 | } | ||
996 | |||
997 | return ret; | ||
998 | } | ||
999 | |||
1000 | static const struct dev_pm_ops wmt_mci_pm = { | ||
1001 | .suspend = wmt_mci_suspend, | ||
1002 | .resume = wmt_mci_resume, | ||
1003 | }; | ||
1004 | |||
1005 | #define wmt_mci_pm_ops (&wmt_mci_pm) | ||
1006 | |||
1007 | #else /* !CONFIG_PM */ | ||
1008 | |||
1009 | #define wmt_mci_pm_ops NULL | ||
1010 | |||
1011 | #endif | ||
1012 | |||
1013 | static struct platform_driver wmt_mci_driver = { | ||
1014 | .probe = wmt_mci_probe, | ||
1015 | .remove = __exit_p(wmt_mci_remove), | ||
1016 | .driver = { | ||
1017 | .name = DRIVER_NAME, | ||
1018 | .owner = THIS_MODULE, | ||
1019 | .pm = wmt_mci_pm_ops, | ||
1020 | .of_match_table = wmt_mci_dt_ids, | ||
1021 | }, | ||
1022 | }; | ||
1023 | |||
1024 | module_platform_driver(wmt_mci_driver); | ||
1025 | |||
1026 | MODULE_DESCRIPTION("Wondermedia MMC/SD Driver"); | ||
1027 | MODULE_AUTHOR("Tony Prisk"); | ||
1028 | MODULE_LICENSE("GPL v2"); | ||
1029 | MODULE_DEVICE_TABLE(of, wmt_mci_dt_ids); | ||
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index 8f52fc858e48..5a5cd2ace4a6 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c | |||
@@ -240,7 +240,7 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength) | |||
240 | 240 | ||
241 | if (*(szlength) != '+') { | 241 | if (*(szlength) != '+') { |
242 | devlength = simple_strtoul(szlength, &buffer, 0); | 242 | devlength = simple_strtoul(szlength, &buffer, 0); |
243 | devlength = handle_unit(devlength, buffer) - devstart; | 243 | devlength = handle_unit(devlength, buffer); |
244 | if (devlength < devstart) | 244 | if (devlength < devstart) |
245 | goto err_out; | 245 | goto err_out; |
246 | 246 | ||
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 374c46dff7dd..ec794a72975d 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -1077,7 +1077,8 @@ EXPORT_SYMBOL_GPL(mtd_writev); | |||
1077 | * until the request succeeds or until the allocation size falls below | 1077 | * until the request succeeds or until the allocation size falls below |
1078 | * the system page size. This attempts to make sure it does not adversely | 1078 | * the system page size. This attempts to make sure it does not adversely |
1079 | * impact system performance, so when allocating more than one page, we | 1079 | * impact system performance, so when allocating more than one page, we |
1080 | * ask the memory allocator to avoid re-trying. | 1080 | * ask the memory allocator to avoid re-trying, swapping, writing back |
1081 | * or performing I/O. | ||
1081 | * | 1082 | * |
1082 | * Note, this function also makes sure that the allocated buffer is aligned to | 1083 | * Note, this function also makes sure that the allocated buffer is aligned to |
1083 | * the MTD device's min. I/O unit, i.e. the "mtd->writesize" value. | 1084 | * the MTD device's min. I/O unit, i.e. the "mtd->writesize" value. |
@@ -1091,7 +1092,8 @@ EXPORT_SYMBOL_GPL(mtd_writev); | |||
1091 | */ | 1092 | */ |
1092 | void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size) | 1093 | void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size) |
1093 | { | 1094 | { |
1094 | gfp_t flags = __GFP_NOWARN | __GFP_WAIT | __GFP_NORETRY; | 1095 | gfp_t flags = __GFP_NOWARN | __GFP_WAIT | |
1096 | __GFP_NORETRY | __GFP_NO_KSWAPD; | ||
1095 | size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE); | 1097 | size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE); |
1096 | void *kbuf; | 1098 | void *kbuf; |
1097 | 1099 | ||
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index ec6841d8e956..1a03b7f673ce 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -2983,13 +2983,15 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, | |||
2983 | /* | 2983 | /* |
2984 | * Field definitions are in the following datasheets: | 2984 | * Field definitions are in the following datasheets: |
2985 | * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32) | 2985 | * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32) |
2986 | * New style (6 byte ID): Samsung K9GAG08U0F (p.44) | 2986 | * New Samsung (6 byte ID): Samsung K9GAG08U0F (p.44) |
2987 | * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22) | 2987 | * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22) |
2988 | * | 2988 | * |
2989 | * Check for ID length, cell type, and Hynix/Samsung ID to decide what | 2989 | * Check for ID length, non-zero 6th byte, cell type, and Hynix/Samsung |
2990 | * to do. | 2990 | * ID to decide what to do. |
2991 | */ | 2991 | */ |
2992 | if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG) { | 2992 | if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG && |
2993 | (chip->cellinfo & NAND_CI_CELLTYPE_MSK) && | ||
2994 | id_data[5] != 0x00) { | ||
2993 | /* Calc pagesize */ | 2995 | /* Calc pagesize */ |
2994 | mtd->writesize = 2048 << (extid & 0x03); | 2996 | mtd->writesize = 2048 << (extid & 0x03); |
2995 | extid >>= 2; | 2997 | extid >>= 2; |
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 64be8f0848b0..d9127e2ed808 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c | |||
@@ -121,7 +121,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master, | |||
121 | nr_parts = plen / sizeof(part[0]); | 121 | nr_parts = plen / sizeof(part[0]); |
122 | 122 | ||
123 | *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL); | 123 | *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL); |
124 | if (!pparts) | 124 | if (!*pparts) |
125 | return -ENOMEM; | 125 | return -ENOMEM; |
126 | 126 | ||
127 | names = of_get_property(dp, "partition-names", &plen); | 127 | names = of_get_property(dp, "partition-names", &plen); |
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 7153e0d27101..b3f41f200622 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -3694,7 +3694,7 @@ static int flexonenand_check_blocks_erased(struct mtd_info *mtd, int start, int | |||
3694 | * flexonenand_set_boundary - Writes the SLC boundary | 3694 | * flexonenand_set_boundary - Writes the SLC boundary |
3695 | * @param mtd - mtd info structure | 3695 | * @param mtd - mtd info structure |
3696 | */ | 3696 | */ |
3697 | int flexonenand_set_boundary(struct mtd_info *mtd, int die, | 3697 | static int flexonenand_set_boundary(struct mtd_info *mtd, int die, |
3698 | int boundary, int lock) | 3698 | int boundary, int lock) |
3699 | { | 3699 | { |
3700 | struct onenand_chip *this = mtd->priv; | 3700 | struct onenand_chip *this = mtd->priv; |
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index da7b44998b40..2144f611196e 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c | |||
@@ -498,7 +498,7 @@ out: | |||
498 | * @ubi: UBI device description object | 498 | * @ubi: UBI device description object |
499 | * | 499 | * |
500 | * This function returns a physical eraseblock in case of success and a | 500 | * This function returns a physical eraseblock in case of success and a |
501 | * negative error code in case of failure. Might sleep. | 501 | * negative error code in case of failure. |
502 | */ | 502 | */ |
503 | static int __wl_get_peb(struct ubi_device *ubi) | 503 | static int __wl_get_peb(struct ubi_device *ubi) |
504 | { | 504 | { |
@@ -540,13 +540,6 @@ retry: | |||
540 | * ubi_wl_get_peb() after removing e from the pool. */ | 540 | * ubi_wl_get_peb() after removing e from the pool. */ |
541 | prot_queue_add(ubi, e); | 541 | prot_queue_add(ubi, e); |
542 | #endif | 542 | #endif |
543 | err = ubi_self_check_all_ff(ubi, e->pnum, ubi->vid_hdr_aloffset, | ||
544 | ubi->peb_size - ubi->vid_hdr_aloffset); | ||
545 | if (err) { | ||
546 | ubi_err("new PEB %d does not contain all 0xFF bytes", e->pnum); | ||
547 | return err; | ||
548 | } | ||
549 | |||
550 | return e->pnum; | 543 | return e->pnum; |
551 | } | 544 | } |
552 | 545 | ||
@@ -679,17 +672,30 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi) | |||
679 | #else | 672 | #else |
680 | static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi) | 673 | static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi) |
681 | { | 674 | { |
682 | return find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF); | 675 | struct ubi_wl_entry *e; |
676 | |||
677 | e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF); | ||
678 | self_check_in_wl_tree(ubi, e, &ubi->free); | ||
679 | rb_erase(&e->u.rb, &ubi->free); | ||
680 | |||
681 | return e; | ||
683 | } | 682 | } |
684 | 683 | ||
685 | int ubi_wl_get_peb(struct ubi_device *ubi) | 684 | int ubi_wl_get_peb(struct ubi_device *ubi) |
686 | { | 685 | { |
687 | int peb; | 686 | int peb, err; |
688 | 687 | ||
689 | spin_lock(&ubi->wl_lock); | 688 | spin_lock(&ubi->wl_lock); |
690 | peb = __wl_get_peb(ubi); | 689 | peb = __wl_get_peb(ubi); |
691 | spin_unlock(&ubi->wl_lock); | 690 | spin_unlock(&ubi->wl_lock); |
692 | 691 | ||
692 | err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset, | ||
693 | ubi->peb_size - ubi->vid_hdr_aloffset); | ||
694 | if (err) { | ||
695 | ubi_err("new PEB %d does not contain all 0xFF bytes", peb); | ||
696 | return err; | ||
697 | } | ||
698 | |||
693 | return peb; | 699 | return peb; |
694 | } | 700 | } |
695 | #endif | 701 | #endif |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b2530b002125..a7d47350ea4b 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -1379,6 +1379,8 @@ static void bond_compute_features(struct bonding *bond) | |||
1379 | struct net_device *bond_dev = bond->dev; | 1379 | struct net_device *bond_dev = bond->dev; |
1380 | netdev_features_t vlan_features = BOND_VLAN_FEATURES; | 1380 | netdev_features_t vlan_features = BOND_VLAN_FEATURES; |
1381 | unsigned short max_hard_header_len = ETH_HLEN; | 1381 | unsigned short max_hard_header_len = ETH_HLEN; |
1382 | unsigned int gso_max_size = GSO_MAX_SIZE; | ||
1383 | u16 gso_max_segs = GSO_MAX_SEGS; | ||
1382 | int i; | 1384 | int i; |
1383 | unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE; | 1385 | unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE; |
1384 | 1386 | ||
@@ -1394,11 +1396,16 @@ static void bond_compute_features(struct bonding *bond) | |||
1394 | dst_release_flag &= slave->dev->priv_flags; | 1396 | dst_release_flag &= slave->dev->priv_flags; |
1395 | if (slave->dev->hard_header_len > max_hard_header_len) | 1397 | if (slave->dev->hard_header_len > max_hard_header_len) |
1396 | max_hard_header_len = slave->dev->hard_header_len; | 1398 | max_hard_header_len = slave->dev->hard_header_len; |
1399 | |||
1400 | gso_max_size = min(gso_max_size, slave->dev->gso_max_size); | ||
1401 | gso_max_segs = min(gso_max_segs, slave->dev->gso_max_segs); | ||
1397 | } | 1402 | } |
1398 | 1403 | ||
1399 | done: | 1404 | done: |
1400 | bond_dev->vlan_features = vlan_features; | 1405 | bond_dev->vlan_features = vlan_features; |
1401 | bond_dev->hard_header_len = max_hard_header_len; | 1406 | bond_dev->hard_header_len = max_hard_header_len; |
1407 | bond_dev->gso_max_segs = gso_max_segs; | ||
1408 | netif_set_gso_max_size(bond_dev, gso_max_size); | ||
1402 | 1409 | ||
1403 | flags = bond_dev->priv_flags & ~IFF_XMIT_DST_RELEASE; | 1410 | flags = bond_dev->priv_flags & ~IFF_XMIT_DST_RELEASE; |
1404 | bond_dev->priv_flags = flags | dst_release_flag; | 1411 | bond_dev->priv_flags = flags | dst_release_flag; |
@@ -3452,6 +3459,28 @@ static int bond_xmit_hash_policy_l34(struct sk_buff *skb, int count) | |||
3452 | 3459 | ||
3453 | /*-------------------------- Device entry points ----------------------------*/ | 3460 | /*-------------------------- Device entry points ----------------------------*/ |
3454 | 3461 | ||
3462 | static void bond_work_init_all(struct bonding *bond) | ||
3463 | { | ||
3464 | INIT_DELAYED_WORK(&bond->mcast_work, | ||
3465 | bond_resend_igmp_join_requests_delayed); | ||
3466 | INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); | ||
3467 | INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); | ||
3468 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) | ||
3469 | INIT_DELAYED_WORK(&bond->arp_work, bond_activebackup_arp_mon); | ||
3470 | else | ||
3471 | INIT_DELAYED_WORK(&bond->arp_work, bond_loadbalance_arp_mon); | ||
3472 | INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); | ||
3473 | } | ||
3474 | |||
3475 | static void bond_work_cancel_all(struct bonding *bond) | ||
3476 | { | ||
3477 | cancel_delayed_work_sync(&bond->mii_work); | ||
3478 | cancel_delayed_work_sync(&bond->arp_work); | ||
3479 | cancel_delayed_work_sync(&bond->alb_work); | ||
3480 | cancel_delayed_work_sync(&bond->ad_work); | ||
3481 | cancel_delayed_work_sync(&bond->mcast_work); | ||
3482 | } | ||
3483 | |||
3455 | static int bond_open(struct net_device *bond_dev) | 3484 | static int bond_open(struct net_device *bond_dev) |
3456 | { | 3485 | { |
3457 | struct bonding *bond = netdev_priv(bond_dev); | 3486 | struct bonding *bond = netdev_priv(bond_dev); |
@@ -3474,41 +3503,27 @@ static int bond_open(struct net_device *bond_dev) | |||
3474 | } | 3503 | } |
3475 | read_unlock(&bond->lock); | 3504 | read_unlock(&bond->lock); |
3476 | 3505 | ||
3477 | INIT_DELAYED_WORK(&bond->mcast_work, bond_resend_igmp_join_requests_delayed); | 3506 | bond_work_init_all(bond); |
3478 | 3507 | ||
3479 | if (bond_is_lb(bond)) { | 3508 | if (bond_is_lb(bond)) { |
3480 | /* bond_alb_initialize must be called before the timer | 3509 | /* bond_alb_initialize must be called before the timer |
3481 | * is started. | 3510 | * is started. |
3482 | */ | 3511 | */ |
3483 | if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB))) { | 3512 | if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB))) |
3484 | /* something went wrong - fail the open operation */ | ||
3485 | return -ENOMEM; | 3513 | return -ENOMEM; |
3486 | } | ||
3487 | |||
3488 | INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); | ||
3489 | queue_delayed_work(bond->wq, &bond->alb_work, 0); | 3514 | queue_delayed_work(bond->wq, &bond->alb_work, 0); |
3490 | } | 3515 | } |
3491 | 3516 | ||
3492 | if (bond->params.miimon) { /* link check interval, in milliseconds. */ | 3517 | if (bond->params.miimon) /* link check interval, in milliseconds. */ |
3493 | INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); | ||
3494 | queue_delayed_work(bond->wq, &bond->mii_work, 0); | 3518 | queue_delayed_work(bond->wq, &bond->mii_work, 0); |
3495 | } | ||
3496 | 3519 | ||
3497 | if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ | 3520 | if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ |
3498 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) | ||
3499 | INIT_DELAYED_WORK(&bond->arp_work, | ||
3500 | bond_activebackup_arp_mon); | ||
3501 | else | ||
3502 | INIT_DELAYED_WORK(&bond->arp_work, | ||
3503 | bond_loadbalance_arp_mon); | ||
3504 | |||
3505 | queue_delayed_work(bond->wq, &bond->arp_work, 0); | 3521 | queue_delayed_work(bond->wq, &bond->arp_work, 0); |
3506 | if (bond->params.arp_validate) | 3522 | if (bond->params.arp_validate) |
3507 | bond->recv_probe = bond_arp_rcv; | 3523 | bond->recv_probe = bond_arp_rcv; |
3508 | } | 3524 | } |
3509 | 3525 | ||
3510 | if (bond->params.mode == BOND_MODE_8023AD) { | 3526 | if (bond->params.mode == BOND_MODE_8023AD) { |
3511 | INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); | ||
3512 | queue_delayed_work(bond->wq, &bond->ad_work, 0); | 3527 | queue_delayed_work(bond->wq, &bond->ad_work, 0); |
3513 | /* register to receive LACPDUs */ | 3528 | /* register to receive LACPDUs */ |
3514 | bond->recv_probe = bond_3ad_lacpdu_recv; | 3529 | bond->recv_probe = bond_3ad_lacpdu_recv; |
@@ -3523,34 +3538,10 @@ static int bond_close(struct net_device *bond_dev) | |||
3523 | struct bonding *bond = netdev_priv(bond_dev); | 3538 | struct bonding *bond = netdev_priv(bond_dev); |
3524 | 3539 | ||
3525 | write_lock_bh(&bond->lock); | 3540 | write_lock_bh(&bond->lock); |
3526 | |||
3527 | bond->send_peer_notif = 0; | 3541 | bond->send_peer_notif = 0; |
3528 | |||
3529 | write_unlock_bh(&bond->lock); | 3542 | write_unlock_bh(&bond->lock); |
3530 | 3543 | ||
3531 | if (bond->params.miimon) { /* link check interval, in milliseconds. */ | 3544 | bond_work_cancel_all(bond); |
3532 | cancel_delayed_work_sync(&bond->mii_work); | ||
3533 | } | ||
3534 | |||
3535 | if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ | ||
3536 | cancel_delayed_work_sync(&bond->arp_work); | ||
3537 | } | ||
3538 | |||
3539 | switch (bond->params.mode) { | ||
3540 | case BOND_MODE_8023AD: | ||
3541 | cancel_delayed_work_sync(&bond->ad_work); | ||
3542 | break; | ||
3543 | case BOND_MODE_TLB: | ||
3544 | case BOND_MODE_ALB: | ||
3545 | cancel_delayed_work_sync(&bond->alb_work); | ||
3546 | break; | ||
3547 | default: | ||
3548 | break; | ||
3549 | } | ||
3550 | |||
3551 | if (delayed_work_pending(&bond->mcast_work)) | ||
3552 | cancel_delayed_work_sync(&bond->mcast_work); | ||
3553 | |||
3554 | if (bond_is_lb(bond)) { | 3545 | if (bond_is_lb(bond)) { |
3555 | /* Must be called only after all | 3546 | /* Must be called only after all |
3556 | * slaves have been released | 3547 | * slaves have been released |
@@ -4429,26 +4420,6 @@ static void bond_setup(struct net_device *bond_dev) | |||
4429 | bond_dev->features |= bond_dev->hw_features; | 4420 | bond_dev->features |= bond_dev->hw_features; |
4430 | } | 4421 | } |
4431 | 4422 | ||
4432 | static void bond_work_cancel_all(struct bonding *bond) | ||
4433 | { | ||
4434 | if (bond->params.miimon && delayed_work_pending(&bond->mii_work)) | ||
4435 | cancel_delayed_work_sync(&bond->mii_work); | ||
4436 | |||
4437 | if (bond->params.arp_interval && delayed_work_pending(&bond->arp_work)) | ||
4438 | cancel_delayed_work_sync(&bond->arp_work); | ||
4439 | |||
4440 | if (bond->params.mode == BOND_MODE_ALB && | ||
4441 | delayed_work_pending(&bond->alb_work)) | ||
4442 | cancel_delayed_work_sync(&bond->alb_work); | ||
4443 | |||
4444 | if (bond->params.mode == BOND_MODE_8023AD && | ||
4445 | delayed_work_pending(&bond->ad_work)) | ||
4446 | cancel_delayed_work_sync(&bond->ad_work); | ||
4447 | |||
4448 | if (delayed_work_pending(&bond->mcast_work)) | ||
4449 | cancel_delayed_work_sync(&bond->mcast_work); | ||
4450 | } | ||
4451 | |||
4452 | /* | 4423 | /* |
4453 | * Destroy a bonding device. | 4424 | * Destroy a bonding device. |
4454 | * Must be under rtnl_lock when this function is called. | 4425 | * Must be under rtnl_lock when this function is called. |
@@ -4699,12 +4670,13 @@ static int bond_check_params(struct bond_params *params) | |||
4699 | arp_ip_count++) { | 4670 | arp_ip_count++) { |
4700 | /* not complete check, but should be good enough to | 4671 | /* not complete check, but should be good enough to |
4701 | catch mistakes */ | 4672 | catch mistakes */ |
4702 | if (!isdigit(arp_ip_target[arp_ip_count][0])) { | 4673 | __be32 ip = in_aton(arp_ip_target[arp_ip_count]); |
4674 | if (!isdigit(arp_ip_target[arp_ip_count][0]) || | ||
4675 | ip == 0 || ip == htonl(INADDR_BROADCAST)) { | ||
4703 | pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", | 4676 | pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", |
4704 | arp_ip_target[arp_ip_count]); | 4677 | arp_ip_target[arp_ip_count]); |
4705 | arp_interval = 0; | 4678 | arp_interval = 0; |
4706 | } else { | 4679 | } else { |
4707 | __be32 ip = in_aton(arp_ip_target[arp_ip_count]); | ||
4708 | arp_target[arp_ip_count] = ip; | 4680 | arp_target[arp_ip_count] = ip; |
4709 | } | 4681 | } |
4710 | } | 4682 | } |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index ef8d2a080d17..1877ed7ca086 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -513,6 +513,8 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
513 | int new_value, ret = count; | 513 | int new_value, ret = count; |
514 | struct bonding *bond = to_bond(d); | 514 | struct bonding *bond = to_bond(d); |
515 | 515 | ||
516 | if (!rtnl_trylock()) | ||
517 | return restart_syscall(); | ||
516 | if (sscanf(buf, "%d", &new_value) != 1) { | 518 | if (sscanf(buf, "%d", &new_value) != 1) { |
517 | pr_err("%s: no arp_interval value specified.\n", | 519 | pr_err("%s: no arp_interval value specified.\n", |
518 | bond->dev->name); | 520 | bond->dev->name); |
@@ -539,10 +541,6 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
539 | pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", | 541 | pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", |
540 | bond->dev->name, bond->dev->name); | 542 | bond->dev->name, bond->dev->name); |
541 | bond->params.miimon = 0; | 543 | bond->params.miimon = 0; |
542 | if (delayed_work_pending(&bond->mii_work)) { | ||
543 | cancel_delayed_work(&bond->mii_work); | ||
544 | flush_workqueue(bond->wq); | ||
545 | } | ||
546 | } | 544 | } |
547 | if (!bond->params.arp_targets[0]) { | 545 | if (!bond->params.arp_targets[0]) { |
548 | pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n", | 546 | pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n", |
@@ -554,19 +552,12 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
554 | * timer will get fired off when the open function | 552 | * timer will get fired off when the open function |
555 | * is called. | 553 | * is called. |
556 | */ | 554 | */ |
557 | if (!delayed_work_pending(&bond->arp_work)) { | 555 | cancel_delayed_work_sync(&bond->mii_work); |
558 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) | 556 | queue_delayed_work(bond->wq, &bond->arp_work, 0); |
559 | INIT_DELAYED_WORK(&bond->arp_work, | ||
560 | bond_activebackup_arp_mon); | ||
561 | else | ||
562 | INIT_DELAYED_WORK(&bond->arp_work, | ||
563 | bond_loadbalance_arp_mon); | ||
564 | |||
565 | queue_delayed_work(bond->wq, &bond->arp_work, 0); | ||
566 | } | ||
567 | } | 557 | } |
568 | 558 | ||
569 | out: | 559 | out: |
560 | rtnl_unlock(); | ||
570 | return ret; | 561 | return ret; |
571 | } | 562 | } |
572 | static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR, | 563 | static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR, |
@@ -962,6 +953,8 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
962 | int new_value, ret = count; | 953 | int new_value, ret = count; |
963 | struct bonding *bond = to_bond(d); | 954 | struct bonding *bond = to_bond(d); |
964 | 955 | ||
956 | if (!rtnl_trylock()) | ||
957 | return restart_syscall(); | ||
965 | if (sscanf(buf, "%d", &new_value) != 1) { | 958 | if (sscanf(buf, "%d", &new_value) != 1) { |
966 | pr_err("%s: no miimon value specified.\n", | 959 | pr_err("%s: no miimon value specified.\n", |
967 | bond->dev->name); | 960 | bond->dev->name); |
@@ -993,10 +986,6 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
993 | bond->params.arp_validate = | 986 | bond->params.arp_validate = |
994 | BOND_ARP_VALIDATE_NONE; | 987 | BOND_ARP_VALIDATE_NONE; |
995 | } | 988 | } |
996 | if (delayed_work_pending(&bond->arp_work)) { | ||
997 | cancel_delayed_work(&bond->arp_work); | ||
998 | flush_workqueue(bond->wq); | ||
999 | } | ||
1000 | } | 989 | } |
1001 | 990 | ||
1002 | if (bond->dev->flags & IFF_UP) { | 991 | if (bond->dev->flags & IFF_UP) { |
@@ -1005,15 +994,12 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
1005 | * timer will get fired off when the open function | 994 | * timer will get fired off when the open function |
1006 | * is called. | 995 | * is called. |
1007 | */ | 996 | */ |
1008 | if (!delayed_work_pending(&bond->mii_work)) { | 997 | cancel_delayed_work_sync(&bond->arp_work); |
1009 | INIT_DELAYED_WORK(&bond->mii_work, | 998 | queue_delayed_work(bond->wq, &bond->mii_work, 0); |
1010 | bond_mii_monitor); | ||
1011 | queue_delayed_work(bond->wq, | ||
1012 | &bond->mii_work, 0); | ||
1013 | } | ||
1014 | } | 999 | } |
1015 | } | 1000 | } |
1016 | out: | 1001 | out: |
1002 | rtnl_unlock(); | ||
1017 | return ret; | 1003 | return ret; |
1018 | } | 1004 | } |
1019 | static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, | 1005 | static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, |
@@ -1582,6 +1568,7 @@ static ssize_t bonding_store_slaves_active(struct device *d, | |||
1582 | goto out; | 1568 | goto out; |
1583 | } | 1569 | } |
1584 | 1570 | ||
1571 | read_lock(&bond->lock); | ||
1585 | bond_for_each_slave(bond, slave, i) { | 1572 | bond_for_each_slave(bond, slave, i) { |
1586 | if (!bond_is_active_slave(slave)) { | 1573 | if (!bond_is_active_slave(slave)) { |
1587 | if (new_value) | 1574 | if (new_value) |
@@ -1590,6 +1577,7 @@ static ssize_t bonding_store_slaves_active(struct device *d, | |||
1590 | slave->inactive = 1; | 1577 | slave->inactive = 1; |
1591 | } | 1578 | } |
1592 | } | 1579 | } |
1580 | read_unlock(&bond->lock); | ||
1593 | out: | 1581 | out: |
1594 | return ret; | 1582 | return ret; |
1595 | } | 1583 | } |
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c index 86f26a1ede4c..25723d8ee201 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c | |||
@@ -519,8 +519,10 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, | |||
519 | mc->pdev->dev.can.state = new_state; | 519 | mc->pdev->dev.can.state = new_state; |
520 | 520 | ||
521 | if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) { | 521 | if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) { |
522 | struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb); | ||
523 | |||
522 | peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); | 524 | peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); |
523 | skb->tstamp = timeval_to_ktime(tv); | 525 | hwts->hwtstamp = timeval_to_ktime(tv); |
524 | } | 526 | } |
525 | 527 | ||
526 | netif_rx(skb); | 528 | netif_rx(skb); |
@@ -605,6 +607,7 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len) | |||
605 | struct sk_buff *skb; | 607 | struct sk_buff *skb; |
606 | struct can_frame *cf; | 608 | struct can_frame *cf; |
607 | struct timeval tv; | 609 | struct timeval tv; |
610 | struct skb_shared_hwtstamps *hwts; | ||
608 | 611 | ||
609 | skb = alloc_can_skb(mc->netdev, &cf); | 612 | skb = alloc_can_skb(mc->netdev, &cf); |
610 | if (!skb) | 613 | if (!skb) |
@@ -652,7 +655,8 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len) | |||
652 | 655 | ||
653 | /* convert timestamp into kernel time */ | 656 | /* convert timestamp into kernel time */ |
654 | peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); | 657 | peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); |
655 | skb->tstamp = timeval_to_ktime(tv); | 658 | hwts = skb_hwtstamps(skb); |
659 | hwts->hwtstamp = timeval_to_ktime(tv); | ||
656 | 660 | ||
657 | /* push the skb */ | 661 | /* push the skb */ |
658 | netif_rx(skb); | 662 | netif_rx(skb); |
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c index e1626d92511a..30d79bfa5b10 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c | |||
@@ -532,6 +532,7 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if, | |||
532 | struct can_frame *can_frame; | 532 | struct can_frame *can_frame; |
533 | struct sk_buff *skb; | 533 | struct sk_buff *skb; |
534 | struct timeval tv; | 534 | struct timeval tv; |
535 | struct skb_shared_hwtstamps *hwts; | ||
535 | 536 | ||
536 | skb = alloc_can_skb(netdev, &can_frame); | 537 | skb = alloc_can_skb(netdev, &can_frame); |
537 | if (!skb) | 538 | if (!skb) |
@@ -549,7 +550,8 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if, | |||
549 | memcpy(can_frame->data, rx->data, can_frame->can_dlc); | 550 | memcpy(can_frame->data, rx->data, can_frame->can_dlc); |
550 | 551 | ||
551 | peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv); | 552 | peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv); |
552 | skb->tstamp = timeval_to_ktime(tv); | 553 | hwts = skb_hwtstamps(skb); |
554 | hwts->hwtstamp = timeval_to_ktime(tv); | ||
553 | 555 | ||
554 | netif_rx(skb); | 556 | netif_rx(skb); |
555 | netdev->stats.rx_packets++; | 557 | netdev->stats.rx_packets++; |
@@ -570,6 +572,7 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if, | |||
570 | u8 err_mask = 0; | 572 | u8 err_mask = 0; |
571 | struct sk_buff *skb; | 573 | struct sk_buff *skb; |
572 | struct timeval tv; | 574 | struct timeval tv; |
575 | struct skb_shared_hwtstamps *hwts; | ||
573 | 576 | ||
574 | /* nothing should be sent while in BUS_OFF state */ | 577 | /* nothing should be sent while in BUS_OFF state */ |
575 | if (dev->can.state == CAN_STATE_BUS_OFF) | 578 | if (dev->can.state == CAN_STATE_BUS_OFF) |
@@ -664,7 +667,8 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if, | |||
664 | dev->can.state = new_state; | 667 | dev->can.state = new_state; |
665 | 668 | ||
666 | peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv); | 669 | peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv); |
667 | skb->tstamp = timeval_to_ktime(tv); | 670 | hwts = skb_hwtstamps(skb); |
671 | hwts->hwtstamp = timeval_to_ktime(tv); | ||
668 | netif_rx(skb); | 672 | netif_rx(skb); |
669 | netdev->stats.rx_packets++; | 673 | netdev->stats.rx_packets++; |
670 | netdev->stats.rx_bytes += can_frame->can_dlc; | 674 | netdev->stats.rx_bytes += can_frame->can_dlc; |
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c index d04911d33b64..47618e505355 100644 --- a/drivers/net/ethernet/8390/ne.c +++ b/drivers/net/ethernet/8390/ne.c | |||
@@ -813,6 +813,7 @@ static int __init ne_drv_probe(struct platform_device *pdev) | |||
813 | dev->irq = irq[this_dev]; | 813 | dev->irq = irq[this_dev]; |
814 | dev->mem_end = bad[this_dev]; | 814 | dev->mem_end = bad[this_dev]; |
815 | } | 815 | } |
816 | SET_NETDEV_DEV(dev, &pdev->dev); | ||
816 | err = do_ne_probe(dev); | 817 | err = do_ne_probe(dev); |
817 | if (err) { | 818 | if (err) { |
818 | free_netdev(dev); | 819 | free_netdev(dev); |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index bd1fd3d87c24..01611b33a93d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | |||
@@ -9545,10 +9545,13 @@ static int __devinit bnx2x_prev_unload_common(struct bnx2x *bp) | |||
9545 | */ | 9545 | */ |
9546 | static void __devinit bnx2x_prev_interrupted_dmae(struct bnx2x *bp) | 9546 | static void __devinit bnx2x_prev_interrupted_dmae(struct bnx2x *bp) |
9547 | { | 9547 | { |
9548 | u32 val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS); | 9548 | if (!CHIP_IS_E1x(bp)) { |
9549 | if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) { | 9549 | u32 val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS); |
9550 | BNX2X_ERR("was error bit was found to be set in pglueb upon startup. Clearing"); | 9550 | if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) { |
9551 | REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR, 1 << BP_FUNC(bp)); | 9551 | BNX2X_ERR("was error bit was found to be set in pglueb upon startup. Clearing"); |
9552 | REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR, | ||
9553 | 1 << BP_FUNC(bp)); | ||
9554 | } | ||
9552 | } | 9555 | } |
9553 | } | 9556 | } |
9554 | 9557 | ||
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 92317e9c0f73..60ac46f4ac08 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c | |||
@@ -1860,10 +1860,14 @@ jme_open(struct net_device *netdev) | |||
1860 | jme_clear_pm(jme); | 1860 | jme_clear_pm(jme); |
1861 | JME_NAPI_ENABLE(jme); | 1861 | JME_NAPI_ENABLE(jme); |
1862 | 1862 | ||
1863 | tasklet_enable(&jme->linkch_task); | 1863 | tasklet_init(&jme->linkch_task, jme_link_change_tasklet, |
1864 | tasklet_enable(&jme->txclean_task); | 1864 | (unsigned long) jme); |
1865 | tasklet_hi_enable(&jme->rxclean_task); | 1865 | tasklet_init(&jme->txclean_task, jme_tx_clean_tasklet, |
1866 | tasklet_hi_enable(&jme->rxempty_task); | 1866 | (unsigned long) jme); |
1867 | tasklet_init(&jme->rxclean_task, jme_rx_clean_tasklet, | ||
1868 | (unsigned long) jme); | ||
1869 | tasklet_init(&jme->rxempty_task, jme_rx_empty_tasklet, | ||
1870 | (unsigned long) jme); | ||
1867 | 1871 | ||
1868 | rc = jme_request_irq(jme); | 1872 | rc = jme_request_irq(jme); |
1869 | if (rc) | 1873 | if (rc) |
@@ -3079,22 +3083,6 @@ jme_init_one(struct pci_dev *pdev, | |||
3079 | tasklet_init(&jme->pcc_task, | 3083 | tasklet_init(&jme->pcc_task, |
3080 | jme_pcc_tasklet, | 3084 | jme_pcc_tasklet, |
3081 | (unsigned long) jme); | 3085 | (unsigned long) jme); |
3082 | tasklet_init(&jme->linkch_task, | ||
3083 | jme_link_change_tasklet, | ||
3084 | (unsigned long) jme); | ||
3085 | tasklet_init(&jme->txclean_task, | ||
3086 | jme_tx_clean_tasklet, | ||
3087 | (unsigned long) jme); | ||
3088 | tasklet_init(&jme->rxclean_task, | ||
3089 | jme_rx_clean_tasklet, | ||
3090 | (unsigned long) jme); | ||
3091 | tasklet_init(&jme->rxempty_task, | ||
3092 | jme_rx_empty_tasklet, | ||
3093 | (unsigned long) jme); | ||
3094 | tasklet_disable_nosync(&jme->linkch_task); | ||
3095 | tasklet_disable_nosync(&jme->txclean_task); | ||
3096 | tasklet_disable_nosync(&jme->rxclean_task); | ||
3097 | tasklet_disable_nosync(&jme->rxempty_task); | ||
3098 | jme->dpi.cur = PCC_P1; | 3086 | jme->dpi.cur = PCC_P1; |
3099 | 3087 | ||
3100 | jme->reg_ghc = 0; | 3088 | jme->reg_ghc = 0; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c index 5d36795877cb..b799ab12a291 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c | |||
@@ -237,7 +237,7 @@ static int mlx4_en_dcbnl_ieee_setmaxrate(struct net_device *dev, | |||
237 | if (err) | 237 | if (err) |
238 | return err; | 238 | return err; |
239 | 239 | ||
240 | memcpy(priv->maxrate, tmp, sizeof(*priv->maxrate)); | 240 | memcpy(priv->maxrate, tmp, sizeof(priv->maxrate)); |
241 | 241 | ||
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index e558edd1cb6c..69e01977a1dd 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c | |||
@@ -5459,8 +5459,10 @@ static int prepare_hardware(struct net_device *dev) | |||
5459 | rc = request_irq(dev->irq, netdev_intr, IRQF_SHARED, dev->name, dev); | 5459 | rc = request_irq(dev->irq, netdev_intr, IRQF_SHARED, dev->name, dev); |
5460 | if (rc) | 5460 | if (rc) |
5461 | return rc; | 5461 | return rc; |
5462 | tasklet_enable(&hw_priv->rx_tasklet); | 5462 | tasklet_init(&hw_priv->rx_tasklet, rx_proc_task, |
5463 | tasklet_enable(&hw_priv->tx_tasklet); | 5463 | (unsigned long) hw_priv); |
5464 | tasklet_init(&hw_priv->tx_tasklet, tx_proc_task, | ||
5465 | (unsigned long) hw_priv); | ||
5464 | 5466 | ||
5465 | hw->promiscuous = 0; | 5467 | hw->promiscuous = 0; |
5466 | hw->all_multi = 0; | 5468 | hw->all_multi = 0; |
@@ -7033,16 +7035,6 @@ static int __devinit pcidev_init(struct pci_dev *pdev, | |||
7033 | spin_lock_init(&hw_priv->hwlock); | 7035 | spin_lock_init(&hw_priv->hwlock); |
7034 | mutex_init(&hw_priv->lock); | 7036 | mutex_init(&hw_priv->lock); |
7035 | 7037 | ||
7036 | /* tasklet is enabled. */ | ||
7037 | tasklet_init(&hw_priv->rx_tasklet, rx_proc_task, | ||
7038 | (unsigned long) hw_priv); | ||
7039 | tasklet_init(&hw_priv->tx_tasklet, tx_proc_task, | ||
7040 | (unsigned long) hw_priv); | ||
7041 | |||
7042 | /* tasklet_enable will decrement the atomic counter. */ | ||
7043 | tasklet_disable(&hw_priv->rx_tasklet); | ||
7044 | tasklet_disable(&hw_priv->tx_tasklet); | ||
7045 | |||
7046 | for (i = 0; i < TOTAL_PORT_NUM; i++) | 7038 | for (i = 0; i < TOTAL_PORT_NUM; i++) |
7047 | init_waitqueue_head(&hw_priv->counter[i].counter); | 7039 | init_waitqueue_head(&hw_priv->counter[i].counter); |
7048 | 7040 | ||
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index 1c818254b7be..609125a249d9 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c | |||
@@ -979,17 +979,6 @@ static void cp_init_hw (struct cp_private *cp) | |||
979 | cpw32_f (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0))); | 979 | cpw32_f (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0))); |
980 | cpw32_f (MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4))); | 980 | cpw32_f (MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4))); |
981 | 981 | ||
982 | cpw32_f(HiTxRingAddr, 0); | ||
983 | cpw32_f(HiTxRingAddr + 4, 0); | ||
984 | |||
985 | ring_dma = cp->ring_dma; | ||
986 | cpw32_f(RxRingAddr, ring_dma & 0xffffffff); | ||
987 | cpw32_f(RxRingAddr + 4, (ring_dma >> 16) >> 16); | ||
988 | |||
989 | ring_dma += sizeof(struct cp_desc) * CP_RX_RING_SIZE; | ||
990 | cpw32_f(TxRingAddr, ring_dma & 0xffffffff); | ||
991 | cpw32_f(TxRingAddr + 4, (ring_dma >> 16) >> 16); | ||
992 | |||
993 | cp_start_hw(cp); | 982 | cp_start_hw(cp); |
994 | cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */ | 983 | cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */ |
995 | 984 | ||
@@ -1003,6 +992,17 @@ static void cp_init_hw (struct cp_private *cp) | |||
1003 | 992 | ||
1004 | cpw8(Config5, cpr8(Config5) & PMEStatus); | 993 | cpw8(Config5, cpr8(Config5) & PMEStatus); |
1005 | 994 | ||
995 | cpw32_f(HiTxRingAddr, 0); | ||
996 | cpw32_f(HiTxRingAddr + 4, 0); | ||
997 | |||
998 | ring_dma = cp->ring_dma; | ||
999 | cpw32_f(RxRingAddr, ring_dma & 0xffffffff); | ||
1000 | cpw32_f(RxRingAddr + 4, (ring_dma >> 16) >> 16); | ||
1001 | |||
1002 | ring_dma += sizeof(struct cp_desc) * CP_RX_RING_SIZE; | ||
1003 | cpw32_f(TxRingAddr, ring_dma & 0xffffffff); | ||
1004 | cpw32_f(TxRingAddr + 4, (ring_dma >> 16) >> 16); | ||
1005 | |||
1006 | cpw16(MultiIntr, 0); | 1006 | cpw16(MultiIntr, 0); |
1007 | 1007 | ||
1008 | cpw8_f(Cfg9346, Cfg9346_Lock); | 1008 | cpw8_f(Cfg9346, Cfg9346_Lock); |
@@ -1060,17 +1060,22 @@ static int cp_init_rings (struct cp_private *cp) | |||
1060 | 1060 | ||
1061 | static int cp_alloc_rings (struct cp_private *cp) | 1061 | static int cp_alloc_rings (struct cp_private *cp) |
1062 | { | 1062 | { |
1063 | struct device *d = &cp->pdev->dev; | ||
1063 | void *mem; | 1064 | void *mem; |
1065 | int rc; | ||
1064 | 1066 | ||
1065 | mem = dma_alloc_coherent(&cp->pdev->dev, CP_RING_BYTES, | 1067 | mem = dma_alloc_coherent(d, CP_RING_BYTES, &cp->ring_dma, GFP_KERNEL); |
1066 | &cp->ring_dma, GFP_KERNEL); | ||
1067 | if (!mem) | 1068 | if (!mem) |
1068 | return -ENOMEM; | 1069 | return -ENOMEM; |
1069 | 1070 | ||
1070 | cp->rx_ring = mem; | 1071 | cp->rx_ring = mem; |
1071 | cp->tx_ring = &cp->rx_ring[CP_RX_RING_SIZE]; | 1072 | cp->tx_ring = &cp->rx_ring[CP_RX_RING_SIZE]; |
1072 | 1073 | ||
1073 | return cp_init_rings(cp); | 1074 | rc = cp_init_rings(cp); |
1075 | if (rc < 0) | ||
1076 | dma_free_coherent(d, CP_RING_BYTES, cp->rx_ring, cp->ring_dma); | ||
1077 | |||
1078 | return rc; | ||
1074 | } | 1079 | } |
1075 | 1080 | ||
1076 | static void cp_clean_rings (struct cp_private *cp) | 1081 | static void cp_clean_rings (struct cp_private *cp) |
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c index fb9f6b38511f..edf5edb13140 100644 --- a/drivers/net/ethernet/sis/sis900.c +++ b/drivers/net/ethernet/sis/sis900.c | |||
@@ -2479,7 +2479,7 @@ static int sis900_resume(struct pci_dev *pci_dev) | |||
2479 | netif_start_queue(net_dev); | 2479 | netif_start_queue(net_dev); |
2480 | 2480 | ||
2481 | /* Workaround for EDB */ | 2481 | /* Workaround for EDB */ |
2482 | sis900_set_mode(ioaddr, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED); | 2482 | sis900_set_mode(sis_priv, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED); |
2483 | 2483 | ||
2484 | /* Enable all known interrupts by setting the interrupt mask. */ | 2484 | /* Enable all known interrupts by setting the interrupt mask. */ |
2485 | sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE); | 2485 | sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE); |
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 62d1baf111ea..c53c0f4e2ce3 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c | |||
@@ -2110,7 +2110,7 @@ static void __devinit smsc911x_read_mac_address(struct net_device *dev) | |||
2110 | static int __devinit smsc911x_init(struct net_device *dev) | 2110 | static int __devinit smsc911x_init(struct net_device *dev) |
2111 | { | 2111 | { |
2112 | struct smsc911x_data *pdata = netdev_priv(dev); | 2112 | struct smsc911x_data *pdata = netdev_priv(dev); |
2113 | unsigned int byte_test; | 2113 | unsigned int byte_test, mask; |
2114 | unsigned int to = 100; | 2114 | unsigned int to = 100; |
2115 | 2115 | ||
2116 | SMSC_TRACE(pdata, probe, "Driver Parameters:"); | 2116 | SMSC_TRACE(pdata, probe, "Driver Parameters:"); |
@@ -2130,9 +2130,22 @@ static int __devinit smsc911x_init(struct net_device *dev) | |||
2130 | /* | 2130 | /* |
2131 | * poll the READY bit in PMT_CTRL. Any other access to the device is | 2131 | * poll the READY bit in PMT_CTRL. Any other access to the device is |
2132 | * forbidden while this bit isn't set. Try for 100ms | 2132 | * forbidden while this bit isn't set. Try for 100ms |
2133 | * | ||
2134 | * Note that this test is done before the WORD_SWAP register is | ||
2135 | * programmed. So in some configurations the READY bit is at 16 before | ||
2136 | * WORD_SWAP is written to. This issue is worked around by waiting | ||
2137 | * until either bit 0 or bit 16 gets set in PMT_CTRL. | ||
2138 | * | ||
2139 | * SMSC has confirmed that checking bit 16 (marked as reserved in | ||
2140 | * the datasheet) is fine since these bits "will either never be set | ||
2141 | * or can only go high after READY does (so also indicate the device | ||
2142 | * is ready)". | ||
2133 | */ | 2143 | */ |
2134 | while (!(smsc911x_reg_read(pdata, PMT_CTRL) & PMT_CTRL_READY_) && --to) | 2144 | |
2145 | mask = PMT_CTRL_READY_ | swahw32(PMT_CTRL_READY_); | ||
2146 | while (!(smsc911x_reg_read(pdata, PMT_CTRL) & mask) && --to) | ||
2135 | udelay(1000); | 2147 | udelay(1000); |
2148 | |||
2136 | if (to == 0) { | 2149 | if (to == 0) { |
2137 | pr_err("Device not READY in 100ms aborting\n"); | 2150 | pr_err("Device not READY in 100ms aborting\n"); |
2138 | return -ENODEV; | 2151 | return -ENODEV; |
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c index 4e9810013850..66e025ad5df1 100644 --- a/drivers/net/ethernet/tile/tilegx.c +++ b/drivers/net/ethernet/tile/tilegx.c | |||
@@ -917,7 +917,7 @@ static int tile_net_setup_interrupts(struct net_device *dev) | |||
917 | ingress_irq = rc; | 917 | ingress_irq = rc; |
918 | tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU); | 918 | tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU); |
919 | rc = request_irq(ingress_irq, tile_net_handle_ingress_irq, | 919 | rc = request_irq(ingress_irq, tile_net_handle_ingress_irq, |
920 | 0, NULL, NULL); | 920 | 0, "tile_net", NULL); |
921 | if (rc != 0) { | 921 | if (rc != 0) { |
922 | netdev_err(dev, "request_irq failed: %d\n", rc); | 922 | netdev_err(dev, "request_irq failed: %d\n", rc); |
923 | destroy_irq(ingress_irq); | 923 | destroy_irq(ingress_irq); |
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 1d04754a6637..a788501e978e 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c | |||
@@ -894,6 +894,8 @@ out: | |||
894 | return IRQ_HANDLED; | 894 | return IRQ_HANDLED; |
895 | } | 895 | } |
896 | 896 | ||
897 | static void axienet_dma_err_handler(unsigned long data); | ||
898 | |||
897 | /** | 899 | /** |
898 | * axienet_open - Driver open routine. | 900 | * axienet_open - Driver open routine. |
899 | * @ndev: Pointer to net_device structure | 901 | * @ndev: Pointer to net_device structure |
@@ -942,6 +944,10 @@ static int axienet_open(struct net_device *ndev) | |||
942 | phy_start(lp->phy_dev); | 944 | phy_start(lp->phy_dev); |
943 | } | 945 | } |
944 | 946 | ||
947 | /* Enable tasklets for Axi DMA error handling */ | ||
948 | tasklet_init(&lp->dma_err_tasklet, axienet_dma_err_handler, | ||
949 | (unsigned long) lp); | ||
950 | |||
945 | /* Enable interrupts for Axi DMA Tx */ | 951 | /* Enable interrupts for Axi DMA Tx */ |
946 | ret = request_irq(lp->tx_irq, axienet_tx_irq, 0, ndev->name, ndev); | 952 | ret = request_irq(lp->tx_irq, axienet_tx_irq, 0, ndev->name, ndev); |
947 | if (ret) | 953 | if (ret) |
@@ -950,8 +956,7 @@ static int axienet_open(struct net_device *ndev) | |||
950 | ret = request_irq(lp->rx_irq, axienet_rx_irq, 0, ndev->name, ndev); | 956 | ret = request_irq(lp->rx_irq, axienet_rx_irq, 0, ndev->name, ndev); |
951 | if (ret) | 957 | if (ret) |
952 | goto err_rx_irq; | 958 | goto err_rx_irq; |
953 | /* Enable tasklets for Axi DMA error handling */ | 959 | |
954 | tasklet_enable(&lp->dma_err_tasklet); | ||
955 | return 0; | 960 | return 0; |
956 | 961 | ||
957 | err_rx_irq: | 962 | err_rx_irq: |
@@ -960,6 +965,7 @@ err_tx_irq: | |||
960 | if (lp->phy_dev) | 965 | if (lp->phy_dev) |
961 | phy_disconnect(lp->phy_dev); | 966 | phy_disconnect(lp->phy_dev); |
962 | lp->phy_dev = NULL; | 967 | lp->phy_dev = NULL; |
968 | tasklet_kill(&lp->dma_err_tasklet); | ||
963 | dev_err(lp->dev, "request_irq() failed\n"); | 969 | dev_err(lp->dev, "request_irq() failed\n"); |
964 | return ret; | 970 | return ret; |
965 | } | 971 | } |
@@ -1613,10 +1619,6 @@ static int __devinit axienet_of_probe(struct platform_device *op) | |||
1613 | goto err_iounmap_2; | 1619 | goto err_iounmap_2; |
1614 | } | 1620 | } |
1615 | 1621 | ||
1616 | tasklet_init(&lp->dma_err_tasklet, axienet_dma_err_handler, | ||
1617 | (unsigned long) lp); | ||
1618 | tasklet_disable(&lp->dma_err_tasklet); | ||
1619 | |||
1620 | return 0; | 1622 | return 0; |
1621 | 1623 | ||
1622 | err_iounmap_2: | 1624 | err_iounmap_2: |
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 98934bdf6acf..477d6729b17f 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c | |||
@@ -1102,10 +1102,12 @@ static int init_queues(struct port *port) | |||
1102 | { | 1102 | { |
1103 | int i; | 1103 | int i; |
1104 | 1104 | ||
1105 | if (!ports_open) | 1105 | if (!ports_open) { |
1106 | if (!(dma_pool = dma_pool_create(DRV_NAME, NULL, | 1106 | dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev, |
1107 | POOL_ALLOC_SIZE, 32, 0))) | 1107 | POOL_ALLOC_SIZE, 32, 0); |
1108 | if (!dma_pool) | ||
1108 | return -ENOMEM; | 1109 | return -ENOMEM; |
1110 | } | ||
1109 | 1111 | ||
1110 | if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, | 1112 | if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, |
1111 | &port->desc_tab_phys))) | 1113 | &port->desc_tab_phys))) |
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index 5039f08f5a5b..43e9ab4f4d7e 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c | |||
@@ -222,7 +222,7 @@ static void sirdev_config_fsm(struct work_struct *work) | |||
222 | break; | 222 | break; |
223 | 223 | ||
224 | case SIRDEV_STATE_DONGLE_SPEED: | 224 | case SIRDEV_STATE_DONGLE_SPEED: |
225 | if (dev->dongle_drv->reset) { | 225 | if (dev->dongle_drv->set_speed) { |
226 | ret = dev->dongle_drv->set_speed(dev, fsm->param); | 226 | ret = dev->dongle_drv->set_speed(dev, fsm->param); |
227 | if (ret < 0) { | 227 | if (ret < 0) { |
228 | fsm->result = ret; | 228 | fsm->result = ret; |
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c index 6428fcbbdd4b..daec9b05d168 100644 --- a/drivers/net/phy/mdio-bitbang.c +++ b/drivers/net/phy/mdio-bitbang.c | |||
@@ -234,7 +234,6 @@ void free_mdio_bitbang(struct mii_bus *bus) | |||
234 | struct mdiobb_ctrl *ctrl = bus->priv; | 234 | struct mdiobb_ctrl *ctrl = bus->priv; |
235 | 235 | ||
236 | module_put(ctrl->ops->owner); | 236 | module_put(ctrl->ops->owner); |
237 | mdiobus_unregister(bus); | ||
238 | mdiobus_free(bus); | 237 | mdiobus_free(bus); |
239 | } | 238 | } |
240 | EXPORT_SYMBOL(free_mdio_bitbang); | 239 | EXPORT_SYMBOL(free_mdio_bitbang); |
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 899274f2f9b1..2ed1140df3e9 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c | |||
@@ -185,17 +185,20 @@ static int __devinit mdio_gpio_probe(struct platform_device *pdev) | |||
185 | { | 185 | { |
186 | struct mdio_gpio_platform_data *pdata; | 186 | struct mdio_gpio_platform_data *pdata; |
187 | struct mii_bus *new_bus; | 187 | struct mii_bus *new_bus; |
188 | int ret; | 188 | int ret, bus_id; |
189 | 189 | ||
190 | if (pdev->dev.of_node) | 190 | if (pdev->dev.of_node) { |
191 | pdata = mdio_gpio_of_get_data(pdev); | 191 | pdata = mdio_gpio_of_get_data(pdev); |
192 | else | 192 | bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio"); |
193 | } else { | ||
193 | pdata = pdev->dev.platform_data; | 194 | pdata = pdev->dev.platform_data; |
195 | bus_id = pdev->id; | ||
196 | } | ||
194 | 197 | ||
195 | if (!pdata) | 198 | if (!pdata) |
196 | return -ENODEV; | 199 | return -ENODEV; |
197 | 200 | ||
198 | new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id); | 201 | new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, bus_id); |
199 | if (!new_bus) | 202 | if (!new_bus) |
200 | return -ENODEV; | 203 | return -ENODEV; |
201 | 204 | ||
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index d44cca327588..ad86660fb8f9 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c | |||
@@ -1794,10 +1794,12 @@ static void team_setup(struct net_device *dev) | |||
1794 | 1794 | ||
1795 | dev->features |= NETIF_F_LLTX; | 1795 | dev->features |= NETIF_F_LLTX; |
1796 | dev->features |= NETIF_F_GRO; | 1796 | dev->features |= NETIF_F_GRO; |
1797 | dev->hw_features = NETIF_F_HW_VLAN_TX | | 1797 | dev->hw_features = TEAM_VLAN_FEATURES | |
1798 | NETIF_F_HW_VLAN_TX | | ||
1798 | NETIF_F_HW_VLAN_RX | | 1799 | NETIF_F_HW_VLAN_RX | |
1799 | NETIF_F_HW_VLAN_FILTER; | 1800 | NETIF_F_HW_VLAN_FILTER; |
1800 | 1801 | ||
1802 | dev->hw_features &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_HW_CSUM); | ||
1801 | dev->features |= dev->hw_features; | 1803 | dev->features |= dev->hw_features; |
1802 | } | 1804 | } |
1803 | 1805 | ||
diff --git a/drivers/net/team/team_mode_broadcast.c b/drivers/net/team/team_mode_broadcast.c index 9db0171e9366..c5db428e73fa 100644 --- a/drivers/net/team/team_mode_broadcast.c +++ b/drivers/net/team/team_mode_broadcast.c | |||
@@ -29,8 +29,8 @@ static bool bc_transmit(struct team *team, struct sk_buff *skb) | |||
29 | if (last) { | 29 | if (last) { |
30 | skb2 = skb_clone(skb, GFP_ATOMIC); | 30 | skb2 = skb_clone(skb, GFP_ATOMIC); |
31 | if (skb2) { | 31 | if (skb2) { |
32 | ret = team_dev_queue_xmit(team, last, | 32 | ret = !team_dev_queue_xmit(team, last, |
33 | skb2); | 33 | skb2); |
34 | if (!sum_ret) | 34 | if (!sum_ret) |
35 | sum_ret = ret; | 35 | sum_ret = ret; |
36 | } | 36 | } |
@@ -39,7 +39,7 @@ static bool bc_transmit(struct team *team, struct sk_buff *skb) | |||
39 | } | 39 | } |
40 | } | 40 | } |
41 | if (last) { | 41 | if (last) { |
42 | ret = team_dev_queue_xmit(team, last, skb); | 42 | ret = !team_dev_queue_xmit(team, last, skb); |
43 | if (!sum_ret) | 43 | if (!sum_ret) |
44 | sum_ret = ret; | 44 | sum_ret = ret; |
45 | } | 45 | } |
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 4cd582a4f625..74fab1a40156 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c | |||
@@ -540,10 +540,12 @@ advance: | |||
540 | (ctx->ether_desc == NULL) || (ctx->control != intf)) | 540 | (ctx->ether_desc == NULL) || (ctx->control != intf)) |
541 | goto error; | 541 | goto error; |
542 | 542 | ||
543 | /* claim interfaces, if any */ | 543 | /* claim data interface, if different from control */ |
544 | temp = usb_driver_claim_interface(driver, ctx->data, dev); | 544 | if (ctx->data != ctx->control) { |
545 | if (temp) | 545 | temp = usb_driver_claim_interface(driver, ctx->data, dev); |
546 | goto error; | 546 | if (temp) |
547 | goto error; | ||
548 | } | ||
547 | 549 | ||
548 | iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber; | 550 | iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber; |
549 | 551 | ||
@@ -623,6 +625,10 @@ static void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf) | |||
623 | 625 | ||
624 | tasklet_kill(&ctx->bh); | 626 | tasklet_kill(&ctx->bh); |
625 | 627 | ||
628 | /* handle devices with combined control and data interface */ | ||
629 | if (ctx->control == ctx->data) | ||
630 | ctx->data = NULL; | ||
631 | |||
626 | /* disconnect master --> disconnect slave */ | 632 | /* disconnect master --> disconnect slave */ |
627 | if (intf == ctx->control && ctx->data) { | 633 | if (intf == ctx->control && ctx->data) { |
628 | usb_set_intfdata(ctx->data, NULL); | 634 | usb_set_intfdata(ctx->data, NULL); |
@@ -1245,6 +1251,14 @@ static const struct usb_device_id cdc_devs[] = { | |||
1245 | .driver_info = (unsigned long) &wwan_info, | 1251 | .driver_info = (unsigned long) &wwan_info, |
1246 | }, | 1252 | }, |
1247 | 1253 | ||
1254 | /* Huawei NCM devices disguised as vendor specific */ | ||
1255 | { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16), | ||
1256 | .driver_info = (unsigned long)&wwan_info, | ||
1257 | }, | ||
1258 | { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x46), | ||
1259 | .driver_info = (unsigned long)&wwan_info, | ||
1260 | }, | ||
1261 | |||
1248 | /* Generic CDC-NCM devices */ | 1262 | /* Generic CDC-NCM devices */ |
1249 | { USB_INTERFACE_INFO(USB_CLASS_COMM, | 1263 | { USB_INTERFACE_INFO(USB_CLASS_COMM, |
1250 | USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), | 1264 | USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), |
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 3b566fa0f8e6..1ea91f4237f0 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c | |||
@@ -385,6 +385,7 @@ static const struct usb_device_id products[] = { | |||
385 | }, | 385 | }, |
386 | 386 | ||
387 | /* 3. Combined interface devices matching on interface number */ | 387 | /* 3. Combined interface devices matching on interface number */ |
388 | {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */ | ||
388 | {QMI_FIXED_INTF(0x19d2, 0x0002, 1)}, | 389 | {QMI_FIXED_INTF(0x19d2, 0x0002, 1)}, |
389 | {QMI_FIXED_INTF(0x19d2, 0x0012, 1)}, | 390 | {QMI_FIXED_INTF(0x19d2, 0x0012, 1)}, |
390 | {QMI_FIXED_INTF(0x19d2, 0x0017, 3)}, | 391 | {QMI_FIXED_INTF(0x19d2, 0x0017, 3)}, |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 3286166415b4..362cb8cfeb92 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
@@ -184,7 +184,7 @@ static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) | |||
184 | /* set the address, index & direction (read from PHY) */ | 184 | /* set the address, index & direction (read from PHY) */ |
185 | phy_id &= dev->mii.phy_id_mask; | 185 | phy_id &= dev->mii.phy_id_mask; |
186 | idx &= dev->mii.reg_num_mask; | 186 | idx &= dev->mii.reg_num_mask; |
187 | addr = (phy_id << 11) | (idx << 6) | MII_READ_; | 187 | addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_; |
188 | ret = smsc95xx_write_reg(dev, MII_ADDR, addr); | 188 | ret = smsc95xx_write_reg(dev, MII_ADDR, addr); |
189 | check_warn_goto_done(ret, "Error writing MII_ADDR"); | 189 | check_warn_goto_done(ret, "Error writing MII_ADDR"); |
190 | 190 | ||
@@ -221,7 +221,7 @@ static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx, | |||
221 | /* set the address, index & direction (write to PHY) */ | 221 | /* set the address, index & direction (write to PHY) */ |
222 | phy_id &= dev->mii.phy_id_mask; | 222 | phy_id &= dev->mii.phy_id_mask; |
223 | idx &= dev->mii.reg_num_mask; | 223 | idx &= dev->mii.reg_num_mask; |
224 | addr = (phy_id << 11) | (idx << 6) | MII_WRITE_; | 224 | addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_; |
225 | ret = smsc95xx_write_reg(dev, MII_ADDR, addr); | 225 | ret = smsc95xx_write_reg(dev, MII_ADDR, addr); |
226 | check_warn_goto_done(ret, "Error writing MII_ADDR"); | 226 | check_warn_goto_done(ret, "Error writing MII_ADDR"); |
227 | 227 | ||
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 7b4adde93c01..8b5c61917076 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * VXLAN: Virtual eXtensiable Local Area Network | 2 | * VXLAN: Virtual eXtensible Local Area Network |
3 | * | 3 | * |
4 | * Copyright (c) 2012 Vyatta Inc. | 4 | * Copyright (c) 2012 Vyatta Inc. |
5 | * | 5 | * |
@@ -50,8 +50,8 @@ | |||
50 | 50 | ||
51 | #define VXLAN_N_VID (1u << 24) | 51 | #define VXLAN_N_VID (1u << 24) |
52 | #define VXLAN_VID_MASK (VXLAN_N_VID - 1) | 52 | #define VXLAN_VID_MASK (VXLAN_N_VID - 1) |
53 | /* VLAN + IP header + UDP + VXLAN */ | 53 | /* IP header + UDP + VXLAN + Ethernet header */ |
54 | #define VXLAN_HEADROOM (4 + 20 + 8 + 8) | 54 | #define VXLAN_HEADROOM (20 + 8 + 8 + 14) |
55 | 55 | ||
56 | #define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */ | 56 | #define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */ |
57 | 57 | ||
@@ -1102,6 +1102,10 @@ static int vxlan_newlink(struct net *net, struct net_device *dev, | |||
1102 | 1102 | ||
1103 | if (!tb[IFLA_MTU]) | 1103 | if (!tb[IFLA_MTU]) |
1104 | dev->mtu = lowerdev->mtu - VXLAN_HEADROOM; | 1104 | dev->mtu = lowerdev->mtu - VXLAN_HEADROOM; |
1105 | |||
1106 | /* update header length based on lower device */ | ||
1107 | dev->hard_header_len = lowerdev->hard_header_len + | ||
1108 | VXLAN_HEADROOM; | ||
1105 | } | 1109 | } |
1106 | 1110 | ||
1107 | if (data[IFLA_VXLAN_TOS]) | 1111 | if (data[IFLA_VXLAN_TOS]) |
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c index 3f575afd8cfc..760776b3d66c 100644 --- a/drivers/net/wan/ixp4xx_hss.c +++ b/drivers/net/wan/ixp4xx_hss.c | |||
@@ -969,10 +969,12 @@ static int init_hdlc_queues(struct port *port) | |||
969 | { | 969 | { |
970 | int i; | 970 | int i; |
971 | 971 | ||
972 | if (!ports_open) | 972 | if (!ports_open) { |
973 | if (!(dma_pool = dma_pool_create(DRV_NAME, NULL, | 973 | dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev, |
974 | POOL_ALLOC_SIZE, 32, 0))) | 974 | POOL_ALLOC_SIZE, 32, 0); |
975 | if (!dma_pool) | ||
975 | return -ENOMEM; | 976 | return -ENOMEM; |
977 | } | ||
976 | 978 | ||
977 | if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, | 979 | if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, |
978 | &port->desc_tab_phys))) | 980 | &port->desc_tab_phys))) |
@@ -1363,7 +1365,7 @@ static int __devinit hss_init_one(struct platform_device *pdev) | |||
1363 | 1365 | ||
1364 | platform_set_drvdata(pdev, port); | 1366 | platform_set_drvdata(pdev, port); |
1365 | 1367 | ||
1366 | netdev_info(dev, "HSS-%i\n", port->id); | 1368 | netdev_info(dev, "initialized\n"); |
1367 | return 0; | 1369 | return 0; |
1368 | 1370 | ||
1369 | err_free_netdev: | 1371 | err_free_netdev: |
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 8e1559aba495..1829b445d0b0 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -1456,7 +1456,7 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type) | |||
1456 | switch (type) { | 1456 | switch (type) { |
1457 | case ATH9K_RESET_POWER_ON: | 1457 | case ATH9K_RESET_POWER_ON: |
1458 | ret = ath9k_hw_set_reset_power_on(ah); | 1458 | ret = ath9k_hw_set_reset_power_on(ah); |
1459 | if (!ret) | 1459 | if (ret) |
1460 | ah->reset_power_on = true; | 1460 | ah->reset_power_on = true; |
1461 | break; | 1461 | break; |
1462 | case ATH9K_RESET_WARM: | 1462 | case ATH9K_RESET_WARM: |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index a6f1e8166008..481345c23ded 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | |||
@@ -4401,7 +4401,7 @@ static s32 brcmf_mode_to_nl80211_iftype(s32 mode) | |||
4401 | 4401 | ||
4402 | static void brcmf_wiphy_pno_params(struct wiphy *wiphy) | 4402 | static void brcmf_wiphy_pno_params(struct wiphy *wiphy) |
4403 | { | 4403 | { |
4404 | #ifndef CONFIG_BRCMFISCAN | 4404 | #ifndef CONFIG_BRCMISCAN |
4405 | /* scheduled scan settings */ | 4405 | /* scheduled scan settings */ |
4406 | wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT; | 4406 | wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT; |
4407 | wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT; | 4407 | wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT; |
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c index ff8162d4c454..2d9eee93c743 100644 --- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c +++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c | |||
@@ -521,7 +521,7 @@ static void iwlagn_mac_tx(struct ieee80211_hw *hw, | |||
521 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); | 521 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); |
522 | 522 | ||
523 | if (iwlagn_tx_skb(priv, control->sta, skb)) | 523 | if (iwlagn_tx_skb(priv, control->sta, skb)) |
524 | dev_kfree_skb_any(skb); | 524 | ieee80211_free_txskb(hw, skb); |
525 | } | 525 | } |
526 | 526 | ||
527 | static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, | 527 | static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, |
@@ -1354,6 +1354,20 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, | |||
1354 | vif_priv->ctx = ctx; | 1354 | vif_priv->ctx = ctx; |
1355 | ctx->vif = vif; | 1355 | ctx->vif = vif; |
1356 | 1356 | ||
1357 | /* | ||
1358 | * In SNIFFER device type, the firmware reports the FCS to | ||
1359 | * the host, rather than snipping it off. Unfortunately, | ||
1360 | * mac80211 doesn't (yet) provide a per-packet flag for | ||
1361 | * this, so that we have to set the hardware flag based | ||
1362 | * on the interfaces added. As the monitor interface can | ||
1363 | * only be present by itself, and will be removed before | ||
1364 | * other interfaces are added, this is safe. | ||
1365 | */ | ||
1366 | if (vif->type == NL80211_IFTYPE_MONITOR) | ||
1367 | priv->hw->flags |= IEEE80211_HW_RX_INCLUDES_FCS; | ||
1368 | else | ||
1369 | priv->hw->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS; | ||
1370 | |||
1357 | err = iwl_setup_interface(priv, ctx); | 1371 | err = iwl_setup_interface(priv, ctx); |
1358 | if (!err || reset) | 1372 | if (!err || reset) |
1359 | goto out; | 1373 | goto out; |
diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c index 7ff3f1430678..408132cf83c1 100644 --- a/drivers/net/wireless/iwlwifi/dvm/main.c +++ b/drivers/net/wireless/iwlwifi/dvm/main.c | |||
@@ -2114,7 +2114,7 @@ static void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) | |||
2114 | 2114 | ||
2115 | info = IEEE80211_SKB_CB(skb); | 2115 | info = IEEE80211_SKB_CB(skb); |
2116 | iwl_trans_free_tx_cmd(priv->trans, info->driver_data[1]); | 2116 | iwl_trans_free_tx_cmd(priv->trans, info->driver_data[1]); |
2117 | dev_kfree_skb_any(skb); | 2117 | ieee80211_free_txskb(priv->hw, skb); |
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | static void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) | 2120 | static void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) |
diff --git a/drivers/net/wireless/iwlwifi/dvm/rxon.c b/drivers/net/wireless/iwlwifi/dvm/rxon.c index 10896393e5a0..2830ea290502 100644 --- a/drivers/net/wireless/iwlwifi/dvm/rxon.c +++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c | |||
@@ -1012,12 +1012,12 @@ static void iwl_calc_basic_rates(struct iwl_priv *priv, | |||
1012 | * As a consequence, it's not as complicated as it sounds, just add | 1012 | * As a consequence, it's not as complicated as it sounds, just add |
1013 | * any lower rates to the ACK rate bitmap. | 1013 | * any lower rates to the ACK rate bitmap. |
1014 | */ | 1014 | */ |
1015 | if (IWL_RATE_11M_INDEX < lowest_present_ofdm) | 1015 | if (IWL_RATE_11M_INDEX < lowest_present_cck) |
1016 | ofdm |= IWL_RATE_11M_MASK >> IWL_FIRST_CCK_RATE; | 1016 | cck |= IWL_RATE_11M_MASK >> IWL_FIRST_CCK_RATE; |
1017 | if (IWL_RATE_5M_INDEX < lowest_present_ofdm) | 1017 | if (IWL_RATE_5M_INDEX < lowest_present_cck) |
1018 | ofdm |= IWL_RATE_5M_MASK >> IWL_FIRST_CCK_RATE; | 1018 | cck |= IWL_RATE_5M_MASK >> IWL_FIRST_CCK_RATE; |
1019 | if (IWL_RATE_2M_INDEX < lowest_present_ofdm) | 1019 | if (IWL_RATE_2M_INDEX < lowest_present_cck) |
1020 | ofdm |= IWL_RATE_2M_MASK >> IWL_FIRST_CCK_RATE; | 1020 | cck |= IWL_RATE_2M_MASK >> IWL_FIRST_CCK_RATE; |
1021 | /* 1M already there or needed so always add */ | 1021 | /* 1M already there or needed so always add */ |
1022 | cck |= IWL_RATE_1M_MASK >> IWL_FIRST_CCK_RATE; | 1022 | cck |= IWL_RATE_1M_MASK >> IWL_FIRST_CCK_RATE; |
1023 | 1023 | ||
diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c index 17c8e5d82681..bb69f8f90b3b 100644 --- a/drivers/net/wireless/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/iwlwifi/pcie/rx.c | |||
@@ -321,6 +321,14 @@ static void iwl_rx_allocate(struct iwl_trans *trans, gfp_t priority) | |||
321 | dma_map_page(trans->dev, page, 0, | 321 | dma_map_page(trans->dev, page, 0, |
322 | PAGE_SIZE << trans_pcie->rx_page_order, | 322 | PAGE_SIZE << trans_pcie->rx_page_order, |
323 | DMA_FROM_DEVICE); | 323 | DMA_FROM_DEVICE); |
324 | if (dma_mapping_error(trans->dev, rxb->page_dma)) { | ||
325 | rxb->page = NULL; | ||
326 | spin_lock_irqsave(&rxq->lock, flags); | ||
327 | list_add(&rxb->list, &rxq->rx_used); | ||
328 | spin_unlock_irqrestore(&rxq->lock, flags); | ||
329 | __free_pages(page, trans_pcie->rx_page_order); | ||
330 | return; | ||
331 | } | ||
324 | /* dma address must be no more than 36 bits */ | 332 | /* dma address must be no more than 36 bits */ |
325 | BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); | 333 | BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); |
326 | /* and also 256 byte aligned! */ | 334 | /* and also 256 byte aligned! */ |
@@ -488,8 +496,19 @@ static void iwl_rx_handle_rxbuf(struct iwl_trans *trans, | |||
488 | dma_map_page(trans->dev, rxb->page, 0, | 496 | dma_map_page(trans->dev, rxb->page, 0, |
489 | PAGE_SIZE << trans_pcie->rx_page_order, | 497 | PAGE_SIZE << trans_pcie->rx_page_order, |
490 | DMA_FROM_DEVICE); | 498 | DMA_FROM_DEVICE); |
491 | list_add_tail(&rxb->list, &rxq->rx_free); | 499 | if (dma_mapping_error(trans->dev, rxb->page_dma)) { |
492 | rxq->free_count++; | 500 | /* |
501 | * free the page(s) as well to not break | ||
502 | * the invariant that the items on the used | ||
503 | * list have no page(s) | ||
504 | */ | ||
505 | __free_pages(rxb->page, trans_pcie->rx_page_order); | ||
506 | rxb->page = NULL; | ||
507 | list_add_tail(&rxb->list, &rxq->rx_used); | ||
508 | } else { | ||
509 | list_add_tail(&rxb->list, &rxq->rx_free); | ||
510 | rxq->free_count++; | ||
511 | } | ||
493 | } else | 512 | } else |
494 | list_add_tail(&rxb->list, &rxq->rx_used); | 513 | list_add_tail(&rxb->list, &rxq->rx_used); |
495 | spin_unlock_irqrestore(&rxq->lock, flags); | 514 | spin_unlock_irqrestore(&rxq->lock, flags); |
diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c index 105e3af3c621..79a4ddc002d3 100644 --- a/drivers/net/wireless/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/iwlwifi/pcie/tx.c | |||
@@ -480,20 +480,12 @@ void iwl_trans_pcie_txq_enable(struct iwl_trans *trans, int txq_id, int fifo, | |||
480 | void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id) | 480 | void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id) |
481 | { | 481 | { |
482 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 482 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
483 | u16 rd_ptr, wr_ptr; | ||
484 | int n_bd = trans_pcie->txq[txq_id].q.n_bd; | ||
485 | 483 | ||
486 | if (!test_and_clear_bit(txq_id, trans_pcie->queue_used)) { | 484 | if (!test_and_clear_bit(txq_id, trans_pcie->queue_used)) { |
487 | WARN_ONCE(1, "queue %d not used", txq_id); | 485 | WARN_ONCE(1, "queue %d not used", txq_id); |
488 | return; | 486 | return; |
489 | } | 487 | } |
490 | 488 | ||
491 | rd_ptr = iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq_id)) & (n_bd - 1); | ||
492 | wr_ptr = iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq_id)); | ||
493 | |||
494 | WARN_ONCE(rd_ptr != wr_ptr, "queue %d isn't empty: [%d,%d]", | ||
495 | txq_id, rd_ptr, wr_ptr); | ||
496 | |||
497 | iwl_txq_set_inactive(trans, txq_id); | 489 | iwl_txq_set_inactive(trans, txq_id); |
498 | IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", txq_id); | 490 | IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", txq_id); |
499 | } | 491 | } |
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c index 8d465107f52b..ae9010ed58de 100644 --- a/drivers/net/wireless/mwifiex/cmdevt.c +++ b/drivers/net/wireless/mwifiex/cmdevt.c | |||
@@ -890,9 +890,6 @@ mwifiex_cmd_timeout_func(unsigned long function_context) | |||
890 | return; | 890 | return; |
891 | } | 891 | } |
892 | cmd_node = adapter->curr_cmd; | 892 | cmd_node = adapter->curr_cmd; |
893 | if (cmd_node->wait_q_enabled) | ||
894 | adapter->cmd_wait_q.status = -ETIMEDOUT; | ||
895 | |||
896 | if (cmd_node) { | 893 | if (cmd_node) { |
897 | adapter->dbg.timeout_cmd_id = | 894 | adapter->dbg.timeout_cmd_id = |
898 | adapter->dbg.last_cmd_id[adapter->dbg.last_cmd_index]; | 895 | adapter->dbg.last_cmd_id[adapter->dbg.last_cmd_index]; |
@@ -938,6 +935,14 @@ mwifiex_cmd_timeout_func(unsigned long function_context) | |||
938 | 935 | ||
939 | dev_err(adapter->dev, "ps_mode=%d ps_state=%d\n", | 936 | dev_err(adapter->dev, "ps_mode=%d ps_state=%d\n", |
940 | adapter->ps_mode, adapter->ps_state); | 937 | adapter->ps_mode, adapter->ps_state); |
938 | |||
939 | if (cmd_node->wait_q_enabled) { | ||
940 | adapter->cmd_wait_q.status = -ETIMEDOUT; | ||
941 | wake_up_interruptible(&adapter->cmd_wait_q.wait); | ||
942 | mwifiex_cancel_pending_ioctl(adapter); | ||
943 | /* reset cmd_sent flag to unblock new commands */ | ||
944 | adapter->cmd_sent = false; | ||
945 | } | ||
941 | } | 946 | } |
942 | if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) | 947 | if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) |
943 | mwifiex_init_fw_complete(adapter); | 948 | mwifiex_init_fw_complete(adapter); |
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index fc8a9bfa1248..82cf0fa2d9f6 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c | |||
@@ -161,7 +161,6 @@ static int mwifiex_sdio_suspend(struct device *dev) | |||
161 | struct sdio_mmc_card *card; | 161 | struct sdio_mmc_card *card; |
162 | struct mwifiex_adapter *adapter; | 162 | struct mwifiex_adapter *adapter; |
163 | mmc_pm_flag_t pm_flag = 0; | 163 | mmc_pm_flag_t pm_flag = 0; |
164 | int hs_actived = 0; | ||
165 | int i; | 164 | int i; |
166 | int ret = 0; | 165 | int ret = 0; |
167 | 166 | ||
@@ -188,12 +187,14 @@ static int mwifiex_sdio_suspend(struct device *dev) | |||
188 | adapter = card->adapter; | 187 | adapter = card->adapter; |
189 | 188 | ||
190 | /* Enable the Host Sleep */ | 189 | /* Enable the Host Sleep */ |
191 | hs_actived = mwifiex_enable_hs(adapter); | 190 | if (!mwifiex_enable_hs(adapter)) { |
192 | if (hs_actived) { | 191 | dev_err(adapter->dev, "cmd: failed to suspend\n"); |
193 | pr_debug("cmd: suspend with MMC_PM_KEEP_POWER\n"); | 192 | return -EFAULT; |
194 | ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); | ||
195 | } | 193 | } |
196 | 194 | ||
195 | dev_dbg(adapter->dev, "cmd: suspend with MMC_PM_KEEP_POWER\n"); | ||
196 | ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); | ||
197 | |||
197 | /* Indicate device suspended */ | 198 | /* Indicate device suspended */ |
198 | adapter->is_suspended = true; | 199 | adapter->is_suspended = true; |
199 | 200 | ||
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index 9970c2b1b199..b7e6607e6b6d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | |||
@@ -297,6 +297,7 @@ static struct usb_device_id rtl8192c_usb_ids[] = { | |||
297 | /*=== Customer ID ===*/ | 297 | /*=== Customer ID ===*/ |
298 | /****** 8188CU ********/ | 298 | /****** 8188CU ********/ |
299 | {RTL_USB_DEVICE(0x050d, 0x1102, rtl92cu_hal_cfg)}, /*Belkin - Edimax*/ | 299 | {RTL_USB_DEVICE(0x050d, 0x1102, rtl92cu_hal_cfg)}, /*Belkin - Edimax*/ |
300 | {RTL_USB_DEVICE(0x050d, 0x11f2, rtl92cu_hal_cfg)}, /*Belkin - ISY*/ | ||
300 | {RTL_USB_DEVICE(0x06f8, 0xe033, rtl92cu_hal_cfg)}, /*Hercules - Edimax*/ | 301 | {RTL_USB_DEVICE(0x06f8, 0xe033, rtl92cu_hal_cfg)}, /*Hercules - Edimax*/ |
301 | {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ | 302 | {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ |
302 | {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ | 303 | {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ |
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index caa011008cd0..fc24eb9b3948 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
@@ -452,29 +452,85 @@ static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev, | |||
452 | /* Grant backend access to each skb fragment page. */ | 452 | /* Grant backend access to each skb fragment page. */ |
453 | for (i = 0; i < frags; i++) { | 453 | for (i = 0; i < frags; i++) { |
454 | skb_frag_t *frag = skb_shinfo(skb)->frags + i; | 454 | skb_frag_t *frag = skb_shinfo(skb)->frags + i; |
455 | struct page *page = skb_frag_page(frag); | ||
455 | 456 | ||
456 | tx->flags |= XEN_NETTXF_more_data; | 457 | len = skb_frag_size(frag); |
458 | offset = frag->page_offset; | ||
457 | 459 | ||
458 | id = get_id_from_freelist(&np->tx_skb_freelist, np->tx_skbs); | 460 | /* Data must not cross a page boundary. */ |
459 | np->tx_skbs[id].skb = skb_get(skb); | 461 | BUG_ON(len + offset > PAGE_SIZE<<compound_order(page)); |
460 | tx = RING_GET_REQUEST(&np->tx, prod++); | ||
461 | tx->id = id; | ||
462 | ref = gnttab_claim_grant_reference(&np->gref_tx_head); | ||
463 | BUG_ON((signed short)ref < 0); | ||
464 | 462 | ||
465 | mfn = pfn_to_mfn(page_to_pfn(skb_frag_page(frag))); | 463 | /* Skip unused frames from start of page */ |
466 | gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id, | 464 | page += offset >> PAGE_SHIFT; |
467 | mfn, GNTMAP_readonly); | 465 | offset &= ~PAGE_MASK; |
468 | 466 | ||
469 | tx->gref = np->grant_tx_ref[id] = ref; | 467 | while (len > 0) { |
470 | tx->offset = frag->page_offset; | 468 | unsigned long bytes; |
471 | tx->size = skb_frag_size(frag); | 469 | |
472 | tx->flags = 0; | 470 | BUG_ON(offset >= PAGE_SIZE); |
471 | |||
472 | bytes = PAGE_SIZE - offset; | ||
473 | if (bytes > len) | ||
474 | bytes = len; | ||
475 | |||
476 | tx->flags |= XEN_NETTXF_more_data; | ||
477 | |||
478 | id = get_id_from_freelist(&np->tx_skb_freelist, | ||
479 | np->tx_skbs); | ||
480 | np->tx_skbs[id].skb = skb_get(skb); | ||
481 | tx = RING_GET_REQUEST(&np->tx, prod++); | ||
482 | tx->id = id; | ||
483 | ref = gnttab_claim_grant_reference(&np->gref_tx_head); | ||
484 | BUG_ON((signed short)ref < 0); | ||
485 | |||
486 | mfn = pfn_to_mfn(page_to_pfn(page)); | ||
487 | gnttab_grant_foreign_access_ref(ref, | ||
488 | np->xbdev->otherend_id, | ||
489 | mfn, GNTMAP_readonly); | ||
490 | |||
491 | tx->gref = np->grant_tx_ref[id] = ref; | ||
492 | tx->offset = offset; | ||
493 | tx->size = bytes; | ||
494 | tx->flags = 0; | ||
495 | |||
496 | offset += bytes; | ||
497 | len -= bytes; | ||
498 | |||
499 | /* Next frame */ | ||
500 | if (offset == PAGE_SIZE && len) { | ||
501 | BUG_ON(!PageCompound(page)); | ||
502 | page++; | ||
503 | offset = 0; | ||
504 | } | ||
505 | } | ||
473 | } | 506 | } |
474 | 507 | ||
475 | np->tx.req_prod_pvt = prod; | 508 | np->tx.req_prod_pvt = prod; |
476 | } | 509 | } |
477 | 510 | ||
511 | /* | ||
512 | * Count how many ring slots are required to send the frags of this | ||
513 | * skb. Each frag might be a compound page. | ||
514 | */ | ||
515 | static int xennet_count_skb_frag_slots(struct sk_buff *skb) | ||
516 | { | ||
517 | int i, frags = skb_shinfo(skb)->nr_frags; | ||
518 | int pages = 0; | ||
519 | |||
520 | for (i = 0; i < frags; i++) { | ||
521 | skb_frag_t *frag = skb_shinfo(skb)->frags + i; | ||
522 | unsigned long size = skb_frag_size(frag); | ||
523 | unsigned long offset = frag->page_offset; | ||
524 | |||
525 | /* Skip unused frames from start of page */ | ||
526 | offset &= ~PAGE_MASK; | ||
527 | |||
528 | pages += PFN_UP(offset + size); | ||
529 | } | ||
530 | |||
531 | return pages; | ||
532 | } | ||
533 | |||
478 | static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) | 534 | static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) |
479 | { | 535 | { |
480 | unsigned short id; | 536 | unsigned short id; |
@@ -487,23 +543,23 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
487 | grant_ref_t ref; | 543 | grant_ref_t ref; |
488 | unsigned long mfn; | 544 | unsigned long mfn; |
489 | int notify; | 545 | int notify; |
490 | int frags = skb_shinfo(skb)->nr_frags; | 546 | int slots; |
491 | unsigned int offset = offset_in_page(data); | 547 | unsigned int offset = offset_in_page(data); |
492 | unsigned int len = skb_headlen(skb); | 548 | unsigned int len = skb_headlen(skb); |
493 | unsigned long flags; | 549 | unsigned long flags; |
494 | 550 | ||
495 | frags += DIV_ROUND_UP(offset + len, PAGE_SIZE); | 551 | slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) + |
496 | if (unlikely(frags > MAX_SKB_FRAGS + 1)) { | 552 | xennet_count_skb_frag_slots(skb); |
497 | printk(KERN_ALERT "xennet: skb rides the rocket: %d frags\n", | 553 | if (unlikely(slots > MAX_SKB_FRAGS + 1)) { |
498 | frags); | 554 | net_alert_ratelimited( |
499 | dump_stack(); | 555 | "xennet: skb rides the rocket: %d slots\n", slots); |
500 | goto drop; | 556 | goto drop; |
501 | } | 557 | } |
502 | 558 | ||
503 | spin_lock_irqsave(&np->tx_lock, flags); | 559 | spin_lock_irqsave(&np->tx_lock, flags); |
504 | 560 | ||
505 | if (unlikely(!netif_carrier_ok(dev) || | 561 | if (unlikely(!netif_carrier_ok(dev) || |
506 | (frags > 1 && !xennet_can_sg(dev)) || | 562 | (slots > 1 && !xennet_can_sg(dev)) || |
507 | netif_needs_gso(skb, netif_skb_features(skb)))) { | 563 | netif_needs_gso(skb, netif_skb_features(skb)))) { |
508 | spin_unlock_irqrestore(&np->tx_lock, flags); | 564 | spin_unlock_irqrestore(&np->tx_lock, flags); |
509 | goto drop; | 565 | goto drop; |
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 97c440a8cd61..30ae18a03a9c 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c | |||
@@ -698,13 +698,14 @@ static void pn533_wq_cmd(struct work_struct *work) | |||
698 | 698 | ||
699 | cmd = list_first_entry(&dev->cmd_queue, struct pn533_cmd, queue); | 699 | cmd = list_first_entry(&dev->cmd_queue, struct pn533_cmd, queue); |
700 | 700 | ||
701 | list_del(&cmd->queue); | ||
702 | |||
701 | mutex_unlock(&dev->cmd_lock); | 703 | mutex_unlock(&dev->cmd_lock); |
702 | 704 | ||
703 | __pn533_send_cmd_frame_async(dev, cmd->out_frame, cmd->in_frame, | 705 | __pn533_send_cmd_frame_async(dev, cmd->out_frame, cmd->in_frame, |
704 | cmd->in_frame_len, cmd->cmd_complete, | 706 | cmd->in_frame_len, cmd->cmd_complete, |
705 | cmd->arg, cmd->flags); | 707 | cmd->arg, cmd->flags); |
706 | 708 | ||
707 | list_del(&cmd->queue); | ||
708 | kfree(cmd); | 709 | kfree(cmd); |
709 | } | 710 | } |
710 | 711 | ||
@@ -1678,11 +1679,14 @@ static void pn533_deactivate_target(struct nfc_dev *nfc_dev, | |||
1678 | static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, | 1679 | static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, |
1679 | u8 *params, int params_len) | 1680 | u8 *params, int params_len) |
1680 | { | 1681 | { |
1681 | struct pn533_cmd_jump_dep *cmd; | ||
1682 | struct pn533_cmd_jump_dep_response *resp; | 1682 | struct pn533_cmd_jump_dep_response *resp; |
1683 | struct nfc_target nfc_target; | 1683 | struct nfc_target nfc_target; |
1684 | u8 target_gt_len; | 1684 | u8 target_gt_len; |
1685 | int rc; | 1685 | int rc; |
1686 | struct pn533_cmd_jump_dep *cmd = (struct pn533_cmd_jump_dep *)arg; | ||
1687 | u8 active = cmd->active; | ||
1688 | |||
1689 | kfree(arg); | ||
1686 | 1690 | ||
1687 | if (params_len == -ENOENT) { | 1691 | if (params_len == -ENOENT) { |
1688 | nfc_dev_dbg(&dev->interface->dev, ""); | 1692 | nfc_dev_dbg(&dev->interface->dev, ""); |
@@ -1704,7 +1708,6 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, | |||
1704 | } | 1708 | } |
1705 | 1709 | ||
1706 | resp = (struct pn533_cmd_jump_dep_response *) params; | 1710 | resp = (struct pn533_cmd_jump_dep_response *) params; |
1707 | cmd = (struct pn533_cmd_jump_dep *) arg; | ||
1708 | rc = resp->status & PN533_CMD_RET_MASK; | 1711 | rc = resp->status & PN533_CMD_RET_MASK; |
1709 | if (rc != PN533_CMD_RET_SUCCESS) { | 1712 | if (rc != PN533_CMD_RET_SUCCESS) { |
1710 | nfc_dev_err(&dev->interface->dev, | 1713 | nfc_dev_err(&dev->interface->dev, |
@@ -1734,7 +1737,7 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, | |||
1734 | if (rc == 0) | 1737 | if (rc == 0) |
1735 | rc = nfc_dep_link_is_up(dev->nfc_dev, | 1738 | rc = nfc_dep_link_is_up(dev->nfc_dev, |
1736 | dev->nfc_dev->targets[0].idx, | 1739 | dev->nfc_dev->targets[0].idx, |
1737 | !cmd->active, NFC_RF_INITIATOR); | 1740 | !active, NFC_RF_INITIATOR); |
1738 | 1741 | ||
1739 | return 0; | 1742 | return 0; |
1740 | } | 1743 | } |
@@ -1819,12 +1822,8 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
1819 | rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame, | 1822 | rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame, |
1820 | dev->in_maxlen, pn533_in_dep_link_up_complete, | 1823 | dev->in_maxlen, pn533_in_dep_link_up_complete, |
1821 | cmd, GFP_KERNEL); | 1824 | cmd, GFP_KERNEL); |
1822 | if (rc) | 1825 | if (rc < 0) |
1823 | goto out; | 1826 | kfree(cmd); |
1824 | |||
1825 | |||
1826 | out: | ||
1827 | kfree(cmd); | ||
1828 | 1827 | ||
1829 | return rc; | 1828 | return rc; |
1830 | } | 1829 | } |
@@ -2078,8 +2077,12 @@ error: | |||
2078 | static int pn533_tm_send_complete(struct pn533 *dev, void *arg, | 2077 | static int pn533_tm_send_complete(struct pn533 *dev, void *arg, |
2079 | u8 *params, int params_len) | 2078 | u8 *params, int params_len) |
2080 | { | 2079 | { |
2080 | struct sk_buff *skb_out = arg; | ||
2081 | |||
2081 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); | 2082 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); |
2082 | 2083 | ||
2084 | dev_kfree_skb(skb_out); | ||
2085 | |||
2083 | if (params_len < 0) { | 2086 | if (params_len < 0) { |
2084 | nfc_dev_err(&dev->interface->dev, | 2087 | nfc_dev_err(&dev->interface->dev, |
2085 | "Error %d when sending data", | 2088 | "Error %d when sending data", |
@@ -2117,7 +2120,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb) | |||
2117 | 2120 | ||
2118 | rc = pn533_send_cmd_frame_async(dev, out_frame, dev->in_frame, | 2121 | rc = pn533_send_cmd_frame_async(dev, out_frame, dev->in_frame, |
2119 | dev->in_maxlen, pn533_tm_send_complete, | 2122 | dev->in_maxlen, pn533_tm_send_complete, |
2120 | NULL, GFP_KERNEL); | 2123 | skb, GFP_KERNEL); |
2121 | if (rc) { | 2124 | if (rc) { |
2122 | nfc_dev_err(&dev->interface->dev, | 2125 | nfc_dev_err(&dev->interface->dev, |
2123 | "Error %d when trying to send data", rc); | 2126 | "Error %d when trying to send data", rc); |
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index e9c11edb0197..390ab69ea569 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig | |||
@@ -180,7 +180,7 @@ config PINCTRL_COH901 | |||
180 | ports of 8 GPIO pins each. | 180 | ports of 8 GPIO pins each. |
181 | 181 | ||
182 | config PINCTRL_SAMSUNG | 182 | config PINCTRL_SAMSUNG |
183 | bool "Samsung pinctrl driver" | 183 | bool |
184 | depends on OF && GPIOLIB | 184 | depends on OF && GPIOLIB |
185 | select PINMUX | 185 | select PINMUX |
186 | select PINCONF | 186 | select PINCONF |
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index c17ae22567e0..0c6fcb461faf 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c | |||
@@ -401,7 +401,7 @@ EXPORT_SYMBOL_GPL(rio_release_inb_pwrite); | |||
401 | /** | 401 | /** |
402 | * rio_map_inb_region -- Map inbound memory region. | 402 | * rio_map_inb_region -- Map inbound memory region. |
403 | * @mport: Master port. | 403 | * @mport: Master port. |
404 | * @lstart: physical address of memory region to be mapped | 404 | * @local: physical address of memory region to be mapped |
405 | * @rbase: RIO base address assigned to this window | 405 | * @rbase: RIO base address assigned to this window |
406 | * @size: Size of the memory region | 406 | * @size: Size of the memory region |
407 | * @rflags: Flags for mapping. | 407 | * @rflags: Flags for mapping. |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5c4829cba6a6..e872c8be080e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1381,22 +1381,14 @@ struct regulator *regulator_get_exclusive(struct device *dev, const char *id) | |||
1381 | } | 1381 | } |
1382 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); | 1382 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); |
1383 | 1383 | ||
1384 | /** | 1384 | /* Locks held by regulator_put() */ |
1385 | * regulator_put - "free" the regulator source | 1385 | static void _regulator_put(struct regulator *regulator) |
1386 | * @regulator: regulator source | ||
1387 | * | ||
1388 | * Note: drivers must ensure that all regulator_enable calls made on this | ||
1389 | * regulator source are balanced by regulator_disable calls prior to calling | ||
1390 | * this function. | ||
1391 | */ | ||
1392 | void regulator_put(struct regulator *regulator) | ||
1393 | { | 1386 | { |
1394 | struct regulator_dev *rdev; | 1387 | struct regulator_dev *rdev; |
1395 | 1388 | ||
1396 | if (regulator == NULL || IS_ERR(regulator)) | 1389 | if (regulator == NULL || IS_ERR(regulator)) |
1397 | return; | 1390 | return; |
1398 | 1391 | ||
1399 | mutex_lock(®ulator_list_mutex); | ||
1400 | rdev = regulator->rdev; | 1392 | rdev = regulator->rdev; |
1401 | 1393 | ||
1402 | debugfs_remove_recursive(regulator->debugfs); | 1394 | debugfs_remove_recursive(regulator->debugfs); |
@@ -1412,6 +1404,20 @@ void regulator_put(struct regulator *regulator) | |||
1412 | rdev->exclusive = 0; | 1404 | rdev->exclusive = 0; |
1413 | 1405 | ||
1414 | module_put(rdev->owner); | 1406 | module_put(rdev->owner); |
1407 | } | ||
1408 | |||
1409 | /** | ||
1410 | * regulator_put - "free" the regulator source | ||
1411 | * @regulator: regulator source | ||
1412 | * | ||
1413 | * Note: drivers must ensure that all regulator_enable calls made on this | ||
1414 | * regulator source are balanced by regulator_disable calls prior to calling | ||
1415 | * this function. | ||
1416 | */ | ||
1417 | void regulator_put(struct regulator *regulator) | ||
1418 | { | ||
1419 | mutex_lock(®ulator_list_mutex); | ||
1420 | _regulator_put(regulator); | ||
1415 | mutex_unlock(®ulator_list_mutex); | 1421 | mutex_unlock(®ulator_list_mutex); |
1416 | } | 1422 | } |
1417 | EXPORT_SYMBOL_GPL(regulator_put); | 1423 | EXPORT_SYMBOL_GPL(regulator_put); |
@@ -1974,7 +1980,7 @@ int regulator_is_supported_voltage(struct regulator *regulator, | |||
1974 | if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { | 1980 | if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { |
1975 | ret = regulator_get_voltage(regulator); | 1981 | ret = regulator_get_voltage(regulator); |
1976 | if (ret >= 0) | 1982 | if (ret >= 0) |
1977 | return (min_uV >= ret && ret <= max_uV); | 1983 | return (min_uV <= ret && ret <= max_uV); |
1978 | else | 1984 | else |
1979 | return ret; | 1985 | return ret; |
1980 | } | 1986 | } |
@@ -3365,7 +3371,7 @@ regulator_register(const struct regulator_desc *regulator_desc, | |||
3365 | if (ret != 0) { | 3371 | if (ret != 0) { |
3366 | rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", | 3372 | rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", |
3367 | config->ena_gpio, ret); | 3373 | config->ena_gpio, ret); |
3368 | goto clean; | 3374 | goto wash; |
3369 | } | 3375 | } |
3370 | 3376 | ||
3371 | rdev->ena_gpio = config->ena_gpio; | 3377 | rdev->ena_gpio = config->ena_gpio; |
@@ -3445,10 +3451,11 @@ unset_supplies: | |||
3445 | 3451 | ||
3446 | scrub: | 3452 | scrub: |
3447 | if (rdev->supply) | 3453 | if (rdev->supply) |
3448 | regulator_put(rdev->supply); | 3454 | _regulator_put(rdev->supply); |
3449 | if (rdev->ena_gpio) | 3455 | if (rdev->ena_gpio) |
3450 | gpio_free(rdev->ena_gpio); | 3456 | gpio_free(rdev->ena_gpio); |
3451 | kfree(rdev->constraints); | 3457 | kfree(rdev->constraints); |
3458 | wash: | ||
3452 | device_unregister(&rdev->dev); | 3459 | device_unregister(&rdev->dev); |
3453 | /* device core frees rdev */ | 3460 | /* device core frees rdev */ |
3454 | rdev = ERR_PTR(ret); | 3461 | rdev = ERR_PTR(ret); |
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index e7a4780e93db..9e198e590675 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c | |||
@@ -120,15 +120,11 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev, | |||
120 | return vq; | 120 | return vq; |
121 | } | 121 | } |
122 | 122 | ||
123 | static void rproc_virtio_del_vqs(struct virtio_device *vdev) | 123 | static void __rproc_virtio_del_vqs(struct virtio_device *vdev) |
124 | { | 124 | { |
125 | struct virtqueue *vq, *n; | 125 | struct virtqueue *vq, *n; |
126 | struct rproc *rproc = vdev_to_rproc(vdev); | ||
127 | struct rproc_vring *rvring; | 126 | struct rproc_vring *rvring; |
128 | 127 | ||
129 | /* power down the remote processor before deleting vqs */ | ||
130 | rproc_shutdown(rproc); | ||
131 | |||
132 | list_for_each_entry_safe(vq, n, &vdev->vqs, list) { | 128 | list_for_each_entry_safe(vq, n, &vdev->vqs, list) { |
133 | rvring = vq->priv; | 129 | rvring = vq->priv; |
134 | rvring->vq = NULL; | 130 | rvring->vq = NULL; |
@@ -137,6 +133,16 @@ static void rproc_virtio_del_vqs(struct virtio_device *vdev) | |||
137 | } | 133 | } |
138 | } | 134 | } |
139 | 135 | ||
136 | static void rproc_virtio_del_vqs(struct virtio_device *vdev) | ||
137 | { | ||
138 | struct rproc *rproc = vdev_to_rproc(vdev); | ||
139 | |||
140 | /* power down the remote processor before deleting vqs */ | ||
141 | rproc_shutdown(rproc); | ||
142 | |||
143 | __rproc_virtio_del_vqs(vdev); | ||
144 | } | ||
145 | |||
140 | static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, | 146 | static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, |
141 | struct virtqueue *vqs[], | 147 | struct virtqueue *vqs[], |
142 | vq_callback_t *callbacks[], | 148 | vq_callback_t *callbacks[], |
@@ -163,7 +169,7 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, | |||
163 | return 0; | 169 | return 0; |
164 | 170 | ||
165 | error: | 171 | error: |
166 | rproc_virtio_del_vqs(vdev); | 172 | __rproc_virtio_del_vqs(vdev); |
167 | return ret; | 173 | return ret; |
168 | } | 174 | } |
169 | 175 | ||
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c index 7a82337e4dee..073108dcf9e7 100644 --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c | |||
@@ -288,11 +288,11 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev) | |||
288 | static int __devexit tps65910_rtc_remove(struct platform_device *pdev) | 288 | static int __devexit tps65910_rtc_remove(struct platform_device *pdev) |
289 | { | 289 | { |
290 | /* leave rtc running, but disable irqs */ | 290 | /* leave rtc running, but disable irqs */ |
291 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 291 | struct tps65910_rtc *tps_rtc = platform_get_drvdata(pdev); |
292 | 292 | ||
293 | tps65910_rtc_alarm_irq_enable(&rtc->dev, 0); | 293 | tps65910_rtc_alarm_irq_enable(&pdev->dev, 0); |
294 | 294 | ||
295 | rtc_device_unregister(rtc); | 295 | rtc_device_unregister(tps_rtc->rtc); |
296 | return 0; | 296 | return 0; |
297 | } | 297 | } |
298 | 298 | ||
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 9ffb6d5f17aa..4ed343e4eb41 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #define RAW3215_NR_CCWS 3 | 44 | #define RAW3215_NR_CCWS 3 |
45 | #define RAW3215_TIMEOUT HZ/10 /* time for delayed output */ | 45 | #define RAW3215_TIMEOUT HZ/10 /* time for delayed output */ |
46 | 46 | ||
47 | #define RAW3215_FIXED 1 /* 3215 console device is not be freed */ | ||
48 | #define RAW3215_WORKING 4 /* set if a request is being worked on */ | 47 | #define RAW3215_WORKING 4 /* set if a request is being worked on */ |
49 | #define RAW3215_THROTTLED 8 /* set if reading is disabled */ | 48 | #define RAW3215_THROTTLED 8 /* set if reading is disabled */ |
50 | #define RAW3215_STOPPED 16 /* set if writing is disabled */ | 49 | #define RAW3215_STOPPED 16 /* set if writing is disabled */ |
@@ -339,8 +338,10 @@ static void raw3215_wakeup(unsigned long data) | |||
339 | struct tty_struct *tty; | 338 | struct tty_struct *tty; |
340 | 339 | ||
341 | tty = tty_port_tty_get(&raw->port); | 340 | tty = tty_port_tty_get(&raw->port); |
342 | tty_wakeup(tty); | 341 | if (tty) { |
343 | tty_kref_put(tty); | 342 | tty_wakeup(tty); |
343 | tty_kref_put(tty); | ||
344 | } | ||
344 | } | 345 | } |
345 | 346 | ||
346 | /* | 347 | /* |
@@ -629,8 +630,7 @@ static void raw3215_shutdown(struct raw3215_info *raw) | |||
629 | DECLARE_WAITQUEUE(wait, current); | 630 | DECLARE_WAITQUEUE(wait, current); |
630 | unsigned long flags; | 631 | unsigned long flags; |
631 | 632 | ||
632 | if (!(raw->port.flags & ASYNC_INITIALIZED) || | 633 | if (!(raw->port.flags & ASYNC_INITIALIZED)) |
633 | (raw->flags & RAW3215_FIXED)) | ||
634 | return; | 634 | return; |
635 | /* Wait for outstanding requests, then free irq */ | 635 | /* Wait for outstanding requests, then free irq */ |
636 | spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); | 636 | spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); |
@@ -926,8 +926,6 @@ static int __init con3215_init(void) | |||
926 | dev_set_drvdata(&cdev->dev, raw); | 926 | dev_set_drvdata(&cdev->dev, raw); |
927 | cdev->handler = raw3215_irq; | 927 | cdev->handler = raw3215_irq; |
928 | 928 | ||
929 | raw->flags |= RAW3215_FIXED; | ||
930 | |||
931 | /* Request the console irq */ | 929 | /* Request the console irq */ |
932 | if (raw3215_startup(raw) != 0) { | 930 | if (raw3215_startup(raw) != 0) { |
933 | raw3215_free_info(raw); | 931 | raw3215_free_info(raw); |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 3e25d3150456..4d6ba00d0047 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
@@ -2942,13 +2942,33 @@ static int qeth_query_ipassists_cb(struct qeth_card *card, | |||
2942 | QETH_DBF_TEXT(SETUP, 2, "qipasscb"); | 2942 | QETH_DBF_TEXT(SETUP, 2, "qipasscb"); |
2943 | 2943 | ||
2944 | cmd = (struct qeth_ipa_cmd *) data; | 2944 | cmd = (struct qeth_ipa_cmd *) data; |
2945 | |||
2946 | switch (cmd->hdr.return_code) { | ||
2947 | case IPA_RC_NOTSUPP: | ||
2948 | case IPA_RC_L2_UNSUPPORTED_CMD: | ||
2949 | QETH_DBF_TEXT(SETUP, 2, "ipaunsup"); | ||
2950 | card->options.ipa4.supported_funcs |= IPA_SETADAPTERPARMS; | ||
2951 | card->options.ipa6.supported_funcs |= IPA_SETADAPTERPARMS; | ||
2952 | return -0; | ||
2953 | default: | ||
2954 | if (cmd->hdr.return_code) { | ||
2955 | QETH_DBF_MESSAGE(1, "%s IPA_CMD_QIPASSIST: Unhandled " | ||
2956 | "rc=%d\n", | ||
2957 | dev_name(&card->gdev->dev), | ||
2958 | cmd->hdr.return_code); | ||
2959 | return 0; | ||
2960 | } | ||
2961 | } | ||
2962 | |||
2945 | if (cmd->hdr.prot_version == QETH_PROT_IPV4) { | 2963 | if (cmd->hdr.prot_version == QETH_PROT_IPV4) { |
2946 | card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported; | 2964 | card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported; |
2947 | card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; | 2965 | card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; |
2948 | } else { | 2966 | } else if (cmd->hdr.prot_version == QETH_PROT_IPV6) { |
2949 | card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported; | 2967 | card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported; |
2950 | card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; | 2968 | card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; |
2951 | } | 2969 | } else |
2970 | QETH_DBF_MESSAGE(1, "%s IPA_CMD_QIPASSIST: Flawed LIC detected" | ||
2971 | "\n", dev_name(&card->gdev->dev)); | ||
2952 | QETH_DBF_TEXT(SETUP, 2, "suppenbl"); | 2972 | QETH_DBF_TEXT(SETUP, 2, "suppenbl"); |
2953 | QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_supported); | 2973 | QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_supported); |
2954 | QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_enabled); | 2974 | QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_enabled); |
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index e67e0258aec5..fddb62654b6a 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c | |||
@@ -626,10 +626,13 @@ static int qeth_l2_request_initial_mac(struct qeth_card *card) | |||
626 | QETH_DBF_TEXT(SETUP, 2, "doL2init"); | 626 | QETH_DBF_TEXT(SETUP, 2, "doL2init"); |
627 | QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card)); | 627 | QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card)); |
628 | 628 | ||
629 | rc = qeth_query_setadapterparms(card); | 629 | if (qeth_is_supported(card, IPA_SETADAPTERPARMS)) { |
630 | if (rc) { | 630 | rc = qeth_query_setadapterparms(card); |
631 | QETH_DBF_MESSAGE(2, "could not query adapter parameters on " | 631 | if (rc) { |
632 | "device %s: x%x\n", CARD_BUS_ID(card), rc); | 632 | QETH_DBF_MESSAGE(2, "could not query adapter " |
633 | "parameters on device %s: x%x\n", | ||
634 | CARD_BUS_ID(card), rc); | ||
635 | } | ||
633 | } | 636 | } |
634 | 637 | ||
635 | if (card->info.type == QETH_CARD_TYPE_IQD || | 638 | if (card->info.type == QETH_CARD_TYPE_IQD || |
@@ -676,7 +679,7 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p) | |||
676 | return -ERESTARTSYS; | 679 | return -ERESTARTSYS; |
677 | } | 680 | } |
678 | rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]); | 681 | rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]); |
679 | if (!rc) | 682 | if (!rc || (rc == IPA_RC_L2_MAC_NOT_FOUND)) |
680 | rc = qeth_l2_send_setmac(card, addr->sa_data); | 683 | rc = qeth_l2_send_setmac(card, addr->sa_data); |
681 | return rc ? -EINVAL : 0; | 684 | return rc ? -EINVAL : 0; |
682 | } | 685 | } |
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index c1bafc3f3fb1..9594ab62702b 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -1972,7 +1972,7 @@ sci_io_request_frame_handler(struct isci_request *ireq, | |||
1972 | frame_index, | 1972 | frame_index, |
1973 | (void **)&frame_buffer); | 1973 | (void **)&frame_buffer); |
1974 | 1974 | ||
1975 | sci_controller_copy_sata_response(&ireq->stp.req, | 1975 | sci_controller_copy_sata_response(&ireq->stp.rsp, |
1976 | frame_header, | 1976 | frame_header, |
1977 | frame_buffer); | 1977 | frame_buffer); |
1978 | 1978 | ||
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 16b7a72a70c4..3b2365c8eab2 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h | |||
@@ -1276,7 +1276,7 @@ struct megasas_evt_detail { | |||
1276 | } __attribute__ ((packed)); | 1276 | } __attribute__ ((packed)); |
1277 | 1277 | ||
1278 | struct megasas_aen_event { | 1278 | struct megasas_aen_event { |
1279 | struct work_struct hotplug_work; | 1279 | struct delayed_work hotplug_work; |
1280 | struct megasas_instance *instance; | 1280 | struct megasas_instance *instance; |
1281 | }; | 1281 | }; |
1282 | 1282 | ||
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index d2c5366aff7f..e4f2baacf1e1 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c | |||
@@ -2060,9 +2060,9 @@ megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd) | |||
2060 | } else { | 2060 | } else { |
2061 | ev->instance = instance; | 2061 | ev->instance = instance; |
2062 | instance->ev = ev; | 2062 | instance->ev = ev; |
2063 | INIT_WORK(&ev->hotplug_work, megasas_aen_polling); | 2063 | INIT_DELAYED_WORK(&ev->hotplug_work, |
2064 | schedule_delayed_work( | 2064 | megasas_aen_polling); |
2065 | (struct delayed_work *)&ev->hotplug_work, 0); | 2065 | schedule_delayed_work(&ev->hotplug_work, 0); |
2066 | } | 2066 | } |
2067 | } | 2067 | } |
2068 | } | 2068 | } |
@@ -4352,8 +4352,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state) | |||
4352 | /* cancel the delayed work if this work still in queue */ | 4352 | /* cancel the delayed work if this work still in queue */ |
4353 | if (instance->ev != NULL) { | 4353 | if (instance->ev != NULL) { |
4354 | struct megasas_aen_event *ev = instance->ev; | 4354 | struct megasas_aen_event *ev = instance->ev; |
4355 | cancel_delayed_work_sync( | 4355 | cancel_delayed_work_sync(&ev->hotplug_work); |
4356 | (struct delayed_work *)&ev->hotplug_work); | ||
4357 | instance->ev = NULL; | 4356 | instance->ev = NULL; |
4358 | } | 4357 | } |
4359 | 4358 | ||
@@ -4545,8 +4544,7 @@ static void __devexit megasas_detach_one(struct pci_dev *pdev) | |||
4545 | /* cancel the delayed work if this work still in queue*/ | 4544 | /* cancel the delayed work if this work still in queue*/ |
4546 | if (instance->ev != NULL) { | 4545 | if (instance->ev != NULL) { |
4547 | struct megasas_aen_event *ev = instance->ev; | 4546 | struct megasas_aen_event *ev = instance->ev; |
4548 | cancel_delayed_work_sync( | 4547 | cancel_delayed_work_sync(&ev->hotplug_work); |
4549 | (struct delayed_work *)&ev->hotplug_work); | ||
4550 | instance->ev = NULL; | 4548 | instance->ev = NULL; |
4551 | } | 4549 | } |
4552 | 4550 | ||
@@ -5190,7 +5188,7 @@ static void | |||
5190 | megasas_aen_polling(struct work_struct *work) | 5188 | megasas_aen_polling(struct work_struct *work) |
5191 | { | 5189 | { |
5192 | struct megasas_aen_event *ev = | 5190 | struct megasas_aen_event *ev = |
5193 | container_of(work, struct megasas_aen_event, hotplug_work); | 5191 | container_of(work, struct megasas_aen_event, hotplug_work.work); |
5194 | struct megasas_instance *instance = ev->instance; | 5192 | struct megasas_instance *instance = ev->instance; |
5195 | union megasas_evt_class_locale class_locale; | 5193 | union megasas_evt_class_locale class_locale; |
5196 | struct Scsi_Host *host; | 5194 | struct Scsi_Host *host; |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 2936b447cae9..2c0d0ec8150b 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <linux/cpu.h> | 55 | #include <linux/cpu.h> |
56 | #include <linux/mutex.h> | 56 | #include <linux/mutex.h> |
57 | #include <linux/async.h> | 57 | #include <linux/async.h> |
58 | #include <asm/unaligned.h> | ||
58 | 59 | ||
59 | #include <scsi/scsi.h> | 60 | #include <scsi/scsi.h> |
60 | #include <scsi/scsi_cmnd.h> | 61 | #include <scsi/scsi_cmnd.h> |
@@ -1062,6 +1063,50 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf, | |||
1062 | EXPORT_SYMBOL_GPL(scsi_get_vpd_page); | 1063 | EXPORT_SYMBOL_GPL(scsi_get_vpd_page); |
1063 | 1064 | ||
1064 | /** | 1065 | /** |
1066 | * scsi_report_opcode - Find out if a given command opcode is supported | ||
1067 | * @sdev: scsi device to query | ||
1068 | * @buffer: scratch buffer (must be at least 20 bytes long) | ||
1069 | * @len: length of buffer | ||
1070 | * @opcode: opcode for command to look up | ||
1071 | * | ||
1072 | * Uses the REPORT SUPPORTED OPERATION CODES to look up the given | ||
1073 | * opcode. Returns 0 if RSOC fails or if the command opcode is | ||
1074 | * unsupported. Returns 1 if the device claims to support the command. | ||
1075 | */ | ||
1076 | int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, | ||
1077 | unsigned int len, unsigned char opcode) | ||
1078 | { | ||
1079 | unsigned char cmd[16]; | ||
1080 | struct scsi_sense_hdr sshdr; | ||
1081 | int result; | ||
1082 | |||
1083 | if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3) | ||
1084 | return 0; | ||
1085 | |||
1086 | memset(cmd, 0, 16); | ||
1087 | cmd[0] = MAINTENANCE_IN; | ||
1088 | cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES; | ||
1089 | cmd[2] = 1; /* One command format */ | ||
1090 | cmd[3] = opcode; | ||
1091 | put_unaligned_be32(len, &cmd[6]); | ||
1092 | memset(buffer, 0, len); | ||
1093 | |||
1094 | result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, | ||
1095 | &sshdr, 30 * HZ, 3, NULL); | ||
1096 | |||
1097 | if (result && scsi_sense_valid(&sshdr) && | ||
1098 | sshdr.sense_key == ILLEGAL_REQUEST && | ||
1099 | (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00) | ||
1100 | return 0; | ||
1101 | |||
1102 | if ((buffer[1] & 3) == 3) /* Command supported */ | ||
1103 | return 1; | ||
1104 | |||
1105 | return 0; | ||
1106 | } | ||
1107 | EXPORT_SYMBOL(scsi_report_opcode); | ||
1108 | |||
1109 | /** | ||
1065 | * scsi_device_get - get an additional reference to a scsi_device | 1110 | * scsi_device_get - get an additional reference to a scsi_device |
1066 | * @sdev: device to get a reference to | 1111 | * @sdev: device to get a reference to |
1067 | * | 1112 | * |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index da36a3a81a9e..9032e910bca3 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -900,11 +900,23 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
900 | action = ACTION_FAIL; | 900 | action = ACTION_FAIL; |
901 | error = -EILSEQ; | 901 | error = -EILSEQ; |
902 | /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ | 902 | /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ |
903 | } else if ((sshdr.asc == 0x20 || sshdr.asc == 0x24) && | 903 | } else if (sshdr.asc == 0x20 || sshdr.asc == 0x24) { |
904 | (cmd->cmnd[0] == UNMAP || | 904 | switch (cmd->cmnd[0]) { |
905 | cmd->cmnd[0] == WRITE_SAME_16 || | 905 | case UNMAP: |
906 | cmd->cmnd[0] == WRITE_SAME)) { | 906 | description = "Discard failure"; |
907 | description = "Discard failure"; | 907 | break; |
908 | case WRITE_SAME: | ||
909 | case WRITE_SAME_16: | ||
910 | if (cmd->cmnd[1] & 0x8) | ||
911 | description = "Discard failure"; | ||
912 | else | ||
913 | description = | ||
914 | "Write same failure"; | ||
915 | break; | ||
916 | default: | ||
917 | description = "Invalid command failure"; | ||
918 | break; | ||
919 | } | ||
908 | action = ACTION_FAIL; | 920 | action = ACTION_FAIL; |
909 | error = -EREMOTEIO; | 921 | error = -EREMOTEIO; |
910 | } else | 922 | } else |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 12f6fdfc1147..352bc77b7c88 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -99,6 +99,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); | |||
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | static void sd_config_discard(struct scsi_disk *, unsigned int); | 101 | static void sd_config_discard(struct scsi_disk *, unsigned int); |
102 | static void sd_config_write_same(struct scsi_disk *); | ||
102 | static int sd_revalidate_disk(struct gendisk *); | 103 | static int sd_revalidate_disk(struct gendisk *); |
103 | static void sd_unlock_native_capacity(struct gendisk *disk); | 104 | static void sd_unlock_native_capacity(struct gendisk *disk); |
104 | static int sd_probe(struct device *); | 105 | static int sd_probe(struct device *); |
@@ -395,6 +396,45 @@ sd_store_max_medium_access_timeouts(struct device *dev, | |||
395 | return err ? err : count; | 396 | return err ? err : count; |
396 | } | 397 | } |
397 | 398 | ||
399 | static ssize_t | ||
400 | sd_show_write_same_blocks(struct device *dev, struct device_attribute *attr, | ||
401 | char *buf) | ||
402 | { | ||
403 | struct scsi_disk *sdkp = to_scsi_disk(dev); | ||
404 | |||
405 | return snprintf(buf, 20, "%u\n", sdkp->max_ws_blocks); | ||
406 | } | ||
407 | |||
408 | static ssize_t | ||
409 | sd_store_write_same_blocks(struct device *dev, struct device_attribute *attr, | ||
410 | const char *buf, size_t count) | ||
411 | { | ||
412 | struct scsi_disk *sdkp = to_scsi_disk(dev); | ||
413 | struct scsi_device *sdp = sdkp->device; | ||
414 | unsigned long max; | ||
415 | int err; | ||
416 | |||
417 | if (!capable(CAP_SYS_ADMIN)) | ||
418 | return -EACCES; | ||
419 | |||
420 | if (sdp->type != TYPE_DISK) | ||
421 | return -EINVAL; | ||
422 | |||
423 | err = kstrtoul(buf, 10, &max); | ||
424 | |||
425 | if (err) | ||
426 | return err; | ||
427 | |||
428 | if (max == 0) | ||
429 | sdp->no_write_same = 1; | ||
430 | else if (max <= SD_MAX_WS16_BLOCKS) | ||
431 | sdkp->max_ws_blocks = max; | ||
432 | |||
433 | sd_config_write_same(sdkp); | ||
434 | |||
435 | return count; | ||
436 | } | ||
437 | |||
398 | static struct device_attribute sd_disk_attrs[] = { | 438 | static struct device_attribute sd_disk_attrs[] = { |
399 | __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, | 439 | __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, |
400 | sd_store_cache_type), | 440 | sd_store_cache_type), |
@@ -410,6 +450,8 @@ static struct device_attribute sd_disk_attrs[] = { | |||
410 | __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), | 450 | __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), |
411 | __ATTR(provisioning_mode, S_IRUGO|S_IWUSR, sd_show_provisioning_mode, | 451 | __ATTR(provisioning_mode, S_IRUGO|S_IWUSR, sd_show_provisioning_mode, |
412 | sd_store_provisioning_mode), | 452 | sd_store_provisioning_mode), |
453 | __ATTR(max_write_same_blocks, S_IRUGO|S_IWUSR, | ||
454 | sd_show_write_same_blocks, sd_store_write_same_blocks), | ||
413 | __ATTR(max_medium_access_timeouts, S_IRUGO|S_IWUSR, | 455 | __ATTR(max_medium_access_timeouts, S_IRUGO|S_IWUSR, |
414 | sd_show_max_medium_access_timeouts, | 456 | sd_show_max_medium_access_timeouts, |
415 | sd_store_max_medium_access_timeouts), | 457 | sd_store_max_medium_access_timeouts), |
@@ -561,19 +603,23 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) | |||
561 | return; | 603 | return; |
562 | 604 | ||
563 | case SD_LBP_UNMAP: | 605 | case SD_LBP_UNMAP: |
564 | max_blocks = min_not_zero(sdkp->max_unmap_blocks, 0xffffffff); | 606 | max_blocks = min_not_zero(sdkp->max_unmap_blocks, |
607 | (u32)SD_MAX_WS16_BLOCKS); | ||
565 | break; | 608 | break; |
566 | 609 | ||
567 | case SD_LBP_WS16: | 610 | case SD_LBP_WS16: |
568 | max_blocks = min_not_zero(sdkp->max_ws_blocks, 0xffffffff); | 611 | max_blocks = min_not_zero(sdkp->max_ws_blocks, |
612 | (u32)SD_MAX_WS16_BLOCKS); | ||
569 | break; | 613 | break; |
570 | 614 | ||
571 | case SD_LBP_WS10: | 615 | case SD_LBP_WS10: |
572 | max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)0xffff); | 616 | max_blocks = min_not_zero(sdkp->max_ws_blocks, |
617 | (u32)SD_MAX_WS10_BLOCKS); | ||
573 | break; | 618 | break; |
574 | 619 | ||
575 | case SD_LBP_ZERO: | 620 | case SD_LBP_ZERO: |
576 | max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)0xffff); | 621 | max_blocks = min_not_zero(sdkp->max_ws_blocks, |
622 | (u32)SD_MAX_WS10_BLOCKS); | ||
577 | q->limits.discard_zeroes_data = 1; | 623 | q->limits.discard_zeroes_data = 1; |
578 | break; | 624 | break; |
579 | } | 625 | } |
@@ -583,29 +629,26 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) | |||
583 | } | 629 | } |
584 | 630 | ||
585 | /** | 631 | /** |
586 | * scsi_setup_discard_cmnd - unmap blocks on thinly provisioned device | 632 | * sd_setup_discard_cmnd - unmap blocks on thinly provisioned device |
587 | * @sdp: scsi device to operate one | 633 | * @sdp: scsi device to operate one |
588 | * @rq: Request to prepare | 634 | * @rq: Request to prepare |
589 | * | 635 | * |
590 | * Will issue either UNMAP or WRITE SAME(16) depending on preference | 636 | * Will issue either UNMAP or WRITE SAME(16) depending on preference |
591 | * indicated by target device. | 637 | * indicated by target device. |
592 | **/ | 638 | **/ |
593 | static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) | 639 | static int sd_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) |
594 | { | 640 | { |
595 | struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); | 641 | struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); |
596 | struct bio *bio = rq->bio; | 642 | sector_t sector = blk_rq_pos(rq); |
597 | sector_t sector = bio->bi_sector; | 643 | unsigned int nr_sectors = blk_rq_sectors(rq); |
598 | unsigned int nr_sectors = bio_sectors(bio); | 644 | unsigned int nr_bytes = blk_rq_bytes(rq); |
599 | unsigned int len; | 645 | unsigned int len; |
600 | int ret; | 646 | int ret; |
601 | char *buf; | 647 | char *buf; |
602 | struct page *page; | 648 | struct page *page; |
603 | 649 | ||
604 | if (sdkp->device->sector_size == 4096) { | 650 | sector >>= ilog2(sdp->sector_size) - 9; |
605 | sector >>= 3; | 651 | nr_sectors >>= ilog2(sdp->sector_size) - 9; |
606 | nr_sectors >>= 3; | ||
607 | } | ||
608 | |||
609 | rq->timeout = SD_TIMEOUT; | 652 | rq->timeout = SD_TIMEOUT; |
610 | 653 | ||
611 | memset(rq->cmd, 0, rq->cmd_len); | 654 | memset(rq->cmd, 0, rq->cmd_len); |
@@ -660,6 +703,7 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) | |||
660 | blk_add_request_payload(rq, page, len); | 703 | blk_add_request_payload(rq, page, len); |
661 | ret = scsi_setup_blk_pc_cmnd(sdp, rq); | 704 | ret = scsi_setup_blk_pc_cmnd(sdp, rq); |
662 | rq->buffer = page_address(page); | 705 | rq->buffer = page_address(page); |
706 | rq->__data_len = nr_bytes; | ||
663 | 707 | ||
664 | out: | 708 | out: |
665 | if (ret != BLKPREP_OK) { | 709 | if (ret != BLKPREP_OK) { |
@@ -669,6 +713,83 @@ out: | |||
669 | return ret; | 713 | return ret; |
670 | } | 714 | } |
671 | 715 | ||
716 | static void sd_config_write_same(struct scsi_disk *sdkp) | ||
717 | { | ||
718 | struct request_queue *q = sdkp->disk->queue; | ||
719 | unsigned int logical_block_size = sdkp->device->sector_size; | ||
720 | unsigned int blocks = 0; | ||
721 | |||
722 | if (sdkp->device->no_write_same) { | ||
723 | sdkp->max_ws_blocks = 0; | ||
724 | goto out; | ||
725 | } | ||
726 | |||
727 | /* Some devices can not handle block counts above 0xffff despite | ||
728 | * supporting WRITE SAME(16). Consequently we default to 64k | ||
729 | * blocks per I/O unless the device explicitly advertises a | ||
730 | * bigger limit. | ||
731 | */ | ||
732 | if (sdkp->max_ws_blocks == 0) | ||
733 | sdkp->max_ws_blocks = SD_MAX_WS10_BLOCKS; | ||
734 | |||
735 | if (sdkp->ws16 || sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS) | ||
736 | blocks = min_not_zero(sdkp->max_ws_blocks, | ||
737 | (u32)SD_MAX_WS16_BLOCKS); | ||
738 | else | ||
739 | blocks = min_not_zero(sdkp->max_ws_blocks, | ||
740 | (u32)SD_MAX_WS10_BLOCKS); | ||
741 | |||
742 | out: | ||
743 | blk_queue_max_write_same_sectors(q, blocks * (logical_block_size >> 9)); | ||
744 | } | ||
745 | |||
746 | /** | ||
747 | * sd_setup_write_same_cmnd - write the same data to multiple blocks | ||
748 | * @sdp: scsi device to operate one | ||
749 | * @rq: Request to prepare | ||
750 | * | ||
751 | * Will issue either WRITE SAME(10) or WRITE SAME(16) depending on | ||
752 | * preference indicated by target device. | ||
753 | **/ | ||
754 | static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq) | ||
755 | { | ||
756 | struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); | ||
757 | struct bio *bio = rq->bio; | ||
758 | sector_t sector = blk_rq_pos(rq); | ||
759 | unsigned int nr_sectors = blk_rq_sectors(rq); | ||
760 | unsigned int nr_bytes = blk_rq_bytes(rq); | ||
761 | int ret; | ||
762 | |||
763 | if (sdkp->device->no_write_same) | ||
764 | return BLKPREP_KILL; | ||
765 | |||
766 | BUG_ON(bio_offset(bio) || bio_iovec(bio)->bv_len != sdp->sector_size); | ||
767 | |||
768 | sector >>= ilog2(sdp->sector_size) - 9; | ||
769 | nr_sectors >>= ilog2(sdp->sector_size) - 9; | ||
770 | |||
771 | rq->__data_len = sdp->sector_size; | ||
772 | rq->timeout = SD_WRITE_SAME_TIMEOUT; | ||
773 | memset(rq->cmd, 0, rq->cmd_len); | ||
774 | |||
775 | if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) { | ||
776 | rq->cmd_len = 16; | ||
777 | rq->cmd[0] = WRITE_SAME_16; | ||
778 | put_unaligned_be64(sector, &rq->cmd[2]); | ||
779 | put_unaligned_be32(nr_sectors, &rq->cmd[10]); | ||
780 | } else { | ||
781 | rq->cmd_len = 10; | ||
782 | rq->cmd[0] = WRITE_SAME; | ||
783 | put_unaligned_be32(sector, &rq->cmd[2]); | ||
784 | put_unaligned_be16(nr_sectors, &rq->cmd[7]); | ||
785 | } | ||
786 | |||
787 | ret = scsi_setup_blk_pc_cmnd(sdp, rq); | ||
788 | rq->__data_len = nr_bytes; | ||
789 | |||
790 | return ret; | ||
791 | } | ||
792 | |||
672 | static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq) | 793 | static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq) |
673 | { | 794 | { |
674 | rq->timeout = SD_FLUSH_TIMEOUT; | 795 | rq->timeout = SD_FLUSH_TIMEOUT; |
@@ -712,7 +833,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
712 | * block PC requests to make life easier. | 833 | * block PC requests to make life easier. |
713 | */ | 834 | */ |
714 | if (rq->cmd_flags & REQ_DISCARD) { | 835 | if (rq->cmd_flags & REQ_DISCARD) { |
715 | ret = scsi_setup_discard_cmnd(sdp, rq); | 836 | ret = sd_setup_discard_cmnd(sdp, rq); |
837 | goto out; | ||
838 | } else if (rq->cmd_flags & REQ_WRITE_SAME) { | ||
839 | ret = sd_setup_write_same_cmnd(sdp, rq); | ||
716 | goto out; | 840 | goto out; |
717 | } else if (rq->cmd_flags & REQ_FLUSH) { | 841 | } else if (rq->cmd_flags & REQ_FLUSH) { |
718 | ret = scsi_setup_flush_cmnd(sdp, rq); | 842 | ret = scsi_setup_flush_cmnd(sdp, rq); |
@@ -1482,12 +1606,21 @@ static int sd_done(struct scsi_cmnd *SCpnt) | |||
1482 | unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt); | 1606 | unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt); |
1483 | struct scsi_sense_hdr sshdr; | 1607 | struct scsi_sense_hdr sshdr; |
1484 | struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk); | 1608 | struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk); |
1609 | struct request *req = SCpnt->request; | ||
1485 | int sense_valid = 0; | 1610 | int sense_valid = 0; |
1486 | int sense_deferred = 0; | 1611 | int sense_deferred = 0; |
1487 | unsigned char op = SCpnt->cmnd[0]; | 1612 | unsigned char op = SCpnt->cmnd[0]; |
1613 | unsigned char unmap = SCpnt->cmnd[1] & 8; | ||
1488 | 1614 | ||
1489 | if ((SCpnt->request->cmd_flags & REQ_DISCARD) && !result) | 1615 | if (req->cmd_flags & REQ_DISCARD || req->cmd_flags & REQ_WRITE_SAME) { |
1490 | scsi_set_resid(SCpnt, 0); | 1616 | if (!result) { |
1617 | good_bytes = blk_rq_bytes(req); | ||
1618 | scsi_set_resid(SCpnt, 0); | ||
1619 | } else { | ||
1620 | good_bytes = 0; | ||
1621 | scsi_set_resid(SCpnt, blk_rq_bytes(req)); | ||
1622 | } | ||
1623 | } | ||
1491 | 1624 | ||
1492 | if (result) { | 1625 | if (result) { |
1493 | sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr); | 1626 | sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr); |
@@ -1536,9 +1669,25 @@ static int sd_done(struct scsi_cmnd *SCpnt) | |||
1536 | if (sshdr.asc == 0x10) /* DIX: Host detected corruption */ | 1669 | if (sshdr.asc == 0x10) /* DIX: Host detected corruption */ |
1537 | good_bytes = sd_completed_bytes(SCpnt); | 1670 | good_bytes = sd_completed_bytes(SCpnt); |
1538 | /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ | 1671 | /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ |
1539 | if ((sshdr.asc == 0x20 || sshdr.asc == 0x24) && | 1672 | if (sshdr.asc == 0x20 || sshdr.asc == 0x24) { |
1540 | (op == UNMAP || op == WRITE_SAME_16 || op == WRITE_SAME)) | 1673 | switch (op) { |
1541 | sd_config_discard(sdkp, SD_LBP_DISABLE); | 1674 | case UNMAP: |
1675 | sd_config_discard(sdkp, SD_LBP_DISABLE); | ||
1676 | break; | ||
1677 | case WRITE_SAME_16: | ||
1678 | case WRITE_SAME: | ||
1679 | if (unmap) | ||
1680 | sd_config_discard(sdkp, SD_LBP_DISABLE); | ||
1681 | else { | ||
1682 | sdkp->device->no_write_same = 1; | ||
1683 | sd_config_write_same(sdkp); | ||
1684 | |||
1685 | good_bytes = 0; | ||
1686 | req->__data_len = blk_rq_bytes(req); | ||
1687 | req->cmd_flags |= REQ_QUIET; | ||
1688 | } | ||
1689 | } | ||
1690 | } | ||
1542 | break; | 1691 | break; |
1543 | default: | 1692 | default: |
1544 | break; | 1693 | break; |
@@ -2374,9 +2523,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) | |||
2374 | if (buffer[3] == 0x3c) { | 2523 | if (buffer[3] == 0x3c) { |
2375 | unsigned int lba_count, desc_count; | 2524 | unsigned int lba_count, desc_count; |
2376 | 2525 | ||
2377 | sdkp->max_ws_blocks = | 2526 | sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]); |
2378 | (u32) min_not_zero(get_unaligned_be64(&buffer[36]), | ||
2379 | (u64)0xffffffff); | ||
2380 | 2527 | ||
2381 | if (!sdkp->lbpme) | 2528 | if (!sdkp->lbpme) |
2382 | goto out; | 2529 | goto out; |
@@ -2469,6 +2616,13 @@ static void sd_read_block_provisioning(struct scsi_disk *sdkp) | |||
2469 | kfree(buffer); | 2616 | kfree(buffer); |
2470 | } | 2617 | } |
2471 | 2618 | ||
2619 | static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) | ||
2620 | { | ||
2621 | if (scsi_report_opcode(sdkp->device, buffer, SD_BUF_SIZE, | ||
2622 | WRITE_SAME_16)) | ||
2623 | sdkp->ws16 = 1; | ||
2624 | } | ||
2625 | |||
2472 | static int sd_try_extended_inquiry(struct scsi_device *sdp) | 2626 | static int sd_try_extended_inquiry(struct scsi_device *sdp) |
2473 | { | 2627 | { |
2474 | /* | 2628 | /* |
@@ -2528,6 +2682,7 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
2528 | sd_read_write_protect_flag(sdkp, buffer); | 2682 | sd_read_write_protect_flag(sdkp, buffer); |
2529 | sd_read_cache_type(sdkp, buffer); | 2683 | sd_read_cache_type(sdkp, buffer); |
2530 | sd_read_app_tag_own(sdkp, buffer); | 2684 | sd_read_app_tag_own(sdkp, buffer); |
2685 | sd_read_write_same(sdkp, buffer); | ||
2531 | } | 2686 | } |
2532 | 2687 | ||
2533 | sdkp->first_scan = 0; | 2688 | sdkp->first_scan = 0; |
@@ -2545,6 +2700,7 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
2545 | blk_queue_flush(sdkp->disk->queue, flush); | 2700 | blk_queue_flush(sdkp->disk->queue, flush); |
2546 | 2701 | ||
2547 | set_capacity(disk, sdkp->capacity); | 2702 | set_capacity(disk, sdkp->capacity); |
2703 | sd_config_write_same(sdkp); | ||
2548 | kfree(buffer); | 2704 | kfree(buffer); |
2549 | 2705 | ||
2550 | out: | 2706 | out: |
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 47c52a6d733c..74a1e4ca5401 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #define SD_TIMEOUT (30 * HZ) | 14 | #define SD_TIMEOUT (30 * HZ) |
15 | #define SD_MOD_TIMEOUT (75 * HZ) | 15 | #define SD_MOD_TIMEOUT (75 * HZ) |
16 | #define SD_FLUSH_TIMEOUT (60 * HZ) | 16 | #define SD_FLUSH_TIMEOUT (60 * HZ) |
17 | #define SD_WRITE_SAME_TIMEOUT (120 * HZ) | ||
17 | 18 | ||
18 | /* | 19 | /* |
19 | * Number of allowed retries | 20 | * Number of allowed retries |
@@ -39,6 +40,11 @@ enum { | |||
39 | }; | 40 | }; |
40 | 41 | ||
41 | enum { | 42 | enum { |
43 | SD_MAX_WS10_BLOCKS = 0xffff, | ||
44 | SD_MAX_WS16_BLOCKS = 0x7fffff, | ||
45 | }; | ||
46 | |||
47 | enum { | ||
42 | SD_LBP_FULL = 0, /* Full logical block provisioning */ | 48 | SD_LBP_FULL = 0, /* Full logical block provisioning */ |
43 | SD_LBP_UNMAP, /* Use UNMAP command */ | 49 | SD_LBP_UNMAP, /* Use UNMAP command */ |
44 | SD_LBP_WS16, /* Use WRITE SAME(16) with UNMAP bit */ | 50 | SD_LBP_WS16, /* Use WRITE SAME(16) with UNMAP bit */ |
@@ -77,6 +83,7 @@ struct scsi_disk { | |||
77 | unsigned lbpws : 1; | 83 | unsigned lbpws : 1; |
78 | unsigned lbpws10 : 1; | 84 | unsigned lbpws10 : 1; |
79 | unsigned lbpvpd : 1; | 85 | unsigned lbpvpd : 1; |
86 | unsigned ws16 : 1; | ||
80 | }; | 87 | }; |
81 | #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) | 88 | #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) |
82 | 89 | ||
diff --git a/drivers/staging/android/android_alarm.h b/drivers/staging/android/android_alarm.h index f2ffd963f1c3..d0cafd637199 100644 --- a/drivers/staging/android/android_alarm.h +++ b/drivers/staging/android/android_alarm.h | |||
@@ -51,12 +51,10 @@ enum android_alarm_return_flags { | |||
51 | #define ANDROID_ALARM_WAIT _IO('a', 1) | 51 | #define ANDROID_ALARM_WAIT _IO('a', 1) |
52 | 52 | ||
53 | #define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size) | 53 | #define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size) |
54 | #define ALARM_IOR(c, type, size) _IOR('a', (c) | ((type) << 4), size) | ||
55 | |||
56 | /* Set alarm */ | 54 | /* Set alarm */ |
57 | #define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) | 55 | #define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) |
58 | #define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) | 56 | #define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) |
59 | #define ANDROID_ALARM_GET_TIME(type) ALARM_IOR(4, type, struct timespec) | 57 | #define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec) |
60 | #define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) | 58 | #define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) |
61 | #define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) | 59 | #define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) |
62 | #define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) | 60 | #define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 9097155e9ebe..dcecbfb17243 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -1819,8 +1819,10 @@ void target_execute_cmd(struct se_cmd *cmd) | |||
1819 | /* | 1819 | /* |
1820 | * If the received CDB has aleady been aborted stop processing it here. | 1820 | * If the received CDB has aleady been aborted stop processing it here. |
1821 | */ | 1821 | */ |
1822 | if (transport_check_aborted_status(cmd, 1)) | 1822 | if (transport_check_aborted_status(cmd, 1)) { |
1823 | complete(&cmd->t_transport_stop_comp); | ||
1823 | return; | 1824 | return; |
1825 | } | ||
1824 | 1826 | ||
1825 | /* | 1827 | /* |
1826 | * Determine if IOCTL context caller in requesting the stopping of this | 1828 | * Determine if IOCTL context caller in requesting the stopping of this |
@@ -3067,7 +3069,7 @@ void transport_send_task_abort(struct se_cmd *cmd) | |||
3067 | unsigned long flags; | 3069 | unsigned long flags; |
3068 | 3070 | ||
3069 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 3071 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
3070 | if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { | 3072 | if (cmd->se_cmd_flags & (SCF_SENT_CHECK_CONDITION | SCF_SENT_DELAYED_TAS)) { |
3071 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | 3073 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); |
3072 | return; | 3074 | return; |
3073 | } | 3075 | } |
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index a5dec1ca1b82..13ee53bd0bf6 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c | |||
@@ -424,7 +424,6 @@ static void hvc_hangup(struct tty_struct *tty) | |||
424 | { | 424 | { |
425 | struct hvc_struct *hp = tty->driver_data; | 425 | struct hvc_struct *hp = tty->driver_data; |
426 | unsigned long flags; | 426 | unsigned long flags; |
427 | int temp_open_count; | ||
428 | 427 | ||
429 | if (!hp) | 428 | if (!hp) |
430 | return; | 429 | return; |
@@ -444,7 +443,6 @@ static void hvc_hangup(struct tty_struct *tty) | |||
444 | return; | 443 | return; |
445 | } | 444 | } |
446 | 445 | ||
447 | temp_open_count = hp->port.count; | ||
448 | hp->port.count = 0; | 446 | hp->port.count = 0; |
449 | spin_unlock_irqrestore(&hp->port.lock, flags); | 447 | spin_unlock_irqrestore(&hp->port.lock, flags); |
450 | tty_port_tty_set(&hp->port, NULL); | 448 | tty_port_tty_set(&hp->port, NULL); |
@@ -453,11 +451,6 @@ static void hvc_hangup(struct tty_struct *tty) | |||
453 | 451 | ||
454 | if (hp->ops->notifier_hangup) | 452 | if (hp->ops->notifier_hangup) |
455 | hp->ops->notifier_hangup(hp, hp->data); | 453 | hp->ops->notifier_hangup(hp, hp->data); |
456 | |||
457 | while(temp_open_count) { | ||
458 | --temp_open_count; | ||
459 | tty_port_put(&hp->port); | ||
460 | } | ||
461 | } | 454 | } |
462 | 455 | ||
463 | /* | 456 | /* |
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 2bc28a59d385..1ab1d2c66de4 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c | |||
@@ -1239,6 +1239,7 @@ static int __devexit max310x_remove(struct spi_device *spi) | |||
1239 | static const struct spi_device_id max310x_id_table[] = { | 1239 | static const struct spi_device_id max310x_id_table[] = { |
1240 | { "max3107", MAX310X_TYPE_MAX3107 }, | 1240 | { "max3107", MAX310X_TYPE_MAX3107 }, |
1241 | { "max3108", MAX310X_TYPE_MAX3108 }, | 1241 | { "max3108", MAX310X_TYPE_MAX3108 }, |
1242 | { } | ||
1242 | }; | 1243 | }; |
1243 | MODULE_DEVICE_TABLE(spi, max310x_id_table); | 1244 | MODULE_DEVICE_TABLE(spi, max310x_id_table); |
1244 | 1245 | ||
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index f87d7e8964bf..4e0d0c3734b3 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c | |||
@@ -539,25 +539,25 @@ static void insert_char(struct vc_data *vc, unsigned int nr) | |||
539 | { | 539 | { |
540 | unsigned short *p = (unsigned short *) vc->vc_pos; | 540 | unsigned short *p = (unsigned short *) vc->vc_pos; |
541 | 541 | ||
542 | scr_memmovew(p + nr, p, vc->vc_cols - vc->vc_x); | 542 | scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x) * 2); |
543 | scr_memsetw(p, vc->vc_video_erase_char, nr * 2); | 543 | scr_memsetw(p, vc->vc_video_erase_char, nr * 2); |
544 | vc->vc_need_wrap = 0; | 544 | vc->vc_need_wrap = 0; |
545 | if (DO_UPDATE(vc)) | 545 | if (DO_UPDATE(vc)) |
546 | do_update_region(vc, (unsigned long) p, | 546 | do_update_region(vc, (unsigned long) p, |
547 | (vc->vc_cols - vc->vc_x) / 2 + 1); | 547 | vc->vc_cols - vc->vc_x); |
548 | } | 548 | } |
549 | 549 | ||
550 | static void delete_char(struct vc_data *vc, unsigned int nr) | 550 | static void delete_char(struct vc_data *vc, unsigned int nr) |
551 | { | 551 | { |
552 | unsigned short *p = (unsigned short *) vc->vc_pos; | 552 | unsigned short *p = (unsigned short *) vc->vc_pos; |
553 | 553 | ||
554 | scr_memcpyw(p, p + nr, vc->vc_cols - vc->vc_x - nr); | 554 | scr_memcpyw(p, p + nr, (vc->vc_cols - vc->vc_x - nr) * 2); |
555 | scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, | 555 | scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, |
556 | nr * 2); | 556 | nr * 2); |
557 | vc->vc_need_wrap = 0; | 557 | vc->vc_need_wrap = 0; |
558 | if (DO_UPDATE(vc)) | 558 | if (DO_UPDATE(vc)) |
559 | do_update_region(vc, (unsigned long) p, | 559 | do_update_region(vc, (unsigned long) p, |
560 | (vc->vc_cols - vc->vc_x) / 2); | 560 | vc->vc_cols - vc->vc_x); |
561 | } | 561 | } |
562 | 562 | ||
563 | static int softcursor_original; | 563 | static int softcursor_original; |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 1e741bca0265..f034716190ff 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -2151,8 +2151,15 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum); | |||
2151 | irqreturn_t usb_hcd_irq (int irq, void *__hcd) | 2151 | irqreturn_t usb_hcd_irq (int irq, void *__hcd) |
2152 | { | 2152 | { |
2153 | struct usb_hcd *hcd = __hcd; | 2153 | struct usb_hcd *hcd = __hcd; |
2154 | unsigned long flags; | ||
2154 | irqreturn_t rc; | 2155 | irqreturn_t rc; |
2155 | 2156 | ||
2157 | /* IRQF_DISABLED doesn't work correctly with shared IRQs | ||
2158 | * when the first handler doesn't use it. So let's just | ||
2159 | * assume it's never used. | ||
2160 | */ | ||
2161 | local_irq_save(flags); | ||
2162 | |||
2156 | if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) | 2163 | if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) |
2157 | rc = IRQ_NONE; | 2164 | rc = IRQ_NONE; |
2158 | else if (hcd->driver->irq(hcd) == IRQ_NONE) | 2165 | else if (hcd->driver->irq(hcd) == IRQ_NONE) |
@@ -2160,6 +2167,7 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd) | |||
2160 | else | 2167 | else |
2161 | rc = IRQ_HANDLED; | 2168 | rc = IRQ_HANDLED; |
2162 | 2169 | ||
2170 | local_irq_restore(flags); | ||
2163 | return rc; | 2171 | return rc; |
2164 | } | 2172 | } |
2165 | EXPORT_SYMBOL_GPL(usb_hcd_irq); | 2173 | EXPORT_SYMBOL_GPL(usb_hcd_irq); |
@@ -2347,6 +2355,14 @@ static int usb_hcd_request_irqs(struct usb_hcd *hcd, | |||
2347 | int retval; | 2355 | int retval; |
2348 | 2356 | ||
2349 | if (hcd->driver->irq) { | 2357 | if (hcd->driver->irq) { |
2358 | |||
2359 | /* IRQF_DISABLED doesn't work as advertised when used together | ||
2360 | * with IRQF_SHARED. As usb_hcd_irq() will always disable | ||
2361 | * interrupts we can remove it here. | ||
2362 | */ | ||
2363 | if (irqflags & IRQF_SHARED) | ||
2364 | irqflags &= ~IRQF_DISABLED; | ||
2365 | |||
2350 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", | 2366 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", |
2351 | hcd->driver->description, hcd->self.busnum); | 2367 | hcd->driver->description, hcd->self.busnum); |
2352 | retval = request_irq(irqnum, &usb_hcd_irq, irqflags, | 2368 | retval = request_irq(irqnum, &usb_hcd_irq, irqflags, |
diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c index e426ad626d74..4bfa78af379c 100644 --- a/drivers/usb/early/ehci-dbgp.c +++ b/drivers/usb/early/ehci-dbgp.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/usb/ehci_def.h> | 20 | #include <linux/usb/ehci_def.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/serial_core.h> | 22 | #include <linux/serial_core.h> |
23 | #include <linux/kconfig.h> | ||
23 | #include <linux/kgdb.h> | 24 | #include <linux/kgdb.h> |
24 | #include <linux/kthread.h> | 25 | #include <linux/kthread.h> |
25 | #include <asm/io.h> | 26 | #include <asm/io.h> |
@@ -614,12 +615,6 @@ err: | |||
614 | return -ENODEV; | 615 | return -ENODEV; |
615 | } | 616 | } |
616 | 617 | ||
617 | int dbgp_external_startup(struct usb_hcd *hcd) | ||
618 | { | ||
619 | return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup(); | ||
620 | } | ||
621 | EXPORT_SYMBOL_GPL(dbgp_external_startup); | ||
622 | |||
623 | static int ehci_reset_port(int port) | 618 | static int ehci_reset_port(int port) |
624 | { | 619 | { |
625 | u32 portsc; | 620 | u32 portsc; |
@@ -979,6 +974,7 @@ struct console early_dbgp_console = { | |||
979 | .index = -1, | 974 | .index = -1, |
980 | }; | 975 | }; |
981 | 976 | ||
977 | #if IS_ENABLED(CONFIG_USB_EHCI_HCD) | ||
982 | int dbgp_reset_prep(struct usb_hcd *hcd) | 978 | int dbgp_reset_prep(struct usb_hcd *hcd) |
983 | { | 979 | { |
984 | int ret = xen_dbgp_reset_prep(hcd); | 980 | int ret = xen_dbgp_reset_prep(hcd); |
@@ -1007,6 +1003,13 @@ int dbgp_reset_prep(struct usb_hcd *hcd) | |||
1007 | } | 1003 | } |
1008 | EXPORT_SYMBOL_GPL(dbgp_reset_prep); | 1004 | EXPORT_SYMBOL_GPL(dbgp_reset_prep); |
1009 | 1005 | ||
1006 | int dbgp_external_startup(struct usb_hcd *hcd) | ||
1007 | { | ||
1008 | return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup(); | ||
1009 | } | ||
1010 | EXPORT_SYMBOL_GPL(dbgp_external_startup); | ||
1011 | #endif /* USB_EHCI_HCD */ | ||
1012 | |||
1010 | #ifdef CONFIG_KGDB | 1013 | #ifdef CONFIG_KGDB |
1011 | 1014 | ||
1012 | static char kgdbdbgp_buf[DBGP_MAX_PACKET]; | 1015 | static char kgdbdbgp_buf[DBGP_MAX_PACKET]; |
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c index ca759652626b..aa0f328922df 100644 --- a/drivers/usb/host/ehci-ls1x.c +++ b/drivers/usb/host/ehci-ls1x.c | |||
@@ -113,7 +113,7 @@ static int ehci_hcd_ls1x_probe(struct platform_device *pdev) | |||
113 | goto err_put_hcd; | 113 | goto err_put_hcd; |
114 | } | 114 | } |
115 | 115 | ||
116 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); | 116 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); |
117 | if (ret) | 117 | if (ret) |
118 | goto err_put_hcd; | 118 | goto err_put_hcd; |
119 | 119 | ||
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c index 84201cd1a472..41e378f17c66 100644 --- a/drivers/usb/host/ohci-xls.c +++ b/drivers/usb/host/ohci-xls.c | |||
@@ -56,7 +56,7 @@ static int ohci_xls_probe_internal(const struct hc_driver *driver, | |||
56 | goto err3; | 56 | goto err3; |
57 | } | 57 | } |
58 | 58 | ||
59 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 59 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); |
60 | if (retval != 0) | 60 | if (retval != 0) |
61 | goto err4; | 61 | goto err4; |
62 | return retval; | 62 | return retval; |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index d0b87e7b4abf..b6b84dacc791 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -707,11 +707,12 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
707 | fifo_count = musb_readw(epio, MUSB_RXCOUNT); | 707 | fifo_count = musb_readw(epio, MUSB_RXCOUNT); |
708 | 708 | ||
709 | /* | 709 | /* |
710 | * use mode 1 only if we expect data of at least ep packet_sz | 710 | * Enable Mode 1 on RX transfers only when short_not_ok flag |
711 | * and have not yet received a short packet | 711 | * is set. Currently short_not_ok flag is set only from |
712 | * file_storage and f_mass_storage drivers | ||
712 | */ | 713 | */ |
713 | if ((request->length - request->actual >= musb_ep->packet_sz) && | 714 | |
714 | (fifo_count >= musb_ep->packet_sz)) | 715 | if (request->short_not_ok && fifo_count == musb_ep->packet_sz) |
715 | use_mode_1 = 1; | 716 | use_mode_1 = 1; |
716 | else | 717 | else |
717 | use_mode_1 = 0; | 718 | use_mode_1 = 0; |
@@ -727,6 +728,27 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
727 | c = musb->dma_controller; | 728 | c = musb->dma_controller; |
728 | channel = musb_ep->dma; | 729 | channel = musb_ep->dma; |
729 | 730 | ||
731 | /* We use DMA Req mode 0 in rx_csr, and DMA controller operates in | ||
732 | * mode 0 only. So we do not get endpoint interrupts due to DMA | ||
733 | * completion. We only get interrupts from DMA controller. | ||
734 | * | ||
735 | * We could operate in DMA mode 1 if we knew the size of the tranfer | ||
736 | * in advance. For mass storage class, request->length = what the host | ||
737 | * sends, so that'd work. But for pretty much everything else, | ||
738 | * request->length is routinely more than what the host sends. For | ||
739 | * most these gadgets, end of is signified either by a short packet, | ||
740 | * or filling the last byte of the buffer. (Sending extra data in | ||
741 | * that last pckate should trigger an overflow fault.) But in mode 1, | ||
742 | * we don't get DMA completion interrupt for short packets. | ||
743 | * | ||
744 | * Theoretically, we could enable DMAReq irq (MUSB_RXCSR_DMAMODE = 1), | ||
745 | * to get endpoint interrupt on every DMA req, but that didn't seem | ||
746 | * to work reliably. | ||
747 | * | ||
748 | * REVISIT an updated g_file_storage can set req->short_not_ok, which | ||
749 | * then becomes usable as a runtime "use mode 1" hint... | ||
750 | */ | ||
751 | |||
730 | /* Experimental: Mode1 works with mass storage use cases */ | 752 | /* Experimental: Mode1 works with mass storage use cases */ |
731 | if (use_mode_1) { | 753 | if (use_mode_1) { |
732 | csr |= MUSB_RXCSR_AUTOCLEAR; | 754 | csr |= MUSB_RXCSR_AUTOCLEAR; |
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index d62a91fedc22..0e62f504410e 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c | |||
@@ -65,7 +65,7 @@ static int __devinit ux500_probe(struct platform_device *pdev) | |||
65 | struct platform_device *musb; | 65 | struct platform_device *musb; |
66 | struct ux500_glue *glue; | 66 | struct ux500_glue *glue; |
67 | struct clk *clk; | 67 | struct clk *clk; |
68 | 68 | int musbid; | |
69 | int ret = -ENOMEM; | 69 | int ret = -ENOMEM; |
70 | 70 | ||
71 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 71 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index d8c8a42bff3e..6223062d5d1b 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig | |||
@@ -58,7 +58,7 @@ config USB_ULPI_VIEWPORT | |||
58 | 58 | ||
59 | config TWL4030_USB | 59 | config TWL4030_USB |
60 | tristate "TWL4030 USB Transceiver Driver" | 60 | tristate "TWL4030 USB Transceiver Driver" |
61 | depends on TWL4030_CORE && REGULATOR_TWL4030 | 61 | depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS |
62 | select USB_OTG_UTILS | 62 | select USB_OTG_UTILS |
63 | help | 63 | help |
64 | Enable this to support the USB OTG transceiver on TWL4030 | 64 | Enable this to support the USB OTG transceiver on TWL4030 |
@@ -68,7 +68,7 @@ config TWL4030_USB | |||
68 | 68 | ||
69 | config TWL6030_USB | 69 | config TWL6030_USB |
70 | tristate "TWL6030 USB Transceiver Driver" | 70 | tristate "TWL6030 USB Transceiver Driver" |
71 | depends on TWL4030_CORE && OMAP_USB2 | 71 | depends on TWL4030_CORE && OMAP_USB2 && USB_MUSB_OMAP2PLUS |
72 | select USB_OTG_UTILS | 72 | select USB_OTG_UTILS |
73 | help | 73 | help |
74 | Enable this to support the USB OTG transceiver on TWL6030 | 74 | Enable this to support the USB OTG transceiver on TWL6030 |
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 7179b0c5f814..cff8dd5b462d 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -2430,7 +2430,7 @@ static void keyspan_release(struct usb_serial *serial) | |||
2430 | static int keyspan_port_probe(struct usb_serial_port *port) | 2430 | static int keyspan_port_probe(struct usb_serial_port *port) |
2431 | { | 2431 | { |
2432 | struct usb_serial *serial = port->serial; | 2432 | struct usb_serial *serial = port->serial; |
2433 | struct keyspan_port_private *s_priv; | 2433 | struct keyspan_serial_private *s_priv; |
2434 | struct keyspan_port_private *p_priv; | 2434 | struct keyspan_port_private *p_priv; |
2435 | const struct keyspan_device_details *d_details; | 2435 | const struct keyspan_device_details *d_details; |
2436 | struct callbacks *cback; | 2436 | struct callbacks *cback; |
@@ -2445,7 +2445,6 @@ static int keyspan_port_probe(struct usb_serial_port *port) | |||
2445 | if (!p_priv) | 2445 | if (!p_priv) |
2446 | return -ENOMEM; | 2446 | return -ENOMEM; |
2447 | 2447 | ||
2448 | s_priv = usb_get_serial_data(port->serial); | ||
2449 | p_priv->device_details = d_details; | 2448 | p_priv->device_details = d_details; |
2450 | 2449 | ||
2451 | /* Setup values for the various callback routines */ | 2450 | /* Setup values for the various callback routines */ |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 5dee7d61241e..edc64bb6f457 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -158,6 +158,7 @@ static void option_instat_callback(struct urb *urb); | |||
158 | #define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0x8001 | 158 | #define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0x8001 |
159 | #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0x9000 | 159 | #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0x9000 |
160 | #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0x9001 | 160 | #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0x9001 |
161 | #define NOVATELWIRELESS_PRODUCT_E362 0x9010 | ||
161 | #define NOVATELWIRELESS_PRODUCT_G1 0xA001 | 162 | #define NOVATELWIRELESS_PRODUCT_G1 0xA001 |
162 | #define NOVATELWIRELESS_PRODUCT_G1_M 0xA002 | 163 | #define NOVATELWIRELESS_PRODUCT_G1_M 0xA002 |
163 | #define NOVATELWIRELESS_PRODUCT_G2 0xA010 | 164 | #define NOVATELWIRELESS_PRODUCT_G2 0xA010 |
@@ -193,6 +194,9 @@ static void option_instat_callback(struct urb *urb); | |||
193 | #define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181 | 194 | #define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181 |
194 | #define DELL_PRODUCT_5730_MINICARD_VZW 0x8182 | 195 | #define DELL_PRODUCT_5730_MINICARD_VZW 0x8182 |
195 | 196 | ||
197 | #define DELL_PRODUCT_5800_MINICARD_VZW 0x8195 /* Novatel E362 */ | ||
198 | #define DELL_PRODUCT_5800_V2_MINICARD_VZW 0x8196 /* Novatel E362 */ | ||
199 | |||
196 | #define KYOCERA_VENDOR_ID 0x0c88 | 200 | #define KYOCERA_VENDOR_ID 0x0c88 |
197 | #define KYOCERA_PRODUCT_KPC650 0x17da | 201 | #define KYOCERA_PRODUCT_KPC650 0x17da |
198 | #define KYOCERA_PRODUCT_KPC680 0x180a | 202 | #define KYOCERA_PRODUCT_KPC680 0x180a |
@@ -283,6 +287,7 @@ static void option_instat_callback(struct urb *urb); | |||
283 | /* ALCATEL PRODUCTS */ | 287 | /* ALCATEL PRODUCTS */ |
284 | #define ALCATEL_VENDOR_ID 0x1bbb | 288 | #define ALCATEL_VENDOR_ID 0x1bbb |
285 | #define ALCATEL_PRODUCT_X060S_X200 0x0000 | 289 | #define ALCATEL_PRODUCT_X060S_X200 0x0000 |
290 | #define ALCATEL_PRODUCT_X220_X500D 0x0017 | ||
286 | 291 | ||
287 | #define PIRELLI_VENDOR_ID 0x1266 | 292 | #define PIRELLI_VENDOR_ID 0x1266 |
288 | #define PIRELLI_PRODUCT_C100_1 0x1002 | 293 | #define PIRELLI_PRODUCT_C100_1 0x1002 |
@@ -706,6 +711,7 @@ static const struct usb_device_id option_ids[] = { | |||
706 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_G2) }, | 711 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_G2) }, |
707 | /* Novatel Ovation MC551 a.k.a. Verizon USB551L */ | 712 | /* Novatel Ovation MC551 a.k.a. Verizon USB551L */ |
708 | { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) }, | 713 | { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) }, |
714 | { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E362, 0xff, 0xff, 0xff) }, | ||
709 | 715 | ||
710 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, | 716 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, |
711 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, | 717 | { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, |
@@ -728,6 +734,8 @@ static const struct usb_device_id option_ids[] = { | |||
728 | { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ | 734 | { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ |
729 | { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ | 735 | { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ |
730 | { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ | 736 | { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ |
737 | { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_MINICARD_VZW, 0xff, 0xff, 0xff) }, | ||
738 | { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_V2_MINICARD_VZW, 0xff, 0xff, 0xff) }, | ||
731 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ | 739 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ |
732 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, | 740 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, |
733 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, | 741 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, |
@@ -1157,6 +1165,7 @@ static const struct usb_device_id option_ids[] = { | |||
1157 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200), | 1165 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200), |
1158 | .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist | 1166 | .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist |
1159 | }, | 1167 | }, |
1168 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D) }, | ||
1160 | { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, | 1169 | { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, |
1161 | { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, | 1170 | { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, |
1162 | { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), | 1171 | { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), |
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 61a73ad1a187..a3e9c095f0d8 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c | |||
@@ -455,9 +455,6 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port, | |||
455 | struct usb_serial *serial = port->serial; | 455 | struct usb_serial *serial = port->serial; |
456 | struct urb *urb; | 456 | struct urb *urb; |
457 | 457 | ||
458 | if (endpoint == -1) | ||
459 | return NULL; /* endpoint not needed */ | ||
460 | |||
461 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ | 458 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ |
462 | if (urb == NULL) { | 459 | if (urb == NULL) { |
463 | dev_dbg(&serial->interface->dev, | 460 | dev_dbg(&serial->interface->dev, |
@@ -489,6 +486,9 @@ int usb_wwan_port_probe(struct usb_serial_port *port) | |||
489 | init_usb_anchor(&portdata->delayed); | 486 | init_usb_anchor(&portdata->delayed); |
490 | 487 | ||
491 | for (i = 0; i < N_IN_URB; i++) { | 488 | for (i = 0; i < N_IN_URB; i++) { |
489 | if (!port->bulk_in_size) | ||
490 | break; | ||
491 | |||
492 | buffer = (u8 *)__get_free_page(GFP_KERNEL); | 492 | buffer = (u8 *)__get_free_page(GFP_KERNEL); |
493 | if (!buffer) | 493 | if (!buffer) |
494 | goto bail_out_error; | 494 | goto bail_out_error; |
@@ -502,8 +502,8 @@ int usb_wwan_port_probe(struct usb_serial_port *port) | |||
502 | } | 502 | } |
503 | 503 | ||
504 | for (i = 0; i < N_OUT_URB; i++) { | 504 | for (i = 0; i < N_OUT_URB; i++) { |
505 | if (port->bulk_out_endpointAddress == -1) | 505 | if (!port->bulk_out_size) |
506 | continue; | 506 | break; |
507 | 507 | ||
508 | buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL); | 508 | buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL); |
509 | if (!buffer) | 509 | if (!buffer) |
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index a3d54366afcc..92f35abee92d 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
@@ -186,6 +186,12 @@ static int slave_configure(struct scsi_device *sdev) | |||
186 | /* Some devices don't handle VPD pages correctly */ | 186 | /* Some devices don't handle VPD pages correctly */ |
187 | sdev->skip_vpd_pages = 1; | 187 | sdev->skip_vpd_pages = 1; |
188 | 188 | ||
189 | /* Do not attempt to use REPORT SUPPORTED OPERATION CODES */ | ||
190 | sdev->no_report_opcodes = 1; | ||
191 | |||
192 | /* Do not attempt to use WRITE SAME */ | ||
193 | sdev->no_write_same = 1; | ||
194 | |||
189 | /* Some disks return the total number of blocks in response | 195 | /* Some disks return the total number of blocks in response |
190 | * to READ CAPACITY rather than the highest block number. | 196 | * to READ CAPACITY rather than the highest block number. |
191 | * If this device makes that mistake, tell the sd driver. */ | 197 | * If this device makes that mistake, tell the sd driver. */ |
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 99ac2cb08b43..dedaf81d8f36 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
@@ -1076,7 +1076,7 @@ static int translate_desc(struct vhost_dev *dev, u64 addr, u32 len, | |||
1076 | } | 1076 | } |
1077 | _iov = iov + ret; | 1077 | _iov = iov + ret; |
1078 | size = reg->memory_size - addr + reg->guest_phys_addr; | 1078 | size = reg->memory_size - addr + reg->guest_phys_addr; |
1079 | _iov->iov_len = min((u64)len, size); | 1079 | _iov->iov_len = min((u64)len - s, size); |
1080 | _iov->iov_base = (void __user *)(unsigned long) | 1080 | _iov->iov_base = (void __user *)(unsigned long) |
1081 | (reg->userspace_addr + addr - reg->guest_phys_addr); | 1081 | (reg->userspace_addr + addr - reg->guest_phys_addr); |
1082 | s += size; | 1082 | s += size; |
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c index d64ac3842884..bee92846cfab 100644 --- a/drivers/video/omap2/dss/dsi.c +++ b/drivers/video/omap2/dss/dsi.c | |||
@@ -365,11 +365,20 @@ struct platform_device *dsi_get_dsidev_from_id(int module) | |||
365 | struct omap_dss_output *out; | 365 | struct omap_dss_output *out; |
366 | enum omap_dss_output_id id; | 366 | enum omap_dss_output_id id; |
367 | 367 | ||
368 | id = module == 0 ? OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2; | 368 | switch (module) { |
369 | case 0: | ||
370 | id = OMAP_DSS_OUTPUT_DSI1; | ||
371 | break; | ||
372 | case 1: | ||
373 | id = OMAP_DSS_OUTPUT_DSI2; | ||
374 | break; | ||
375 | default: | ||
376 | return NULL; | ||
377 | } | ||
369 | 378 | ||
370 | out = omap_dss_get_output(id); | 379 | out = omap_dss_get_output(id); |
371 | 380 | ||
372 | return out->pdev; | 381 | return out ? out->pdev : NULL; |
373 | } | 382 | } |
374 | 383 | ||
375 | static inline void dsi_write_reg(struct platform_device *dsidev, | 384 | static inline void dsi_write_reg(struct platform_device *dsidev, |
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c index 2ab1c3e96553..5f6eea801b06 100644 --- a/drivers/video/omap2/dss/dss.c +++ b/drivers/video/omap2/dss/dss.c | |||
@@ -697,11 +697,15 @@ static int dss_get_clocks(void) | |||
697 | 697 | ||
698 | dss.dss_clk = clk; | 698 | dss.dss_clk = clk; |
699 | 699 | ||
700 | clk = clk_get(NULL, dss.feat->clk_name); | 700 | if (dss.feat->clk_name) { |
701 | if (IS_ERR(clk)) { | 701 | clk = clk_get(NULL, dss.feat->clk_name); |
702 | DSSERR("Failed to get %s\n", dss.feat->clk_name); | 702 | if (IS_ERR(clk)) { |
703 | r = PTR_ERR(clk); | 703 | DSSERR("Failed to get %s\n", dss.feat->clk_name); |
704 | goto err; | 704 | r = PTR_ERR(clk); |
705 | goto err; | ||
706 | } | ||
707 | } else { | ||
708 | clk = NULL; | ||
705 | } | 709 | } |
706 | 710 | ||
707 | dss.dpll4_m4_ck = clk; | 711 | dss.dpll4_m4_ck = clk; |
@@ -805,10 +809,10 @@ static int __init dss_init_features(struct device *dev) | |||
805 | 809 | ||
806 | if (cpu_is_omap24xx()) | 810 | if (cpu_is_omap24xx()) |
807 | src = &omap24xx_dss_feats; | 811 | src = &omap24xx_dss_feats; |
808 | else if (cpu_is_omap34xx()) | ||
809 | src = &omap34xx_dss_feats; | ||
810 | else if (cpu_is_omap3630()) | 812 | else if (cpu_is_omap3630()) |
811 | src = &omap3630_dss_feats; | 813 | src = &omap3630_dss_feats; |
814 | else if (cpu_is_omap34xx()) | ||
815 | src = &omap34xx_dss_feats; | ||
812 | else if (cpu_is_omap44xx()) | 816 | else if (cpu_is_omap44xx()) |
813 | src = &omap44xx_dss_feats; | 817 | src = &omap44xx_dss_feats; |
814 | else if (soc_is_omap54xx()) | 818 | else if (soc_is_omap54xx()) |
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c index a48a7dd75b33..8c9b8b3b7f77 100644 --- a/drivers/video/omap2/dss/hdmi.c +++ b/drivers/video/omap2/dss/hdmi.c | |||
@@ -644,8 +644,10 @@ static void hdmi_dump_regs(struct seq_file *s) | |||
644 | { | 644 | { |
645 | mutex_lock(&hdmi.lock); | 645 | mutex_lock(&hdmi.lock); |
646 | 646 | ||
647 | if (hdmi_runtime_get()) | 647 | if (hdmi_runtime_get()) { |
648 | mutex_unlock(&hdmi.lock); | ||
648 | return; | 649 | return; |
650 | } | ||
649 | 651 | ||
650 | hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s); | 652 | hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s); |
651 | hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s); | 653 | hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s); |
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c index 606b89f12351..d630b26a005c 100644 --- a/drivers/video/omap2/omapfb/omapfb-ioctl.c +++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c | |||
@@ -787,7 +787,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg) | |||
787 | 787 | ||
788 | case OMAPFB_WAITFORVSYNC: | 788 | case OMAPFB_WAITFORVSYNC: |
789 | DBG("ioctl WAITFORVSYNC\n"); | 789 | DBG("ioctl WAITFORVSYNC\n"); |
790 | if (!display && !display->output && !display->output->manager) { | 790 | if (!display || !display->output || !display->output->manager) { |
791 | r = -EINVAL; | 791 | r = -EINVAL; |
792 | break; | 792 | break; |
793 | } | 793 | } |
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index 8adb9cc267f9..71f5c459b088 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c | |||
@@ -361,13 +361,13 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version) | |||
361 | down_write(&mm->mmap_sem); | 361 | down_write(&mm->mmap_sem); |
362 | 362 | ||
363 | vma = find_vma(mm, m.addr); | 363 | vma = find_vma(mm, m.addr); |
364 | ret = -EINVAL; | ||
365 | if (!vma || | 364 | if (!vma || |
366 | vma->vm_ops != &privcmd_vm_ops || | 365 | vma->vm_ops != &privcmd_vm_ops || |
367 | (m.addr != vma->vm_start) || | 366 | (m.addr != vma->vm_start) || |
368 | ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) || | 367 | ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) || |
369 | !privcmd_enforce_singleshot_mapping(vma)) { | 368 | !privcmd_enforce_singleshot_mapping(vma)) { |
370 | up_write(&mm->mmap_sem); | 369 | up_write(&mm->mmap_sem); |
370 | ret = -EINVAL; | ||
371 | goto out; | 371 | goto out; |
372 | } | 372 | } |
373 | 373 | ||
@@ -383,12 +383,16 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version) | |||
383 | 383 | ||
384 | up_write(&mm->mmap_sem); | 384 | up_write(&mm->mmap_sem); |
385 | 385 | ||
386 | if (state.global_error && (version == 1)) { | 386 | if (version == 1) { |
387 | /* Write back errors in second pass. */ | 387 | if (state.global_error) { |
388 | state.user_mfn = (xen_pfn_t *)m.arr; | 388 | /* Write back errors in second pass. */ |
389 | state.err = err_array; | 389 | state.user_mfn = (xen_pfn_t *)m.arr; |
390 | ret = traverse_pages(m.num, sizeof(xen_pfn_t), | 390 | state.err = err_array; |
391 | &pagelist, mmap_return_errors_v1, &state); | 391 | ret = traverse_pages(m.num, sizeof(xen_pfn_t), |
392 | &pagelist, mmap_return_errors_v1, &state); | ||
393 | } else | ||
394 | ret = 0; | ||
395 | |||
392 | } else if (version == 2) { | 396 | } else if (version == 2) { |
393 | ret = __copy_to_user(m.err, err_array, m.num * sizeof(int)); | 397 | ret = __copy_to_user(m.err, err_array, m.num * sizeof(int)); |
394 | if (ret) | 398 | if (ret) |