2006-10-03 08:14:12 +00:00
|
|
|
|
|
|
|
/*
|
2008-11-02 20:40:08 +00:00
|
|
|
* Copyright (C) 2006 Red Hat
|
2006-10-03 08:14:12 +00:00
|
|
|
*
|
|
|
|
* May be copied or modified under the terms of the GNU General Public License
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/ide.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
2008-07-24 20:53:32 +00:00
|
|
|
#define DRV_NAME "jmicron"
|
|
|
|
|
2006-10-03 08:14:12 +00:00
|
|
|
typedef enum {
|
|
|
|
PORT_PATA0 = 0,
|
|
|
|
PORT_PATA1 = 1,
|
|
|
|
PORT_SATA = 2,
|
|
|
|
} port_type;
|
|
|
|
|
|
|
|
/**
|
2008-04-26 20:25:14 +00:00
|
|
|
* jmicron_cable_detect - cable detection
|
2006-10-03 08:14:12 +00:00
|
|
|
* @hwif: IDE port
|
|
|
|
*
|
2007-07-09 21:17:58 +00:00
|
|
|
* Returns the cable type.
|
2006-10-03 08:14:12 +00:00
|
|
|
*/
|
|
|
|
|
2008-08-05 16:17:04 +00:00
|
|
|
static u8 jmicron_cable_detect(ide_hwif_t *hwif)
|
2006-10-03 08:14:12 +00:00
|
|
|
{
|
2008-02-01 22:09:31 +00:00
|
|
|
struct pci_dev *pdev = to_pci_dev(hwif->dev);
|
2006-10-03 08:14:12 +00:00
|
|
|
|
|
|
|
u32 control;
|
|
|
|
u32 control5;
|
|
|
|
|
|
|
|
int port = hwif->channel;
|
|
|
|
port_type port_map[2];
|
|
|
|
|
|
|
|
pci_read_config_dword(pdev, 0x40, &control);
|
|
|
|
|
|
|
|
/* There are two basic mappings. One has the two SATA ports merged
|
|
|
|
as master/slave and the secondary as PATA, the other has only the
|
|
|
|
SATA port mapped */
|
|
|
|
if (control & (1 << 23)) {
|
|
|
|
port_map[0] = PORT_SATA;
|
|
|
|
port_map[1] = PORT_PATA0;
|
|
|
|
} else {
|
|
|
|
port_map[0] = PORT_SATA;
|
|
|
|
port_map[1] = PORT_SATA;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The 365/366 may have this bit set to map the second PATA port
|
|
|
|
as the internal primary channel */
|
|
|
|
pci_read_config_dword(pdev, 0x80, &control5);
|
|
|
|
if (control5 & (1<<24))
|
|
|
|
port_map[0] = PORT_PATA1;
|
|
|
|
|
|
|
|
/* The two ports may then be logically swapped by the firmware */
|
|
|
|
if (control & (1 << 22))
|
|
|
|
port = port ^ 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now we know which physical port we are talking about we can
|
|
|
|
* actually do our cable checking etc. Thankfully we don't need
|
|
|
|
* to do the plumbing for other cases.
|
|
|
|
*/
|
2008-04-26 15:36:40 +00:00
|
|
|
switch (port_map[port]) {
|
2006-10-03 08:14:12 +00:00
|
|
|
case PORT_PATA0:
|
|
|
|
if (control & (1 << 3)) /* 40/80 pin primary */
|
2007-07-09 21:17:58 +00:00
|
|
|
return ATA_CBL_PATA40;
|
|
|
|
return ATA_CBL_PATA80;
|
2006-10-03 08:14:12 +00:00
|
|
|
case PORT_PATA1:
|
|
|
|
if (control5 & (1 << 19)) /* 40/80 pin secondary */
|
2007-07-09 21:17:58 +00:00
|
|
|
return ATA_CBL_PATA40;
|
|
|
|
return ATA_CBL_PATA80;
|
2006-10-03 08:14:12 +00:00
|
|
|
case PORT_SATA:
|
2007-01-27 12:46:21 +00:00
|
|
|
break;
|
2006-10-03 08:14:12 +00:00
|
|
|
}
|
2007-07-09 21:17:58 +00:00
|
|
|
/* Avoid bogus "control reaches end of non-void function" */
|
|
|
|
return ATA_CBL_PATA80;
|
2006-10-03 08:14:12 +00:00
|
|
|
}
|
|
|
|
|
2010-01-19 09:44:41 +00:00
|
|
|
static void jmicron_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
|
2006-10-03 08:14:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
ide: move ide_config_drive_speed() calls to upper layers (take 2)
* Convert {ide_hwif_t,ide_pci_device_t}->host_flag to be u16.
* Add IDE_HFLAG_POST_SET_MODE host flag to indicate the need to program
the host for the transfer mode after programming the device. Set it
in au1xxx-ide, amd74xx, cs5530, cs5535, pdc202xx_new, sc1200, pmac
and via82cxxx host drivers.
* Add IDE_HFLAG_NO_SET_MODE host flag to indicate the need to completely
skip programming of host/device for the transfer mode ("smart" hosts).
Set it in it821x host driver and check it in ide_tune_dma().
* Add ide_set_pio_mode()/ide_set_dma_mode() helpers and convert all
direct ->set_pio_mode/->speedproc users to use these helpers.
* Move ide_config_drive_speed() calls from ->set_pio_mode/->speedproc
methods to callers.
* Rename ->speedproc method to ->set_dma_mode, make it void and update
all implementations accordingly.
* Update ide_set_xfer_rate() comments.
* Unexport ide_config_drive_speed().
v2:
* Fix issues noticed by Sergei:
- export ide_set_dma_mode() instead of moving ->set_pio_mode abuse wrt
to setting DMA modes from sc1200_set_pio_mode() to do_special()
- check IDE_HFLAG_NO_SET_MODE in ide_tune_dma()
- check for (hwif->set_pio_mode) == NULL in ide_set_pio_mode()
- check for (hwif->set_dma_mode) == NULL in ide_set_dma_mode()
- return -1 from ide_set_{pio,dma}_mode() if ->set_{pio,dma}_mode == NULL
- don't set ->set_{pio,dma}_mode on it821x in "smart" mode
- fix build problem in pmac.c
- minor fixes in au1xxx-ide.c/cs5530.c/siimage.c
- improve patch description
Changes in behavior caused by this patch:
- HDIO_SET_PIO_MODE ioctl would now return -ENOSYS for attempts to change
PIO mode if it821x controller is in "smart" mode
- removal of two debugging printk-s (from cs5530.c and sc1200.c)
- transfer modes 0x00-0x07 passed from user space may be programmed twice on
the device (not really an issue since 0x00 is not supported correctly by
any host driver ATM, 0x01 is not supported at all and 0x02-0x07 are invalid)
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2007-10-13 15:47:51 +00:00
|
|
|
* jmicron_set_dma_mode - set host controller for DMA mode
|
2010-01-19 09:45:29 +00:00
|
|
|
* @hwif: port
|
ide: move ide_config_drive_speed() calls to upper layers (take 2)
* Convert {ide_hwif_t,ide_pci_device_t}->host_flag to be u16.
* Add IDE_HFLAG_POST_SET_MODE host flag to indicate the need to program
the host for the transfer mode after programming the device. Set it
in au1xxx-ide, amd74xx, cs5530, cs5535, pdc202xx_new, sc1200, pmac
and via82cxxx host drivers.
* Add IDE_HFLAG_NO_SET_MODE host flag to indicate the need to completely
skip programming of host/device for the transfer mode ("smart" hosts).
Set it in it821x host driver and check it in ide_tune_dma().
* Add ide_set_pio_mode()/ide_set_dma_mode() helpers and convert all
direct ->set_pio_mode/->speedproc users to use these helpers.
* Move ide_config_drive_speed() calls from ->set_pio_mode/->speedproc
methods to callers.
* Rename ->speedproc method to ->set_dma_mode, make it void and update
all implementations accordingly.
* Update ide_set_xfer_rate() comments.
* Unexport ide_config_drive_speed().
v2:
* Fix issues noticed by Sergei:
- export ide_set_dma_mode() instead of moving ->set_pio_mode abuse wrt
to setting DMA modes from sc1200_set_pio_mode() to do_special()
- check IDE_HFLAG_NO_SET_MODE in ide_tune_dma()
- check for (hwif->set_pio_mode) == NULL in ide_set_pio_mode()
- check for (hwif->set_dma_mode) == NULL in ide_set_dma_mode()
- return -1 from ide_set_{pio,dma}_mode() if ->set_{pio,dma}_mode == NULL
- don't set ->set_{pio,dma}_mode on it821x in "smart" mode
- fix build problem in pmac.c
- minor fixes in au1xxx-ide.c/cs5530.c/siimage.c
- improve patch description
Changes in behavior caused by this patch:
- HDIO_SET_PIO_MODE ioctl would now return -ENOSYS for attempts to change
PIO mode if it821x controller is in "smart" mode
- removal of two debugging printk-s (from cs5530.c and sc1200.c)
- transfer modes 0x00-0x07 passed from user space may be programmed twice on
the device (not really an issue since 0x00 is not supported correctly by
any host driver ATM, 0x01 is not supported at all and 0x02-0x07 are invalid)
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2007-10-13 15:47:51 +00:00
|
|
|
* @drive: drive
|
2006-10-03 08:14:12 +00:00
|
|
|
*
|
ide: move ide_config_drive_speed() calls to upper layers (take 2)
* Convert {ide_hwif_t,ide_pci_device_t}->host_flag to be u16.
* Add IDE_HFLAG_POST_SET_MODE host flag to indicate the need to program
the host for the transfer mode after programming the device. Set it
in au1xxx-ide, amd74xx, cs5530, cs5535, pdc202xx_new, sc1200, pmac
and via82cxxx host drivers.
* Add IDE_HFLAG_NO_SET_MODE host flag to indicate the need to completely
skip programming of host/device for the transfer mode ("smart" hosts).
Set it in it821x host driver and check it in ide_tune_dma().
* Add ide_set_pio_mode()/ide_set_dma_mode() helpers and convert all
direct ->set_pio_mode/->speedproc users to use these helpers.
* Move ide_config_drive_speed() calls from ->set_pio_mode/->speedproc
methods to callers.
* Rename ->speedproc method to ->set_dma_mode, make it void and update
all implementations accordingly.
* Update ide_set_xfer_rate() comments.
* Unexport ide_config_drive_speed().
v2:
* Fix issues noticed by Sergei:
- export ide_set_dma_mode() instead of moving ->set_pio_mode abuse wrt
to setting DMA modes from sc1200_set_pio_mode() to do_special()
- check IDE_HFLAG_NO_SET_MODE in ide_tune_dma()
- check for (hwif->set_pio_mode) == NULL in ide_set_pio_mode()
- check for (hwif->set_dma_mode) == NULL in ide_set_dma_mode()
- return -1 from ide_set_{pio,dma}_mode() if ->set_{pio,dma}_mode == NULL
- don't set ->set_{pio,dma}_mode on it821x in "smart" mode
- fix build problem in pmac.c
- minor fixes in au1xxx-ide.c/cs5530.c/siimage.c
- improve patch description
Changes in behavior caused by this patch:
- HDIO_SET_PIO_MODE ioctl would now return -ENOSYS for attempts to change
PIO mode if it821x controller is in "smart" mode
- removal of two debugging printk-s (from cs5530.c and sc1200.c)
- transfer modes 0x00-0x07 passed from user space may be programmed twice on
the device (not really an issue since 0x00 is not supported correctly by
any host driver ATM, 0x01 is not supported at all and 0x02-0x07 are invalid)
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2007-10-13 15:47:51 +00:00
|
|
|
* As the JMicron snoops for timings we don't need to do anything here.
|
2006-10-03 08:14:12 +00:00
|
|
|
*/
|
|
|
|
|
2010-01-19 09:45:29 +00:00
|
|
|
static void jmicron_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
|
2006-10-03 08:14:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-26 20:25:14 +00:00
|
|
|
static const struct ide_port_ops jmicron_port_ops = {
|
|
|
|
.set_pio_mode = jmicron_set_pio_mode,
|
|
|
|
.set_dma_mode = jmicron_set_dma_mode,
|
|
|
|
.cable_detect = jmicron_cable_detect,
|
|
|
|
};
|
2006-10-03 08:14:12 +00:00
|
|
|
|
2012-12-21 21:21:03 +00:00
|
|
|
static const struct ide_port_info jmicron_chipset = {
|
2008-07-24 20:53:32 +00:00
|
|
|
.name = DRV_NAME,
|
2007-10-11 21:53:59 +00:00
|
|
|
.enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } },
|
2008-04-26 20:25:14 +00:00
|
|
|
.port_ops = &jmicron_port_ops,
|
2007-10-11 21:53:59 +00:00
|
|
|
.pio_mask = ATA_PIO5,
|
2007-10-18 22:30:07 +00:00
|
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
|
|
.udma_mask = ATA_UDMA6,
|
2006-10-03 08:14:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* jmicron_init_one - pci layer discovery entry
|
|
|
|
* @dev: PCI device
|
|
|
|
* @id: ident table entry
|
|
|
|
*
|
|
|
|
* Called by the PCI code when it finds a Jmicron controller.
|
|
|
|
* We then use the IDE PCI generic helper to do most of the work.
|
|
|
|
*/
|
|
|
|
|
2012-12-21 21:21:03 +00:00
|
|
|
static int jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
2006-10-03 08:14:12 +00:00
|
|
|
{
|
2008-07-24 20:53:14 +00:00
|
|
|
return ide_pci_init_one(dev, &jmicron_chipset, NULL);
|
2006-10-03 08:14:12 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 21:53:59 +00:00
|
|
|
/* All JMB PATA controllers have and will continue to have the same
|
|
|
|
* interface. Matching vendor and device class is enough for all
|
|
|
|
* current and future controllers if the controller is programmed
|
|
|
|
* properly.
|
|
|
|
*
|
|
|
|
* If libata is configured, jmicron PCI quirk programs the controller
|
|
|
|
* into the correct mode. If libata isn't configured, match known
|
|
|
|
* device IDs too to maintain backward compatibility.
|
2007-03-17 20:57:25 +00:00
|
|
|
*/
|
2006-10-03 08:14:12 +00:00
|
|
|
static struct pci_device_id jmicron_pci_tbl[] = {
|
2007-10-11 21:53:59 +00:00
|
|
|
#if !defined(CONFIG_ATA) && !defined(CONFIG_ATA_MODULE)
|
|
|
|
{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361) },
|
|
|
|
{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363) },
|
|
|
|
{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB365) },
|
|
|
|
{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB366) },
|
|
|
|
{ PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB368) },
|
|
|
|
#endif
|
|
|
|
{ PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
|
|
|
PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 },
|
2006-10-03 08:14:12 +00:00
|
|
|
{ 0, },
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, jmicron_pci_tbl);
|
|
|
|
|
2008-10-13 19:39:41 +00:00
|
|
|
static struct pci_driver jmicron_pci_driver = {
|
2006-10-03 08:14:12 +00:00
|
|
|
.name = "JMicron IDE",
|
|
|
|
.id_table = jmicron_pci_tbl,
|
|
|
|
.probe = jmicron_init_one,
|
2008-07-24 20:53:22 +00:00
|
|
|
.remove = ide_pci_remove,
|
2008-10-10 20:39:32 +00:00
|
|
|
.suspend = ide_pci_suspend,
|
|
|
|
.resume = ide_pci_resume,
|
2006-10-03 08:14:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init jmicron_ide_init(void)
|
|
|
|
{
|
2008-10-13 19:39:41 +00:00
|
|
|
return ide_pci_register_driver(&jmicron_pci_driver);
|
2006-10-03 08:14:12 +00:00
|
|
|
}
|
|
|
|
|
2008-07-24 20:53:22 +00:00
|
|
|
static void __exit jmicron_ide_exit(void)
|
|
|
|
{
|
2008-10-13 19:39:41 +00:00
|
|
|
pci_unregister_driver(&jmicron_pci_driver);
|
2008-07-24 20:53:22 +00:00
|
|
|
}
|
|
|
|
|
2006-10-03 08:14:12 +00:00
|
|
|
module_init(jmicron_ide_init);
|
2008-07-24 20:53:22 +00:00
|
|
|
module_exit(jmicron_ide_exit);
|
2006-10-03 08:14:12 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Alan Cox");
|
|
|
|
MODULE_DESCRIPTION("PCI driver module for the JMicron in legacy modes");
|
|
|
|
MODULE_LICENSE("GPL");
|