* [PATCH] Add VIA VT6410 support
@ 2005-08-30 14:27 Daniel Drake
2005-08-30 15:12 ` Bartlomiej Zolnierkiewicz
0 siblings, 1 reply; 24+ messages in thread
From: Daniel Drake @ 2005-08-30 14:27 UTC (permalink / raw)
To: bzolnier, jgarzik; +Cc: linux-kernel, linux-ide, posting, vsu
[-- Attachment #1: Type: text/plain, Size: 553 bytes --]
Jeff/Bart,
Can of you please apply this to a git tree and get this included in 2.6.14.
The patch is about 6 months old and has been included in Gentoo kernels for
about 3 months, and we've recieved multiple success reports.
I sent a mail to Bart at the end of June asking about this, and Sergey Vlasov
recently asked the same question on LKML. If the patch isn't acceptable then
please at least say _something_ :)
Thanks!
--
From: Mathias Kretschmer <posting@blx4.net>
Add VIA VT6410 IDE support
Signed-off-by: Daniel Drake <dsd@gentoo.org>
[-- Attachment #2: 4300_via-vt6410.patch --]
[-- Type: text/x-patch, Size: 3052 bytes --]
diff -Naru a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
--- a/drivers/ide/pci/via82cxxx.c 2005-05-06 11:22:48 -07:00
+++ b/drivers/ide/pci/via82cxxx.c 2005-05-06 11:22:48 -07:00
@@ -79,6 +79,7 @@
u8 rev_max;
u16 flags;
} via_isa_bridges[] = {
+ { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
{ "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
{ "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
{ "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
@@ -616,24 +617,35 @@
hwif->drives[1].autodma = hwif->autodma;
}
-static ide_pci_device_t via82cxxx_chipset __devinitdata = {
- .name = "VP_IDE",
- .init_chipset = init_chipset_via82cxxx,
- .init_hwif = init_hwif_via82cxxx,
- .channels = 2,
- .autodma = NOAUTODMA,
- .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
- .bootable = ON_BOARD,
+static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
+ { /* 0 */
+ .name = "VP_IDE",
+ .init_chipset = init_chipset_via82cxxx,
+ .init_hwif = init_hwif_via82cxxx,
+ .channels = 2,
+ .autodma = NOAUTODMA,
+ .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
+ .bootable = ON_BOARD
+ },{ /* 1 */
+ .name = "VP_IDE",
+ .init_chipset = init_chipset_via82cxxx,
+ .init_hwif = init_hwif_via82cxxx,
+ .channels = 2,
+ .autodma = AUTODMA,
+ .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
+ .bootable = ON_BOARD,
+ }
};
static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
- return ide_setup_pci_device(dev, &via82cxxx_chipset);
+ return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
}
static struct pci_device_id via_pci_tbl[] = {
{ PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{ PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_6410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
{ 0, },
};
MODULE_DEVICE_TABLE(pci, via_pci_tbl);
diff -Naru a/include/linux/pci_ids.h b/include/linux/pci_ids.h
--- a/include/linux/pci_ids.h 2005-05-06 11:22:48 -07:00
+++ b/include/linux/pci_ids.h 2005-05-06 11:22:48 -07:00
@@ -1280,6 +1280,7 @@
#define PCI_DEVICE_ID_VIA_8703_51_0 0x3148
#define PCI_DEVICE_ID_VIA_8237_SATA 0x3149
#define PCI_DEVICE_ID_VIA_XN266 0x3156
+#define PCI_DEVICE_ID_VIA_6410 0x3164
#define PCI_DEVICE_ID_VIA_8754C_0 0x3168
#define PCI_DEVICE_ID_VIA_8235 0x3177
#define PCI_DEVICE_ID_VIA_P4N333 0x3178
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2005/02/11 19:31:17+01:00 bzolnier@trik.(none)
# [ide via82cxxx] add VIA VT6410 support
#
# From: Mathias Kretschmer <posting@blx4.net>
#
# drivers/ide/pci/via82cxxx.c
# 2005/02/11 19:31:06+01:00 bzolnier@trik.(none) +21 -9
# [ide via82cxxx] add VIA VT6410 support
#
# include/linux/pci_ids.h
# 2005/02/11 19:31:06+01:00 bzolnier@trik.(none) +1 -0
# [ide via82cxxx] add VIA VT6410 support
#
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [PATCH] Add VIA VT6410 support 2005-08-30 14:27 [PATCH] Add VIA VT6410 support Daniel Drake @ 2005-08-30 15:12 ` Bartlomiej Zolnierkiewicz 2005-09-02 0:28 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake 0 siblings, 1 reply; 24+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2005-08-30 15:12 UTC (permalink / raw) To: Daniel Drake; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu On 8/30/05, Daniel Drake <dsd@gentoo.org> wrote: > Jeff/Bart, > > Can of you please apply this to a git tree and get this included in 2.6.14. > The patch is about 6 months old and has been included in Gentoo kernels for > about 3 months, and we've recieved multiple success reports. > > I sent a mail to Bart at the end of June asking about this, and Sergey Vlasov > recently asked the same question on LKML. If the patch isn't acceptable then > please at least say _something_ :) Same thing as with VT6420 support: I'm still concerned about VIA IDE chipset + VT6410 combo (AFAIR I've also seen VT6410 on PCI add-on card but I can be wrong). via82cxxx.c needs to be fixed to support multiple controllers first. Thanks, Bartlomiej ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH] via82cxxx IDE: Support multiple controllers 2005-08-30 15:12 ` Bartlomiej Zolnierkiewicz @ 2005-09-02 0:28 ` Daniel Drake 2005-09-09 22:19 ` Daniel Drake 2005-09-27 13:20 ` Bartlomiej Zolnierkiewicz 0 siblings, 2 replies; 24+ messages in thread From: Daniel Drake @ 2005-09-02 0:28 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu [-- Attachment #1: Type: text/plain, Size: 525 bytes --] Bartlomiej Zolnierkiewicz wrote: > Same thing as with VT6420 support: > > I'm still concerned about VIA IDE chipset + VT6410 combo > (AFAIR I've also seen VT6410 on PCI add-on card but I can be wrong). > > via82cxxx.c needs to be fixed to support multiple controllers first. Hows this? I don't have any hardware with two VIA controllers, however I have tested this on a pc which has a single vt8233a controller. --- Support multiple controllers in the via82cxxx IDE driver Signed-off-by: Daniel Drake <dsd@gentoo.org> [-- Attachment #2: via82cxxx-multi.patch --] [-- Type: text/x-patch, Size: 13513 bytes --] --- linux/drivers/ide/pci/via82cxxx.c.orig 2005-08-31 01:32:05.000000000 +0100 +++ linux/drivers/ide/pci/via82cxxx.c 2005-09-02 01:16:59.000000000 +0100 @@ -101,11 +101,19 @@ static struct via_isa_bridge { { NULL } }; -static struct via_isa_bridge *via_config; -static unsigned int via_80w; -static unsigned int via_clock; static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" }; +struct via82cxxx_dev +{ + struct pci_dev *pci_dev, *isa_dev; + struct via_isa_bridge *via_config; + unsigned int via_clock; + unsigned int via_80w; +}; + +#define VIA_MAX_CONTROLLERS 4 +static struct via82cxxx_dev *via_controllers[VIA_MAX_CONTROLLERS]; + /* * VIA /proc entry. */ @@ -116,9 +124,6 @@ static char *via_dma[] = { "MWDMA16", "U #include <linux/proc_fs.h> static u8 via_proc = 0; -static unsigned long via_base; -static struct pci_dev *bmide_dev, *isa_dev; - static char *via_control3[] = { "No limit", "64", "128", "192" }; #define via_print(format, arg...) p += sprintf(p, format "\n" , ## arg) @@ -127,43 +132,42 @@ static char *via_control3[] = { "No limi /** - * via_get_info - generate via /proc file - * @buffer: buffer for data - * @addr: set to start of data to use - * @offset: current file offset - * @count: size of read + * via_print_controller_info - produce /proc info for one controller + * @p: buffer for data + * @hwif: hwif of controller * * Fills in buffer with the debugging/configuration information for - * the VIA chipset tuning and attached drives + * the VIA chipset tuning and attached drives on the specified + * controller. Returns the end of the buffer that was reached. */ - -static int via_get_info(char *buffer, char **addr, off_t offset, int count) + +static char* via_print_controller_info(char *p, struct via82cxxx_dev *vdev) { + struct pci_dev *dev = vdev->pci_dev; int speed[4], cycle[4], setup[4], active[4], recover[4], den[4], uen[4], udma[4], umul[4], active8b[4], recover8b[4]; - struct pci_dev *dev = bmide_dev; unsigned int v, u, i; - int len; u16 c, w; u8 t, x; - char *p = buffer; + unsigned long via_base; via_print("----------VIA BusMastering IDE Configuration" "----------------"); via_print("Driver Version: 3.38"); via_print("South Bridge: VIA %s", - via_config->name); + vdev->via_config->name); - pci_read_config_byte(isa_dev, PCI_REVISION_ID, &t); + pci_read_config_byte(vdev->isa_dev, PCI_REVISION_ID, &t); pci_read_config_byte(dev, PCI_REVISION_ID, &x); via_print("Revision: ISA %#x IDE %#x", t, x); via_print("Highest DMA rate: %s", - via_dma[via_config->flags & VIA_UDMA]); + via_dma[vdev->via_config->flags & VIA_UDMA]); + via_base = pci_resource_start(dev, 4); via_print("BM-DMA base: %#lx", via_base); via_print("PCI clock: %d.%dMHz", - via_clock / 1000, via_clock / 100 % 10); + vdev->via_clock / 1000, vdev->via_clock / 100 % 10); pci_read_config_byte(dev, VIA_MISC_1, &t); via_print("Master Read Cycle IRDY: %dws", @@ -199,7 +203,7 @@ static int via_get_info(char *buffer, ch (c & 0x80) ? "yes" : "no", (c & 0x8000) ? "yes" : "no"); via_print("Cable Type: %10s%20s", - (via_80w & 1) ? "80w" : "40w", (via_80w & 2) ? "80w" : "40w"); + (vdev->via_80w & 1) ? "80w" : "40w", (vdev->via_80w & 2) ? "80w" : "40w"); via_print("-------------------drive0----drive1" "----drive2----drive3-----"); @@ -208,7 +212,7 @@ static int via_get_info(char *buffer, ch pci_read_config_dword(dev, VIA_DRIVE_TIMING, &v); pci_read_config_word(dev, VIA_8BIT_TIMING, &w); - if (via_config->flags & VIA_UDMA) + if (vdev->via_config->flags & VIA_UDMA) pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); else u = 0; @@ -224,32 +228,32 @@ static int via_get_info(char *buffer, ch uen[i] = ((u >> ((3 - i) << 3)) & 0x20); den[i] = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2)); - speed[i] = 2 * via_clock / (active[i] + recover[i]); - cycle[i] = 1000000 * (active[i] + recover[i]) / via_clock; + speed[i] = 2 * vdev->via_clock / (active[i] + recover[i]); + cycle[i] = 1000000 * (active[i] + recover[i]) / vdev->via_clock; if (!uen[i] || !den[i]) continue; - switch (via_config->flags & VIA_UDMA) { + switch (vdev->via_config->flags & VIA_UDMA) { case VIA_UDMA_33: - speed[i] = 2 * via_clock / udma[i]; - cycle[i] = 1000000 * udma[i] / via_clock; + speed[i] = 2 * vdev->via_clock / udma[i]; + cycle[i] = 1000000 * udma[i] / vdev->via_clock; break; case VIA_UDMA_66: - speed[i] = 4 * via_clock / (udma[i] * umul[i]); - cycle[i] = 500000 * (udma[i] * umul[i]) / via_clock; + speed[i] = 4 * vdev->via_clock / (udma[i] * umul[i]); + cycle[i] = 500000 * (udma[i] * umul[i]) / vdev->via_clock; break; case VIA_UDMA_100: - speed[i] = 6 * via_clock / udma[i]; - cycle[i] = 333333 * udma[i] / via_clock; + speed[i] = 6 * vdev->via_clock / udma[i]; + cycle[i] = 333333 * udma[i] / vdev->via_clock; break; case VIA_UDMA_133: - speed[i] = 8 * via_clock / udma[i]; - cycle[i] = 250000 * udma[i] / via_clock; + speed[i] = 8 * vdev->via_clock / udma[i]; + cycle[i] = 250000 * udma[i] / vdev->via_clock; break; } } @@ -258,20 +262,46 @@ static int via_get_info(char *buffer, ch den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO"); via_print_drive("Address Setup: ", "%8dns", - 1000000 * setup[i] / via_clock); + 1000000 * setup[i] / vdev->via_clock); via_print_drive("Cmd Active: ", "%8dns", - 1000000 * active8b[i] / via_clock); + 1000000 * active8b[i] / vdev->via_clock); via_print_drive("Cmd Recovery: ", "%8dns", - 1000000 * recover8b[i] / via_clock); + 1000000 * recover8b[i] / vdev->via_clock); via_print_drive("Data Active: ", "%8dns", - 1000000 * active[i] / via_clock); + 1000000 * active[i] / vdev->via_clock); via_print_drive("Data Recovery: ", "%8dns", - 1000000 * recover[i] / via_clock); + 1000000 * recover[i] / vdev->via_clock); via_print_drive("Cycle Time: ", "%8dns", cycle[i]); via_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 1000, speed[i] / 100 % 10); + return p; +} + +/** + * via_get_info - generate via /proc file + * @buffer: buffer for data + * @addr: set to start of data to use + * @offset: current file offset + * @count: size of read + * + * Fills in buffer with the debugging/configuration information for + * the VIA chipset tuning and attached drives of all controllers + */ + +static int via_get_info(char *buffer, char **addr, off_t offset, int count) +{ + unsigned int i; + int len; + char *p = buffer; + + for (i = 0; i < VIA_MAX_CONTROLLERS; i++) + if (via_controllers[i] != NULL) { + via_print("====== CONTROLLER %d ======\n", i+1); + p = via_print_controller_info(p, via_controllers[i]); + } + /* hoping it is less than 4K... */ len = (p - buffer) - offset; *addr = buffer + offset; @@ -283,18 +313,20 @@ static int via_get_info(char *buffer, ch /** * via_set_speed - write timing registers - * @dev: PCI device + * @hwif: hwif of device * @dn: device * @timing: IDE timing data to use * * via_set_speed writes timing values to the chipset registers */ -static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing) +static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) { + struct pci_dev *dev = hwif->pci_dev; + struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif); u8 t; - if (~via_config->flags & VIA_BAD_AST) { + if (~vdev->via_config->flags & VIA_BAD_AST) { pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); @@ -306,7 +338,7 @@ static void via_set_speed(struct pci_dev pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); - switch (via_config->flags & VIA_UDMA) { + switch (vdev->via_config->flags & VIA_UDMA) { case VIA_UDMA_33: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; case VIA_UDMA_66: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; @@ -330,15 +362,16 @@ static void via_set_speed(struct pci_dev static int via_set_drive(ide_drive_t *drive, u8 speed) { ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); + struct via82cxxx_dev *vdev = ide_get_hwifdata(drive->hwif); struct ide_timing t, p; unsigned int T, UT; if (speed != XFER_PIO_SLOW) ide_config_drive_speed(drive, speed); - T = 1000000000 / via_clock; + T = 1000000000 / vdev->via_clock; - switch (via_config->flags & VIA_UDMA) { + switch (vdev->via_config->flags & VIA_UDMA) { case VIA_UDMA_33: UT = T; break; case VIA_UDMA_66: UT = T/2; break; case VIA_UDMA_100: UT = T/3; break; @@ -353,7 +386,7 @@ static int via_set_drive(ide_drive_t *dr ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); } - via_set_speed(HWIF(drive)->pci_dev, drive->dn, &t); + via_set_speed(HWIF(drive), drive->dn, &t); if (!drive->init_speed) drive->init_speed = speed; @@ -391,20 +424,22 @@ static void via82cxxx_tune_drive(ide_dri static int via82cxxx_ide_dma_check (ide_drive_t *drive) { - u16 w80 = HWIF(drive)->udma_four; + ide_hwif_t *hwif = HWIF(drive); + struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif); + u16 w80 = hwif->udma_four; u16 speed = ide_find_best_mode(drive, XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA | - (via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); + (vdev->via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); via_set_drive(drive, speed); if (drive->autodma && (speed & XFER_MODE) != XFER_PIO) - return HWIF(drive)->ide_dma_on(drive); - return HWIF(drive)->ide_dma_off_quietly(drive); + return hwif->ide_dma_on(drive); + return hwif->ide_dma_off_quietly(drive); } /** @@ -418,9 +453,11 @@ static int via82cxxx_ide_dma_check (ide_ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name) { + struct via82cxxx_dev *vdev; + struct via_isa_bridge *via_config; struct pci_dev *isa = NULL; u8 t, v; - unsigned int u; + unsigned int via_80w = 0, via_clock, u; int i; /* @@ -444,6 +481,28 @@ static unsigned int __devinit init_chips } /* + * Allocate and index a via82cxxx_dev for this controller + */ + + for (i = 0; i <= VIA_MAX_CONTROLLERS; i++) + if (via_controllers[i] == NULL) + break; + + if (i == VIA_MAX_CONTROLLERS) { + printk(KERN_WARNING "VP_IDE: Controller limit reached.\n"); + return -ENODEV; + } + + vdev = kmalloc(sizeof(struct via82cxxx_dev), GFP_KERNEL); + if (vdev == NULL) { + printk(KERN_ERR "VP_IDE: out of memory :(\n"); + return -ENODEV; + } + + memset(vdev, 0, sizeof(struct via82cxxx_dev)); + via_controllers[i] = vdev; + + /* * Check 80-wire cable presence and setup Clk66. */ @@ -562,14 +621,20 @@ static unsigned int __devinit init_chips pci_name(dev)); /* + * Populate our via82cxxx_dev + */ + vdev->pci_dev = dev; + vdev->isa_dev = isa; + vdev->via_config = via_config; + vdev->via_clock = via_clock; + vdev->via_80w = via_80w; + + /* * Setup /proc/ide/via entry. */ #if defined(DISPLAY_VIA_TIMINGS) && defined(CONFIG_PROC_FS) if (!via_proc) { - via_base = pci_resource_start(dev, 4); - bmide_dev = dev; - isa_dev = isa; ide_pci_create_host_proc("via", via_get_info); via_proc = 1; } @@ -580,6 +645,19 @@ static unsigned int __devinit init_chips static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) { int i; + struct via82cxxx_dev *vdev; + + /* + * Find the via82cxxx_dev we created at init_chipset time + */ + + for (i = 0; i < VIA_MAX_CONTROLLERS; i++) + if (via_controllers[i] != NULL + && via_controllers[i]->pci_dev == hwif->pci_dev) + break; + + vdev = via_controllers[i]; + ide_set_hwifdata(hwif, vdev); hwif->autodma = 0; @@ -595,7 +673,7 @@ static void __devinit init_hwif_via82cxx for (i = 0; i < 2; i++) { hwif->drives[i].io_32bit = 1; - hwif->drives[i].unmask = (via_config->flags & VIA_NO_UNMASK) ? 0 : 1; + hwif->drives[i].unmask = (vdev->via_config->flags & VIA_NO_UNMASK) ? 0 : 1; hwif->drives[i].autotune = 1; hwif->drives[i].dn = hwif->channel * 2 + i; } @@ -609,7 +687,7 @@ static void __devinit init_hwif_via82cxx hwif->swdma_mask = 0x07; if (!hwif->udma_four) - hwif->udma_four = (via_80w >> hwif->channel) & 1; + hwif->udma_four = (vdev->via_80w >> hwif->channel) & 1; hwif->ide_dma_check = &via82cxxx_ide_dma_check; if (!noautodma) hwif->autodma = 1; @@ -658,6 +736,7 @@ static struct pci_driver driver = { static int via_ide_init(void) { + memset(via_controllers, 0, sizeof(via_controllers)); return ide_pci_register_driver(&driver); } ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-09-02 0:28 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake @ 2005-09-09 22:19 ` Daniel Drake 2005-09-27 13:20 ` Bartlomiej Zolnierkiewicz 1 sibling, 0 replies; 24+ messages in thread From: Daniel Drake @ 2005-09-09 22:19 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide, posting, vsu [-- Attachment #1: Type: text/plain, Size: 424 bytes --] Bart, any word on this? I know you're busy but it would be much appreciated if you could comment, even if it is hurling abuse ;) Thanks. Daniel Drake wrote: > Hows this? I don't have any hardware with two VIA controllers, however I > have tested this on a pc which has a single vt8233a controller. > > --- > > Support multiple controllers in the via82cxxx IDE driver > > Signed-off-by: Daniel Drake <dsd@gentoo.org> [-- Attachment #2: via82cxxx-multi.patch --] [-- Type: text/x-patch, Size: 13513 bytes --] --- linux/drivers/ide/pci/via82cxxx.c.orig 2005-08-31 01:32:05.000000000 +0100 +++ linux/drivers/ide/pci/via82cxxx.c 2005-09-02 01:16:59.000000000 +0100 @@ -101,11 +101,19 @@ static struct via_isa_bridge { { NULL } }; -static struct via_isa_bridge *via_config; -static unsigned int via_80w; -static unsigned int via_clock; static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" }; +struct via82cxxx_dev +{ + struct pci_dev *pci_dev, *isa_dev; + struct via_isa_bridge *via_config; + unsigned int via_clock; + unsigned int via_80w; +}; + +#define VIA_MAX_CONTROLLERS 4 +static struct via82cxxx_dev *via_controllers[VIA_MAX_CONTROLLERS]; + /* * VIA /proc entry. */ @@ -116,9 +124,6 @@ static char *via_dma[] = { "MWDMA16", "U #include <linux/proc_fs.h> static u8 via_proc = 0; -static unsigned long via_base; -static struct pci_dev *bmide_dev, *isa_dev; - static char *via_control3[] = { "No limit", "64", "128", "192" }; #define via_print(format, arg...) p += sprintf(p, format "\n" , ## arg) @@ -127,43 +132,42 @@ static char *via_control3[] = { "No limi /** - * via_get_info - generate via /proc file - * @buffer: buffer for data - * @addr: set to start of data to use - * @offset: current file offset - * @count: size of read + * via_print_controller_info - produce /proc info for one controller + * @p: buffer for data + * @hwif: hwif of controller * * Fills in buffer with the debugging/configuration information for - * the VIA chipset tuning and attached drives + * the VIA chipset tuning and attached drives on the specified + * controller. Returns the end of the buffer that was reached. */ - -static int via_get_info(char *buffer, char **addr, off_t offset, int count) + +static char* via_print_controller_info(char *p, struct via82cxxx_dev *vdev) { + struct pci_dev *dev = vdev->pci_dev; int speed[4], cycle[4], setup[4], active[4], recover[4], den[4], uen[4], udma[4], umul[4], active8b[4], recover8b[4]; - struct pci_dev *dev = bmide_dev; unsigned int v, u, i; - int len; u16 c, w; u8 t, x; - char *p = buffer; + unsigned long via_base; via_print("----------VIA BusMastering IDE Configuration" "----------------"); via_print("Driver Version: 3.38"); via_print("South Bridge: VIA %s", - via_config->name); + vdev->via_config->name); - pci_read_config_byte(isa_dev, PCI_REVISION_ID, &t); + pci_read_config_byte(vdev->isa_dev, PCI_REVISION_ID, &t); pci_read_config_byte(dev, PCI_REVISION_ID, &x); via_print("Revision: ISA %#x IDE %#x", t, x); via_print("Highest DMA rate: %s", - via_dma[via_config->flags & VIA_UDMA]); + via_dma[vdev->via_config->flags & VIA_UDMA]); + via_base = pci_resource_start(dev, 4); via_print("BM-DMA base: %#lx", via_base); via_print("PCI clock: %d.%dMHz", - via_clock / 1000, via_clock / 100 % 10); + vdev->via_clock / 1000, vdev->via_clock / 100 % 10); pci_read_config_byte(dev, VIA_MISC_1, &t); via_print("Master Read Cycle IRDY: %dws", @@ -199,7 +203,7 @@ static int via_get_info(char *buffer, ch (c & 0x80) ? "yes" : "no", (c & 0x8000) ? "yes" : "no"); via_print("Cable Type: %10s%20s", - (via_80w & 1) ? "80w" : "40w", (via_80w & 2) ? "80w" : "40w"); + (vdev->via_80w & 1) ? "80w" : "40w", (vdev->via_80w & 2) ? "80w" : "40w"); via_print("-------------------drive0----drive1" "----drive2----drive3-----"); @@ -208,7 +212,7 @@ static int via_get_info(char *buffer, ch pci_read_config_dword(dev, VIA_DRIVE_TIMING, &v); pci_read_config_word(dev, VIA_8BIT_TIMING, &w); - if (via_config->flags & VIA_UDMA) + if (vdev->via_config->flags & VIA_UDMA) pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); else u = 0; @@ -224,32 +228,32 @@ static int via_get_info(char *buffer, ch uen[i] = ((u >> ((3 - i) << 3)) & 0x20); den[i] = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2)); - speed[i] = 2 * via_clock / (active[i] + recover[i]); - cycle[i] = 1000000 * (active[i] + recover[i]) / via_clock; + speed[i] = 2 * vdev->via_clock / (active[i] + recover[i]); + cycle[i] = 1000000 * (active[i] + recover[i]) / vdev->via_clock; if (!uen[i] || !den[i]) continue; - switch (via_config->flags & VIA_UDMA) { + switch (vdev->via_config->flags & VIA_UDMA) { case VIA_UDMA_33: - speed[i] = 2 * via_clock / udma[i]; - cycle[i] = 1000000 * udma[i] / via_clock; + speed[i] = 2 * vdev->via_clock / udma[i]; + cycle[i] = 1000000 * udma[i] / vdev->via_clock; break; case VIA_UDMA_66: - speed[i] = 4 * via_clock / (udma[i] * umul[i]); - cycle[i] = 500000 * (udma[i] * umul[i]) / via_clock; + speed[i] = 4 * vdev->via_clock / (udma[i] * umul[i]); + cycle[i] = 500000 * (udma[i] * umul[i]) / vdev->via_clock; break; case VIA_UDMA_100: - speed[i] = 6 * via_clock / udma[i]; - cycle[i] = 333333 * udma[i] / via_clock; + speed[i] = 6 * vdev->via_clock / udma[i]; + cycle[i] = 333333 * udma[i] / vdev->via_clock; break; case VIA_UDMA_133: - speed[i] = 8 * via_clock / udma[i]; - cycle[i] = 250000 * udma[i] / via_clock; + speed[i] = 8 * vdev->via_clock / udma[i]; + cycle[i] = 250000 * udma[i] / vdev->via_clock; break; } } @@ -258,20 +262,46 @@ static int via_get_info(char *buffer, ch den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO"); via_print_drive("Address Setup: ", "%8dns", - 1000000 * setup[i] / via_clock); + 1000000 * setup[i] / vdev->via_clock); via_print_drive("Cmd Active: ", "%8dns", - 1000000 * active8b[i] / via_clock); + 1000000 * active8b[i] / vdev->via_clock); via_print_drive("Cmd Recovery: ", "%8dns", - 1000000 * recover8b[i] / via_clock); + 1000000 * recover8b[i] / vdev->via_clock); via_print_drive("Data Active: ", "%8dns", - 1000000 * active[i] / via_clock); + 1000000 * active[i] / vdev->via_clock); via_print_drive("Data Recovery: ", "%8dns", - 1000000 * recover[i] / via_clock); + 1000000 * recover[i] / vdev->via_clock); via_print_drive("Cycle Time: ", "%8dns", cycle[i]); via_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 1000, speed[i] / 100 % 10); + return p; +} + +/** + * via_get_info - generate via /proc file + * @buffer: buffer for data + * @addr: set to start of data to use + * @offset: current file offset + * @count: size of read + * + * Fills in buffer with the debugging/configuration information for + * the VIA chipset tuning and attached drives of all controllers + */ + +static int via_get_info(char *buffer, char **addr, off_t offset, int count) +{ + unsigned int i; + int len; + char *p = buffer; + + for (i = 0; i < VIA_MAX_CONTROLLERS; i++) + if (via_controllers[i] != NULL) { + via_print("====== CONTROLLER %d ======\n", i+1); + p = via_print_controller_info(p, via_controllers[i]); + } + /* hoping it is less than 4K... */ len = (p - buffer) - offset; *addr = buffer + offset; @@ -283,18 +313,20 @@ static int via_get_info(char *buffer, ch /** * via_set_speed - write timing registers - * @dev: PCI device + * @hwif: hwif of device * @dn: device * @timing: IDE timing data to use * * via_set_speed writes timing values to the chipset registers */ -static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing) +static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) { + struct pci_dev *dev = hwif->pci_dev; + struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif); u8 t; - if (~via_config->flags & VIA_BAD_AST) { + if (~vdev->via_config->flags & VIA_BAD_AST) { pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); @@ -306,7 +338,7 @@ static void via_set_speed(struct pci_dev pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); - switch (via_config->flags & VIA_UDMA) { + switch (vdev->via_config->flags & VIA_UDMA) { case VIA_UDMA_33: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; case VIA_UDMA_66: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; @@ -330,15 +362,16 @@ static void via_set_speed(struct pci_dev static int via_set_drive(ide_drive_t *drive, u8 speed) { ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); + struct via82cxxx_dev *vdev = ide_get_hwifdata(drive->hwif); struct ide_timing t, p; unsigned int T, UT; if (speed != XFER_PIO_SLOW) ide_config_drive_speed(drive, speed); - T = 1000000000 / via_clock; + T = 1000000000 / vdev->via_clock; - switch (via_config->flags & VIA_UDMA) { + switch (vdev->via_config->flags & VIA_UDMA) { case VIA_UDMA_33: UT = T; break; case VIA_UDMA_66: UT = T/2; break; case VIA_UDMA_100: UT = T/3; break; @@ -353,7 +386,7 @@ static int via_set_drive(ide_drive_t *dr ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); } - via_set_speed(HWIF(drive)->pci_dev, drive->dn, &t); + via_set_speed(HWIF(drive), drive->dn, &t); if (!drive->init_speed) drive->init_speed = speed; @@ -391,20 +424,22 @@ static void via82cxxx_tune_drive(ide_dri static int via82cxxx_ide_dma_check (ide_drive_t *drive) { - u16 w80 = HWIF(drive)->udma_four; + ide_hwif_t *hwif = HWIF(drive); + struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif); + u16 w80 = hwif->udma_four; u16 speed = ide_find_best_mode(drive, XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA | - (via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); + (vdev->via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); via_set_drive(drive, speed); if (drive->autodma && (speed & XFER_MODE) != XFER_PIO) - return HWIF(drive)->ide_dma_on(drive); - return HWIF(drive)->ide_dma_off_quietly(drive); + return hwif->ide_dma_on(drive); + return hwif->ide_dma_off_quietly(drive); } /** @@ -418,9 +453,11 @@ static int via82cxxx_ide_dma_check (ide_ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name) { + struct via82cxxx_dev *vdev; + struct via_isa_bridge *via_config; struct pci_dev *isa = NULL; u8 t, v; - unsigned int u; + unsigned int via_80w = 0, via_clock, u; int i; /* @@ -444,6 +481,28 @@ static unsigned int __devinit init_chips } /* + * Allocate and index a via82cxxx_dev for this controller + */ + + for (i = 0; i <= VIA_MAX_CONTROLLERS; i++) + if (via_controllers[i] == NULL) + break; + + if (i == VIA_MAX_CONTROLLERS) { + printk(KERN_WARNING "VP_IDE: Controller limit reached.\n"); + return -ENODEV; + } + + vdev = kmalloc(sizeof(struct via82cxxx_dev), GFP_KERNEL); + if (vdev == NULL) { + printk(KERN_ERR "VP_IDE: out of memory :(\n"); + return -ENODEV; + } + + memset(vdev, 0, sizeof(struct via82cxxx_dev)); + via_controllers[i] = vdev; + + /* * Check 80-wire cable presence and setup Clk66. */ @@ -562,14 +621,20 @@ static unsigned int __devinit init_chips pci_name(dev)); /* + * Populate our via82cxxx_dev + */ + vdev->pci_dev = dev; + vdev->isa_dev = isa; + vdev->via_config = via_config; + vdev->via_clock = via_clock; + vdev->via_80w = via_80w; + + /* * Setup /proc/ide/via entry. */ #if defined(DISPLAY_VIA_TIMINGS) && defined(CONFIG_PROC_FS) if (!via_proc) { - via_base = pci_resource_start(dev, 4); - bmide_dev = dev; - isa_dev = isa; ide_pci_create_host_proc("via", via_get_info); via_proc = 1; } @@ -580,6 +645,19 @@ static unsigned int __devinit init_chips static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) { int i; + struct via82cxxx_dev *vdev; + + /* + * Find the via82cxxx_dev we created at init_chipset time + */ + + for (i = 0; i < VIA_MAX_CONTROLLERS; i++) + if (via_controllers[i] != NULL + && via_controllers[i]->pci_dev == hwif->pci_dev) + break; + + vdev = via_controllers[i]; + ide_set_hwifdata(hwif, vdev); hwif->autodma = 0; @@ -595,7 +673,7 @@ static void __devinit init_hwif_via82cxx for (i = 0; i < 2; i++) { hwif->drives[i].io_32bit = 1; - hwif->drives[i].unmask = (via_config->flags & VIA_NO_UNMASK) ? 0 : 1; + hwif->drives[i].unmask = (vdev->via_config->flags & VIA_NO_UNMASK) ? 0 : 1; hwif->drives[i].autotune = 1; hwif->drives[i].dn = hwif->channel * 2 + i; } @@ -609,7 +687,7 @@ static void __devinit init_hwif_via82cxx hwif->swdma_mask = 0x07; if (!hwif->udma_four) - hwif->udma_four = (via_80w >> hwif->channel) & 1; + hwif->udma_four = (vdev->via_80w >> hwif->channel) & 1; hwif->ide_dma_check = &via82cxxx_ide_dma_check; if (!noautodma) hwif->autodma = 1; @@ -658,6 +736,7 @@ static struct pci_driver driver = { static int via_ide_init(void) { + memset(via_controllers, 0, sizeof(via_controllers)); return ide_pci_register_driver(&driver); } ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-09-02 0:28 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake 2005-09-09 22:19 ` Daniel Drake @ 2005-09-27 13:20 ` Bartlomiej Zolnierkiewicz 2005-09-28 22:18 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Daniel Drake ` (2 more replies) 1 sibling, 3 replies; 24+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2005-09-27 13:20 UTC (permalink / raw) To: Daniel Drake; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu On 9/2/05, Daniel Drake <dsd@gentoo.org> wrote: > Bartlomiej Zolnierkiewicz wrote: > > Same thing as with VT6420 support: > > > > I'm still concerned about VIA IDE chipset + VT6410 combo > > (AFAIR I've also seen VT6410 on PCI add-on card but I can be wrong). > > > > via82cxxx.c needs to be fixed to support multiple controllers first. > > Hows this? I don't have any hardware with two VIA controllers, however I have > tested this on a pc which has a single vt8233a controller. > > --- > > Support multiple controllers in the via82cxxx IDE driver > > Signed-off-by: Daniel Drake <dsd@gentoo.org> --- linux/drivers/ide/pci/via82cxxx.c.orig 2005-08-31 01:32:05.000000000 +0100 +++ linux/drivers/ide/pci/via82cxxx.c 2005-09-02 01:16:59.000000000 +0100 @@ -101,11 +101,19 @@ static struct via_isa_bridge { { NULL } }; -static struct via_isa_bridge *via_config; -static unsigned int via_80w; -static unsigned int via_clock; static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" }; I would really prefer not to add per host struct via82xxx_dev, (making it per hwif and doing extra match in ->init_hwif() is acceptable). +struct via82cxxx_dev +{ + struct pci_dev *pci_dev, *isa_dev; pci_dev is needed only for /proc/via and I would prefer /proc/via to vanish because it complicates driver needlessly (could you do this in separate patch?). isa_dev has no relevance for vt6410 and won't be needed if /proc/via goes away + struct via_isa_bridge *via_config; Please instead add via_config_find() which would find proper via_config given PCI ID. + unsigned int via_clock; Global via_clock is OK as IDE core doesn't support per bus PCI clocks anyway. + unsigned int via_80w; Cable detection code should be moved to separate function and be called from ->init_hwif() (required for future hotplug support). Otherwise patch looks fine. Thanks and sorry for the delay, Bartlomiej ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH] via82cxxx IDE: Remove /proc/via entry 2005-09-27 13:20 ` Bartlomiej Zolnierkiewicz @ 2005-09-28 22:18 ` Daniel Drake 2005-09-28 22:37 ` Al Viro 2005-09-28 22:48 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Grzegorz Kulewski 2005-09-28 22:22 ` [PATCH] via82cxxx IDE: Support multiple controllers (v2) Daniel Drake 2005-10-12 15:38 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake 2 siblings, 2 replies; 24+ messages in thread From: Daniel Drake @ 2005-09-28 22:18 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu [-- Attachment #1: Type: text/plain, Size: 325 bytes --] This entry adds needless complication to the driver as it requires the use of global variables to be passed into via_get_info(), making things quite ugly when we try and make this driver support multiple controllers simultaneously. This patch removes /proc/via for simplicity. Signed-off-by: Daniel Drake <dsd@gentoo.org> [-- Attachment #2: via82cxxx-no-proc.patch --] [-- Type: text/x-patch, Size: 6672 bytes --] --- linux-2.6.14-rc1/drivers/ide/pci/via82cxxx.c.orig 2005-09-28 22:19:00.000000000 +0100 +++ linux-2.6.14-rc1/drivers/ide/pci/via82cxxx.c 2005-09-28 22:20:46.000000000 +0100 @@ -105,181 +105,6 @@ static unsigned int via_80w; static unsigned int via_clock; static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" }; -/* - * VIA /proc entry. - */ - -#if defined(DISPLAY_VIA_TIMINGS) && defined(CONFIG_PROC_FS) - -#include <linux/stat.h> -#include <linux/proc_fs.h> - -static u8 via_proc = 0; -static unsigned long via_base; -static struct pci_dev *bmide_dev, *isa_dev; - -static char *via_control3[] = { "No limit", "64", "128", "192" }; - -#define via_print(format, arg...) p += sprintf(p, format "\n" , ## arg) -#define via_print_drive(name, format, arg...)\ - p += sprintf(p, name); for (i = 0; i < 4; i++) p += sprintf(p, format, ## arg); p += sprintf(p, "\n"); - - -/** - * via_get_info - generate via /proc file - * @buffer: buffer for data - * @addr: set to start of data to use - * @offset: current file offset - * @count: size of read - * - * Fills in buffer with the debugging/configuration information for - * the VIA chipset tuning and attached drives - */ - -static int via_get_info(char *buffer, char **addr, off_t offset, int count) -{ - int speed[4], cycle[4], setup[4], active[4], recover[4], den[4], - uen[4], udma[4], umul[4], active8b[4], recover8b[4]; - struct pci_dev *dev = bmide_dev; - unsigned int v, u, i; - int len; - u16 c, w; - u8 t, x; - char *p = buffer; - - via_print("----------VIA BusMastering IDE Configuration" - "----------------"); - - via_print("Driver Version: 3.38"); - via_print("South Bridge: VIA %s", - via_config->name); - - pci_read_config_byte(isa_dev, PCI_REVISION_ID, &t); - pci_read_config_byte(dev, PCI_REVISION_ID, &x); - via_print("Revision: ISA %#x IDE %#x", t, x); - via_print("Highest DMA rate: %s", - via_dma[via_config->flags & VIA_UDMA]); - - via_print("BM-DMA base: %#lx", via_base); - via_print("PCI clock: %d.%dMHz", - via_clock / 1000, via_clock / 100 % 10); - - pci_read_config_byte(dev, VIA_MISC_1, &t); - via_print("Master Read Cycle IRDY: %dws", - (t & 64) >> 6); - via_print("Master Write Cycle IRDY: %dws", - (t & 32) >> 5); - via_print("BM IDE Status Register Read Retry: %s", - (t & 8) ? "yes" : "no"); - - pci_read_config_byte(dev, VIA_MISC_3, &t); - via_print("Max DRDY Pulse Width: %s%s", - via_control3[(t & 0x03)], (t & 0x03) ? " PCI clocks" : ""); - - via_print("-----------------------Primary IDE" - "-------Secondary IDE------"); - via_print("Read DMA FIFO flush: %10s%20s", - (t & 0x80) ? "yes" : "no", (t & 0x40) ? "yes" : "no"); - via_print("End Sector FIFO flush: %10s%20s", - (t & 0x20) ? "yes" : "no", (t & 0x10) ? "yes" : "no"); - - pci_read_config_byte(dev, VIA_IDE_CONFIG, &t); - via_print("Prefetch Buffer: %10s%20s", - (t & 0x80) ? "yes" : "no", (t & 0x20) ? "yes" : "no"); - via_print("Post Write Buffer: %10s%20s", - (t & 0x40) ? "yes" : "no", (t & 0x10) ? "yes" : "no"); - - pci_read_config_byte(dev, VIA_IDE_ENABLE, &t); - via_print("Enabled: %10s%20s", - (t & 0x02) ? "yes" : "no", (t & 0x01) ? "yes" : "no"); - - c = inb(via_base + 0x02) | (inb(via_base + 0x0a) << 8); - via_print("Simplex only: %10s%20s", - (c & 0x80) ? "yes" : "no", (c & 0x8000) ? "yes" : "no"); - - via_print("Cable Type: %10s%20s", - (via_80w & 1) ? "80w" : "40w", (via_80w & 2) ? "80w" : "40w"); - - via_print("-------------------drive0----drive1" - "----drive2----drive3-----"); - - pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); - pci_read_config_dword(dev, VIA_DRIVE_TIMING, &v); - pci_read_config_word(dev, VIA_8BIT_TIMING, &w); - - if (via_config->flags & VIA_UDMA) - pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); - else u = 0; - - for (i = 0; i < 4; i++) { - - setup[i] = ((t >> ((3 - i) << 1)) & 0x3) + 1; - recover8b[i] = ((w >> ((1 - (i >> 1)) << 3)) & 0xf) + 1; - active8b[i] = ((w >> (((1 - (i >> 1)) << 3) + 4)) & 0xf) + 1; - active[i] = ((v >> (((3 - i) << 3) + 4)) & 0xf) + 1; - recover[i] = ((v >> ((3 - i) << 3)) & 0xf) + 1; - udma[i] = ((u >> ((3 - i) << 3)) & 0x7) + 2; - umul[i] = ((u >> (((3 - i) & 2) << 3)) & 0x8) ? 1 : 2; - uen[i] = ((u >> ((3 - i) << 3)) & 0x20); - den[i] = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2)); - - speed[i] = 2 * via_clock / (active[i] + recover[i]); - cycle[i] = 1000000 * (active[i] + recover[i]) / via_clock; - - if (!uen[i] || !den[i]) - continue; - - switch (via_config->flags & VIA_UDMA) { - - case VIA_UDMA_33: - speed[i] = 2 * via_clock / udma[i]; - cycle[i] = 1000000 * udma[i] / via_clock; - break; - - case VIA_UDMA_66: - speed[i] = 4 * via_clock / (udma[i] * umul[i]); - cycle[i] = 500000 * (udma[i] * umul[i]) / via_clock; - break; - - case VIA_UDMA_100: - speed[i] = 6 * via_clock / udma[i]; - cycle[i] = 333333 * udma[i] / via_clock; - break; - - case VIA_UDMA_133: - speed[i] = 8 * via_clock / udma[i]; - cycle[i] = 250000 * udma[i] / via_clock; - break; - } - } - - via_print_drive("Transfer Mode: ", "%10s", - den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO"); - - via_print_drive("Address Setup: ", "%8dns", - 1000000 * setup[i] / via_clock); - via_print_drive("Cmd Active: ", "%8dns", - 1000000 * active8b[i] / via_clock); - via_print_drive("Cmd Recovery: ", "%8dns", - 1000000 * recover8b[i] / via_clock); - via_print_drive("Data Active: ", "%8dns", - 1000000 * active[i] / via_clock); - via_print_drive("Data Recovery: ", "%8dns", - 1000000 * recover[i] / via_clock); - via_print_drive("Cycle Time: ", "%8dns", - cycle[i]); - via_print_drive("Transfer Rate: ", "%4d.%dMB/s", - speed[i] / 1000, speed[i] / 100 % 10); - - /* hoping it is less than 4K... */ - len = (p - buffer) - offset; - *addr = buffer + offset; - - return len > count ? count : len; -} - -#endif /* DISPLAY_VIA_TIMINGS && CONFIG_PROC_FS */ - /** * via_set_speed - write timing registers * @dev: PCI device @@ -560,19 +385,6 @@ static unsigned int __devinit init_chips via_dma[via_config->flags & VIA_UDMA], pci_name(dev)); - /* - * Setup /proc/ide/via entry. - */ - -#if defined(DISPLAY_VIA_TIMINGS) && defined(CONFIG_PROC_FS) - if (!via_proc) { - via_base = pci_resource_start(dev, 4); - bmide_dev = dev; - isa_dev = isa; - ide_pci_create_host_proc("via", via_get_info); - via_proc = 1; - } -#endif /* DISPLAY_VIA_TIMINGS && CONFIG_PROC_FS */ return 0; } ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Remove /proc/via entry 2005-09-28 22:18 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Daniel Drake @ 2005-09-28 22:37 ` Al Viro 2005-09-28 23:00 ` [PATCH] via82cxxx IDE: Remove /proc/ide/via entry Daniel Drake 2005-09-28 22:48 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Grzegorz Kulewski 1 sibling, 1 reply; 24+ messages in thread From: Al Viro @ 2005-09-28 22:37 UTC (permalink / raw) To: Daniel Drake Cc: Bartlomiej Zolnierkiewicz, jgarzik, linux-kernel, linux-ide, posting, vsu On Wed, Sep 28, 2005 at 11:18:37PM +0100, Daniel Drake wrote: > This entry adds needless complication to the driver as it requires the use > of > global variables to be passed into via_get_info(), making things quite ugly > when we try and make this driver support multiple controllers > simultaneously. > > This patch removes /proc/via for simplicity. > > Signed-off-by: Daniel Drake <dsd@gentoo.org> Care to explain * where to get equivalent information? * what hardware setup has more than one of those controllers? ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Remove /proc/ide/via entry 2005-09-28 22:37 ` Al Viro @ 2005-09-28 23:00 ` Daniel Drake 2005-09-29 7:26 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 24+ messages in thread From: Daniel Drake @ 2005-09-28 23:00 UTC (permalink / raw) To: Al Viro Cc: Bartlomiej Zolnierkiewicz, jgarzik, linux-kernel, linux-ide, posting, vsu Hi Al, (btw, original subject was wrong, I actually meant /proc/ide/via) Al Viro wrote: > Care to explain > * where to get equivalent information? I don't think there is anywhere else that provides the whole range, but I do question the usefulness of most of it :) Here's my previous attempt at this patch: http://marc.theaimsgroup.com/?l=linux-ide&m=112630444000358&w=2 If you can point out a way to keep /proc/ide/via around without causing the kind of ugliness found above, then maybe Bart can be persuaded to keep it around :) > * what hardware setup has more than one of those controllers? I'm pushing to get a simple patch merged, which adds ID's for a VIA VT6410 controller. Apparently these are available in PCI-card form as well as onboard-PCI-chip form. Bart raised the concern that this driver wouldn't cope well with 2 different controllers in use, so I'm trying to address this. Thanks, Daniel ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Remove /proc/ide/via entry 2005-09-28 23:00 ` [PATCH] via82cxxx IDE: Remove /proc/ide/via entry Daniel Drake @ 2005-09-29 7:26 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 24+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2005-09-29 7:26 UTC (permalink / raw) To: Daniel Drake; +Cc: Al Viro, jgarzik, linux-kernel, linux-ide, posting, vsu Hi, On 9/29/05, Daniel Drake <dsd@gentoo.org> wrote: > Hi Al, > > (btw, original subject was wrong, I actually meant /proc/ide/via) > > Al Viro wrote: > > Care to explain > > * where to get equivalent information? > > I don't think there is anywhere else that provides the whole range, but I do > question the usefulness of most of it :) Exactly, all the important information is available through other sources (dmesg, lspci and of course /proc/ide/hd?/*) and configuration of timing registers etc. shouldn't be of user concern (and it is available from PCI configuration space so code to parse it can be easily moved to user-space). Bartlomiej ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Remove /proc/via entry 2005-09-28 22:18 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Daniel Drake 2005-09-28 22:37 ` Al Viro @ 2005-09-28 22:48 ` Grzegorz Kulewski 2005-09-29 7:27 ` Bartlomiej Zolnierkiewicz 1 sibling, 1 reply; 24+ messages in thread From: Grzegorz Kulewski @ 2005-09-28 22:48 UTC (permalink / raw) To: Daniel Drake Cc: Bartlomiej Zolnierkiewicz, jgarzik, linux-kernel, linux-ide, posting, vsu On Wed, 28 Sep 2005, Daniel Drake wrote: > This entry adds needless complication to the driver as it requires the use of > global variables to be passed into via_get_info(), making things quite ugly > when we try and make this driver support multiple controllers simultaneously. > > This patch removes /proc/via for simplicity. Is similar data available from sysfs? As a user of this controller, I think that if it is not then this patch should be changed to export it or should be dropped. The data from that file is really helpfull in debugging problems (for example related to bad cables or breaking disks/cdroms). Thanks, Grzegorz Kulewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Remove /proc/via entry 2005-09-28 22:48 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Grzegorz Kulewski @ 2005-09-29 7:27 ` Bartlomiej Zolnierkiewicz 2005-10-09 15:18 ` Grzegorz Kulewski 0 siblings, 1 reply; 24+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2005-09-29 7:27 UTC (permalink / raw) To: Grzegorz Kulewski Cc: Daniel Drake, jgarzik, linux-kernel, linux-ide, posting, vsu On 9/29/05, Grzegorz Kulewski <kangur@polcom.net> wrote: > On Wed, 28 Sep 2005, Daniel Drake wrote: > > > This entry adds needless complication to the driver as it requires the use of > > global variables to be passed into via_get_info(), making things quite ugly > > when we try and make this driver support multiple controllers simultaneously. > > > > This patch removes /proc/via for simplicity. > > Is similar data available from sysfs? > > As a user of this controller, I think that if it is not then this patch > should be changed to export it or should be dropped. The data from that > file is really helpfull in debugging problems (for example related to bad > cables or breaking disks/cdroms). Could you please give some details (which data is useful)? Bartlomiej ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Remove /proc/via entry 2005-09-29 7:27 ` Bartlomiej Zolnierkiewicz @ 2005-10-09 15:18 ` Grzegorz Kulewski 2005-10-13 22:52 ` Daniel Drake 0 siblings, 1 reply; 24+ messages in thread From: Grzegorz Kulewski @ 2005-10-09 15:18 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz Cc: Daniel Drake, jgarzik, linux-kernel, linux-ide, posting, vsu On Thu, 29 Sep 2005, Bartlomiej Zolnierkiewicz wrote: > On 9/29/05, Grzegorz Kulewski <kangur@polcom.net> wrote: >> On Wed, 28 Sep 2005, Daniel Drake wrote: >> >>> This entry adds needless complication to the driver as it requires the use of >>> global variables to be passed into via_get_info(), making things quite ugly >>> when we try and make this driver support multiple controllers simultaneously. >>> >>> This patch removes /proc/via for simplicity. >> >> Is similar data available from sysfs? >> >> As a user of this controller, I think that if it is not then this patch >> should be changed to export it or should be dropped. The data from that >> file is really helpfull in debugging problems (for example related to bad >> cables or breaking disks/cdroms). > > Could you please give some details (which data is useful)? Sorry for delay - I was very busy during past week. Well, I guess that thanks to this file I am able to know that the drive is connected to via chipset and not to some pseudo raid controller (it is important if I am working remotely), if it has 80w cables attached, what is attached where, what are controller parameters, dma rate and timings (if they are strange I can suspect that something bad is happening with the drive / controler). I am not saying that these data are not available elsewhere (but some are not for sure). But they are presented nicely in one standard place and this is in my opinion good. But I understand the desire to remove all files that can be removed from /proc. So I am just suggesting to move some of the data (like type of cable detected for example) to sysfs if they are not already there. Thanks, Grzegorz Kulewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Remove /proc/via entry 2005-10-09 15:18 ` Grzegorz Kulewski @ 2005-10-13 22:52 ` Daniel Drake 2005-11-18 20:39 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 24+ messages in thread From: Daniel Drake @ 2005-10-13 22:52 UTC (permalink / raw) To: Grzegorz Kulewski Cc: Bartlomiej Zolnierkiewicz, jgarzik, linux-kernel, linux-ide, posting, vsu Hi, Grzegorz Kulewski wrote: >>> As a user of this controller, I think that if it is not then this patch >>> should be changed to export it or should be dropped. The data from that >>> file is really helpfull in debugging problems (for example related to >>> bad >>> cables or breaking disks/cdroms). Per Bart's suggestion, I've created a user-space app which shows identical data (and doesn't even rely on the via82cxxx IDE driver). http://www.reactivated.net/software/viaideinfo/ So, I think we should be clear to drop /proc/ide/via now. Daniel ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Remove /proc/via entry 2005-10-13 22:52 ` Daniel Drake @ 2005-11-18 20:39 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 24+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2005-11-18 20:39 UTC (permalink / raw) To: Daniel Drake Cc: Grzegorz Kulewski, jgarzik, linux-kernel, linux-ide, posting, vsu On 10/13/05, Daniel Drake <dsd@gentoo.org> wrote: > Hi, > > Grzegorz Kulewski wrote: > >>> As a user of this controller, I think that if it is not then this patch > >>> should be changed to export it or should be dropped. The data from that > >>> file is really helpfull in debugging problems (for example related to > >>> bad > >>> cables or breaking disks/cdroms). > > Per Bart's suggestion, I've created a user-space app which shows identical > data (and doesn't even rely on the via82cxxx IDE driver). > > http://www.reactivated.net/software/viaideinfo/ > > So, I think we should be clear to drop /proc/ide/via now. patch applied, thanks for working on this ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers (v2) 2005-09-27 13:20 ` Bartlomiej Zolnierkiewicz 2005-09-28 22:18 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Daniel Drake @ 2005-09-28 22:22 ` Daniel Drake 2005-11-04 10:52 ` Daniel Drake 2005-10-12 15:38 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake 2 siblings, 1 reply; 24+ messages in thread From: Daniel Drake @ 2005-09-28 22:22 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu [-- Attachment #1: Type: text/plain, Size: 316 bytes --] Support multiple controllers in the via82cxxx IDE driver, revised patch. Cable detection and ISA bridge finding have been moved into their own functions. Unfortunately I won't have access to a via82cxxx machine until December now, this patch is only compile-tested. Signed-off-by: Daniel Drake <dsd@gentoo.org> [-- Attachment #2: via82cxxx-multi-2.patch --] [-- Type: text/x-patch, Size: 9424 bytes --] --- linux-2.6.14-rc1/drivers/ide/pci/via82cxxx.c.orig 2005-09-28 22:31:22.000000000 +0100 +++ linux-2.6.14-rc1/drivers/ide/pci/via82cxxx.c 2005-09-28 23:06:50.000000000 +0100 @@ -100,11 +100,15 @@ static struct via_isa_bridge { { NULL } }; -static struct via_isa_bridge *via_config; -static unsigned int via_80w; static unsigned int via_clock; static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" }; +struct via82cxxx_dev +{ + struct via_isa_bridge *via_config; + unsigned int via_80w; +}; + /** * via_set_speed - write timing registers * @dev: PCI device @@ -114,11 +118,13 @@ static char *via_dma[] = { "MWDMA16", "U * via_set_speed writes timing values to the chipset registers */ -static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing) +static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) { + struct pci_dev *dev = hwif->pci_dev; + struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif); u8 t; - if (~via_config->flags & VIA_BAD_AST) { + if (~vdev->via_config->flags & VIA_BAD_AST) { pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); @@ -130,7 +136,7 @@ static void via_set_speed(struct pci_dev pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); - switch (via_config->flags & VIA_UDMA) { + switch (vdev->via_config->flags & VIA_UDMA) { case VIA_UDMA_33: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; case VIA_UDMA_66: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; @@ -154,6 +160,7 @@ static void via_set_speed(struct pci_dev static int via_set_drive(ide_drive_t *drive, u8 speed) { ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); + struct via82cxxx_dev *vdev = ide_get_hwifdata(drive->hwif); struct ide_timing t, p; unsigned int T, UT; @@ -162,7 +169,7 @@ static int via_set_drive(ide_drive_t *dr T = 1000000000 / via_clock; - switch (via_config->flags & VIA_UDMA) { + switch (vdev->via_config->flags & VIA_UDMA) { case VIA_UDMA_33: UT = T; break; case VIA_UDMA_66: UT = T/2; break; case VIA_UDMA_100: UT = T/3; break; @@ -177,7 +184,7 @@ static int via_set_drive(ide_drive_t *dr ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); } - via_set_speed(HWIF(drive)->pci_dev, drive->dn, &t); + via_set_speed(HWIF(drive), drive->dn, &t); if (!drive->init_speed) drive->init_speed = speed; @@ -215,20 +222,41 @@ static void via82cxxx_tune_drive(ide_dri static int via82cxxx_ide_dma_check (ide_drive_t *drive) { - u16 w80 = HWIF(drive)->udma_four; + ide_hwif_t *hwif = HWIF(drive); + struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif); + u16 w80 = hwif->udma_four; u16 speed = ide_find_best_mode(drive, XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA | - (via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | - (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); + (vdev->via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | + (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); via_set_drive(drive, speed); if (drive->autodma && (speed & XFER_MODE) != XFER_PIO) - return HWIF(drive)->ide_dma_on(drive); - return HWIF(drive)->ide_dma_off_quietly(drive); + return hwif->ide_dma_on(drive); + return hwif->ide_dma_off_quietly(drive); +} + +static struct via_isa_bridge *via_config_find(struct pci_dev **isa) +{ + struct via_isa_bridge *via_config; + u8 t; + + for (via_config = via_isa_bridges; via_config->id; via_config++) + if ((*isa = pci_find_device(PCI_VENDOR_ID_VIA + + !!(via_config->flags & VIA_BAD_ID), + via_config->id, NULL))) { + + pci_read_config_byte(*isa, PCI_REVISION_ID, &t); + if (t >= via_config->rev_min && + t <= via_config->rev_max) + break; + } + + return via_config; } /** @@ -243,82 +271,28 @@ static int via82cxxx_ide_dma_check (ide_ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name) { struct pci_dev *isa = NULL; + struct via_isa_bridge *via_config; u8 t, v; unsigned int u; - int i; /* * Find the ISA bridge to see how good the IDE is. */ - - for (via_config = via_isa_bridges; via_config->id; via_config++) - if ((isa = pci_find_device(PCI_VENDOR_ID_VIA + - !!(via_config->flags & VIA_BAD_ID), - via_config->id, NULL))) { - - pci_read_config_byte(isa, PCI_REVISION_ID, &t); - if (t >= via_config->rev_min && - t <= via_config->rev_max) - break; - } - + via_config = via_config_find(&isa); if (!via_config->id) { printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); return -ENODEV; } /* - * Check 80-wire cable presence and setup Clk66. + * Setup or disable Clk66 if appropriate */ - switch (via_config->flags & VIA_UDMA) { - - case VIA_UDMA_66: - /* Enable Clk66 */ - pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); - pci_write_config_dword(dev, VIA_UDMA_TIMING, u|0x80008); - for (i = 24; i >= 0; i -= 8) - if (((u >> (i & 16)) & 8) && - ((u >> i) & 0x20) && - (((u >> i) & 7) < 2)) { - /* - * 2x PCI clock and - * UDMA w/ < 3T/cycle - */ - via_80w |= (1 << (1 - (i >> 4))); - } - break; - - case VIA_UDMA_100: - pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); - for (i = 24; i >= 0; i -= 8) - if (((u >> i) & 0x10) || - (((u >> i) & 0x20) && - (((u >> i) & 7) < 4))) { - /* BIOS 80-wire bit or - * UDMA w/ < 60ns/cycle - */ - via_80w |= (1 << (1 - (i >> 4))); - } - break; - - case VIA_UDMA_133: - pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); - for (i = 24; i >= 0; i -= 8) - if (((u >> i) & 0x10) || - (((u >> i) & 0x20) && - (((u >> i) & 7) < 6))) { - /* BIOS 80-wire bit or - * UDMA w/ < 60ns/cycle - */ - via_80w |= (1 << (1 - (i >> 4))); - } - break; - - } - - /* Disable Clk66 */ - if (via_config->flags & VIA_BAD_CLK66) { + if ((via_config->flags & VIA_UDMA) == VIA_UDMA_66) { + /* Enable Clk66 */ + pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); + pci_write_config_dword(dev, VIA_UDMA_TIMING, u|0x80008); + } else if (via_config->flags & VIA_BAD_CLK66) { /* Would cause trouble on 596a and 686 */ pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); pci_write_config_dword(dev, VIA_UDMA_TIMING, u & ~0x80008); @@ -388,10 +362,75 @@ static unsigned int __devinit init_chips return 0; } +/* + * Check and handle 80-wire cable presence + */ +static void __devinit via_cable_detect(struct pci_dev *dev, struct via82cxxx_dev *vdev) +{ + unsigned int u; + int i; + pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); + + switch (vdev->via_config->flags & VIA_UDMA) { + + case VIA_UDMA_66: + for (i = 24; i >= 0; i -= 8) + if (((u >> (i & 16)) & 8) && + ((u >> i) & 0x20) && + (((u >> i) & 7) < 2)) { + /* + * 2x PCI clock and + * UDMA w/ < 3T/cycle + */ + vdev->via_80w |= (1 << (1 - (i >> 4))); + } + break; + + case VIA_UDMA_100: + for (i = 24; i >= 0; i -= 8) + if (((u >> i) & 0x10) || + (((u >> i) & 0x20) && + (((u >> i) & 7) < 4))) { + /* BIOS 80-wire bit or + * UDMA w/ < 60ns/cycle + */ + vdev->via_80w |= (1 << (1 - (i >> 4))); + } + break; + + case VIA_UDMA_133: + for (i = 24; i >= 0; i -= 8) + if (((u >> i) & 0x10) || + (((u >> i) & 0x20) && + (((u >> i) & 7) < 6))) { + /* BIOS 80-wire bit or + * UDMA w/ < 60ns/cycle + */ + vdev->via_80w |= (1 << (1 - (i >> 4))); + } + break; + + } +} + static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) { + struct via82cxxx_dev *vdev = kmalloc(sizeof(struct via82cxxx_dev), + GFP_KERNEL); + struct pci_dev *isa = NULL; int i; + if (vdev == NULL) { + printk(KERN_ERR "VP_IDE: out of memory :(\n"); + return; + } + + memset(vdev, 0, sizeof(struct via82cxxx_dev)); + ide_set_hwifdata(hwif, vdev); + + vdev->via_config = via_config_find(&isa); + via_cable_detect(hwif->pci_dev, vdev); + hwif->autodma = 0; hwif->tuneproc = &via82cxxx_tune_drive; @@ -406,7 +445,7 @@ static void __devinit init_hwif_via82cxx for (i = 0; i < 2; i++) { hwif->drives[i].io_32bit = 1; - hwif->drives[i].unmask = (via_config->flags & VIA_NO_UNMASK) ? 0 : 1; + hwif->drives[i].unmask = (vdev->via_config->flags & VIA_NO_UNMASK) ? 0 : 1; hwif->drives[i].autotune = 1; hwif->drives[i].dn = hwif->channel * 2 + i; } @@ -420,7 +459,7 @@ static void __devinit init_hwif_via82cxx hwif->swdma_mask = 0x07; if (!hwif->udma_four) - hwif->udma_four = (via_80w >> hwif->channel) & 1; + hwif->udma_four = (vdev->via_80w >> hwif->channel) & 1; hwif->ide_dma_check = &via82cxxx_ide_dma_check; if (!noautodma) hwif->autodma = 1; ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers (v2) 2005-09-28 22:22 ` [PATCH] via82cxxx IDE: Support multiple controllers (v2) Daniel Drake @ 2005-11-04 10:52 ` Daniel Drake 2005-11-18 20:41 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 24+ messages in thread From: Daniel Drake @ 2005-11-04 10:52 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu Daniel Drake wrote: > Support multiple controllers in the via82cxxx IDE driver, revised patch. > Cable detection and ISA bridge finding have been moved into their own > functions. > > Unfortunately I won't have access to a via82cxxx machine until December > now, this patch is only compile-tested. I went home a little earlier than expected and tested this patch on my single-controller via machine. It works fine. Is this ok to be merged? > Signed-off-by: Daniel Drake <dsd@gentoo.org> > > > ------------------------------------------------------------------------ > > --- linux-2.6.14-rc1/drivers/ide/pci/via82cxxx.c.orig 2005-09-28 22:31:22.000000000 +0100 > +++ linux-2.6.14-rc1/drivers/ide/pci/via82cxxx.c 2005-09-28 23:06:50.000000000 +0100 ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers (v2) 2005-11-04 10:52 ` Daniel Drake @ 2005-11-18 20:41 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 24+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2005-11-18 20:41 UTC (permalink / raw) To: Daniel Drake; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu On 11/4/05, Daniel Drake <dsd@gentoo.org> wrote: > Daniel Drake wrote: > > Support multiple controllers in the via82cxxx IDE driver, revised patch. > > Cable detection and ISA bridge finding have been moved into their own > > functions. > > > > Unfortunately I won't have access to a via82cxxx machine until December > > now, this patch is only compile-tested. > > I went home a little earlier than expected and tested this patch on my > single-controller via machine. It works fine. Is this ok to be merged? applied ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-09-27 13:20 ` Bartlomiej Zolnierkiewicz 2005-09-28 22:18 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Daniel Drake 2005-09-28 22:22 ` [PATCH] via82cxxx IDE: Support multiple controllers (v2) Daniel Drake @ 2005-10-12 15:38 ` Daniel Drake 2005-10-12 15:49 ` Jeff Garzik 2005-10-12 15:57 ` Daniel Drake 2 siblings, 2 replies; 24+ messages in thread From: Daniel Drake @ 2005-10-12 15:38 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu Bartlomiej Zolnierkiewicz wrote: > I would prefer /proc/via > to vanish because it complicates driver needlessly (could you do > this in separate patch?). I'm working on a user-space app to provide the same info. It's nearly there but lacking some timing info. Do you have any suggestions for how I can compute the value of via_clock in userspace? (i.e. some equivalent of system_bus_clock()) Thanks, Daniel ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-10-12 15:38 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake @ 2005-10-12 15:49 ` Jeff Garzik 2005-10-12 15:57 ` Daniel Drake 1 sibling, 0 replies; 24+ messages in thread From: Jeff Garzik @ 2005-10-12 15:49 UTC (permalink / raw) To: Daniel Drake; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel, linux-ide, Alan Cox Daniel Drake wrote: > Bartlomiej Zolnierkiewicz wrote: > >> I would prefer /proc/via >> to vanish because it complicates driver needlessly (could you do >> this in separate patch?). > > > I'm working on a user-space app to provide the same info. It's nearly > there but lacking some timing info. > > Do you have any suggestions for how I can compute the value of via_clock > in userspace? (i.e. some equivalent of system_bus_clock()) A sysfs read-only attribute, associated with the PCI device? Of course, procfs sure seems a whole lot easier some days... Jeff ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-10-12 15:38 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake 2005-10-12 15:49 ` Jeff Garzik @ 2005-10-12 15:57 ` Daniel Drake 2005-10-12 17:52 ` Alan Cox 1 sibling, 1 reply; 24+ messages in thread From: Daniel Drake @ 2005-10-12 15:57 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz; +Cc: jgarzik, linux-kernel, linux-ide, posting, vsu Daniel Drake wrote: > Do you have any suggestions for how I can compute the value of via_clock > in userspace? (i.e. some equivalent of system_bus_clock()) Uh, looks like the kernel just assumes 33mhz unless overriden by the user. Is this assumption generally accurate? If it is not, then there's probably no point displaying timing info... Daniel ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-10-12 15:57 ` Daniel Drake @ 2005-10-12 17:52 ` Alan Cox 2005-10-13 11:45 ` Alan Cox 0 siblings, 1 reply; 24+ messages in thread From: Alan Cox @ 2005-10-12 17:52 UTC (permalink / raw) To: Daniel Drake Cc: Bartlomiej Zolnierkiewicz, jgarzik, linux-kernel, linux-ide, posting, vsu On Mer, 2005-10-12 at 16:57 +0100, Daniel Drake wrote: > Uh, looks like the kernel just assumes 33mhz unless overriden by the user. Is > this assumption generally accurate? > If it is not, then there's probably no point displaying timing info... A small number of 486 systems use 25Mhz, some boards allow overclock at 37.5Mhz on the PCI. I've been looking at this the past couple of days for the libata via driver which I've been porting over and unfortunately having been through the Northbridge manuals I can find no way to ask the chipset what the PCI clock is set too. Alan ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-10-12 17:52 ` Alan Cox @ 2005-10-13 11:45 ` Alan Cox 2005-10-13 14:41 ` Mark Lord 0 siblings, 1 reply; 24+ messages in thread From: Alan Cox @ 2005-10-13 11:45 UTC (permalink / raw) To: Daniel Drake Cc: Bartlomiej Zolnierkiewicz, jgarzik, linux-kernel, linux-ide, posting, vsu On Mer, 2005-10-12 at 18:52 +0100, Alan Cox wrote: > On Mer, 2005-10-12 at 16:57 +0100, Daniel Drake wrote: > > Uh, looks like the kernel just assumes 33mhz unless overriden by the user. Is > > this assumption generally accurate? > > If it is not, then there's probably no point displaying timing info... > > A small number of 486 systems use 25Mhz, some boards allow overclock at > 37.5Mhz on the PCI. I've been looking at this the past couple of days > for the libata via driver which I've been porting over and unfortunately > having been through the Northbridge manuals I can find no way to ask the > chipset what the PCI clock is set too. Ok I found what seems to be a pattern for the early chipsets with 25MHz support. If the bus speed of your 486 is 25Mhz the chipset is at 25MHz as is your IDE (ie 486/25, DX2/50, 3/75 - not sure about 4/100 etc). Now does anyone know how you find out if the CPU is 25MHz bus clocked on a 486 8) ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-10-13 11:45 ` Alan Cox @ 2005-10-13 14:41 ` Mark Lord 2005-10-13 15:29 ` Alan Cox 0 siblings, 1 reply; 24+ messages in thread From: Mark Lord @ 2005-10-13 14:41 UTC (permalink / raw) To: Alan Cox Cc: Daniel Drake, Bartlomiej Zolnierkiewicz, jgarzik, linux-kernel, linux-ide, posting, vsu Alan Cox wrote: > > If the bus speed of your 486 is 25Mhz the chipset is at 25MHz as is your > IDE (ie 486/25, DX2/50, 3/75 - not sure about 4/100 etc). Now does > anyone know how you find out if the CPU is 25MHz bus clocked on a 486 8) Same method as /proc/cpuinfo, for an approximation? :) ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] via82cxxx IDE: Support multiple controllers 2005-10-13 14:41 ` Mark Lord @ 2005-10-13 15:29 ` Alan Cox 0 siblings, 0 replies; 24+ messages in thread From: Alan Cox @ 2005-10-13 15:29 UTC (permalink / raw) To: Mark Lord Cc: Daniel Drake, Bartlomiej Zolnierkiewicz, jgarzik, linux-kernel, linux-ide, posting, vsu On Iau, 2005-10-13 at 10:41 -0400, Mark Lord wrote: > Alan Cox wrote: > > > > If the bus speed of your 486 is 25Mhz the chipset is at 25MHz as is your > > IDE (ie 486/25, DX2/50, 3/75 - not sure about 4/100 etc). Now does > > anyone know how you find out if the CPU is 25MHz bus clocked on a 486 8) > > Same method as /proc/cpuinfo, for an approximation? :) Unfortunately cpuinfo doesn't know the difference between a 100Mhz (4x25) and 100Mhz (3x33). Late 486s have cpuid which helps a bit but many do not have that (it comes in with writeback cache) and they don't have rdmsr to access the processor boot bus speed bits as the preventium and later do. Alan ^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2005-11-18 20:41 UTC | newest] Thread overview: 24+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-08-30 14:27 [PATCH] Add VIA VT6410 support Daniel Drake 2005-08-30 15:12 ` Bartlomiej Zolnierkiewicz 2005-09-02 0:28 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake 2005-09-09 22:19 ` Daniel Drake 2005-09-27 13:20 ` Bartlomiej Zolnierkiewicz 2005-09-28 22:18 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Daniel Drake 2005-09-28 22:37 ` Al Viro 2005-09-28 23:00 ` [PATCH] via82cxxx IDE: Remove /proc/ide/via entry Daniel Drake 2005-09-29 7:26 ` Bartlomiej Zolnierkiewicz 2005-09-28 22:48 ` [PATCH] via82cxxx IDE: Remove /proc/via entry Grzegorz Kulewski 2005-09-29 7:27 ` Bartlomiej Zolnierkiewicz 2005-10-09 15:18 ` Grzegorz Kulewski 2005-10-13 22:52 ` Daniel Drake 2005-11-18 20:39 ` Bartlomiej Zolnierkiewicz 2005-09-28 22:22 ` [PATCH] via82cxxx IDE: Support multiple controllers (v2) Daniel Drake 2005-11-04 10:52 ` Daniel Drake 2005-11-18 20:41 ` Bartlomiej Zolnierkiewicz 2005-10-12 15:38 ` [PATCH] via82cxxx IDE: Support multiple controllers Daniel Drake 2005-10-12 15:49 ` Jeff Garzik 2005-10-12 15:57 ` Daniel Drake 2005-10-12 17:52 ` Alan Cox 2005-10-13 11:45 ` Alan Cox 2005-10-13 14:41 ` Mark Lord 2005-10-13 15:29 ` Alan Cox
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).