mc146818(4): remove obsolete driver

It's no longer used since 58aa35d429
and r357455 respectively.
This commit is contained in:
Marius Strobl 2020-12-24 20:06:53 +01:00
parent 5731987b71
commit d141239c56
5 changed files with 0 additions and 529 deletions

View File

@ -2388,7 +2388,6 @@ lio_23xx_nic.bin.fw optional lio \
dev/malo/if_malo.c optional malo
dev/malo/if_malohal.c optional malo
dev/malo/if_malo_pci.c optional malo pci
dev/mc146818/mc146818.c optional mc146818
dev/md/md.c optional md
dev/mdio/mdio_if.m optional miiproxy | mdio
dev/mdio/mdio.c optional miiproxy | mdio

View File

@ -1,290 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2003 Izumi Tsutsui. All rights reserved.
*
* 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 AUTHOR ``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 AUTHOR 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.
*
* $NetBSD: mc146818.c,v 1.16 2008/05/14 13:29:28 tsutsui Exp $
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* mc146818 and compatible time of day chip subroutines
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <machine/bus.h>
#include <dev/mc146818/mc146818reg.h>
#include <dev/mc146818/mc146818var.h>
#include "clock_if.h"
static u_int mc146818_def_getcent(device_t);
static void mc146818_def_setcent(device_t, u_int);
int
mc146818_attach(device_t dev)
{
struct mc146818_softc *sc;
sc = device_get_softc(dev);
if (mtx_initialized(&sc->sc_mtx) == 0) {
device_printf(dev, "%s: mutex not initialized\n", __func__);
return (ENXIO);
}
if (sc->sc_mcread == NULL)
sc->sc_mcread = mc146818_def_read;
if (sc->sc_mcwrite == NULL)
sc->sc_mcwrite = mc146818_def_write;
if (sc->sc_flag & MC146818_NO_CENT_ADJUST) {
/*
* Note that setting MC146818_NO_CENT_ADJUST means that
* the century has to be stored in NVRAM somewhere.
*/
if (sc->sc_getcent == NULL)
sc->sc_getcent = mc146818_def_getcent;
if (sc->sc_setcent == NULL)
sc->sc_setcent = mc146818_def_setcent;
}
mtx_lock_spin(&sc->sc_mtx);
if (((*sc->sc_mcread)(dev, MC_REGD) & MC_REGD_VRT) == 0) {
mtx_unlock_spin(&sc->sc_mtx);
device_printf(dev, "%s: battery low\n", __func__);
return (ENXIO);
}
sc->sc_rega = MC_BASE_32_KHz;
(*sc->sc_mcwrite)(dev, MC_REGA, sc->sc_rega);
sc->sc_regb = 0;
sc->sc_regb |= (sc->sc_flag & MC146818_BCD) ? 0 : MC_REGB_BINARY;
sc->sc_regb |= (sc->sc_flag & MC146818_12HR) ? 0 : MC_REGB_24HR;
(*sc->sc_mcwrite)(dev, MC_REGB, sc->sc_regb);
mtx_unlock_spin(&sc->sc_mtx);
clock_register(dev, 1000000); /* 1 second resolution */
return (0);
}
/*
* Get time of day and convert it to a struct timespec.
* Return 0 on success, an error number otherwise.
*/
int
mc146818_gettime(device_t dev, struct timespec *ts)
{
struct mc146818_softc *sc;
struct clocktime ct;
int timeout, cent, year;
sc = device_get_softc(dev);
timeout = 1000000; /* XXX how long should we wait? */
/*
* If MC_REGA_UIP is 0 we have at least 244us before the next
* update. If it's 1 an update is imminent.
*/
for (;;) {
mtx_lock_spin(&sc->sc_mtx);
if (((*sc->sc_mcread)(dev, MC_REGA) & MC_REGA_UIP) == 0)
break;
mtx_unlock_spin(&sc->sc_mtx);
if (--timeout < 0) {
device_printf(dev, "%s: timeout\n", __func__);
return (EBUSY);
}
}
#define FROMREG(x) ((sc->sc_flag & MC146818_BCD) ? FROMBCD(x) : (x))
ct.nsec = 0;
ct.sec = FROMREG((*sc->sc_mcread)(dev, MC_SEC));
ct.min = FROMREG((*sc->sc_mcread)(dev, MC_MIN));
ct.hour = FROMREG((*sc->sc_mcread)(dev, MC_HOUR));
/* Map dow from 1 - 7 to 0 - 6. */
ct.dow = FROMREG((*sc->sc_mcread)(dev, MC_DOW)) - 1;
ct.day = FROMREG((*sc->sc_mcread)(dev, MC_DOM));
ct.mon = FROMREG((*sc->sc_mcread)(dev, MC_MONTH));
year = FROMREG((*sc->sc_mcread)(dev, MC_YEAR));
year += sc->sc_year0;
if (sc->sc_flag & MC146818_NO_CENT_ADJUST) {
cent = (*sc->sc_getcent)(dev);
year += cent * 100;
} else if (year < POSIX_BASE_YEAR)
year += 100;
mtx_unlock_spin(&sc->sc_mtx);
ct.year = year;
return (clock_ct_to_ts(&ct, ts));
}
#ifdef notyet
int
mc146818_getsecs(device_t dev, int *secp)
{
struct mc146818_softc *sc;
int sec, timeout;
sc = device_get_softc(dev);
timeout = 1000000; /* XXX how long should we wait? */
for (;;) {
mtx_lock_spin(&sc->sc_mtx);
if (((*sc->sc_mcread)(dev, MC_REGA) & MC_REGA_UIP) == 0) {
sec = FROMREG((*sc->sc_mcread)(dev, MC_SEC));
mtx_unlock_spin(&sc->sc_mtx);
break;
}
mtx_unlock_spin(&sc->sc_mtx);
if (--timeout == 0) {
device_printf(dev, "%s: timeout\n", __func__);
return (EBUSY);
}
}
#undef FROMREG
*secp = sec;
return (0);
}
#endif
/*
* Set the time of day clock based on the value of the struct timespec arg.
* Return 0 on success, an error number otherwise.
*/
int
mc146818_settime(device_t dev, struct timespec *ts)
{
struct mc146818_softc *sc;
struct clocktime ct;
int cent, year;
sc = device_get_softc(dev);
/* Accuracy is only one second. */
if (ts->tv_nsec >= 500000000)
ts->tv_sec++;
ts->tv_nsec = 0;
clock_ts_to_ct(ts, &ct);
mtx_lock_spin(&sc->sc_mtx);
/* Disable RTC updates and interrupts (if enabled). */
(*sc->sc_mcwrite)(dev, MC_REGB,
((sc->sc_regb & (MC_REGB_BINARY | MC_REGB_24HR)) | MC_REGB_SET));
#define TOREG(x) ((sc->sc_flag & MC146818_BCD) ? TOBCD(x) : (x))
(*sc->sc_mcwrite)(dev, MC_SEC, TOREG(ct.sec));
(*sc->sc_mcwrite)(dev, MC_MIN, TOREG(ct.min));
(*sc->sc_mcwrite)(dev, MC_HOUR, TOREG(ct.hour));
/* Map dow from 0 - 6 to 1 - 7. */
(*sc->sc_mcwrite)(dev, MC_DOW, TOREG(ct.dow + 1));
(*sc->sc_mcwrite)(dev, MC_DOM, TOREG(ct.day));
(*sc->sc_mcwrite)(dev, MC_MONTH, TOREG(ct.mon));
year = ct.year - sc->sc_year0;
if (sc->sc_flag & MC146818_NO_CENT_ADJUST) {
cent = year / 100;
(*sc->sc_setcent)(dev, cent);
year -= cent * 100;
} else if (year > 99)
year -= 100;
(*sc->sc_mcwrite)(dev, MC_YEAR, TOREG(year));
/* Reenable RTC updates and interrupts. */
(*sc->sc_mcwrite)(dev, MC_REGB, sc->sc_regb);
mtx_unlock_spin(&sc->sc_mtx);
#undef TOREG
return (0);
}
#define MC_ADDR 0
#define MC_DATA 1
u_int
mc146818_def_read(device_t dev, u_int reg)
{
struct mc146818_softc *sc;
sc = device_get_softc(dev);
bus_space_write_1(sc->sc_bst, sc->sc_bsh, MC_ADDR, reg);
return (bus_space_read_1(sc->sc_bst, sc->sc_bsh, MC_DATA));
}
void
mc146818_def_write(device_t dev, u_int reg, u_int val)
{
struct mc146818_softc *sc;
sc = device_get_softc(dev);
bus_space_write_1(sc->sc_bst, sc->sc_bsh, MC_ADDR, reg);
bus_space_write_1(sc->sc_bst, sc->sc_bsh, MC_DATA, val);
}
#undef MC_ADDR
#undef MC_DATA
/*
* Looks like it's common even across platforms to store the century at
* 0x32 in the NVRAM of the mc146818.
*/
#define MC_CENT 0x32
static u_int
mc146818_def_getcent(device_t dev)
{
struct mc146818_softc *sc;
sc = device_get_softc(dev);
return ((*sc->sc_mcread)(dev, MC_CENT));
}
static void
mc146818_def_setcent(device_t dev, u_int cent)
{
struct mc146818_softc *sc;
sc = device_get_softc(dev);
(*sc->sc_mcwrite)(dev, MC_CENT, cent);
}
#undef MC_CENT

View File

@ -1,150 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-CMU
*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $NetBSD: mc146818reg.h,v 1.9 2006/03/08 23:46:25 lukem Exp $
*
* $FreeBSD$
*/
/*
* Definitions for the Motorola MC146818A Real Time Clock.
* They also apply for the (compatible) Dallas Semiconductor DS1287A RTC.
*
* Though there are undoubtedly other (better) sources, this material was
* culled from the DEC "KN121 System Module Programmer's Reference
* Information."
*
* The MC146818A has 16 registers. The first 10 contain time-of-year
* and alarm data. The rest contain various control and status bits.
*
* To read or write the registers, one writes the register number to
* the RTC's control port, then either reads from or writes the new
* data to the RTC's data port. Since the locations of these ports
* and the method used to access them can be machine-dependent, the
* low-level details of reading and writing the RTC's registers are
* handled by machine-specific functions.
*
* The time-of-year and alarm data can be expressed in either binary
* or BCD, and they are selected by a bit in register B.
*
* The "hour" time-of-year and alarm fields can either be expressed in
* AM/PM format, or in 24-hour format. If AM/PM format is chosen, the
* hour fields can have the values: 1-12 and 81-92 (the latter being
* PM). If the 24-hour format is chosen, they can have the values
* 0-24. The hour format is selectable by a bit in register B.
* (XXX IS AM/PM MODE DESCRIPTION CORRECT?)
*
* It is assumed the if systems are going to use BCD (rather than
* binary) mode, or AM/PM hour format, they'll do the appropriate
* conversions in machine-dependent code. Also, if the clock is
* switched between BCD and binary mode, or between AM/PM mode and
* 24-hour mode, the time-of-day and alarm registers are NOT
* automatically reset; they must be reprogrammed with correct values.
*/
/*
* The registers, and the bits within each register.
*/
#define MC_SEC 0x0 /* Time of year: seconds (0-59) */
#define MC_ASEC 0x1 /* Alarm: seconds */
#define MC_MIN 0x2 /* Time of year: minutes (0-59) */
#define MC_AMIN 0x3 /* Alarm: minutes */
#define MC_HOUR 0x4 /* Time of year: hour (see above) */
#define MC_AHOUR 0x5 /* Alarm: hour */
#define MC_DOW 0x6 /* Time of year: day of week (1-7) */
#define MC_DOM 0x7 /* Time of year: day of month (1-31) */
#define MC_MONTH 0x8 /* Time of year: month (1-12) */
#define MC_YEAR 0x9 /* Time of year: year in century (0-99) */
#define MC_REGA 0xa /* Control register A */
#define MC_REGA_RSMASK 0x0f /* Interrupt rate select mask (see below) */
#define MC_REGA_DVMASK 0x70 /* Divisor select mask (see below) */
#define MC_REGA_DV0 0x10 /* Divisor 0 */
#define MC_REGA_DV1 0x20 /* Divisor 1 */
#define MC_REGA_DV2 0x40 /* Divisor 2 */
#define MC_REGA_UIP 0x80 /* Update in progress; read only. */
#define MC_REGB 0xb /* Control register B */
#define MC_REGB_DSE 0x01 /* Daylight Savings Enable */
#define MC_REGB_24HR 0x02 /* 24-hour mode (AM/PM mode when clear) */
#define MC_REGB_BINARY 0x04 /* Binary mode (BCD mode when clear) */
#define MC_REGB_SQWE 0x08 /* Square Wave Enable */
#define MC_REGB_UIE 0x10 /* Update End interrupt enable */
#define MC_REGB_AIE 0x20 /* Alarm interrupt enable */
#define MC_REGB_PIE 0x40 /* Periodic interrupt enable */
#define MC_REGB_SET 0x80 /* Allow time to be set; stops updates */
#define MC_REGC 0xc /* Control register C */
/* MC_REGC_UNUSED 0x0f UNUSED */
#define MC_REGC_UF 0x10 /* Update End interrupt flag */
#define MC_REGC_AF 0x20 /* Alarm interrupt flag */
#define MC_REGC_PF 0x40 /* Periodic interrupt flag */
#define MC_REGC_IRQF 0x80 /* Interrupt request pending flag */
#define MC_REGD 0xd /* Control register D */
/* MC_REGD_UNUSED 0x7f UNUSED */
#define MC_REGD_VRT 0x80 /* Valid RAM and Time bit */
#define MC_NREGS 0xe /* 14 registers; CMOS follows */
#define MC_NTODREGS 0xa /* 10 of those regs are for TOD and alarm */
#define MC_NVRAM_START 0xe /* start of NVRAM: offset 14 */
#define MC_NVRAM_SIZE 50 /* 50 bytes of NVRAM */
/*
* Periodic Interrupt Rate Select constants (Control register A)
*/
#define MC_RATE_NONE 0x0 /* No periodic interrupt */
#define MC_RATE_1 0x1 /* 256 Hz if MC_BASE_32_KHz, else 32768 Hz */
#define MC_RATE_2 0x2 /* 128 Hz if MC_BASE_32_KHz, else 16384 Hz */
#define MC_RATE_8192_Hz 0x3 /* 122.070 us period */
#define MC_RATE_4096_Hz 0x4 /* 244.141 us period */
#define MC_RATE_2048_Hz 0x5 /* 488.281 us period */
#define MC_RATE_1024_Hz 0x6 /* 976.562 us period */
#define MC_RATE_512_Hz 0x7 /* 1.953125 ms period */
#define MC_RATE_256_Hz 0x8 /* 3.90625 ms period */
#define MC_RATE_128_Hz 0x9 /* 7.8125 ms period */
#define MC_RATE_64_Hz 0xa /* 15.625 ms period */
#define MC_RATE_32_Hz 0xb /* 31.25 ms period */
#define MC_RATE_16_Hz 0xc /* 62.5 ms period */
#define MC_RATE_8_Hz 0xd /* 125 ms period */
#define MC_RATE_4_Hz 0xe /* 250 ms period */
#define MC_RATE_2_Hz 0xf /* 500 ms period */
/*
* Time base (divisor select) constants (Control register A)
*/
#define MC_BASE_4_MHz 0x00 /* 4 MHz crystal */
#define MC_BASE_1_MHz MC_REGA_DV0 /* 1 MHz crystal */
#define MC_BASE_32_KHz MC_REGA_DV1 /* 32 KHz crystal */
#define MC_BASE_NONE (MC_REGA_DV2 | MC_REGA_DV1) /* actually also resets */
#define MC_BASE_RESET (MC_REGA_DV2 | MC_REGA_DV1 | MC_REGA_DV0)

View File

@ -1,67 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2003 Izumi Tsutsui. All rights reserved.
*
* 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 AUTHOR ``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 AUTHOR 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.
*
* $NetBSD: mc146818var.h,v 1.7 2008/05/14 13:29:29 tsutsui Exp $
*
* $FreeBSD$
*/
struct mc146818_softc {
bus_space_tag_t sc_bst; /* bus space tag */
bus_space_handle_t sc_bsh; /* bus space handle */
struct mtx sc_mtx; /* hardware mutex */
u_char sc_rega; /* register A */
u_char sc_regb; /* register B */
u_int sc_year0; /* year counter offset */
u_int sc_flag; /* MD flags */
#define MC146818_NO_CENT_ADJUST 0x0001 /* don't adjust century */
#define MC146818_BCD 0x0002 /* use BCD mode */
#define MC146818_12HR 0x0004 /* use AM/PM mode */
/* MD chip register read/write functions */
u_int (*sc_mcread)(device_t dev, u_int reg);
void (*sc_mcwrite)(device_t dev, u_int reg, u_int val);
/* MD century get/set functions */
u_int (*sc_getcent)(device_t dev);
void (*sc_setcent)(device_t dev, u_int cent);
};
/* Default read/write functions */
u_int mc146818_def_read(device_t dev, u_int reg);
void mc146818_def_write(device_t dev, u_int reg, u_int val);
/* Chip attach function */
int mc146818_attach(device_t);
/* Methods for the clock interface */
#ifdef notyet
int mc146818_getsecs(device_t dev, int *secp);
#endif
int mc146818_gettime(device_t dev, struct timespec *ts);
int mc146818_settime(device_t dev, struct timespec *ts);

View File

@ -1,21 +0,0 @@
# Doxyfile 1.5.2
# $FreeBSD$
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "FreeBSD kernel MC146818 device code"
OUTPUT_DIRECTORY = $(DOXYGEN_DEST_PATH)/dev_mc146818/
EXTRACT_ALL = YES # for undocumented src, no warnings enabled
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = $(DOXYGEN_SRC_PATH)/dev/mc146818/ \
$(NOTREVIEWED)
GENERATE_TAGFILE = dev_mc146818/dev_mc146818.tag
@INCLUDE_PATH = $(DOXYGEN_INCLUDE_PATH)
@INCLUDE = common-Doxyfile