Blame view
drivers/ata/pata_palmld.c
3.18 KB
5a9d25150
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/* * drivers/ata/pata_palmld.c * * Driver for IDE channel in Palm LifeDrive * * Based on research of: * Alex Osborne <ato@meshy.org> * * Rewrite for mainline: * Marek Vasut <marek.vasut@gmail.com> * * Rewritten version based on pata_ixp4xx_cf.c: * ixp4xx PATA/Compact Flash driver * Copyright (C) 2006-07 Tower Technologies * Author: Alessandro Zummo <a.zummo@towertech.it> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/libata.h> #include <linux/irq.h> #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/gpio.h> #include <scsi/scsi_host.h> #include <mach/palmld.h> #define DRV_NAME "pata_palmld" |
6b1e3fca6
|
35 36 37 38 |
static struct gpio palmld_hdd_gpios[] = { { GPIO_NR_PALMLD_IDE_PWEN, GPIOF_INIT_HIGH, "HDD Power" }, { GPIO_NR_PALMLD_IDE_RESET, GPIOF_INIT_LOW, "HDD Reset" }, }; |
5a9d25150
|
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
static struct scsi_host_template palmld_sht = { ATA_PIO_SHT(DRV_NAME), }; static struct ata_port_operations palmld_port_ops = { .inherits = &ata_sff_port_ops, .sff_data_xfer = ata_sff_data_xfer_noirq, .cable_detect = ata_cable_40wire, }; static __devinit int palmld_pata_probe(struct platform_device *pdev) { struct ata_host *host; struct ata_port *ap; void __iomem *mem; int ret; /* allocate host */ host = ata_host_alloc(&pdev->dev, 1); |
6b1e3fca6
|
58 59 60 61 |
if (!host) { ret = -ENOMEM; goto err1; } |
5a9d25150
|
62 63 64 |
/* remap drive's physical memory address */ mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000); |
6b1e3fca6
|
65 66 67 68 |
if (!mem) { ret = -ENOMEM; goto err1; } |
5a9d25150
|
69 70 |
/* request and activate power GPIO, IRQ GPIO */ |
6b1e3fca6
|
71 72 |
ret = gpio_request_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios)); |
5a9d25150
|
73 74 |
if (ret) goto err1; |
5a9d25150
|
75 76 77 78 79 80 81 82 83 84 85 |
/* reset the drive */ gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0); msleep(30); gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 1); msleep(30); /* setup the ata port */ ap = host->ports[0]; ap->ops = &palmld_port_ops; ap->pio_mask = ATA_PIO4; |
9cbe056f6
|
86 |
ap->flags |= ATA_FLAG_PIO_POLLING; |
5a9d25150
|
87 88 89 90 91 92 93 94 95 96 |
/* memory mapping voodoo */ ap->ioaddr.cmd_addr = mem + 0x10; ap->ioaddr.altstatus_addr = mem + 0xe; ap->ioaddr.ctl_addr = mem + 0xe; /* start the port */ ata_sff_std_ports(&ap->ioaddr); /* activate host */ |
6b1e3fca6
|
97 |
ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING, |
5a9d25150
|
98 |
&palmld_sht); |
6b1e3fca6
|
99 100 101 102 |
if (ret) goto err2; return ret; |
5a9d25150
|
103 |
|
5a9d25150
|
104 |
err2: |
6b1e3fca6
|
105 |
gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios)); |
5a9d25150
|
106 107 108 109 110 111 112 113 114 115 116 117 |
err1: return ret; } static __devexit int palmld_pata_remove(struct platform_device *dev) { struct ata_host *host = platform_get_drvdata(dev); ata_host_detach(host); /* power down the HDD */ gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0); |
6b1e3fca6
|
118 |
gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios)); |
5a9d25150
|
119 120 121 122 123 124 125 126 127 128 129 130 |
return 0; } static struct platform_driver palmld_pata_platform_driver = { .driver = { .name = DRV_NAME, .owner = THIS_MODULE, }, .probe = palmld_pata_probe, .remove = __devexit_p(palmld_pata_remove), }; |
99c8ea3e5
|
131 |
module_platform_driver(palmld_pata_platform_driver); |
5a9d25150
|
132 133 134 135 136 |
MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); MODULE_DESCRIPTION("PalmLD PATA driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:" DRV_NAME); |