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> |
Matthew Wilcox | 6188e10 | 2008-04-18 22:21:05 -0400 | [diff] [blame] | 43 | #include <linux/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 | |
Adrian Bunk | fa14f7e | 2008-06-26 10:46:39 -0400 | [diff] [blame] | 53 | static struct hp_sdc_mlc_priv_s { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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: |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame^] | 128 | printk(KERN_WARNING PREFIX "Unknown HIL Error status (%x)!\n", data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | struct hp_sdc_mlc_priv_s *priv; |
| 146 | int rc = 2; |
| 147 | |
| 148 | priv = mlc->priv; |
| 149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | /* Try to down the semaphore */ |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 151 | if (down_trylock(&mlc->isem)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | struct timeval tv; |
| 153 | if (priv->emtestmode) { |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 154 | mlc->ipacket[0] = |
| 155 | HIL_ERR_INT | (mlc->opacket & |
| 156 | (HIL_PKT_CMD | |
| 157 | HIL_PKT_ADDR_MASK | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | HIL_PKT_DATA_MASK)); |
| 159 | mlc->icount = 14; |
| 160 | /* printk(KERN_DEBUG PREFIX ">[%x]\n", mlc->ipacket[0]); */ |
| 161 | goto wasup; |
| 162 | } |
| 163 | do_gettimeofday(&tv); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 164 | 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] | 165 | if (tv.tv_usec - mlc->instart.tv_usec > mlc->intimeout) { |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 166 | /* printk("!%i %i", |
| 167 | tv.tv_usec - mlc->instart.tv_usec, |
| 168 | mlc->intimeout); |
| 169 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | rc = 1; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 171 | up(&mlc->isem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | } |
| 173 | goto done; |
| 174 | } |
| 175 | wasup: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 176 | up(&mlc->isem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | rc = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | return rc; |
| 180 | } |
| 181 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 182 | static int hp_sdc_mlc_cts(hil_mlc *mlc) |
| 183 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | struct hp_sdc_mlc_priv_s *priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
| 186 | priv = mlc->priv; |
| 187 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 188 | /* Try to down the semaphores -- they should be up. */ |
| 189 | BUG_ON(down_trylock(&mlc->isem)); |
| 190 | BUG_ON(down_trylock(&mlc->osem)); |
| 191 | |
| 192 | up(&mlc->isem); |
| 193 | up(&mlc->osem); |
| 194 | |
| 195 | if (down_trylock(&mlc->csem)) { |
| 196 | if (priv->trans.act.semaphore != &mlc->csem) |
| 197 | goto poll; |
| 198 | else |
| 199 | goto busy; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 202 | if (!(priv->tseq[4] & HP_SDC_USE_LOOP)) |
| 203 | goto done; |
| 204 | |
| 205 | poll: |
| 206 | priv->trans.act.semaphore = &mlc->csem; |
| 207 | priv->trans.actidx = 0; |
| 208 | priv->trans.idx = 1; |
| 209 | priv->trans.endidx = 5; |
| 210 | priv->tseq[0] = |
| 211 | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE; |
| 212 | priv->tseq[1] = HP_SDC_CMD_READ_USE; |
| 213 | priv->tseq[2] = 1; |
| 214 | priv->tseq[3] = 0; |
| 215 | priv->tseq[4] = 0; |
Helge Deller | 9575499 | 2007-03-16 00:59:29 -0400 | [diff] [blame] | 216 | __hp_sdc_enqueue_transaction(&priv->trans); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 217 | busy: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 218 | return 1; |
| 219 | done: |
| 220 | priv->trans.act.semaphore = &mlc->osem; |
| 221 | up(&mlc->csem); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | static void hp_sdc_mlc_out(hil_mlc *mlc) |
| 226 | { |
| 227 | struct hp_sdc_mlc_priv_s *priv; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 228 | |
| 229 | priv = mlc->priv; |
| 230 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 231 | /* Try to down the semaphore -- it should be up. */ |
| 232 | BUG_ON(down_trylock(&mlc->osem)); |
| 233 | |
| 234 | if (mlc->opacket & HIL_DO_ALTER_CTRL) |
| 235 | goto do_control; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
| 237 | do_data: |
| 238 | if (priv->emtestmode) { |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 239 | up(&mlc->osem); |
Helge Deller | 9575499 | 2007-03-16 00:59:29 -0400 | [diff] [blame] | 240 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |
| 242 | /* Shouldn't be sending commands when loop may be busy */ |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 243 | BUG_ON(down_trylock(&mlc->csem)); |
| 244 | up(&mlc->csem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
| 246 | priv->trans.actidx = 0; |
| 247 | priv->trans.idx = 1; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 248 | priv->trans.act.semaphore = &mlc->osem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | priv->trans.endidx = 6; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 250 | priv->tseq[0] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | HP_SDC_ACT_DATAREG | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_SEMAPHORE; |
| 252 | priv->tseq[1] = 0x7; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 253 | priv->tseq[2] = |
| 254 | (mlc->opacket & |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | (HIL_PKT_ADDR_MASK | HIL_PKT_CMD)) |
| 256 | >> HIL_PKT_ADDR_SHIFT; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 257 | priv->tseq[3] = |
| 258 | (mlc->opacket & HIL_PKT_DATA_MASK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | >> HIL_PKT_DATA_SHIFT; |
| 260 | priv->tseq[4] = 0; /* No timeout */ |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 261 | if (priv->tseq[3] == HIL_CMD_DHR) |
| 262 | priv->tseq[4] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | priv->tseq[5] = HP_SDC_CMD_DO_HIL; |
| 264 | goto enqueue; |
| 265 | |
| 266 | do_control: |
| 267 | priv->emtestmode = mlc->opacket & HIL_CTRL_TEST; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 268 | |
Eric Sesterhenn | fddaaae | 2006-03-26 18:23:47 +0200 | [diff] [blame] | 269 | /* we cannot emulate this, it should not be used. */ |
| 270 | 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] | 271 | |
| 272 | if ((mlc->opacket & HIL_CTRL_ONLY) == HIL_CTRL_ONLY) |
| 273 | goto control_only; |
| 274 | |
| 275 | /* Should not send command/data after engaging APE */ |
| 276 | BUG_ON(mlc->opacket & HIL_CTRL_APE); |
| 277 | |
| 278 | /* Disengaging APE this way would not be valid either since |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | * the loop must be allowed to idle. |
| 280 | * |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 281 | * So, it works out that we really never actually send control |
| 282 | * and data when using SDC, we just send the data. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | */ |
| 284 | goto do_data; |
| 285 | |
| 286 | control_only: |
| 287 | priv->trans.actidx = 0; |
| 288 | priv->trans.idx = 1; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 289 | priv->trans.act.semaphore = &mlc->osem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | priv->trans.endidx = 4; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 291 | priv->tseq[0] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | HP_SDC_ACT_PRECMD | HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE; |
| 293 | priv->tseq[1] = HP_SDC_CMD_SET_LPC; |
| 294 | priv->tseq[2] = 1; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 295 | /* priv->tseq[3] = (mlc->ddc + 1) | HP_SDC_LPS_ACSUCC; */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | priv->tseq[3] = 0; |
| 297 | if (mlc->opacket & HIL_CTRL_APE) { |
| 298 | priv->tseq[3] |= HP_SDC_LPC_APE_IPF; |
Helge Deller | c6fe6b0 | 2009-08-02 15:13:29 +0200 | [diff] [blame] | 299 | BUG_ON(down_trylock(&mlc->csem)); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 300 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | enqueue: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 302 | hp_sdc_enqueue_transaction(&priv->trans); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | static int __init hp_sdc_mlc_init(void) |
| 306 | { |
| 307 | hil_mlc *mlc = &hp_sdc_mlc; |
| 308 | |
Geert Uytterhoeven | eb98630 | 2008-05-18 20:47:17 +0200 | [diff] [blame] | 309 | #ifdef __mc68000__ |
| 310 | if (!MACH_IS_HP300) |
| 311 | return -ENODEV; |
| 312 | #endif |
| 313 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | printk(KERN_INFO PREFIX "Registering the System Domain Controller's HIL MLC.\n"); |
| 315 | |
| 316 | hp_sdc_mlc_priv.emtestmode = 0; |
| 317 | hp_sdc_mlc_priv.trans.seq = hp_sdc_mlc_priv.tseq; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 318 | hp_sdc_mlc_priv.trans.act.semaphore = &mlc->osem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | hp_sdc_mlc_priv.got5x = 0; |
| 320 | |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 321 | mlc->cts = &hp_sdc_mlc_cts; |
| 322 | mlc->in = &hp_sdc_mlc_in; |
| 323 | mlc->out = &hp_sdc_mlc_out; |
| 324 | mlc->priv = &hp_sdc_mlc_priv; |
Helge Deller | 3acaf54 | 2007-02-28 23:51:19 -0500 | [diff] [blame] | 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | if (hil_mlc_register(mlc)) { |
| 327 | printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n"); |
| 328 | goto err0; |
| 329 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | |
| 331 | if (hp_sdc_request_hil_irq(&hp_sdc_mlc_isr)) { |
| 332 | printk(KERN_WARNING PREFIX "Request for raw HIL ISR hook denied\n"); |
| 333 | goto err1; |
| 334 | } |
| 335 | return 0; |
| 336 | err1: |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 337 | if (hil_mlc_unregister(mlc)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" |
| 339 | "This is bad. Could cause an oops.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | err0: |
| 341 | return -EBUSY; |
| 342 | } |
| 343 | |
| 344 | static void __exit hp_sdc_mlc_exit(void) |
| 345 | { |
| 346 | hil_mlc *mlc = &hp_sdc_mlc; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 347 | |
| 348 | if (hp_sdc_release_hil_irq(&hp_sdc_mlc_isr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | printk(KERN_ERR PREFIX "Failed to release the raw HIL ISR hook.\n" |
| 350 | "This is bad. Could cause an oops.\n"); |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 351 | |
| 352 | if (hil_mlc_unregister(mlc)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" |
| 354 | "This is bad. Could cause an oops.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | module_init(hp_sdc_mlc_init); |
| 358 | module_exit(hp_sdc_mlc_exit); |