Home | History | Annotate | Line # | Download | only in ppbus
      1 /* $NetBSD: ppbus_conf.h,v 1.12 2011/02/18 21:38:17 phx Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1997, 1998, 1999 Nicolas Souchu
      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  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  *
     28  * $FreeBSD: src/sys/dev/ppbus/ppbconf.h,v 1.17.2.1 2000/05/24 00:20:57 n_hibma Exp $
     29  *
     30  */
     31 #ifndef __PPBUS_CONF_H
     32 #define __PPBUS_CONF_H
     33 
     34 #include "gpio.h"
     35 
     36 #include <sys/device.h>
     37 #include <sys/gpio.h>
     38 #include <sys/mutex.h>
     39 #include <sys/queue.h>
     40 
     41 #include <sys/bus.h>
     42 
     43 #include <dev/ppbus/ppbus_msq.h>
     44 #include <dev/ppbus/ppbus_device.h>
     45 
     46 #if NGPIO > 0
     47 #include <dev/gpio/gpiovar.h>
     48 #define PPBUS_NPINS 17
     49 #endif
     50 
     51 /* Function pointer types used for interface */
     52 typedef u_char (*PARPORT_IO_T)(device_t, int, u_char *, int, u_char);
     53 typedef int (*PARPORT_EXEC_MICROSEQ_T)(device_t,
     54 	struct ppbus_microseq **);
     55 typedef void (*PARPORT_RESET_EPP_TIMEOUT_T)(device_t);
     56 typedef int (*PARPORT_SETMODE_T)(device_t, int);
     57 typedef int (*PARPORT_GETMODE_T)(device_t);
     58 typedef void (*PARPORT_ECP_SYNC_T)(device_t);
     59 typedef int (*PARPORT_READ_T)(device_t, char *, int, int, size_t *);
     60 typedef int (*PARPORT_WRITE_T)(device_t, char *, int, int, size_t *);
     61 typedef int (*PARPORT_READ_IVAR_T)(device_t, int, unsigned int *);
     62 typedef int (*PARPORT_WRITE_IVAR_T)(device_t, int, unsigned int *);
     63 typedef int (*PARPORT_DMA_MALLOC_T)(device_t, void **, bus_addr_t *,
     64 	bus_size_t);
     65 typedef void (*PARPORT_DMA_FREE_T)(device_t, void **, bus_addr_t *,
     66 	bus_size_t);
     67 typedef int (*PARPORT_ADD_HANDLER_T)(device_t, void (*)(void *),
     68 	void *);
     69 typedef int (*PARPORT_REMOVE_HANDLER_T)(device_t, void (*)(void *));
     70 
     71 /* Adapter structure that each parport device needs to implement ppbus */
     72 struct parport_adapter {
     73 	u_int16_t capabilities;
     74 
     75 	/* Functions which make up interface */
     76 	PARPORT_IO_T parport_io;
     77 	PARPORT_EXEC_MICROSEQ_T parport_exec_microseq;
     78 	PARPORT_RESET_EPP_TIMEOUT_T parport_reset_epp_timeout;
     79 	PARPORT_SETMODE_T parport_setmode;
     80 	PARPORT_GETMODE_T parport_getmode;
     81 	PARPORT_ECP_SYNC_T parport_ecp_sync;
     82 	PARPORT_READ_T parport_read;
     83 	PARPORT_WRITE_T parport_write;
     84 	PARPORT_READ_IVAR_T parport_read_ivar;
     85 	PARPORT_WRITE_IVAR_T parport_write_ivar;
     86 	PARPORT_DMA_MALLOC_T parport_dma_malloc;
     87 	PARPORT_DMA_FREE_T parport_dma_free;
     88 	PARPORT_ADD_HANDLER_T parport_add_handler;
     89 	PARPORT_REMOVE_HANDLER_T parport_remove_handler;
     90 };
     91 
     92 /* Parallel Port Bus configuration structure. */
     93 struct ppbus_softc {
     94         device_t sc_dev;
     95 
     96 	/* Lock for critical section when requesting/releasing the bus */
     97 	kmutex_t sc_lock;
     98 
     99 #define PPBUS_OK 1
    100 #define PPBUS_NOK 0
    101 	u_int8_t sc_dev_ok;
    102 
    103 	/* ppbus capabilities (see ppbus_var.h) */
    104 	u_int16_t sc_capabilities;
    105 
    106 /* PnP device type defined in ppbus_var.h */
    107 	int sc_class_id;		/* not a PnP device if class_id < 0 */
    108 
    109 	/* Defined in pbus_1284.h: error and host side state. */
    110 	u_int32_t sc_1284_state;	/* current IEEE1284 state */
    111 	u_int32_t sc_1284_error;	/* last IEEE1284 error */
    112 
    113 	/* Use IEEE 1284 negotiations in mode changes and direction changes */
    114 	u_int32_t sc_use_ieee;
    115 
    116 /* PPBUS mode masks defined in ppbus_var.h. */
    117 	u_int32_t sc_mode;		/* IEEE 1284-1994 mode */
    118 
    119 	/* ppbus_device which owns the bus */
    120 	device_t ppbus_owner;
    121 
    122 	/* Head of list of child devices */
    123 	SLIST_HEAD(childlist, ppbus_device_softc) sc_childlist_head;
    124 
    125 	/* Functions which make up interface */
    126 	PARPORT_IO_T ppbus_io;
    127 	PARPORT_EXEC_MICROSEQ_T ppbus_exec_microseq;
    128 	PARPORT_RESET_EPP_TIMEOUT_T ppbus_reset_epp_timeout;
    129 	PARPORT_SETMODE_T ppbus_setmode;
    130 	PARPORT_GETMODE_T ppbus_getmode;
    131 	PARPORT_ECP_SYNC_T ppbus_ecp_sync;
    132 	PARPORT_READ_T ppbus_read;
    133 	PARPORT_WRITE_T ppbus_write;
    134         PARPORT_READ_IVAR_T ppbus_read_ivar;
    135         PARPORT_WRITE_IVAR_T ppbus_write_ivar;
    136 	PARPORT_DMA_MALLOC_T ppbus_dma_malloc;
    137 	PARPORT_DMA_FREE_T ppbus_dma_free;
    138 	PARPORT_ADD_HANDLER_T ppbus_add_handler;
    139 	PARPORT_REMOVE_HANDLER_T ppbus_remove_handler;
    140 
    141 #if NGPIO > 0
    142 	struct gpio_chipset_tag sc_gpio_gc;
    143 	gpio_pin_t sc_gpio_pins[PPBUS_NPINS];
    144 #endif
    145 };
    146 
    147 #if NGPIO > 0
    148 void gpio_ppbus_attach(struct ppbus_softc *);
    149 #endif
    150 
    151 #endif /* __PPBUS_CONF_H */
    152