PERFORCE change 151931 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sun Oct 26 00:09:50 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=151931
Change 151931 by marcel at marcel_xcllnt on 2008/10/26 00:09:05
More merge fodder: use lbc(4) from SVN as-is.
Affected files ...
.. //depot/projects/e500/sys/dev/cfi/cfi_reg.h#6 edit
.. //depot/projects/e500/sys/dev/cfi/cfi_var.h#6 edit
.. //depot/projects/e500/sys/powerpc/mpc85xx/lbc.c#4 edit
.. //depot/projects/e500/sys/powerpc/mpc85xx/lbc.h#4 edit
.. //depot/projects/e500/sys/sys/cfictl.h#3 edit
Differences ...
==== //depot/projects/e500/sys/dev/cfi/cfi_reg.h#6 (text+ko) ====
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/dev/cfi/cfi_reg.h,v 1.1 2008/10/25 06:18:12 marcel Exp $
+ * $FreeBSD: src/sys/dev/cfi/cfi_reg.h,v 1.1 2008/10/25 06:18:12 marcel Exp $
*/
#ifndef _DEV_CFI_REG_H_
==== //depot/projects/e500/sys/dev/cfi/cfi_var.h#6 (text+ko) ====
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/dev/cfi/cfi_var.h,v 1.1 2008/10/25 06:18:12 marcel Exp $
+ * $FreeBSD: src/sys/dev/cfi/cfi_var.h,v 1.1 2008/10/25 06:18:12 marcel Exp $
*/
#ifndef _DEV_CFI_VAR_H_
==== //depot/projects/e500/sys/powerpc/mpc85xx/lbc.c#4 (text+ko) ====
@@ -1,5 +1,6 @@
/*-
- * Copyright 2006 by Juniper Networks. All rights reserved.
+ * Copyright (c) 2006-2008, Juniper Networks, Inc.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,42 +24,37 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD: src/sys/powerpc/psim/iobus.c,v 1.8 2005/01/07 02:29:21 imp Exp $
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/powerpc/mpc85xx/lbc.c,v 1.1 2008/10/25 06:03:40 marcel Exp $");
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ktr.h>
#include <sys/kernel.h>
+#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/rman.h>
+#include <machine/bus.h>
+#include <machine/ocpbus.h>
+
#include <vm/vm.h>
#include <vm/pmap.h>
-#include <sys/malloc.h>
-#include <machine/spr.h>
-#include <machine/openpicvar.h>
-#include <machine/ocpbus.h>
-#include <machine/md_var.h>
-#include <powerpc/mpc85xx/ocpbus.h>
#include <powerpc/mpc85xx/lbc.h>
-#include "pic_if.h"
-#include "lb_if.h"
+struct lbc_softc {
+ device_t sc_dev;
+
+ struct resource *sc_res;
+ bus_space_handle_t sc_bsh;
+ bus_space_tag_t sc_bst;
+ int sc_rid;
-struct lbc_softc {
- /* Currently only 1 */
- device_t lb_dev;
- /* Acquired from OCP bus & basically used for CCSR */
- struct resource *lb_memr;
- bus_space_handle_t lb_bsh;
- bus_space_tag_t lb_bst;
- int lb_rid;
- /* Now for the children */
- struct rman lbc_memregion;
- bus_addr_t lbc_iomem_va;
+ struct rman sc_rman;
+ uintptr_t sc_kva;
};
struct lbc_devinfo {
@@ -71,25 +67,14 @@
static int lbc_probe(device_t);
static int lbc_attach(device_t);
static int lbc_shutdown(device_t);
-#if 0
static int lbc_get_resource(device_t, device_t, int, int, u_long *,
u_long *);
-#endif
static struct resource *lbc_alloc_resource(device_t, device_t, int, int *,
u_long, u_long, u_long, u_int);
-#if 0
static int lbc_print_child(device_t, device_t);
-#endif
static int lbc_release_resource(device_t, device_t, int, int,
struct resource *);
static int lbc_read_ivar(device_t, device_t, int, uintptr_t *);
-static void lbc_write_reg(device_t , uint32_t , uint32_t , uint32_t );
-static uint32_t lbc_read_reg(device_t , uint32_t , uint32_t );
-#if 0
-static int lbc_setup_intr(device_t, device_t, struct resource *, int,
- driver_intr_t *, void *, void **);
-static int lbc_teardown_intr(device_t, device_t, struct resource *, void *);
-#endif
/*
* Bus interface definition
@@ -101,79 +86,28 @@
DEVMETHOD(device_shutdown, lbc_shutdown),
/* Bus interface */
-#if 0
DEVMETHOD(bus_print_child, lbc_print_child),
-#endif
- DEVMETHOD(bus_print_child, NULL),
DEVMETHOD(bus_read_ivar, lbc_read_ivar),
- DEVMETHOD(bus_setup_intr, NULL),
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, NULL),
DEVMETHOD(bus_get_resource, NULL),
DEVMETHOD(bus_alloc_resource, lbc_alloc_resource),
DEVMETHOD(bus_release_resource, lbc_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- /* local bus CCSR access functions for child */
- DEVMETHOD(lb_write_reg, lbc_write_reg),
- DEVMETHOD(lb_read_reg, lbc_read_reg),
-
{ 0, 0 }
};
static driver_t lbc_driver = {
"lbc",
lbc_methods,
- sizeof (struct lbc_softc)
+ sizeof(struct lbc_softc)
};
-
devclass_t lbc_devclass;
-
DRIVER_MODULE(lbc, ocpbus, lbc_driver, lbc_devclass, 0, 0);
-static void
-lbc_write_reg(device_t dev, uint32_t offset, uint32_t val, uint32_t bytes)
-{
- struct lbc_softc *sc = device_get_softc(dev);
-
- switch (bytes) {
- case 1:
- bus_space_write_1(sc->lb_bst, sc->lb_bsh, offset, val);
-
- break;
- case 2:
- bus_space_write_2(sc->lb_bst, sc->lb_bsh, offset, val);
-
- break;
- case 4:
- bus_space_write_4(sc->lb_bst, sc->lb_bsh, offset, val);
-
- break;
- }
-}
-
-static uint32_t
-lbc_read_reg(device_t dev, uint32_t offset, uint32_t bytes)
-{
- struct lbc_softc *sc = device_get_softc(dev);
- uint32_t data = 0;
-
- switch (bytes) {
- case 1:
- data = bus_space_read_1(sc->lb_bst, sc->lb_bsh, offset);
- break;
- case 2:
- data = bus_space_read_2(sc->lb_bst, sc->lb_bsh, offset);
- break;
- case 4:
- data = bus_space_read_4(sc->lb_bst, sc->lb_bsh, offset);
- break;
- }
-
- return (data);
-}
-
static device_t
lbc_mk_child(device_t dev, int type, int mtype, int unit)
{
@@ -185,7 +119,7 @@
device_printf(dev, "could not add child device\n");
return (NULL);
}
- dinfo = malloc(sizeof (struct lbc_devinfo), M_DEVBUF, M_WAITOK|M_ZERO);
+ dinfo = malloc(sizeof(struct lbc_devinfo), M_DEVBUF, M_WAITOK | M_ZERO);
dinfo->lbc_devtype = type;
dinfo->lbc_memtype = mtype;
dinfo->lbc_unit = unit;
@@ -196,7 +130,6 @@
static int
lbc_probe(device_t dev)
{
- struct lbc_softc *sc;
device_t parent;
uintptr_t devtype;
int error;
@@ -208,137 +141,105 @@
if (devtype != OCPBUS_DEVTYPE_LBC)
return (ENXIO);
- sc = device_get_softc(dev);
-
- device_set_desc(dev, "Freescale 8533 Local Bus Controller");
+ device_set_desc(dev, "Freescale MPC85xx Local Bus Controller");
return (BUS_PROBE_DEFAULT);
}
static int
-lbc_attach (device_t dev)
+lbc_attach(device_t dev)
{
struct lbc_softc *sc;
- u_long start, end, size;
- struct rman *rp;
+ struct rman *rm;
+ u_long start, size;
int error;
sc = device_get_softc(dev);
- sc->lb_dev = dev;
+ sc->sc_dev = dev;
- sc->lb_rid = 0;
- sc->lb_memr = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->lb_rid,
+ sc->sc_rid = 0;
+ sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rid,
RF_ACTIVE);
- if (sc->lb_memr == NULL)
+ if (sc->sc_res == NULL)
return (ENXIO);
- sc->lb_bst = rman_get_bustag(sc->lb_memr);
- sc->lb_bsh = rman_get_bushandle(sc->lb_memr);
+ sc->sc_bst = rman_get_bustag(sc->sc_res);
+ sc->sc_bsh = rman_get_bushandle(sc->sc_res);
error = bus_get_resource(dev, SYS_RES_MEMORY, 1, &start, &size);
- if (error) {
- bus_release_resource(dev, SYS_RES_MEMORY, sc->lb_rid, sc->lb_memr);
- return (error);
- }
+ if (error)
+ goto fail;
- /* Initialize the LBC registers */
- /* Boot Flash */
- LB_WRITE_REG(dev,LBC85XX_BR(0), 0xff801001, 4);
- LB_WRITE_REG(dev,LBC85XX_OR(0), 0xff801040, 4);
+ rm = &sc->sc_rman;
+ rm->rm_type = RMAN_ARRAY;
+ rm->rm_descr = "MPC85XX Local Bus Space";
+ rm->rm_start = start;
+ rm->rm_end = start + size - 1;
+ error = rman_init(rm);
+ if (error)
+ goto fail;
- /* SYSPLD */
- LB_WRITE_REG(dev,LBC85XX_BR(1), 0xea001001, 4);
- LB_WRITE_REG(dev,LBC85XX_OR(1), 0xffff1040, 4);
-
-#if 0
- /* LCD */
- LB_WRITE_REG(dev,LBC85XX_BR(2), 0xeb000801, 4);
- LB_WRITE_REG(dev,LBC85XX_OR(2), 0xffff1100, 4);
-#endif
-
- LB_WRITE_REG(dev,LBC85XX_LBCR, 0x00000000, 4);
- LB_WRITE_REG(dev,LBC85XX_LCRR, 0x00030008, 4);
-
- /*
- * The unit argument will serve as the bar number. Logic is
- * that there are only that much banks as there are bars and
- * there can only be as many devices as there are banks.
- */
-
- lbc_mk_child(dev, LBC_DEVTYPE_LCD, LB_GPCM_TYPE, 0);
-#if 0
- lbc_mk_child(dev, LBC_DEVTYPE_FLASH, 0);
-#endif
-
- end = start + size - 1;
-
- rp = &sc->lbc_memregion;
- rp->rm_type = RMAN_ARRAY;
- rp->rm_descr = "MPC8533 Localbus Device Memory";
- /* Not sure below 2 lines are needed */
- rp->rm_start = start;
- rp->rm_end = end;
- error = rman_init(rp);
+ error = rman_manage_region(rm, rm->rm_start, rm->rm_end);
if (error) {
- device_printf(dev, "rman_init() failed. error = %d\n", error);
- return (error);
+ rman_fini(rm);
+ goto fail;
}
- error = rman_manage_region(rp, start, end);
- if (error) {
- device_printf(dev, "rman_manage_region() failed. error = %d\n",
- error);
- return (error);
- }
+ sc->sc_kva = (uintptr_t)pmap_mapdev(start, size);
- sc->lbc_iomem_va = (uintptr_t)pmap_mapdev(start, size);
+ lbc_mk_child(dev, LBC_DEVTYPE_CFI, 0, 0);
return (bus_generic_attach(dev));
+ fail:
+ bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rid, sc->sc_res);
+ return (error);
}
static int
lbc_shutdown(device_t dev)
{
+
+ /* TODO */
return(0);
}
-/*
- * The calling convention should be local_bus_alloc_resource and
- * if it succeeds then call lb_write_reg to program the BARS.
- */
static struct resource *
-lbc_alloc_resource (device_t dev, device_t child, int type, int *rid,
+lbc_alloc_resource(device_t dev, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
struct lbc_softc *sc;
struct resource *rv;
- struct rman *rp;
+ struct rman *rm;
+ int error;
sc = device_get_softc(dev);
- if (type != SYS_RES_MEMORY)
+ if (type != SYS_RES_MEMORY && type != SYS_RES_IRQ)
return (NULL);
- /* For now don't allow *_alloc_any */
- if (start == 0ul || end == ~0ul)
+
+ /* We only support default allocations. */
+ if (start != 0ul || end != ~0ul)
return (NULL);
- rp = &sc->lbc_memregion;
- end = start + count - 1;
- rv = rman_reserve_resource(rp, start, end, count, flags, child);
- if (rv == NULL)
+ if (type == SYS_RES_IRQ)
+ return (bus_alloc_resource(dev, type, rid, start, end, count,
+ flags));
+
+ error = lbc_get_resource(dev, child, type, *rid, &start, &count);
+ if (error)
return (NULL);
-#if 0
- /* TODO: Check this out later */
- rman_set_bustag(rv, PPC_BUS_SPACE_MEM | PPC_BUS_SPACE_BE);
-#endif
- rman_set_bustag(rv, &bs_be_tag);
- rman_set_bushandle(rv, sc->lbc_iomem_va +
- rman_get_start(rv) - rp->rm_start);
+ rm = &sc->sc_rman;
+ end = start + count - 1;
+ rv = rman_reserve_resource(rm, start, end, count, flags, child);
+ if (rv != NULL) {
+ rman_set_bustag(rv, &bs_be_tag);
+ rman_set_bushandle(rv, sc->sc_kva + rman_get_start(rv) -
+ rm->rm_start);
+ }
return (rv);
}
-#if 0
static int
lbc_print_child(device_t dev, device_t child)
{
@@ -360,39 +261,9 @@
rid++;
}
- /*
- * The SYS_RES_IOPORT resource of the PCIB has rid 1 because the
- * the SYS_RES_MEMORY resource related to the decoding window also
- * has rid 1. This is friendlier for the PCIB child...
- */
- rid = 1;
- while (1) {
- error = lbc_get_resource(dev, child, SYS_RES_IOPORT, rid,
- &start, &size);
- if (error)
- break;
- retval += (rid == 1) ? printf(" ioport ") : printf(",");
- retval += printf("%#lx", start);
- if (size > 1)
- retval += printf("-%#lx", start + size - 1);
- rid++;
- }
-
- rid = 0;
- while (1) {
- error = lbc_get_resource(dev, child, SYS_RES_IRQ, rid,
- &start, &size);
- if (error)
- break;
- retval += (rid == 0) ? printf(" irq ") : printf(",");
- retval += printf("%ld", start);
- rid++;
- }
-
retval += bus_print_child_footer(dev, child);
return (retval);
}
-#endif
static int
lbc_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
@@ -408,17 +279,50 @@
case LBC_IVAR_DEVTYPE:
*result = dinfo->lbc_devtype;
return (0);
-
+ case LBC_IVAR_CLOCK:
+ *result = 1843200;
+ return (0);
+ case LBC_IVAR_REGSHIFT:
+ *result = 0;
+ return (0);
default:
break;
}
-
return (EINVAL);
}
static int
-lbc_release_resource (device_t dev, device_t child, int type, int rid,
+lbc_release_resource(device_t dev, device_t child, int type, int rid,
struct resource *res)
{
+
return (rman_release_resource(res));
}
+
+static int
+lbc_get_resource(device_t dev, device_t child, int type, int rid,
+ u_long *startp, u_long *countp)
+{
+ struct lbc_softc *sc;
+ struct lbc_devinfo *dinfo;
+
+ if (type != SYS_RES_MEMORY)
+ return (ENOENT);
+
+ /* Currently all devices have a single RID per type. */
+ if (rid != 0)
+ return (ENOENT);
+
+ sc = device_get_softc(dev);
+ dinfo = device_get_ivars(child);
+
+ switch (dinfo->lbc_devtype) {
+ case LBC_DEVTYPE_CFI:
+ *startp = sc->sc_rman.rm_start;
+ *countp = sc->sc_rman.rm_end - sc->sc_rman.rm_start + 1;
+ break;
+ default:
+ return(EDOOFUS);
+ }
+ return(0);
+}
==== //depot/projects/e500/sys/powerpc/mpc85xx/lbc.h#4 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2006 Juniper Networks
+ * Copyright (c) 2006-2008, Juniper Networks, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,48 +23,19 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: src/sys/powerpc/mpc85xx/lbc.h,v 1.1 2008/10/25 06:03:40 marcel Exp
+$
*/
-#ifndef _MACHINE_LOCALBUS_H_
-#define _MACHINE_LOCALBUS_H_
+#ifndef _MACHINE_LBC_H_
+#define _MACHINE_LBC_H_
#define LBC_IVAR_DEVTYPE 1
-#define LBC_IVAR_CLOCK 2
+#define LBC_IVAR_CLOCK 2
+#define LBC_IVAR_REGSHIFT 3
/* Device types. */
-#define LBC_DEVTYPE_LCD 1
-#define LBC_DEVTYPE_FLASH 2
+#define LBC_DEVTYPE_CFI 1
+#define LBC_DEVTYPE_UART 2
-#define LB_SDRAM_TYPE 0x01
-#define LB_GPCM_TYPE 0x02
-#define LB_UPM_TYPE 0x04
-
-#define LBC85XX_START (0x5000)
-#define LBC85XX_SIZE 0x1000
-#define LBC85XX_END (LBC85XX_START + LBC85XX_SIZE)
-
-/*
- * Local access registers.
- */
-#define LBC85XX_BR(n) (LBC85XX_START + (8 * n)) /* Base Registers */
-#define LBC85XX_OR(n) (LBC85XX_START + 4 + (8 * n)) /* Options Registers */
-
-#define LBC85XX_MAR (LBC85XX_START + 0x68)
-#define LBC85XX_MAMR (LBC85XX_START + 0x70)
-#define LBC85XX_MBMR (LBC85XX_START + 0x74)
-#define LBC85XX_MCMR (LBC85XX_START + 0x78)
-#define LBC85XX_MRTPR (LBC85XX_START + 0x84)
-#define LBC85XX_MDR (LBC85XX_START + 0x88)
-#define LBC85XX_LSDMR (LBC85XX_START + 0x94)
-#define LBC85XX_LURT (LBC85XX_START + 0xA0)
-#define LBC85XX_LSRT (LBC85XX_START + 0xA4)
-#define LBC85XX_LTESR (LBC85XX_START + 0xB0)
-#define LBC85XX_LTEDR (LBC85XX_START + 0xB4)
-#define LBC85XX_LTEIR (LBC85XX_START + 0xB8)
-#define LBC85XX_LTEATR (LBC85XX_START + 0xBC)
-#define LBC85XX_LTEAR (LBC85XX_START + 0xC0)
-#define LBC85XX_LBCR (LBC85XX_START + 0xD0)
-#define LBC85XX_LCRR (LBC85XX_START + 0xD4)
-
-#endif /* _MACHINE_LOCALBUS_H */
+#endif /* _MACHINE_LBC_H_ */
==== //depot/projects/e500/sys/sys/cfictl.h#3 (text+ko) ====
@@ -25,6 +25,8 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/sys/cfictl.h,v 1.1 2008/10/25 06:18:12 marcel Exp $
*/
#ifndef _SYS_CFICTL_H_
More information about the p4-projects
mailing list