Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips/atheros Add athers_get_uart_freq() (since AR72...



details:   https://anonhg.NetBSD.org/src/rev/2f4930c8431c
branches:  trunk
changeset: 767168:2f4930c8431c
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Jul 10 06:26:02 2011 +0000

description:
Add athers_get_uart_freq() (since AR7240 uses the ref_clk, not the bus_clk).
Add little endian bus_space_tag for arbus.
Add EHCI attachment for arbus.

diffstat:

 sys/arch/mips/atheros/ar9344.c           |   42 +++++----
 sys/arch/mips/atheros/ar_conf.c          |   26 +++++-
 sys/arch/mips/atheros/ar_console.c       |    9 +-
 sys/arch/mips/atheros/arbus.c            |   15 ++-
 sys/arch/mips/atheros/arbusle.c          |   54 ++++++++++++
 sys/arch/mips/atheros/dev/ehci_arbus.c   |  138 +++++++++++++++++++++++++++++++
 sys/arch/mips/atheros/include/arbusvar.h |    4 +-
 sys/arch/mips/atheros/include/platform.h |    4 +-
 8 files changed, 263 insertions(+), 29 deletions(-)

diffs (truncated from 482 to 300 lines):

diff -r b39236e55101 -r 2f4930c8431c sys/arch/mips/atheros/ar9344.c
--- a/sys/arch/mips/atheros/ar9344.c    Sun Jul 10 06:24:18 2011 +0000
+++ b/sys/arch/mips/atheros/ar9344.c    Sun Jul 10 06:26:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ar9344.c,v 1.1 2011/07/07 05:06:44 matt Exp $ */
+/* $NetBSD: ar9344.c,v 1.2 2011/07/10 06:26:02 matt Exp $ */
 
 /*
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -48,7 +48,7 @@
  * family.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ar9344.c,v 1.1 2011/07/07 05:06:44 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ar9344.c,v 1.2 2011/07/10 06:26:02 matt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -183,6 +183,11 @@
        } else {
                freqs->freq_mem = cpu_pll_freq / (post_div + 1);
        }
+
+       /*
+        * Console is off the reference clock, not the bus clock.
+        */
+       freqs->freq_uart = freqs->freq_ref;
 }
 
 #if 0
@@ -285,26 +290,22 @@
 static int
 ar9344_enable_device(const struct atheros_device *adv)
 {
-#if 0
-       if (adv->adv_addr == AR9344_WLAN_BASE) {
-               /* enable arbitration for wlan */
-               PUTRESET(AR9344_RESET_AHB_ARB_CTL,
-                   GETRESET(AR9344_RESET_AHB_ARB_CTL) | AR9344_ARB_WLAN);
+       if (adv->adv_reset) {
+               /* put device into reset */
+               PUTRESETREG(AR9344_RESET_RESETCTL,
+                   GETRESETREG(AR9344_RESET_RESETCTL) | adv->adv_reset);
 
-               /* set WLAN for big endian */
-               PUTRESET(AR9344_RESET_ENDIAN,
-                   GETRESET(AR9344_RESET_ENDIAN) | AR9344_ENDIAN_WLAN);
+               delay(15000);   /* XXX: tsleep? */
 
-               /* wake up the mac */
-               PUTPCIREG(AR9344_PCI_MAC_SCR,
-                   (GETPCIREG(AR9344_PCI_MAC_SCR) & ~PCI_MAC_SCR_SLM_MASK) |
-                   PCI_MAC_SCR_SLM_FWAKE);
+               /* take it out of reset */
+               PUTRESETREG(AR9344_RESET_RESETCTL,
+                   GETRESETREG(AR9344_RESET_RESETCTL) & ~adv->adv_reset);
 
-               /* wait for it to wake up */
-               while (GETPCIREG(AR9344_PCI_MAC_PCICFG) &
-                   PCI_MAC_PCICFG_SPWR_DN);
+               delay(25);
        }
-#endif
+       if (adv->adv_enable)
+               panic("%s: %s: enable not supported!", __func__, adv->adv_name);
+
        return 0;
 }
 
@@ -392,10 +393,13 @@
                .adv_mirq = AR9344_MISC_IRQ_UART0,
        }, {
                .adv_name = "ehci",
-               .adv_addr = AR9344_USB_BASE,
+               .adv_addr = AR9344_USB_BASE + 0x100,
                .adv_size = 0x1000,
                .adv_cirq = ARCHIP_CPU_IRQ_USB,
                .adv_mirq = -1,
+               .adv_reset = AR9344_RESETCTL_USB_PHY_SUSPEND_OVERRIDE
+                   | ARCHIP_RESETCTL_USB_PHY_RESET
+                   | ARCHIP_RESETCTL_USB_HOST_RESET,
        }, {
                .adv_name = "age",
                .adv_addr = AR9344_GMAC0_BASE,
diff -r b39236e55101 -r 2f4930c8431c sys/arch/mips/atheros/ar_conf.c
--- a/sys/arch/mips/atheros/ar_conf.c   Sun Jul 10 06:24:18 2011 +0000
+++ b/sys/arch/mips/atheros/ar_conf.c   Sun Jul 10 06:26:02 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ar_conf.c,v 1.1 2011/07/07 05:06:44 matt Exp $ */
+/*     $NetBSD: ar_conf.c,v 1.2 2011/07/10 06:26:02 matt Exp $ */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: ar_conf.c,v 1.1 2011/07/07 05:06:44 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ar_conf.c,v 1.2 2011/07/10 06:26:02 matt Exp $");
 
 #include <sys/param.h>
 
@@ -102,6 +102,13 @@
 #ifdef WISOC_AR9344
        {
                .ac_platformsw =        &ar9344_platformsw,
+               .ac_chipid =            0x20,   /* 7240? */
+               .ac_chipmask =          0xff,
+               .ac_cid =               MIPS_PRID_CID_MTI,
+               .ac_pid =               MIPS_74K,
+               .ac_name =              "AR7240"
+       }, {
+               .ac_platformsw =        &ar9344_platformsw,
                .ac_chipid =            ARCHIP_AR9344,
                .ac_chipmask =          0xff,
                .ac_cid =               MIPS_PRID_CID_MTI,
@@ -132,6 +139,15 @@
 }
 
 uint32_t
+atheros_get_uart_freq(void)
+{
+       if (chip_freqs.freq_uart)
+               return chip_freqs.freq_uart;
+
+       return chip_freqs.freq_bus;
+}
+
+uint32_t
 atheros_get_bus_freq(void)
 {
        return chip_freqs.freq_bus;
@@ -172,6 +188,12 @@
                        atheros_early_consinit();
                        printf("Early console started!\n");
                        (*apsw->apsw_get_freqs)(&chip_freqs);
+                       printf("freqs: cpu=%u bus=%u mem=%u ref=%u pll=%u\n",
+                            chip_freqs.freq_cpu,
+                            chip_freqs.freq_bus,
+                            chip_freqs.freq_mem,
+                            chip_freqs.freq_ref,
+                            chip_freqs.freq_pll);
                        return;
                }
        }
diff -r b39236e55101 -r 2f4930c8431c sys/arch/mips/atheros/ar_console.c
--- a/sys/arch/mips/atheros/ar_console.c        Sun Jul 10 06:24:18 2011 +0000
+++ b/sys/arch/mips/atheros/ar_console.c        Sun Jul 10 06:26:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ar_console.c,v 1.1 2011/07/07 05:06:44 matt Exp $ */
+/* $NetBSD: ar_console.c,v 1.2 2011/07/10 06:26:02 matt Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  * This file implement an Atheros dependent early console.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ar_console.c,v 1.1 2011/07/07 05:06:44 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ar_console.c,v 1.2 2011/07/10 06:26:02 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -49,7 +49,7 @@
 #include <mips/atheros/include/platform.h>
 #include <mips/atheros/include/arbusvar.h>
 
-#include <machine/locore.h>
+#include <mips/locore.h>
 #include "com.h"
 
 #include <dev/ic/ns16450reg.h>
@@ -66,7 +66,8 @@
 #if NCOM > 0
        /* Setup polled serial for early console I/O */
        /* XXX: pass in CONSPEED? */
-       com_arbus_cnattach(platformsw->apsw_uart0_base, atheros_get_bus_freq());
+       com_arbus_cnattach(platformsw->apsw_uart0_base,
+           atheros_get_uart_freq());
 #else
        panic("Not configured to use serial console!\n");
        /* not going to see that message now, are we? */
diff -r b39236e55101 -r 2f4930c8431c sys/arch/mips/atheros/arbus.c
--- a/sys/arch/mips/atheros/arbus.c     Sun Jul 10 06:24:18 2011 +0000
+++ b/sys/arch/mips/atheros/arbus.c     Sun Jul 10 06:26:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $Id: arbus.c,v 1.14 2011/07/07 05:06:44 matt Exp $ */
+/* $Id: arbus.c,v 1.15 2011/07/10 06:26:02 matt Exp $ */
 /*
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
  * Copyright (c) 2006 Garrett D'Amore.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arbus.c,v 1.14 2011/07/07 05:06:44 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arbus.c,v 1.15 2011/07/10 06:26:02 matt Exp $");
 
 #include "locators.h"
 #define        _MIPS_BUS_DMA_PRIVATE
@@ -70,6 +70,9 @@
 CFATTACH_DECL_NEW(arbus, 0, arbus_match, arbus_attach, NULL, NULL);
 
 struct mips_bus_space  arbus_mbst;
+#if _BYTE_ORDER == _BIG_ENDIAN
+struct mips_bus_space  arbus_mbst_le;
+#endif
 struct mips_bus_dma_tag        arbus_mdt = {
        ._dmamap_ops = _BUS_DMAMAP_OPS_INITIALIZER,
        ._dmamem_ops = _BUS_DMAMEM_OPS_INITIALIZER,
@@ -85,6 +88,9 @@
        done = true;
 
        arbus_bus_mem_init(&arbus_mbst, NULL);
+#if _BYTE_ORDER == _BIG_ENDIAN
+       arbusle_bus_mem_init(&arbus_mbst_le, NULL);
+#endif
 }
 
 /* this primarily exists so we can get to the console... */
@@ -125,6 +131,11 @@
                aa.aa_size = adv->adv_size;
                aa.aa_dmat = &arbus_mdt;
                aa.aa_bst = &arbus_mbst;
+#if _BYTE_ORDER == _BIG_ENDIAN
+               aa.aa_bst_le = &arbus_mbst_le;
+#else
+               aa.aa_bst_le = &arbus_mbst;
+#endif
                aa.aa_cirq = adv->adv_cirq;
                aa.aa_mirq = adv->adv_mirq;
 
diff -r b39236e55101 -r 2f4930c8431c sys/arch/mips/atheros/arbusle.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mips/atheros/arbusle.c   Sun Jul 10 06:26:02 2011 +0000
@@ -0,0 +1,54 @@
+/* $NetBSD: arbusle.c,v 1.1 2011/07/10 06:26:02 matt Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+
+__KERNEL_RCSID(0, "$NetBSD: arbusle.c,v 1.1 2011/07/10 06:26:02 matt Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+
+#include <mips/atheros/include/arbusvar.h>
+
+#define CHIP                    arbusle
+#define CHIP_MEM                /* defined */
+#define        CHIP_LITTLE_ENDIAN      /* defined */
+#define CHIP_W1_BUS_START(v)    0x00000000UL
+#define CHIP_W1_BUS_END(v)      0x1fffffffUL
+#define CHIP_W1_SYS_START(v)    CHIP_W1_BUS_START(v)
+#define CHIP_W1_SYS_END(v)      CHIP_W1_BUS_END(v)
+//#define      CHIP_ACCESS_SIZE        4
+
+#include <mips/mips/bus_space_alignstride_chipdep.c>
+#endif /* _BYTE_ORDER == _BIG_ENDIAN */
diff -r b39236e55101 -r 2f4930c8431c sys/arch/mips/atheros/dev/ehci_arbus.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mips/atheros/dev/ehci_arbus.c    Sun Jul 10 06:26:02 2011 +0000
@@ -0,0 +1,138 @@
+/*     $NetBSD: ehci_arbus.c,v 1.1 2011/07/10 06:26:02 matt Exp $      */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *



Home | Main Index | Thread Index | Old Index