xref: /openbmc/linux/drivers/input/serio/hp_sdc_mlc.c (revision 879bc2d2)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * Access to HP-HIL MLC through HP System Device Controller.
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Copyright (c) 2001 Brian S. Julin
51da177e4SLinus Torvalds  * All rights reserved.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  * Redistribution and use in source and binary forms, with or without
81da177e4SLinus Torvalds  * modification, are permitted provided that the following conditions
91da177e4SLinus Torvalds  * are met:
101da177e4SLinus Torvalds  * 1. Redistributions of source code must retain the above copyright
111da177e4SLinus Torvalds  *    notice, this list of conditions, and the following disclaimer,
121da177e4SLinus Torvalds  *    without modification.
131da177e4SLinus Torvalds  * 2. The name of the author may not be used to endorse or promote products
141da177e4SLinus Torvalds  *    derived from this software without specific prior written permission.
151da177e4SLinus Torvalds  *
161da177e4SLinus Torvalds  * Alternatively, this software may be distributed under the terms of the
171da177e4SLinus Torvalds  * GNU General Public License ("GPL").
181da177e4SLinus Torvalds  *
191da177e4SLinus Torvalds  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
201da177e4SLinus Torvalds  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
211da177e4SLinus Torvalds  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
221da177e4SLinus Torvalds  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
231da177e4SLinus Torvalds  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241da177e4SLinus Torvalds  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
251da177e4SLinus Torvalds  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
261da177e4SLinus Torvalds  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
271da177e4SLinus Torvalds  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281da177e4SLinus Torvalds  *
291da177e4SLinus Torvalds  * References:
301da177e4SLinus Torvalds  * HP-HIL Technical Reference Manual.  Hewlett Packard Product No. 45918A
311da177e4SLinus Torvalds  * System Device Controller Microprocessor Firmware Theory of Operation
321da177e4SLinus Torvalds  *      for Part Number 1820-4784 Revision B.  Dwg No. A-1820-4784-2
331da177e4SLinus Torvalds  *
341da177e4SLinus Torvalds  */
351da177e4SLinus Torvalds 
361da177e4SLinus Torvalds #include <linux/hil_mlc.h>
371da177e4SLinus Torvalds #include <linux/hp_sdc.h>
381da177e4SLinus Torvalds #include <linux/errno.h>
391da177e4SLinus Torvalds #include <linux/kernel.h>
401da177e4SLinus Torvalds #include <linux/module.h>
411da177e4SLinus Torvalds #include <linux/init.h>
421da177e4SLinus Torvalds #include <linux/string.h>
436188e10dSMatthew Wilcox #include <linux/semaphore.h>
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds #define PREFIX "HP SDC MLC: "
461da177e4SLinus Torvalds 
471da177e4SLinus Torvalds static hil_mlc hp_sdc_mlc;
481da177e4SLinus Torvalds 
491da177e4SLinus Torvalds MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
501da177e4SLinus Torvalds MODULE_DESCRIPTION("Glue for onboard HIL MLC in HP-PARISC machines");
511da177e4SLinus Torvalds MODULE_LICENSE("Dual BSD/GPL");
521da177e4SLinus Torvalds 
53fa14f7e8SAdrian Bunk static struct hp_sdc_mlc_priv_s {
541da177e4SLinus Torvalds 	int emtestmode;
551da177e4SLinus Torvalds 	hp_sdc_transaction trans;
561da177e4SLinus Torvalds 	u8 tseq[16];
571da177e4SLinus Torvalds 	int got5x;
581da177e4SLinus Torvalds } hp_sdc_mlc_priv;
591da177e4SLinus Torvalds 
601da177e4SLinus Torvalds /************************* Interrupt context ******************************/
hp_sdc_mlc_isr(int irq,void * dev_id,uint8_t status,uint8_t data)611da177e4SLinus Torvalds static void hp_sdc_mlc_isr (int irq, void *dev_id,
62ffd51f46SHelge Deller 			    uint8_t status, uint8_t data)
63ffd51f46SHelge Deller {
641da177e4SLinus Torvalds 	int idx;
651da177e4SLinus Torvalds 	hil_mlc *mlc = &hp_sdc_mlc;
661da177e4SLinus Torvalds 
67ffd51f46SHelge Deller 	write_lock(&mlc->lock);
681da177e4SLinus Torvalds 	if (mlc->icount < 0) {
691da177e4SLinus Torvalds 		printk(KERN_WARNING PREFIX "HIL Overflow!\n");
701da177e4SLinus Torvalds 		up(&mlc->isem);
711da177e4SLinus Torvalds 		goto out;
721da177e4SLinus Torvalds 	}
731da177e4SLinus Torvalds 	idx = 15 - mlc->icount;
741da177e4SLinus Torvalds 	if ((status & HP_SDC_STATUS_IRQMASK) == HP_SDC_STATUS_HILDATA) {
751da177e4SLinus Torvalds 		mlc->ipacket[idx] |= data | HIL_ERR_INT;
761da177e4SLinus Torvalds 		mlc->icount--;
77ffd51f46SHelge Deller 		if (hp_sdc_mlc_priv.got5x || !idx)
78ffd51f46SHelge Deller 			goto check;
791da177e4SLinus Torvalds 		if ((mlc->ipacket[idx - 1] & HIL_PKT_ADDR_MASK) !=
801da177e4SLinus Torvalds 		    (mlc->ipacket[idx] & HIL_PKT_ADDR_MASK)) {
811da177e4SLinus Torvalds 			mlc->ipacket[idx] &= ~HIL_PKT_ADDR_MASK;
821da177e4SLinus Torvalds 			mlc->ipacket[idx] |= (mlc->ipacket[idx - 1]
831da177e4SLinus Torvalds 						& HIL_PKT_ADDR_MASK);
841da177e4SLinus Torvalds 		}
851da177e4SLinus Torvalds 		goto check;
861da177e4SLinus Torvalds 	}
871da177e4SLinus Torvalds 	/* We know status is 5X */
88ffd51f46SHelge Deller 	if (data & HP_SDC_HIL_ISERR)
89ffd51f46SHelge Deller 		goto err;
901da177e4SLinus Torvalds 	mlc->ipacket[idx] =
911da177e4SLinus Torvalds 		(data & HP_SDC_HIL_R1MASK) << HIL_PKT_ADDR_SHIFT;
921da177e4SLinus Torvalds 	hp_sdc_mlc_priv.got5x = 1;
931da177e4SLinus Torvalds 	goto out;
941da177e4SLinus Torvalds 
951da177e4SLinus Torvalds  check:
961da177e4SLinus Torvalds 	hp_sdc_mlc_priv.got5x = 0;
97ffd51f46SHelge Deller 	if (mlc->imatch == 0)
98ffd51f46SHelge Deller 		goto done;
991da177e4SLinus Torvalds 	if ((mlc->imatch == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL))
100ffd51f46SHelge Deller 	    && (mlc->ipacket[idx] == (mlc->imatch | idx)))
101ffd51f46SHelge Deller 		goto done;
102ffd51f46SHelge Deller 	if (mlc->ipacket[idx] == mlc->imatch)
103ffd51f46SHelge Deller 		goto done;
1041da177e4SLinus Torvalds 	goto out;
1051da177e4SLinus Torvalds 
1061da177e4SLinus Torvalds  err:
1071da177e4SLinus Torvalds 	printk(KERN_DEBUG PREFIX "err code %x\n", data);
108ffd51f46SHelge Deller 
1091da177e4SLinus Torvalds 	switch (data) {
1101da177e4SLinus Torvalds 	case HP_SDC_HIL_RC_DONE:
1111da177e4SLinus Torvalds 		printk(KERN_WARNING PREFIX "Bastard SDC reconfigured loop!\n");
1121da177e4SLinus Torvalds 		break;
113ffd51f46SHelge Deller 
1141da177e4SLinus Torvalds 	case HP_SDC_HIL_ERR:
1151da177e4SLinus Torvalds 		mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_PERR |
1161da177e4SLinus Torvalds 					HIL_ERR_FERR | HIL_ERR_FOF;
1171da177e4SLinus Torvalds 		break;
118ffd51f46SHelge Deller 
1191da177e4SLinus Torvalds 	case HP_SDC_HIL_TO:
1201da177e4SLinus Torvalds 		mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_LERR;
1211da177e4SLinus Torvalds 		break;
122ffd51f46SHelge Deller 
1231da177e4SLinus Torvalds 	case HP_SDC_HIL_RC:
1241da177e4SLinus Torvalds 		printk(KERN_WARNING PREFIX "Bastard SDC decided to reconfigure loop!\n");
1251da177e4SLinus Torvalds 		break;
126ffd51f46SHelge Deller 
1271da177e4SLinus Torvalds 	default:
128af901ca1SAndré Goddard Rosa 		printk(KERN_WARNING PREFIX "Unknown HIL Error status (%x)!\n", data);
1291da177e4SLinus Torvalds 		break;
1301da177e4SLinus Torvalds 	}
131ffd51f46SHelge Deller 
1321da177e4SLinus Torvalds 	/* No more data will be coming due to an error. */
1331da177e4SLinus Torvalds  done:
1341da177e4SLinus Torvalds 	tasklet_schedule(mlc->tasklet);
135ffd51f46SHelge Deller 	up(&mlc->isem);
1361da177e4SLinus Torvalds  out:
137ffd51f46SHelge Deller 	write_unlock(&mlc->lock);
1381da177e4SLinus Torvalds }
1391da177e4SLinus Torvalds 
1401da177e4SLinus Torvalds 
1411da177e4SLinus Torvalds /******************** Tasklet or userspace context functions ****************/
1421da177e4SLinus Torvalds 
hp_sdc_mlc_in(hil_mlc * mlc,suseconds_t timeout)143ffd51f46SHelge Deller static int hp_sdc_mlc_in(hil_mlc *mlc, suseconds_t timeout)
144ffd51f46SHelge Deller {
1451da177e4SLinus Torvalds 	struct hp_sdc_mlc_priv_s *priv;
1461da177e4SLinus Torvalds 	int rc = 2;
1471da177e4SLinus Torvalds 
1481da177e4SLinus Torvalds 	priv = mlc->priv;
1491da177e4SLinus Torvalds 
1501da177e4SLinus Torvalds 	/* Try to down the semaphore */
151ffd51f46SHelge Deller 	if (down_trylock(&mlc->isem)) {
1521da177e4SLinus Torvalds 		if (priv->emtestmode) {
1531da177e4SLinus Torvalds 			mlc->ipacket[0] =
1541da177e4SLinus Torvalds 				HIL_ERR_INT | (mlc->opacket &
1551da177e4SLinus Torvalds 					       (HIL_PKT_CMD |
1561da177e4SLinus Torvalds 						HIL_PKT_ADDR_MASK |
1571da177e4SLinus Torvalds 						HIL_PKT_DATA_MASK));
1581da177e4SLinus Torvalds 			mlc->icount = 14;
1591da177e4SLinus Torvalds 			/* printk(KERN_DEBUG PREFIX ">[%x]\n", mlc->ipacket[0]); */
1601da177e4SLinus Torvalds 			goto wasup;
1611da177e4SLinus Torvalds 		}
16259d805afSWEN Pingbo 		if (time_after(jiffies, mlc->instart + mlc->intimeout)) {
1631da177e4SLinus Torvalds 			/*	printk("!%i %i",
1641da177e4SLinus Torvalds 				tv.tv_usec - mlc->instart.tv_usec,
1651da177e4SLinus Torvalds 				mlc->intimeout);
1661da177e4SLinus Torvalds 			 */
1671da177e4SLinus Torvalds 			rc = 1;
168ffd51f46SHelge Deller 			up(&mlc->isem);
1691da177e4SLinus Torvalds 		}
1701da177e4SLinus Torvalds 		goto done;
1711da177e4SLinus Torvalds 	}
1721da177e4SLinus Torvalds  wasup:
173ffd51f46SHelge Deller 	up(&mlc->isem);
1741da177e4SLinus Torvalds 	rc = 0;
1751da177e4SLinus Torvalds  done:
1761da177e4SLinus Torvalds 	return rc;
1771da177e4SLinus Torvalds }
1781da177e4SLinus Torvalds 
hp_sdc_mlc_cts(hil_mlc * mlc)179ffd51f46SHelge Deller static int hp_sdc_mlc_cts(hil_mlc *mlc)
180ffd51f46SHelge Deller {
1811da177e4SLinus Torvalds 	struct hp_sdc_mlc_priv_s *priv;
1821da177e4SLinus Torvalds 
1831da177e4SLinus Torvalds 	priv = mlc->priv;
1841da177e4SLinus Torvalds 
1851da177e4SLinus Torvalds 	/* Try to down the semaphores -- they should be up. */
186ffd51f46SHelge Deller 	BUG_ON(down_trylock(&mlc->isem));
187ffd51f46SHelge Deller 	BUG_ON(down_trylock(&mlc->osem));
1881da177e4SLinus Torvalds 
189ffd51f46SHelge Deller 	up(&mlc->isem);
190ffd51f46SHelge Deller 	up(&mlc->osem);
191ffd51f46SHelge Deller 
192ffd51f46SHelge Deller 	if (down_trylock(&mlc->csem)) {
193ffd51f46SHelge Deller 		if (priv->trans.act.semaphore != &mlc->csem)
194ffd51f46SHelge Deller 			goto poll;
195ffd51f46SHelge Deller 		else
1961da177e4SLinus Torvalds 			goto busy;
1971da177e4SLinus Torvalds 	}
198ffd51f46SHelge Deller 
199ffd51f46SHelge Deller 	if (!(priv->tseq[4] & HP_SDC_USE_LOOP))
200ffd51f46SHelge Deller 		goto done;
2011da177e4SLinus Torvalds 
2021da177e4SLinus Torvalds  poll:
203ffd51f46SHelge Deller 	priv->trans.act.semaphore = &mlc->csem;
2041da177e4SLinus Torvalds 	priv->trans.actidx = 0;
2051da177e4SLinus Torvalds 	priv->trans.idx = 1;
2061da177e4SLinus Torvalds 	priv->trans.endidx = 5;
2071da177e4SLinus Torvalds 	priv->tseq[0] =
2081da177e4SLinus Torvalds 		HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE;
2091da177e4SLinus Torvalds 	priv->tseq[1] = HP_SDC_CMD_READ_USE;
2101da177e4SLinus Torvalds 	priv->tseq[2] = 1;
2111da177e4SLinus Torvalds 	priv->tseq[3] = 0;
2121da177e4SLinus Torvalds 	priv->tseq[4] = 0;
213879bc2d2SHelge Deller 	return __hp_sdc_enqueue_transaction(&priv->trans);
2141da177e4SLinus Torvalds  busy:
2151da177e4SLinus Torvalds 	return 1;
2161da177e4SLinus Torvalds  done:
217ffd51f46SHelge Deller 	priv->trans.act.semaphore = &mlc->osem;
218ffd51f46SHelge Deller 	up(&mlc->csem);
2191da177e4SLinus Torvalds 	return 0;
2201da177e4SLinus Torvalds }
2211da177e4SLinus Torvalds 
hp_sdc_mlc_out(hil_mlc * mlc)222879bc2d2SHelge Deller static int hp_sdc_mlc_out(hil_mlc *mlc)
223ffd51f46SHelge Deller {
2241da177e4SLinus Torvalds 	struct hp_sdc_mlc_priv_s *priv;
2251da177e4SLinus Torvalds 
2261da177e4SLinus Torvalds 	priv = mlc->priv;
2271da177e4SLinus Torvalds 
2281da177e4SLinus Torvalds 	/* Try to down the semaphore -- it should be up. */
229ffd51f46SHelge Deller 	BUG_ON(down_trylock(&mlc->osem));
2301da177e4SLinus Torvalds 
231ffd51f46SHelge Deller 	if (mlc->opacket & HIL_DO_ALTER_CTRL)
232ffd51f46SHelge Deller 		goto do_control;
2331da177e4SLinus Torvalds 
2341da177e4SLinus Torvalds  do_data:
2351da177e4SLinus Torvalds 	if (priv->emtestmode) {
236ffd51f46SHelge Deller 		up(&mlc->osem);
237879bc2d2SHelge Deller 		return 0;
2381da177e4SLinus Torvalds 	}
2391da177e4SLinus Torvalds 	/* Shouldn't be sending commands when loop may be busy */
240ffd51f46SHelge Deller 	BUG_ON(down_trylock(&mlc->csem));
241ffd51f46SHelge Deller 	up(&mlc->csem);
2421da177e4SLinus Torvalds 
2431da177e4SLinus Torvalds 	priv->trans.actidx = 0;
2441da177e4SLinus Torvalds 	priv->trans.idx = 1;
245ffd51f46SHelge Deller 	priv->trans.act.semaphore = &mlc->osem;
2461da177e4SLinus Torvalds 	priv->trans.endidx = 6;
2471da177e4SLinus Torvalds 	priv->tseq[0] =
2481da177e4SLinus Torvalds 		HP_SDC_ACT_DATAREG | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_SEMAPHORE;
2491da177e4SLinus Torvalds 	priv->tseq[1] = 0x7;
2501da177e4SLinus Torvalds 	priv->tseq[2] =
2511da177e4SLinus Torvalds 		(mlc->opacket &
2521da177e4SLinus Torvalds 		 (HIL_PKT_ADDR_MASK | HIL_PKT_CMD))
2531da177e4SLinus Torvalds 		   >> HIL_PKT_ADDR_SHIFT;
2541da177e4SLinus Torvalds 	priv->tseq[3] =
2551da177e4SLinus Torvalds 		(mlc->opacket & HIL_PKT_DATA_MASK)
2561da177e4SLinus Torvalds 		  >> HIL_PKT_DATA_SHIFT;
2571da177e4SLinus Torvalds 	priv->tseq[4] = 0;  /* No timeout */
258ffd51f46SHelge Deller 	if (priv->tseq[3] == HIL_CMD_DHR)
259ffd51f46SHelge Deller 		priv->tseq[4] = 1;
2601da177e4SLinus Torvalds 	priv->tseq[5] = HP_SDC_CMD_DO_HIL;
2611da177e4SLinus Torvalds 	goto enqueue;
2621da177e4SLinus Torvalds 
2631da177e4SLinus Torvalds  do_control:
2641da177e4SLinus Torvalds 	priv->emtestmode = mlc->opacket & HIL_CTRL_TEST;
265fddaaae1SEric Sesterhenn 
266fddaaae1SEric Sesterhenn 	/* we cannot emulate this, it should not be used. */
267fddaaae1SEric Sesterhenn 	BUG_ON((mlc->opacket & (HIL_CTRL_APE | HIL_CTRL_IPF)) == HIL_CTRL_APE);
268fddaaae1SEric Sesterhenn 
269ffd51f46SHelge Deller 	if ((mlc->opacket & HIL_CTRL_ONLY) == HIL_CTRL_ONLY)
270ffd51f46SHelge Deller 		goto control_only;
271ffd51f46SHelge Deller 
272ffd51f46SHelge Deller 	/* Should not send command/data after engaging APE */
273ffd51f46SHelge Deller 	BUG_ON(mlc->opacket & HIL_CTRL_APE);
274ffd51f46SHelge Deller 
2751da177e4SLinus Torvalds 	/* Disengaging APE this way would not be valid either since
2761da177e4SLinus Torvalds 	 * the loop must be allowed to idle.
2771da177e4SLinus Torvalds 	 *
2781da177e4SLinus Torvalds 	 * So, it works out that we really never actually send control
2791da177e4SLinus Torvalds 	 * and data when using SDC, we just send the data.
2801da177e4SLinus Torvalds 	 */
2811da177e4SLinus Torvalds 	goto do_data;
2821da177e4SLinus Torvalds 
2831da177e4SLinus Torvalds  control_only:
2841da177e4SLinus Torvalds 	priv->trans.actidx = 0;
2851da177e4SLinus Torvalds 	priv->trans.idx = 1;
286ffd51f46SHelge Deller 	priv->trans.act.semaphore = &mlc->osem;
2871da177e4SLinus Torvalds 	priv->trans.endidx = 4;
2881da177e4SLinus Torvalds 	priv->tseq[0] =
2891da177e4SLinus Torvalds 	  HP_SDC_ACT_PRECMD | HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE;
2901da177e4SLinus Torvalds 	priv->tseq[1] = HP_SDC_CMD_SET_LPC;
2911da177e4SLinus Torvalds 	priv->tseq[2] = 1;
292ffd51f46SHelge Deller 	/* priv->tseq[3] = (mlc->ddc + 1) | HP_SDC_LPS_ACSUCC; */
2931da177e4SLinus Torvalds 	priv->tseq[3] = 0;
2941da177e4SLinus Torvalds 	if (mlc->opacket & HIL_CTRL_APE) {
2951da177e4SLinus Torvalds 		priv->tseq[3] |= HP_SDC_LPC_APE_IPF;
296c6fe6b07SHelge Deller 		BUG_ON(down_trylock(&mlc->csem));
2971da177e4SLinus Torvalds 	}
2981da177e4SLinus Torvalds  enqueue:
299879bc2d2SHelge Deller 	return hp_sdc_enqueue_transaction(&priv->trans);
3001da177e4SLinus Torvalds }
3011da177e4SLinus Torvalds 
hp_sdc_mlc_init(void)3021da177e4SLinus Torvalds static int __init hp_sdc_mlc_init(void)
3031da177e4SLinus Torvalds {
3041da177e4SLinus Torvalds 	hil_mlc *mlc = &hp_sdc_mlc;
30539de5210SJesper Juhl 	int err;
3061da177e4SLinus Torvalds 
307eb98630bSGeert Uytterhoeven #ifdef __mc68000__
308eb98630bSGeert Uytterhoeven 	if (!MACH_IS_HP300)
309eb98630bSGeert Uytterhoeven 		return -ENODEV;
310eb98630bSGeert Uytterhoeven #endif
311eb98630bSGeert Uytterhoeven 
3121da177e4SLinus Torvalds 	printk(KERN_INFO PREFIX "Registering the System Domain Controller's HIL MLC.\n");
3131da177e4SLinus Torvalds 
3141da177e4SLinus Torvalds 	hp_sdc_mlc_priv.emtestmode = 0;
3151da177e4SLinus Torvalds 	hp_sdc_mlc_priv.trans.seq = hp_sdc_mlc_priv.tseq;
316ffd51f46SHelge Deller 	hp_sdc_mlc_priv.trans.act.semaphore = &mlc->osem;
3171da177e4SLinus Torvalds 	hp_sdc_mlc_priv.got5x = 0;
3181da177e4SLinus Torvalds 
3191da177e4SLinus Torvalds 	mlc->cts = &hp_sdc_mlc_cts;
3201da177e4SLinus Torvalds 	mlc->in	= &hp_sdc_mlc_in;
3211da177e4SLinus Torvalds 	mlc->out = &hp_sdc_mlc_out;
3223acaf540SHelge Deller 	mlc->priv = &hp_sdc_mlc_priv;
3233acaf540SHelge Deller 
32439de5210SJesper Juhl 	err = hil_mlc_register(mlc);
32539de5210SJesper Juhl 	if (err) {
3261da177e4SLinus Torvalds 		printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n");
32739de5210SJesper Juhl 		return err;
3281da177e4SLinus Torvalds 	}
3291da177e4SLinus Torvalds 
3301da177e4SLinus Torvalds 	if (hp_sdc_request_hil_irq(&hp_sdc_mlc_isr)) {
3311da177e4SLinus Torvalds 		printk(KERN_WARNING PREFIX "Request for raw HIL ISR hook denied\n");
332ffd51f46SHelge Deller 		if (hil_mlc_unregister(mlc))
3331da177e4SLinus Torvalds 			printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n"
3341da177e4SLinus Torvalds 				"This is bad.  Could cause an oops.\n");
3351da177e4SLinus Torvalds 		return -EBUSY;
3361da177e4SLinus Torvalds 	}
3371da177e4SLinus Torvalds 
33839de5210SJesper Juhl 	return 0;
33939de5210SJesper Juhl }
34039de5210SJesper Juhl 
hp_sdc_mlc_exit(void)3411da177e4SLinus Torvalds static void __exit hp_sdc_mlc_exit(void)
3421da177e4SLinus Torvalds {
3431da177e4SLinus Torvalds 	hil_mlc *mlc = &hp_sdc_mlc;
344ffd51f46SHelge Deller 
345ffd51f46SHelge Deller 	if (hp_sdc_release_hil_irq(&hp_sdc_mlc_isr))
3461da177e4SLinus Torvalds 		printk(KERN_ERR PREFIX "Failed to release the raw HIL ISR hook.\n"
3471da177e4SLinus Torvalds 			"This is bad.  Could cause an oops.\n");
348ffd51f46SHelge Deller 
349ffd51f46SHelge Deller 	if (hil_mlc_unregister(mlc))
3501da177e4SLinus Torvalds 		printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n"
3511da177e4SLinus Torvalds 			"This is bad.  Could cause an oops.\n");
3521da177e4SLinus Torvalds }
3531da177e4SLinus Torvalds 
3541da177e4SLinus Torvalds module_init(hp_sdc_mlc_init);
3551da177e4SLinus Torvalds module_exit(hp_sdc_mlc_exit);
356