at v5.10-rc6 106 lines 2.1 kB view raw
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (c) 1996-2002 Russell King. 4 */ 5 6#include <linux/module.h> 7#include <linux/blkdev.h> 8#include <linux/errno.h> 9#include <linux/ide.h> 10#include <linux/init.h> 11 12#include <asm/ecard.h> 13 14static const struct ide_port_info rapide_port_info = { 15 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 16 .chipset = ide_generic, 17}; 18 19static void rapide_setup_ports(struct ide_hw *hw, void __iomem *base, 20 void __iomem *ctrl, unsigned int sz, int irq) 21{ 22 unsigned long port = (unsigned long)base; 23 int i; 24 25 for (i = 0; i <= 7; i++) { 26 hw->io_ports_array[i] = port; 27 port += sz; 28 } 29 hw->io_ports.ctl_addr = (unsigned long)ctrl; 30 hw->irq = irq; 31} 32 33static int rapide_probe(struct expansion_card *ec, const struct ecard_id *id) 34{ 35 void __iomem *base; 36 struct ide_host *host; 37 int ret; 38 struct ide_hw hw, *hws[] = { &hw }; 39 40 ret = ecard_request_resources(ec); 41 if (ret) 42 goto out; 43 44 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); 45 if (!base) { 46 ret = -ENOMEM; 47 goto release; 48 } 49 50 memset(&hw, 0, sizeof(hw)); 51 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); 52 hw.dev = &ec->dev; 53 54 ret = ide_host_add(&rapide_port_info, hws, 1, &host); 55 if (ret) 56 goto release; 57 58 ecard_set_drvdata(ec, host); 59 goto out; 60 61 release: 62 ecard_release_resources(ec); 63 out: 64 return ret; 65} 66 67static void rapide_remove(struct expansion_card *ec) 68{ 69 struct ide_host *host = ecard_get_drvdata(ec); 70 71 ecard_set_drvdata(ec, NULL); 72 73 ide_host_remove(host); 74 75 ecard_release_resources(ec); 76} 77 78static struct ecard_id rapide_ids[] = { 79 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 }, 80 { 0xffff, 0xffff } 81}; 82 83static struct ecard_driver rapide_driver = { 84 .probe = rapide_probe, 85 .remove = rapide_remove, 86 .id_table = rapide_ids, 87 .drv = { 88 .name = "rapide", 89 }, 90}; 91 92static int __init rapide_init(void) 93{ 94 return ecard_register_driver(&rapide_driver); 95} 96 97static void __exit rapide_exit(void) 98{ 99 ecard_remove_driver(&rapide_driver); 100} 101 102MODULE_LICENSE("GPL"); 103MODULE_DESCRIPTION("Yellowstone RAPIDE driver"); 104 105module_init(rapide_init); 106module_exit(rapide_exit);