2014-03-25 19:52:16 +04:00
|
|
|
/* $NetBSD: clmpcc_pcctwo.c,v 1.20 2014/03/25 15:52:16 christos Exp $ */
|
1999-02-14 20:54:27 +03:00
|
|
|
|
|
|
|
/*-
|
2002-02-12 23:38:09 +03:00
|
|
|
* Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
|
1999-02-14 20:54:27 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Steve C. Woodford.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cirrus Logic CD2401 4-channel serial chip. PCCchip2 Front-end.
|
|
|
|
*/
|
|
|
|
|
2003-07-14 19:47:00 +04:00
|
|
|
#include <sys/cdefs.h>
|
2014-03-25 19:52:16 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: clmpcc_pcctwo.c,v 1.20 2014/03/25 15:52:16 christos Exp $");
|
2003-07-14 19:47:00 +04:00
|
|
|
|
1999-02-14 20:54:27 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
|
|
|
|
#include <dev/cons.h>
|
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/cpu.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/intr.h>
|
1999-02-14 20:54:27 +03:00
|
|
|
|
|
|
|
#include <dev/ic/clmpccvar.h>
|
|
|
|
|
2002-02-12 23:38:09 +03:00
|
|
|
#include <dev/mvme/pcctwovar.h>
|
|
|
|
#include <dev/mvme/pcctworeg.h>
|
|
|
|
|
|
|
|
/* XXXXSCW: Fixme */
|
|
|
|
#ifdef MVME68K
|
2000-03-19 01:33:02 +03:00
|
|
|
#include <mvme68k/dev/mainbus.h>
|
2002-02-12 23:38:09 +03:00
|
|
|
#else
|
|
|
|
#error Need consiack hook
|
|
|
|
#endif
|
1999-02-14 20:54:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* Definition of the driver for autoconfig. */
|
2009-05-12 18:38:26 +04:00
|
|
|
int clmpcc_pcctwo_match(device_t, cfdata_t, void *);
|
|
|
|
void clmpcc_pcctwo_attach(device_t, device_t, void *);
|
2005-02-04 05:10:35 +03:00
|
|
|
void clmpcc_pcctwo_iackhook(struct clmpcc_softc *, int);
|
|
|
|
void clmpcc_pcctwo_consiackhook(struct clmpcc_softc *, int);
|
1999-02-14 20:54:27 +03:00
|
|
|
|
2012-10-27 21:17:22 +04:00
|
|
|
CFATTACH_DECL_NEW(clmpcc_pcctwo, sizeof(struct clmpcc_softc),
|
2002-10-02 20:33:28 +04:00
|
|
|
clmpcc_pcctwo_match, clmpcc_pcctwo_attach, NULL, NULL);
|
1999-02-14 20:54:27 +03:00
|
|
|
|
|
|
|
extern struct cfdriver clmpcc_cd;
|
|
|
|
|
2002-09-06 17:18:43 +04:00
|
|
|
extern const struct cdevsw clmpcc_cdevsw;
|
|
|
|
|
1999-02-14 20:54:27 +03:00
|
|
|
/*
|
2002-09-06 17:18:43 +04:00
|
|
|
* For clmpcccn*()
|
1999-02-14 20:54:27 +03:00
|
|
|
*/
|
2000-03-19 01:33:02 +03:00
|
|
|
cons_decl(clmpcc);
|
1999-02-14 20:54:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is the CD2401 chip present?
|
|
|
|
*/
|
2000-03-19 01:33:02 +03:00
|
|
|
int
|
2009-05-12 18:38:26 +04:00
|
|
|
clmpcc_pcctwo_match(device_t parent, cfdata_t cf, void *aux)
|
1999-02-14 20:54:27 +03:00
|
|
|
{
|
2000-03-19 01:33:02 +03:00
|
|
|
struct pcctwo_attach_args *pa;
|
|
|
|
|
|
|
|
pa = aux;
|
1999-02-14 20:54:27 +03:00
|
|
|
|
2002-02-12 23:38:09 +03:00
|
|
|
if (strcmp(pa->pa_name, clmpcc_cd.cd_name))
|
1999-02-14 20:54:27 +03:00
|
|
|
return (0);
|
|
|
|
|
2000-03-19 01:33:02 +03:00
|
|
|
pa->pa_ipl = cf->pcctwocf_ipl;
|
1999-02-14 20:54:27 +03:00
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
2002-02-12 23:38:09 +03:00
|
|
|
|
1999-02-14 20:54:27 +03:00
|
|
|
/*
|
|
|
|
* Attach a found CD2401.
|
|
|
|
*/
|
2000-03-19 01:33:02 +03:00
|
|
|
void
|
2009-05-12 18:38:26 +04:00
|
|
|
clmpcc_pcctwo_attach(device_t parent, device_t self, void *aux)
|
1999-02-14 20:54:27 +03:00
|
|
|
{
|
2000-03-19 01:33:02 +03:00
|
|
|
struct clmpcc_softc *sc;
|
2006-08-07 05:31:36 +04:00
|
|
|
struct pcctwo_attach_args *pa = aux;
|
1999-02-14 20:54:27 +03:00
|
|
|
int level = pa->pa_ipl;
|
|
|
|
|
2006-03-29 10:51:47 +04:00
|
|
|
sc = device_private(self);
|
2012-10-27 21:17:22 +04:00
|
|
|
sc->sc_dev = self;
|
2000-03-19 01:33:02 +03:00
|
|
|
level = pa->pa_ipl;
|
|
|
|
sc->sc_iot = pa->pa_bust;
|
|
|
|
bus_space_map(pa->pa_bust, pa->pa_offset, 0x100, 0, &sc->sc_ioh);
|
|
|
|
|
1999-02-14 20:54:27 +03:00
|
|
|
sc->sc_clk = 20000000;
|
|
|
|
sc->sc_byteswap = CLMPCC_BYTESWAP_LOW;
|
|
|
|
sc->sc_swaprtsdtr = 1;
|
|
|
|
sc->sc_iackhook = clmpcc_pcctwo_iackhook;
|
|
|
|
sc->sc_vector_base = PCCTWO_SCC_VECBASE;
|
|
|
|
sc->sc_rpilr = 0x03;
|
|
|
|
sc->sc_tpilr = 0x02;
|
|
|
|
sc->sc_mpilr = 0x01;
|
2001-05-31 22:46:07 +04:00
|
|
|
sc->sc_evcnt = pcctwointr_evcnt(level);
|
1999-02-14 20:54:27 +03:00
|
|
|
|
|
|
|
/* Do common parts of CD2401 configuration. */
|
|
|
|
clmpcc_attach(sc);
|
|
|
|
|
|
|
|
/* Hook the interrupts */
|
2001-05-31 22:46:07 +04:00
|
|
|
pcctwointr_establish(PCCTWOV_SCC_RX, clmpcc_rxintr, level, sc, NULL);
|
|
|
|
pcctwointr_establish(PCCTWOV_SCC_RX_EXCEP, clmpcc_rxintr, level, sc,
|
|
|
|
NULL);
|
|
|
|
pcctwointr_establish(PCCTWOV_SCC_TX, clmpcc_txintr, level, sc, NULL);
|
|
|
|
pcctwointr_establish(PCCTWOV_SCC_MODEM, clmpcc_mdintr, level, sc, NULL);
|
1999-02-14 20:54:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-14 18:35:58 +03:00
|
|
|
clmpcc_pcctwo_iackhook(struct clmpcc_softc *sc, int which)
|
1999-02-14 20:54:27 +03:00
|
|
|
{
|
2000-03-19 01:33:02 +03:00
|
|
|
bus_size_t offset;
|
|
|
|
volatile u_char foo;
|
|
|
|
|
|
|
|
switch (which) {
|
|
|
|
case CLMPCC_IACK_MODEM:
|
|
|
|
offset = PCC2REG_SCC_MODEM_PIACK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLMPCC_IACK_RX:
|
|
|
|
offset = PCC2REG_SCC_RX_PIACK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLMPCC_IACK_TX:
|
|
|
|
offset = PCC2REG_SCC_TX_PIACK;
|
|
|
|
break;
|
|
|
|
default:
|
2003-11-07 22:16:01 +03:00
|
|
|
#ifdef DEBUG
|
2000-03-19 01:33:02 +03:00
|
|
|
printf("%s: Invalid IACK number '%d'\n",
|
2012-10-27 21:17:22 +04:00
|
|
|
device_xname(sc->sc_dev), which);
|
2000-03-19 01:33:02 +03:00
|
|
|
#endif
|
2003-11-07 22:16:01 +03:00
|
|
|
panic("clmpcc_pcctwo_iackhook %d", which);
|
2000-03-19 01:33:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
foo = pcc2_reg_read(sys_pcctwo, offset);
|
2014-03-25 19:52:16 +04:00
|
|
|
__USE(foo);
|
2000-03-19 01:33:02 +03:00
|
|
|
}
|
2002-02-12 23:38:09 +03:00
|
|
|
|
2000-03-19 01:33:02 +03:00
|
|
|
/*
|
|
|
|
* This routine is only used prior to clmpcc_attach() being called
|
|
|
|
*/
|
|
|
|
void
|
2009-03-14 18:35:58 +03:00
|
|
|
clmpcc_pcctwo_consiackhook(struct clmpcc_softc *sc, int which)
|
2000-03-19 01:33:02 +03:00
|
|
|
{
|
|
|
|
bus_space_handle_t bush;
|
|
|
|
bus_size_t offset;
|
1999-02-14 20:54:27 +03:00
|
|
|
volatile u_char foo;
|
|
|
|
|
2000-03-19 01:33:02 +03:00
|
|
|
switch (which) {
|
|
|
|
case CLMPCC_IACK_MODEM:
|
|
|
|
offset = PCC2REG_SCC_MODEM_PIACK;
|
1999-02-14 20:54:27 +03:00
|
|
|
break;
|
|
|
|
|
2000-03-19 01:33:02 +03:00
|
|
|
case CLMPCC_IACK_RX:
|
|
|
|
offset = PCC2REG_SCC_RX_PIACK;
|
1999-02-14 20:54:27 +03:00
|
|
|
break;
|
|
|
|
|
2000-03-19 01:33:02 +03:00
|
|
|
case CLMPCC_IACK_TX:
|
|
|
|
offset = PCC2REG_SCC_TX_PIACK;
|
1999-02-14 20:54:27 +03:00
|
|
|
break;
|
2000-03-19 01:33:02 +03:00
|
|
|
default:
|
2003-11-09 17:26:15 +03:00
|
|
|
#ifdef DEBUG
|
2000-03-19 01:33:02 +03:00
|
|
|
printf("%s: Invalid IACK number '%d'\n",
|
2012-10-27 21:17:22 +04:00
|
|
|
device_xname(sc->sc_dev), which);
|
2000-03-19 01:33:02 +03:00
|
|
|
panic("clmpcc_pcctwo_consiackhook");
|
|
|
|
#endif
|
2003-11-09 17:26:15 +03:00
|
|
|
panic("clmpcc_pcctwo_iackhook %d", which);
|
1999-02-14 20:54:27 +03:00
|
|
|
}
|
2000-03-19 01:33:02 +03:00
|
|
|
|
2002-02-12 23:38:09 +03:00
|
|
|
#ifdef MVME68K
|
2000-11-24 12:36:40 +03:00
|
|
|
/*
|
|
|
|
* We need to fake the tag and handle since 'sys_pcctwo' will
|
|
|
|
* be NULL during early system startup...
|
|
|
|
*/
|
|
|
|
bush = (bus_space_handle_t) & (intiobase[MAINBUS_PCCTWO_OFFSET +
|
|
|
|
PCCTWO_REG_OFF]);
|
|
|
|
|
|
|
|
foo = bus_space_read_1(&_mainbus_space_tag, bush, offset);
|
2014-03-25 19:52:16 +04:00
|
|
|
__USE(foo);
|
2002-02-12 23:38:09 +03:00
|
|
|
#else
|
|
|
|
#error Need consiack hook
|
|
|
|
#endif
|
1999-02-14 20:54:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
* Console support functions (MVME PCCchip2 specific!)
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for CD2401 console.
|
|
|
|
*/
|
|
|
|
void
|
2009-03-14 18:35:58 +03:00
|
|
|
clmpcccnprobe(struct consdev *cp)
|
1999-02-14 20:54:27 +03:00
|
|
|
{
|
2000-03-19 01:33:02 +03:00
|
|
|
int maj;
|
1999-02-14 20:54:27 +03:00
|
|
|
|
2002-02-12 23:38:09 +03:00
|
|
|
#if defined(MVME68K)
|
|
|
|
if (machineid != MVME_167 && machineid != MVME_177)
|
|
|
|
#elif defined(MVME88K)
|
|
|
|
if (machineid != MVME_187)
|
|
|
|
#endif
|
|
|
|
{
|
1999-02-14 20:54:27 +03:00
|
|
|
cp->cn_pri = CN_DEAD;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locate the major number
|
|
|
|
*/
|
2002-09-06 17:18:43 +04:00
|
|
|
maj = cdevsw_lookup_major(&clmpcc_cdevsw);
|
1999-02-14 20:54:27 +03:00
|
|
|
|
|
|
|
/* Initialize required fields. */
|
|
|
|
cp->cn_dev = makedev(maj, 0);
|
|
|
|
cp->cn_pri = CN_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-14 18:35:58 +03:00
|
|
|
clmpcccninit(struct consdev *cp)
|
1999-02-14 20:54:27 +03:00
|
|
|
{
|
|
|
|
static struct clmpcc_softc cons_sc;
|
|
|
|
|
2000-11-24 12:36:40 +03:00
|
|
|
cons_sc.sc_iot = &_mainbus_space_tag;
|
|
|
|
bus_space_map(&_mainbus_space_tag,
|
|
|
|
intiobase_phys + MAINBUS_PCCTWO_OFFSET + PCCTWO_SCC_OFF,
|
2000-03-19 01:33:02 +03:00
|
|
|
PCC2REG_SIZE, 0, &cons_sc.sc_ioh);
|
1999-02-14 20:54:27 +03:00
|
|
|
cons_sc.sc_clk = 20000000;
|
|
|
|
cons_sc.sc_byteswap = CLMPCC_BYTESWAP_LOW;
|
|
|
|
cons_sc.sc_swaprtsdtr = 1;
|
2000-03-19 01:33:02 +03:00
|
|
|
cons_sc.sc_iackhook = clmpcc_pcctwo_consiackhook;
|
1999-02-14 20:54:27 +03:00
|
|
|
cons_sc.sc_vector_base = PCCTWO_SCC_VECBASE;
|
|
|
|
cons_sc.sc_rpilr = 0x03;
|
|
|
|
cons_sc.sc_tpilr = 0x02;
|
|
|
|
cons_sc.sc_mpilr = 0x01;
|
|
|
|
|
|
|
|
clmpcc_cnattach(&cons_sc, 0, 9600);
|
|
|
|
}
|