Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amiga The a2kbbc is now based on MI MSM6242B driver.



details:   https://anonhg.NetBSD.org/src/rev/f08c5f364227
branches:  trunk
changeset: 782681:f08c5f364227
user:      rkujawa <rkujawa%NetBSD.org@localhost>
date:      Wed Nov 14 01:55:25 2012 +0000

description:
The a2kbbc is now based on MI MSM6242B driver.

diffstat:

 sys/arch/amiga/conf/files.amiga |    4 +-
 sys/arch/amiga/dev/a2kbbc.c     |  176 ++++++---------------------------------
 2 files changed, 32 insertions(+), 148 deletions(-)

diffs (247 lines):

diff -r 01ec5090512a -r f08c5f364227 sys/arch/amiga/conf/files.amiga
--- a/sys/arch/amiga/conf/files.amiga   Wed Nov 14 01:52:48 2012 +0000
+++ b/sys/arch/amiga/conf/files.amiga   Wed Nov 14 01:55:25 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amiga,v 1.163 2012/10/27 11:54:21 phx Exp $
+#      $NetBSD: files.amiga,v 1.164 2012/11/14 01:55:25 rkujawa Exp $
 
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16                       # NOTE THAT AMIGA IS SPECIAL!
@@ -76,7 +76,7 @@
 file   arch/amiga/dev/clock.c
 
 # A2000 internal hwc
-device a2kbbc
+device a2kbbc: msm6242b
 attach a2kbbc at mainbus
 file   arch/amiga/dev/a2kbbc.c         a2kbbc
 
diff -r 01ec5090512a -r f08c5f364227 sys/arch/amiga/dev/a2kbbc.c
--- a/sys/arch/amiga/dev/a2kbbc.c       Wed Nov 14 01:52:48 2012 +0000
+++ b/sys/arch/amiga/dev/a2kbbc.c       Wed Nov 14 01:55:25 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: a2kbbc.c,v 1.24 2012/10/27 17:17:26 chs Exp $ */
+/*     $NetBSD: a2kbbc.c,v 1.25 2012/11/14 01:55:25 rkujawa Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,37 +39,42 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: a2kbbc.c,v 1.24 2012/10/27 17:17:26 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: a2kbbc.c,v 1.25 2012/11/14 01:55:25 rkujawa Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
 #include <sys/systm.h>
+#include <sys/bus.h>
 #include <machine/psl.h>
 #include <machine/cpu.h>
 #include <amiga/amiga/device.h>
 #include <amiga/amiga/custom.h>
 #include <amiga/amiga/cia.h>
-#include <amiga/dev/rtc.h>
 #include <amiga/dev/zbusvar.h>
 
 #include <dev/clock_subr.h>
 
-int a2kbbc_match(device_t, cfdata_t, void *);
-void a2kbbc_attach(device_t, device_t, void *);
+#include <dev/ic/msm6242bvar.h>
+#include <dev/ic/msm6242breg.h>
+
+#define        A2KBBC_ADDR     0xDC0000        /* XXX: possible D80000 on A2000 "A"? */
 
-CFATTACH_DECL_NEW(a2kbbc, 0,
+static int a2kbbc_match(device_t, cfdata_t, void *);
+static void a2kbbc_attach(device_t, device_t, void *);
+
+struct a2kbbc_softc {
+       struct msm6242b_softc sc_msm6242b;
+       struct bus_space_tag sc_bst;
+};
+
+CFATTACH_DECL_NEW(a2kbbc, sizeof(struct a2kbbc_softc),
     a2kbbc_match, a2kbbc_attach, NULL, NULL);
 
-void *a2kclockaddr;
-int a2kugettod(todr_chip_handle_t, struct clock_ymdhms *);
-int a2kusettod(todr_chip_handle_t, struct clock_ymdhms *);
-static struct todr_chip_handle a2ktodr;
-
-int
+static int
 a2kbbc_match(device_t parent, cfdata_t cf, void *aux)
 {
-       struct clock_ymdhms dt;
+       //struct clock_ymdhms dt;
        static int a2kbbc_matched = 0;
 
        if (!matchname("a2kbbc", aux))
@@ -86,10 +91,6 @@
            )
                return (0);
 
-       a2kclockaddr = (void *)__UNVOLATILE(ztwomap(0xdc0000));
-       if (a2kugettod(&a2ktodr, &dt) != 0)
-               return (0);
-
        a2kbbc_matched = 1;
        return (1);
 }
@@ -100,141 +101,24 @@
 void
 a2kbbc_attach(device_t parent, device_t self, void *aux)
 {
-       printf("\n");
-       a2kclockaddr = (void *)__UNVOLATILE(ztwomap(0xdc0000));
-
-       a2ktodr.cookie = a2kclockaddr;
-       a2ktodr.todr_gettime_ymdhms = a2kugettod;
-       a2ktodr.todr_settime_ymdhms = a2kusettod;
-       todr_attach(&a2ktodr);
-}
+       struct a2kbbc_softc *sc;
+       struct msm6242b_softc *msc;
 
-int
-a2kugettod(todr_chip_handle_t h, struct clock_ymdhms *dt)
-{
-       struct rtclock2000 *rt;
-       int i;
-
-       rt = a2kclockaddr;
-
-       /*
-        * hold clock
-        */
-       rt->control1 |= A2CONTROL1_HOLD;
-       i = 0x1000;
-       while (rt->control1 & A2CONTROL1_BUSY && i--)
-               ;
-       if (rt->control1 & A2CONTROL1_BUSY)
-               return (ENXIO);         /* Give up and say it's not there */
+       sc = device_private(self);
+       msc = &sc->sc_msm6242b;
+       msc->sc_dev = self;
 
-       /* Copy the info.  Careful about the order! */
-       dt->dt_sec   = rt->second1 * 10 + rt->second2;
-       dt->dt_min   = rt->minute1 * 10 + rt->minute2;
-       dt->dt_hour  = (rt->hour1 & 3) * 10 + rt->hour2;
-       dt->dt_day   = rt->day1    * 10 + rt->day2;
-       dt->dt_mon   = rt->month1  * 10 + rt->month2;
-       dt->dt_year  = rt->year1   * 10 + rt->year2;
-       dt->dt_wday  = rt->weekday;
+       sc->sc_bst.base = (bus_addr_t) __UNVOLATILE(ztwomap(A2KBBC_ADDR+1));
+       sc->sc_bst.absm = &amiga_bus_stride_4;
 
-       /*
-        * The oki clock chip has a register to put the clock into
-        * 12/24h mode.
-        *
-        *  clockmode   |    A2HOUR1_PM
-        *  24h   12h   |  am = 0, pm = 1
-        * ---------------------------------
-        *   0    12    |       0
-        *   1     1    |       0
-        *  ..    ..    |       0
-        *  11    11    |       0
-        *  12    12    |       1
-        *  13     1    |       1
-        *  ..    ..    |       1
-        *  23    11    |       1
-        *
-        */
+       msc->sc_iot = &sc->sc_bst;
 
-       if ((rt->control3 & A2CONTROL3_24HMODE) == 0) {
-               if ((rt->hour1 & A2HOUR1_PM) == 0 && dt->dt_hour == 12)
-                       dt->dt_hour = 0;
-               else if ((rt->hour1 & A2HOUR1_PM) && dt->dt_hour != 12)
-                       dt->dt_hour += 12;
+       if (bus_space_map(msc->sc_iot, 0, MSM6242B_SIZE, 0, &msc->sc_ioh)) {
+               aprint_error_dev(msc->sc_dev, "couldn't map registers\n");
+               return;
        }
 
-       /*
-        * release the clock
-        */
-       rt->control1 &= ~A2CONTROL1_HOLD;
-
-       dt->dt_year += CLOCK_BASE_YEAR;
-       if (dt->dt_year < STARTOFTIME)
-               dt->dt_year += 100;
-
-       /*
-        * Note that this check is redundant with one in kern_todr.c, but
-        * attach relies on it being here.
-        */
-       if ((dt->dt_hour > 23) ||
-           (dt->dt_day  > 31) ||
-           (dt->dt_mon  > 12) ||
-           /* (dt->dt_year < STARTOFTIME) || */ (dt->dt_year > 2036))
-               return (EINVAL);
-
-       return (0);
+       msm6242b_attach(msc);
 }
 
-int
-a2kusettod(todr_chip_handle_t h, struct clock_ymdhms *dt)
-{
-       struct rtclock2000 *rt;
-       int ampm, i;
 
-       rt = a2kclockaddr;
-       /*
-        * there seem to be problems with the bitfield addressing
-        * currently used..
-        */
-       if (! rt)
-               return (ENXIO);
-
-       /*
-        * hold clock
-        */
-       rt->control1 |= A2CONTROL1_HOLD;
-       i = 0x1000;
-       while (rt->control1 & A2CONTROL1_BUSY && i--)
-               ;
-       if (rt->control1 & A2CONTROL1_BUSY)
-               return (ENXIO);         /* Give up and say it's not there */
-
-       ampm = 0;
-       if ((rt->control3 & A2CONTROL3_24HMODE) == 0) {
-               if (dt->dt_hour >= 12) {
-                       ampm = A2HOUR1_PM;
-                       if (dt->dt_hour != 12)
-                               dt->dt_hour -= 12;
-               } else if (dt->dt_hour == 0) {
-                       dt->dt_hour = 12;
-               }
-       }
-       rt->hour1   = (dt->dt_hour / 10) | ampm;
-       rt->hour2   = dt->dt_hour % 10;
-       rt->second1 = dt->dt_sec / 10;
-       rt->second2 = dt->dt_sec % 10;
-       rt->minute1 = dt->dt_min / 10;
-       rt->minute2 = dt->dt_min % 10;
-       rt->day1    = dt->dt_day / 10;
-       rt->day2    = dt->dt_day % 10;
-       rt->month1  = dt->dt_mon / 10;
-       rt->month2  = dt->dt_mon % 10;
-       rt->year1   = (dt->dt_year / 10) % 10;
-       rt->year2   = dt->dt_year % 10;
-       rt->weekday = dt->dt_wday;
-
-       /*
-        * release the clock
-        */
-       rt->control2 &= ~A2CONTROL1_HOLD;
-
-       return (0);
-}



Home | Main Index | Thread Index | Old Index