2011-03-28 12:56:27

by Igor Plyatov

[permalink] [raw]
Subject: [PATCH v4 1/2] ata: pata_at91.c bugfix for initial_timing initialisation

The "struct ata_timing" must contain 10 members, but ".dmack_hold" member was
forgotten for "initial_timing" initialisation. This patch fixes such a problem.

Signed-off-by: Igor Plyatov <[email protected]>
---
drivers/ata/pata_at91.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index 0da0dcc..0267d54 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -49,8 +49,18 @@ struct at91_ide_info {
void __iomem *alt_addr;
};

-static const struct ata_timing initial_timing =
- {XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0};
+static const struct ata_timing initial_timing = {
+ .mode = XFER_PIO_0,
+ .setup = 70,
+ .act8b = 290,
+ .rec8b = 240,
+ .cyc8b = 600,
+ .active = 165,
+ .recover = 150,
+ .dmack_hold = 0,
+ .cycle = 600,
+ .udma = 0
+};

static unsigned long calc_mck_cycles(unsigned long ns, unsigned long mck_hz)
{
--
1.7.1


2011-03-28 12:56:36

by Igor Plyatov

[permalink] [raw]
Subject: [PATCH v4 2/2] ata: pata_at91.c bugfix for high master clock

The AT91SAM9 microcontrollers with master clock higher then 105 MHz
and PIO0, have overflow of the NCS_RD_PULSE value in the MSB. This
lead to "NCS_RD_PULSE" pulse longer then "NRD_CYCLE" pulse and driver
does not detect ATA device.

Signed-off-by: Igor Plyatov <[email protected]>
---
drivers/ata/pata_at91.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index 0267d54..a5fdbdc 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -33,11 +33,12 @@


#define DRV_NAME "pata_at91"
-#define DRV_VERSION "0.1"
+#define DRV_VERSION "0.2"

#define CF_IDE_OFFSET 0x00c00000
#define CF_ALT_IDE_OFFSET 0x00e00000
#define CF_IDE_RES_SIZE 0x08
+#define NCS_RD_PULSE_LIMIT 0x3f /* maximal value for pulse bitfields */

struct at91_ide_info {
unsigned long mode;
@@ -119,6 +120,11 @@ static void set_smc_timing(struct device *dev,
/* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */
ncs_read_setup = 1;
ncs_read_pulse = read_cycle - 2;
+ if (ncs_read_pulse > NCS_RD_PULSE_LIMIT) {
+ ncs_read_pulse = NCS_RD_PULSE_LIMIT;
+ dev_warn(dev, "ncs_read_pulse limited to maximal value %lu\n",
+ ncs_read_pulse);
+ }

/* Write timings same as read timings */
write_cycle = read_cycle;
--
1.7.1

2011-03-28 16:16:28

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] ata: pata_at91.c bugfix for initial_timing initialisation

Hello.

Igor Plyatov wrote:

> The "struct ata_timing" must contain 10 members, but ".dmack_hold" member was
> forgotten for "initial_timing" initialisation. This patch fixes such a problem.

> Signed-off-by: Igor Plyatov <[email protected]>
> ---
> drivers/ata/pata_at91.c | 14 ++++++++++++--
> 1 files changed, 12 insertions(+), 2 deletions(-)

> diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
> index 0da0dcc..0267d54 100644
> --- a/drivers/ata/pata_at91.c
> +++ b/drivers/ata/pata_at91.c
> @@ -49,8 +49,18 @@ struct at91_ide_info {
> void __iomem *alt_addr;
> };
>
> -static const struct ata_timing initial_timing =
> - {XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0};
> +static const struct ata_timing initial_timing = {
> + .mode = XFER_PIO_0,
> + .setup = 70,
> + .act8b = 290,
> + .rec8b = 240,
> + .cyc8b = 600,
> + .active = 165,
> + .recover = 150,
> + .dmack_hold = 0,
> + .cycle = 600,
> + .udma = 0
> +};

There's no need to explicitly initialize to 0.

MBR, Sergei

2011-03-28 16:32:01

by Igor Plyatov

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] ata: pata_at91.c bugfix for initial_timing initialisation

Hello Sergei!

> Hello.
>
> Igor Plyatov wrote:
>
> > The "struct ata_timing" must contain 10 members, but ".dmack_hold" member was
> > forgotten for "initial_timing" initialisation. This patch fixes such a problem.
>
> > Signed-off-by: Igor Plyatov <[email protected]>
> > ---
> > drivers/ata/pata_at91.c | 14 ++++++++++++--
> > 1 files changed, 12 insertions(+), 2 deletions(-)
>
> > diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
> > index 0da0dcc..0267d54 100644
> > --- a/drivers/ata/pata_at91.c
> > +++ b/drivers/ata/pata_at91.c
> > @@ -49,8 +49,18 @@ struct at91_ide_info {
> > void __iomem *alt_addr;
> > };
> >
> > -static const struct ata_timing initial_timing =
> > - {XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0};
> > +static const struct ata_timing initial_timing = {
> > + .mode = XFER_PIO_0,
> > + .setup = 70,
> > + .act8b = 290,
> > + .rec8b = 240,
> > + .cyc8b = 600,
> > + .active = 165,
> > + .recover = 150,
> > + .dmack_hold = 0,
> > + .cycle = 600,
> > + .udma = 0
> > +};
>
> There's no need to explicitly initialize to 0.
>
> MBR, Sergei

It's much better to explicitly initialise, then use old wrong code,
where .dmack_hold member was equal to 600.

Best regards!
--
Igor Plyatov