2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2006-02-02 08:00:46 +00:00
|
|
|
* Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
|
2009-06-15 16:52:55 +00:00
|
|
|
* Copyright (C) 2008-2009 MontaVista Software, Inc.
|
2005-04-16 22:20:36 +00: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/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/blkdev.h>
|
2007-07-25 06:13:56 +00: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 00:15:59 +00:00
|
|
|
#include <linux/ioc4.h>
|
2009-06-15 16:52:55 +00:00
|
|
|
#include <linux/io.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/ide.h>
|
|
|
|
|
2007-10-11 21:54:00 +00:00
|
|
|
#define DRV_NAME "SGIIOC4"
|
|
|
|
|
2005-04-16 22:20:36 +00: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
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
struct ioc4_dma_regs {
|
2005-04-16 22:20:36 +00:00
|
|
|
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;
|
2009-06-15 16:52:55 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Each Physical Region Descriptor Entry size is 16 bytes (2 * 64 bits) */
|
|
|
|
/* IOC4 has only 1 IDE channel */
|
2009-06-15 16:52:55 +00:00
|
|
|
#define IOC4_PRD_BYTES 16
|
|
|
|
#define IOC4_PRD_ENTRIES (PAGE_SIZE / (4 * IOC4_PRD_BYTES))
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
static void sgiioc4_init_hwif_ports(struct ide_hw *hw,
|
|
|
|
unsigned long data_port,
|
|
|
|
unsigned long ctrl_port,
|
|
|
|
unsigned long irq_port)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned long reg = data_port;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Registers are word (32 bit) aligned */
|
2008-04-27 13:38:32 +00:00
|
|
|
for (i = 0; i <= 7; i++)
|
|
|
|
hw->io_ports_array[i] = reg + i * 4;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-17 16:09:16 +00:00
|
|
|
hw->io_ports.ctl_addr = ctrl_port;
|
|
|
|
hw->io_ports.irq_addr = irq_port;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
static int sgiioc4_checkirq(ide_hwif_t *hwif)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-06-15 16:52:55 +00:00
|
|
|
unsigned long intr_addr = hwif->io_ports.irq_addr + IOC4_INTR_REG * 4;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
if (readl((void __iomem *)intr_addr) & 0x03)
|
2005-04-16 22:20:36 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-23 17:55:52 +00:00
|
|
|
static u8 sgiioc4_read_status(ide_hwif_t *);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
static int sgiioc4_clearirq(ide_drive_t *drive)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u32 intr_reg;
|
2009-01-06 16:20:52 +00:00
|
|
|
ide_hwif_t *hwif = drive->hwif;
|
2008-04-27 13:38:32 +00:00
|
|
|
struct ide_io_ports *io_ports = &hwif->io_ports;
|
|
|
|
unsigned long other_ir = io_ports->irq_addr + (IOC4_INTR_REG << 2);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Code to check for PCI error conditions */
|
2007-02-17 01:40:25 +00:00
|
|
|
intr_reg = readl((void __iomem *)other_ir);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (intr_reg & 0x03) { /* Valid IOC4-IDE interrupt */
|
|
|
|
/*
|
2008-07-23 17:55:52 +00:00
|
|
|
* Using sgiioc4_read_status to read the Status register has a
|
|
|
|
* side effect of clearing the interrupt. The first read should
|
2008-04-17 22:46:26 +00:00
|
|
|
* 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.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2008-07-23 17:55:52 +00:00
|
|
|
u8 stat = sgiioc4_read_status(hwif);
|
2005-04-16 22:20:36 +00:00
|
|
|
int count = 0;
|
2008-07-23 17:55:52 +00:00
|
|
|
|
|
|
|
stat = sgiioc4_read_status(hwif);
|
2008-10-13 19:39:29 +00:00
|
|
|
while ((stat & ATA_BUSY) && (count++ < 100)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
udelay(1);
|
2008-07-23 17:55:52 +00:00
|
|
|
stat = sgiioc4_read_status(hwif);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (intr_reg & 0x02) {
|
2008-02-01 22:09:31 +00:00
|
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
/* 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 =
|
2008-04-27 13:38:32 +00:00
|
|
|
readl((void __iomem *)io_ports->irq_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
pci_err_addr_high =
|
2008-04-27 13:38:32 +00:00
|
|
|
readl((void __iomem *)(io_ports->irq_addr + 4));
|
2008-02-01 22:09:31 +00:00
|
|
|
pci_read_config_dword(dev, PCI_COMMAND,
|
2005-04-16 22:20:36 +00:00
|
|
|
&pci_stat_cmd_reg);
|
2009-06-15 16:52:55 +00:00
|
|
|
printk(KERN_ERR "%s(%s): PCI Bus Error when doing DMA: "
|
|
|
|
"status-cmd reg is 0x%x\n",
|
2008-04-26 20:25:20 +00:00
|
|
|
__func__, drive->name, pci_stat_cmd_reg);
|
2009-06-15 16:52:55 +00:00
|
|
|
printk(KERN_ERR "%s(%s): PCI Error Address is 0x%x%x\n",
|
2008-04-26 20:25:20 +00:00
|
|
|
__func__, drive->name,
|
2005-04-16 22:20:36 +00:00
|
|
|
pci_err_addr_high, pci_err_addr_low);
|
|
|
|
/* Clear the PCI Error indicator */
|
2008-02-01 22:09:31 +00:00
|
|
|
pci_write_config_dword(dev, PCI_COMMAND, 0x00000146);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the Interrupt, Error bits on the IOC4 */
|
2007-02-17 01:40:25 +00:00
|
|
|
writel(0x03, (void __iomem *)other_ir);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-02-17 01:40:25 +00:00
|
|
|
intr_reg = readl((void __iomem *)other_ir);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return intr_reg & 3;
|
|
|
|
}
|
|
|
|
|
2008-04-26 20:25:24 +00:00
|
|
|
static void sgiioc4_dma_start(ide_drive_t *drive)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-01-06 16:20:52 +00:00
|
|
|
ide_hwif_t *hwif = drive->hwif;
|
2007-02-17 01:40:25 +00:00
|
|
|
unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4;
|
|
|
|
unsigned int reg = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned int temp_reg = reg | IOC4_S_DMA_START;
|
|
|
|
|
2007-02-17 01:40:25 +00:00
|
|
|
writel(temp_reg, (void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
static u32 sgiioc4_ide_dma_stop(ide_hwif_t *hwif, u64 dma_base)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-02-17 01:40:25 +00:00
|
|
|
unsigned long ioc4_dma_addr = dma_base + IOC4_DMA_CTRL * 4;
|
2005-04-16 22:20:36 +00:00
|
|
|
u32 ioc4_dma;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
count = 0;
|
2007-02-17 01:40:25 +00:00
|
|
|
ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
while ((ioc4_dma & IOC4_S_DMA_STOP) && (count++ < 200)) {
|
|
|
|
udelay(1);
|
2007-02-17 01:40:25 +00:00
|
|
|
ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
return ioc4_dma;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stops the IOC4 DMA Engine */
|
2008-04-26 20:25:24 +00:00
|
|
|
static int sgiioc4_dma_end(ide_drive_t *drive)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0;
|
2009-01-06 16:20:52 +00:00
|
|
|
ide_hwif_t *hwif = drive->hwif;
|
2007-02-17 01:40:25 +00:00
|
|
|
unsigned long dma_base = hwif->dma_base;
|
2005-04-16 22:20:36 +00:00
|
|
|
int dma_stat = 0;
|
2006-10-03 08:14:25 +00:00
|
|
|
unsigned long *ending_dma = ide_get_hwifdata(hwif);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-02-17 01:40:25 +00:00
|
|
|
writel(IOC4_S_DMA_STOP, (void __iomem *)(dma_base + IOC4_DMA_CTRL * 4));
|
2005-04-16 22:20:36 +00: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",
|
2008-04-26 20:25:20 +00:00
|
|
|
__func__, drive->name, ioc4_dma);
|
2005-04-16 22:20:36 +00:00
|
|
|
dma_stat = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-06-15 16:52:55 +00:00
|
|
|
* The IOC4 will DMA 1's to the ending DMA area to indicate that
|
2005-04-16 22:20:36 +00:00
|
|
|
* 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) {
|
2008-04-26 20:25:20 +00:00
|
|
|
printk(KERN_ERR "%s(%s) : DMA incomplete\n", __func__,
|
2005-04-16 22:20:36 +00:00
|
|
|
drive->name);
|
|
|
|
dma_stat = 1;
|
|
|
|
}
|
|
|
|
|
2007-02-17 01:40:25 +00: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-16 22:20:36 +00: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",
|
2008-04-26 20:25:20 +00:00
|
|
|
__func__, drive->name, bc_dev, bc_mem);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dma_stat;
|
|
|
|
}
|
|
|
|
|
2010-01-19 09:45:29 +00:00
|
|
|
static void sgiioc4_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
|
2007-10-11 21:54:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
/* Returns 1 if DMA IRQ issued, 0 otherwise */
|
2008-04-26 20:25:24 +00:00
|
|
|
static int sgiioc4_dma_test_irq(ide_drive_t *drive)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-01-06 16:20:52 +00:00
|
|
|
return sgiioc4_checkirq(drive->hwif);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-01-26 19:13:03 +00:00
|
|
|
static void sgiioc4_dma_host_set(ide_drive_t *drive, int on)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-01-26 19:13:03 +00:00
|
|
|
if (!on)
|
|
|
|
sgiioc4_clearirq(drive);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-03-31 18:15:24 +00:00
|
|
|
static void sgiioc4_resetproc(ide_drive_t *drive)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-03-31 18:15:24 +00:00
|
|
|
struct ide_cmd *cmd = &drive->hwif->cmd;
|
|
|
|
|
2008-04-26 20:25:24 +00:00
|
|
|
sgiioc4_dma_end(drive);
|
2009-03-31 18:15:24 +00:00
|
|
|
ide_dma_unmap_sg(drive, cmd);
|
2005-04-16 22:20:36 +00:00
|
|
|
sgiioc4_clearirq(drive);
|
|
|
|
}
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
static void sgiioc4_dma_lost_irq(ide_drive_t *drive)
|
2007-07-09 21:17:54 +00:00
|
|
|
{
|
|
|
|
sgiioc4_resetproc(drive);
|
|
|
|
|
|
|
|
ide_dma_lost_irq(drive);
|
|
|
|
}
|
|
|
|
|
2008-07-23 17:55:52 +00:00
|
|
|
static u8 sgiioc4_read_status(ide_hwif_t *hwif)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-07-23 17:55:52 +00:00
|
|
|
unsigned long port = hwif->io_ports.status_addr;
|
2006-05-31 04:27:07 +00:00
|
|
|
u8 reg = (u8) readb((void __iomem *) port);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-17 16:09:16 +00:00
|
|
|
if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */
|
|
|
|
unsigned long other_ir = port - 0x110;
|
|
|
|
unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-17 16:09:16 +00:00
|
|
|
/* Clear the Interrupt, Error bits on the IOC4 */
|
|
|
|
if (intr_reg & 0x03) {
|
|
|
|
writel(0x03, (void __iomem *) other_ir);
|
|
|
|
intr_reg = (u32) readl((void __iomem *) other_ir);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
/* Creates a DMA map for the scatter-gather list entries */
|
2012-12-21 21:21:03 +00:00
|
|
|
static int ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-02-01 22:09:31 +00:00
|
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
2008-04-26 20:25:23 +00:00
|
|
|
unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET;
|
2009-06-15 16:52:55 +00:00
|
|
|
int num_ports = sizeof(struct ioc4_dma_regs);
|
2006-10-03 08:14:25 +00:00
|
|
|
void *pad;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-13 19:39:30 +00:00
|
|
|
printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-13 19:39:30 +00:00
|
|
|
if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) {
|
|
|
|
printk(KERN_ERR "%s(%s) -- ERROR: addresses 0x%08lx to 0x%08lx "
|
|
|
|
"already in use\n", __func__, hwif->name,
|
|
|
|
dma_base, dma_base + num_ports - 1);
|
2007-10-11 21:54:00 +00:00
|
|
|
return -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-10-17 16:09:17 +00:00
|
|
|
hwif->dma_base = (unsigned long)hwif->io_ports.irq_addr +
|
|
|
|
IOC4_DMA_OFFSET;
|
2006-09-01 04:27:51 +00:00
|
|
|
|
2008-10-13 19:39:47 +00:00
|
|
|
hwif->sg_max_nents = IOC4_PRD_ENTRIES;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-13 19:39:47 +00:00
|
|
|
hwif->prd_max_nents = IOC4_PRD_ENTRIES;
|
|
|
|
hwif->prd_ent_size = IOC4_PRD_BYTES;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-13 19:39:47 +00:00
|
|
|
if (ide_allocate_dma_engine(hwif))
|
|
|
|
goto dma_pci_alloc_failure;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
ide: remove deprecated use of pci api
Replace occurences of the pci api by appropriate call to the dma api.
A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr)
@deprecated@
idexpression id;
position p;
@@
(
pci_dma_supported@p ( id, ...)
|
pci_alloc_consistent@p ( id, ...)
)
@bad1@
idexpression id;
position deprecated.p;
@@
...when != &id->dev
when != pci_get_drvdata ( id )
when != pci_enable_device ( id )
(
pci_dma_supported@p ( id, ...)
|
pci_alloc_consistent@p ( id, ...)
)
@depends on !bad1@
idexpression id;
expression direction;
position deprecated.p;
@@
(
- pci_dma_supported@p ( id,
+ dma_supported ( &id->dev,
...
+ , GFP_ATOMIC
)
|
- pci_alloc_consistent@p ( id,
+ dma_alloc_coherent ( &id->dev,
...
+ , GFP_ATOMIC
)
)
Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-04-13 08:26:53 +00:00
|
|
|
pad = dma_alloc_coherent(&dev->dev, IOC4_IDE_CACHELINE_SIZE,
|
|
|
|
(dma_addr_t *)&hwif->extra_base, GFP_KERNEL);
|
2006-10-03 08:14:25 +00:00
|
|
|
if (pad) {
|
|
|
|
ide_set_hwifdata(hwif, pad);
|
2007-10-11 21:54:00 +00:00
|
|
|
return 0;
|
2006-10-03 08:14:25 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-10-13 19:39:47 +00:00
|
|
|
ide_release_dma_engine(hwif);
|
|
|
|
|
2008-10-13 19:39:30 +00:00
|
|
|
printk(KERN_ERR "%s(%s) -- ERROR: Unable to allocate DMA maps\n",
|
2008-04-26 20:25:20 +00:00
|
|
|
__func__, hwif->name);
|
2008-10-13 19:39:30 +00:00
|
|
|
printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-01 04:27:51 +00:00
|
|
|
dma_pci_alloc_failure:
|
|
|
|
release_mem_region(dma_base, num_ports);
|
|
|
|
|
2007-10-11 21:54:00 +00:00
|
|
|
return -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initializes the IOC4 DMA Engine */
|
2009-06-15 16:52:55 +00:00
|
|
|
static void sgiioc4_configure_for_dma(int dma_direction, ide_drive_t *drive)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u32 ioc4_dma;
|
2009-01-06 16:20:52 +00:00
|
|
|
ide_hwif_t *hwif = drive->hwif;
|
2007-02-17 01:40:25 +00:00
|
|
|
unsigned long dma_base = hwif->dma_base;
|
|
|
|
unsigned long ioc4_dma_addr = dma_base + IOC4_DMA_CTRL * 4;
|
2005-04-16 22:20:36 +00:00
|
|
|
u32 dma_addr, ending_dma_addr;
|
|
|
|
|
2007-02-17 01:40:25 +00:00
|
|
|
ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (ioc4_dma & IOC4_S_DMA_ACTIVE) {
|
2009-06-15 16:52:55 +00:00
|
|
|
printk(KERN_WARNING "%s(%s): Warning!! DMA from previous "
|
|
|
|
"transfer was still active\n", __func__, drive->name);
|
2007-02-17 01:40:25 +00:00
|
|
|
writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base);
|
|
|
|
|
|
|
|
if (ioc4_dma & IOC4_S_DMA_STOP)
|
2009-06-15 16:52:55 +00:00
|
|
|
printk(KERN_ERR "%s(%s): IOC4 DMA STOP bit is "
|
|
|
|
"still 1\n", __func__, drive->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-02-17 01:40:25 +00:00
|
|
|
ioc4_dma = readl((void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ioc4_dma & IOC4_S_DMA_ERROR) {
|
2009-06-15 16:52:55 +00:00
|
|
|
printk(KERN_WARNING "%s(%s): Warning!! DMA Error during "
|
|
|
|
"previous transfer, status 0x%x\n",
|
2008-04-26 20:25:20 +00:00
|
|
|
__func__, drive->name, ioc4_dma);
|
2007-02-17 01:40:25 +00:00
|
|
|
writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base);
|
|
|
|
|
|
|
|
if (ioc4_dma & IOC4_S_DMA_STOP)
|
2009-06-15 16:52:55 +00:00
|
|
|
printk(KERN_ERR "%s(%s): IOC4 DMA STOP bit is "
|
|
|
|
"still 1\n", __func__, drive->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Address of the Scatter Gather List */
|
|
|
|
dma_addr = cpu_to_le32(hwif->dmatable_dma);
|
2007-02-17 01:40:25 +00:00
|
|
|
writel(dma_addr, (void __iomem *)(dma_base + IOC4_DMA_PTR_L * 4));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Address of the Ending DMA */
|
2006-10-03 08:14:25 +00:00
|
|
|
memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE);
|
2008-07-15 19:21:47 +00:00
|
|
|
ending_dma_addr = cpu_to_le32(hwif->extra_base);
|
2009-06-15 16:52:55 +00:00
|
|
|
writel(ending_dma_addr, (void __iomem *)(dma_base +
|
|
|
|
IOC4_DMA_END_ADDR * 4));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-02-17 01:40:25 +00:00
|
|
|
writel(dma_direction, (void __iomem *)ioc4_dma_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
/* IOC4 Scatter Gather list Format */
|
2005-04-16 22:20:36 +00:00
|
|
|
/* 128 Bit entries to support 64 bit addresses in the future */
|
|
|
|
/* The Scatter Gather list Entry should be in the BIG-ENDIAN Format */
|
|
|
|
/* --------------------------------------------------------------------- */
|
2009-06-15 16:52:55 +00:00
|
|
|
/* | Upper 32 bits - Zero | Lower 32 bits- address | */
|
2005-04-16 22:20:36 +00:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* | Upper 32 bits - Zero |EOL| 15 unused | 16 Bit Length| */
|
|
|
|
/* --------------------------------------------------------------------- */
|
2009-06-15 16:52:55 +00:00
|
|
|
/* Creates the scatter gather list, DMA Table */
|
|
|
|
|
2009-03-27 11:46:46 +00:00
|
|
|
static int sgiioc4_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-01-06 16:20:52 +00:00
|
|
|
ide_hwif_t *hwif = drive->hwif;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned int *table = hwif->dmatable_cpu;
|
2009-03-27 11:46:46 +00:00
|
|
|
unsigned int count = 0, i = cmd->sg_nents;
|
2009-03-27 11:46:37 +00:00
|
|
|
struct scatterlist *sg = hwif->sg_table;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
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);
|
2009-03-31 18:15:21 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2006-02-02 08:00:46 +00:00
|
|
|
u32 bcount =
|
2005-04-16 22:20:36 +00:00
|
|
|
0x10000 - (cur_addr & 0xffff);
|
|
|
|
|
|
|
|
if (bcount > cur_len)
|
|
|
|
bcount = cur_len;
|
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
/*
|
|
|
|
* Put the address, length in
|
|
|
|
* the IOC4 dma-table format
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
*table = 0x0;
|
|
|
|
table++;
|
|
|
|
*table = cpu_to_be32(cur_addr);
|
|
|
|
table++;
|
|
|
|
*table = 0x0;
|
|
|
|
table++;
|
|
|
|
|
2006-02-02 08:00:46 +00:00
|
|
|
*table = cpu_to_be32(bcount);
|
2005-04-16 22:20:36 +00:00
|
|
|
table++;
|
|
|
|
|
|
|
|
cur_addr += bcount;
|
|
|
|
cur_len -= bcount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-25 06:13:56 +00:00
|
|
|
sg = sg_next(sg);
|
2005-04-16 22:20:36 +00:00
|
|
|
i--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count) {
|
|
|
|
table--;
|
|
|
|
*table |= cpu_to_be32(0x80000000);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0; /* revert to PIO for this request */
|
|
|
|
}
|
|
|
|
|
2009-03-27 11:46:46 +00:00
|
|
|
static int sgiioc4_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int ddir;
|
2009-03-27 11:46:46 +00:00
|
|
|
u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-31 18:15:21 +00:00
|
|
|
if (sgiioc4_build_dmatable(drive, cmd) == 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* try PIO instead of DMA */
|
|
|
|
return 1;
|
|
|
|
|
2009-03-27 11:46:46 +00:00
|
|
|
if (write)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2008-07-23 17:55:56 +00:00
|
|
|
static const struct ide_tp_ops sgiioc4_tp_ops = {
|
|
|
|
.exec_command = ide_exec_command,
|
|
|
|
.read_status = sgiioc4_read_status,
|
|
|
|
.read_altstatus = ide_read_altstatus,
|
2009-03-31 18:15:30 +00:00
|
|
|
.write_devctl = ide_write_devctl,
|
2008-07-23 17:55:56 +00:00
|
|
|
|
2009-03-31 18:15:32 +00:00
|
|
|
.dev_select = ide_dev_select,
|
2008-07-23 17:55:56 +00:00
|
|
|
.tf_load = ide_tf_load,
|
|
|
|
.tf_read = ide_tf_read,
|
|
|
|
|
|
|
|
.input_data = ide_input_data,
|
|
|
|
.output_data = ide_output_data,
|
|
|
|
};
|
|
|
|
|
2008-04-26 20:25:14 +00:00
|
|
|
static const struct ide_port_ops sgiioc4_port_ops = {
|
|
|
|
.set_dma_mode = sgiioc4_set_dma_mode,
|
|
|
|
/* reset DMA engine, clear IRQs */
|
|
|
|
.resetproc = sgiioc4_resetproc,
|
|
|
|
};
|
|
|
|
|
2008-04-26 20:25:24 +00:00
|
|
|
static const struct ide_dma_ops sgiioc4_dma_ops = {
|
2008-04-26 20:25:24 +00:00
|
|
|
.dma_host_set = sgiioc4_dma_host_set,
|
|
|
|
.dma_setup = sgiioc4_dma_setup,
|
|
|
|
.dma_start = sgiioc4_dma_start,
|
|
|
|
.dma_end = sgiioc4_dma_end,
|
|
|
|
.dma_test_irq = sgiioc4_dma_test_irq,
|
|
|
|
.dma_lost_irq = sgiioc4_dma_lost_irq,
|
|
|
|
};
|
|
|
|
|
2012-12-21 21:21:03 +00:00
|
|
|
static const struct ide_port_info sgiioc4_port_info = {
|
2008-07-16 18:33:42 +00:00
|
|
|
.name = DRV_NAME,
|
2008-02-02 18:56:31 +00:00
|
|
|
.chipset = ide_pci,
|
2008-04-26 20:25:23 +00:00
|
|
|
.init_dma = ide_dma_sgiioc4,
|
2008-07-23 17:55:56 +00:00
|
|
|
.tp_ops = &sgiioc4_tp_ops,
|
2008-04-26 20:25:14 +00:00
|
|
|
.port_ops = &sgiioc4_port_ops,
|
2008-04-26 20:25:24 +00:00
|
|
|
.dma_ops = &sgiioc4_dma_ops,
|
2008-04-28 21:44:37 +00:00
|
|
|
.host_flags = IDE_HFLAG_MMIO,
|
2009-03-27 11:46:27 +00:00
|
|
|
.irq_flags = IRQF_SHARED,
|
2008-02-02 18:56:31 +00:00
|
|
|
.mwdma_mask = ATA_MWDMA2_ONLY,
|
|
|
|
};
|
|
|
|
|
2012-12-21 21:21:03 +00:00
|
|
|
static int sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-04-26 20:25:23 +00:00
|
|
|
unsigned long cmd_base, irqport;
|
2006-09-01 04:27:51 +00:00
|
|
|
unsigned long bar0, cmd_phys_base, ctl;
|
|
|
|
void __iomem *virt_base;
|
2009-05-17 17:12:25 +00:00
|
|
|
struct ide_hw hw, *hws[] = { &hw };
|
2008-07-23 17:55:59 +00:00
|
|
|
int rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
/* Get the CmdBlk and CtrlBlk base registers */
|
2006-09-01 04:27:51 +00:00
|
|
|
bar0 = pci_resource_start(dev, 0);
|
2008-10-23 21:22:07 +00:00
|
|
|
virt_base = pci_ioremap_bar(dev, 0);
|
2006-09-01 04:27:51 +00:00
|
|
|
if (virt_base == NULL) {
|
|
|
|
printk(KERN_ERR "%s: Unable to remap BAR 0 address: 0x%lx\n",
|
2007-10-11 21:54:00 +00:00
|
|
|
DRV_NAME, bar0);
|
2006-09-01 04:27:51 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2009-06-15 16:52:55 +00:00
|
|
|
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-16 22:20:36 +00:00
|
|
|
|
2006-09-01 04:27:51 +00:00
|
|
|
cmd_phys_base = bar0 + IOC4_CMD_OFFSET;
|
2008-10-13 19:39:30 +00:00
|
|
|
if (request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE,
|
|
|
|
DRV_NAME) == NULL) {
|
|
|
|
printk(KERN_ERR "%s %s -- ERROR: addresses 0x%08lx to 0x%08lx "
|
|
|
|
"already in use\n", DRV_NAME, pci_name(dev),
|
|
|
|
cmd_phys_base, cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
|
2008-10-23 21:22:06 +00:00
|
|
|
rc = -EBUSY;
|
|
|
|
goto req_mem_rgn_err;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-01-26 19:13:05 +00:00
|
|
|
/* Initialize the IO registers */
|
|
|
|
memset(&hw, 0, sizeof(hw));
|
|
|
|
sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport);
|
2008-01-26 19:13:05 +00:00
|
|
|
hw.irq = dev->irq;
|
|
|
|
hw.dev = &dev->dev;
|
2008-07-16 18:33:44 +00:00
|
|
|
|
2009-06-15 16:52:55 +00:00
|
|
|
/* Initialize chipset IRQ registers */
|
2007-02-17 01:40:25 +00:00
|
|
|
writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-05-17 17:12:24 +00:00
|
|
|
rc = ide_host_add(&sgiioc4_port_info, hws, 1, NULL);
|
2008-10-23 21:22:06 +00:00
|
|
|
if (!rc)
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-07-16 18:33:44 +00:00
|
|
|
release_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE);
|
2008-10-23 21:22:06 +00:00
|
|
|
req_mem_rgn_err:
|
2008-07-16 18:33:44 +00:00
|
|
|
iounmap(virt_base);
|
2008-07-23 17:55:59 +00:00
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-21 21:21:03 +00:00
|
|
|
static unsigned int pci_init_sgiioc4(struct pci_dev *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
printk(KERN_INFO "%s: IDE controller at PCI slot %s, revision %d\n",
|
2007-10-18 22:30:08 +00:00
|
|
|
DRV_NAME, pci_name(dev), dev->revision);
|
|
|
|
|
|
|
|
if (dev->revision < IOC4_SUPPORTED_FIRMWARE_REV) {
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_ERR "Skipping %s IDE controller in slot %s: "
|
2007-10-11 21:54:00 +00:00
|
|
|
"firmware is obsolete - please upgrade to "
|
|
|
|
"revision46 or higher\n",
|
|
|
|
DRV_NAME, pci_name(dev));
|
2005-04-16 22:20:36 +00:00
|
|
|
ret = -EAGAIN;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-10-11 21:54:00 +00:00
|
|
|
ret = sgiioc4_ide_setup_pci_device(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-08-07 05:17:55 +00:00
|
|
|
static int ioc4_ide_attach_one(struct ioc4_driver_data *idd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-06-15 16:52:55 +00:00
|
|
|
/*
|
|
|
|
* PCI-RT does not bring out IDE connection.
|
2006-06-23 09:05:52 +00:00
|
|
|
* Do not attach to this particular IOC4.
|
|
|
|
*/
|
|
|
|
if (idd->idd_variant == IOC4_VARIANT_PCI_RT)
|
|
|
|
return 0;
|
|
|
|
|
2007-10-11 21:54:00 +00:00
|
|
|
return pci_init_sgiioc4(idd->idd_pdev);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-21 21:21:03 +00:00
|
|
|
static struct ioc4_submodule ioc4_ide_submodule = {
|
[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 00:15:59 +00:00
|
|
|
.is_name = "IOC4_ide",
|
|
|
|
.is_owner = THIS_MODULE,
|
|
|
|
.is_probe = ioc4_ide_attach_one,
|
|
|
|
};
|
|
|
|
|
2007-01-27 12:46:56 +00: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 00:15:59 +00:00
|
|
|
{
|
|
|
|
return ioc4_register_submodule(&ioc4_ide_submodule);
|
|
|
|
}
|
|
|
|
|
2006-10-17 07:09:25 +00:00
|
|
|
late_initcall(ioc4_ide_init); /* Call only after IDE init is done */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-05-31 04:27:07 +00:00
|
|
|
MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card");
|
|
|
|
MODULE_LICENSE("GPL");
|