Blame view
drivers/ata/pata_palmld.c
3.1 KB
d2912cb15 treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
5a9d25150 [ARM] 5522/1: Pal... |
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/* * 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> |
5a9d25150 [ARM] 5522/1: Pal... |
17 18 19 20 21 22 23 24 |
*/ #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> |
f43e4b007 ata: palmld: Conv... |
25 |
#include <linux/gpio/consumer.h> |
5a9d25150 [ARM] 5522/1: Pal... |
26 27 28 29 30 |
#include <scsi/scsi_host.h> #include <mach/palmld.h> #define DRV_NAME "pata_palmld" |
614c61a65 ata: palmld: Intr... |
31 32 33 34 35 |
struct palmld_pata { struct ata_host *host; struct gpio_desc *power; struct gpio_desc *reset; }; |
6b1e3fca6 ARM: pxa: Use gpi... |
36 |
|
5a9d25150 [ARM] 5522/1: Pal... |
37 38 39 40 41 42 |
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, |
23ebda2fc libata: remove at... |
43 |
.sff_data_xfer = ata_sff_data_xfer32, |
5a9d25150 [ARM] 5522/1: Pal... |
44 45 |
.cable_detect = ata_cable_40wire, }; |
0ec249146 Drivers: ata: rem... |
46 |
static int palmld_pata_probe(struct platform_device *pdev) |
5a9d25150 [ARM] 5522/1: Pal... |
47 |
{ |
614c61a65 ata: palmld: Intr... |
48 |
struct palmld_pata *lda; |
5a9d25150 [ARM] 5522/1: Pal... |
49 50 |
struct ata_port *ap; void __iomem *mem; |
f43e4b007 ata: palmld: Conv... |
51 |
struct device *dev = &pdev->dev; |
5a9d25150 [ARM] 5522/1: Pal... |
52 |
int ret; |
614c61a65 ata: palmld: Intr... |
53 54 55 |
lda = devm_kzalloc(dev, sizeof(*lda), GFP_KERNEL); if (!lda) return -ENOMEM; |
5a9d25150 [ARM] 5522/1: Pal... |
56 |
/* allocate host */ |
614c61a65 ata: palmld: Intr... |
57 58 |
lda->host = ata_host_alloc(dev, 1); if (!lda->host) |
f43e4b007 ata: palmld: Conv... |
59 |
return -ENOMEM; |
5a9d25150 [ARM] 5522/1: Pal... |
60 61 |
/* remap drive's physical memory address */ |
f43e4b007 ata: palmld: Conv... |
62 63 64 65 66 |
mem = devm_ioremap(dev, PALMLD_IDE_PHYS, 0x1000); if (!mem) return -ENOMEM; /* request and activate power and reset GPIOs */ |
614c61a65 ata: palmld: Intr... |
67 68 69 70 71 72 73 |
lda->power = devm_gpiod_get(dev, "power", GPIOD_OUT_HIGH); if (IS_ERR(lda->power)) return PTR_ERR(lda->power); lda->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(lda->reset)) { gpiod_set_value(lda->power, 0); return PTR_ERR(lda->reset); |
6b1e3fca6 ARM: pxa: Use gpi... |
74 |
} |
5a9d25150 [ARM] 5522/1: Pal... |
75 |
|
f43e4b007 ata: palmld: Conv... |
76 |
/* Assert reset to reset the drive */ |
614c61a65 ata: palmld: Intr... |
77 |
gpiod_set_value(lda->reset, 1); |
5a9d25150 [ARM] 5522/1: Pal... |
78 |
msleep(30); |
614c61a65 ata: palmld: Intr... |
79 |
gpiod_set_value(lda->reset, 0); |
5a9d25150 [ARM] 5522/1: Pal... |
80 81 82 |
msleep(30); /* setup the ata port */ |
614c61a65 ata: palmld: Intr... |
83 |
ap = lda->host->ports[0]; |
5a9d25150 [ARM] 5522/1: Pal... |
84 85 |
ap->ops = &palmld_port_ops; ap->pio_mask = ATA_PIO4; |
9cbe056f6 libata: remove AT... |
86 |
ap->flags |= ATA_FLAG_PIO_POLLING; |
5a9d25150 [ARM] 5522/1: Pal... |
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 */ |
614c61a65 ata: palmld: Intr... |
97 98 |
ret = ata_host_activate(lda->host, 0, NULL, IRQF_TRIGGER_RISING, &palmld_sht); |
f43e4b007 ata: palmld: Conv... |
99 |
/* power down on failure */ |
614c61a65 ata: palmld: Intr... |
100 101 102 103 104 105 106 |
if (ret) { gpiod_set_value(lda->power, 0); return ret; } platform_set_drvdata(pdev, lda); return 0; |
5a9d25150 [ARM] 5522/1: Pal... |
107 |
} |
614c61a65 ata: palmld: Intr... |
108 |
static int palmld_pata_remove(struct platform_device *pdev) |
5a9d25150 [ARM] 5522/1: Pal... |
109 |
{ |
614c61a65 ata: palmld: Intr... |
110 111 112 |
struct palmld_pata *lda = platform_get_drvdata(pdev); ata_platform_remove_one(pdev); |
5a9d25150 [ARM] 5522/1: Pal... |
113 114 |
/* power down the HDD */ |
614c61a65 ata: palmld: Intr... |
115 |
gpiod_set_value(lda->power, 0); |
5a9d25150 [ARM] 5522/1: Pal... |
116 117 118 119 120 121 122 |
return 0; } static struct platform_driver palmld_pata_platform_driver = { .driver = { .name = DRV_NAME, |
5a9d25150 [ARM] 5522/1: Pal... |
123 124 |
}, .probe = palmld_pata_probe, |
0ec249146 Drivers: ata: rem... |
125 |
.remove = palmld_pata_remove, |
5a9d25150 [ARM] 5522/1: Pal... |
126 |
}; |
99c8ea3e5 SATA/PATA: conver... |
127 |
module_platform_driver(palmld_pata_platform_driver); |
5a9d25150 [ARM] 5522/1: Pal... |
128 129 130 131 132 |
MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); MODULE_DESCRIPTION("PalmLD PATA driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:" DRV_NAME); |