forked from luck/tmp_suning_uos_patched
ide: convert ide-timing.h to ide-timings.c library (take 2)
* Don't include ide-timing.h in cs5535 and sis5513 host drivers (they don't need it currently). * Convert ide-timing.h to ide-timings.c library and add CONFIG_IDE_TIMINGS config option to be selected by host drivers using the library. While at it: - fix ide_timing_find_mode() placement v2: * Add missing EXPORT_SYMBOLs. (Stephen Rothwell <sfr@canb.auug.org.au>) There should be no functional changes caused by this patch. Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
parent
2c139e7a71
commit
f06ab3402a
|
@ -98,6 +98,9 @@ if BLK_DEV_IDE
|
||||||
|
|
||||||
comment "Please see Documentation/ide/ide.txt for help/info on IDE drives"
|
comment "Please see Documentation/ide/ide.txt for help/info on IDE drives"
|
||||||
|
|
||||||
|
config IDE_TIMINGS
|
||||||
|
bool
|
||||||
|
|
||||||
config IDE_ATAPI
|
config IDE_ATAPI
|
||||||
bool
|
bool
|
||||||
|
|
||||||
|
@ -469,6 +472,7 @@ config BLK_DEV_ALI15X3
|
||||||
config BLK_DEV_AMD74XX
|
config BLK_DEV_AMD74XX
|
||||||
tristate "AMD and nVidia IDE support"
|
tristate "AMD and nVidia IDE support"
|
||||||
depends on !ARM
|
depends on !ARM
|
||||||
|
select IDE_TIMINGS
|
||||||
select BLK_DEV_IDEDMA_PCI
|
select BLK_DEV_IDEDMA_PCI
|
||||||
help
|
help
|
||||||
This driver adds explicit support for AMD-7xx and AMD-8111 chips
|
This driver adds explicit support for AMD-7xx and AMD-8111 chips
|
||||||
|
@ -725,6 +729,7 @@ config BLK_DEV_TRM290
|
||||||
|
|
||||||
config BLK_DEV_VIA82CXXX
|
config BLK_DEV_VIA82CXXX
|
||||||
tristate "VIA82CXXX chipset support"
|
tristate "VIA82CXXX chipset support"
|
||||||
|
select IDE_TIMINGS
|
||||||
select BLK_DEV_IDEDMA_PCI
|
select BLK_DEV_IDEDMA_PCI
|
||||||
help
|
help
|
||||||
This driver adds explicit support for VIA BusMastering IDE chips.
|
This driver adds explicit support for VIA BusMastering IDE chips.
|
||||||
|
@ -751,6 +756,7 @@ endif
|
||||||
config BLK_DEV_IDE_PMAC
|
config BLK_DEV_IDE_PMAC
|
||||||
tristate "PowerMac on-board IDE support"
|
tristate "PowerMac on-board IDE support"
|
||||||
depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y
|
depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y
|
||||||
|
select IDE_TIMINGS
|
||||||
help
|
help
|
||||||
This driver provides support for the on-board IDE controller on
|
This driver provides support for the on-board IDE controller on
|
||||||
most of the recent Apple Power Macintoshes and PowerBooks.
|
most of the recent Apple Power Macintoshes and PowerBooks.
|
||||||
|
@ -912,6 +918,7 @@ config BLK_DEV_Q40IDE
|
||||||
config BLK_DEV_PALMCHIP_BK3710
|
config BLK_DEV_PALMCHIP_BK3710
|
||||||
tristate "Palmchip bk3710 IDE controller support"
|
tristate "Palmchip bk3710 IDE controller support"
|
||||||
depends on ARCH_DAVINCI
|
depends on ARCH_DAVINCI
|
||||||
|
select IDE_TIMINGS
|
||||||
select BLK_DEV_IDEDMA_SFF
|
select BLK_DEV_IDEDMA_SFF
|
||||||
help
|
help
|
||||||
Say Y here if you want to support the onchip IDE controller on the
|
Say Y here if you want to support the onchip IDE controller on the
|
||||||
|
|
|
@ -14,6 +14,7 @@ EXTRA_CFLAGS += -Idrivers/ide
|
||||||
ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o
|
ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o
|
||||||
|
|
||||||
# core IDE code
|
# core IDE code
|
||||||
|
ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o
|
||||||
ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o
|
ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o
|
||||||
ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
|
ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
|
||||||
ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o
|
ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o
|
||||||
|
|
|
@ -74,8 +74,6 @@ struct palm_bk3710_udmatiming {
|
||||||
#define BK3710_IORDYTMP 0x78
|
#define BK3710_IORDYTMP 0x78
|
||||||
#define BK3710_IORDYTMS 0x7C
|
#define BK3710_IORDYTMS 0x7C
|
||||||
|
|
||||||
#include "../ide-timing.h"
|
|
||||||
|
|
||||||
static unsigned ideclk_period; /* in nanoseconds */
|
static unsigned ideclk_period; /* in nanoseconds */
|
||||||
|
|
||||||
static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
|
static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#ifndef _IDE_TIMING_H
|
|
||||||
#define _IDE_TIMING_H
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999-2001 Vojtech Pavlik
|
* Copyright (c) 1999-2001 Vojtech Pavlik
|
||||||
*
|
*
|
||||||
|
@ -25,6 +22,8 @@
|
||||||
|
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/hdreg.h>
|
#include <linux/hdreg.h>
|
||||||
|
#include <linux/ide.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
|
* PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
|
||||||
|
@ -65,6 +64,17 @@ static struct ide_timing ide_timing[] = {
|
||||||
{ 0xff }
|
{ 0xff }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ide_timing *ide_timing_find_mode(u8 speed)
|
||||||
|
{
|
||||||
|
struct ide_timing *t;
|
||||||
|
|
||||||
|
for (t = ide_timing; t->mode != speed; t++)
|
||||||
|
if (t->mode == 0xff)
|
||||||
|
return NULL;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(ide_timing_find_mode);
|
||||||
|
|
||||||
#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
|
#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
|
||||||
#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
|
#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
|
||||||
|
|
||||||
|
@ -81,8 +91,8 @@ static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q,
|
||||||
q->udma = EZ(t->udma * 1000, UT);
|
q->udma = EZ(t->udma * 1000, UT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
|
void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
|
||||||
struct ide_timing *m, unsigned int what)
|
struct ide_timing *m, unsigned int what)
|
||||||
{
|
{
|
||||||
if (what & IDE_TIMING_SETUP)
|
if (what & IDE_TIMING_SETUP)
|
||||||
m->setup = max(a->setup, b->setup);
|
m->setup = max(a->setup, b->setup);
|
||||||
|
@ -101,19 +111,10 @@ static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
|
||||||
if (what & IDE_TIMING_UDMA)
|
if (what & IDE_TIMING_UDMA)
|
||||||
m->udma = max(a->udma, b->udma);
|
m->udma = max(a->udma, b->udma);
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(ide_timing_merge);
|
||||||
|
|
||||||
static struct ide_timing *ide_timing_find_mode(u8 speed)
|
int ide_timing_compute(ide_drive_t *drive, u8 speed,
|
||||||
{
|
struct ide_timing *t, int T, int UT)
|
||||||
struct ide_timing *t;
|
|
||||||
|
|
||||||
for (t = ide_timing; t->mode != speed; t++)
|
|
||||||
if (t->mode == 0xff)
|
|
||||||
return NULL;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ide_timing_compute(ide_drive_t *drive, u8 speed,
|
|
||||||
struct ide_timing *t, int T, int UT)
|
|
||||||
{
|
{
|
||||||
struct hd_driveid *id = drive->id;
|
struct hd_driveid *id = drive->id;
|
||||||
struct ide_timing *s, p;
|
struct ide_timing *s, p;
|
||||||
|
@ -179,5 +180,4 @@ static int ide_timing_compute(ide_drive_t *drive, u8 speed,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(ide_timing_compute);
|
||||||
#endif
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/ide.h>
|
#include <linux/ide.h>
|
||||||
|
|
||||||
#include "ide-timing.h"
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
AMD_IDE_CONFIG = 0x41,
|
AMD_IDE_CONFIG = 0x41,
|
||||||
AMD_CABLE_DETECT = 0x42,
|
AMD_CABLE_DETECT = 0x42,
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
#include <linux/ide.h>
|
#include <linux/ide.h>
|
||||||
|
|
||||||
#include "ide-timing.h"
|
|
||||||
|
|
||||||
#define MSR_ATAC_BASE 0x51300000
|
#define MSR_ATAC_BASE 0x51300000
|
||||||
#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0)
|
#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0)
|
||||||
#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01)
|
#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01)
|
||||||
|
|
|
@ -52,8 +52,6 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/ide.h>
|
#include <linux/ide.h>
|
||||||
|
|
||||||
#include "ide-timing.h"
|
|
||||||
|
|
||||||
/* registers layout and init values are chipset family dependant */
|
/* registers layout and init values are chipset family dependant */
|
||||||
|
|
||||||
#define ATA_16 0x01
|
#define ATA_16 0x01
|
||||||
|
@ -616,7 +614,6 @@ MODULE_LICENSE("GPL");
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
* - CLEANUP
|
* - CLEANUP
|
||||||
* - Use drivers/ide/ide-timing.h !
|
|
||||||
* - More checks in the config registers (force values instead of
|
* - More checks in the config registers (force values instead of
|
||||||
* relying on the BIOS setting them correctly).
|
* relying on the BIOS setting them correctly).
|
||||||
* - Further optimisations ?
|
* - Further optimisations ?
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
#include <asm/processor.h>
|
#include <asm/processor.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ide-timing.h"
|
|
||||||
|
|
||||||
#define VIA_IDE_ENABLE 0x40
|
#define VIA_IDE_ENABLE 0x40
|
||||||
#define VIA_IDE_CONFIG 0x41
|
#define VIA_IDE_CONFIG 0x41
|
||||||
#define VIA_FIFO_CONFIG 0x43
|
#define VIA_FIFO_CONFIG 0x43
|
||||||
|
|
|
@ -48,8 +48,6 @@
|
||||||
#include <asm/mediabay.h>
|
#include <asm/mediabay.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../ide-timing.h"
|
|
||||||
|
|
||||||
#undef IDE_PMAC_DEBUG
|
#undef IDE_PMAC_DEBUG
|
||||||
|
|
||||||
#define DMA_WAIT_TIMEOUT 50
|
#define DMA_WAIT_TIMEOUT 50
|
||||||
|
|
|
@ -1299,6 +1299,11 @@ enum {
|
||||||
IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
|
IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ide_timing *ide_timing_find_mode(u8);
|
||||||
|
void ide_timing_merge(struct ide_timing *, struct ide_timing *,
|
||||||
|
struct ide_timing *, unsigned int);
|
||||||
|
int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
|
||||||
|
|
||||||
typedef struct ide_pio_timings_s {
|
typedef struct ide_pio_timings_s {
|
||||||
int setup_time; /* Address setup (ns) minimum */
|
int setup_time; /* Address setup (ns) minimum */
|
||||||
int active_time; /* Active pulse (ns) minimum */
|
int active_time; /* Active pulse (ns) minimum */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user