summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/powermac/macio.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/powerpc/powermac/macio.c')
-rw-r--r--sys/powerpc/powermac/macio.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c
index b31cf15..8a980ba 100644
--- a/sys/powerpc/powermac/macio.c
+++ b/sys/powerpc/powermac/macio.c
@@ -236,13 +236,45 @@ macio_add_intr(phandle_t devnode, struct macio_devinfo *dinfo)
static void
macio_add_reg(phandle_t devnode, struct macio_devinfo *dinfo)
{
- struct macio_reg *reg;
- int i, nreg;
+ struct macio_reg *reg, *regp;
+ phandle_t child;
+ char buf[8];
+ int i, layout_id = 0, nreg, res;
nreg = OF_getprop_alloc(devnode, "reg", sizeof(*reg), (void **)&reg);
if (nreg == -1)
return;
+ /*
+ * Some G5's have broken properties in the i2s-a area. If so we try
+ * to fix it. Right now we know of two different cases, one for
+ * sound layout-id 36 and the other one for sound layout-id 76.
+ * What is missing is the base address for the memory addresses.
+ * We take them from the parent node (i2s) and use the size
+ * information from the child.
+ */
+
+ if (reg[0].mr_base == 0) {
+ child = OF_child(devnode);
+ while (child != 0) {
+ res = OF_getprop(child, "name", buf, sizeof(buf));
+ if (res > 0 && strcmp(buf, "sound") == 0)
+ break;
+ child = OF_peer(child);
+ }
+
+ res = OF_getprop(child, "layout-id", &layout_id,
+ sizeof(layout_id));
+
+ if (res > 0 && (layout_id == 36 || layout_id == 76)) {
+ res = OF_getprop_alloc(OF_parent(devnode), "reg",
+ sizeof(*regp), (void **)&regp);
+ reg[0] = regp[0];
+ reg[1].mr_base = regp[1].mr_base;
+ reg[2].mr_base = regp[1].mr_base + reg[1].mr_size;
+ }
+ }
+
for (i = 0; i < nreg; i++) {
resource_list_add(&dinfo->mdi_resources, SYS_RES_MEMORY, i,
reg[i].mr_base, reg[i].mr_base + reg[i].mr_size,
@@ -284,6 +316,7 @@ macio_attach(device_t dev)
phandle_t subchild;
device_t cdev;
u_int reg[3];
+ char compat[32];
int error, quirks;
sc = device_get_softc(dev);
@@ -297,6 +330,9 @@ macio_attach(device_t dev)
return (ENXIO);
}
+ /* Used later to see if we have to enable the I2S part. */
+ OF_getprop(root, "compatible", compat, sizeof(compat));
+
sc->sc_base = reg[2];
sc->sc_size = MACIO_REG_SIZE;
@@ -378,6 +414,21 @@ macio_attach(device_t dev)
bus_write_4(sc->sc_memr, HEATHROW_FCR, fcr);
}
+
+ /*
+ * Make sure the I2S0 and the I2S0_CLK are enabled.
+ * On certain G5's they are not.
+ */
+ if ((strcmp(ofw_bus_get_name(cdev), "i2s") == 0) &&
+ (strcmp(compat, "K2-Keylargo") == 0)) {
+
+ uint32_t fcr1;
+
+ fcr1 = bus_read_4(sc->sc_memr, KEYLARGO_FCR1);
+ fcr1 |= FCR1_I2S0_CLK_ENABLE | FCR1_I2S0_ENABLE;
+ bus_write_4(sc->sc_memr, KEYLARGO_FCR1, fcr1);
+ }
+
}
return (bus_generic_attach(dev));
OpenPOWER on IntegriCloud