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