scc_bfe.h revision 157351
1145479Smp/*- 259243Sobrien * Copyright (c) 2004-2006 Marcel Moolenaar 359243Sobrien * All rights reserved. 459243Sobrien * 559243Sobrien * Redistribution and use in source and binary forms, with or without 659243Sobrien * modification, are permitted provided that the following conditions 759243Sobrien * are met: 859243Sobrien * 959243Sobrien * 1. Redistributions of source code must retain the above copyright 1059243Sobrien * notice, this list of conditions and the following disclaimer. 1159243Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1259243Sobrien * notice, this list of conditions and the following disclaimer in the 1359243Sobrien * documentation and/or other materials provided with the distribution. 1459243Sobrien * 1559243Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1659243Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17100616Smp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1859243Sobrien * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1959243Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2059243Sobrien * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2159243Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2259243Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2359243Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2459243Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2559243Sobrien * 2659243Sobrien * $FreeBSD: head/sys/dev/scc/scc_bfe.h 157351 2006-04-01 04:51:56Z marcel $ 2759243Sobrien */ 2859243Sobrien 2959243Sobrien#ifndef _DEV_SCC_BFE_H_ 3059243Sobrien#define _DEV_SCC_BFE_H_ 3159243Sobrien 3259243Sobrien#include <sys/serial.h> 3359243Sobrien 3459243Sobrien/* 35145479Smp * Bus access structure. This structure holds the minimum information needed 3659243Sobrien * to access the SCC. The rclk field, although not important to actually 3759243Sobrien * access the SCC, is important for baudrate programming, delay loops and 3859243Sobrien * other timing related computations. 3959243Sobrien */ 4059243Sobrienstruct scc_bas { 4159243Sobrien bus_space_tag_t bst; 4259243Sobrien bus_space_handle_t bsh; 4359243Sobrien u_int range; 4459243Sobrien u_int rclk; 4559243Sobrien u_int regshft; 4659243Sobrien}; 4759243Sobrien 4859243Sobrien#define scc_regofs(bas, reg) ((reg) << (bas)->regshft) 4959243Sobrien 5059243Sobrien#define scc_getreg(bas, reg) \ 5159243Sobrien bus_space_read_1((bas)->bst, (bas)->bsh, scc_regofs(bas, reg)) 5259243Sobrien#define scc_setreg(bas, reg, value) \ 5359243Sobrien bus_space_write_1((bas)->bst, (bas)->bsh, scc_regofs(bas, reg), value) 5459243Sobrien 5559243Sobrien#define scc_barrier(bas) \ 5659243Sobrien bus_space_barrier((bas)->bst, (bas)->bsh, 0, (bas)->range, \ 5759243Sobrien BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE) 5859243Sobrien 5959243Sobrien/* 6059243Sobrien * SCC mode (child) and channel control structures. 6159243Sobrien */ 6259243Sobrien 6359243Sobrien#define SCC_NMODES 3 6459243Sobrien#define SCC_ISRCCNT 5 6559243Sobrien 6659243Sobrienstruct scc_chan; 6759243Sobrien 6859243Sobrienstruct scc_mode { 6959243Sobrien struct scc_chan *m_chan; 70145479Smp device_t m_dev; 7159243Sobrien 7259243Sobrien u_int m_mode; 7359243Sobrien int m_attached:1; 7459243Sobrien int m_fastintr:1; 7559243Sobrien int m_hasintr:1; 7659243Sobrien int m_probed:1; 7759243Sobrien int m_sysdev:1; 7859243Sobrien 7959243Sobrien driver_intr_t *ih; 8059243Sobrien serdev_intr_t *ih_src[SCC_ISRCCNT]; 8159243Sobrien void *ih_arg; 8259243Sobrien}; 8359243Sobrien 8459243Sobrienstruct scc_chan { 8559243Sobrien struct resource ch_rres; 8659243Sobrien struct resource_list ch_rlist; 8759243Sobrien 8859243Sobrien struct scc_mode ch_mode[SCC_NMODES]; 8959243Sobrien 90145479Smp u_int ch_nr; 9159243Sobrien int ch_sysdev:1; 9259243Sobrien 9359243Sobrien uint32_t ch_ipend; 9459243Sobrien uint32_t ch_hwsig; 9559243Sobrien}; 9659243Sobrien 9759243Sobrien/* 9859243Sobrien * SCC class & instance (=softc) 9959243Sobrien */ 100145479Smpstruct scc_class { 10159243Sobrien KOBJ_CLASS_FIELDS; 10259243Sobrien u_int cl_channels; /* Number of independent channels. */ 10359243Sobrien u_int cl_class; /* SCC bus class ID. */ 10459243Sobrien u_int cl_modes; /* Supported modes (bitset). */ 10559243Sobrien int cl_range; 10659243Sobrien}; 10759243Sobrien 10859243Sobrienextern struct scc_class scc_sab82532_class; 10959243Sobrienextern struct scc_class scc_z8530_class; 11059243Sobrien 11159243Sobrienstruct scc_softc { 11259243Sobrien KOBJ_FIELDS; 11359243Sobrien struct scc_class *sc_class; 11459243Sobrien struct scc_bas sc_bas; 115145479Smp device_t sc_dev; 11659243Sobrien 11759243Sobrien struct mtx sc_hwmtx; /* Spinlock protecting hardware. */ 11859243Sobrien 11959243Sobrien struct resource *sc_rres; /* Register resource. */ 12059243Sobrien int sc_rrid; 12159243Sobrien int sc_rtype; /* SYS_RES_{IOPORT|MEMORY}. */ 12259243Sobrien struct resource *sc_ires; /* Interrupt resource. */ 12359243Sobrien void *sc_icookie; 12459243Sobrien int sc_irid; 12559243Sobrien 12659243Sobrien struct scc_chan *sc_chan; 12759243Sobrien 12859243Sobrien int sc_fastintr:1; 12959243Sobrien int sc_leaving:1; 13059243Sobrien int sc_polled:1; 13159243Sobrien 13259243Sobrien uint32_t sc_hwsig; /* Signal state. Used by HW driver. */ 13359243Sobrien}; 13459243Sobrien 13559243Sobrienextern devclass_t scc_devclass; 13659243Sobrienextern char scc_driver_name[]; 13759243Sobrien 13859243Sobrienint scc_bfe_attach(device_t dev); 13959243Sobrienint scc_bfe_detach(device_t dev); 14059243Sobrienint scc_bfe_probe(device_t dev, u_int, u_int); 14159243Sobrien 14259243Sobrienstruct resource *scc_bus_alloc_resource(device_t, device_t, int, int *, 14359243Sobrien u_long, u_long, u_long, u_int); 14459243Sobrienint scc_bus_get_resource(device_t, device_t, int, int, u_long *, u_long *); 14559243Sobrienint scc_bus_read_ivar(device_t, device_t, int, uintptr_t *); 14659243Sobrienint scc_bus_release_resource(device_t, device_t, int, int, struct resource *); 14759243Sobrienint scc_bus_setup_intr(device_t, device_t, struct resource *, int, 14859243Sobrien void (*)(void *), void *, void **); 14959243Sobrienint scc_bus_teardown_intr(device_t, device_t, struct resource *, void *); 15059243Sobrien 151145479Smp#endif /* _DEV_SCC_BFE_H_ */ 15259243Sobrien