Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 1 | /* |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 2 | * Marvell 88SE64xx/88SE94xx pci init |
| 3 | * |
| 4 | * Copyright 2007 Red Hat, Inc. |
| 5 | * Copyright 2008 Marvell. <kewei@marvell.com> |
| 6 | * |
| 7 | * This file is licensed under GPLv2. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; version 2 of the |
| 12 | * License. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 22 | * USA |
| 23 | */ |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 24 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 25 | |
| 26 | #include "mv_sas.h" |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 27 | |
| 28 | static struct scsi_transport_template *mvs_stt; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 29 | static const struct mvs_chip_info mvs_chips[] = { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 30 | [chip_6320] = { 1, 2, 0x400, 17, 16, 9, &mvs_64xx_dispatch, }, |
| 31 | [chip_6440] = { 1, 4, 0x400, 17, 16, 9, &mvs_64xx_dispatch, }, |
| 32 | [chip_6485] = { 1, 8, 0x800, 33, 32, 10, &mvs_64xx_dispatch, }, |
| 33 | [chip_9180] = { 2, 4, 0x800, 17, 64, 9, &mvs_94xx_dispatch, }, |
| 34 | [chip_9480] = { 2, 4, 0x800, 17, 64, 9, &mvs_94xx_dispatch, }, |
Xiangliang Yu | 8214028 | 2011-04-26 06:34:01 -0700 | [diff] [blame^] | 35 | [chip_9445] = { 1, 4, 0x800, 17, 64, 11, &mvs_94xx_dispatch, }, |
| 36 | [chip_9485] = { 2, 4, 0x800, 17, 64, 11, &mvs_94xx_dispatch, }, |
Nick Cheng | f31491d | 2009-09-08 19:03:07 +0800 | [diff] [blame] | 37 | [chip_1300] = { 1, 4, 0x400, 17, 16, 9, &mvs_64xx_dispatch, }, |
| 38 | [chip_1320] = { 2, 4, 0x800, 17, 64, 9, &mvs_94xx_dispatch, }, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 39 | }; |
| 40 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 41 | #define SOC_SAS_NUM 2 |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 42 | #define SG_MX 64 |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 43 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 44 | static struct scsi_host_template mvs_sht = { |
| 45 | .module = THIS_MODULE, |
| 46 | .name = DRV_NAME, |
| 47 | .queuecommand = sas_queuecommand, |
| 48 | .target_alloc = sas_target_alloc, |
| 49 | .slave_configure = mvs_slave_configure, |
| 50 | .slave_destroy = sas_slave_destroy, |
| 51 | .scan_finished = mvs_scan_finished, |
| 52 | .scan_start = mvs_scan_start, |
| 53 | .change_queue_depth = sas_change_queue_depth, |
| 54 | .change_queue_type = sas_change_queue_type, |
| 55 | .bios_param = sas_bios_param, |
| 56 | .can_queue = 1, |
| 57 | .cmd_per_lun = 1, |
| 58 | .this_id = -1, |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 59 | .sg_tablesize = SG_MX, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 60 | .max_sectors = SCSI_DEFAULT_MAX_SECTORS, |
| 61 | .use_clustering = ENABLE_CLUSTERING, |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 62 | .eh_device_reset_handler = sas_eh_device_reset_handler, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 63 | .eh_bus_reset_handler = sas_eh_bus_reset_handler, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 64 | .slave_alloc = mvs_slave_alloc, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 65 | .target_destroy = sas_target_destroy, |
| 66 | .ioctl = sas_ioctl, |
| 67 | }; |
| 68 | |
| 69 | static struct sas_domain_function_template mvs_transport_ops = { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 70 | .lldd_dev_found = mvs_dev_found, |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 71 | .lldd_dev_gone = mvs_dev_gone, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 72 | .lldd_execute_task = mvs_queue_command, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 73 | .lldd_control_phy = mvs_phy_control, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 74 | |
| 75 | .lldd_abort_task = mvs_abort_task, |
| 76 | .lldd_abort_task_set = mvs_abort_task_set, |
| 77 | .lldd_clear_aca = mvs_clear_aca, |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 78 | .lldd_clear_task_set = mvs_clear_task_set, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 79 | .lldd_I_T_nexus_reset = mvs_I_T_nexus_reset, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 80 | .lldd_lu_reset = mvs_lu_reset, |
| 81 | .lldd_query_task = mvs_query_task, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 82 | .lldd_port_formed = mvs_port_formed, |
| 83 | .lldd_port_deformed = mvs_port_deformed, |
| 84 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | static void __devinit mvs_phy_init(struct mvs_info *mvi, int phy_id) |
| 88 | { |
| 89 | struct mvs_phy *phy = &mvi->phy[phy_id]; |
| 90 | struct asd_sas_phy *sas_phy = &phy->sas_phy; |
| 91 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 92 | phy->mvi = mvi; |
| 93 | init_timer(&phy->timer); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 94 | sas_phy->enabled = (phy_id < mvi->chip->n_phy) ? 1 : 0; |
| 95 | sas_phy->class = SAS; |
| 96 | sas_phy->iproto = SAS_PROTOCOL_ALL; |
| 97 | sas_phy->tproto = 0; |
| 98 | sas_phy->type = PHY_TYPE_PHYSICAL; |
| 99 | sas_phy->role = PHY_ROLE_INITIATOR; |
| 100 | sas_phy->oob_mode = OOB_NOT_CONNECTED; |
| 101 | sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN; |
| 102 | |
| 103 | sas_phy->id = phy_id; |
| 104 | sas_phy->sas_addr = &mvi->sas_addr[0]; |
| 105 | sas_phy->frame_rcvd = &phy->frame_rcvd[0]; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 106 | sas_phy->ha = (struct sas_ha_struct *)mvi->shost->hostdata; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 107 | sas_phy->lldd_phy = phy; |
| 108 | } |
| 109 | |
| 110 | static void mvs_free(struct mvs_info *mvi) |
| 111 | { |
| 112 | int i; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 113 | struct mvs_wq *mwq; |
| 114 | int slot_nr; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 115 | |
| 116 | if (!mvi) |
| 117 | return; |
| 118 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 119 | if (mvi->flags & MVF_FLAG_SOC) |
| 120 | slot_nr = MVS_SOC_SLOTS; |
| 121 | else |
| 122 | slot_nr = MVS_SLOTS; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 123 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 124 | for (i = 0; i < mvi->tags_num; i++) { |
| 125 | struct mvs_slot_info *slot = &mvi->slot_info[i]; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 126 | if (slot->buf) |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 127 | dma_free_coherent(mvi->dev, MVS_SLOT_BUF_SZ, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 128 | slot->buf, slot->buf_dma); |
| 129 | } |
| 130 | |
| 131 | if (mvi->tx) |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 132 | dma_free_coherent(mvi->dev, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 133 | sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ, |
| 134 | mvi->tx, mvi->tx_dma); |
| 135 | if (mvi->rx_fis) |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 136 | dma_free_coherent(mvi->dev, MVS_RX_FISL_SZ, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 137 | mvi->rx_fis, mvi->rx_fis_dma); |
| 138 | if (mvi->rx) |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 139 | dma_free_coherent(mvi->dev, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 140 | sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1), |
| 141 | mvi->rx, mvi->rx_dma); |
| 142 | if (mvi->slot) |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 143 | dma_free_coherent(mvi->dev, |
| 144 | sizeof(*mvi->slot) * slot_nr, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 145 | mvi->slot, mvi->slot_dma); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 146 | #ifndef DISABLE_HOTPLUG_DMA_FIX |
| 147 | if (mvi->bulk_buffer) |
| 148 | dma_free_coherent(mvi->dev, TRASH_BUCKET_SIZE, |
| 149 | mvi->bulk_buffer, mvi->bulk_buffer_dma); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 150 | #endif |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 151 | |
| 152 | MVS_CHIP_DISP->chip_iounmap(mvi); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 153 | if (mvi->shost) |
| 154 | scsi_host_put(mvi->shost); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 155 | list_for_each_entry(mwq, &mvi->wq_list, entry) |
| 156 | cancel_delayed_work(&mwq->work_q); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 157 | kfree(mvi); |
| 158 | } |
| 159 | |
| 160 | #ifdef MVS_USE_TASKLET |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 161 | struct tasklet_struct mv_tasklet; |
| 162 | static void mvs_tasklet(unsigned long opaque) |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 163 | { |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 164 | unsigned long flags; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 165 | u32 stat; |
| 166 | u16 core_nr, i = 0; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 167 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 168 | struct mvs_info *mvi; |
| 169 | struct sas_ha_struct *sha = (struct sas_ha_struct *)opaque; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 170 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 171 | core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; |
| 172 | mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; |
| 173 | |
| 174 | if (unlikely(!mvi)) |
| 175 | BUG_ON(1); |
| 176 | |
| 177 | for (i = 0; i < core_nr; i++) { |
| 178 | mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; |
| 179 | stat = MVS_CHIP_DISP->isr_status(mvi, mvi->irq); |
| 180 | if (stat) |
| 181 | MVS_CHIP_DISP->isr(mvi, mvi->irq, stat); |
| 182 | } |
| 183 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 184 | } |
| 185 | #endif |
| 186 | |
| 187 | static irqreturn_t mvs_interrupt(int irq, void *opaque) |
| 188 | { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 189 | u32 core_nr, i = 0; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 190 | u32 stat; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 191 | struct mvs_info *mvi; |
| 192 | struct sas_ha_struct *sha = opaque; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 193 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 194 | core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; |
| 195 | mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 196 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 197 | if (unlikely(!mvi)) |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 198 | return IRQ_NONE; |
| 199 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 200 | stat = MVS_CHIP_DISP->isr_status(mvi, irq); |
| 201 | if (!stat) |
| 202 | return IRQ_NONE; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 203 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 204 | #ifdef MVS_USE_TASKLET |
| 205 | tasklet_schedule(&mv_tasklet); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 206 | #else |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 207 | for (i = 0; i < core_nr; i++) { |
| 208 | mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; |
| 209 | MVS_CHIP_DISP->isr(mvi, irq, stat); |
| 210 | } |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 211 | #endif |
| 212 | return IRQ_HANDLED; |
| 213 | } |
| 214 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 215 | static int __devinit mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost) |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 216 | { |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 217 | int i = 0, slot_nr; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 218 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 219 | if (mvi->flags & MVF_FLAG_SOC) |
| 220 | slot_nr = MVS_SOC_SLOTS; |
| 221 | else |
| 222 | slot_nr = MVS_SLOTS; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 223 | |
| 224 | spin_lock_init(&mvi->lock); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 225 | for (i = 0; i < mvi->chip->n_phy; i++) { |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 226 | mvs_phy_init(mvi, i); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 227 | mvi->port[i].wide_port_phymap = 0; |
| 228 | mvi->port[i].port_attached = 0; |
| 229 | INIT_LIST_HEAD(&mvi->port[i].list); |
| 230 | } |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 231 | for (i = 0; i < MVS_MAX_DEVICES; i++) { |
| 232 | mvi->devices[i].taskfileset = MVS_ID_NOT_MAPPED; |
| 233 | mvi->devices[i].dev_type = NO_DEVICE; |
| 234 | mvi->devices[i].device_id = i; |
| 235 | mvi->devices[i].dev_status = MVS_DEV_NORMAL; |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 236 | init_timer(&mvi->devices[i].timer); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 237 | } |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 238 | |
| 239 | /* |
| 240 | * alloc and init our DMA areas |
| 241 | */ |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 242 | mvi->tx = dma_alloc_coherent(mvi->dev, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 243 | sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ, |
| 244 | &mvi->tx_dma, GFP_KERNEL); |
| 245 | if (!mvi->tx) |
| 246 | goto err_out; |
| 247 | memset(mvi->tx, 0, sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 248 | mvi->rx_fis = dma_alloc_coherent(mvi->dev, MVS_RX_FISL_SZ, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 249 | &mvi->rx_fis_dma, GFP_KERNEL); |
| 250 | if (!mvi->rx_fis) |
| 251 | goto err_out; |
| 252 | memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ); |
| 253 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 254 | mvi->rx = dma_alloc_coherent(mvi->dev, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 255 | sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1), |
| 256 | &mvi->rx_dma, GFP_KERNEL); |
| 257 | if (!mvi->rx) |
| 258 | goto err_out; |
| 259 | memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1)); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 260 | mvi->rx[0] = cpu_to_le32(0xfff); |
| 261 | mvi->rx_cons = 0xfff; |
| 262 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 263 | mvi->slot = dma_alloc_coherent(mvi->dev, |
| 264 | sizeof(*mvi->slot) * slot_nr, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 265 | &mvi->slot_dma, GFP_KERNEL); |
| 266 | if (!mvi->slot) |
| 267 | goto err_out; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 268 | memset(mvi->slot, 0, sizeof(*mvi->slot) * slot_nr); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 269 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 270 | #ifndef DISABLE_HOTPLUG_DMA_FIX |
| 271 | mvi->bulk_buffer = dma_alloc_coherent(mvi->dev, |
| 272 | TRASH_BUCKET_SIZE, |
| 273 | &mvi->bulk_buffer_dma, GFP_KERNEL); |
| 274 | if (!mvi->bulk_buffer) |
| 275 | goto err_out; |
| 276 | #endif |
| 277 | for (i = 0; i < slot_nr; i++) { |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 278 | struct mvs_slot_info *slot = &mvi->slot_info[i]; |
| 279 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 280 | slot->buf = dma_alloc_coherent(mvi->dev, MVS_SLOT_BUF_SZ, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 281 | &slot->buf_dma, GFP_KERNEL); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 282 | if (!slot->buf) { |
| 283 | printk(KERN_DEBUG"failed to allocate slot->buf.\n"); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 284 | goto err_out; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 285 | } |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 286 | memset(slot->buf, 0, MVS_SLOT_BUF_SZ); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 287 | ++mvi->tags_num; |
| 288 | } |
| 289 | /* Initialize tags */ |
| 290 | mvs_tag_init(mvi); |
| 291 | return 0; |
| 292 | err_out: |
| 293 | return 1; |
| 294 | } |
| 295 | |
| 296 | |
| 297 | int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex) |
| 298 | { |
| 299 | unsigned long res_start, res_len, res_flag, res_flag_ex = 0; |
| 300 | struct pci_dev *pdev = mvi->pdev; |
| 301 | if (bar_ex != -1) { |
| 302 | /* |
| 303 | * ioremap main and peripheral registers |
| 304 | */ |
| 305 | res_start = pci_resource_start(pdev, bar_ex); |
| 306 | res_len = pci_resource_len(pdev, bar_ex); |
| 307 | if (!res_start || !res_len) |
| 308 | goto err_out; |
| 309 | |
| 310 | res_flag_ex = pci_resource_flags(pdev, bar_ex); |
| 311 | if (res_flag_ex & IORESOURCE_MEM) { |
| 312 | if (res_flag_ex & IORESOURCE_CACHEABLE) |
| 313 | mvi->regs_ex = ioremap(res_start, res_len); |
| 314 | else |
| 315 | mvi->regs_ex = ioremap_nocache(res_start, |
| 316 | res_len); |
| 317 | } else |
| 318 | mvi->regs_ex = (void *)res_start; |
| 319 | if (!mvi->regs_ex) |
| 320 | goto err_out; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 321 | } |
| 322 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 323 | res_start = pci_resource_start(pdev, bar); |
| 324 | res_len = pci_resource_len(pdev, bar); |
| 325 | if (!res_start || !res_len) |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 326 | goto err_out; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 327 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 328 | res_flag = pci_resource_flags(pdev, bar); |
| 329 | if (res_flag & IORESOURCE_CACHEABLE) |
| 330 | mvi->regs = ioremap(res_start, res_len); |
| 331 | else |
| 332 | mvi->regs = ioremap_nocache(res_start, res_len); |
| 333 | |
| 334 | if (!mvi->regs) { |
| 335 | if (mvi->regs_ex && (res_flag_ex & IORESOURCE_MEM)) |
| 336 | iounmap(mvi->regs_ex); |
| 337 | mvi->regs_ex = NULL; |
| 338 | goto err_out; |
| 339 | } |
| 340 | |
| 341 | return 0; |
| 342 | err_out: |
| 343 | return -1; |
| 344 | } |
| 345 | |
| 346 | void mvs_iounmap(void __iomem *regs) |
| 347 | { |
| 348 | iounmap(regs); |
| 349 | } |
| 350 | |
| 351 | static struct mvs_info *__devinit mvs_pci_alloc(struct pci_dev *pdev, |
| 352 | const struct pci_device_id *ent, |
| 353 | struct Scsi_Host *shost, unsigned int id) |
| 354 | { |
| 355 | struct mvs_info *mvi; |
| 356 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 357 | |
| 358 | mvi = kzalloc(sizeof(*mvi) + MVS_SLOTS * sizeof(struct mvs_slot_info), |
| 359 | GFP_KERNEL); |
| 360 | if (!mvi) |
| 361 | return NULL; |
| 362 | |
| 363 | mvi->pdev = pdev; |
| 364 | mvi->dev = &pdev->dev; |
| 365 | mvi->chip_id = ent->driver_data; |
| 366 | mvi->chip = &mvs_chips[mvi->chip_id]; |
| 367 | INIT_LIST_HEAD(&mvi->wq_list); |
| 368 | mvi->irq = pdev->irq; |
| 369 | |
| 370 | ((struct mvs_prv_info *)sha->lldd_ha)->mvi[id] = mvi; |
| 371 | ((struct mvs_prv_info *)sha->lldd_ha)->n_phy = mvi->chip->n_phy; |
| 372 | |
| 373 | mvi->id = id; |
| 374 | mvi->sas = sha; |
| 375 | mvi->shost = shost; |
| 376 | #ifdef MVS_USE_TASKLET |
| 377 | tasklet_init(&mv_tasklet, mvs_tasklet, (unsigned long)sha); |
| 378 | #endif |
| 379 | |
| 380 | if (MVS_CHIP_DISP->chip_ioremap(mvi)) |
| 381 | goto err_out; |
| 382 | if (!mvs_alloc(mvi, shost)) |
| 383 | return mvi; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 384 | err_out: |
| 385 | mvs_free(mvi); |
| 386 | return NULL; |
| 387 | } |
| 388 | |
| 389 | /* move to PCI layer or libata core? */ |
| 390 | static int pci_go_64(struct pci_dev *pdev) |
| 391 | { |
| 392 | int rc; |
| 393 | |
| 394 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { |
| 395 | rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); |
| 396 | if (rc) { |
| 397 | rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
| 398 | if (rc) { |
| 399 | dev_printk(KERN_ERR, &pdev->dev, |
| 400 | "64-bit DMA enable failed\n"); |
| 401 | return rc; |
| 402 | } |
| 403 | } |
| 404 | } else { |
| 405 | rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
| 406 | if (rc) { |
| 407 | dev_printk(KERN_ERR, &pdev->dev, |
| 408 | "32-bit DMA enable failed\n"); |
| 409 | return rc; |
| 410 | } |
| 411 | rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
| 412 | if (rc) { |
| 413 | dev_printk(KERN_ERR, &pdev->dev, |
| 414 | "32-bit consistent DMA enable failed\n"); |
| 415 | return rc; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | return rc; |
| 420 | } |
| 421 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 422 | static int __devinit mvs_prep_sas_ha_init(struct Scsi_Host *shost, |
| 423 | const struct mvs_chip_info *chip_info) |
| 424 | { |
| 425 | int phy_nr, port_nr; unsigned short core_nr; |
| 426 | struct asd_sas_phy **arr_phy; |
| 427 | struct asd_sas_port **arr_port; |
| 428 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 429 | |
| 430 | core_nr = chip_info->n_host; |
| 431 | phy_nr = core_nr * chip_info->n_phy; |
| 432 | port_nr = phy_nr; |
| 433 | |
| 434 | memset(sha, 0x00, sizeof(struct sas_ha_struct)); |
| 435 | arr_phy = kcalloc(phy_nr, sizeof(void *), GFP_KERNEL); |
| 436 | arr_port = kcalloc(port_nr, sizeof(void *), GFP_KERNEL); |
| 437 | if (!arr_phy || !arr_port) |
| 438 | goto exit_free; |
| 439 | |
| 440 | sha->sas_phy = arr_phy; |
| 441 | sha->sas_port = arr_port; |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 442 | sha->core.shost = shost; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 443 | |
| 444 | sha->lldd_ha = kzalloc(sizeof(struct mvs_prv_info), GFP_KERNEL); |
| 445 | if (!sha->lldd_ha) |
| 446 | goto exit_free; |
| 447 | |
| 448 | ((struct mvs_prv_info *)sha->lldd_ha)->n_host = core_nr; |
| 449 | |
| 450 | shost->transportt = mvs_stt; |
| 451 | shost->max_id = 128; |
| 452 | shost->max_lun = ~0; |
| 453 | shost->max_channel = 1; |
| 454 | shost->max_cmd_len = 16; |
| 455 | |
| 456 | return 0; |
| 457 | exit_free: |
| 458 | kfree(arr_phy); |
| 459 | kfree(arr_port); |
| 460 | return -1; |
| 461 | |
| 462 | } |
| 463 | |
| 464 | static void __devinit mvs_post_sas_ha_init(struct Scsi_Host *shost, |
| 465 | const struct mvs_chip_info *chip_info) |
| 466 | { |
| 467 | int can_queue, i = 0, j = 0; |
| 468 | struct mvs_info *mvi = NULL; |
| 469 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 470 | unsigned short nr_core = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; |
| 471 | |
| 472 | for (j = 0; j < nr_core; j++) { |
| 473 | mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[j]; |
| 474 | for (i = 0; i < chip_info->n_phy; i++) { |
| 475 | sha->sas_phy[j * chip_info->n_phy + i] = |
| 476 | &mvi->phy[i].sas_phy; |
| 477 | sha->sas_port[j * chip_info->n_phy + i] = |
| 478 | &mvi->port[i].sas_port; |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | sha->sas_ha_name = DRV_NAME; |
| 483 | sha->dev = mvi->dev; |
| 484 | sha->lldd_module = THIS_MODULE; |
| 485 | sha->sas_addr = &mvi->sas_addr[0]; |
| 486 | |
| 487 | sha->num_phys = nr_core * chip_info->n_phy; |
| 488 | |
| 489 | sha->lldd_max_execute_num = 1; |
| 490 | |
| 491 | if (mvi->flags & MVF_FLAG_SOC) |
| 492 | can_queue = MVS_SOC_CAN_QUEUE; |
| 493 | else |
| 494 | can_queue = MVS_CAN_QUEUE; |
| 495 | |
| 496 | sha->lldd_queue_size = can_queue; |
| 497 | shost->can_queue = can_queue; |
| 498 | mvi->shost->cmd_per_lun = MVS_SLOTS/sha->num_phys; |
| 499 | sha->core.shost = mvi->shost; |
| 500 | } |
| 501 | |
| 502 | static void mvs_init_sas_add(struct mvs_info *mvi) |
| 503 | { |
| 504 | u8 i; |
| 505 | for (i = 0; i < mvi->chip->n_phy; i++) { |
| 506 | mvi->phy[i].dev_sas_addr = 0x5005043011ab0000ULL; |
| 507 | mvi->phy[i].dev_sas_addr = |
| 508 | cpu_to_be64((u64)(*(u64 *)&mvi->phy[i].dev_sas_addr)); |
| 509 | } |
| 510 | |
| 511 | memcpy(mvi->sas_addr, &mvi->phy[0].dev_sas_addr, SAS_ADDR_SIZE); |
| 512 | } |
| 513 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 514 | static int __devinit mvs_pci_init(struct pci_dev *pdev, |
| 515 | const struct pci_device_id *ent) |
| 516 | { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 517 | unsigned int rc, nhost = 0; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 518 | struct mvs_info *mvi; |
| 519 | irq_handler_t irq_handler = mvs_interrupt; |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 520 | struct Scsi_Host *shost = NULL; |
| 521 | const struct mvs_chip_info *chip; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 522 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 523 | dev_printk(KERN_INFO, &pdev->dev, |
| 524 | "mvsas: driver version %s\n", DRV_VERSION); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 525 | rc = pci_enable_device(pdev); |
| 526 | if (rc) |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 527 | goto err_out_enable; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 528 | |
| 529 | pci_set_master(pdev); |
| 530 | |
| 531 | rc = pci_request_regions(pdev, DRV_NAME); |
| 532 | if (rc) |
| 533 | goto err_out_disable; |
| 534 | |
| 535 | rc = pci_go_64(pdev); |
| 536 | if (rc) |
| 537 | goto err_out_regions; |
| 538 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 539 | shost = scsi_host_alloc(&mvs_sht, sizeof(void *)); |
| 540 | if (!shost) { |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 541 | rc = -ENOMEM; |
| 542 | goto err_out_regions; |
| 543 | } |
| 544 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 545 | chip = &mvs_chips[ent->driver_data]; |
| 546 | SHOST_TO_SAS_HA(shost) = |
| 547 | kcalloc(1, sizeof(struct sas_ha_struct), GFP_KERNEL); |
| 548 | if (!SHOST_TO_SAS_HA(shost)) { |
| 549 | kfree(shost); |
| 550 | rc = -ENOMEM; |
| 551 | goto err_out_regions; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 552 | } |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 553 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 554 | rc = mvs_prep_sas_ha_init(shost, chip); |
| 555 | if (rc) { |
| 556 | kfree(shost); |
| 557 | rc = -ENOMEM; |
| 558 | goto err_out_regions; |
| 559 | } |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 560 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 561 | pci_set_drvdata(pdev, SHOST_TO_SAS_HA(shost)); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 562 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 563 | do { |
| 564 | mvi = mvs_pci_alloc(pdev, ent, shost, nhost); |
| 565 | if (!mvi) { |
| 566 | rc = -ENOMEM; |
| 567 | goto err_out_regions; |
| 568 | } |
| 569 | |
| 570 | mvs_init_sas_add(mvi); |
| 571 | |
| 572 | mvi->instance = nhost; |
| 573 | rc = MVS_CHIP_DISP->chip_init(mvi); |
| 574 | if (rc) { |
| 575 | mvs_free(mvi); |
| 576 | goto err_out_regions; |
| 577 | } |
| 578 | nhost++; |
| 579 | } while (nhost < chip->n_host); |
Srinivas | 9dc9fd9 | 2010-02-15 00:00:00 -0600 | [diff] [blame] | 580 | #ifdef MVS_USE_TASKLET |
| 581 | tasklet_init(&mv_tasklet, mvs_tasklet, |
| 582 | (unsigned long)SHOST_TO_SAS_HA(shost)); |
| 583 | #endif |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 584 | |
| 585 | mvs_post_sas_ha_init(shost, chip); |
| 586 | |
| 587 | rc = scsi_add_host(shost, &pdev->dev); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 588 | if (rc) |
| 589 | goto err_out_shost; |
| 590 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 591 | rc = sas_register_ha(SHOST_TO_SAS_HA(shost)); |
| 592 | if (rc) |
| 593 | goto err_out_shost; |
| 594 | rc = request_irq(pdev->irq, irq_handler, IRQF_SHARED, |
| 595 | DRV_NAME, SHOST_TO_SAS_HA(shost)); |
| 596 | if (rc) |
| 597 | goto err_not_sas; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 598 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 599 | MVS_CHIP_DISP->interrupt_enable(mvi); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 600 | |
| 601 | scsi_scan_host(mvi->shost); |
| 602 | |
| 603 | return 0; |
| 604 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 605 | err_not_sas: |
| 606 | sas_unregister_ha(SHOST_TO_SAS_HA(shost)); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 607 | err_out_shost: |
| 608 | scsi_remove_host(mvi->shost); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 609 | err_out_regions: |
| 610 | pci_release_regions(pdev); |
| 611 | err_out_disable: |
| 612 | pci_disable_device(pdev); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 613 | err_out_enable: |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 614 | return rc; |
| 615 | } |
| 616 | |
| 617 | static void __devexit mvs_pci_remove(struct pci_dev *pdev) |
| 618 | { |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 619 | unsigned short core_nr, i = 0; |
| 620 | struct sas_ha_struct *sha = pci_get_drvdata(pdev); |
| 621 | struct mvs_info *mvi = NULL; |
| 622 | |
| 623 | core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; |
| 624 | mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; |
| 625 | |
| 626 | #ifdef MVS_USE_TASKLET |
| 627 | tasklet_kill(&mv_tasklet); |
| 628 | #endif |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 629 | |
| 630 | pci_set_drvdata(pdev, NULL); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 631 | sas_unregister_ha(sha); |
| 632 | sas_remove_host(mvi->shost); |
| 633 | scsi_remove_host(mvi->shost); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 634 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 635 | MVS_CHIP_DISP->interrupt_disable(mvi); |
| 636 | free_irq(mvi->irq, sha); |
| 637 | for (i = 0; i < core_nr; i++) { |
| 638 | mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 639 | mvs_free(mvi); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 640 | } |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 641 | kfree(sha->sas_phy); |
| 642 | kfree(sha->sas_port); |
| 643 | kfree(sha); |
| 644 | pci_release_regions(pdev); |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 645 | pci_disable_device(pdev); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 646 | return; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | static struct pci_device_id __devinitdata mvs_pci_table[] = { |
| 650 | { PCI_VDEVICE(MARVELL, 0x6320), chip_6320 }, |
| 651 | { PCI_VDEVICE(MARVELL, 0x6340), chip_6440 }, |
| 652 | { |
| 653 | .vendor = PCI_VENDOR_ID_MARVELL, |
| 654 | .device = 0x6440, |
| 655 | .subvendor = PCI_ANY_ID, |
| 656 | .subdevice = 0x6480, |
| 657 | .class = 0, |
| 658 | .class_mask = 0, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 659 | .driver_data = chip_6485, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 660 | }, |
| 661 | { PCI_VDEVICE(MARVELL, 0x6440), chip_6440 }, |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 662 | { PCI_VDEVICE(MARVELL, 0x6485), chip_6485 }, |
| 663 | { PCI_VDEVICE(MARVELL, 0x9480), chip_9480 }, |
| 664 | { PCI_VDEVICE(MARVELL, 0x9180), chip_9180 }, |
Nick Cheng | f31491d | 2009-09-08 19:03:07 +0800 | [diff] [blame] | 665 | { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1300), chip_1300 }, |
| 666 | { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1320), chip_1320 }, |
Srinivas | 7ec4ad0 | 2009-11-24 20:07:39 +0530 | [diff] [blame] | 667 | { PCI_VDEVICE(ADAPTEC2, 0x0450), chip_6440 }, |
HighPoint Linux Team | 463b897 | 2011-02-23 16:28:44 +0800 | [diff] [blame] | 668 | { PCI_VDEVICE(TTI, 0x2710), chip_9480 }, |
| 669 | { PCI_VDEVICE(TTI, 0x2720), chip_9480 }, |
| 670 | { PCI_VDEVICE(TTI, 0x2721), chip_9480 }, |
| 671 | { PCI_VDEVICE(TTI, 0x2722), chip_9480 }, |
| 672 | { PCI_VDEVICE(TTI, 0x2740), chip_9480 }, |
| 673 | { PCI_VDEVICE(TTI, 0x2744), chip_9480 }, |
| 674 | { PCI_VDEVICE(TTI, 0x2760), chip_9480 }, |
Xiangliang Yu | 8214028 | 2011-04-26 06:34:01 -0700 | [diff] [blame^] | 675 | { |
| 676 | .vendor = 0x1b4b, |
| 677 | .device = 0x9445, |
| 678 | .subvendor = PCI_ANY_ID, |
| 679 | .subdevice = 0x9480, |
| 680 | .class = 0, |
| 681 | .class_mask = 0, |
| 682 | .driver_data = chip_9445, |
| 683 | }, |
| 684 | { |
| 685 | .vendor = 0x1b4b, |
| 686 | .device = 0x9485, |
| 687 | .subvendor = PCI_ANY_ID, |
| 688 | .subdevice = 0x9480, |
| 689 | .class = 0, |
| 690 | .class_mask = 0, |
| 691 | .driver_data = chip_9485, |
| 692 | }, |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 693 | |
| 694 | { } /* terminate list */ |
| 695 | }; |
| 696 | |
| 697 | static struct pci_driver mvs_pci_driver = { |
| 698 | .name = DRV_NAME, |
| 699 | .id_table = mvs_pci_table, |
| 700 | .probe = mvs_pci_init, |
| 701 | .remove = __devexit_p(mvs_pci_remove), |
| 702 | }; |
| 703 | |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 704 | /* task handler */ |
| 705 | struct task_struct *mvs_th; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 706 | static int __init mvs_init(void) |
| 707 | { |
| 708 | int rc; |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 709 | mvs_stt = sas_domain_attach_transport(&mvs_transport_ops); |
| 710 | if (!mvs_stt) |
| 711 | return -ENOMEM; |
| 712 | |
| 713 | rc = pci_register_driver(&mvs_pci_driver); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 714 | |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 715 | if (rc) |
| 716 | goto err_out; |
| 717 | |
| 718 | return 0; |
| 719 | |
| 720 | err_out: |
| 721 | sas_release_transport(mvs_stt); |
| 722 | return rc; |
| 723 | } |
| 724 | |
| 725 | static void __exit mvs_exit(void) |
| 726 | { |
| 727 | pci_unregister_driver(&mvs_pci_driver); |
| 728 | sas_release_transport(mvs_stt); |
| 729 | } |
| 730 | |
| 731 | module_init(mvs_init); |
| 732 | module_exit(mvs_exit); |
| 733 | |
| 734 | MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>"); |
| 735 | MODULE_DESCRIPTION("Marvell 88SE6440 SAS/SATA controller driver"); |
| 736 | MODULE_VERSION(DRV_VERSION); |
| 737 | MODULE_LICENSE("GPL"); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 738 | #ifdef CONFIG_PCI |
Jeff Garzik | dd4969a | 2009-05-08 17:44:01 -0400 | [diff] [blame] | 739 | MODULE_DEVICE_TABLE(pci, mvs_pci_table); |
Andy Yan | 20b09c2 | 2009-05-08 17:46:40 -0400 | [diff] [blame] | 740 | #endif |