svn commit: r239281 - in head/sys: arm/conf arm/ti arm/ti/am335x
arm/ti/cpsw arm/ti/omap3 arm/ti/omap4 arm/ti/omap4/pandaboard
arm/ti/twl arm/ti/usb boot/fdt/dts dev/mmc modules modules/cpsw
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Wed Aug 15 06:31:33 UTC 2012
Author: gonzo
Date: Wed Aug 15 06:31:32 2012
New Revision: 239281
URL: http://svn.freebsd.org/changeset/base/239281
Log:
Merging of projects/armv6, part 10
- Support for Texas Instruments SoCs:
- AM335x
- OMAP4
- Kernel configs, DTS for Beaglebone and Pandaboard
Submitted by: Ben Gray, Damjan Marion
Added:
head/sys/arm/conf/BEAGLEBONE (contents, props changed)
head/sys/arm/conf/PANDABOARD (contents, props changed)
head/sys/arm/conf/PANDABOARD.hints (contents, props changed)
head/sys/arm/ti/
head/sys/arm/ti/aintc.c (contents, props changed)
head/sys/arm/ti/am335x/
head/sys/arm/ti/am335x/am335x_dmtimer.c (contents, props changed)
head/sys/arm/ti/am335x/am335x_pmic.c (contents, props changed)
head/sys/arm/ti/am335x/am335x_prcm.c (contents, props changed)
head/sys/arm/ti/am335x/am335x_reg.h (contents, props changed)
head/sys/arm/ti/am335x/am335x_scm_padconf.c (contents, props changed)
head/sys/arm/ti/am335x/files.am335x (contents, props changed)
head/sys/arm/ti/am335x/files.beaglebone (contents, props changed)
head/sys/arm/ti/am335x/std.am335x (contents, props changed)
head/sys/arm/ti/am335x/std.beaglebone (contents, props changed)
head/sys/arm/ti/bus_space.c (contents, props changed)
head/sys/arm/ti/common.c (contents, props changed)
head/sys/arm/ti/cpsw/
head/sys/arm/ti/cpsw/if_cpsw.c (contents, props changed)
head/sys/arm/ti/cpsw/if_cpswreg.h (contents, props changed)
head/sys/arm/ti/cpsw/if_cpswvar.h (contents, props changed)
head/sys/arm/ti/files.ti (contents, props changed)
head/sys/arm/ti/omap3/
head/sys/arm/ti/omap3/omap3_reg.h (contents, props changed)
head/sys/arm/ti/omap4/
head/sys/arm/ti/omap4/files.omap4 (contents, props changed)
head/sys/arm/ti/omap4/omap4_l2cache.c (contents, props changed)
head/sys/arm/ti/omap4/omap4_mp.c (contents, props changed)
head/sys/arm/ti/omap4/omap4_prcm_clks.c (contents, props changed)
head/sys/arm/ti/omap4/omap4_reg.h (contents, props changed)
head/sys/arm/ti/omap4/omap4_scm_padconf.c (contents, props changed)
head/sys/arm/ti/omap4/omap4_smc.h (contents, props changed)
head/sys/arm/ti/omap4/omap4var.h (contents, props changed)
head/sys/arm/ti/omap4/pandaboard/
head/sys/arm/ti/omap4/pandaboard/files.pandaboard (contents, props changed)
head/sys/arm/ti/omap4/pandaboard/pandaboard.c (contents, props changed)
head/sys/arm/ti/omap4/pandaboard/std.pandaboard (contents, props changed)
head/sys/arm/ti/omap4/std.omap4 (contents, props changed)
head/sys/arm/ti/std.ti (contents, props changed)
head/sys/arm/ti/ti_cpuid.c (contents, props changed)
head/sys/arm/ti/ti_cpuid.h (contents, props changed)
head/sys/arm/ti/ti_edma3.c (contents, props changed)
head/sys/arm/ti/ti_edma3.h (contents, props changed)
head/sys/arm/ti/ti_gpio.c (contents, props changed)
head/sys/arm/ti/ti_i2c.c (contents, props changed)
head/sys/arm/ti/ti_i2c.h (contents, props changed)
head/sys/arm/ti/ti_machdep.c (contents, props changed)
head/sys/arm/ti/ti_mmchs.c (contents, props changed)
head/sys/arm/ti/ti_mmchs.h (contents, props changed)
head/sys/arm/ti/ti_prcm.c (contents, props changed)
head/sys/arm/ti/ti_prcm.h (contents, props changed)
head/sys/arm/ti/ti_scm.c (contents, props changed)
head/sys/arm/ti/ti_scm.h (contents, props changed)
head/sys/arm/ti/ti_sdma.c (contents, props changed)
head/sys/arm/ti/ti_sdma.h (contents, props changed)
head/sys/arm/ti/ti_sdmareg.h (contents, props changed)
head/sys/arm/ti/ti_smc.S (contents, props changed)
head/sys/arm/ti/ti_smc.h (contents, props changed)
head/sys/arm/ti/tivar.h (contents, props changed)
head/sys/arm/ti/twl/
head/sys/arm/ti/twl/twl.c (contents, props changed)
head/sys/arm/ti/twl/twl.h (contents, props changed)
head/sys/arm/ti/twl/twl_clks.c (contents, props changed)
head/sys/arm/ti/twl/twl_clks.h (contents, props changed)
head/sys/arm/ti/twl/twl_vreg.c (contents, props changed)
head/sys/arm/ti/twl/twl_vreg.h (contents, props changed)
head/sys/arm/ti/usb/
head/sys/arm/ti/usb/omap_ehci.c (contents, props changed)
head/sys/arm/ti/usb/omap_usb.h (contents, props changed)
head/sys/boot/fdt/dts/beaglebone.dts (contents, props changed)
head/sys/boot/fdt/dts/pandaboard.dts (contents, props changed)
head/sys/modules/cpsw/
head/sys/modules/cpsw/Makefile (contents, props changed)
Modified:
head/sys/dev/mmc/mmc.c
head/sys/modules/Makefile
Added: head/sys/arm/conf/BEAGLEBONE
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/arm/conf/BEAGLEBONE Wed Aug 15 06:31:32 2012 (r239281)
@@ -0,0 +1,126 @@
+# BEAGLEBONE -- Custom configuration for the BeagleBone ARM development
+# platform, check out http://www.beagleboard.org/bone
+#
+# For more information on this file, please read the handbook section on
+# Kernel Configuration Files:
+#
+# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# The handbook is also available locally in /usr/share/doc/handbook
+# if you've installed the doc distribution, otherwise always see the
+# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
+# latest information.
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files.
+# If you are in doubt as to the purpose or necessity of a line, check first
+# in NOTES.
+#
+# $FreeBSD$
+
+ident BEAGLEBONE
+
+include "../ti/am335x/std.beaglebone"
+
+makeoptions MODULES_OVERRIDE=""
+makeoptions WITHOUT_MODULES="ahc"
+
+options HZ=100
+options SCHED_4BSD #4BSD scheduler
+options INET #InterNETworking
+options INET6 #IPv6 communications protocols
+options FFS #Berkeley Fast Filesystem
+options SOFTUPDATES #Enable FFS soft updates support
+options UFS_ACL #Support for access control lists
+options UFS_DIRHASH #Improve performance on big directories
+options MSDOSFS #MSDOS Filesystem
+options CD9660 #ISO 9660 Filesystem
+options PROCFS #Process filesystem (requires PSEUDOFS)
+options PSEUDOFS #Pseudo-filesystem framework
+options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
+options SCSI_DELAY=5000 #Delay (in ms) before probing SCSI
+options KTRACE #ktrace(1) support
+options SYSVSHM #SYSV-style shared memory
+options SYSVMSG #SYSV-style message queues
+options SYSVSEM #SYSV-style semaphores
+options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+options KBD_INSTALL_CDEV # install a CDEV entry in /dev
+options PREEMPTION
+
+# Debugging
+makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
+options BREAK_TO_DEBUGGER
+#options VERBOSE_SYSINIT #Enable verbose sysinit messages
+options KDB
+options DDB #Enable the kernel debugger
+options INVARIANTS #Enable calls of extra sanity checking
+options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS
+options WITNESS #Enable checks to detect deadlocks and cycles
+options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed
+#options DIAGNOSTIC
+
+# NFS support
+#options NFSCL
+#options NFSSERVER #Network Filesystem Server
+#options NFSCLIENT #Network Filesystem Client
+
+# Uncomment this for NFS root
+#options NFS_ROOT #NFS usable as /, requires NFSCLIENT
+#options BOOTP_NFSROOT
+#options BOOTP_COMPAT
+#options BOOTP
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=cpsw0
+
+
+# MMC/SD/SDIO card slot support
+device mmc # mmc/sd bus
+device mmcsd # mmc/sd flash cards
+
+# Boot device is 2nd slice on MMC/SD card
+options ROOTDEVNAME=\"ufs:mmcsd0s2\"
+
+# Console and misc
+device uart
+device uart_ns8250
+device pty
+device snp
+device md
+device random # Entropy device
+
+# I2C support
+device iicbus
+device iic
+device ti_i2c
+device am335x_pmic # AM335x Power Management IC (TPC65217)
+
+# GPIO
+device gpio
+
+# USB support
+device usb
+options USB_DEBUG
+#options USB_REQ_DEBUG
+#options USB_VERBOSE
+device musb
+device umass
+device scbus # SCSI bus (required for SCSI)
+device da # Direct Access (disks)
+
+# Ethernet
+device loop
+device ether
+device mii
+device smscphy
+device cpsw
+device bpf
+
+# USB ethernet support, requires miibus
+device miibus
+device axe # ASIX Electronics USB Ethernet
+
+# Flattened Device Tree
+options FDT
+options FDT_DTB_STATIC
+makeoptions FDT_DTS_FILE=beaglebone.dts
+
Added: head/sys/arm/conf/PANDABOARD
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/arm/conf/PANDABOARD Wed Aug 15 06:31:32 2012 (r239281)
@@ -0,0 +1,144 @@
+# PANDABOARD -- Custom configuration for the PandaBoard ARM development
+# platform, check out www.pandaboard.org
+#
+# For more information on this file, please read the handbook section on
+# Kernel Configuration Files:
+#
+# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# The handbook is also available locally in /usr/share/doc/handbook
+# if you've installed the doc distribution, otherwise always see the
+# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
+# latest information.
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files.
+# If you are in doubt as to the purpose or necessity of a line, check first
+# in NOTES.
+#
+# $FreeBSD$
+
+ident PANDABOARD
+
+
+
+# This probably wants to move somewhere else. Maybe we can create a basic
+# OMAP4340 config, then make a PANDABOARD config that includes the basic one,
+# adds the start addresses and custom devices plus pulls in this hints file.
+
+hints "PANDABOARD.hints"
+
+include "../ti/omap4/pandaboard/std.pandaboard"
+
+#To statically compile in device wiring instead of /boot/device.hints
+makeoptions MODULES_OVERRIDE=""
+makeoptions WITHOUT_MODULES="ahc"
+
+makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
+options HZ=100
+
+options SCHED_4BSD #4BSD scheduler
+options INET #InterNETworking
+#options INET6 #IPv6 communications protocols
+options FFS #Berkeley Fast Filesystem
+options SOFTUPDATES #Enable FFS soft updates support
+options UFS_ACL #Support for access control lists
+options UFS_DIRHASH #Improve performance on big directories
+options NFSCLIENT #Network Filesystem Client
+device snp
+#options NFSCL
+#options NFSSERVER #Network Filesystem Server
+options NFS_ROOT #NFS usable as /, requires NFSCLIENT
+options BREAK_TO_DEBUGGER
+options BOOTP_NFSROOT
+options BOOTP_COMPAT
+options BOOTP
+options BOOTP_NFSV3
+options BOOTP_WIRED_TO=ue0
+options MSDOSFS #MSDOS Filesystem
+#options CD9660 #ISO 9660 Filesystem
+#options PROCFS #Process filesystem (requires PSEUDOFS)
+options PSEUDOFS #Pseudo-filesystem framework
+options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
+options SCSI_DELAY=5000 #Delay (in ms) before probing SCSI
+options KTRACE #ktrace(1) support
+options SYSVSHM #SYSV-style shared memory
+options SYSVMSG #SYSV-style message queues
+options SYSVSEM #SYSV-style semaphores
+options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+options KBD_INSTALL_CDEV # install a CDEV entry in /dev
+
+options PREEMPTION
+
+# MMC/SD/SDIO Card slot support
+device mmc # mmc/sd bus
+device mmcsd # mmc/sd flash cards
+
+# I2C support
+device iicbus
+device iic
+device ti_i2c
+
+device loop
+device ether
+device mii
+device smc
+device smcphy
+device uart
+device uart_ns8250
+
+device gpio
+
+device pty
+
+device pl310 # PL310 L2 cache controller
+# Debugging for use in -current
+#options VERBOSE_SYSINIT #Enable verbose sysinit messages
+options KDB
+options DDB #Enable the kernel debugger
+#options INVARIANTS #Enable calls of extra sanity checking
+#options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS
+#options WITNESS #Enable checks to detect deadlocks and cycles
+#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed
+#options DIAGNOSTIC
+
+device md
+
+# The following enables MFS as root, this seems similar to an initramfs or initrd
+# as used in Linux.
+# options MD_ROOT
+# options MD_ROOT_SIZE=7560
+
+device random # Entropy device
+
+# USB support
+device usb
+options USB_DEBUG
+#options USB_REQ_DEBUG
+#options USB_VERBOSE
+device ohci
+device ehci
+device umass
+device scbus # SCSI bus (required for SCSI)
+device da # Direct Access (disks)
+
+
+# USB Ethernet support, requires miibus
+device miibus
+# device axe # ASIX Electronics USB Ethernet
+device smsc # SMSC LAN95xx USB Ethernet
+
+
+# OMAP-specific devices
+device ti_sdma
+device twl
+device twl_vreg
+device twl_clks
+
+# Flattened Device Tree
+options FDT
+options FDT_DTB_STATIC
+makeoptions FDT_DTS_FILE=pandaboard.dts
+
+# device vfp # vfp/neon
+# options ARM_VFP_SUPPORT # vfp/neon
Added: head/sys/arm/conf/PANDABOARD.hints
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/arm/conf/PANDABOARD.hints Wed Aug 15 06:31:32 2012 (r239281)
@@ -0,0 +1,61 @@
+# $FreeBSD$
+
+# USB ECHI
+
+#
+# TI OMAP Power Management and System Companion Device sitting on the I2C bus
+# hint.tps65950.0.at="iicbus0"
+# hint.tps65950.0.addr=0xd0
+
+
+#
+# Defines the GPIO pin used to detect the Write Protect stat of the MMC/SD card.
+#hint.omap_mmc.0.wp_gpio="23"
+
+
+#
+# If 'phy_reset" is set, then the accompaning PHY is reset using one of the
+# GPIO pins. If the reset GPIO pin is not -1 then the pin will be toggled when
+# the USB driver is loaded.
+hint.ehci.0.phy_reset="0"
+
+#
+# Sets the PHY mode for the individual ports, the following values are allowed
+# - EHCI_HCD_OMAP3_MODE_UNKNOWN 0
+# - EHCI_HCD_OMAP3_MODE_PHY 1
+# - EHCI_HCD_OMAP3_MODE_TLL 2
+hint.ehci.0.phy_mode_0="1"
+hint.ehci.0.phy_mode_1="0"
+hint.ehci.0.phy_mode_2="0"
+
+#
+# If specified the value indicates a pin that is toggled as a heart-beat. The
+# heart beat pusle is triggered every 500ms using the system tick timer.
+hint.omap_clk.0.heartbeat_gpio="150"
+
+
+#
+# Padconf (pinmux) settings - typically this would be set by the boot-loader
+# but can be overridden here. These hints are applied to the H/W when the
+# SCM module is initialised.
+#
+# The format is:
+# hint.omap_scm.0.padconf.<padname>=<muxmode:options>
+#
+# Where the options can be one of the following:
+# output, input, input_pullup, input_pulldown
+#
+
+# Setup the pin settings for the HS USB Host (PHY mode)
+hint.omap4.0.padconf.ag19="usbb1_ulpiphy_stp:output"
+hint.omap4.0.padconf.ae18="usbb1_ulpiphy_clk:input_pulldown"
+hint.omap4.0.padconf.af19="usbb1_ulpiphy_dir:input_pulldown"
+hint.omap4.0.padconf.ae19="usbb1_ulpiphy_nxt:input_pulldown"
+hint.omap4.0.padconf.af18="usbb1_ulpiphy_dat0:input_pulldown"
+hint.omap4.0.padconf.ag18="usbb1_ulpiphy_dat1:input_pulldown"
+hint.omap4.0.padconf.ae17="usbb1_ulpiphy_dat2:input_pulldown"
+hint.omap4.0.padconf.af17="usbb1_ulpiphy_dat3:input_pulldown"
+hint.omap4.0.padconf.ah17="usbb1_ulpiphy_dat4:input_pulldown"
+hint.omap4.0.padconf.ae16="usbb1_ulpiphy_dat5:input_pulldown"
+hint.omap4.0.padconf.af16="usbb1_ulpiphy_dat6:input_pulldown"
+hint.omap4.0.padconf.ag16="usbb1_ulpiphy_dat7:input_pulldown"
Added: head/sys/arm/ti/aintc.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/arm/ti/aintc.c Wed Aug 15 06:31:32 2012 (r239281)
@@ -0,0 +1,179 @@
+/*-
+ * Copyright (c) 2012 Damjan Marion <dmarion at Freebsd.org>
+ * All rights reserved.
+ *
+ * Based on OMAP3 INTC code by Ben Gray
+ *
+ * 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 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 AUTHOR 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>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/module.h>
+#include <sys/rman.h>
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#define INTC_REVISION 0x00
+#define INTC_SYSCONFIG 0x10
+#define INTC_SYSSTATUS 0x14
+#define INTC_SIR_IRQ 0x40
+#define INTC_CONTROL 0x48
+#define INTC_THRESHOLD 0x68
+#define INTC_MIR_CLEAR(x) (0x88 + ((x) * 0x20))
+#define INTC_MIR_SET(x) (0x8C + ((x) * 0x20))
+#define INTC_ISR_SET(x) (0x90 + ((x) * 0x20))
+#define INTC_ISR_CLEAR(x) (0x94 + ((x) * 0x20))
+
+struct ti_aintc_softc {
+ device_t sc_dev;
+ struct resource * aintc_res[3];
+ bus_space_tag_t aintc_bst;
+ bus_space_handle_t aintc_bsh;
+ uint8_t ver;
+};
+
+static struct resource_spec ti_aintc_spec[] = {
+ { SYS_RES_MEMORY, 0, RF_ACTIVE },
+ { -1, 0 }
+};
+
+
+static struct ti_aintc_softc *ti_aintc_sc = NULL;
+
+#define aintc_read_4(reg) \
+ bus_space_read_4(ti_aintc_sc->aintc_bst, ti_aintc_sc->aintc_bsh, reg)
+#define aintc_write_4(reg, val) \
+ bus_space_write_4(ti_aintc_sc->aintc_bst, ti_aintc_sc->aintc_bsh, reg, val)
+
+
+static int
+ti_aintc_probe(device_t dev)
+{
+ if (!ofw_bus_is_compatible(dev, "ti,aintc"))
+ return (ENXIO);
+ device_set_desc(dev, "TI AINTC Interrupt Controller");
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+ti_aintc_attach(device_t dev)
+{
+ struct ti_aintc_softc *sc = device_get_softc(dev);
+ uint32_t x;
+
+ sc->sc_dev = dev;
+
+ if (ti_aintc_sc)
+ return (ENXIO);
+
+ if (bus_alloc_resources(dev, ti_aintc_spec, sc->aintc_res)) {
+ device_printf(dev, "could not allocate resources\n");
+ return (ENXIO);
+ }
+
+ sc->aintc_bst = rman_get_bustag(sc->aintc_res[0]);
+ sc->aintc_bsh = rman_get_bushandle(sc->aintc_res[0]);
+
+ ti_aintc_sc = sc;
+
+ x = aintc_read_4(INTC_REVISION);
+ device_printf(dev, "Revision %u.%u\n",(x >> 4) & 0xF, x & 0xF);
+
+ /* SoftReset */
+ aintc_write_4(INTC_SYSCONFIG, 2);
+
+ /* Wait for reset to complete */
+ while(!(aintc_read_4(INTC_SYSSTATUS) & 1));
+
+ /*Set Priority Threshold */
+ aintc_write_4(INTC_THRESHOLD, 0xFF);
+
+ return (0);
+}
+
+static device_method_t ti_aintc_methods[] = {
+ DEVMETHOD(device_probe, ti_aintc_probe),
+ DEVMETHOD(device_attach, ti_aintc_attach),
+ { 0, 0 }
+};
+
+static driver_t ti_aintc_driver = {
+ "aintc",
+ ti_aintc_methods,
+ sizeof(struct ti_aintc_softc),
+};
+
+static devclass_t ti_aintc_devclass;
+
+DRIVER_MODULE(aintc, simplebus, ti_aintc_driver, ti_aintc_devclass, 0, 0);
+
+int
+arm_get_next_irq(int last_irq)
+{
+ uint32_t active_irq;
+
+ if (last_irq != -1) {
+ aintc_write_4(INTC_ISR_CLEAR(last_irq >> 5),
+ 1UL << (last_irq & 0x1F));
+ aintc_write_4(INTC_CONTROL,1);
+ }
+
+ /* Get the next active interrupt */
+ active_irq = aintc_read_4(INTC_SIR_IRQ);
+
+ /* Check for spurious interrupt */
+ if ((active_irq & 0xffffff80)) {
+ device_printf(ti_aintc_sc->sc_dev,
+ "Spurious interrupt detected (0x%08x)\n", active_irq);
+ return -1;
+ }
+
+ if (active_irq != last_irq)
+ return active_irq;
+ else
+ return -1;
+}
+
+void
+arm_mask_irq(uintptr_t nb)
+{
+ aintc_write_4(INTC_MIR_SET(nb >> 5), (1UL << (nb & 0x1F)));
+}
+
+void
+arm_unmask_irq(uintptr_t nb)
+{
+ aintc_write_4(INTC_MIR_CLEAR(nb >> 5), (1UL << (nb & 0x1F)));
+}
Added: head/sys/arm/ti/am335x/am335x_dmtimer.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/arm/ti/am335x/am335x_dmtimer.c Wed Aug 15 06:31:32 2012 (r239281)
@@ -0,0 +1,385 @@
+/*-
+ * Copyright (c) 2012 Damjan Marion <dmarion at Freebsd.org>
+ * 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 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 AUTHOR 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>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/malloc.h>
+#include <sys/rman.h>
+#include <sys/timeet.h>
+#include <sys/timetc.h>
+#include <sys/watchdog.h>
+#include <machine/bus.h>
+#include <machine/cpu.h>
+#include <machine/frame.h>
+#include <machine/intr.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <machine/bus.h>
+#include <machine/fdt.h>
+
+#include <arm/ti/ti_prcm.h>
+
+#define AM335X_NUM_TIMERS 8
+
+#define DMTIMER_TIDR 0x00 /* Identification Register */
+#define DMTIMER_TIOCP_CFG 0x10 /* Timer OCP Configuration Reg */
+#define DMTIMER_IQR_EOI 0x20 /* Timer IRQ End-Of-Interrupt Reg */
+#define DMTIMER_IRQSTATUS_RAW 0x24 /* Timer IRQSTATUS Raw Reg */
+#define DMTIMER_IRQSTATUS 0x28 /* Timer IRQSTATUS Reg */
+#define DMTIMER_IRQENABLE_SET 0x2c /* Timer IRQSTATUS Set Reg */
+#define DMTIMER_IRQENABLE_CLR 0x30 /* Timer IRQSTATUS Clear Reg */
+#define DMTIMER_IRQWAKEEN 0x34 /* Timer IRQ Wakeup Enable Reg */
+#define DMTIMER_TCLR 0x38 /* Timer Control Register */
+#define DMTIMER_TCRR 0x3C /* Timer Counter Register */
+#define DMTIMER_TLDR 0x40 /* Timer Load Reg */
+#define DMTIMER_TTGR 0x44 /* Timer Trigger Reg */
+#define DMTIMER_TWPS 0x48 /* Timer Write Posted Status Reg */
+#define DMTIMER_TMAR 0x4C /* Timer Match Reg */
+#define DMTIMER_TCAR1 0x50 /* Timer Capture Reg */
+#define DMTIMER_TSICR 0x54 /* Timer Synchr. Interface Control Reg */
+#define DMTIMER_TCAR2 0x48 /* Timer Capture Reg */
+
+
+struct am335x_dmtimer_softc {
+ struct resource * tmr_mem_res[AM335X_NUM_TIMERS];
+ struct resource * tmr_irq_res[AM335X_NUM_TIMERS];
+ uint32_t sysclk_freq;
+ struct am335x_dmtimer {
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
+ struct eventtimer et;
+ } t[AM335X_NUM_TIMERS];
+};
+
+static struct resource_spec am335x_dmtimer_mem_spec[] = {
+ { SYS_RES_MEMORY, 0, RF_ACTIVE },
+ { SYS_RES_MEMORY, 1, RF_ACTIVE },
+ { SYS_RES_MEMORY, 2, RF_ACTIVE },
+ { SYS_RES_MEMORY, 3, RF_ACTIVE },
+ { SYS_RES_MEMORY, 4, RF_ACTIVE },
+ { SYS_RES_MEMORY, 5, RF_ACTIVE },
+ { SYS_RES_MEMORY, 6, RF_ACTIVE },
+ { SYS_RES_MEMORY, 7, RF_ACTIVE },
+ { -1, 0, 0 }
+};
+static struct resource_spec am335x_dmtimer_irq_spec[] = {
+ { SYS_RES_IRQ, 0, RF_ACTIVE },
+ { SYS_RES_IRQ, 1, RF_ACTIVE },
+ { SYS_RES_IRQ, 2, RF_ACTIVE },
+ { SYS_RES_IRQ, 3, RF_ACTIVE },
+ { SYS_RES_IRQ, 4, RF_ACTIVE },
+ { SYS_RES_IRQ, 5, RF_ACTIVE },
+ { SYS_RES_IRQ, 6, RF_ACTIVE },
+ { SYS_RES_IRQ, 7, RF_ACTIVE },
+ { -1, 0, 0 }
+};
+
+static struct am335x_dmtimer *am335x_dmtimer_tc_tmr = NULL;
+
+/* Read/Write macros for Timer used as timecounter */
+#define am335x_dmtimer_tc_read_4(reg) \
+ bus_space_read_4(am335x_dmtimer_tc_tmr->bst, \
+ am335x_dmtimer_tc_tmr->bsh, reg)
+
+#define am335x_dmtimer_tc_write_4(reg, val) \
+ bus_space_write_4(am335x_dmtimer_tc_tmr->bst, \
+ am335x_dmtimer_tc_tmr->bsh, reg, val)
+
+/* Read/Write macros for Timer used as eventtimer */
+#define am335x_dmtimer_et_read_4(reg) \
+ bus_space_read_4(tmr->bst, tmr->bsh, reg)
+
+#define am335x_dmtimer_et_write_4(reg, val) \
+ bus_space_write_4(tmr->bst, tmr->bsh, reg, val)
+
+static unsigned am335x_dmtimer_tc_get_timecount(struct timecounter *);
+
+static struct timecounter am335x_dmtimer_tc = {
+ .tc_name = "AM335x Timecouter",
+ .tc_get_timecount = am335x_dmtimer_tc_get_timecount,
+ .tc_poll_pps = NULL,
+ .tc_counter_mask = ~0u,
+ .tc_frequency = 0,
+ .tc_quality = 1000,
+};
+
+static unsigned
+am335x_dmtimer_tc_get_timecount(struct timecounter *tc)
+{
+ return am335x_dmtimer_tc_read_4(DMTIMER_TCRR);
+}
+
+static int
+am335x_dmtimer_start(struct eventtimer *et, struct bintime *first,
+ struct bintime *period)
+{
+ struct am335x_dmtimer *tmr = (struct am335x_dmtimer *)et->et_priv;
+ uint32_t load, count;
+ uint32_t tclr = 0;
+
+ if (period != NULL) {
+ load = (et->et_frequency * (period->frac >> 32)) >> 32;
+ if (period->sec > 0)
+ load += et->et_frequency * period->sec;
+ tclr |= 2; /* autoreload bit */
+ panic("periodic timer not implemented\n");
+ } else {
+ load = 0;
+ }
+
+ if (first != NULL) {
+ count = (tmr->et.et_frequency * (first->frac >> 32)) >> 32;
+ if (first->sec != 0)
+ count += tmr->et.et_frequency * first->sec;
+ } else {
+ count = load;
+ }
+
+ /* Reset Timer */
+ am335x_dmtimer_et_write_4(DMTIMER_TSICR, 2);
+
+ /* Wait for reset to complete */
+ while (am335x_dmtimer_et_read_4(DMTIMER_TIOCP_CFG) & 1);
+
+ /* set load value */
+ am335x_dmtimer_et_write_4(DMTIMER_TLDR, 0xFFFFFFFE - load);
+
+ /* set counter value */
+ am335x_dmtimer_et_write_4(DMTIMER_TCRR, 0xFFFFFFFE - count);
+
+ /* enable overflow interrupt */
+ am335x_dmtimer_et_write_4(DMTIMER_IRQENABLE_SET, 2);
+
+ /* start timer(ST) */
+ tclr |= 1;
+ am335x_dmtimer_et_write_4(DMTIMER_TCLR, tclr);
+
+ return (0);
+}
+
+static int
+am335x_dmtimer_stop(struct eventtimer *et)
+{
+ struct am335x_dmtimer *tmr = (struct am335x_dmtimer *)et->et_priv;
+
+ /* Disable all interrupts */
+ am335x_dmtimer_et_write_4(DMTIMER_IRQENABLE_CLR, 7);
+
+ /* Stop Timer */
+ am335x_dmtimer_et_write_4(DMTIMER_TCLR, 0);
+
+ return (0);
+}
+
+static int
+am335x_dmtimer_intr(void *arg)
+{
+ struct am335x_dmtimer *tmr = (struct am335x_dmtimer *)arg;
+
+ /* Ack interrupt */
+ am335x_dmtimer_et_write_4(DMTIMER_IRQSTATUS, 7);
+ if (tmr->et.et_active)
+ tmr->et.et_event_cb(&tmr->et, tmr->et.et_arg);
+
+ return (FILTER_HANDLED);
+}
+
+static int
+am335x_dmtimer_probe(device_t dev)
+{
+ struct am335x_dmtimer_softc *sc;
+ sc = (struct am335x_dmtimer_softc *)device_get_softc(dev);
+
+ if (ofw_bus_is_compatible(dev, "ti,am335x-dmtimer")) {
+ device_set_desc(dev, "AM335x DMTimer");
+ return(BUS_PROBE_DEFAULT);
+ }
+
+ return (ENXIO);
+}
+
+static int
+am335x_dmtimer_attach(device_t dev)
+{
+ struct am335x_dmtimer_softc *sc = device_get_softc(dev);
+ void *ihl;
+ int err;
+ int i;
+
+ if (am335x_dmtimer_tc_tmr != NULL)
+ return (EINVAL);
+
+ /* Get the base clock frequency */
+ err = ti_prcm_clk_get_source_freq(SYS_CLK, &sc->sysclk_freq);
+ if (err) {
+ device_printf(dev, "Error: could not get sysclk frequency\n");
+ return (ENXIO);
+ }
+
+ /* Request the memory resources */
+ err = bus_alloc_resources(dev, am335x_dmtimer_mem_spec,
+ sc->tmr_mem_res);
+ if (err) {
+ device_printf(dev, "Error: could not allocate mem resources\n");
+ return (ENXIO);
+ }
+
+ /* Request the IRQ resources */
+ err = bus_alloc_resources(dev, am335x_dmtimer_irq_spec,
+ sc->tmr_irq_res);
+ if (err) {
+ device_printf(dev, "Error: could not allocate irq resources\n");
+ return (ENXIO);
+ }
+
+ for(i=0;i<AM335X_NUM_TIMERS;i++) {
+ sc->t[i].bst = rman_get_bustag(sc->tmr_mem_res[i]);
+ sc->t[i].bsh = rman_get_bushandle(sc->tmr_mem_res[i]);
+ }
+
+ /* Configure DMTimer2 and DMTimer3 source and enable them */
+ err = ti_prcm_clk_set_source(DMTIMER2_CLK, SYSCLK_CLK);
+ err |= ti_prcm_clk_enable(DMTIMER2_CLK);
+ err |= ti_prcm_clk_set_source(DMTIMER3_CLK, SYSCLK_CLK);
+ err |= ti_prcm_clk_enable(DMTIMER3_CLK);
+ if (err) {
+ device_printf(dev, "Error: could not setup timer clock\n");
+ return (ENXIO);
+ }
+
+ /* Take DMTimer2 for TC */
+ am335x_dmtimer_tc_tmr = &sc->t[2];
+
+ /* Reset Timer */
+ am335x_dmtimer_tc_write_4(DMTIMER_TSICR, 2);
+
+ /* Wait for reset to complete */
+ while (am335x_dmtimer_tc_read_4(DMTIMER_TIOCP_CFG) & 1);
+
+ /* set load value */
+ am335x_dmtimer_tc_write_4(DMTIMER_TLDR, 0);
+
+ /* set counter value */
+ am335x_dmtimer_tc_write_4(DMTIMER_TCRR, 0);
+
+ /* Set Timer autoreload(AR) and start timer(ST) */
+ am335x_dmtimer_tc_write_4(DMTIMER_TCLR, 3);
+
+ am335x_dmtimer_tc.tc_frequency = sc->sysclk_freq;
+ tc_init(&am335x_dmtimer_tc);
+
+ /* Register DMTimer3 as ET */
+
+ /* Setup and enable the timer */
+ if (bus_setup_intr(dev, sc->tmr_irq_res[3], INTR_TYPE_CLK,
+ am335x_dmtimer_intr, NULL, &sc->t[3], &ihl) != 0) {
+ bus_release_resources(dev, am335x_dmtimer_irq_spec,
+ sc->tmr_irq_res);
+ device_printf(dev, "Unable to setup the clock irq handler.\n");
+ return (ENXIO);
+ }
+
+ sc->t[3].et.et_name = "AM335x Eventtimer0";
+ sc->t[3].et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT;
+ sc->t[3].et.et_quality = 1000;
+ sc->t[3].et.et_frequency = sc->sysclk_freq;
+ sc->t[3].et.et_min_period.sec = 0;
+ sc->t[3].et.et_min_period.frac =
+ ((0x00000002LLU << 32) / sc->t[3].et.et_frequency) << 32;
+ sc->t[3].et.et_max_period.sec = 0xfffffff0U / sc->t[3].et.et_frequency;
+ sc->t[3].et.et_max_period.frac =
+ ((0xfffffffeLLU << 32) / sc->t[3].et.et_frequency) << 32;
+ sc->t[3].et.et_start = am335x_dmtimer_start;
+ sc->t[3].et.et_stop = am335x_dmtimer_stop;
+ sc->t[3].et.et_priv = &sc->t[3];
+ et_register(&sc->t[3].et);
+
+ return (0);
+}
+
+static device_method_t am335x_dmtimer_methods[] = {
+ DEVMETHOD(device_probe, am335x_dmtimer_probe),
+ DEVMETHOD(device_attach, am335x_dmtimer_attach),
+ { 0, 0 }
+};
+
+static driver_t am335x_dmtimer_driver = {
+ "am335x_dmtimer",
+ am335x_dmtimer_methods,
+ sizeof(struct am335x_dmtimer_softc),
+};
+
+static devclass_t am335x_dmtimer_devclass;
+
+DRIVER_MODULE(am335x_dmtimer, simplebus, am335x_dmtimer_driver, am335x_dmtimer_devclass, 0, 0);
+MODULE_DEPEND(am335x_dmtimer, am335x_prcm, 1, 1, 1);
+
+void
+cpu_initclocks(void)
+{
+ cpu_initclocks_bsp();
+}
+
+void
+DELAY(int usec)
+{
+ int32_t counts;
+ uint32_t first, last;
+
+ if (am335x_dmtimer_tc_tmr == NULL) {
+ for (; usec > 0; usec--)
+ for (counts = 200; counts > 0; counts--)
+ /* Prevent gcc from optimizing out the loop */
+ cpufunc_nullop();
+ return;
+ }
+
+ /* Get the number of times to count */
+ counts = usec * ((am335x_dmtimer_tc.tc_frequency / 1000000) + 1);;
+
+ first = am335x_dmtimer_tc_read_4(DMTIMER_TCRR);
+
+ while (counts > 0) {
+ last = am335x_dmtimer_tc_read_4(DMTIMER_TCRR);
+ if (last>first) {
+ counts -= (int32_t)(last - first);
+ } else {
+ counts -= (int32_t)((0xFFFFFFFF - first) + last);
+ }
+ first = last;
+ }
+}
+
Added: head/sys/arm/ti/am335x/am335x_pmic.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/arm/ti/am335x/am335x_pmic.c Wed Aug 15 06:31:32 2012 (r239281)
@@ -0,0 +1,176 @@
+/*-
+ * Copyright (c) 2012 Damjan Marion <dmarion at Freebsd.org>
+ * 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 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 AUTHOR 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>
+__FBSDID("$FreeBSD$");
+/*
+* TPS65217 PMIC companion chip for AM335x SoC sitting on I2C bus
+*/
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/clock.h>
+#include <sys/time.h>
+#include <sys/bus.h>
+#include <sys/resource.h>
+#include <sys/rman.h>
+
+#include <dev/iicbus/iicbus.h>
+#include <dev/iicbus/iiconf.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "iicbus_if.h"
+
+#define TPS65217A 0x7
+#define TPS65217B 0xF
+
+/* TPS65217 Reisters */
+#define TPS65217_CHIPID_REG 0x00
+#define TPS65217_STATUS_REG 0x0A
+
+#define MAX_IIC_DATA_SIZE 2
+
+
+struct am335x_pmic_softc {
+ device_t sc_dev;
+ uint32_t sc_addr;
+ struct intr_config_hook enum_hook;
+};
+
+static int
+am335x_pmic_read(device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
+{
+ struct am335x_pmic_softc *sc = device_get_softc(dev);
+ struct iic_msg msg[] = {
+ { sc->sc_addr, IIC_M_WR, 1, &addr },
+ { sc->sc_addr, IIC_M_RD, size, data },
+ };
+ return (iicbus_transfer(dev, msg, 2));
+}
+
+#ifdef notyet
+static int
+am335x_pmic_write(device_t dev, uint8_t address, uint8_t *data, uint8_t size)
+{
+ uint8_t buffer[MAX_IIC_DATA_SIZE + 1];
+ struct am335x_pmic_softc *sc = device_get_softc(dev);
+ struct iic_msg msg[] = {
+ { sc->sc_addr, IIC_M_WR, size + 1, buffer },
+ };
+
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-head
mailing list