1/* $NetBSD: mkclock_pnpbus.c,v 1.5 2008/04/28 20:23:33 martin Exp $ */
2/*-
3 * Copyright (c) 2006 The NetBSD Foundation, Inc.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Tim Rightnour
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/*
32 * Mostek MK48T18 time-of-day chip attachment to pnpbus, using two
33 * 8-bit ports for address selection and one 8-bit port for data.
34 *
35 * Note that this is essentially a stub driver. We cannot attach the clock
36 * with this driver because the clock and nvram part are one in the same, and
37 * share the same IO ports.  If we attach the clock, the NVRAM driver will
38 * fail to attach.  Instead, we note that we have an mk48txx device, and in
39 * the nvram driver, we will attach the clock goop there.
40 *
41 * Therefore the probe will always fail.
42 */
43
44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: mkclock_pnpbus.c,v 1.5 2008/04/28 20:23:33 martin Exp $");
46
47#include <sys/param.h>
48#include <sys/kernel.h>
49#include <sys/systm.h>
50#include <sys/device.h>
51
52#include <sys/bus.h>
53#include <machine/residual.h>
54#include <machine/chpidpnp.h>
55
56#include <dev/isa/isavar.h>
57#include <prep/pnpbus/pnpbusvar.h>
58
59extern int prep_clock_mk48txx;
60
61static int	mkclock_pnpbus_probe(device_t, cfdata_t, void *);
62
63CFATTACH_DECL_NEW(mkclock_pnpbus, 0, mkclock_pnpbus_probe, NULL, NULL, NULL);
64
65static int
66mkclock_pnpbus_probe(device_t parent, cfdata_t cf, void *aux)
67{
68	struct pnpbus_dev_attach_args *pna = aux;
69
70	if (strcmp(pna->pna_devid, "PNP0B00") == 0 &&
71	    pna->subtype == RealTimeClock && pna->chipid == MOTmk48)
72		prep_clock_mk48txx = 1;
73
74	return 0;
75}
76