linux-bk/drivers/scsi/sata_via.c
<<
>>
Prefs
   1/*
   2   sata_via.c - VIA Serial ATA controllers
   3
   4   Copyright 2003 Red Hat, Inc.  All rights reserved.
   5   Copyright 2003 Jeff Garzik
   6
   7   The contents of this file are subject to the Open
   8   Software License version 1.1 that can be found at
   9   http://www.opensource.org/licenses/osl-1.1.txt and is included herein
  10   by reference.
  11
  12   Alternatively, the contents of this file may be used under the terms
  13   of the GNU General Public License version 2 (the "GPL") as distributed
  14   in the kernel source COPYING file, in which case the provisions of
  15   the GPL are applicable instead of the above.  If you wish to allow
  16   the use of your version of this file only under the terms of the
  17   GPL and not to allow others to use your version of this file under
  18   the OSL, indicate your decision by deleting the provisions above and
  19   replace them with the notice and other provisions required by the GPL.
  20   If you do not delete the provisions above, a recipient may use your
  21   version of this file under either the OSL or the GPL.
  22
  23 */
  24
  25#include <linux/config.h>
  26#include <linux/kernel.h>
  27#include <linux/module.h>
  28#include <linux/pci.h>
  29#include <linux/init.h>
  30#include <linux/blkdev.h>
  31#include <linux/delay.h>
  32#include "scsi.h"
  33#include "hosts.h"
  34#include <linux/libata.h>
  35
  36#define DRV_NAME        "sata_via"
  37#define DRV_VERSION     "0.11"
  38
  39enum {
  40        via_sata                = 0,
  41};
  42
  43static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
  44static void svia_sata_phy_reset(struct ata_port *ap);
  45static void svia_port_disable(struct ata_port *ap);
  46static void svia_set_piomode (struct ata_port *ap, struct ata_device *adev,
  47                              unsigned int pio);
  48static void svia_set_udmamode (struct ata_port *ap, struct ata_device *adev,
  49                               unsigned int udma);
  50
  51static unsigned int in_module_init = 1;
  52
  53static struct pci_device_id svia_pci_tbl[] = {
  54        { 0x1106, 0x3149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, via_sata },
  55
  56        { }     /* terminate list */
  57};
  58
  59static struct pci_driver svia_pci_driver = {
  60        .name                   = DRV_NAME,
  61        .id_table               = svia_pci_tbl,
  62        .probe                  = svia_init_one,
  63        .remove                 = ata_pci_remove_one,
  64};
  65
  66static Scsi_Host_Template svia_sht = {
  67        .module                 = THIS_MODULE,
  68        .name                   = DRV_NAME,
  69        .queuecommand           = ata_scsi_queuecmd,
  70        .eh_strategy_handler    = ata_scsi_error,
  71        .can_queue              = ATA_DEF_QUEUE,
  72        .this_id                = ATA_SHT_THIS_ID,
  73        .sg_tablesize           = ATA_MAX_PRD,
  74        .max_sectors            = ATA_MAX_SECTORS,
  75        .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
  76        .emulated               = ATA_SHT_EMULATED,
  77        .use_clustering         = ATA_SHT_USE_CLUSTERING,
  78        .proc_name              = DRV_NAME,
  79        .dma_boundary           = ATA_DMA_BOUNDARY,
  80        .slave_configure        = ata_scsi_slave_config,
  81};
  82
  83static struct ata_port_operations svia_sata_ops = {
  84        .port_disable           = svia_port_disable,
  85        .set_piomode            = svia_set_piomode,
  86        .set_udmamode           = svia_set_udmamode,
  87
  88        .tf_load                = ata_tf_load_pio,
  89        .tf_read                = ata_tf_read_pio,
  90        .check_status           = ata_check_status_pio,
  91        .exec_command           = ata_exec_command_pio,
  92
  93        .phy_reset              = svia_sata_phy_reset,
  94        .phy_config             = pata_phy_config,      /* not a typo */
  95
  96        .bmdma_start            = ata_bmdma_start_pio,
  97        .fill_sg                = ata_fill_sg,
  98        .eng_timeout            = ata_eng_timeout,
  99
 100        .irq_handler            = ata_interrupt,
 101
 102        .port_start             = ata_port_start,
 103        .port_stop              = ata_port_stop,
 104};
 105
 106static struct ata_port_info svia_port_info[] = {
 107        /* via_sata */
 108        {
 109                .sht            = &svia_sht,
 110                .host_flags     = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY
 111                                  | ATA_FLAG_SRST,
 112                .pio_mask       = 0x03, /* pio3-4 */
 113                .udma_mask      = 0x7f, /* udma0-6 ; FIXME */
 114                .port_ops       = &svia_sata_ops,
 115        },
 116};
 117
 118static struct pci_bits svia_enable_bits[] = {
 119        { 0x40U, 1U, 0x02UL, 0x02UL },  /* port 0 */
 120        { 0x40U, 1U, 0x01UL, 0x01UL },  /* port 1 */
 121};
 122
 123
 124MODULE_AUTHOR("Jeff Garzik");
 125MODULE_DESCRIPTION("SCSI low-level driver for VIA SATA controllers");
 126MODULE_LICENSE("GPL");
 127MODULE_DEVICE_TABLE(pci, svia_pci_tbl);
 128
 129/**
 130 *      svia_sata_phy_reset -
 131 *      @ap:
 132 *
 133 *      LOCKING:
 134 *
 135 */
 136
 137static void svia_sata_phy_reset(struct ata_port *ap)
 138{
 139        if (!pci_test_config_bits(ap->host_set->pdev,
 140                                  &svia_enable_bits[ap->port_no])) {
 141                ata_port_disable(ap);
 142                printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
 143                return;
 144        }
 145
 146        ata_port_probe(ap);
 147        if (ap->flags & ATA_FLAG_PORT_DISABLED)
 148                return;
 149
 150        ata_bus_reset(ap);
 151}
 152
 153/**
 154 *      svia_port_disable -
 155 *      @ap:
 156 *
 157 *      LOCKING:
 158 *
 159 */
 160
 161static void svia_port_disable(struct ata_port *ap)
 162{
 163        ata_port_disable(ap);
 164
 165        /* FIXME */
 166}
 167
 168/**
 169 *      svia_set_piomode -
 170 *      @ap:
 171 *      @adev:
 172 *      @pio:
 173 *
 174 *      LOCKING:
 175 *
 176 */
 177
 178static void svia_set_piomode (struct ata_port *ap, struct ata_device *adev,
 179                              unsigned int pio)
 180{
 181        /* FIXME: needed? */
 182}
 183
 184/**
 185 *      svia_set_udmamode -
 186 *      @ap:
 187 *      @adev:
 188 *      @udma:
 189 *
 190 *      LOCKING:
 191 *
 192 */
 193
 194static void svia_set_udmamode (struct ata_port *ap, struct ata_device *adev,
 195                              unsigned int udma)
 196{
 197        /* FIXME: needed? */
 198}
 199
 200/**
 201 *      svia_init_one -
 202 *      @pdev:
 203 *      @ent:
 204 *
 205 *      LOCKING:
 206 *
 207 *      RETURNS:
 208 *
 209 */
 210
 211static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 212{
 213        static int printed_version;
 214        struct ata_port_info *port_info[1];
 215        unsigned int n_ports = 1;
 216
 217        if (!printed_version++)
 218                printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
 219
 220        /* no hotplugging support (FIXME) */
 221        if (!in_module_init)
 222                return -ENODEV;
 223
 224        port_info[0] = &svia_port_info[ent->driver_data];
 225
 226        return ata_pci_init_one(pdev, port_info, n_ports);
 227}
 228
 229/**
 230 *      svia_init -
 231 *
 232 *      LOCKING:
 233 *
 234 *      RETURNS:
 235 *
 236 */
 237
 238static int __init svia_init(void)
 239{
 240        int rc;
 241
 242        DPRINTK("pci_module_init\n");
 243        rc = pci_module_init(&svia_pci_driver);
 244        if (rc)
 245                return rc;
 246
 247        in_module_init = 0;
 248
 249        DPRINTK("done\n");
 250        return 0;
 251}
 252
 253/**
 254 *      svia_exit -
 255 *
 256 *      LOCKING:
 257 *
 258 */
 259
 260static void __exit svia_exit(void)
 261{
 262        pci_unregister_driver(&svia_pci_driver);
 263}
 264
 265module_init(svia_init);
 266module_exit(svia_exit);
 267
 268
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.