| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* sun_esp.c: ESP front-end for Sparc SBUS systems. |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2007, 2008 David S. Miller (davem@davemloft.net) |
|---|
| .. | .. |
|---|
| 80 | 81 | |
|---|
| 81 | 82 | static int esp_sbus_map_regs(struct esp *esp, int hme) |
|---|
| 82 | 83 | { |
|---|
| 83 | | - struct platform_device *op = esp->dev; |
|---|
| 84 | + struct platform_device *op = to_platform_device(esp->dev); |
|---|
| 84 | 85 | struct resource *res; |
|---|
| 85 | 86 | |
|---|
| 86 | 87 | /* On HME, two reg sets exist, first is DVMA, |
|---|
| .. | .. |
|---|
| 100 | 101 | |
|---|
| 101 | 102 | static int esp_sbus_map_command_block(struct esp *esp) |
|---|
| 102 | 103 | { |
|---|
| 103 | | - struct platform_device *op = esp->dev; |
|---|
| 104 | | - |
|---|
| 105 | | - esp->command_block = dma_alloc_coherent(&op->dev, 16, |
|---|
| 104 | + esp->command_block = dma_alloc_coherent(esp->dev, 16, |
|---|
| 106 | 105 | &esp->command_block_dma, |
|---|
| 107 | | - GFP_ATOMIC); |
|---|
| 106 | + GFP_KERNEL); |
|---|
| 108 | 107 | if (!esp->command_block) |
|---|
| 109 | 108 | return -ENOMEM; |
|---|
| 110 | 109 | return 0; |
|---|
| .. | .. |
|---|
| 113 | 112 | static int esp_sbus_register_irq(struct esp *esp) |
|---|
| 114 | 113 | { |
|---|
| 115 | 114 | struct Scsi_Host *host = esp->host; |
|---|
| 116 | | - struct platform_device *op = esp->dev; |
|---|
| 115 | + struct platform_device *op = to_platform_device(esp->dev); |
|---|
| 117 | 116 | |
|---|
| 118 | 117 | host->irq = op->archdata.irqs[0]; |
|---|
| 119 | 118 | return request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp); |
|---|
| .. | .. |
|---|
| 121 | 120 | |
|---|
| 122 | 121 | static void esp_get_scsi_id(struct esp *esp, struct platform_device *espdma) |
|---|
| 123 | 122 | { |
|---|
| 124 | | - struct platform_device *op = esp->dev; |
|---|
| 123 | + struct platform_device *op = to_platform_device(esp->dev); |
|---|
| 125 | 124 | struct device_node *dp; |
|---|
| 126 | 125 | |
|---|
| 127 | 126 | dp = op->dev.of_node; |
|---|
| .. | .. |
|---|
| 143 | 142 | |
|---|
| 144 | 143 | static void esp_get_differential(struct esp *esp) |
|---|
| 145 | 144 | { |
|---|
| 146 | | - struct platform_device *op = esp->dev; |
|---|
| 145 | + struct platform_device *op = to_platform_device(esp->dev); |
|---|
| 147 | 146 | struct device_node *dp; |
|---|
| 148 | 147 | |
|---|
| 149 | 148 | dp = op->dev.of_node; |
|---|
| .. | .. |
|---|
| 155 | 154 | |
|---|
| 156 | 155 | static void esp_get_clock_params(struct esp *esp) |
|---|
| 157 | 156 | { |
|---|
| 158 | | - struct platform_device *op = esp->dev; |
|---|
| 157 | + struct platform_device *op = to_platform_device(esp->dev); |
|---|
| 159 | 158 | struct device_node *bus_dp, *dp; |
|---|
| 160 | 159 | int fmhz; |
|---|
| 161 | 160 | |
|---|
| .. | .. |
|---|
| 172 | 171 | static void esp_get_bursts(struct esp *esp, struct platform_device *dma_of) |
|---|
| 173 | 172 | { |
|---|
| 174 | 173 | struct device_node *dma_dp = dma_of->dev.of_node; |
|---|
| 175 | | - struct platform_device *op = esp->dev; |
|---|
| 174 | + struct platform_device *op = to_platform_device(esp->dev); |
|---|
| 176 | 175 | struct device_node *dp; |
|---|
| 177 | 176 | u8 bursts, val; |
|---|
| 178 | 177 | |
|---|
| .. | .. |
|---|
| 212 | 211 | return sbus_readb(esp->regs + (reg * 4UL)); |
|---|
| 213 | 212 | } |
|---|
| 214 | 213 | |
|---|
| 215 | | -static dma_addr_t sbus_esp_map_single(struct esp *esp, void *buf, |
|---|
| 216 | | - size_t sz, int dir) |
|---|
| 217 | | -{ |
|---|
| 218 | | - struct platform_device *op = esp->dev; |
|---|
| 219 | | - |
|---|
| 220 | | - return dma_map_single(&op->dev, buf, sz, dir); |
|---|
| 221 | | -} |
|---|
| 222 | | - |
|---|
| 223 | | -static int sbus_esp_map_sg(struct esp *esp, struct scatterlist *sg, |
|---|
| 224 | | - int num_sg, int dir) |
|---|
| 225 | | -{ |
|---|
| 226 | | - struct platform_device *op = esp->dev; |
|---|
| 227 | | - |
|---|
| 228 | | - return dma_map_sg(&op->dev, sg, num_sg, dir); |
|---|
| 229 | | -} |
|---|
| 230 | | - |
|---|
| 231 | | -static void sbus_esp_unmap_single(struct esp *esp, dma_addr_t addr, |
|---|
| 232 | | - size_t sz, int dir) |
|---|
| 233 | | -{ |
|---|
| 234 | | - struct platform_device *op = esp->dev; |
|---|
| 235 | | - |
|---|
| 236 | | - dma_unmap_single(&op->dev, addr, sz, dir); |
|---|
| 237 | | -} |
|---|
| 238 | | - |
|---|
| 239 | | -static void sbus_esp_unmap_sg(struct esp *esp, struct scatterlist *sg, |
|---|
| 240 | | - int num_sg, int dir) |
|---|
| 241 | | -{ |
|---|
| 242 | | - struct platform_device *op = esp->dev; |
|---|
| 243 | | - |
|---|
| 244 | | - dma_unmap_sg(&op->dev, sg, num_sg, dir); |
|---|
| 245 | | -} |
|---|
| 246 | | - |
|---|
| 247 | 214 | static int sbus_esp_irq_pending(struct esp *esp) |
|---|
| 248 | 215 | { |
|---|
| 249 | 216 | if (dma_read32(DMA_CSR) & (DMA_HNDL_INTR | DMA_HNDL_ERROR)) |
|---|
| .. | .. |
|---|
| 255 | 222 | { |
|---|
| 256 | 223 | int can_do_burst16, can_do_burst32, can_do_burst64; |
|---|
| 257 | 224 | int can_do_sbus64, lim; |
|---|
| 258 | | - struct platform_device *op; |
|---|
| 225 | + struct platform_device *op = to_platform_device(esp->dev); |
|---|
| 259 | 226 | u32 val; |
|---|
| 260 | 227 | |
|---|
| 261 | 228 | can_do_burst16 = (esp->bursts & DMA_BURST16) != 0; |
|---|
| 262 | 229 | can_do_burst32 = (esp->bursts & DMA_BURST32) != 0; |
|---|
| 263 | 230 | can_do_burst64 = 0; |
|---|
| 264 | 231 | can_do_sbus64 = 0; |
|---|
| 265 | | - op = esp->dev; |
|---|
| 266 | 232 | if (sbus_can_dma_64bit()) |
|---|
| 267 | 233 | can_do_sbus64 = 1; |
|---|
| 268 | 234 | if (sbus_can_burst64()) |
|---|
| .. | .. |
|---|
| 474 | 440 | static const struct esp_driver_ops sbus_esp_ops = { |
|---|
| 475 | 441 | .esp_write8 = sbus_esp_write8, |
|---|
| 476 | 442 | .esp_read8 = sbus_esp_read8, |
|---|
| 477 | | - .map_single = sbus_esp_map_single, |
|---|
| 478 | | - .map_sg = sbus_esp_map_sg, |
|---|
| 479 | | - .unmap_single = sbus_esp_unmap_single, |
|---|
| 480 | | - .unmap_sg = sbus_esp_unmap_sg, |
|---|
| 481 | 443 | .irq_pending = sbus_esp_irq_pending, |
|---|
| 482 | 444 | .reset_dma = sbus_esp_reset_dma, |
|---|
| 483 | 445 | .dma_drain = sbus_esp_dma_drain, |
|---|
| .. | .. |
|---|
| 504 | 466 | esp = shost_priv(host); |
|---|
| 505 | 467 | |
|---|
| 506 | 468 | esp->host = host; |
|---|
| 507 | | - esp->dev = op; |
|---|
| 469 | + esp->dev = &op->dev; |
|---|
| 508 | 470 | esp->ops = &sbus_esp_ops; |
|---|
| 509 | 471 | |
|---|
| 510 | 472 | if (hme) |
|---|
| .. | .. |
|---|
| 540 | 502 | |
|---|
| 541 | 503 | dev_set_drvdata(&op->dev, esp); |
|---|
| 542 | 504 | |
|---|
| 543 | | - err = scsi_esp_register(esp, &op->dev); |
|---|
| 505 | + err = scsi_esp_register(esp); |
|---|
| 544 | 506 | if (err) |
|---|
| 545 | 507 | goto fail_free_irq; |
|---|
| 546 | 508 | |
|---|
| .. | .. |
|---|
| 568 | 530 | int hme = 0; |
|---|
| 569 | 531 | int ret; |
|---|
| 570 | 532 | |
|---|
| 571 | | - if (dp->parent && |
|---|
| 572 | | - (!strcmp(dp->parent->name, "espdma") || |
|---|
| 573 | | - !strcmp(dp->parent->name, "dma"))) |
|---|
| 533 | + if (of_node_name_eq(dp->parent, "espdma") || |
|---|
| 534 | + of_node_name_eq(dp->parent, "dma")) |
|---|
| 574 | 535 | dma_node = dp->parent; |
|---|
| 575 | | - else if (!strcmp(dp->name, "SUNW,fas")) { |
|---|
| 536 | + else if (of_node_name_eq(dp, "SUNW,fas")) { |
|---|
| 576 | 537 | dma_node = op->dev.of_node; |
|---|
| 577 | 538 | hme = 1; |
|---|
| 578 | 539 | } |
|---|
| .. | .. |
|---|
| 645 | 606 | .probe = esp_sbus_probe, |
|---|
| 646 | 607 | .remove = esp_sbus_remove, |
|---|
| 647 | 608 | }; |
|---|
| 648 | | - |
|---|
| 649 | | -static int __init sunesp_init(void) |
|---|
| 650 | | -{ |
|---|
| 651 | | - return platform_driver_register(&esp_sbus_driver); |
|---|
| 652 | | -} |
|---|
| 653 | | - |
|---|
| 654 | | -static void __exit sunesp_exit(void) |
|---|
| 655 | | -{ |
|---|
| 656 | | - platform_driver_unregister(&esp_sbus_driver); |
|---|
| 657 | | -} |
|---|
| 609 | +module_platform_driver(esp_sbus_driver); |
|---|
| 658 | 610 | |
|---|
| 659 | 611 | MODULE_DESCRIPTION("Sun ESP SCSI driver"); |
|---|
| 660 | 612 | MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); |
|---|
| 661 | 613 | MODULE_LICENSE("GPL"); |
|---|
| 662 | 614 | MODULE_VERSION(DRV_VERSION); |
|---|
| 663 | | - |
|---|
| 664 | | -module_init(sunesp_init); |
|---|
| 665 | | -module_exit(sunesp_exit); |
|---|