2005-04-17 00:20:36 +02:00
|
|
|
/*
|
2006-02-02 09:00:46 +01:00
|
|
|
* Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it would be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public
|
|
|
|
* License along with this program; if not, write the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* For further information regarding this notice, see:
|
|
|
|
*
|
|
|
|
* http://oss.sgi.com/projects/GenInfo/NoticeExplan
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/hdreg.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/blkdev.h>
|
2007-07-25 08:13:56 +02:00
|
|
|
#include <linux/scatterlist.h>
|
[PATCH] ioc4: Core driver rewrite
This series of patches reworks the configuration and internal structure
of the SGI IOC4 I/O controller device drivers.
These changes are motivated by several factors:
- The IOC4 chip PCI resources are of mixed use between functions (i.e.
multiple functions are handled in the same address range, sometimes
within the same register), muddling resource ownership and initialization
issues. Centralizing this ownership in a core driver is desirable.
- The IOC4 chip implements multiple functions (serial, IDE, others not
yet implemented in the mainline kernel) but is not a multifunction
PCI device. In order to properly handle device addition and removal
as well as module insertion and deletion, an intermediary IOC4-specific
driver layer is needed to handle these operations cleanly.
- All IOC4 drivers are currently enabled by a single CONFIG value. As
not all systems need all IOC4 functions, it is desireable to enable
these drivers independently.
- The current IOC4 core driver will trigger loading of all function-level
drivers, as it makes direct calls to them. This situation should be
reversed (i.e. function-level drivers cause loading of core driver)
in order to maintain a clear and least-surprise driver loading model.
- IOC4 hardware design necessitates some driver-level dependency on
the PCI bus clock speed. Current code assumes a 66MHz bus, but the
speed should be autodetected and appropriate compensation taken.
This patch series effects the above changes by a newly and better designed
IOC4 core driver with which the function-level drivers can register and
deregister themselves upon module insertion/removal. By tracking these
modules, device addition/removal is also handled properly. PCI resource
management and ownership issues are centralized in this core driver, and
IOC4-wide configuration actions such as bus speed detection are also
handled in this core driver.
This patch:
The SGI IOC4 I/O controller chip implements multiple functions, though it is
not a multi-function PCI device. Additionally, various PCI resources of the
IOC4 are shared by multiple hardware functions, and thus resource ownership by
driver is not clearly delineated. Due to the current driver design, all core
and subordinate drivers must be loaded, or none, which is undesirable if not
all IOC4 hardware features are being used.
This patch reorganizes the IOC4 drivers so that the core driver provides a
subdriver registration service. Through appropriate callbacks the subdrivers
can now handle device addition and removal, as well as module insertion and
deletion (though the IOC4 IDE driver requires further work before module
deletion will work). The core driver now takes care of allocating PCI
resources and data which must be shared between subdrivers, to clearly
delineate module ownership of these items.
Signed-off-by: Brent Casavant <bcasavan@sgi.com>
Acked-by: Pat Gefre <pfg@sgi.com
Acked-by: Jeremy Higdon <jeremy@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-22 02:15:59 +02:00
|
|
|
#include <linux/ioc4.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include <linux/ide.h>
|
|
|
|
|
2007-10-11 23:54:00 +02:00
|
|
|
#define DRV_NAME "SGIIOC4"
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* IOC4 Specific Definitions */
|
|
|
|
#define IOC4_CMD_OFFSET 0x100
|
|
|
|
#define IOC4_CTRL_OFFSET 0x120
|
|
|
|
#define IOC4_DMA_OFFSET 0x140
|
|
|
|
#define IOC4_INTR_OFFSET 0x0
|
|
|
|
|
|
|
|
#define IOC4_TIMING 0x00
|
|
|
|
#define IOC4_DMA_PTR_L 0x01
|
|
|
|
#define IOC4_DMA_PTR_H 0x02
|
|
|
|
#define IOC4_DMA_ADDR_L 0x03
|
|
|
|
#define IOC4_DMA_ADDR_H 0x04
|
|
|
|
#define IOC4_BC_DEV 0x05
|
|
|
|
#define IOC4_BC_MEM 0x06
|
|
|
|
#define IOC4_DMA_CTRL 0x07
|
|
|
|
#define IOC4_DMA_END_ADDR 0x08
|
|
|
|
|
|
|
|
/* Bits in the IOC4 Control/Status Register */
|
|
|
|
#define IOC4_S_DMA_START 0x01
|
|
|
|
#define IOC4_S_DMA_STOP 0x02
|
|
|
|
#define IOC4_S_DMA_DIR 0x04
|
|
|
|
#define IOC4_S_DMA_ACTIVE 0x08
|
|
|
|
#define IOC4_S_DMA_ERROR 0x10
|
|
|
|
#define IOC4_ATA_MEMERR 0x02
|
|
|
|
|
|
|
|
/* Read/Write Directions */
|
|
|
|
#define IOC4_DMA_WRITE 0x04
|
|
|
|
#define IOC4_DMA_READ 0x00
|
|
|
|
|
|
|
|
/* Interrupt Register Offsets */
|
|
|
|
#define IOC4_INTR_REG 0x03
|
|
|
|
#define IOC4_INTR_SET 0x05
|
|
|
|
#define IOC4_INTR_CLEAR 0x07
|
|
|
|
|
|
|
|
#define IOC4_IDE_CACHELINE_SIZE 128
|
|
|
|
#define IOC4_CMD_CTL_BLK_SIZE 0x20
|
|
|
|
#define IOC4_SUPPORTED_FIRMWARE_REV 46
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
u32 timing_reg0;
|
|
|
|
u32 timing_reg1;
|
|
|
|
u32 low_mem_ptr;
|
|
|
|
u32 high_mem_ptr;
|
|
|
|
u32 low_mem_addr;
|
|
|
|
u32 high_mem_addr;
|
|
|
|
u32 dev_byte_count;
|
|
|
|
u32 mem_byte_count;
|
|
|
|
u32 status;
|
|
|
|
} ioc4_dma_regs_t;
|
|
|
|
|
|
|
|
/* Each Physical Region Descriptor Entry size is 16 bytes (2 * 64 bits) */
|
|
|
|
/* IOC4 has only 1 IDE channel */
|
|
|
|
#define IOC4_PRD_BYTES 16
|
|
|
|
#define IOC4_PRD_ENTRIES (PAGE_SIZE /(4*IOC4_PRD_BYTES))
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port,
|
|
|
|
unsigned long ctrl_port, unsigned long irq_port)
|
|
|
|
{
|
|
|
|
unsigned long reg = data_port;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Registers are word (32 bit) aligned */
|
|
|
|
for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
|
|
|
|
hw->io_ports[i] = reg + i * 4;
|
|
|
|
|
|
|
|
if (ctrl_port)
|
|
|
|
hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
|
|
|
|
|
|
|
|
if (irq_port)
|
|
|
|
hw->io_ports[IDE_IRQ_OFFSET] = irq_port;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sgiioc4_maskproc(ide_drive_t * drive, int mask)
|
|
|
|
{
|
2007-02-17 02:40:25 +01:00
|
|
|
writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2),
|
|
|
|
(void __iomem *)IDE_CONTROL_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
sgiioc4_checkirq(ide_hwif_t * hwif)
|
|
|
|
{
|
2007-02-17 02:40:25 +01:00
|
|
|
unsigned long intr_addr =
|
|
|
|
hwif->io_ports[IDE_IRQ_OFFSET] + IOC4_INTR_REG * 4;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
if ((u8)readl((void __iomem *)intr_addr) & 0x03)
|
2005-04-17 00:20:36 +02:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
static u8 sgiioc4_INB(unsigned long);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
static int
|
|
|
|
sgiioc4_clearirq(ide_drive_t * drive)
|
|
|
|
{
|
|
|
|
u32 intr_reg;
|
|
|
|
ide_hwif_t *hwif = HWIF(drive);
|
|
|
|
unsigned long other_ir =
|
|
|
|
hwif->io_ports[IDE_IRQ_OFFSET] + (IOC4_INTR_REG << 2);
|
|
|
|
|
|
|
|
/* Code to check for PCI error conditions */
|
2007-02-17 02:40:25 +01:00
|
|
|
intr_reg = readl((void __iomem *)other_ir);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (intr_reg & 0x03) { /* Valid IOC4-IDE interrupt */
|
|
|
|
/*
|
2007-02-17 02:40:25 +01:00
|
|
|
* Using sgiioc4_INB to read the IDE_STATUS_REG has a side effect
|
2005-04-17 00:20:36 +02:00
|
|
|
* of clearing the interrupt. The first read should clear it
|
|
|
|
* if it is set. The second read should return a "clear" status
|
|
|
|
* if it got cleared. If not, then spin for a bit trying to
|
|
|
|
* clear it.
|
|
|
|
*/
|
2007-02-17 02:40:25 +01:00
|
|
|
u8 stat = sgiioc4_INB(IDE_STATUS_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
int count = 0;
|
2007-02-17 02:40:25 +01:00
|
|
|
stat = sgiioc4_INB(IDE_STATUS_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
while ((stat & 0x80) && (count++ < 100)) {
|
|
|
|
udelay(1);
|
2007-02-17 02:40:25 +01:00
|
|
|
stat = sgiioc4_INB(IDE_STATUS_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (intr_reg & 0x02) {
|
|
|
|
/* Error when transferring DMA data on PCI bus */
|
|
|
|
u32 pci_err_addr_low, pci_err_addr_high,
|
|
|
|
pci_stat_cmd_reg;
|
|
|
|
|
|
|
|
pci_err_addr_low =
|
2007-02-17 02:40:25 +01:00
|
|
|
readl((void __iomem *)hwif->io_ports[IDE_IRQ_OFFSET]);
|
2005-04-17 00:20:36 +02:00
|
|
|
pci_err_addr_high =
|
2007-02-17 02:40:25 +01:00
|
|
|
readl((void __iomem *)(hwif->io_ports[IDE_IRQ_OFFSET] + 4));
|
2005-04-17 00:20:36 +02:00
|
|
|
pci_read_config_dword(hwif->pci_dev, PCI_COMMAND,
|
|
|
|
&pci_stat_cmd_reg);
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s(%s) : PCI Bus Error when doing DMA:"
|
|
|
|
" status-cmd reg is 0x%x\n",
|
|
|
|
__FUNCTION__, drive->name, pci_stat_cmd_reg);
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s(%s) : PCI Error Address is 0x%x%x\n",
|
|
|
|
__FUNCTION__, drive->name,
|
|
|
|
pci_err_addr_high, pci_err_addr_low);
|
|
|
|
/* Clear the PCI Error indicator */
|
|
|
|
pci_write_config_dword(hwif->pci_dev, PCI_COMMAND,
|
|
|
|
0x00000146);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the Interrupt, Error bits on the IOC4 */
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(0x03, (void __iomem *)other_ir);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
intr_reg = readl((void __iomem *)other_ir);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return intr_reg & 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sgiioc4_ide_dma_start(ide_drive_t * drive)
|
|
|
|
{
|
|
|
|
ide_hwif_t *hwif = HWIF(drive);
|
2007-02-17 02:40:25 +01:00
|
|
|
unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4;
|
|
|
|
unsigned int reg = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned int temp_reg = reg | IOC4_S_DMA_START;
|
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(temp_reg, (void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static u32
|
|
|
|
sgiioc4_ide_dma_stop(ide_hwif_t *hwif, u64 dma_base)
|
|
|
|
{
|
2007-02-17 02:40:25 +01:00
|
|
|
unsigned long ioc4_dma_addr = dma_base + IOC4_DMA_CTRL * 4;
|
2005-04-17 00:20:36 +02:00
|
|
|
u32 ioc4_dma;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
count = 0;
|
2007-02-17 02:40:25 +01:00
|
|
|
ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
while ((ioc4_dma & IOC4_S_DMA_STOP) && (count++ < 200)) {
|
|
|
|
udelay(1);
|
2007-02-17 02:40:25 +01:00
|
|
|
ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
return ioc4_dma;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stops the IOC4 DMA Engine */
|
|
|
|
static int
|
|
|
|
sgiioc4_ide_dma_end(ide_drive_t * drive)
|
|
|
|
{
|
|
|
|
u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0;
|
|
|
|
ide_hwif_t *hwif = HWIF(drive);
|
2007-02-17 02:40:25 +01:00
|
|
|
unsigned long dma_base = hwif->dma_base;
|
2005-04-17 00:20:36 +02:00
|
|
|
int dma_stat = 0;
|
2006-10-03 10:14:25 +02:00
|
|
|
unsigned long *ending_dma = ide_get_hwifdata(hwif);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(IOC4_S_DMA_STOP, (void __iomem *)(dma_base + IOC4_DMA_CTRL * 4));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base);
|
|
|
|
|
|
|
|
if (ioc4_dma & IOC4_S_DMA_STOP) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s(%s): IOC4 DMA STOP bit is still 1 :"
|
|
|
|
"ioc4_dma_reg 0x%x\n",
|
|
|
|
__FUNCTION__, drive->name, ioc4_dma);
|
|
|
|
dma_stat = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The IOC4 will DMA 1's to the ending dma area to indicate that
|
|
|
|
* previous data DMA is complete. This is necessary because of relaxed
|
|
|
|
* ordering between register reads and DMA writes on the Altix.
|
|
|
|
*/
|
|
|
|
while ((cnt++ < 200) && (!valid)) {
|
|
|
|
for (num = 0; num < 16; num++) {
|
|
|
|
if (ending_dma[num]) {
|
|
|
|
valid = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
udelay(1);
|
|
|
|
}
|
|
|
|
if (!valid) {
|
|
|
|
printk(KERN_ERR "%s(%s) : DMA incomplete\n", __FUNCTION__,
|
|
|
|
drive->name);
|
|
|
|
dma_stat = 1;
|
|
|
|
}
|
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
bc_dev = readl((void __iomem *)(dma_base + IOC4_BC_DEV * 4));
|
|
|
|
bc_mem = readl((void __iomem *)(dma_base + IOC4_BC_MEM * 4));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if ((bc_dev & 0x01FF) || (bc_mem & 0x1FF)) {
|
|
|
|
if (bc_dev > bc_mem + 8) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s(%s): WARNING!! byte_count_dev %d "
|
|
|
|
"!= byte_count_mem %d\n",
|
|
|
|
__FUNCTION__, drive->name, bc_dev, bc_mem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drive->waiting_for_dma = 0;
|
|
|
|
ide_destroy_dmatable(drive);
|
|
|
|
|
|
|
|
return dma_stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sgiioc4_ide_dma_on(ide_drive_t * drive)
|
|
|
|
{
|
|
|
|
drive->using_dma = 1;
|
|
|
|
|
2007-02-17 02:40:26 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2007-02-17 02:40:26 +01:00
|
|
|
static void sgiioc4_dma_off_quietly(ide_drive_t *drive)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
drive->using_dma = 0;
|
|
|
|
|
2007-02-17 02:40:26 +01:00
|
|
|
drive->hwif->dma_host_off(drive);
|
2005-04-17 00:20:36 +02: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 17:47:51 +02:00
|
|
|
static void sgiioc4_set_dma_mode(ide_drive_t *drive, const u8 speed)
|
2007-10-11 23:54:00 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* returns 1 if dma irq issued, 0 otherwise */
|
|
|
|
static int
|
|
|
|
sgiioc4_ide_dma_test_irq(ide_drive_t * drive)
|
|
|
|
{
|
|
|
|
return sgiioc4_checkirq(HWIF(drive));
|
|
|
|
}
|
|
|
|
|
2007-02-17 02:40:26 +01:00
|
|
|
static void sgiioc4_dma_host_on(ide_drive_t * drive)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-02-17 02:40:26 +01:00
|
|
|
static void sgiioc4_dma_host_off(ide_drive_t * drive)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
sgiioc4_clearirq(drive);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sgiioc4_resetproc(ide_drive_t * drive)
|
|
|
|
{
|
|
|
|
sgiioc4_ide_dma_end(drive);
|
|
|
|
sgiioc4_clearirq(drive);
|
|
|
|
}
|
|
|
|
|
2007-07-09 23:17:54 +02:00
|
|
|
static void
|
|
|
|
sgiioc4_dma_lost_irq(ide_drive_t * drive)
|
|
|
|
{
|
|
|
|
sgiioc4_resetproc(drive);
|
|
|
|
|
|
|
|
ide_dma_lost_irq(drive);
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
static u8
|
|
|
|
sgiioc4_INB(unsigned long port)
|
|
|
|
{
|
2006-05-31 06:27:07 +02:00
|
|
|
u8 reg = (u8) readb((void __iomem *) port);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */
|
|
|
|
if (reg & 0x51) { /* Not busy...check for interrupt */
|
|
|
|
unsigned long other_ir = port - 0x110;
|
2006-05-31 06:27:07 +02:00
|
|
|
unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Clear the Interrupt, Error bits on the IOC4 */
|
|
|
|
if (intr_reg & 0x03) {
|
2006-05-31 06:27:07 +02:00
|
|
|
writel(0x03, (void __iomem *) other_ir);
|
|
|
|
intr_reg = (u32) readl((void __iomem *) other_ir);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Creates a dma map for the scatter-gather list entries */
|
2007-10-11 23:54:00 +02:00
|
|
|
static int __devinit
|
2005-04-17 00:20:36 +02:00
|
|
|
ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
|
|
|
|
{
|
2006-09-01 06:27:51 +02:00
|
|
|
void __iomem *virt_dma_base;
|
2005-04-17 00:20:36 +02:00
|
|
|
int num_ports = sizeof (ioc4_dma_regs_t);
|
2006-10-03 10:14:25 +02:00
|
|
|
void *pad;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name,
|
|
|
|
dma_base, dma_base + num_ports - 1);
|
|
|
|
|
2006-09-01 06:27:51 +02:00
|
|
|
if (!request_mem_region(dma_base, num_ports, hwif->name)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
printk(KERN_ERR
|
|
|
|
"%s(%s) -- ERROR, Addresses 0x%p to 0x%p "
|
|
|
|
"ALREADY in use\n",
|
|
|
|
__FUNCTION__, hwif->name, (void *) dma_base,
|
|
|
|
(void *) dma_base + num_ports - 1);
|
2007-10-11 23:54:00 +02:00
|
|
|
return -1;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-09-01 06:27:51 +02:00
|
|
|
virt_dma_base = ioremap(dma_base, num_ports);
|
|
|
|
if (virt_dma_base == NULL) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n",
|
|
|
|
__FUNCTION__, hwif->name, dma_base, dma_base + num_ports - 1);
|
|
|
|
goto dma_remap_failure;
|
|
|
|
}
|
|
|
|
hwif->dma_base = (unsigned long) virt_dma_base;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
|
|
|
|
IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
|
|
|
|
&hwif->dmatable_dma);
|
|
|
|
|
|
|
|
if (!hwif->dmatable_cpu)
|
2006-09-01 06:27:51 +02:00
|
|
|
goto dma_pci_alloc_failure;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
hwif->sg_max_nents = IOC4_PRD_ENTRIES;
|
|
|
|
|
2006-10-03 10:14:25 +02:00
|
|
|
pad = pci_alloc_consistent(hwif->pci_dev, IOC4_IDE_CACHELINE_SIZE,
|
|
|
|
(dma_addr_t *) &(hwif->dma_status));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-10-03 10:14:25 +02:00
|
|
|
if (pad) {
|
|
|
|
ide_set_hwifdata(hwif, pad);
|
2007-10-11 23:54:00 +02:00
|
|
|
return 0;
|
2006-10-03 10:14:25 +02:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
pci_free_consistent(hwif->pci_dev,
|
|
|
|
IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
|
|
|
|
hwif->dmatable_cpu, hwif->dmatable_dma);
|
|
|
|
printk(KERN_INFO
|
|
|
|
"%s() -- Error! Unable to allocate DMA Maps for drive %s\n",
|
|
|
|
__FUNCTION__, hwif->name);
|
|
|
|
printk(KERN_INFO
|
|
|
|
"Changing from DMA to PIO mode for Drive %s\n", hwif->name);
|
|
|
|
|
2006-09-01 06:27:51 +02:00
|
|
|
dma_pci_alloc_failure:
|
|
|
|
iounmap(virt_dma_base);
|
|
|
|
|
|
|
|
dma_remap_failure:
|
|
|
|
release_mem_region(dma_base, num_ports);
|
|
|
|
|
2007-10-11 23:54:00 +02:00
|
|
|
return -1;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initializes the IOC4 DMA Engine */
|
|
|
|
static void
|
|
|
|
sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive)
|
|
|
|
{
|
|
|
|
u32 ioc4_dma;
|
|
|
|
ide_hwif_t *hwif = HWIF(drive);
|
2007-02-17 02:40:25 +01:00
|
|
|
unsigned long dma_base = hwif->dma_base;
|
|
|
|
unsigned long ioc4_dma_addr = dma_base + IOC4_DMA_CTRL * 4;
|
2005-04-17 00:20:36 +02:00
|
|
|
u32 dma_addr, ending_dma_addr;
|
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (ioc4_dma & IOC4_S_DMA_ACTIVE) {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"%s(%s):Warning!! DMA from previous transfer was still active\n",
|
|
|
|
__FUNCTION__, drive->name);
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base);
|
|
|
|
|
|
|
|
if (ioc4_dma & IOC4_S_DMA_STOP)
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s(%s) : IOC4 Dma STOP bit is still 1\n",
|
|
|
|
__FUNCTION__, drive->name);
|
|
|
|
}
|
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (ioc4_dma & IOC4_S_DMA_ERROR) {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"%s(%s) : Warning!! - DMA Error during Previous"
|
|
|
|
" transfer | status 0x%x\n",
|
|
|
|
__FUNCTION__, drive->name, ioc4_dma);
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base);
|
|
|
|
|
|
|
|
if (ioc4_dma & IOC4_S_DMA_STOP)
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s(%s) : IOC4 DMA STOP bit is still 1\n",
|
|
|
|
__FUNCTION__, drive->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Address of the Scatter Gather List */
|
|
|
|
dma_addr = cpu_to_le32(hwif->dmatable_dma);
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(dma_addr, (void __iomem *)(dma_base + IOC4_DMA_PTR_L * 4));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Address of the Ending DMA */
|
2006-10-03 10:14:25 +02:00
|
|
|
memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE);
|
2005-04-17 00:20:36 +02:00
|
|
|
ending_dma_addr = cpu_to_le32(hwif->dma_status);
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(ending_dma_addr, (void __iomem *)(dma_base + IOC4_DMA_END_ADDR * 4));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(dma_direction, (void __iomem *)ioc4_dma_addr);
|
2005-04-17 00:20:36 +02:00
|
|
|
drive->waiting_for_dma = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IOC4 Scatter Gather list Format */
|
|
|
|
/* 128 Bit entries to support 64 bit addresses in the future */
|
|
|
|
/* The Scatter Gather list Entry should be in the BIG-ENDIAN Format */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* | Upper 32 bits - Zero | Lower 32 bits- address | */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* | Upper 32 bits - Zero |EOL| 15 unused | 16 Bit Length| */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* Creates the scatter gather list, DMA Table */
|
|
|
|
static unsigned int
|
|
|
|
sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
|
|
|
|
{
|
|
|
|
ide_hwif_t *hwif = HWIF(drive);
|
|
|
|
unsigned int *table = hwif->dmatable_cpu;
|
|
|
|
unsigned int count = 0, i = 1;
|
|
|
|
struct scatterlist *sg;
|
|
|
|
|
|
|
|
hwif->sg_nents = i = ide_build_sglist(drive, rq);
|
|
|
|
|
|
|
|
if (!i)
|
|
|
|
return 0; /* sglist of length Zero */
|
|
|
|
|
|
|
|
sg = hwif->sg_table;
|
|
|
|
while (i && sg_dma_len(sg)) {
|
|
|
|
dma_addr_t cur_addr;
|
|
|
|
int cur_len;
|
|
|
|
cur_addr = sg_dma_address(sg);
|
|
|
|
cur_len = sg_dma_len(sg);
|
|
|
|
|
|
|
|
while (cur_len) {
|
|
|
|
if (count++ >= IOC4_PRD_ENTRIES) {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"%s: DMA table too small\n",
|
|
|
|
drive->name);
|
|
|
|
goto use_pio_instead;
|
|
|
|
} else {
|
2006-02-02 09:00:46 +01:00
|
|
|
u32 bcount =
|
2005-04-17 00:20:36 +02:00
|
|
|
0x10000 - (cur_addr & 0xffff);
|
|
|
|
|
|
|
|
if (bcount > cur_len)
|
|
|
|
bcount = cur_len;
|
|
|
|
|
|
|
|
/* put the addr, length in
|
|
|
|
* the IOC4 dma-table format */
|
|
|
|
*table = 0x0;
|
|
|
|
table++;
|
|
|
|
*table = cpu_to_be32(cur_addr);
|
|
|
|
table++;
|
|
|
|
*table = 0x0;
|
|
|
|
table++;
|
|
|
|
|
2006-02-02 09:00:46 +01:00
|
|
|
*table = cpu_to_be32(bcount);
|
2005-04-17 00:20:36 +02:00
|
|
|
table++;
|
|
|
|
|
|
|
|
cur_addr += bcount;
|
|
|
|
cur_len -= bcount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-25 08:13:56 +02:00
|
|
|
sg = sg_next(sg);
|
2005-04-17 00:20:36 +02:00
|
|
|
i--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count) {
|
|
|
|
table--;
|
|
|
|
*table |= cpu_to_be32(0x80000000);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
use_pio_instead:
|
|
|
|
pci_unmap_sg(hwif->pci_dev, hwif->sg_table, hwif->sg_nents,
|
|
|
|
hwif->sg_dma_direction);
|
|
|
|
|
|
|
|
return 0; /* revert to PIO for this request */
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sgiioc4_ide_dma_setup(ide_drive_t *drive)
|
|
|
|
{
|
|
|
|
struct request *rq = HWGROUP(drive)->rq;
|
|
|
|
unsigned int count = 0;
|
|
|
|
int ddir;
|
|
|
|
|
|
|
|
if (rq_data_dir(rq))
|
|
|
|
ddir = PCI_DMA_TODEVICE;
|
|
|
|
else
|
|
|
|
ddir = PCI_DMA_FROMDEVICE;
|
|
|
|
|
|
|
|
if (!(count = sgiioc4_build_dma_table(drive, rq, ddir))) {
|
|
|
|
/* try PIO instead of DMA */
|
|
|
|
ide_map_sg(drive, rq);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rq_data_dir(rq))
|
|
|
|
/* Writes TO the IOC4 FROM Main Memory */
|
|
|
|
ddir = IOC4_DMA_READ;
|
|
|
|
else
|
|
|
|
/* Writes FROM the IOC4 TO Main Memory */
|
|
|
|
ddir = IOC4_DMA_WRITE;
|
|
|
|
|
|
|
|
sgiioc4_configure_for_dma(ddir, drive);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __devinit
|
|
|
|
ide_init_sgiioc4(ide_hwif_t * hwif)
|
|
|
|
{
|
2007-02-17 02:40:25 +01:00
|
|
|
hwif->mmio = 1;
|
2007-07-20 01:11:59 +02:00
|
|
|
hwif->pio_mask = 0x00;
|
2007-10-11 23:54:00 +02:00
|
|
|
hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */
|
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 17:47:51 +02:00
|
|
|
hwif->set_dma_mode = &sgiioc4_set_dma_mode;
|
2005-04-17 00:20:36 +02:00
|
|
|
hwif->selectproc = NULL;/* Use the default routine to select drive */
|
|
|
|
hwif->reset_poll = NULL;/* No HBA specific reset_poll needed */
|
|
|
|
hwif->pre_reset = NULL; /* No HBA specific pre_set needed */
|
|
|
|
hwif->resetproc = &sgiioc4_resetproc;/* Reset DMA engine,
|
|
|
|
clear interrupts */
|
|
|
|
hwif->intrproc = NULL; /* Enable or Disable interrupt from drive */
|
|
|
|
hwif->maskproc = &sgiioc4_maskproc; /* Mask on/off NIEN register */
|
|
|
|
hwif->quirkproc = NULL;
|
|
|
|
hwif->busproc = NULL;
|
|
|
|
|
2007-10-13 17:47:52 +02:00
|
|
|
hwif->INB = &sgiioc4_INB;
|
|
|
|
|
|
|
|
if (hwif->dma_base == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hwif->atapi_dma = 1;
|
|
|
|
hwif->mwdma_mask = 0x04;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
hwif->dma_setup = &sgiioc4_ide_dma_setup;
|
|
|
|
hwif->dma_start = &sgiioc4_ide_dma_start;
|
|
|
|
hwif->ide_dma_end = &sgiioc4_ide_dma_end;
|
|
|
|
hwif->ide_dma_on = &sgiioc4_ide_dma_on;
|
2007-02-17 02:40:26 +01:00
|
|
|
hwif->dma_off_quietly = &sgiioc4_dma_off_quietly;
|
2005-04-17 00:20:36 +02:00
|
|
|
hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq;
|
2007-02-17 02:40:26 +01:00
|
|
|
hwif->dma_host_on = &sgiioc4_dma_host_on;
|
2007-02-17 02:40:26 +01:00
|
|
|
hwif->dma_host_off = &sgiioc4_dma_host_off;
|
2007-07-09 23:17:54 +02:00
|
|
|
hwif->dma_lost_irq = &sgiioc4_dma_lost_irq;
|
2007-07-09 23:17:54 +02:00
|
|
|
hwif->dma_timeout = &ide_dma_timeout;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit
|
2007-10-11 23:54:00 +02:00
|
|
|
sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-09-01 06:27:51 +02:00
|
|
|
unsigned long cmd_base, dma_base, irqport;
|
|
|
|
unsigned long bar0, cmd_phys_base, ctl;
|
|
|
|
void __iomem *virt_base;
|
2005-04-17 00:20:36 +02:00
|
|
|
ide_hwif_t *hwif;
|
|
|
|
int h;
|
|
|
|
|
2005-12-15 02:10:35 +01:00
|
|
|
/*
|
|
|
|
* Find an empty HWIF; if none available, return -ENOMEM.
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
for (h = 0; h < MAX_HWIFS; ++h) {
|
|
|
|
hwif = &ide_hwifs[h];
|
|
|
|
if (hwif->chipset == ide_unknown)
|
|
|
|
break;
|
|
|
|
}
|
2005-12-15 02:10:35 +01:00
|
|
|
if (h == MAX_HWIFS) {
|
2007-10-11 23:54:00 +02:00
|
|
|
printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n",
|
|
|
|
DRV_NAME);
|
2005-12-15 02:10:35 +01:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Get the CmdBlk and CtrlBlk Base Registers */
|
2006-09-01 06:27:51 +02:00
|
|
|
bar0 = pci_resource_start(dev, 0);
|
|
|
|
virt_base = ioremap(bar0, pci_resource_len(dev, 0));
|
|
|
|
if (virt_base == NULL) {
|
|
|
|
printk(KERN_ERR "%s: Unable to remap BAR 0 address: 0x%lx\n",
|
2007-10-11 23:54:00 +02:00
|
|
|
DRV_NAME, bar0);
|
2006-09-01 06:27:51 +02:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
cmd_base = (unsigned long) virt_base + IOC4_CMD_OFFSET;
|
|
|
|
ctl = (unsigned long) virt_base + IOC4_CTRL_OFFSET;
|
|
|
|
irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET;
|
2005-04-17 00:20:36 +02:00
|
|
|
dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET;
|
|
|
|
|
2006-09-01 06:27:51 +02:00
|
|
|
cmd_phys_base = bar0 + IOC4_CMD_OFFSET;
|
|
|
|
if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE,
|
|
|
|
hwif->name)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
printk(KERN_ERR
|
2006-09-01 06:27:51 +02:00
|
|
|
"%s : %s -- ERROR, Addresses "
|
2005-04-17 00:20:36 +02:00
|
|
|
"0x%p to 0x%p ALREADY in use\n",
|
2006-09-01 06:27:51 +02:00
|
|
|
__FUNCTION__, hwif->name, (void *) cmd_phys_base,
|
|
|
|
(void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
|
2005-04-17 00:20:36 +02:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2006-09-01 06:27:51 +02:00
|
|
|
if (hwif->io_ports[IDE_DATA_OFFSET] != cmd_base) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Initialize the IO registers */
|
2006-09-01 06:27:51 +02:00
|
|
|
sgiioc4_init_hwif_ports(&hwif->hw, cmd_base, ctl, irqport);
|
2005-04-17 00:20:36 +02:00
|
|
|
memcpy(hwif->io_ports, hwif->hw.io_ports,
|
|
|
|
sizeof (hwif->io_ports));
|
|
|
|
hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET];
|
|
|
|
}
|
|
|
|
|
|
|
|
hwif->irq = dev->irq;
|
|
|
|
hwif->chipset = ide_pci;
|
|
|
|
hwif->pci_dev = dev;
|
|
|
|
hwif->channel = 0; /* Single Channel chip */
|
|
|
|
hwif->gendev.parent = &dev->dev;/* setup proper ancestral information */
|
|
|
|
|
2006-09-01 06:27:51 +02:00
|
|
|
/* The IOC4 uses MMIO rather than Port IO. */
|
|
|
|
default_hwif_mmiops(hwif);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Initializing chipset IRQ Registers */
|
2007-02-17 02:40:25 +01:00
|
|
|
writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-10-11 23:54:00 +02:00
|
|
|
hwif->autodma = 0;
|
|
|
|
|
|
|
|
if (dma_base && ide_dma_sgiioc4(hwif, dma_base) == 0) {
|
|
|
|
hwif->autodma = 1;
|
|
|
|
hwif->drives[1].autodma = hwif->drives[0].autodma = 1;
|
|
|
|
} else
|
2005-04-17 00:20:36 +02:00
|
|
|
printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n",
|
2007-10-11 23:54:00 +02:00
|
|
|
hwif->name, DRV_NAME);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-10-13 17:47:52 +02:00
|
|
|
ide_init_sgiioc4(hwif);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (probe_hwif_init(hwif))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
/* Create /proc/ide entries */
|
2007-05-10 00:01:11 +02:00
|
|
|
ide_proc_register_port(hwif);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int __devinit
|
2007-10-11 23:54:00 +02:00
|
|
|
pci_init_sgiioc4(struct pci_dev *dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned int class_rev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
|
|
|
|
class_rev &= 0xff;
|
|
|
|
printk(KERN_INFO "%s: IDE controller at PCI slot %s, revision %d\n",
|
2007-10-11 23:54:00 +02:00
|
|
|
DRV_NAME, pci_name(dev), class_rev);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (class_rev < IOC4_SUPPORTED_FIRMWARE_REV) {
|
|
|
|
printk(KERN_ERR "Skipping %s IDE controller in slot %s: "
|
2007-10-11 23:54:00 +02:00
|
|
|
"firmware is obsolete - please upgrade to "
|
|
|
|
"revision46 or higher\n",
|
|
|
|
DRV_NAME, pci_name(dev));
|
2005-04-17 00:20:36 +02:00
|
|
|
ret = -EAGAIN;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-10-11 23:54:00 +02:00
|
|
|
ret = sgiioc4_ide_setup_pci_device(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
[PATCH] ioc4: Core driver rewrite
This series of patches reworks the configuration and internal structure
of the SGI IOC4 I/O controller device drivers.
These changes are motivated by several factors:
- The IOC4 chip PCI resources are of mixed use between functions (i.e.
multiple functions are handled in the same address range, sometimes
within the same register), muddling resource ownership and initialization
issues. Centralizing this ownership in a core driver is desirable.
- The IOC4 chip implements multiple functions (serial, IDE, others not
yet implemented in the mainline kernel) but is not a multifunction
PCI device. In order to properly handle device addition and removal
as well as module insertion and deletion, an intermediary IOC4-specific
driver layer is needed to handle these operations cleanly.
- All IOC4 drivers are currently enabled by a single CONFIG value. As
not all systems need all IOC4 functions, it is desireable to enable
these drivers independently.
- The current IOC4 core driver will trigger loading of all function-level
drivers, as it makes direct calls to them. This situation should be
reversed (i.e. function-level drivers cause loading of core driver)
in order to maintain a clear and least-surprise driver loading model.
- IOC4 hardware design necessitates some driver-level dependency on
the PCI bus clock speed. Current code assumes a 66MHz bus, but the
speed should be autodetected and appropriate compensation taken.
This patch series effects the above changes by a newly and better designed
IOC4 core driver with which the function-level drivers can register and
deregister themselves upon module insertion/removal. By tracking these
modules, device addition/removal is also handled properly. PCI resource
management and ownership issues are centralized in this core driver, and
IOC4-wide configuration actions such as bus speed detection are also
handled in this core driver.
This patch:
The SGI IOC4 I/O controller chip implements multiple functions, though it is
not a multi-function PCI device. Additionally, various PCI resources of the
IOC4 are shared by multiple hardware functions, and thus resource ownership by
driver is not clearly delineated. Due to the current driver design, all core
and subordinate drivers must be loaded, or none, which is undesirable if not
all IOC4 hardware features are being used.
This patch reorganizes the IOC4 drivers so that the core driver provides a
subdriver registration service. Through appropriate callbacks the subdrivers
can now handle device addition and removal, as well as module insertion and
deletion (though the IOC4 IDE driver requires further work before module
deletion will work). The core driver now takes care of allocating PCI
resources and data which must be shared between subdrivers, to clearly
delineate module ownership of these items.
Signed-off-by: Brent Casavant <bcasavan@sgi.com>
Acked-by: Pat Gefre <pfg@sgi.com
Acked-by: Jeremy Higdon <jeremy@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-22 02:15:59 +02:00
|
|
|
ioc4_ide_attach_one(struct ioc4_driver_data *idd)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-06-23 11:05:52 +02:00
|
|
|
/* PCI-RT does not bring out IDE connection.
|
|
|
|
* Do not attach to this particular IOC4.
|
|
|
|
*/
|
|
|
|
if (idd->idd_variant == IOC4_VARIANT_PCI_RT)
|
|
|
|
return 0;
|
|
|
|
|
2007-10-11 23:54:00 +02:00
|
|
|
return pci_init_sgiioc4(idd->idd_pdev);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
[PATCH] ioc4: Core driver rewrite
This series of patches reworks the configuration and internal structure
of the SGI IOC4 I/O controller device drivers.
These changes are motivated by several factors:
- The IOC4 chip PCI resources are of mixed use between functions (i.e.
multiple functions are handled in the same address range, sometimes
within the same register), muddling resource ownership and initialization
issues. Centralizing this ownership in a core driver is desirable.
- The IOC4 chip implements multiple functions (serial, IDE, others not
yet implemented in the mainline kernel) but is not a multifunction
PCI device. In order to properly handle device addition and removal
as well as module insertion and deletion, an intermediary IOC4-specific
driver layer is needed to handle these operations cleanly.
- All IOC4 drivers are currently enabled by a single CONFIG value. As
not all systems need all IOC4 functions, it is desireable to enable
these drivers independently.
- The current IOC4 core driver will trigger loading of all function-level
drivers, as it makes direct calls to them. This situation should be
reversed (i.e. function-level drivers cause loading of core driver)
in order to maintain a clear and least-surprise driver loading model.
- IOC4 hardware design necessitates some driver-level dependency on
the PCI bus clock speed. Current code assumes a 66MHz bus, but the
speed should be autodetected and appropriate compensation taken.
This patch series effects the above changes by a newly and better designed
IOC4 core driver with which the function-level drivers can register and
deregister themselves upon module insertion/removal. By tracking these
modules, device addition/removal is also handled properly. PCI resource
management and ownership issues are centralized in this core driver, and
IOC4-wide configuration actions such as bus speed detection are also
handled in this core driver.
This patch:
The SGI IOC4 I/O controller chip implements multiple functions, though it is
not a multi-function PCI device. Additionally, various PCI resources of the
IOC4 are shared by multiple hardware functions, and thus resource ownership by
driver is not clearly delineated. Due to the current driver design, all core
and subordinate drivers must be loaded, or none, which is undesirable if not
all IOC4 hardware features are being used.
This patch reorganizes the IOC4 drivers so that the core driver provides a
subdriver registration service. Through appropriate callbacks the subdrivers
can now handle device addition and removal, as well as module insertion and
deletion (though the IOC4 IDE driver requires further work before module
deletion will work). The core driver now takes care of allocating PCI
resources and data which must be shared between subdrivers, to clearly
delineate module ownership of these items.
Signed-off-by: Brent Casavant <bcasavan@sgi.com>
Acked-by: Pat Gefre <pfg@sgi.com
Acked-by: Jeremy Higdon <jeremy@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-22 02:15:59 +02:00
|
|
|
static struct ioc4_submodule ioc4_ide_submodule = {
|
|
|
|
.is_name = "IOC4_ide",
|
|
|
|
.is_owner = THIS_MODULE,
|
|
|
|
.is_probe = ioc4_ide_attach_one,
|
|
|
|
/* .is_remove = ioc4_ide_remove_one, */
|
|
|
|
};
|
|
|
|
|
2007-01-27 13:46:56 +01:00
|
|
|
static int __init ioc4_ide_init(void)
|
[PATCH] ioc4: Core driver rewrite
This series of patches reworks the configuration and internal structure
of the SGI IOC4 I/O controller device drivers.
These changes are motivated by several factors:
- The IOC4 chip PCI resources are of mixed use between functions (i.e.
multiple functions are handled in the same address range, sometimes
within the same register), muddling resource ownership and initialization
issues. Centralizing this ownership in a core driver is desirable.
- The IOC4 chip implements multiple functions (serial, IDE, others not
yet implemented in the mainline kernel) but is not a multifunction
PCI device. In order to properly handle device addition and removal
as well as module insertion and deletion, an intermediary IOC4-specific
driver layer is needed to handle these operations cleanly.
- All IOC4 drivers are currently enabled by a single CONFIG value. As
not all systems need all IOC4 functions, it is desireable to enable
these drivers independently.
- The current IOC4 core driver will trigger loading of all function-level
drivers, as it makes direct calls to them. This situation should be
reversed (i.e. function-level drivers cause loading of core driver)
in order to maintain a clear and least-surprise driver loading model.
- IOC4 hardware design necessitates some driver-level dependency on
the PCI bus clock speed. Current code assumes a 66MHz bus, but the
speed should be autodetected and appropriate compensation taken.
This patch series effects the above changes by a newly and better designed
IOC4 core driver with which the function-level drivers can register and
deregister themselves upon module insertion/removal. By tracking these
modules, device addition/removal is also handled properly. PCI resource
management and ownership issues are centralized in this core driver, and
IOC4-wide configuration actions such as bus speed detection are also
handled in this core driver.
This patch:
The SGI IOC4 I/O controller chip implements multiple functions, though it is
not a multi-function PCI device. Additionally, various PCI resources of the
IOC4 are shared by multiple hardware functions, and thus resource ownership by
driver is not clearly delineated. Due to the current driver design, all core
and subordinate drivers must be loaded, or none, which is undesirable if not
all IOC4 hardware features are being used.
This patch reorganizes the IOC4 drivers so that the core driver provides a
subdriver registration service. Through appropriate callbacks the subdrivers
can now handle device addition and removal, as well as module insertion and
deletion (though the IOC4 IDE driver requires further work before module
deletion will work). The core driver now takes care of allocating PCI
resources and data which must be shared between subdrivers, to clearly
delineate module ownership of these items.
Signed-off-by: Brent Casavant <bcasavan@sgi.com>
Acked-by: Pat Gefre <pfg@sgi.com
Acked-by: Jeremy Higdon <jeremy@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-22 02:15:59 +02:00
|
|
|
{
|
|
|
|
return ioc4_register_submodule(&ioc4_ide_submodule);
|
|
|
|
}
|
|
|
|
|
2006-10-17 09:09:25 +02:00
|
|
|
late_initcall(ioc4_ide_init); /* Call only after IDE init is done */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-05-31 06:27:07 +02:00
|
|
|
MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
|
2005-04-17 00:20:36 +02:00
|
|
|
MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card");
|
|
|
|
MODULE_LICENSE("GPL");
|