Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Access to HP-HIL MLC through HP System Device Controller. |
| 3 | * |
| 4 | * Copyright (c) 2001 Brian S. Julin |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions, and the following disclaimer, |
| 12 | * without modification. |
| 13 | * 2. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * Alternatively, this software may be distributed under the terms of the |
| 17 | * GNU General Public License ("GPL"). |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR |
| 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 28 | * |
| 29 | * References: |
| 30 | * HP-HIL Technical Reference Manual. Hewlett Packard Product No. 45918A |
| 31 | * System Device Controller Microprocessor Firmware Theory of Operation |
| 32 | * for Part Number 1820-4784 Revision B. Dwg No. A-1820-4784-2 |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | #include <linux/hil_mlc.h> |
| 37 | #include <linux/hp_sdc.h> |
| 38 | #include <linux/errno.h> |
| 39 | #include <linux/kernel.h> |
| 40 | #include <linux/module.h> |
| 41 | #include <linux/init.h> |
| 42 | #include <linux/string.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 43 | #include <asm/semaphore.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | #define PREFIX "HP SDC MLC: " |
| 46 | |
| 47 | static hil_mlc hp_sdc_mlc; |
| 48 | |
| 49 | MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); |
| 50 | MODULE_DESCRIPTION("Glue for onboard HIL MLC in HP-PARISC machines"); |
| 51 | MODULE_LICENSE("Dual BSD/GPL"); |
| 52 | |
| 53 | struct hp_sdc_mlc_priv_s { |
| 54 | int emtestmode; |
| 55 | hp_sdc_transaction trans; |
| 56 | u8 tseq[16]; |
| 57 | int got5x; |
| 58 | } hp_sdc_mlc_priv; |
| 59 | |
| 60 | /************************* Interrupt context ******************************/ |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 61 | static void hp_sdc_mlc_isr (int irq, void *dev_id, |
| 62 | uint8_t status, uint8_t data) |
| 63 | { |
| 64 | int idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | hil_mlc *mlc = &hp_sdc_mlc; |
| 66 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 67 | write_lock(&mlc->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | if (mlc->icount < 0) { |
| 69 | printk(KERN_WARNING PREFIX "HIL Overflow!\n"); |
| 70 | up(&mlc->isem); |
| 71 | goto out; |
| 72 | } |
| 73 | idx = 15 - mlc->icount; |
| 74 | if ((status & HP_SDC_STATUS_IRQMASK) == HP_SDC_STATUS_HILDATA) { |
| 75 | mlc->ipacket[idx] |= data | HIL_ERR_INT; |
| 76 | mlc->icount--; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 77 | if (hp_sdc_mlc_priv.got5x || !idx) |
| 78 | goto check; |
| 79 | if ((mlc->ipacket[idx - 1] & HIL_PKT_ADDR_MASK) != |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | (mlc->ipacket[idx] & HIL_PKT_ADDR_MASK)) { |
| 81 | mlc->ipacket[idx] &= ~HIL_PKT_ADDR_MASK; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 82 | mlc->ipacket[idx] |= (mlc->ipacket[idx - 1] |
| 83 | & HIL_PKT_ADDR_MASK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } |
| 85 | goto check; |
| 86 | } |
| 87 | /* We know status is 5X */ |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 88 | if (data & HP_SDC_HIL_ISERR) |
| 89 | goto err; |
| 90 | mlc->ipacket[idx] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | (data & HP_SDC_HIL_R1MASK) << HIL_PKT_ADDR_SHIFT; |
| 92 | hp_sdc_mlc_priv.got5x = 1; |
| 93 | goto out; |
| 94 | |
| 95 | check: |
| 96 | hp_sdc_mlc_priv.got5x = 0; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 97 | if (mlc->imatch == 0) |
| 98 | goto done; |
| 99 | if ((mlc->imatch == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) |
| 100 | && (mlc->ipacket[idx] == (mlc->imatch | idx))) |
| 101 | goto done; |
| 102 | if (mlc->ipacket[idx] == mlc->imatch) |
| 103 | goto done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | goto out; |
| 105 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 106 | err: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | printk(KERN_DEBUG PREFIX "err code %x\n", data); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | switch (data) { |
| 110 | case HP_SDC_HIL_RC_DONE: |
| 111 | printk(KERN_WARNING PREFIX "Bastard SDC reconfigured loop!\n"); |
| 112 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | case HP_SDC_HIL_ERR: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 115 | mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_PERR | |
| 116 | HIL_ERR_FERR | HIL_ERR_FOF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | case HP_SDC_HIL_TO: |
| 120 | mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_LERR; |
| 121 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | case HP_SDC_HIL_RC: |
| 124 | printk(KERN_WARNING PREFIX "Bastard SDC decided to reconfigure loop!\n"); |
| 125 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | default: |
| 128 | printk(KERN_WARNING PREFIX "Unkown HIL Error status (%x)!\n", data); |
| 129 | break; |
| 130 | } |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | /* No more data will be coming due to an error. */ |
| 133 | done: |
| 134 | tasklet_schedule(mlc->tasklet); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 135 | up(&mlc->isem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | out: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 137 | write_unlock(&mlc->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | |
| 141 | /******************** Tasklet or userspace context functions ****************/ |
| 142 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 143 | static int hp_sdc_mlc_in(hil_mlc *mlc, suseconds_t timeout) |
| 144 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | unsigned long flags; |
| 146 | struct hp_sdc_mlc_priv_s *priv; |
| 147 | int rc = 2; |
| 148 | |
| 149 | priv = mlc->priv; |
| 150 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 151 | write_lock_irqsave(&mlc->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | /* Try to down the semaphore */ |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 154 | if (down_trylock(&mlc->isem)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | struct timeval tv; |
| 156 | if (priv->emtestmode) { |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 157 | mlc->ipacket[0] = |
| 158 | HIL_ERR_INT | (mlc->opacket & |
| 159 | (HIL_PKT_CMD | |
| 160 | HIL_PKT_ADDR_MASK | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | HIL_PKT_DATA_MASK)); |
| 162 | mlc->icount = 14; |
| 163 | /* printk(KERN_DEBUG PREFIX ">[%x]\n", mlc->ipacket[0]); */ |
| 164 | goto wasup; |
| 165 | } |
| 166 | do_gettimeofday(&tv); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 167 | tv.tv_usec += USEC_PER_SEC * (tv.tv_sec - mlc->instart.tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | if (tv.tv_usec - mlc->instart.tv_usec > mlc->intimeout) { |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 169 | /* printk("!%i %i", |
| 170 | tv.tv_usec - mlc->instart.tv_usec, |
| 171 | mlc->intimeout); |
| 172 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | rc = 1; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 174 | up(&mlc->isem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | } |
| 176 | goto done; |
| 177 | } |
| 178 | wasup: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 179 | up(&mlc->isem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | rc = 0; |
| 181 | goto done; |
| 182 | done: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 183 | write_unlock_irqrestore(&mlc->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | return rc; |
| 185 | } |
| 186 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 187 | static int hp_sdc_mlc_cts(hil_mlc *mlc) |
| 188 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | struct hp_sdc_mlc_priv_s *priv; |
| 190 | unsigned long flags; |
| 191 | |
| 192 | priv = mlc->priv; |
| 193 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 194 | write_lock_irqsave(&mlc->lock, flags); |
| 195 | |
| 196 | /* Try to down the semaphores -- they should be up. */ |
| 197 | BUG_ON(down_trylock(&mlc->isem)); |
| 198 | BUG_ON(down_trylock(&mlc->osem)); |
| 199 | |
| 200 | up(&mlc->isem); |
| 201 | up(&mlc->osem); |
| 202 | |
| 203 | if (down_trylock(&mlc->csem)) { |
| 204 | if (priv->trans.act.semaphore != &mlc->csem) |
| 205 | goto poll; |
| 206 | else |
| 207 | goto busy; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 210 | if (!(priv->tseq[4] & HP_SDC_USE_LOOP)) |
| 211 | goto done; |
| 212 | |
| 213 | poll: |
| 214 | priv->trans.act.semaphore = &mlc->csem; |
| 215 | priv->trans.actidx = 0; |
| 216 | priv->trans.idx = 1; |
| 217 | priv->trans.endidx = 5; |
| 218 | priv->tseq[0] = |
| 219 | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE; |
| 220 | priv->tseq[1] = HP_SDC_CMD_READ_USE; |
| 221 | priv->tseq[2] = 1; |
| 222 | priv->tseq[3] = 0; |
| 223 | priv->tseq[4] = 0; |
| 224 | hp_sdc_enqueue_transaction(&priv->trans); |
| 225 | busy: |
| 226 | write_unlock_irqrestore(&mlc->lock, flags); |
| 227 | return 1; |
| 228 | done: |
| 229 | priv->trans.act.semaphore = &mlc->osem; |
| 230 | up(&mlc->csem); |
| 231 | write_unlock_irqrestore(&mlc->lock, flags); |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | static void hp_sdc_mlc_out(hil_mlc *mlc) |
| 236 | { |
| 237 | struct hp_sdc_mlc_priv_s *priv; |
| 238 | unsigned long flags; |
| 239 | |
| 240 | priv = mlc->priv; |
| 241 | |
| 242 | write_lock_irqsave(&mlc->lock, flags); |
| 243 | |
| 244 | /* Try to down the semaphore -- it should be up. */ |
| 245 | BUG_ON(down_trylock(&mlc->osem)); |
| 246 | |
| 247 | if (mlc->opacket & HIL_DO_ALTER_CTRL) |
| 248 | goto do_control; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
| 250 | do_data: |
| 251 | if (priv->emtestmode) { |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 252 | up(&mlc->osem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | goto done; |
| 254 | } |
| 255 | /* Shouldn't be sending commands when loop may be busy */ |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 256 | BUG_ON(down_trylock(&mlc->csem)); |
| 257 | up(&mlc->csem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | |
| 259 | priv->trans.actidx = 0; |
| 260 | priv->trans.idx = 1; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 261 | priv->trans.act.semaphore = &mlc->osem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | priv->trans.endidx = 6; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 263 | priv->tseq[0] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | HP_SDC_ACT_DATAREG | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_SEMAPHORE; |
| 265 | priv->tseq[1] = 0x7; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 266 | priv->tseq[2] = |
| 267 | (mlc->opacket & |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | (HIL_PKT_ADDR_MASK | HIL_PKT_CMD)) |
| 269 | >> HIL_PKT_ADDR_SHIFT; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 270 | priv->tseq[3] = |
| 271 | (mlc->opacket & HIL_PKT_DATA_MASK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | >> HIL_PKT_DATA_SHIFT; |
| 273 | priv->tseq[4] = 0; /* No timeout */ |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 274 | if (priv->tseq[3] == HIL_CMD_DHR) |
| 275 | priv->tseq[4] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | priv->tseq[5] = HP_SDC_CMD_DO_HIL; |
| 277 | goto enqueue; |
| 278 | |
| 279 | do_control: |
| 280 | priv->emtestmode = mlc->opacket & HIL_CTRL_TEST; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 281 | |
Eric Sesterhenn | fddaaae | 2006-03-26 18:23:47 +0200 | [diff] [blame] | 282 | /* we cannot emulate this, it should not be used. */ |
| 283 | BUG_ON((mlc->opacket & (HIL_CTRL_APE | HIL_CTRL_IPF)) == HIL_CTRL_APE); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 284 | |
| 285 | if ((mlc->opacket & HIL_CTRL_ONLY) == HIL_CTRL_ONLY) |
| 286 | goto control_only; |
| 287 | |
| 288 | /* Should not send command/data after engaging APE */ |
| 289 | BUG_ON(mlc->opacket & HIL_CTRL_APE); |
| 290 | |
| 291 | /* Disengaging APE this way would not be valid either since |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | * the loop must be allowed to idle. |
| 293 | * |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 294 | * So, it works out that we really never actually send control |
| 295 | * and data when using SDC, we just send the data. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | */ |
| 297 | goto do_data; |
| 298 | |
| 299 | control_only: |
| 300 | priv->trans.actidx = 0; |
| 301 | priv->trans.idx = 1; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 302 | priv->trans.act.semaphore = &mlc->osem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | priv->trans.endidx = 4; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 304 | priv->tseq[0] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | HP_SDC_ACT_PRECMD | HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE; |
| 306 | priv->tseq[1] = HP_SDC_CMD_SET_LPC; |
| 307 | priv->tseq[2] = 1; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 308 | /* priv->tseq[3] = (mlc->ddc + 1) | HP_SDC_LPS_ACSUCC; */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | priv->tseq[3] = 0; |
| 310 | if (mlc->opacket & HIL_CTRL_APE) { |
| 311 | priv->tseq[3] |= HP_SDC_LPC_APE_IPF; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 312 | down_trylock(&mlc->csem); |
| 313 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | enqueue: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 315 | hp_sdc_enqueue_transaction(&priv->trans); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | done: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 317 | write_unlock_irqrestore(&mlc->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | static int __init hp_sdc_mlc_init(void) |
| 321 | { |
| 322 | hil_mlc *mlc = &hp_sdc_mlc; |
| 323 | |
| 324 | printk(KERN_INFO PREFIX "Registering the System Domain Controller's HIL MLC.\n"); |
| 325 | |
| 326 | hp_sdc_mlc_priv.emtestmode = 0; |
| 327 | hp_sdc_mlc_priv.trans.seq = hp_sdc_mlc_priv.tseq; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 328 | hp_sdc_mlc_priv.trans.act.semaphore = &mlc->osem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | hp_sdc_mlc_priv.got5x = 0; |
| 330 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 331 | mlc->cts = &hp_sdc_mlc_cts; |
| 332 | mlc->in = &hp_sdc_mlc_in; |
| 333 | mlc->out = &hp_sdc_mlc_out; |
| 334 | mlc->priv = &hp_sdc_mlc_priv; |
Helge Deller | 3acaf54 | 2007-02-28 23:51:19 -0500 | [diff] [blame] | 335 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | if (hil_mlc_register(mlc)) { |
| 337 | printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n"); |
| 338 | goto err0; |
| 339 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
| 341 | if (hp_sdc_request_hil_irq(&hp_sdc_mlc_isr)) { |
| 342 | printk(KERN_WARNING PREFIX "Request for raw HIL ISR hook denied\n"); |
| 343 | goto err1; |
| 344 | } |
| 345 | return 0; |
| 346 | err1: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 347 | if (hil_mlc_unregister(mlc)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" |
| 349 | "This is bad. Could cause an oops.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | err0: |
| 351 | return -EBUSY; |
| 352 | } |
| 353 | |
| 354 | static void __exit hp_sdc_mlc_exit(void) |
| 355 | { |
| 356 | hil_mlc *mlc = &hp_sdc_mlc; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 357 | |
| 358 | if (hp_sdc_release_hil_irq(&hp_sdc_mlc_isr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | printk(KERN_ERR PREFIX "Failed to release the raw HIL ISR hook.\n" |
| 360 | "This is bad. Could cause an oops.\n"); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame^] | 361 | |
| 362 | if (hil_mlc_unregister(mlc)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" |
| 364 | "This is bad. Could cause an oops.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | module_init(hp_sdc_mlc_init); |
| 368 | module_exit(hp_sdc_mlc_exit); |