Deleted Added
full compact
cuda.c (209639) cuda.c (212054)
1/*-
2 * Copyright (c) 2006 Michael Lorenz
3 * Copyright 2008 by Nathan Whitehorn
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:

--- 15 unchanged lines hidden (view full) ---

24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006 Michael Lorenz
3 * Copyright 2008 by Nathan Whitehorn
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:

--- 15 unchanged lines hidden (view full) ---

24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/powerpc/powermac/cuda.c 209639 2010-07-02 02:17:39Z marcel $");
32__FBSDID("$FreeBSD: head/sys/powerpc/powermac/cuda.c 212054 2010-08-31 15:27:46Z nwhitehorn $");
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/module.h>
37#include <sys/bus.h>
38#include <sys/conf.h>
39#include <sys/kernel.h>
40#include <sys/clock.h>
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/module.h>
37#include <sys/bus.h>
38#include <sys/conf.h>
39#include <sys/kernel.h>
40#include <sys/clock.h>
41#include <sys/reboot.h>
41
42#include <dev/ofw/ofw_bus.h>
43#include <dev/ofw/openfirm.h>
44
45#include <machine/bus.h>
46#include <machine/intr_machdep.h>
47#include <machine/md_var.h>
48#include <machine/pio.h>

--- 18 unchanged lines hidden (view full) ---

67static int cuda_detach(device_t);
68
69static u_int cuda_adb_send(device_t dev, u_char command_byte, int len,
70 u_char *data, u_char poll);
71static u_int cuda_adb_autopoll(device_t dev, uint16_t mask);
72static u_int cuda_poll(device_t dev);
73static void cuda_send_inbound(struct cuda_softc *sc);
74static void cuda_send_outbound(struct cuda_softc *sc);
42
43#include <dev/ofw/ofw_bus.h>
44#include <dev/ofw/openfirm.h>
45
46#include <machine/bus.h>
47#include <machine/intr_machdep.h>
48#include <machine/md_var.h>
49#include <machine/pio.h>

--- 18 unchanged lines hidden (view full) ---

68static int cuda_detach(device_t);
69
70static u_int cuda_adb_send(device_t dev, u_char command_byte, int len,
71 u_char *data, u_char poll);
72static u_int cuda_adb_autopoll(device_t dev, uint16_t mask);
73static u_int cuda_poll(device_t dev);
74static void cuda_send_inbound(struct cuda_softc *sc);
75static void cuda_send_outbound(struct cuda_softc *sc);
76static void cuda_shutdown(void *xsc, int howto);
75
76/*
77 * Clock interface
78 */
79static int cuda_gettime(device_t dev, struct timespec *ts);
80static int cuda_settime(device_t dev, struct timespec *ts);
81
82static device_method_t cuda_methods[] = {

--- 161 unchanged lines hidden (view full) ---

244 device_printf(dev, "CUDA child <%s>\n",name);
245
246 if (strncmp(name, "adb", 4) == 0) {
247 sc->adb_bus = device_add_child(dev,"adb",-1);
248 }
249 }
250
251 clock_register(dev, 1000);
77
78/*
79 * Clock interface
80 */
81static int cuda_gettime(device_t dev, struct timespec *ts);
82static int cuda_settime(device_t dev, struct timespec *ts);
83
84static device_method_t cuda_methods[] = {

--- 161 unchanged lines hidden (view full) ---

246 device_printf(dev, "CUDA child <%s>\n",name);
247
248 if (strncmp(name, "adb", 4) == 0) {
249 sc->adb_bus = device_add_child(dev,"adb",-1);
250 }
251 }
252
253 clock_register(dev, 1000);
254 EVENTHANDLER_REGISTER(shutdown_final, cuda_shutdown, sc,
255 SHUTDOWN_PRI_LAST);
252
253 return (bus_generic_attach(dev));
254}
255
256static int cuda_detach(device_t dev) {
257 struct cuda_softc *sc;
258
259 sc = device_get_softc(dev);

--- 474 unchanged lines hidden (view full) ---

734 sc->sc_autopoll = -1;
735 cuda_send(sc, 1, 3, cmd);
736
737 mtx_unlock(&sc->sc_mutex);
738
739 return (0);
740}
741
256
257 return (bus_generic_attach(dev));
258}
259
260static int cuda_detach(device_t dev) {
261 struct cuda_softc *sc;
262
263 sc = device_get_softc(dev);

--- 474 unchanged lines hidden (view full) ---

738 sc->sc_autopoll = -1;
739 cuda_send(sc, 1, 3, cmd);
740
741 mtx_unlock(&sc->sc_mutex);
742
743 return (0);
744}
745
746static void
747cuda_shutdown(void *xsc, int howto)
748{
749 struct cuda_softc *sc = xsc;
750 uint8_t cmd[] = {CUDA_PSEUDO, 0};
751
752 cmd[1] = (howto & RB_HALT) ? CMD_POWEROFF : CMD_RESET;
753 cuda_poll(sc->sc_dev);
754 cuda_send(sc, 1, 2, cmd);
755
756 while (1)
757 cuda_poll(sc->sc_dev);
758}
759
742#define DIFF19041970 2082844800
743
744static int
745cuda_gettime(device_t dev, struct timespec *ts)
746{
747 struct cuda_softc *sc = device_get_softc(dev);
748 uint8_t cmd[] = {CUDA_PSEUDO, CMD_READ_RTC};
749

--- 30 unchanged lines hidden ---
760#define DIFF19041970 2082844800
761
762static int
763cuda_gettime(device_t dev, struct timespec *ts)
764{
765 struct cuda_softc *sc = device_get_softc(dev);
766 uint8_t cmd[] = {CUDA_PSEUDO, CMD_READ_RTC};
767

--- 30 unchanged lines hidden ---