Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc Support Synopsys DesigneWave OTG on PowerPC...
details: https://anonhg.NetBSD.org/src/rev/bd8caf6e346b
branches: trunk
changeset: 791496:bd8caf6e346b
user: kiyohara <kiyohara%NetBSD.org@localhost>
date: Thu Nov 21 13:33:15 2013 +0000
description:
Support Synopsys DesigneWave OTG on PowerPC 405EX.
diffstat:
sys/arch/powerpc/conf/files.ibm4xx | 8 +-
sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c | 161 +++++++++++++++++++++++++++++++
sys/arch/powerpc/ibm4xx/dev/plb.c | 10 +-
sys/arch/powerpc/ibm4xx/dev/plbvar.h | 3 +-
sys/arch/powerpc/include/ibm4xx/dcr4xx.h | 46 ++++++++-
5 files changed, 221 insertions(+), 7 deletions(-)
diffs (truncated from 319 to 300 lines):
diff -r 84030fcb1e52 -r bd8caf6e346b sys/arch/powerpc/conf/files.ibm4xx
--- a/sys/arch/powerpc/conf/files.ibm4xx Thu Nov 21 11:21:54 2013 +0000
+++ b/sys/arch/powerpc/conf/files.ibm4xx Thu Nov 21 13:33:15 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.ibm4xx,v 1.14 2011/06/22 18:06:34 matt Exp $
+# $NetBSD: files.ibm4xx,v 1.15 2013/11/21 13:33:15 kiyohara Exp $
#
# IBM 4xx specific configuration info
@@ -12,7 +12,7 @@
file arch/powerpc/ibm4xx/board_prop.c
# Processor Local Bus
-device plb { [irq = -1] }
+device plb {[addr = -1], [irq = -1]}
attach plb at root
file arch/powerpc/ibm4xx/dev/plb.c plb
@@ -77,3 +77,7 @@
#device exb {[addr = -1]}
#attach exb at plb
#file arch/powerpc/ibm4xx/dev/exb.c exb
+
+# On-chip USB OTG bridge (Synopsys DesigneWave OTG)
+attach dwctwo at plb with dwctwo_plb
+file arch/powerpc/ibm4xx/dev/dwctwo_plb.c dwctwo_plb
diff -r 84030fcb1e52 -r bd8caf6e346b sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c Thu Nov 21 13:33:15 2013 +0000
@@ -0,0 +1,161 @@
+/* $NetBSD: dwctwo_plb.c,v 1.1 2013/11/21 13:33:15 kiyohara Exp $ */
+/*
+ * Copyright (c) 2013 KIYOHARA Takashi
+ * All rights reserved.
+ *
+ * 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 AUTHOR ``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 AUTHOR 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: dwctwo_plb.c,v 1.1 2013/11/21 13:33:15 kiyohara Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+#include <sys/extent.h>
+
+#include <powerpc/ibm4xx/cpu.h>
+#include <powerpc/ibm4xx/dev/plbvar.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdivar.h>
+#include <dev/usb/usb_mem.h>
+
+#include <dwc2/dwc2.h>
+#include <dwc2/dwc2var.h>
+#include "dwc2_core.h"
+
+#include "locators.h"
+
+#define DWCTWO_SIZE 0x40000
+
+static int dwctwo_plb_match(device_t, cfdata_t, void *);
+static void dwctwo_plb_attach(device_t, device_t, void *);
+
+static void dwctwo_plb_deferred(device_t);
+
+CFATTACH_DECL_NEW(dwctwo_plb, sizeof(struct dwc2_softc),
+ dwctwo_plb_match, dwctwo_plb_attach, NULL, NULL);
+
+static struct powerpc_bus_space dwctwo_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN | _BUS_SPACE_MEM_TYPE,
+ 0x00000000,
+ 0x00000000,
+ DWCTWO_SIZE
+};
+static char ex_storage[EXTENT_FIXED_STORAGE_SIZE(8)]
+ __attribute__((aligned(8)));
+
+static struct dwc2_core_params dwctwo_405ex_params = {
+ .otg_cap = 0, /* HNP/SRP capable */
+ .otg_ver = 0, /* 1.3 */
+ .dma_enable = 1,
+ .dma_desc_enable = 0,
+ .speed = 0, /* High Speed */
+ .enable_dynamic_fifo = 1,
+ .en_multiple_tx_fifo = 0,
+ .host_rx_fifo_size = 531, /* 531 DWORDs */
+ .host_nperio_tx_fifo_size = 256, /* 256 DWORDs */
+ .host_perio_tx_fifo_size = 256, /* 256 DWORDs */
+ .max_transfer_size = 524287,
+ .max_packet_count = 1023,
+ .host_channels = 4,
+ .phy_type = 2, /* ULPI */
+ .phy_utmi_width = 8, /* 8 bits */
+ .phy_ulpi_ddr = 0, /* Single */
+ .phy_ulpi_ext_vbus = 0,
+ .i2c_enable = 0,
+ .ulpi_fs_ls = 0,
+ .host_support_fs_ls_low_power = 0,
+ .host_ls_low_power_phy_clk = 0, /* 48 MHz */
+ .ts_dline = 0,
+ .reload_ctl = 0,
+ .ahbcfg = 0x10,
+ .uframe_sched = 1,
+};
+
+
+static int
+dwctwo_plb_match(device_t parent, cfdata_t match, void *aux)
+{
+ struct plb_attach_args *paa = aux;
+
+ if (strcmp(paa->plb_name, match->cf_name) != 0)
+ return 0;
+
+ if (match->cf_loc[PLBCF_ADDR] == PLBCF_ADDR_DEFAULT)
+ panic("dwctwo_plb_match: wildcard addr not allowed");
+ if (match->cf_loc[PLBCF_IRQ] == PLBCF_IRQ_DEFAULT)
+ panic("dwctwo_plb_match: wildcard IRQ not allowed");
+
+ paa->plb_addr = match->cf_loc[PLBCF_ADDR];
+ paa->plb_irq = match->cf_loc[PLBCF_IRQ];
+ return 1;
+}
+
+static void
+dwctwo_plb_attach(device_t parent, device_t self, void *aux)
+{
+ struct dwc2_softc *sc = device_private(self);
+ struct plb_attach_args *paa = aux;
+ uint32_t srst0;
+
+ sc->sc_dev = self;
+ sc->sc_params = &dwctwo_405ex_params;
+
+ dwctwo_tag.pbs_base = paa->plb_addr;
+ dwctwo_tag.pbs_limit += paa->plb_addr;
+ if (bus_space_init(&dwctwo_tag, "dwctwotag", ex_storage,
+ sizeof(ex_storage)))
+ panic("dwctwo_attach: Failed to initialise opb_tag");
+ sc->sc_iot = &dwctwo_tag;
+ bus_space_map(sc->sc_iot, paa->plb_addr, DWCTWO_SIZE, 0, &sc->sc_ioh);
+ sc->sc_bus.dmatag = paa->plb_dmat;
+
+ intr_establish(paa->plb_irq, IST_LEVEL, IPL_USB, dwc2_intr, sc);
+
+ /* Enable the USB interface. */
+ mtsdr(DCR_SDR0_PFC1, mfsdr(DCR_SDR0_PFC1) | SDR0_PFC1_USBEN);
+ srst0 = mfsdr(DCR_SDR0_SRST0);
+ mtsdr(DCR_SDR0_SRST0, srst0 | SDR0_SRST0_UPRST | SDR0_SRST0_AHB);
+ delay(200 * 1000); /* XXXX */
+ mtsdr(DCR_SDR0_SRST0, srst0);
+
+ config_defer(self, dwctwo_plb_deferred);
+}
+
+static void
+dwctwo_plb_deferred(device_t self)
+{
+ struct dwc2_softc *sc = device_private(self);
+ int error;
+
+ error = dwc2_init(sc);
+ if (error != 0) {
+ aprint_error_dev(self, "couldn't initialize host, error=%d\n",
+ error);
+ return;
+ }
+ sc->sc_child = config_found(sc->sc_dev, &sc->sc_bus, usbctlprint);
+}
diff -r 84030fcb1e52 -r bd8caf6e346b sys/arch/powerpc/ibm4xx/dev/plb.c
--- a/sys/arch/powerpc/ibm4xx/dev/plb.c Thu Nov 21 11:21:54 2013 +0000
+++ b/sys/arch/powerpc/ibm4xx/dev/plb.c Thu Nov 21 13:33:15 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: plb.c,v 1.20 2011/06/18 06:41:42 matt Exp $ */
+/* $NetBSD: plb.c,v 1.21 2013/11/21 13:33:15 kiyohara Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plb.c,v 1.20 2011/06/18 06:41:42 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plb.c,v 1.21 2013/11/21 13:33:15 kiyohara Exp $");
#include "locators.h"
#include "emac.h"
@@ -107,7 +107,7 @@
{ AMCC405EX, "cpu", },
{ AMCC405EX, "ecc", },
{ AMCC405EX, "opb", },
- { AMCC405EX, "pchb", },
+ { AMCC405EX, "dwctwo", },
{ 0, NULL }
};
@@ -174,6 +174,7 @@
continue;
paa.plb_name = plb_devs[i].plb_name;
+ paa.plb_addr = PLBCF_ADDR_DEFAULT;
paa.plb_dmat = &ibm4xx_default_bus_dma_tag;
paa.plb_irq = PLBCF_IRQ_DEFAULT;
@@ -185,6 +186,7 @@
continue;
paa.plb_name = local_plb_devs->plb_name;
+ paa.plb_addr = PLBCF_ADDR_DEFAULT;
paa.plb_dmat = &ibm4xx_default_bus_dma_tag;
paa.plb_irq = PLBCF_IRQ_DEFAULT;
@@ -200,6 +202,8 @@
if (pnp)
aprint_normal("%s at %s", paa->plb_name, pnp);
+ if (paa->plb_addr != PLBCF_ADDR_DEFAULT)
+ aprint_normal(" address 0x%08x", paa->plb_addr);
if (paa->plb_irq != PLBCF_IRQ_DEFAULT)
aprint_normal(" irq %d", paa->plb_irq);
diff -r 84030fcb1e52 -r bd8caf6e346b sys/arch/powerpc/ibm4xx/dev/plbvar.h
--- a/sys/arch/powerpc/ibm4xx/dev/plbvar.h Thu Nov 21 11:21:54 2013 +0000
+++ b/sys/arch/powerpc/ibm4xx/dev/plbvar.h Thu Nov 21 13:33:15 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: plbvar.h,v 1.6 2011/06/18 06:41:42 matt Exp $ */
+/* $NetBSD: plbvar.h,v 1.7 2013/11/21 13:33:15 kiyohara Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -45,5 +45,6 @@
struct plb_attach_args {
const char *plb_name;
bus_dma_tag_t plb_dmat; /* DMA tag */
+ bus_addr_t plb_addr;
int plb_irq;
};
diff -r 84030fcb1e52 -r bd8caf6e346b sys/arch/powerpc/include/ibm4xx/dcr4xx.h
--- a/sys/arch/powerpc/include/ibm4xx/dcr4xx.h Thu Nov 21 11:21:54 2013 +0000
+++ b/sys/arch/powerpc/include/ibm4xx/dcr4xx.h Thu Nov 21 13:33:15 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dcr4xx.h,v 1.2 2010/11/06 16:32:08 uebayasi Exp $ */
+/* $NetBSD: dcr4xx.h,v 1.3 2013/11/21 13:33:15 kiyohara Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -239,6 +239,50 @@
/* Indirectly accessed Clocking Controller DCRs */
+#define DCR_SDR0_SRST0 0x0200 /* Soft Reset */
+#define SDR0_SRST0_BGO (1 << 31) /* PLB4 to OPB bridge */
+#define SDR0_SRST0_PLB4 (1 << 30) /* PLB4 arbiter */
+#define SDR0_SRST0_EBC (1 << 29) /* External bus controller */
+#define SDR0_SRST0_OPB (1 << 28) /* OPB arbiter */
+#define SDR0_SRST0_UART0 (1 << 27) /* Universal asynchronous receiver/transmitter 0 */
+#define SDR0_SRST0_UART1 (1 << 26) /* Universal asynchronous receiver/transmitter 1 */
+#define SDR0_SRST0_IIC0 (1 << 25) /* Inter integrated circuit 0 */
+#define SDR0_SRST0_BGI (1 << 24) /* OPB to PLB bridge */
+#define SDR0_SRST0_GPIO (1 << 23) /* General purpose I/O */
+#define SDR0_SRST0_GPT (1 << 22) /* General purpose timer */
+#define SDR0_SRST0_DMC (1 << 21) /* DDR1/2 SDRAM memory controller */
+#define SDR0_SRST0_RGMII (1 << 20) /* RGMII bridge */
+#define SDR0_SRST0_EMAC0 (1 << 19) /* Ethernet media access controller 0 */
+#define SDR0_SRST0_EMAC1 (1 << 18) /* Ethernet media access controller 1 */
+#define SDR0_SRST0_CPM (1 << 17) /* Clock and power management */
+#define SDR0_SRST0_EPLL (1 << 16) /* Ethernet PLL */
+#define SDR0_SRST0_UIC (1 << 15) /* UIC0, UIC1, UIC2 */
+#define SDR0_SRST0_UPRST (1 << 14) /* USB PRST */
+#define SDR0_SRST0_IIC1 (1 << 13) /* Inter integrated circuit 1 */
+#define SDR0_SRST0_SCP (1 << 12) /* Serial communications port */
+#define SDR0_SRST0_UHRST (1 << 11) /* USB HRESET (AHB) */
+#define SDR0_SRST0_DMA (1 << 10) /* Direct memory access controller */
+#define SDR0_SRST0_DMAC (1 << 9) /* DMA channel */
+#define SDR0_SRST0_MAL (1 << 8) /* Media access layer */
+#define SDR0_SRST0_EBM (1 << 7) /* External bus master */
+#define SDR0_SRST0_GPTR (1 << 6) /* General purpose timer */
+#define SDR0_SRST0_PE0 (1 << 5) /* PCI Express 0 */
Home |
Main Index |
Thread Index |
Old Index