Changeset View
Changeset View
Standalone View
Standalone View
sys/powerpc/powermac/macio.c
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#include <machine/vmparam.h> | #include <machine/vmparam.h> | ||||
#include <dev/ofw/ofw_bus.h> | #include <dev/ofw/ofw_bus.h> | ||||
#include <dev/ofw/ofw_bus_subr.h> | #include <dev/ofw/ofw_bus_subr.h> | ||||
#include <dev/ofw/openfirm.h> | #include <dev/ofw/openfirm.h> | ||||
#include <powerpc/powermac/maciovar.h> | #include <powerpc/powermac/maciovar.h> | ||||
#include <powerpc/powermac/platform_powermac.h> | |||||
#include <dev/pci/pcivar.h> | #include <dev/pci/pcivar.h> | ||||
#include <dev/pci/pcireg.h> | #include <dev/pci/pcireg.h> | ||||
/* | /* | ||||
* Macio softc | * Macio softc | ||||
*/ | */ | ||||
struct macio_softc { | struct macio_softc { | ||||
phandle_t sc_node; | phandle_t sc_node; | ||||
vm_offset_t sc_base; | vm_offset_t sc_base; | ||||
vm_offset_t sc_size; | vm_offset_t sc_size; | ||||
struct rman sc_mem_rman; | struct rman sc_mem_rman; | ||||
/* FCR registers */ | /* FCR registers */ | ||||
int sc_memrid; | int sc_memrid; | ||||
struct resource *sc_memr; | struct resource *sc_memr; | ||||
/* GPIO offsets */ | |||||
int sc_timebase; | |||||
}; | }; | ||||
static MALLOC_DEFINE(M_MACIO, "macio", "macio device information"); | static MALLOC_DEFINE(M_MACIO, "macio", "macio device information"); | ||||
static int macio_probe(device_t); | static int macio_probe(device_t); | ||||
static int macio_attach(device_t); | static int macio_attach(device_t); | ||||
static int macio_print_child(device_t dev, device_t child); | static int macio_print_child(device_t dev, device_t child); | ||||
static void macio_probe_nomatch(device_t, device_t); | static void macio_probe_nomatch(device_t, device_t); | ||||
static struct resource *macio_alloc_resource(device_t, device_t, int, int *, | static struct resource *macio_alloc_resource(device_t, device_t, int, int *, | ||||
rman_res_t, rman_res_t, rman_res_t, | rman_res_t, rman_res_t, rman_res_t, | ||||
u_int); | u_int); | ||||
static int macio_activate_resource(device_t, device_t, int, int, | static int macio_activate_resource(device_t, device_t, int, int, | ||||
struct resource *); | struct resource *); | ||||
static int macio_deactivate_resource(device_t, device_t, int, int, | static int macio_deactivate_resource(device_t, device_t, int, int, | ||||
struct resource *); | struct resource *); | ||||
static int macio_release_resource(device_t, device_t, int, int, | static int macio_release_resource(device_t, device_t, int, int, | ||||
struct resource *); | struct resource *); | ||||
static struct resource_list *macio_get_resource_list (device_t, device_t); | static struct resource_list *macio_get_resource_list (device_t, device_t); | ||||
static ofw_bus_get_devinfo_t macio_get_devinfo; | static ofw_bus_get_devinfo_t macio_get_devinfo; | ||||
#if !defined(__powerpc64__) && defined(SMP) | |||||
static void macio_freeze_timebase(device_t, bool); | |||||
#endif | |||||
/* | /* | ||||
* Bus interface definition | * Bus interface definition | ||||
*/ | */ | ||||
static device_method_t macio_methods[] = { | static device_method_t macio_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, macio_probe), | DEVMETHOD(device_probe, macio_probe), | ||||
DEVMETHOD(device_attach, macio_attach), | DEVMETHOD(device_attach, macio_attach), | ||||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | if ((strcmp(ofw_bus_get_name(cdev), "i2s") == 0) && | ||||
uint32_t fcr1; | uint32_t fcr1; | ||||
fcr1 = bus_read_4(sc->sc_memr, KEYLARGO_FCR1); | fcr1 = bus_read_4(sc->sc_memr, KEYLARGO_FCR1); | ||||
fcr1 |= FCR1_I2S0_CLK_ENABLE | FCR1_I2S0_ENABLE; | fcr1 |= FCR1_I2S0_CLK_ENABLE | FCR1_I2S0_ENABLE; | ||||
bus_write_4(sc->sc_memr, KEYLARGO_FCR1, fcr1); | bus_write_4(sc->sc_memr, KEYLARGO_FCR1, fcr1); | ||||
} | } | ||||
} | } | ||||
#if !defined(__powerpc64__) && defined(SMP) | |||||
/* | |||||
* Detect an SMP G4 machine. | |||||
* | |||||
* On SMP G4, timebase freeze is via a GPIO on macio. | |||||
* | |||||
* When we are on an SMP G4, we need to install a handler to | |||||
* perform timebase freeze/unfreeze on behalf of the platform. | |||||
*/ | |||||
if ((child = OF_finddevice("/cpus/PowerPC,G4@0")) != -1 && | |||||
OF_peer(child) != -1) { | |||||
if (OF_getprop(child, "timebase-enable", &sc->sc_timebase, | |||||
sizeof(sc->sc_timebase)) <= 0) | |||||
sc->sc_timebase = KEYLARGO_GPIO_BASE + 0x09; | |||||
powermac_register_timebase(dev, macio_freeze_timebase); | |||||
device_printf(dev, "GPIO timebase control at 0x%x\n", | |||||
sc->sc_timebase); | |||||
} | |||||
#endif | |||||
return (bus_generic_attach(dev)); | return (bus_generic_attach(dev)); | ||||
} | } | ||||
static int | static int | ||||
macio_print_child(device_t dev, device_t child) | macio_print_child(device_t dev, device_t child) | ||||
{ | { | ||||
struct macio_devinfo *dinfo; | struct macio_devinfo *dinfo; | ||||
struct resource_list *rl; | struct resource_list *rl; | ||||
▲ Show 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | if (enable) { | ||||
x = bus_read_4(sc->sc_memr, KEYLARGO_FCR2); | x = bus_read_4(sc->sc_memr, KEYLARGO_FCR2); | ||||
x &= ~0x4; | x &= ~0x4; | ||||
bus_write_4(sc->sc_memr, KEYLARGO_FCR2, x); | bus_write_4(sc->sc_memr, KEYLARGO_FCR2, x); | ||||
/* out8(gpio + 0x10, 0); */ | /* out8(gpio + 0x10, 0); */ | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
#if !defined(__powerpc64__) && defined(SMP) | |||||
static void | |||||
macio_freeze_timebase(device_t dev, bool freeze) | |||||
jhibbits: Is 'frozen' to mean that it's *already* frozen, or that you want to freeze it? I'd rename it… | |||||
Done Inline Actionsgood point. Will change to "freeze" bdragon: good point. Will change to "freeze" | |||||
{ | |||||
struct macio_softc *sc = device_get_softc(dev); | |||||
if (freeze) { | |||||
bus_write_1(sc->sc_memr, sc->sc_timebase, 4); | |||||
} else { | |||||
bus_write_1(sc->sc_memr, sc->sc_timebase, 0); | |||||
} | |||||
bus_read_1(sc->sc_memr, sc->sc_timebase); | |||||
} | |||||
#endif |
Is 'frozen' to mean that it's *already* frozen, or that you want to freeze it? I'd rename it 'freeze' in that case, or 'thaw' if it's already frozen.