diff options
author | Tejun Heo <tj@kernel.org> | 2009-07-03 18:13:18 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2009-07-03 18:13:18 -0400 |
commit | c43768cbb7655ea5ff782ae250f6e2ef4297cf98 (patch) | |
tree | 3982e41dde3eecaa3739a5d1a8ed18d04bd74f01 /drivers/ata | |
parent | 1a8dd307cc0a2119be4e578c517795464e6dabba (diff) | |
parent | 746a99a5af60ee676afa2ba469ccd1373493c7e7 (diff) |
Merge branch 'master' into for-next
Pull linus#master to merge PER_CPU_DEF_ATTRIBUTES and alpha build fix
changes. As alpha in percpu tree uses 'weak' attribute instead of
inline assembly, there's no need for __used attribute.
Conflicts:
arch/alpha/include/asm/percpu.h
arch/mn10300/kernel/vmlinux.lds.S
include/linux/percpu-defs.h
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/Kconfig | 8 | ||||
-rw-r--r-- | drivers/ata/Makefile | 1 | ||||
-rw-r--r-- | drivers/ata/libata-core.c | 25 | ||||
-rw-r--r-- | drivers/ata/pata_at91.c | 361 | ||||
-rw-r--r-- | drivers/ata/sata_fsl.c | 35 |
5 files changed, 420 insertions, 10 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 2aa1908e5ce0..b17c57f85032 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -679,6 +679,14 @@ config PATA_PLATFORM | |||
679 | 679 | ||
680 | If unsure, say N. | 680 | If unsure, say N. |
681 | 681 | ||
682 | config PATA_AT91 | ||
683 | tristate "PATA support for AT91SAM9260" | ||
684 | depends on ARM && ARCH_AT91 | ||
685 | help | ||
686 | This option enables support for IDE devices on the Atmel AT91SAM9260 SoC. | ||
687 | |||
688 | If unsure, say N. | ||
689 | |||
682 | config PATA_OF_PLATFORM | 690 | config PATA_OF_PLATFORM |
683 | tristate "OpenFirmware platform device PATA support" | 691 | tristate "OpenFirmware platform device PATA support" |
684 | depends on PATA_PLATFORM && PPC_OF | 692 | depends on PATA_PLATFORM && PPC_OF |
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 1558059874f0..38906f9bbb4e 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
@@ -72,6 +72,7 @@ obj-$(CONFIG_PATA_SCH) += pata_sch.o | |||
72 | obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o | 72 | obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o |
73 | obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o | 73 | obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o |
74 | obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o | 74 | obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o |
75 | obj-$(CONFIG_PATA_AT91) += pata_at91.o | ||
75 | obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o | 76 | obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o |
76 | obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o | 77 | obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o |
77 | # Should be last but two libata driver | 78 | # Should be last but two libata driver |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index ca4d208ddf3b..045a486a09ea 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -125,19 +125,19 @@ MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link spe | |||
125 | 125 | ||
126 | static int atapi_enabled = 1; | 126 | static int atapi_enabled = 1; |
127 | module_param(atapi_enabled, int, 0444); | 127 | module_param(atapi_enabled, int, 0444); |
128 | MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); | 128 | MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on [default])"); |
129 | 129 | ||
130 | static int atapi_dmadir = 0; | 130 | static int atapi_dmadir = 0; |
131 | module_param(atapi_dmadir, int, 0444); | 131 | module_param(atapi_dmadir, int, 0444); |
132 | MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off, 1=on)"); | 132 | MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off [default], 1=on)"); |
133 | 133 | ||
134 | int atapi_passthru16 = 1; | 134 | int atapi_passthru16 = 1; |
135 | module_param(atapi_passthru16, int, 0444); | 135 | module_param(atapi_passthru16, int, 0444); |
136 | MODULE_PARM_DESC(atapi_passthru16, "Enable ATA_16 passthru for ATAPI devices; on by default (0=off, 1=on)"); | 136 | MODULE_PARM_DESC(atapi_passthru16, "Enable ATA_16 passthru for ATAPI devices (0=off, 1=on [default])"); |
137 | 137 | ||
138 | int libata_fua = 0; | 138 | int libata_fua = 0; |
139 | module_param_named(fua, libata_fua, int, 0444); | 139 | module_param_named(fua, libata_fua, int, 0444); |
140 | MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); | 140 | MODULE_PARM_DESC(fua, "FUA support (0=off [default], 1=on)"); |
141 | 141 | ||
142 | static int ata_ignore_hpa; | 142 | static int ata_ignore_hpa; |
143 | module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644); | 143 | module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644); |
@@ -153,11 +153,11 @@ MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)"); | |||
153 | 153 | ||
154 | int libata_noacpi = 0; | 154 | int libata_noacpi = 0; |
155 | module_param_named(noacpi, libata_noacpi, int, 0444); | 155 | module_param_named(noacpi, libata_noacpi, int, 0444); |
156 | MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in probe/suspend/resume when set"); | 156 | MODULE_PARM_DESC(noacpi, "Disable the use of ACPI in probe/suspend/resume (0=off [default], 1=on)"); |
157 | 157 | ||
158 | int libata_allow_tpm = 0; | 158 | int libata_allow_tpm = 0; |
159 | module_param_named(allow_tpm, libata_allow_tpm, int, 0444); | 159 | module_param_named(allow_tpm, libata_allow_tpm, int, 0444); |
160 | MODULE_PARM_DESC(allow_tpm, "Permit the use of TPM commands"); | 160 | MODULE_PARM_DESC(allow_tpm, "Permit the use of TPM commands (0=off [default], 1=on)"); |
161 | 161 | ||
162 | MODULE_AUTHOR("Jeff Garzik"); | 162 | MODULE_AUTHOR("Jeff Garzik"); |
163 | MODULE_DESCRIPTION("Library module for ATA devices"); | 163 | MODULE_DESCRIPTION("Library module for ATA devices"); |
@@ -1993,11 +1993,17 @@ unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) | |||
1993 | * Check if the current speed of the device requires IORDY. Used | 1993 | * Check if the current speed of the device requires IORDY. Used |
1994 | * by various controllers for chip configuration. | 1994 | * by various controllers for chip configuration. |
1995 | */ | 1995 | */ |
1996 | |||
1997 | unsigned int ata_pio_need_iordy(const struct ata_device *adev) | 1996 | unsigned int ata_pio_need_iordy(const struct ata_device *adev) |
1998 | { | 1997 | { |
1999 | /* Controller doesn't support IORDY. Probably a pointless check | 1998 | /* Don't set IORDY if we're preparing for reset. IORDY may |
2000 | as the caller should know this */ | 1999 | * lead to controller lock up on certain controllers if the |
2000 | * port is not occupied. See bko#11703 for details. | ||
2001 | */ | ||
2002 | if (adev->link->ap->pflags & ATA_PFLAG_RESETTING) | ||
2003 | return 0; | ||
2004 | /* Controller doesn't support IORDY. Probably a pointless | ||
2005 | * check as the caller should know this. | ||
2006 | */ | ||
2001 | if (adev->link->ap->flags & ATA_FLAG_NO_IORDY) | 2007 | if (adev->link->ap->flags & ATA_FLAG_NO_IORDY) |
2002 | return 0; | 2008 | return 0; |
2003 | /* CF spec. r4.1 Table 22 says no iordy on PIO5 and PIO6. */ | 2009 | /* CF spec. r4.1 Table 22 says no iordy on PIO5 and PIO6. */ |
@@ -2020,7 +2026,6 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
2020 | * Compute the highest mode possible if we are not using iordy. Return | 2026 | * Compute the highest mode possible if we are not using iordy. Return |
2021 | * -1 if no iordy mode is available. | 2027 | * -1 if no iordy mode is available. |
2022 | */ | 2028 | */ |
2023 | |||
2024 | static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) | 2029 | static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) |
2025 | { | 2030 | { |
2026 | /* If we have no drive specific rule, then PIO 2 is non IORDY */ | 2031 | /* If we have no drive specific rule, then PIO 2 is non IORDY */ |
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c new file mode 100644 index 000000000000..4b27617be26d --- /dev/null +++ b/drivers/ata/pata_at91.c | |||
@@ -0,0 +1,361 @@ | |||
1 | /* | ||
2 | * PATA driver for AT91SAM9260 Static Memory Controller | ||
3 | * with CompactFlash interface in True IDE mode | ||
4 | * | ||
5 | * Copyright (C) 2009 Matyukevich Sergey | ||
6 | * | ||
7 | * Based on: | ||
8 | * * generic platform driver by Paul Mundt: drivers/ata/pata_platform.c | ||
9 | * * pata_at32 driver by Kristoffer Nyborg Gregertsen | ||
10 | * * at91_ide driver by Stanislaw Gruszka | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License version 2 | ||
14 | * as published by the Free Software Foundation. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/blkdev.h> | ||
22 | #include <scsi/scsi_host.h> | ||
23 | #include <linux/ata.h> | ||
24 | #include <linux/clk.h> | ||
25 | #include <linux/libata.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/ata_platform.h> | ||
28 | |||
29 | #include <mach/at91sam9260_matrix.h> | ||
30 | #include <mach/at91sam9_smc.h> | ||
31 | #include <mach/at91sam9260.h> | ||
32 | #include <mach/board.h> | ||
33 | #include <mach/gpio.h> | ||
34 | |||
35 | |||
36 | #define DRV_NAME "pata_at91" | ||
37 | #define DRV_VERSION "0.1" | ||
38 | |||
39 | #define CF_IDE_OFFSET 0x00c00000 | ||
40 | #define CF_ALT_IDE_OFFSET 0x00e00000 | ||
41 | #define CF_IDE_RES_SIZE 0x08 | ||
42 | |||
43 | struct at91_ide_info { | ||
44 | unsigned long mode; | ||
45 | unsigned int cs; | ||
46 | |||
47 | void __iomem *ide_addr; | ||
48 | void __iomem *alt_addr; | ||
49 | }; | ||
50 | |||
51 | const struct ata_timing initial_timing = | ||
52 | {XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0}; | ||
53 | |||
54 | static unsigned int calc_mck_cycles(unsigned int ns, unsigned int mck_hz) | ||
55 | { | ||
56 | unsigned long mul; | ||
57 | |||
58 | /* | ||
59 | * cycles = x [nsec] * f [Hz] / 10^9 [ns in sec] = | ||
60 | * x * (f / 1_000_000_000) = | ||
61 | * x * ((f * 65536) / 1_000_000_000) / 65536 = | ||
62 | * x * (((f / 10_000) * 65536) / 100_000) / 65536 = | ||
63 | */ | ||
64 | |||
65 | mul = (mck_hz / 10000) << 16; | ||
66 | mul /= 100000; | ||
67 | |||
68 | return (ns * mul + 65536) >> 16; /* rounding */ | ||
69 | } | ||
70 | |||
71 | static void set_smc_mode(struct at91_ide_info *info) | ||
72 | { | ||
73 | at91_sys_write(AT91_SMC_MODE(info->cs), info->mode); | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | static void set_smc_timing(struct device *dev, | ||
78 | struct at91_ide_info *info, const struct ata_timing *ata) | ||
79 | { | ||
80 | int read_cycle, write_cycle, active, recover; | ||
81 | int nrd_setup, nrd_pulse, nrd_recover; | ||
82 | int nwe_setup, nwe_pulse; | ||
83 | |||
84 | int ncs_write_setup, ncs_write_pulse; | ||
85 | int ncs_read_setup, ncs_read_pulse; | ||
86 | |||
87 | unsigned int mck_hz; | ||
88 | struct clk *mck; | ||
89 | |||
90 | read_cycle = ata->cyc8b; | ||
91 | nrd_setup = ata->setup; | ||
92 | nrd_pulse = ata->act8b; | ||
93 | nrd_recover = ata->rec8b; | ||
94 | |||
95 | mck = clk_get(NULL, "mck"); | ||
96 | BUG_ON(IS_ERR(mck)); | ||
97 | mck_hz = clk_get_rate(mck); | ||
98 | |||
99 | read_cycle = calc_mck_cycles(read_cycle, mck_hz); | ||
100 | nrd_setup = calc_mck_cycles(nrd_setup, mck_hz); | ||
101 | nrd_pulse = calc_mck_cycles(nrd_pulse, mck_hz); | ||
102 | nrd_recover = calc_mck_cycles(nrd_recover, mck_hz); | ||
103 | |||
104 | clk_put(mck); | ||
105 | |||
106 | active = nrd_setup + nrd_pulse; | ||
107 | recover = read_cycle - active; | ||
108 | |||
109 | /* Need at least two cycles recovery */ | ||
110 | if (recover < 2) | ||
111 | read_cycle = active + 2; | ||
112 | |||
113 | /* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */ | ||
114 | ncs_read_setup = 1; | ||
115 | ncs_read_pulse = read_cycle - 2; | ||
116 | |||
117 | /* Write timings same as read timings */ | ||
118 | write_cycle = read_cycle; | ||
119 | nwe_setup = nrd_setup; | ||
120 | nwe_pulse = nrd_pulse; | ||
121 | ncs_write_setup = ncs_read_setup; | ||
122 | ncs_write_pulse = ncs_read_pulse; | ||
123 | |||
124 | dev_dbg(dev, "ATA timings: nrd_setup = %d nrd_pulse = %d nrd_cycle = %d\n", | ||
125 | nrd_setup, nrd_pulse, read_cycle); | ||
126 | dev_dbg(dev, "ATA timings: nwe_setup = %d nwe_pulse = %d nwe_cycle = %d\n", | ||
127 | nwe_setup, nwe_pulse, write_cycle); | ||
128 | dev_dbg(dev, "ATA timings: ncs_read_setup = %d ncs_read_pulse = %d\n", | ||
129 | ncs_read_setup, ncs_read_pulse); | ||
130 | dev_dbg(dev, "ATA timings: ncs_write_setup = %d ncs_write_pulse = %d\n", | ||
131 | ncs_write_setup, ncs_write_pulse); | ||
132 | |||
133 | at91_sys_write(AT91_SMC_SETUP(info->cs), | ||
134 | AT91_SMC_NWESETUP_(nwe_setup) | | ||
135 | AT91_SMC_NRDSETUP_(nrd_setup) | | ||
136 | AT91_SMC_NCS_WRSETUP_(ncs_write_setup) | | ||
137 | AT91_SMC_NCS_RDSETUP_(ncs_read_setup)); | ||
138 | |||
139 | at91_sys_write(AT91_SMC_PULSE(info->cs), | ||
140 | AT91_SMC_NWEPULSE_(nwe_pulse) | | ||
141 | AT91_SMC_NRDPULSE_(nrd_pulse) | | ||
142 | AT91_SMC_NCS_WRPULSE_(ncs_write_pulse) | | ||
143 | AT91_SMC_NCS_RDPULSE_(ncs_read_pulse)); | ||
144 | |||
145 | at91_sys_write(AT91_SMC_CYCLE(info->cs), | ||
146 | AT91_SMC_NWECYCLE_(write_cycle) | | ||
147 | AT91_SMC_NRDCYCLE_(read_cycle)); | ||
148 | |||
149 | return; | ||
150 | } | ||
151 | |||
152 | static void pata_at91_set_piomode(struct ata_port *ap, struct ata_device *adev) | ||
153 | { | ||
154 | struct at91_ide_info *info = ap->host->private_data; | ||
155 | struct ata_timing timing; | ||
156 | int ret; | ||
157 | |||
158 | /* Compute ATA timing and set it to SMC */ | ||
159 | ret = ata_timing_compute(adev, adev->pio_mode, &timing, 1000, 0); | ||
160 | if (ret) { | ||
161 | dev_warn(ap->dev, "Failed to compute ATA timing %d, \ | ||
162 | set PIO_0 timing\n", ret); | ||
163 | set_smc_timing(ap->dev, info, &initial_timing); | ||
164 | } else { | ||
165 | set_smc_timing(ap->dev, info, &timing); | ||
166 | } | ||
167 | |||
168 | /* Setup SMC mode */ | ||
169 | set_smc_mode(info); | ||
170 | |||
171 | return; | ||
172 | } | ||
173 | |||
174 | static unsigned int pata_at91_data_xfer_noirq(struct ata_device *dev, | ||
175 | unsigned char *buf, unsigned int buflen, int rw) | ||
176 | { | ||
177 | struct at91_ide_info *info = dev->link->ap->host->private_data; | ||
178 | unsigned int consumed; | ||
179 | unsigned long flags; | ||
180 | unsigned int mode; | ||
181 | |||
182 | local_irq_save(flags); | ||
183 | mode = at91_sys_read(AT91_SMC_MODE(info->cs)); | ||
184 | |||
185 | /* set 16bit mode before writing data */ | ||
186 | at91_sys_write(AT91_SMC_MODE(info->cs), | ||
187 | (mode & ~AT91_SMC_DBW) | AT91_SMC_DBW_16); | ||
188 | |||
189 | consumed = ata_sff_data_xfer(dev, buf, buflen, rw); | ||
190 | |||
191 | /* restore 8bit mode after data is written */ | ||
192 | at91_sys_write(AT91_SMC_MODE(info->cs), | ||
193 | (mode & ~AT91_SMC_DBW) | AT91_SMC_DBW_8); | ||
194 | |||
195 | local_irq_restore(flags); | ||
196 | return consumed; | ||
197 | } | ||
198 | |||
199 | static struct scsi_host_template pata_at91_sht = { | ||
200 | ATA_PIO_SHT(DRV_NAME), | ||
201 | }; | ||
202 | |||
203 | static struct ata_port_operations pata_at91_port_ops = { | ||
204 | .inherits = &ata_sff_port_ops, | ||
205 | |||
206 | .sff_data_xfer = pata_at91_data_xfer_noirq, | ||
207 | .set_piomode = pata_at91_set_piomode, | ||
208 | .cable_detect = ata_cable_40wire, | ||
209 | .port_start = ATA_OP_NULL, | ||
210 | }; | ||
211 | |||
212 | static int __devinit pata_at91_probe(struct platform_device *pdev) | ||
213 | { | ||
214 | struct at91_cf_data *board = pdev->dev.platform_data; | ||
215 | struct device *dev = &pdev->dev; | ||
216 | struct at91_ide_info *info; | ||
217 | struct resource *mem_res; | ||
218 | struct ata_host *host; | ||
219 | struct ata_port *ap; | ||
220 | int irq_flags = 0; | ||
221 | int irq = 0; | ||
222 | int ret; | ||
223 | |||
224 | /* get platform resources: IO/CTL memories and irq/rst pins */ | ||
225 | |||
226 | if (pdev->num_resources != 1) { | ||
227 | dev_err(&pdev->dev, "invalid number of resources\n"); | ||
228 | return -EINVAL; | ||
229 | } | ||
230 | |||
231 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
232 | |||
233 | if (!mem_res) { | ||
234 | dev_err(dev, "failed to get mem resource\n"); | ||
235 | return -EINVAL; | ||
236 | } | ||
237 | |||
238 | irq = board->irq_pin; | ||
239 | |||
240 | /* init ata host */ | ||
241 | |||
242 | host = ata_host_alloc(dev, 1); | ||
243 | |||
244 | if (!host) | ||
245 | return -ENOMEM; | ||
246 | |||
247 | ap = host->ports[0]; | ||
248 | ap->ops = &pata_at91_port_ops; | ||
249 | ap->flags |= ATA_FLAG_SLAVE_POSS; | ||
250 | ap->pio_mask = ATA_PIO4; | ||
251 | |||
252 | if (!irq) { | ||
253 | ap->flags |= ATA_FLAG_PIO_POLLING; | ||
254 | ata_port_desc(ap, "no IRQ, using PIO polling"); | ||
255 | } | ||
256 | |||
257 | info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
258 | |||
259 | if (!info) { | ||
260 | dev_err(dev, "failed to allocate memory for private data\n"); | ||
261 | return -ENOMEM; | ||
262 | } | ||
263 | |||
264 | info->cs = board->chipselect; | ||
265 | info->mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | | ||
266 | AT91_SMC_EXNWMODE_READY | AT91_SMC_BAT_SELECT | | ||
267 | AT91_SMC_DBW_8 | AT91_SMC_TDF_(0); | ||
268 | |||
269 | info->ide_addr = devm_ioremap(dev, | ||
270 | mem_res->start + CF_IDE_OFFSET, CF_IDE_RES_SIZE); | ||
271 | |||
272 | if (!info->ide_addr) { | ||
273 | dev_err(dev, "failed to map IO base\n"); | ||
274 | ret = -ENOMEM; | ||
275 | goto err_ide_ioremap; | ||
276 | } | ||
277 | |||
278 | info->alt_addr = devm_ioremap(dev, | ||
279 | mem_res->start + CF_ALT_IDE_OFFSET, CF_IDE_RES_SIZE); | ||
280 | |||
281 | if (!info->alt_addr) { | ||
282 | dev_err(dev, "failed to map CTL base\n"); | ||
283 | ret = -ENOMEM; | ||
284 | goto err_alt_ioremap; | ||
285 | } | ||
286 | |||
287 | ap->ioaddr.cmd_addr = info->ide_addr; | ||
288 | ap->ioaddr.ctl_addr = info->alt_addr + 0x06; | ||
289 | ap->ioaddr.altstatus_addr = ap->ioaddr.ctl_addr; | ||
290 | |||
291 | ata_sff_std_ports(&ap->ioaddr); | ||
292 | |||
293 | ata_port_desc(ap, "mmio cmd 0x%llx ctl 0x%llx", | ||
294 | (unsigned long long)mem_res->start + CF_IDE_OFFSET, | ||
295 | (unsigned long long)mem_res->start + CF_ALT_IDE_OFFSET); | ||
296 | |||
297 | host->private_data = info; | ||
298 | |||
299 | return ata_host_activate(host, irq ? gpio_to_irq(irq) : 0, | ||
300 | irq ? ata_sff_interrupt : NULL, | ||
301 | irq_flags, &pata_at91_sht); | ||
302 | |||
303 | err_alt_ioremap: | ||
304 | devm_iounmap(dev, info->ide_addr); | ||
305 | |||
306 | err_ide_ioremap: | ||
307 | kfree(info); | ||
308 | |||
309 | return ret; | ||
310 | } | ||
311 | |||
312 | static int __devexit pata_at91_remove(struct platform_device *pdev) | ||
313 | { | ||
314 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | ||
315 | struct at91_ide_info *info = host->private_data; | ||
316 | struct device *dev = &pdev->dev; | ||
317 | |||
318 | if (!host) | ||
319 | return 0; | ||
320 | |||
321 | ata_host_detach(host); | ||
322 | |||
323 | if (!info) | ||
324 | return 0; | ||
325 | |||
326 | devm_iounmap(dev, info->ide_addr); | ||
327 | devm_iounmap(dev, info->alt_addr); | ||
328 | |||
329 | kfree(info); | ||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | static struct platform_driver pata_at91_driver = { | ||
334 | .probe = pata_at91_probe, | ||
335 | .remove = __devexit_p(pata_at91_remove), | ||
336 | .driver = { | ||
337 | .name = DRV_NAME, | ||
338 | .owner = THIS_MODULE, | ||
339 | }, | ||
340 | }; | ||
341 | |||
342 | static int __init pata_at91_init(void) | ||
343 | { | ||
344 | return platform_driver_register(&pata_at91_driver); | ||
345 | } | ||
346 | |||
347 | static void __exit pata_at91_exit(void) | ||
348 | { | ||
349 | platform_driver_unregister(&pata_at91_driver); | ||
350 | } | ||
351 | |||
352 | |||
353 | module_init(pata_at91_init); | ||
354 | module_exit(pata_at91_exit); | ||
355 | |||
356 | |||
357 | MODULE_LICENSE("GPL"); | ||
358 | MODULE_DESCRIPTION("Driver for CF in True IDE mode on AT91SAM9260 SoC"); | ||
359 | MODULE_AUTHOR("Matyukevich Sergey"); | ||
360 | MODULE_VERSION(DRV_VERSION); | ||
361 | |||
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c index 36b8629203be..94eaa432c40a 100644 --- a/drivers/ata/sata_fsl.c +++ b/drivers/ata/sata_fsl.c | |||
@@ -1378,6 +1378,37 @@ static int sata_fsl_remove(struct of_device *ofdev) | |||
1378 | return 0; | 1378 | return 0; |
1379 | } | 1379 | } |
1380 | 1380 | ||
1381 | #ifdef CONFIG_PM | ||
1382 | static int sata_fsl_suspend(struct of_device *op, pm_message_t state) | ||
1383 | { | ||
1384 | struct ata_host *host = dev_get_drvdata(&op->dev); | ||
1385 | return ata_host_suspend(host, state); | ||
1386 | } | ||
1387 | |||
1388 | static int sata_fsl_resume(struct of_device *op) | ||
1389 | { | ||
1390 | struct ata_host *host = dev_get_drvdata(&op->dev); | ||
1391 | struct sata_fsl_host_priv *host_priv = host->private_data; | ||
1392 | int ret; | ||
1393 | void __iomem *hcr_base = host_priv->hcr_base; | ||
1394 | struct ata_port *ap = host->ports[0]; | ||
1395 | struct sata_fsl_port_priv *pp = ap->private_data; | ||
1396 | |||
1397 | ret = sata_fsl_init_controller(host); | ||
1398 | if (ret) { | ||
1399 | dev_printk(KERN_ERR, &op->dev, | ||
1400 | "Error initialize hardware\n"); | ||
1401 | return ret; | ||
1402 | } | ||
1403 | |||
1404 | /* Recovery the CHBA register in host controller cmd register set */ | ||
1405 | iowrite32(pp->cmdslot_paddr & 0xffffffff, hcr_base + CHBA); | ||
1406 | |||
1407 | ata_host_resume(host); | ||
1408 | return 0; | ||
1409 | } | ||
1410 | #endif | ||
1411 | |||
1381 | static struct of_device_id fsl_sata_match[] = { | 1412 | static struct of_device_id fsl_sata_match[] = { |
1382 | { | 1413 | { |
1383 | .compatible = "fsl,pq-sata", | 1414 | .compatible = "fsl,pq-sata", |
@@ -1392,6 +1423,10 @@ static struct of_platform_driver fsl_sata_driver = { | |||
1392 | .match_table = fsl_sata_match, | 1423 | .match_table = fsl_sata_match, |
1393 | .probe = sata_fsl_probe, | 1424 | .probe = sata_fsl_probe, |
1394 | .remove = sata_fsl_remove, | 1425 | .remove = sata_fsl_remove, |
1426 | #ifdef CONFIG_PM | ||
1427 | .suspend = sata_fsl_suspend, | ||
1428 | .resume = sata_fsl_resume, | ||
1429 | #endif | ||
1395 | }; | 1430 | }; |
1396 | 1431 | ||
1397 | static int __init sata_fsl_init(void) | 1432 | static int __init sata_fsl_init(void) |