Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/broadcom Add support for the BCM56340 iProc bas...



details:   https://anonhg.NetBSD.org/src/rev/93d1fe02f829
branches:  trunk
changeset: 790971:93d1fe02f829
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Oct 28 22:51:16 2013 +0000

description:
Add support for the BCM56340 iProc based switch

diffstat:

 sys/arch/arm/broadcom/bcm53xx_board.c |   36 +++++++-
 sys/arch/arm/broadcom/bcm53xx_ccb.c   |   36 ++++++-
 sys/arch/arm/broadcom/bcm53xx_eth.c   |   51 ++++++-----
 sys/arch/arm/broadcom/bcm53xx_intr.h  |  149 +++++++++++++++++++++------------
 sys/arch/arm/broadcom/bcm53xx_nand.c  |   92 ++++++++++++++++++++
 sys/arch/arm/broadcom/bcm53xx_reg.h   |  122 ++++++++++++++++++++++++++-
 sys/arch/arm/broadcom/bcm53xx_usb.c   |   12 +-
 sys/arch/arm/broadcom/bcm53xx_var.h   |    5 +-
 sys/arch/arm/broadcom/bcmgen_space.c  |   61 +++++++------
 sys/arch/arm/broadcom/files.bcm53xx   |    8 +-
 10 files changed, 445 insertions(+), 127 deletions(-)

diffs (truncated from 1002 to 300 lines):

diff -r 9ee9a8987d02 -r 93d1fe02f829 sys/arch/arm/broadcom/bcm53xx_board.c
--- a/sys/arch/arm/broadcom/bcm53xx_board.c     Mon Oct 28 22:50:25 2013 +0000
+++ b/sys/arch/arm/broadcom/bcm53xx_board.c     Mon Oct 28 22:51:16 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm53xx_board.c,v 1.16 2013/08/29 15:46:17 riz Exp $   */
+/*     $NetBSD: bcm53xx_board.c,v 1.17 2013/10/28 22:51:16 matt Exp $  */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.16 2013/08/29 15:46:17 riz Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.17 2013/10/28 22:51:16 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -46,6 +46,7 @@
 #include <net/if.h>
 #include <net/if_ether.h>
 
+#define CCA_PRIVATE
 #define CRU_PRIVATE
 #define DDR_PRIVATE
 #define DMU_PRIVATE
@@ -67,6 +68,7 @@
 static struct cpu_softc cpu_softc;
 
 struct arm32_dma_range bcm53xx_dma_ranges[] = {
+#ifdef BCM5301X
        [0] = {
                .dr_sysbase = 0x80000000,
                .dr_busbase = 0x80000000,
@@ -75,6 +77,16 @@
                .dr_sysbase = 0x90000000,
                .dr_busbase = 0x90000000,
        },
+#elif defined(BCM56340)
+       [0] = {
+               .dr_sysbase = 0x60000000,
+               .dr_busbase = 0x60000000,
+               .dr_len = 0x20000000,
+       }, [1] = {
+               .dr_sysbase = 0xa0000000,
+               .dr_busbase = 0xa0000000,
+       }.
+#endif
 };
 
 struct arm32_bus_dma_tag bcm53xx_dma_tag = {
@@ -86,6 +98,7 @@
 };
 
 struct arm32_dma_range bcm53xx_coherent_dma_ranges[] = {
+#ifdef BCM5301X
        [0] = {
                .dr_sysbase = 0x80000000,
                .dr_busbase = 0x80000000,
@@ -95,6 +108,17 @@
                .dr_sysbase = 0x90000000,
                .dr_busbase = 0x90000000,
        },
+#elif defined(BCM563XX)
+       [0] = {
+               .dr_sysbase = 0x60000000,
+               .dr_busbase = 0x60000000,
+               .dr_len = 0x20000000,
+               .dr_flags = _BUS_DMAMAP_COHERENT,
+       }, [1] = {
+               .dr_sysbase = 0xa0000000,
+               .dr_busbase = 0xa0000000,
+       },
+#endif
 };
 
 struct arm32_bus_dma_tag bcm53xx_coherent_dma_tag = {
@@ -453,6 +477,11 @@
 
        cpu->cpu_armcore_bst = bcm53xx_armcore_bst;
        cpu->cpu_armcore_bsh = bcm53xx_armcore_bsh;
+
+       const uint32_t chipid = bus_space_read_4(cpu->cpu_ioreg_bst,
+           cpu->cpu_ioreg_bsh, CCA_MISC_BASE + MISC_CHIPID);
+
+       cpu->cpu_chipid = __SHIFTOUT(chipid, CHIPID_ID);
 }
 
 void
@@ -525,7 +554,8 @@
 
        curcpu()->ci_data.cpu_cc_freq = clk->clk_cpu;
 
-       arml2cc_init(bcm53xx_armcore_bst, bcm53xx_armcore_bsh, ARMCORE_L2C_BASE);
+       arml2cc_init(bcm53xx_armcore_bst, bcm53xx_armcore_bsh,
+           ARMCORE_L2C_BASE);
 }
 
 void
diff -r 9ee9a8987d02 -r 93d1fe02f829 sys/arch/arm/broadcom/bcm53xx_ccb.c
--- a/sys/arch/arm/broadcom/bcm53xx_ccb.c       Mon Oct 28 22:50:25 2013 +0000
+++ b/sys/arch/arm/broadcom/bcm53xx_ccb.c       Mon Oct 28 22:51:16 2013 +0000
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_ccb.c,v 1.3 2012/10/03 19:18:41 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_ccb.c,v 1.4 2013/10/28 22:51:16 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -101,18 +101,35 @@
        { "bcmtmr", TIMER1_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT, 2, { IRQ_TIMER1_1, IRQ_TIMER1_2 } },
        { "bcmsw", SRAB_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT, },
        { "bcmcom", UART2_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT, 1, { IRQ_UART2 } },
-       { "bcmi2c", SMBUS_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT, 1, { IRQ_SMBUS } },
+#ifdef BCM5301X
+       { "bcmi2c", SMBUS1_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT, 1, { IRQ_SMBUS1 } },
+#endif
+#ifdef BCM536XX
+       { "bcmi2c", SMBUS1_BASE, 0x1000, 1, 1, { IRQ_SMBUS1 } },
+       { "bcmi2c", SMBUS2_BASE, 0x1000, 2, 1, { IRQ_SMBUS2 } },
+#endif
        { "bcmcru", CRU_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT },
        { "bcmdmu", DMU_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT },
        { "bcmddr", DDR_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT, 1, { IRQ_DDR_CONTROLLER } },
        { "bcmeth", GMAC0_BASE, 0x1000, 0, 1, { IRQ_GMAC0 }, },
        { "bcmeth", GMAC1_BASE, 0x1000, 1, 1, { IRQ_GMAC1 }, },
+#ifdef GMAC2_BASE
        { "bcmeth", GMAC2_BASE, 0x1000, 2, 1, { IRQ_GMAC2 }, },
+#endif
        // { "bcmeth", GMAC3_BASE, 0x1000, 3, 1, { IRQ_GMAC3 }, },
        { "bcmpax", PCIE0_BASE, 0x1000, 0, 6, { IRQ_PCIE_INT0 }, },
        { "bcmpax", PCIE1_BASE, 0x1000, 1, 6, { IRQ_PCIE_INT1 }, },
+#ifdef PCIE2_BASE
        { "bcmpax", PCIE2_BASE, 0x1000, 2, 6, { IRQ_PCIE_INT2 }, },
+#endif
+#ifdef SDIO_BASE
        { "sdhc", SDIO_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT, 1, { IRQ_SDIO } },
+#endif
+       { "bcmnand", NAND_BASE, 0x1000, BCMCCBCF_PORT_DEFAULT, 8,
+         { IRQ_NAND_RD_MISS, IRQ_NAND_BLK_ERASE_COMP,
+           IRQ_NAND_COPY_BACK_COMP, IRQ_NAND_PGM_PAGE_COMP,
+           IRQ_NAND_RO_CTLR_READY, IRQ_NAND_RB_B,
+           IRQ_NAND_ECC_MIPS_UNCORR, IRQ_NAND_ECC_MIPS_CORR } },
        { "bcmusb", EHCI_BASE, 0x2000, BCMCCBCF_PORT_DEFAULT, 1, { IRQ_USB2 } },
 };
 
@@ -159,22 +176,27 @@
        aprint_naive("\n");
        aprint_normal("\n");
 
-       bcm53xx_srab_init();    // need this for ethernet.
+       for (size_t i = 0; i < __arraycount(bcmccb_locators); i++) {
+               const struct bcm_locators *loc = &bcmccb_locators[i];
 
-       for (size_t i = 0; i < __arraycount(bcmccb_locators); i++) {
+#ifdef BCM5301X
+               if (strcmp(loc->loc_name, "bcmsw") == 0) {
+                       bcm53xx_srab_init();    // need this for ethernet.
+               }
+#endif
+
                struct bcmccb_attach_args ccbaa = {
                        .ccbaa_ccb_bst = sc->sc_bst,
                        .ccbaa_ccb_bsh = sc->sc_bsh,
                        .ccbaa_dmat = &bcm53xx_dma_tag,
-                       .ccbaa_loc = bcmccb_locators[i],
+                       .ccbaa_loc = *loc,
                };
 
                /*
                 * If the device might be in reset, let's try to take it
                 * out of it.  If it fails or is unavailable, skip it.
                 */
-               if (!bcm53xx_idm_device_init(&bcmccb_locators[i],
-                       sc->sc_bst, sc->sc_bsh))
+               if (!bcm53xx_idm_device_init(loc, sc->sc_bst, sc->sc_bsh))
                        continue;
 
                cfdata_t cf = config_search_ia(bcmccb_find, self, "bcmccb",
diff -r 9ee9a8987d02 -r 93d1fe02f829 sys/arch/arm/broadcom/bcm53xx_eth.c
--- a/sys/arch/arm/broadcom/bcm53xx_eth.c       Mon Oct 28 22:50:25 2013 +0000
+++ b/sys/arch/arm/broadcom/bcm53xx_eth.c       Mon Oct 28 22:51:16 2013 +0000
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.24 2013/02/19 02:18:29 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.25 2013/10/28 22:51:16 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -903,7 +903,7 @@
        }
        KASSERT(map->dm_mapsize == MCLBYTES);
 #ifdef BCMETH_RCVMAGIC
-       *mtod(m, uint32_t *) = BCMETH_RCVMAGIC;
+       *mtod(m, uint32_t *) = htole32(BCMETH_RCVMAGIC);
        bus_dmamap_sync(sc->sc_dmat, map, 0, sizeof(uint32_t),
            BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
        bus_dmamap_sync(sc->sc_dmat, map, sizeof(uint32_t),
@@ -955,9 +955,9 @@
                bus_dmamap_t map = M_GETCTX(m, bus_dmamap_t);
                KASSERT(map);
 
-               producer->rxdb_buflen = MCLBYTES;
-               producer->rxdb_addrlo = map->dm_segs[0].ds_addr;
-               producer->rxdb_flags &= RXDB_FLAG_ET;
+               producer->rxdb_buflen = htole32(MCLBYTES);
+               producer->rxdb_addrlo = htole32(map->dm_segs[0].ds_addr);
+               producer->rxdb_flags &= htole32(RXDB_FLAG_ET);
                *rxq->rxq_mtail = m;
                rxq->rxq_mtail = &m->m_next;
                m->m_len = MCLBYTES;
@@ -1063,6 +1063,7 @@
                bus_dmamap_sync(sc->sc_dmat, map, 0, arm_dcache_align,
                    BUS_DMASYNC_POSTREAD);
                memcpy(&rxsts, rxq->rxq_mhead->m_data, 4);
+               rxsts = le32toh(rxsts);
 #if 0
                KASSERTMSG(rxsts != BCMETH_RCVMAGIC, "currdscr=%u consumer=%zd",
                    currdscr, consumer - rxq->rxq_first);
@@ -1138,7 +1139,7 @@
                         * Wrap at the last entry!
                         */
                        if (++consumer == rxq->rxq_last) {
-                               KASSERT(consumer[-1].rxdb_flags & RXDB_FLAG_ET);
+                               KASSERT(consumer[-1].rxdb_flags & htole32(RXDB_FLAG_ET));
                                rxq->rxq_consumer = rxq->rxq_first;
                        } else {
                                rxq->rxq_consumer = consumer;
@@ -1166,7 +1167,7 @@
                 * Wrap at the last entry!
                 */
                if (++consumer == rxq->rxq_last) {
-                       KASSERT(consumer[-1].rxdb_flags & RXDB_FLAG_ET);
+                       KASSERT(consumer[-1].rxdb_flags & htole32(RXDB_FLAG_ET));
                        consumer = rxq->rxq_first;
                }
        }
@@ -1227,13 +1228,13 @@
         */
        struct gmac_rxdb *rxdb;
        for (rxdb = rxq->rxq_first; rxdb < rxq->rxq_last - 1; rxdb++) {
-               rxdb->rxdb_flags = RXDB_FLAG_IC;
+               rxdb->rxdb_flags = htole32(RXDB_FLAG_IC);
        }
 
        /*
         * Last descriptor has the wrap flag.
         */
-       rxdb->rxdb_flags = RXDB_FLAG_ET|RXDB_FLAG_IC;
+       rxdb->rxdb_flags = htole32(RXDB_FLAG_ET|RXDB_FLAG_IC);
 
        /*
         * Reset the producer consumer indexes.
@@ -1415,14 +1416,16 @@
 
        struct gmac_txdb *start = producer;
        size_t count = map->dm_nsegs;
-       producer->txdb_flags |= first_flags;
-       producer->txdb_addrlo = map->dm_segs[0].ds_addr;
-       producer->txdb_buflen = map->dm_segs[0].ds_len;
+       producer->txdb_flags |= htole32(first_flags);
+       producer->txdb_addrlo = htole32(map->dm_segs[0].ds_addr);
+       producer->txdb_buflen = htole32(map->dm_segs[0].ds_len);
        for (u_int i = 1; i < map->dm_nsegs; i++) {
 #if 0
                printf("[%zu]: %#x/%#x/%#x/%#x\n", producer - txq->txq_first,
-                    producer->txdb_flags, producer->txdb_buflen,
-                    producer->txdb_addrlo, producer->txdb_addrhi);
+                   le32toh(producer->txdb_flags),
+                   le32toh(producer->txdb_buflen),
+                   le32toh(producer->txdb_addrlo),
+                   le32toh(producer->txdb_addrhi));
 #endif
                if (__predict_false(++producer == txq->txq_last)) {
                        bcmeth_txq_desc_presync(sc, txq, start,
@@ -1431,14 +1434,14 @@
                        producer = txq->txq_first;
                        start = txq->txq_first;
                }
-               producer->txdb_addrlo = map->dm_segs[i].ds_addr;
-               producer->txdb_buflen = map->dm_segs[i].ds_len;
+               producer->txdb_addrlo = htole32(map->dm_segs[i].ds_addr);
+               producer->txdb_buflen = htole32(map->dm_segs[i].ds_len);
        }
-       producer->txdb_flags |= last_flags;
+       producer->txdb_flags |= htole32(last_flags);
 #if 0
        printf("[%zu]: %#x/%#x/%#x/%#x\n", producer - txq->txq_first,
-            producer->txdb_flags, producer->txdb_buflen,
-            producer->txdb_addrlo, producer->txdb_addrhi);
+           le32toh(producer->txdb_flags), le32toh(producer->txdb_buflen),
+           le32toh(producer->txdb_addrlo), le32toh(producer->txdb_addrhi));
 #endif
        if (count)
                bcmeth_txq_desc_presync(sc, txq, start, count);
@@ -1448,8 +1451,8 @@



Home | Main Index | Thread Index | Old Index