linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pata_hpt3x2n: calculate average f_CNT
@ 2010-12-28 19:54 Sergei Shtylyov
  2011-01-08  3:34 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Sergei Shtylyov @ 2010-12-28 19:54 UTC (permalink / raw)
  To: jgarzik, linux-ide; +Cc: alan

Allow hpt3x2n_pci_clock() to calculate the average f_CNT register value iff
HighPoint BIOS hasn't saved one, just like the 'pata_hpt37x' driver (reading
the full 16-bit register, unlike what that driver does), so that this driver
would work correctly on e.g. non-x86 machine with 66 MHz PCI.

I'm not sure why Alan has only done this in one driver and not the other...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

---
The patch is against the recent Linus' tree plus the two patches I posted
before:

http://marc.info/?l=linux-ide&m=129356208121192
http://marc.info/?l=linux-ide&m=129330632207779

 drivers/ata/pata_hpt3x2n.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Index: linux-2.6/drivers/ata/pata_hpt3x2n.c
===================================================================
--- linux-2.6.orig/drivers/ata/pata_hpt3x2n.c
+++ linux-2.6/drivers/ata/pata_hpt3x2n.c
@@ -25,7 +25,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME	"pata_hpt3x2n"
-#define DRV_VERSION	"0.3.11"
+#define DRV_VERSION	"0.3.12"
 
 enum {
 	HPT_PCI_FAST	=	(1 << 31),
@@ -413,8 +413,19 @@ static int hpt3x2n_pci_clock(struct pci_
 
 	fcnt = inl(iobase + 0x90);	/* Not PCI readable for some chips */
 	if ((fcnt >> 12) != 0xABCDE) {
-		printk(KERN_WARNING "hpt3xn: BIOS clock data not set.\n");
-		return 33;	/* Not BIOS set */
+		int i;
+		u16 sr;
+		u32 total = 0;
+
+		printk(KERN_WARNING "pata_hpt3x2n: BIOS clock data not set.\n");
+
+		/* This is the process the HPT371 BIOS is reported to use */
+		for (i = 0; i < 128; i++) {
+			pci_read_config_word(pdev, 0x78, &sr);
+			total += sr & 0x1FF;
+			udelay(15);
+		}
+		fcnt = total / 128;
 	}
 	fcnt &= 0x1FF;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pata_hpt3x2n: calculate average f_CNT
  2010-12-28 19:54 [PATCH] pata_hpt3x2n: calculate average f_CNT Sergei Shtylyov
@ 2011-01-08  3:34 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2011-01-08  3:34 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-ide, alan

On 12/28/2010 02:54 PM, Sergei Shtylyov wrote:
> Allow hpt3x2n_pci_clock() to calculate the average f_CNT register value iff
> HighPoint BIOS hasn't saved one, just like the 'pata_hpt37x' driver (reading
> the full 16-bit register, unlike what that driver does), so that this driver
> would work correctly on e.g. non-x86 machine with 66 MHz PCI.
>
> I'm not sure why Alan has only done this in one driver and not the other...
>
> Signed-off-by: Sergei Shtylyov<sshtylyov@ru.mvista.com>
>
> ---
> The patch is against the recent Linus' tree plus the two patches I posted
> before:
>
> http://marc.info/?l=linux-ide&m=129356208121192
> http://marc.info/?l=linux-ide&m=129330632207779
>
>   drivers/ata/pata_hpt3x2n.c |   17 ++++++++++++++---
>   1 file changed, 14 insertions(+), 3 deletions(-)

applied



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-08  3:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-28 19:54 [PATCH] pata_hpt3x2n: calculate average f_CNT Sergei Shtylyov
2011-01-08  3:34 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).