libata updates
Subsystems (2)
PATCH 1/1 libata updates
Please pull from 'upstream-linus' branch of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream-linus
to receive the following updates:
drivers/ata/Kconfig | 8 + drivers/ata/Makefile | 1 + drivers/ata/libata-core.c | 25 ++-- drivers/ata/pata_at91.c | 361 +++++++++++++++++++++++++++++++++++++++++++++ drivers/ata/sata_fsl.c | 35 +++++ 5 files changed, 420 insertions(+), 10 deletions(-) create mode 100644 drivers/ata/pata_at91.c
Dave Liu (1):
sata_fsl: Add power mgmt support
Evgeni Golov (1):
[libata] beautify module parameters
Sergey Matyukevich (1):
[libata] PATA driver for CF interface on AT91SAM9260 SoC
Tejun Heo (1):
libata: don't set IORDY for reset
drivers/ata/Kconfig +8 -0
@@ -679,6 +679,14 @@ config PATA_PLATFORM If unsure, say N. +config PATA_AT91 + tristate "PATA support for AT91SAM9260" + depends on ARM && ARCH_AT91 + help + This option enables support for IDE devices on the Atmel AT91SAM9260 SoC. + + If unsure, say N. + config PATA_OF_PLATFORM tristate "OpenFirmware platform device PATA support" depends on PATA_PLATFORM && PPC_OF
drivers/ata/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_PATA_SCH) += pata_sch.o obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o +obj-$(CONFIG_PATA_AT91) += pata_at91.o obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o # Should be last but two libata driver
drivers/ata/libata-core.c +15 -10
@@ -125,19 +125,19 @@ MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link spestatic int atapi_enabled =1 ;module_param (atapi_enabled, int,0444 ); -MODULE_PARM_DESC (atapi_enabled,"Enable discovery of ATAPI devices (0=off, 1=on)" ); +MODULE_PARM_DESC (atapi_enabled,"Enable discovery of ATAPI devices (0=off, 1=on [default])" );static int atapi_dmadir =0 ;module_param (atapi_dmadir, int,0444 ); -MODULE_PARM_DESC (atapi_dmadir,"Enable ATAPI DMADIR bridge support (0=off, 1=on)" ); +MODULE_PARM_DESC (atapi_dmadir,"Enable ATAPI DMADIR bridge support (0=off [default], 1=on)" );int atapi_passthru16 =1 ;module_param (atapi_passthru16, int,0444 ); -MODULE_PARM_DESC (atapi_passthru16,"Enable ATA_16 passthru for ATAPI devices; on by default (0=off, 1=on)" ); +MODULE_PARM_DESC (atapi_passthru16,"Enable ATA_16 passthru for ATAPI devices (0=off, 1=on [default])" );int libata_fua =0 ;module_param_named (fua, libata_fua, int,0444 ); -MODULE_PARM_DESC (fua,"FUA support (0=off, 1=on)" ); +MODULE_PARM_DESC (fua,"FUA support (0=off [default], 1=on)" );static int ata_ignore_hpa;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)");int libata_noacpi =0 ;module_param_named (noacpi, libata_noacpi, int,0444 ); -MODULE_PARM_DESC (noacpi,"Disables the use of ACPI in probe/suspend/resume when set" ); +MODULE_PARM_DESC (noacpi,"Disable the use of ACPI in probe/suspend/resume (0=off [default], 1=on)" );int libata_allow_tpm =0 ;module_param_named (allow_tpm, libata_allow_tpm, int,0444 ); -MODULE_PARM_DESC (allow_tpm,"Permit the use of TPM commands" ); +MODULE_PARM_DESC (allow_tpm,"Permit the use of TPM commands (0=off [default], 1=on)" );MODULE_AUTHOR ("Jeff Garzik" );MODULE_DESCRIPTION ("Library module for ATA devices" );
@@ -1993,11 +1993,17 @@ unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd)* Check if the current speed of the device requires IORDY. Used * by various controllers for chip configuration. */ -unsigned int ata_pio_need_iordy (const struct ata_device *adev) { -/* Controller doesn't support IORDY. Probably a pointless check -as the caller should know this */ +/* Don't set IORDY if we're preparing for reset. IORDY may +* lead to controller lock up on certain controllers if the +* port is not occupied. See bko#11703 for details. +*/ +if (adev->link->ap->pflags &ATA_PFLAG_RESETTING ) +return 0 ; +/* Controller doesn't support IORDY. Probably a pointless +* check as the caller should know this. +*/ if (adev->link->ap->flags &ATA_FLAG_NO_IORDY )return 0 ;/* 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)* Compute the highest mode possible if we are not using iordy. Return * -1 if no iordy mode is available. */ -static u32 ata_pio_mask_no_iordy (const struct ata_device *adev) {/* If we have no drive specific rule, then PIO 2 is non IORDY */
drivers/ata/pata_at91.c new file +361 -0
361 lines not on this page · raw message
drivers/ata/sata_fsl.c +35 -0
@@ -1378,6 +1378,37 @@ static int sata_fsl_remove(struct of_device *ofdev)return 0 ; } +#ifdef CONFIG_PM +static int sata_fsl_suspend (struct of_device *op,pm_message_t state) +{ +struct ata_host *host =dev_get_drvdata (&op->dev); +return ata_host_suspend (host, state); +} + +static int sata_fsl_resume (struct of_device *op) +{ +struct ata_host *host =dev_get_drvdata (&op->dev); +struct sata_fsl_host_priv *host_priv = host->private_data; +int ret; +void __iomem *hcr_base = host_priv->hcr_base; +struct ata_port *ap = host->ports[0 ]; +struct sata_fsl_port_priv *pp = ap->private_data; + + ret =sata_fsl_init_controller (host); +if (ret) { +dev_printk (KERN_ERR , &op->dev, +"Error initialize hardware\n" ); +return ret; + } + +/* Recovery the CHBA register in host controller cmd register set */ +iowrite32 (pp->cmdslot_paddr &0xffffffff , hcr_base +CHBA ); + +ata_host_resume (host); +return 0 ; +} +#endif +static struct of_device_id fsl_sata_match[] = { { .compatible ="fsl,pq-sata" ,
@@ -1392,6 +1423,10 @@ static struct of_platform_driver fsl_sata_driver = { .match_table = fsl_sata_match, .probe = sata_fsl_probe, .remove = sata_fsl_remove, +#ifdef CONFIG_PM + .suspend = sata_fsl_suspend, + .resume = sata_fsl_resume, +#endif };static int __init sata_fsl_init (void )
Quoted 48 lines · On Tue, 23 Jun 2009 02:06:00 -0400 Jeff Garzik <[email protected]> wrote:
...
drivers/ata/pata_at91.c new file +42
-0@@ -0,0 +1,361 @@ +/* +* PATA driver for AT91SAM9260 Static Memory Controller +* with CompactFlash interface in True IDE mode +* +* Copyright (C) 2009 Matyukevich Sergey +* +* Based on: +* * generic platform driver by Paul Mundt: drivers/ata/pata_platform.c +* * pata_at32 driver by Kristoffer Nyborg Gregertsen +* * at91_ide driver by Stanislaw Gruszka +* +* 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/init.h> +#include <linux/blkdev.h> +#include <scsi/scsi_host.h> +#include <linux/ata.h> +#include <linux/clk.h> +#include <linux/libata.h> +#include <linux/platform_device.h> +#include <linux/ata_platform.h> + +#include <mach/at91sam9260_matrix.h> +#include <mach/at91sam9_smc.h> +#include <mach/at91sam9260.h> +#include <mach/board.h> +#include <mach/gpio.h> + + +#define DRV_NAME "pata_at91" +#define DRV_VERSION "0.1" + +#define CF_IDE_OFFSET 0x00c00000 +#define CF_ALT_IDE_OFFSET 0x00e00000 +#define CF_IDE_RES_SIZE 0x08 +
drivers/ata/pata_at91.c line 52
Quoted 10 lines
drivers/ata/pata_at91.c new file +10
-0+struct at91_ide_info { +unsigned long mode; +unsigned int cs; + +void __iomem *ide_addr; +void __iomem *alt_addr; +}; + +const struct ata_timing initial_timing = + {XFER_PIO_0 ,70 ,290 ,240 ,600 ,165 ,150 ,600 ,0 };
static.
Quoted 6 lines
drivers/ata/pata_at91.c new file +6
-0+static unsigned int calc_mck_cycles (unsigned int ns,unsigned int mck_hz) +{ +unsigned long mul; + +/* +* cycles = x [nsec] * f [Hz] / 10^9 [ns in sec] =
drivers/ata/pata_at91.c line 69
Quoted 10 lines
drivers/ata/pata_at91.c new file +10
-0+* x * (f / 1_000_000_000) = +* x * ((f * 65536) / 1_000_000_000) / 65536 = +* x * (((f / 10_000) * 65536) / 100_000) / 65536 = +*/ + + mul = (mck_hz /10000 ) <<16 ; + mul /=100000 ; + +return (ns * mul +65536 ) >>16 ;/* rounding */ +}
yum, fixed-point float.
This combination of uints and ulongs is just asking for 32bit-vs-64bit overflow bugs.
Quoted 16 lines
drivers/ata/pata_at91.c new file +16
-0+static void set_smc_mode (struct at91_ide_info *info) +{ +at91_sys_write (AT91_SMC_MODE (info->cs), info->mode); +return ; +} + +static void set_smc_timing (struct device *dev, +struct at91_ide_info *info,const struct ata_timing *ata) +{ +int read_cycle, write_cycle, active, recover; +int nrd_setup, nrd_pulse, nrd_recover; +int nwe_setup, nwe_pulse; + +int ncs_write_setup, ncs_write_pulse; +int ncs_read_setup, ncs_read_pulse; +
drivers/ata/pata_at91.c line 96
Quoted 10 lines
drivers/ata/pata_at91.c new file +10
-0+unsigned int mck_hz; +struct clk *mck; + + read_cycle = ata->cyc8b; + nrd_setup = ata->setup; + nrd_pulse = ata->act8b; + nrd_recover = ata->rec8b; + + mck =clk_get (NULL ,"mck" ); +BUG_ON (IS_ERR (mck));
That seems harsh.
Quoted 77 lines
drivers/ata/pata_at91.c new file +74
-0+ mck_hz =clk_get_rate (mck); + + read_cycle =calc_mck_cycles (read_cycle, mck_hz); + nrd_setup =calc_mck_cycles (nrd_setup, mck_hz); + nrd_pulse =calc_mck_cycles (nrd_pulse, mck_hz); + nrd_recover =calc_mck_cycles (nrd_recover, mck_hz); + +clk_put (mck); + + active = nrd_setup + nrd_pulse; + recover = read_cycle - active; + +/* Need at least two cycles recovery */ +if (recover <2 ) + read_cycle = active +2 ; + +/* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */ + ncs_read_setup =1 ; + ncs_read_pulse = read_cycle -2 ; + +/* Write timings same as read timings */ + write_cycle = read_cycle; + nwe_setup = nrd_setup; + nwe_pulse = nrd_pulse; + ncs_write_setup = ncs_read_setup; + ncs_write_pulse = ncs_read_pulse; + +dev_dbg (dev,"ATA timings: nrd_setup = %d nrd_pulse = %d nrd_cycle = %d\n" , + nrd_setup, nrd_pulse, read_cycle); +dev_dbg (dev,"ATA timings: nwe_setup = %d nwe_pulse = %d nwe_cycle = %d\n" , + nwe_setup, nwe_pulse, write_cycle); +dev_dbg (dev,"ATA timings: ncs_read_setup = %d ncs_read_pulse = %d\n" , + ncs_read_setup, ncs_read_pulse); +dev_dbg (dev,"ATA timings: ncs_write_setup = %d ncs_write_pulse = %d\n" , + ncs_write_setup, ncs_write_pulse); + +at91_sys_write (AT91_SMC_SETUP (info->cs), +AT91_SMC_NWESETUP_ (nwe_setup) | +AT91_SMC_NRDSETUP_ (nrd_setup) | +AT91_SMC_NCS_WRSETUP_ (ncs_write_setup) | +AT91_SMC_NCS_RDSETUP_ (ncs_read_setup)); + +at91_sys_write (AT91_SMC_PULSE (info->cs), +AT91_SMC_NWEPULSE_ (nwe_pulse) | +AT91_SMC_NRDPULSE_ (nrd_pulse) | +AT91_SMC_NCS_WRPULSE_ (ncs_write_pulse) | +AT91_SMC_NCS_RDPULSE_ (ncs_read_pulse)); + +at91_sys_write (AT91_SMC_CYCLE (info->cs), +AT91_SMC_NWECYCLE_ (write_cycle) | +AT91_SMC_NRDCYCLE_ (read_cycle)); + +return ; +} + +#ifdef CONFIG_PM +static int sata_fsl_suspend (struct of_device *op,pm_message_t state) +{ +struct ata_host *host =dev_get_drvdata (&op->dev); +return ata_host_suspend (host, state); +} + +static int sata_fsl_resume (struct of_device *op) +{ +struct ata_host *host =dev_get_drvdata (&op->dev); +struct sata_fsl_host_priv *host_priv = host->private_data; +int ret; +void __iomem *hcr_base = host_priv->hcr_base; +struct ata_port *ap = host->ports[0 ]; +struct sata_fsl_port_priv *pp = ap->private_data; + + ret =sata_fsl_init_controller (host); +if (ret) { + dev_printk(KERN_ERR, &op->dev,
drivers/ata/pata_at91.c line 236
Quoted 10 lines
drivers/ata/pata_at91.c new file +10
-0+ "Error initialize hardware\n"); +return ret; + } + +/* Recovery the CHBA register in host controller cmd register set */ +iowrite32 (pp->cmdslot_paddr &0xffffffff , hcr_base +CHBA ); + +ata_host_resume (host); +return 0 ; +}
#else
#define sata_fsl_suspend NULL
#define sata_fsl_resume NULL
drivers/ata/pata_at91.c static struct of_platform_driver fsl_sata_driver = { · line 1429
Quoted 13 lines
drivers/ata/pata_at91.c new file +6
-0+#endif +static struct of_device_id fsl_sata_match[] = { { .compatible ="fsl,pq-sata" ,@@ -1392,6 +1423,10 @@ static struct of_platform_driver fsl_sata_driver = { .match_table = fsl_sata_match, .probe = sata_fsl_probe, .remove = sata_fsl_remove, +#ifdef CONFIG_PM + .suspend = sata_fsl_suspend, + .resume = sata_fsl_resume, +#endif
And remove this ifdef.
Quoted 169 lines · On Mon, 22 Jun 2009 23:31:57 -0700 Andrew Morton <[email protected]>…
Quoted 50 lines · On Tue, 23 Jun 2009 02:06:00 -0400 Jeff Garzik <[email protected]> wrote:
...
drivers/ata/pata_at91.c new file +8
-0@@ -0,0 +1,361 @@ +/* +* PATA driver for AT91SAM9260 Static Memory Controller +* with CompactFlash interface in True IDE mode +* +* Copyright (C) 2009 Matyukevich Sergey +* +* Based on: +* * generic platform driver by Paul Mundt:
drivers/ata/pata_platform.c
+ * *pata_at32driver by Kristoffer Nyborg Gregertsen
+ * *at91_idedriver by Stanislaw Gruszka
+ *
+ * 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.
+ *
+ */drivers/ata/pata_at91.c new file +26
-0+ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/blkdev.h> +#include <scsi/scsi_host.h> +#include <linux/ata.h> +#include <linux/clk.h> +#include <linux/libata.h> +#include <linux/platform_device.h> +#include <linux/ata_platform.h> + +#include <mach/at91sam9260_matrix.h> +#include <mach/at91sam9_smc.h> +#include <mach/at91sam9260.h> +#include <mach/board.h> +#include <mach/gpio.h> + + +#define DRV_NAME "pata_at91" +#define DRV_VERSION "0.1" + +#define CF_IDE_OFFSET 0x00c00000 +#define CF_ALT_IDE_OFFSET 0x00e00000 +#define CF_IDE_RES_SIZE 0x08 +drivers/ata/pata_at91.c line 52
Quoted 10 lines
drivers/ata/pata_at91.c new file +10
-0+struct at91_ide_info { +unsigned long mode; +unsigned int cs; + +void __iomem *ide_addr; +void __iomem *alt_addr; +}; + +const struct ata_timing initial_timing = + {XFER_PIO_0 ,70 ,290 ,240 ,600 ,165 ,150 ,600 ,0 };static.
Quoted 6 lines
+static unsigned int
calc_mck_cycles(unsigned int ns, unsigned int mck_hz)+{drivers/ata/pata_at91.c new file +4
-0+unsigned long mul; + +/* +* cycles = x [nsec] * f [Hz] / 10^9 [ns in sec] = drivers/ata/pata_at91.c line 69
Quoted 10 lines
drivers/ata/pata_at91.c new file +10
-0+* x * (f / 1_000_000_000) = +* x * ((f * 65536) / 1_000_000_000) / 65536 = +* x * (((f / 10_000) * 65536) / 100_000) / 65536 = +*/ + + mul = (mck_hz /10000 ) <<16 ; + mul /=100000 ; + +return (ns * mul +65536 ) >>16 ;/* rounding */ +}yum, fixed-point float.
This combination of uints and ulongs is just asking for 32bit-vs-64bit overflow bugs.
Quoted 16 lines
drivers/ata/pata_at91.c new file +8
-0+static void set_smc_mode (struct at91_ide_info *info) +{ +at91_sys_write (AT91_SMC_MODE (info->cs), info->mode); +return ; +} + +static void set_smc_timing(struct device *dev, + struct at91_ide_info *info, const struct
ata_timing*ata) +{drivers/ata/pata_at91.c new file +7
-0+int read_cycle, write_cycle, active, recover; +int nrd_setup, nrd_pulse, nrd_recover; +int nwe_setup, nwe_pulse; + +int ncs_write_setup, ncs_write_pulse; +int ncs_read_setup, ncs_read_pulse; +drivers/ata/pata_at91.c line 96
Quoted 10 lines
drivers/ata/pata_at91.c new file +10
-0+unsigned int mck_hz; +struct clk *mck; + + read_cycle = ata->cyc8b; + nrd_setup = ata->setup; + nrd_pulse = ata->act8b; + nrd_recover = ata->rec8b; + + mck =clk_get (NULL ,"mck" ); +BUG_ON (IS_ERR (mck));That seems harsh.
Quoted 52 lines
drivers/ata/pata_at91.c new file +17
-0+ mck_hz =clk_get_rate (mck); + + read_cycle =calc_mck_cycles (read_cycle, mck_hz); + nrd_setup =calc_mck_cycles (nrd_setup, mck_hz); + nrd_pulse =calc_mck_cycles (nrd_pulse, mck_hz); + nrd_recover =calc_mck_cycles (nrd_recover, mck_hz); + +clk_put (mck); + + active = nrd_setup + nrd_pulse; + recover = read_cycle - active; + +/* Need at least two cycles recovery */ +if (recover <2 ) + read_cycle = active +2 ; + +/* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */
drivers/ata/pata_at91.c new file +11
-0+ ncs_read_setup =1 ; + ncs_read_pulse = read_cycle -2 ; + +/* Write timings same as read timings */ + write_cycle = read_cycle; + nwe_setup = nrd_setup; + nwe_pulse = nrd_pulse; + ncs_write_setup = ncs_read_setup; + ncs_write_pulse = ncs_read_pulse; + + dev_dbg(dev, "ATA timings: nrd_setup = %d nrd_pulse = %d
nrd_cycle= %d\n",drivers/ata/pata_at91.c new file +2
-0+ nrd_setup, nrd_pulse, read_cycle); + dev_dbg(dev, "ATA timings: nwe_setup = %d nwe_pulse = %d
nwe_cycle= %d\n",drivers/ata/pata_at91.c new file +2
-0+ nwe_setup, nwe_pulse, write_cycle); + dev_dbg(dev, "ATA timings: ncs_read_setup = %d
ncs_read_pulse= %d\n",drivers/ata/pata_at91.c new file +2
-0+ ncs_read_setup, ncs_read_pulse); + dev_dbg(dev, "ATA timings: ncs_write_setup = %d
ncs_write_pulse= %d\n",drivers/ata/pata_at91.c new file +13
-0+ ncs_write_setup, ncs_write_pulse); + +at91_sys_write (AT91_SMC_SETUP (info->cs), +AT91_SMC_NWESETUP_ (nwe_setup) | +AT91_SMC_NRDSETUP_ (nrd_setup) | +AT91_SMC_NCS_WRSETUP_ (ncs_write_setup) | +AT91_SMC_NCS_RDSETUP_ (ncs_read_setup)); + +at91_sys_write (AT91_SMC_PULSE (info->cs), +AT91_SMC_NWEPULSE_ (nwe_pulse) | +AT91_SMC_NRDPULSE_ (nrd_pulse) | +AT91_SMC_NCS_WRPULSE_ (ncs_write_pulse) | +AT91_SMC_NCS_RDPULSE_ (ncs_read_pulse));
Quoted 8 lines
drivers/ata/pata_at91.c line 151
Quoted 8 lines
drivers/ata/pata_at91.c new file +8
-0+ +at91_sys_write (AT91_SMC_CYCLE (info->cs), +AT91_SMC_NWECYCLE_ (write_cycle) | +AT91_SMC_NRDCYCLE_ (read_cycle)); + +return ; +} +
Hi,
Could you tell me where to send update for pata_at91 driver modified according to Andrew's remarks ? To Jeff ?
Thanks,
Sergey
Quoted 2 lines · Sergey Matyukevich
Could you tell me where to send update for
pata_at91driver modified according to Andrew's remarks ? To Jeff ?
Me and linux-ide...
Jeff
Quoted 9 lines · On Tue, 23 Jun 2009 13:59:44 -0400 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines · Sergey Matyukevich
Could you tell me where to send update for
pata_at91driver modified according to Andrew's remarks ? To Jeff ?Me and linux-ide...
Jeff
Jeff,
Here is updated pata_at91 driver according to comments by Andrew Morton.
This patch provides PATA driver for CompactFlash interface in True IDE mode on AT91SAM9260 SoC.
--- drivers/ata/Kconfig | 8 + drivers/ata/Makefile | 1 + drivers/ata/pata_at91.c | 367 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 376 insertions(+), 0 deletions(-) create mode 100644 drivers/ata/pata_at91.c
drivers/ata/Kconfig +8 -0
@@ -679,6 +679,14 @@ config PATA_PLATFORM If unsure, say N. +config PATA_AT91 + tristate "PATA support for AT91SAM9260" + depends on ARM && ARCH_AT91 + help + This option enables support for IDE devices on the Atmel AT91SAM9260 SoC. + + If unsure, say N. + config PATA_OF_PLATFORM tristate "OpenFirmware platform device PATA support" depends on PATA_PLATFORM && PPC_OF
drivers/ata/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_PATA_SCH) += pata_sch.o obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o +obj-$(CONFIG_PATA_AT91) += pata_at91.o obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o # Should be last but two libata driver
drivers/ata/pata_at91.c new file +367 -0
367 lines not on this page · raw message
Signature · 1 line
1.6.2.5
Quoted 21 lines · Sergey Matyukevich
Quoted 8 lines · On Tue, 23 Jun 2009 13:59:44 -0400 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines · Sergey Matyukevich
Could you tell me where to send update for
pata_at91driver modified according to Andrew's remarks ? To Jeff ?Me and linux-ide...
Jeff
Jeff,
Here is updatedpata_at91driver according to comments by Andrew Morton.This patch provides PATA driver for CompactFlash interface in True IDE mode on AT91SAM9260 SoC.
Quoted 7 lines
Signed-off-by Sergey Matyukevich <[email protected]>--- drivers/ata/Kconfig | 8 + drivers/ata/Makefile | 1 + drivers/ata/pata_at91.c | 367 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 376 insertions(+), 0 deletions(-) create mode 100644 drivers/ata/pata_at91.c
Once I (or someone else, in the case of another driver) merges a driver, you will want to send a diff against that merged version. In this case, the driver is upstream as of an hour or two ago, so you'll want to diff against that.
Note that little details like email subject line matter, because they are copied into the kernel changelog by default, when merging patches. See Documentation/SubmittingPatches for a list of details.
Jeff
PATCH 1/1 pata_at91: Updates for pata_at91 driver
Quoted 10 lines · On Tue, 23 Jun 2009 17:30:43 -0400 Jeff Garzik <[email protected]> wrote:
Once I (or someone else, in the case of another driver) merges a driver, you will want to send a diff against that merged version. In this case, the driver is upstream as of an hour or two ago, so you'll want to diff against that.
Note that little details like email subject line matter, because they are copied into the kernel changelog by default, when merging patches. See
Documentation/SubmittingPatchesfor a list of details.Jeff
Driver pata_at91 is updated according to A. Morton comments.
* No harsh BUG_ON for get_clk in set_smc_timing function get_clk is now performed in driver probing function, probing fails if master clock is not available
* Fixed uint/ulong mess in calc_mck_cycles function
--- drivers/ata/pata_at91.c | 65 ++++++++++++++++++++++++++--------------------- 1 files changed, 36 insertions(+), 29 deletions(-)
drivers/ata/pata_at91.c +36 -29
@@ -44,65 +44,62 @@ struct at91_ide_info {unsigned long mode;unsigned int cs; +struct clk *mck; +void __iomem *ide_addr;void __iomem *alt_addr; }; -const struct ata_timing initial_timing = +static const struct ata_timing initial_timing = {XFER_PIO_0 ,70 ,290 ,240 ,600 ,165 ,150 ,600 ,0 }; -static unsigned int calc_mck_cycles (unsigned int ns,unsigned int mck_hz) +static unsigned long calc_mck_cycles (unsigned long ns,unsigned long mck_hz) {unsigned long mul; -/* -* cycles = x [nsec] * f [Hz] / 10^9 [ns in sec] = -* x * (f / 1_000_000_000) = -* x * ((f * 65536) / 1_000_000_000) / 65536 = -* x * (((f / 10_000) * 65536) / 100_000) / 65536 = -*/ +/* +* cycles = x [nsec] * f [Hz] / 10^9 [ns in sec] = +* x * (f / 1_000_000_000) = +* x * ((f * 65536) / 1_000_000_000) / 65536 = +* x * (((f / 10_000) * 65536) / 100_000) / 65536 = +*/ - mul = (mck_hz /10000 ) <<16 ; - mul /=100000 ; + mul = (mck_hz /10000 ) <<16 ; + mul /=100000 ; -return (ns * mul +65536 ) >>16 ;/* rounding */ +return (ns * mul +65536 ) >>16 ;/* rounding */ }static void set_smc_mode (struct at91_ide_info *info) { -at91_sys_write (AT91_SMC_MODE (info->cs), info->mode); -return ; +at91_sys_write (AT91_SMC_MODE (info->cs), info->mode); +return ; }static void set_smc_timing (struct device *dev,struct at91_ide_info *info,const struct ata_timing *ata) { -int read_cycle, write_cycle, active, recover; -int nrd_setup, nrd_pulse, nrd_recover; -int nwe_setup, nwe_pulse; +unsigned long read_cycle, write_cycle, active, recover; +unsigned long nrd_setup, nrd_pulse, nrd_recover; +unsigned long nwe_setup, nwe_pulse; -int ncs_write_setup, ncs_write_pulse; -int ncs_read_setup, ncs_read_pulse; +unsigned long ncs_write_setup, ncs_write_pulse; +unsigned long ncs_read_setup, ncs_read_pulse; -unsigned int mck_hz; -struct clk *mck; +unsigned long mck_hz; read_cycle = ata->cyc8b; nrd_setup = ata->setup; nrd_pulse = ata->act8b; nrd_recover = ata->rec8b; - mck =clk_get (NULL ,"mck" ); -BUG_ON (IS_ERR (mck)); - mck_hz =clk_get_rate (mck); + mck_hz =clk_get_rate (info->mck); read_cycle =calc_mck_cycles (read_cycle, mck_hz); nrd_setup =calc_mck_cycles (nrd_setup, mck_hz); nrd_pulse =calc_mck_cycles (nrd_pulse, mck_hz); nrd_recover =calc_mck_cycles (nrd_recover, mck_hz); -clk_put (mck); - active = nrd_setup + nrd_pulse; recover = read_cycle - active;
@@ -121,13 +118,13 @@ static void set_smc_timing(struct device *dev, ncs_write_setup = ncs_read_setup; ncs_write_pulse = ncs_read_pulse; -dev_dbg (dev,"ATA timings: nrd_setup = %d nrd_pulse = %d nrd_cycle = %d\n" , +dev_dbg (dev,"ATA timings: nrd_setup = %lu nrd_pulse = %lu nrd_cycle = %lu\n" , nrd_setup, nrd_pulse, read_cycle); -dev_dbg (dev,"ATA timings: nwe_setup = %d nwe_pulse = %d nwe_cycle = %d\n" , +dev_dbg (dev,"ATA timings: nwe_setup = %lu nwe_pulse = %lu nwe_cycle = %lu\n" , nwe_setup, nwe_pulse, write_cycle); -dev_dbg (dev,"ATA timings: ncs_read_setup = %d ncs_read_pulse = %d\n" , +dev_dbg (dev,"ATA timings: ncs_read_setup = %lu ncs_read_pulse = %lu\n" , ncs_read_setup, ncs_read_pulse); -dev_dbg (dev,"ATA timings: ncs_write_setup = %d ncs_write_pulse = %d\n" , +dev_dbg (dev,"ATA timings: ncs_write_setup = %lu ncs_write_pulse = %lu\n" , ncs_write_setup, ncs_write_pulse); at91_sys_write(AT91_SMC_SETUP(info->cs),
@@ -217,6 +214,7 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)struct resource *mem_res;struct ata_host *host;struct ata_port *ap; +int irq_flags =0 ;int irq =0 ;int ret;
@@ -261,6 +259,13 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)return -ENOMEM ; } + info->mck =clk_get (NULL ,"mck" ); + +if (IS_ERR (info->mck)) { +dev_err (dev,"failed to get access to mck clock\n" ); +return -ENODEV ; + } + info->cs = board->chipselect; info->mode =AT91_SMC_READMODE |AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_READY | AT91_SMC_BAT_SELECT |
@@ -304,6 +309,7 @@ err_alt_ioremap:devm_iounmap (dev, info->ide_addr); err_ide_ioremap: +clk_put (info->mck);kfree (info);return ret;
@@ -325,6 +331,7 @@ static int __devexit pata_at91_remove(struct platform_device *pdev)devm_iounmap (dev, info->ide_addr);devm_iounmap (dev, info->alt_addr); +clk_put (info->mck);kfree (info);return 0 ;
Signature · 1 line
1.6.2.5
Quoted 2 lines · On Tue, 23 Jun 2009 21:37:43 +0400 Sergey Matyukevich <[email protected]>…
Could you tell me where to send update for
pata_at91driver modified according to Andrew's remarks ? To Jeff ?
Yes.
SERIAL ATA (SATA) SUBSYSTEM
P: Jeff Garzik
M: [email protected]
L: [email protected]
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
S: Supported
F: drivers/ata/
F: include/linux/ata.h
F: include/linux/libata.h