Deleted Added
full compact
uninorth.c (258272) uninorth.c (259284)
1/*-
2 * Copyright (C) 2002 Benno Rice.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
1/*-
2 * Copyright (C) 2002 Benno Rice.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/sys/powerpc/powermac/uninorth.c 258272 2013-11-17 19:01:13Z nwhitehorn $
25 * $FreeBSD: head/sys/powerpc/powermac/uninorth.c 259284 2013-12-13 02:37:35Z jhibbits $
26 */
27
28#include <sys/param.h>
29#include <sys/systm.h>
30#include <sys/module.h>
31#include <sys/bus.h>
32#include <sys/conf.h>
33#include <sys/kernel.h>

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

131static driver_t unin_chip_driver = {
132 "unin",
133 unin_chip_methods,
134 sizeof(struct unin_chip_softc)
135};
136
137static devclass_t unin_chip_devclass;
138
26 */
27
28#include <sys/param.h>
29#include <sys/systm.h>
30#include <sys/module.h>
31#include <sys/bus.h>
32#include <sys/conf.h>
33#include <sys/kernel.h>

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

131static driver_t unin_chip_driver = {
132 "unin",
133 unin_chip_methods,
134 sizeof(struct unin_chip_softc)
135};
136
137static devclass_t unin_chip_devclass;
138
139/*
140 * Assume there is only one unin chip in a PowerMac, so that pmu.c functions can
141 * suspend the chip after the whole rest of the device tree is suspended, not
142 * earlier.
143 */
144static device_t unin_chip;
145
139DRIVER_MODULE(unin, nexus, unin_chip_driver, unin_chip_devclass, 0, 0);
140
141/*
142 * Add an interrupt to the dev's resource list if present
143 */
144static void
145unin_chip_add_intr(phandle_t devnode, struct unin_chip_devinfo *dinfo)
146{

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

205 resource_list_add(&dinfo->udi_resources, SYS_RES_MEMORY, i,
206 reg[i].mr_base,
207 reg[i].mr_base + reg[i].mr_size,
208 reg[i].mr_size);
209 }
210}
211
212static void
146DRIVER_MODULE(unin, nexus, unin_chip_driver, unin_chip_devclass, 0, 0);
147
148/*
149 * Add an interrupt to the dev's resource list if present
150 */
151static void
152unin_chip_add_intr(phandle_t devnode, struct unin_chip_devinfo *dinfo)
153{

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

212 resource_list_add(&dinfo->udi_resources, SYS_RES_MEMORY, i,
213 reg[i].mr_base,
214 reg[i].mr_base + reg[i].mr_size,
215 reg[i].mr_size);
216 }
217}
218
219static void
213unin_enable_gmac(device_t dev)
220unin_update_reg(device_t dev, uint32_t regoff, uint32_t set, uint32_t clr)
214{
221{
215 volatile u_int *clkreg;
222 volatile u_int *reg;
216 struct unin_chip_softc *sc;
217 u_int32_t tmpl;
218
219 sc = device_get_softc(dev);
223 struct unin_chip_softc *sc;
224 u_int32_t tmpl;
225
226 sc = device_get_softc(dev);
220 clkreg = (void *)(sc->sc_addr + UNIN_CLOCKCNTL);
221 tmpl = inl(clkreg);
222 tmpl |= UNIN_CLOCKCNTL_GMAC;
223 outl(clkreg, tmpl);
227 reg = (void *)(sc->sc_addr + regoff);
228 tmpl = inl(reg);
229 tmpl &= ~clr;
230 tmpl |= set;
231 outl(reg, tmpl);
224}
225
226static void
232}
233
234static void
227unin_enable_mpic(device_t dev)
235unin_enable_gmac(device_t dev)
228{
236{
229 volatile u_int *toggle;
230 struct unin_chip_softc *sc;
231 u_int32_t tmpl;
237 unin_update_reg(dev, UNIN_CLOCKCNTL, UNIN_CLOCKCNTL_GMAC, 0);
238}
232
239
233 sc = device_get_softc(dev);
234 toggle = (void *)(sc->sc_addr + UNIN_TOGGLE_REG);
235 tmpl = inl(toggle);
236 tmpl |= UNIN_MPIC_RESET | UNIN_MPIC_OUTPUT_ENABLE;
237 outl(toggle, tmpl);
240static void
241unin_enable_mpic(device_t dev)
242{
243 unin_update_reg(dev, UNIN_TOGGLE_REG, UNIN_MPIC_RESET | UNIN_MPIC_OUTPUT_ENABLE, 0);
238}
239
240static int
241unin_chip_probe(device_t dev)
242{
243 const char *name;
244
245 name = ofw_bus_get_name(dev);

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

306 sc->sc_physaddr + sc->sc_size - 1);
307 if (error) {
308 device_printf(dev,
309 "rman_manage_region() failed. error = %d\n",
310 error);
311 return (error);
312 }
313
244}
245
246static int
247unin_chip_probe(device_t dev)
248{
249 const char *name;
250
251 name = ofw_bus_get_name(dev);

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

312 sc->sc_physaddr + sc->sc_size - 1);
313 if (error) {
314 device_printf(dev,
315 "rman_manage_region() failed. error = %d\n",
316 error);
317 return (error);
318 }
319
320 if (unin_chip == NULL)
321 unin_chip = dev;
322
314 /*
315 * Iterate through the sub-devices
316 */
317 for (child = OF_child(root); child != 0; child = OF_peer(child)) {
318 dinfo = malloc(sizeof(*dinfo), M_UNIN, M_WAITOK | M_ZERO);
319 if (ofw_bus_gen_setup_devinfo(&dinfo->udi_obdinfo, child)
320 != 0)
321 {

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

626unin_chip_get_devinfo(device_t dev, device_t child)
627{
628 struct unin_chip_devinfo *dinfo;
629
630 dinfo = device_get_ivars(child);
631 return (&dinfo->udi_obdinfo);
632}
633
323 /*
324 * Iterate through the sub-devices
325 */
326 for (child = OF_child(root); child != 0; child = OF_peer(child)) {
327 dinfo = malloc(sizeof(*dinfo), M_UNIN, M_WAITOK | M_ZERO);
328 if (ofw_bus_gen_setup_devinfo(&dinfo->udi_obdinfo, child)
329 != 0)
330 {

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

635unin_chip_get_devinfo(device_t dev, device_t child)
636{
637 struct unin_chip_devinfo *dinfo;
638
639 dinfo = device_get_ivars(child);
640 return (&dinfo->udi_obdinfo);
641}
642
643int
644unin_chip_wake(device_t dev)
645{
646
647 if (dev == NULL)
648 dev = unin_chip;
649 unin_update_reg(dev, UNIN_PWR_MGMT, UNIN_PWR_NORMAL, UNIN_PWR_MASK);
650 DELAY(10);
651 unin_update_reg(dev, UNIN_HWINIT_STATE, UNIN_RUNNING, 0);
652 DELAY(100);
653
654 return (0);
655}
656
657int
658unin_chip_sleep(device_t dev, int idle)
659{
660 if (dev == NULL)
661 dev = unin_chip;
662
663 unin_update_reg(dev, UNIN_HWINIT_STATE, UNIN_SLEEPING, 0);
664 DELAY(10);
665 if (idle)
666 unin_update_reg(dev, UNIN_PWR_MGMT, UNIN_PWR_IDLE2, UNIN_PWR_MASK);
667 else
668 unin_update_reg(dev, UNIN_PWR_MGMT, UNIN_PWR_SLEEP, UNIN_PWR_MASK);
669 DELAY(10);
670
671 return (0);
672}