Source-Changes-HG archive

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

[src/trunk]: src/sys Split gcscpcib into MI part, and MD pci attachement whic...



details:   https://anonhg.NetBSD.org/src/rev/85730e16e5a1
branches:  trunk
changeset: 768771:85730e16e5a1
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Aug 27 12:47:49 2011 +0000

description:
Split gcscpcib into MI part, and MD pci attachement which is also in
charge of attaching the MD pcib device.
Will be used by the upcoming evbmips loongson support.

diffstat:

 sys/arch/i386/conf/files.i386    |    7 +-
 sys/arch/i386/pci/gcscpcib.c     |  511 ---------------------------------------
 sys/arch/i386/pci/gcscpcib_pci.c |  108 ++++++++
 sys/arch/i386/pci/gcscpcibreg.h  |  141 ----------
 sys/dev/ic/gcscpcib.c            |  443 +++++++++++++++++++++++++++++++++
 sys/dev/ic/gcscpcibreg.h         |  141 ++++++++++
 sys/dev/ic/gcscpcibvar.h         |   51 +++
 7 files changed, 747 insertions(+), 655 deletions(-)

diffs (truncated from 1440 to 300 lines):

diff -r daa3583d5525 -r 85730e16e5a1 sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386     Sat Aug 27 09:32:11 2011 +0000
+++ b/sys/arch/i386/conf/files.i386     Sat Aug 27 12:47:49 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.i386,v 1.360 2011/06/12 03:35:41 rmind Exp $
+#      $NetBSD: files.i386,v 1.361 2011/08/27 12:47:49 bouyer Exp $
 #
 # new style config file for i386 architecture
 #
@@ -213,8 +213,9 @@
 
 # AMD Geode CS5535/CS5536 PCI-ISA bridge
 device gcscpcib: isabus, sysmon_wdog, gpiobus
-attach gcscpcib at pci
-file   arch/i386/pci/gcscpcib.c        gcscpcib
+attach gcscpcib at pci with gcscpcib_pci
+file   arch/i386/pci/gcscpcib_pci.c    gcscpcib_pci
+file   dev/ic/gcscpcib.c               gcscpcib
 
 device piixpcib: isabus, bioscall
 attach piixpcib at pci
diff -r daa3583d5525 -r 85730e16e5a1 sys/arch/i386/pci/gcscpcib.c
--- a/sys/arch/i386/pci/gcscpcib.c      Sat Aug 27 09:32:11 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,511 +0,0 @@
-/* $NetBSD: gcscpcib.c,v 1.8 2009/09/27 18:31:58 jakllsch Exp $ */
-/* $OpenBSD: gcscpcib.c,v 1.6 2007/11/17 17:02:47 mbalmer Exp $        */
-
-/*
- * Copyright (c) 2008 Yojiro UO <yuo%nui.org@localhost>
- * Copyright (c) 2007 Marc Balmer <mbalmer%openbsd.org@localhost>
- * Copyright (c) 2007 Michael Shalayeff
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * AMD CS5535/CS5536 series LPC bridge also containing timer, watchdog and GPIO.
- */
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gcscpcib.c,v 1.8 2009/09/27 18:31:58 jakllsch Exp $");
-
-#include "gpio.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-#include <sys/gpio.h>
-#include <sys/sysctl.h>
-#include <sys/timetc.h>
-#include <sys/wdog.h>
-
-#include <sys/bus.h>
-#include <machine/cpufunc.h>
-
-#if NGPIO > 0
-#include <dev/gpio/gpiovar.h>
-#endif
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcidevs.h>
-
-#include <dev/sysmon/sysmonvar.h>
-
-#include <arch/i386/pci/gcscpcibreg.h>
-#include <arch/x86/pci/pcibvar.h>
-
-/* define if you need to select MFGPT for watchdog manually (0-5). */
-/* #define AMD553X_WDT_FORCEUSEMFGPT   0 */
-/* select precision of watchdog timer (default value = 0.25sec (4Hz tick) */
-#define        AMD553X_MFGPT_PRESCALE  AMD553X_MFGPT_DIV_8K /* 32K/8K = 4Hz */
-
-/* #define GCSCPCIB_DEBUG */
-#ifdef GCSCPCIB_DEBUG
-#define DPRINTF(x)     printf x
-#else
-#define DPRINTF(x)
-#endif
-
-/* 1 bit replace (not support multiple bit)*/
-#define AMD553X_MFGPTx_NR_DISABLE(x, bit) \
-       ( wrmsr(AMD553X_MFGPT_NR, rdmsr(AMD553X_MFGPT_NR) & ~((bit) << (x))) )
-#define AMD553X_MFGPTx_NR_ENABLE(x, bit) \
-       ( wrmsr(AMD553X_MFGPT_NR, rdmsr(AMD553X_MFGPT_NR) | ((bit) << (x))) )
-
-/* caliculate watchdog timer setting */
-#define        AMD553X_WDT_TICK (1<<(AMD553X_MFGPT_DIV_32K - AMD553X_MFGPT_PRESCALE))
-#define AMD553X_WDT_COUNTMAX   (0xffff / AMD553X_WDT_TICK)
-
-struct gcscpcib_softc {
-       /* we call pcibattach() which assumes softc starts like this: */
-       struct pcib_softc       sc_pcib;
-
-       pcireg_t                sc_pirqrc;
-
-       struct timecounter      sc_timecounter;
-       bus_space_tag_t         sc_iot;
-       bus_space_handle_t      sc_ioh;
-
-       /* Watchdog Timer */
-       struct sysmon_wdog      sc_smw;
-       int                     sc_wdt_mfgpt;
-
-#if NGPIO > 0
-       /* GPIO interface */
-       bus_space_tag_t         sc_gpio_iot;
-       bus_space_handle_t      sc_gpio_ioh;
-       struct gpio_chipset_tag sc_gpio_gc;
-       gpio_pin_t              sc_gpio_pins[AMD553X_GPIO_NPINS];
-#endif
-
-       /* SMbus/i2c interface */ 
-#if 0
-       bus_space_tag_t         sc_smbus_iot;
-        bus_space_handle_t     sc_smbus_ioh;
-       i2c_addr_t              sc_smbus_slaveaddr; /* address of smbus slave */
-       struct i2c_controller   sc_i2c;         /* i2c controller info */
-       krwlock_t               sc_smbus_rwlock;
-#endif
-};
-
-static int     gcscpcib_match(device_t, cfdata_t, void *);
-static void    gcscpcib_attach(device_t, device_t, void *);
-
-CFATTACH_DECL_NEW(gcscpcib, sizeof(struct gcscpcib_softc),
-       gcscpcib_match, gcscpcib_attach, NULL, NULL);
-
-static u_int   gcscpcib_get_timecount(struct timecounter *tc);
-static int     gscspcib_scan_mfgpt(struct gcscpcib_softc *sc);
-static void    gscspcib_wdog_update(struct gcscpcib_softc *, uint16_t);
-static int     gcscpcib_wdog_setmode(struct sysmon_wdog *smw);
-static int     gcscpcib_wdog_tickle(struct sysmon_wdog *smw);
-static void    gcscpcib_wdog_enable(struct gcscpcib_softc *sc);
-static void    gcscpcib_wdog_disable(struct gcscpcib_softc *sc);
-static void    gcscpcib_wdog_reset(struct gcscpcib_softc *sc);
-
-#if NGPIO > 0
-static int     gcscpcib_gpio_pin_read(void *, int);
-static void    gcscpcib_gpio_pin_write(void *, int, int);
-static void    gcscpcib_gpio_pin_ctl(void *, int, int);
-#endif
-
-static int
-gcscpcib_match(device_t parent, cfdata_t match, void *aux)
-{ 
-       struct pci_attach_args *pa = aux;
-
-       if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE ||
-           PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA)
-               return 0;
-
-       switch (PCI_PRODUCT(pa->pa_id)) {
-       case PCI_PRODUCT_NS_CS5535_ISA:
-       case PCI_PRODUCT_AMD_CS5536_PCIB:
-               return 2;       /* supersede pcib(4) */
-       }
-
-       return 0;
-}
-
-static void
-gcscpcib_attach(device_t parent, device_t self, void *aux)
-{
-       struct gcscpcib_softc *sc = device_private(self);
-       struct pci_attach_args *pa = (struct pci_attach_args *)aux;
-       struct timecounter *tc = &sc->sc_timecounter;
-       bus_addr_t wdtbase;
-       int wdt = 0;
-#if NGPIO > 0
-       struct gpiobus_attach_args gba;
-       bus_addr_t gpiobase;
-       int i, gpio;
-#endif
-
-       sc->sc_pcib.sc_pc = pa->pa_pc;
-       sc->sc_pcib.sc_tag = pa->pa_tag;
-       sc->sc_iot = pa->pa_iot;
-#if NGPIO > 0
-       sc->sc_gpio_iot = pa->pa_iot;
-#endif
-
-       /* Attach the PCI-ISA bridge at first */
-       pcibattach(parent, self, aux);
-
-       /* Attach the CS553[56] timer */
-       tc->tc_get_timecount = gcscpcib_get_timecount;
-       tc->tc_counter_mask = 0xffffffff;
-       tc->tc_frequency = 3579545;
-       tc->tc_name = device_xname(self);
-       tc->tc_quality = 1000;
-       tc->tc_priv = sc;
-       tc_init(tc);
-
-       /* Attach the watchdog timer */
-       wdtbase = rdmsr(MSR_LBAR_MFGPT) & 0xffff;
-       if (bus_space_map(sc->sc_iot, wdtbase, 64, 0, &sc->sc_ioh)) {
-               aprint_error_dev(self, "can't map memory space for WDT\n");
-       } else {
-               /* select a MFGPT timer for watchdog counter */
-               if (!gscspcib_scan_mfgpt(sc)) {
-                       aprint_error_dev(self, "can't alloc an MFGPT for WDT\n");
-                       goto gpio;
-               }
-               /* 
-                * Note: MFGPGx_SETUP register is write once register
-                * except CNT_EN and CMP[12]EV bit. 
-                */
-               bus_space_write_2(sc->sc_iot, sc->sc_ioh,
-                       AMD553X_MFGPTX_SETUP(sc->sc_wdt_mfgpt),
-                       AMD553X_MFGPT_CMP2EV | AMD553X_MFGPT_CMP2 |
-                       AMD553X_MFGPT_PRESCALE);
-
-               /* disable watchdog action */
-               AMD553X_MFGPTx_NR_DISABLE(sc->sc_wdt_mfgpt, 
-                       AMD553X_MFGPT0_C2_NMIM);
-               AMD553X_MFGPTx_NR_DISABLE(sc->sc_wdt_mfgpt,
-                       AMD553X_MFGPT0_C2_RSTEN);
-
-               sc->sc_smw.smw_name = device_xname(self);
-               sc->sc_smw.smw_cookie = sc;
-               sc->sc_smw.smw_setmode = gcscpcib_wdog_setmode;
-               sc->sc_smw.smw_tickle = gcscpcib_wdog_tickle;
-               sc->sc_smw.smw_period = 32;
-               aprint_normal_dev(self, "Watchdog Timer via MFGPT%d",
-                        sc->sc_wdt_mfgpt);
-               wdt = 1;
-       }
-
-gpio:
-#if NGPIO > 0
-       /* map GPIO I/O space */
-       gpiobase = rdmsr(MSR_LBAR_GPIO) & 0xffff;
-       if (!bus_space_map(sc->sc_gpio_iot, gpiobase, 0xff, 0,
-           &sc->sc_gpio_ioh)) {
-               aprint_normal(", GPIO");
-
-               /* initialize pin array */
-               for (i = 0; i < AMD553X_GPIO_NPINS; i++) {
-                       sc->sc_gpio_pins[i].pin_num = i;
-                       sc->sc_gpio_pins[i].pin_caps = GPIO_PIN_INPUT |
-                           GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN |
-                           GPIO_PIN_PUSHPULL | GPIO_PIN_TRISTATE |
-                           GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN |
-                           GPIO_PIN_INVIN | GPIO_PIN_INVOUT;
-
-                       /* read initial state */
-                       sc->sc_gpio_pins[i].pin_state =
-                           gcscpcib_gpio_pin_read(sc, i);
-               }
-
-               /* create controller tag */
-               sc->sc_gpio_gc.gp_cookie = sc;
-               sc->sc_gpio_gc.gp_pin_read = gcscpcib_gpio_pin_read;
-               sc->sc_gpio_gc.gp_pin_write = gcscpcib_gpio_pin_write;
-               sc->sc_gpio_gc.gp_pin_ctl = gcscpcib_gpio_pin_ctl;
-
-               gba.gba_gc = &sc->sc_gpio_gc;
-               gba.gba_pins = sc->sc_gpio_pins;
-               gba.gba_npins = AMD553X_GPIO_NPINS;
-               gpio = 1;
-       }
-#endif
-       aprint_normal("\n");
-
-#if NGPIO > 0
-       /* Attach GPIO framework */
-       if (gpio)
-                config_found_ia(self, "gpiobus", &gba, gpiobus_print);
-#endif
-
-       /* Register Watchdog timer to SMW */
-       if (wdt) {
-               if (sysmon_wdog_register(&sc->sc_smw) != 0)
-                       aprint_error_dev(self,
-                           "cannot register wdog with sysmon\n");
-       }
-}
-
-static u_int
-gcscpcib_get_timecount(struct timecounter *tc)
-{
-        return rdmsr(AMD553X_TMC);
-}
-
-/* Watchdog timer support functions */
-static int     
-gscspcib_scan_mfgpt(struct gcscpcib_softc *sc)
-{
-       int i;



Home | Main Index | Thread Index | Old Index