From 74ab06b7a7c2b8371a9655c5c209f508157c6591 Mon Sep 17 00:00:00 2001 From: macallan Date: Sun, 10 Dec 2006 02:41:30 +0000 Subject: [PATCH] when powering up the mediabay wait two seconds before looking for devices Without this CDROM drives wouldn't be found when hotplugged. --- sys/arch/macppc/dev/mediabay.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/sys/arch/macppc/dev/mediabay.c b/sys/arch/macppc/dev/mediabay.c index 7cc7b751870b..dc4a46583ffc 100644 --- a/sys/arch/macppc/dev/mediabay.c +++ b/sys/arch/macppc/dev/mediabay.c @@ -1,4 +1,4 @@ -/* $NetBSD: mediabay.c,v 1.11 2005/12/11 12:18:03 christos Exp $ */ +/* $NetBSD: mediabay.c,v 1.12 2006/12/10 02:41:30 macallan Exp $ */ /*- * Copyright (C) 1999 Tsubai Masanari. All rights reserved. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mediabay.c,v 1.11 2005/12/11 12:18:03 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mediabay.c,v 1.12 2006/12/10 02:41:30 macallan Exp $"); #include #include @@ -142,17 +142,28 @@ mediabay_attach_content(sc) char name[32]; fcr = in32rb(sc->sc_fcr); - fcr |= FCR_MEDIABAY_ENABLE | FCR_MEDIABAY_RESET; - out32rb(sc->sc_fcr, fcr); - delay(50000); - fcr &= ~FCR_MEDIABAY_RESET; - out32rb(sc->sc_fcr, fcr); - delay(50000); + /* + * if the mediabay isn't powered up we need to wait a few seconds + * before probing devices + */ + if ((fcr & (FCR_MEDIABAY_ENABLE | FCR_MEDIABAY_IDE_ENABLE + | FCR_MEDIABAY_CD_POWER)) != (FCR_MEDIABAY_ENABLE + | FCR_MEDIABAY_IDE_ENABLE | FCR_MEDIABAY_CD_POWER)) { + fcr |= FCR_MEDIABAY_ENABLE | FCR_MEDIABAY_RESET; + out32rb(sc->sc_fcr, fcr); + delay(50000); - fcr |= FCR_MEDIABAY_IDE_ENABLE | FCR_MEDIABAY_CD_POWER; - out32rb(sc->sc_fcr, fcr); - delay(50000); + fcr &= ~FCR_MEDIABAY_RESET; + out32rb(sc->sc_fcr, fcr); + delay(50000); + + fcr |= FCR_MEDIABAY_IDE_ENABLE | FCR_MEDIABAY_CD_POWER; + out32rb(sc->sc_fcr, fcr); + delay(50000); + printf("%s: powering up...\n", sc->sc_dev.dv_xname); + delay(2000000); + } for (child = OF_child(sc->sc_node); child; child = OF_peer(child)) { memset(name, 0, sizeof(name));