esp_sbus.c (207885) | esp_sbus.c (226381) |
---|---|
1/*- 2 * Copyright (c) 2004 Scott Long 3 * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 | 1/*- 2 * Copyright (c) 2004 Scott Long 3 * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 |
29/* $NetBSD: esp_sbus.c,v 1.31 2005/02/27 00:27:48 perry Exp $ */ | 29/* $NetBSD: esp_sbus.c,v 1.51 2009/09/17 16:28:12 tsutsui Exp $ */ |
30 31/*- 32 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 33 * All rights reserved. 34 * 35 * This code is derived from software contributed to The NetBSD Foundation 36 * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace 37 * Simulation Facility, NASA Ames Research Center; Paul Kranenburg. 38 * 39 * Redistribution and use in source and binary forms, with or without 40 * modification, are permitted provided that the following conditions 41 * are met: 42 * 1. Redistributions of source code must retain the above copyright 43 * notice, this list of conditions and the following disclaimer. 44 * 2. Redistributions in binary form must reproduce the above copyright 45 * notice, this list of conditions and the following disclaimer in the 46 * documentation and/or other materials provided with the distribution. | 30 31/*- 32 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 33 * All rights reserved. 34 * 35 * This code is derived from software contributed to The NetBSD Foundation 36 * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace 37 * Simulation Facility, NASA Ames Research Center; Paul Kranenburg. 38 * 39 * Redistribution and use in source and binary forms, with or without 40 * modification, are permitted provided that the following conditions 41 * are met: 42 * 1. Redistributions of source code must retain the above copyright 43 * notice, this list of conditions and the following disclaimer. 44 * 2. Redistributions in binary form must reproduce the above copyright 45 * notice, this list of conditions and the following disclaimer in the 46 * documentation and/or other materials provided with the distribution. |
47 * 3. All advertising materials mentioning features or use of this software 48 * must display the following acknowledgement: 49 * This product includes software developed by the NetBSD 50 * Foundation, Inc. and its contributors. 51 * 4. Neither the name of The NetBSD Foundation nor the names of its 52 * contributors may be used to endorse or promote products derived 53 * from this software without specific prior written permission. | |
54 * 55 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 56 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 57 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 58 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 59 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 60 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 61 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 62 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 63 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 64 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 65 * POSSIBILITY OF SUCH DAMAGE. 66 */ 67 68#include <sys/cdefs.h> | 47 * 48 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 49 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 50 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 51 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 52 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 53 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 54 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 55 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 57 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 58 * POSSIBILITY OF SUCH DAMAGE. 59 */ 60 61#include <sys/cdefs.h> |
69__FBSDID("$FreeBSD: head/sys/dev/esp/esp_sbus.c 207885 2010-05-10 20:02:39Z marius $"); | 62__FBSDID("$FreeBSD: head/sys/dev/esp/esp_sbus.c 226381 2011-10-15 09:29:43Z marius $"); |
70 71#include <sys/param.h> 72#include <sys/systm.h> 73#include <sys/bus.h> 74#include <sys/kernel.h> 75#include <sys/lock.h> 76#include <sys/module.h> 77#include <sys/mutex.h> --- 75 unchanged lines hidden (view full) --- 153}; 154 155DRIVER_MODULE(esp, sbus, esp_sbus_driver, esp_devclass, 0, 0); 156MODULE_DEPEND(esp, sbus, 1, 1, 1); 157 158/* 159 * Functions and the switch for the MI code 160 */ | 63 64#include <sys/param.h> 65#include <sys/systm.h> 66#include <sys/bus.h> 67#include <sys/kernel.h> 68#include <sys/lock.h> 69#include <sys/module.h> 70#include <sys/mutex.h> --- 75 unchanged lines hidden (view full) --- 146}; 147 148DRIVER_MODULE(esp, sbus, esp_sbus_driver, esp_devclass, 0, 0); 149MODULE_DEPEND(esp, sbus, 1, 1, 1); 150 151/* 152 * Functions and the switch for the MI code 153 */ |
161static u_char esp_read_reg(struct ncr53c9x_softc *sc, int reg); 162static void esp_write_reg(struct ncr53c9x_softc *sc, int reg, u_char v); | 154static uint8_t esp_read_reg(struct ncr53c9x_softc *sc, int reg); 155static void esp_write_reg(struct ncr53c9x_softc *sc, int reg, uint8_t v); |
163static int esp_dma_isintr(struct ncr53c9x_softc *sc); 164static void esp_dma_reset(struct ncr53c9x_softc *sc); 165static int esp_dma_intr(struct ncr53c9x_softc *sc); | 156static int esp_dma_isintr(struct ncr53c9x_softc *sc); 157static void esp_dma_reset(struct ncr53c9x_softc *sc); 158static int esp_dma_intr(struct ncr53c9x_softc *sc); |
166static int esp_dma_setup(struct ncr53c9x_softc *sc, caddr_t *addr, | 159static int esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, |
167 size_t *len, int datain, size_t *dmasize); 168static void esp_dma_go(struct ncr53c9x_softc *sc); 169static void esp_dma_stop(struct ncr53c9x_softc *sc); 170static int esp_dma_isactive(struct ncr53c9x_softc *sc); 171static int espattach(struct esp_softc *esc, 172 const struct ncr53c9x_glue *gluep); 173static int espdetach(struct esp_softc *esc); 174 | 160 size_t *len, int datain, size_t *dmasize); 161static void esp_dma_go(struct ncr53c9x_softc *sc); 162static void esp_dma_stop(struct ncr53c9x_softc *sc); 163static int esp_dma_isactive(struct ncr53c9x_softc *sc); 164static int espattach(struct esp_softc *esc, 165 const struct ncr53c9x_glue *gluep); 166static int espdetach(struct esp_softc *esc); 167 |
175static const struct ncr53c9x_glue esp_sbus_glue = { | 168static const struct ncr53c9x_glue const esp_sbus_glue = { |
176 esp_read_reg, 177 esp_write_reg, 178 esp_dma_isintr, 179 esp_dma_reset, 180 esp_dma_intr, 181 esp_dma_setup, 182 esp_dma_go, 183 esp_dma_stop, --- 529 unchanged lines hidden (view full) --- 713/* 714 * Glue functions 715 */ 716 717#ifdef ESP_SBUS_DEBUG 718static int esp_sbus_debug = 0; 719 720static const struct { | 169 esp_read_reg, 170 esp_write_reg, 171 esp_dma_isintr, 172 esp_dma_reset, 173 esp_dma_intr, 174 esp_dma_setup, 175 esp_dma_go, 176 esp_dma_stop, --- 529 unchanged lines hidden (view full) --- 706/* 707 * Glue functions 708 */ 709 710#ifdef ESP_SBUS_DEBUG 711static int esp_sbus_debug = 0; 712 713static const struct { |
721 char *r_name; 722 int r_flag; 723} esp__read_regnames [] = { | 714 const char *r_name; 715 int r_flag; 716} const esp__read_regnames [] = { |
724 { "TCL", 0}, /* 0/00 */ 725 { "TCM", 0}, /* 1/04 */ 726 { "FIFO", 0}, /* 2/08 */ 727 { "CMD", 0}, /* 3/0c */ 728 { "STAT", 0}, /* 4/10 */ 729 { "INTR", 0}, /* 5/14 */ 730 { "STEP", 0}, /* 6/18 */ 731 { "FFLAGS", 1}, /* 7/1c */ 732 { "CFG1", 1}, /* 8/20 */ 733 { "STAT2", 0}, /* 9/24 */ 734 { "CFG4", 1}, /* a/28 */ 735 { "CFG2", 1}, /* b/2c */ 736 { "CFG3", 1}, /* c/30 */ 737 { "-none", 1}, /* d/34 */ 738 { "TCH", 1}, /* e/38 */ 739 { "TCX", 1}, /* f/3c */ 740}; 741 | 717 { "TCL", 0}, /* 0/00 */ 718 { "TCM", 0}, /* 1/04 */ 719 { "FIFO", 0}, /* 2/08 */ 720 { "CMD", 0}, /* 3/0c */ 721 { "STAT", 0}, /* 4/10 */ 722 { "INTR", 0}, /* 5/14 */ 723 { "STEP", 0}, /* 6/18 */ 724 { "FFLAGS", 1}, /* 7/1c */ 725 { "CFG1", 1}, /* 8/20 */ 726 { "STAT2", 0}, /* 9/24 */ 727 { "CFG4", 1}, /* a/28 */ 728 { "CFG2", 1}, /* b/2c */ 729 { "CFG3", 1}, /* c/30 */ 730 { "-none", 1}, /* d/34 */ 731 { "TCH", 1}, /* e/38 */ 732 { "TCX", 1}, /* f/3c */ 733}; 734 |
742static const struct { 743 char *r_name; 744 int r_flag; 745} esp__write_regnames[] = { | 735static const const struct { 736 const char *r_name; 737 int r_flag; 738} const esp__write_regnames[] = { |
746 { "TCL", 1}, /* 0/00 */ 747 { "TCM", 1}, /* 1/04 */ 748 { "FIFO", 0}, /* 2/08 */ 749 { "CMD", 0}, /* 3/0c */ 750 { "SELID", 1}, /* 4/10 */ 751 { "TIMEOUT", 1}, /* 5/14 */ 752 { "SYNCTP", 1}, /* 6/18 */ 753 { "SYNCOFF", 1}, /* 7/1c */ 754 { "CFG1", 1}, /* 8/20 */ 755 { "CCF", 1}, /* 9/24 */ 756 { "TEST", 1}, /* a/28 */ 757 { "CFG2", 1}, /* b/2c */ 758 { "CFG3", 1}, /* c/30 */ 759 { "-none", 1}, /* d/34 */ 760 { "TCH", 1}, /* e/38 */ 761 { "TCX", 1}, /* f/3c */ 762}; 763#endif 764 | 739 { "TCL", 1}, /* 0/00 */ 740 { "TCM", 1}, /* 1/04 */ 741 { "FIFO", 0}, /* 2/08 */ 742 { "CMD", 0}, /* 3/0c */ 743 { "SELID", 1}, /* 4/10 */ 744 { "TIMEOUT", 1}, /* 5/14 */ 745 { "SYNCTP", 1}, /* 6/18 */ 746 { "SYNCOFF", 1}, /* 7/1c */ 747 { "CFG1", 1}, /* 8/20 */ 748 { "CCF", 1}, /* 9/24 */ 749 { "TEST", 1}, /* a/28 */ 750 { "CFG2", 1}, /* b/2c */ 751 { "CFG3", 1}, /* c/30 */ 752 { "-none", 1}, /* d/34 */ 753 { "TCH", 1}, /* e/38 */ 754 { "TCX", 1}, /* f/3c */ 755}; 756#endif 757 |
765static u_char | 758static uint8_t |
766esp_read_reg(struct ncr53c9x_softc *sc, int reg) 767{ 768 struct esp_softc *esc = (struct esp_softc *)sc; | 759esp_read_reg(struct ncr53c9x_softc *sc, int reg) 760{ 761 struct esp_softc *esc = (struct esp_softc *)sc; |
769 u_char v; | 762 uint8_t v; |
770 771 v = bus_read_1(esc->sc_res, reg * 4); 772 773#ifdef ESP_SBUS_DEBUG 774 if (esp_sbus_debug && (reg < 0x10) && esp__read_regnames[reg].r_flag) 775 printf("RD:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ? 776 esp__read_regnames[reg].r_name : "<***>", v); 777#endif 778 779 return (v); 780} 781 782static void | 763 764 v = bus_read_1(esc->sc_res, reg * 4); 765 766#ifdef ESP_SBUS_DEBUG 767 if (esp_sbus_debug && (reg < 0x10) && esp__read_regnames[reg].r_flag) 768 printf("RD:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ? 769 esp__read_regnames[reg].r_name : "<***>", v); 770#endif 771 772 return (v); 773} 774 775static void |
783esp_write_reg(struct ncr53c9x_softc *sc, int reg, u_char v) | 776esp_write_reg(struct ncr53c9x_softc *sc, int reg, uint8_t v) |
784{ 785 struct esp_softc *esc = (struct esp_softc *)sc; 786 787#ifdef ESP_SBUS_DEBUG 788 if (esp_sbus_debug && (reg < 0x10) && esp__write_regnames[reg].r_flag) 789 printf("WR:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ? 790 esp__write_regnames[reg].r_name : "<***>", v); 791#endif --- 21 unchanged lines hidden (view full) --- 813esp_dma_intr(struct ncr53c9x_softc *sc) 814{ 815 struct esp_softc *esc = (struct esp_softc *)sc; 816 817 return (DMA_INTR(esc->sc_dma)); 818} 819 820static int | 777{ 778 struct esp_softc *esc = (struct esp_softc *)sc; 779 780#ifdef ESP_SBUS_DEBUG 781 if (esp_sbus_debug && (reg < 0x10) && esp__write_regnames[reg].r_flag) 782 printf("WR:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ? 783 esp__write_regnames[reg].r_name : "<***>", v); 784#endif --- 21 unchanged lines hidden (view full) --- 806esp_dma_intr(struct ncr53c9x_softc *sc) 807{ 808 struct esp_softc *esc = (struct esp_softc *)sc; 809 810 return (DMA_INTR(esc->sc_dma)); 811} 812 813static int |
821esp_dma_setup(struct ncr53c9x_softc *sc, caddr_t *addr, size_t *len, 822 int datain, size_t *dmasize) | 814esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, 815 int datain, size_t *dmasize) |
823{ 824 struct esp_softc *esc = (struct esp_softc *)sc; 825 826 return (DMA_SETUP(esc->sc_dma, addr, len, datain, dmasize)); 827} 828 829static void 830esp_dma_go(struct ncr53c9x_softc *sc) --- 21 unchanged lines hidden --- | 816{ 817 struct esp_softc *esc = (struct esp_softc *)sc; 818 819 return (DMA_SETUP(esc->sc_dma, addr, len, datain, dmasize)); 820} 821 822static void 823esp_dma_go(struct ncr53c9x_softc *sc) --- 21 unchanged lines hidden --- |