aboutsummaryrefslogtreecommitdiff
path: root/sys/arm/broadcom
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arm/broadcom')
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_bsc.c2
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c22
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_intr.c3
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_machdep.c28
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_spi.c2
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_systimer.c309
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2836.c5
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2838_pci.c2
-rw-r--r--sys/arm/broadcom/bcm2835/files.bcm28352
-rw-r--r--sys/arm/broadcom/bcm2835/std.bcm28359
10 files changed, 8 insertions, 376 deletions
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_bsc.c b/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
index 7d14a5c26c4d..6a9853a7b4f9 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
@@ -342,7 +342,7 @@ bcm_bsc_attach(device_t dev)
bcm_bsc_reset(sc);
BCM_BSC_UNLOCK(sc);
- sc->sc_iicbus = device_add_child(dev, "iicbus", -1);
+ sc->sc_iicbus = device_add_child(dev, "iicbus", DEVICE_UNIT_ANY);
if (sc->sc_iicbus == NULL) {
bcm_bsc_detach(dev);
return (ENXIO);
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c b/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
index 56227f948e98..3ef564c6ae13 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
@@ -61,17 +61,10 @@
#define HZ2MHZ(freq) ((freq) / (1000 * 1000))
#define MHZ2HZ(freq) ((freq) * (1000 * 1000))
-#ifdef SOC_BCM2835
-#define OFFSET2MVOLT(val) (1200 + ((val) * 25))
-#define MVOLT2OFFSET(val) (((val) - 1200) / 25)
-#define DEFAULT_ARM_FREQUENCY 700
-#define DEFAULT_LOWEST_FREQ 300
-#else
#define OFFSET2MVOLT(val) (((val) / 1000))
#define MVOLT2OFFSET(val) (((val) * 1000))
#define DEFAULT_ARM_FREQUENCY 600
#define DEFAULT_LOWEST_FREQ 600
-#endif
#define DEFAULT_CORE_FREQUENCY 250
#define DEFAULT_SDRAM_FREQUENCY 400
#define TRANSITION_LATENCY 1000
@@ -1507,20 +1500,6 @@ bcm2835_cpufreq_make_freq_list(device_t dev, struct cf_setting *sets,
if (min_freq > cpufreq_lowest_freq)
min_freq = cpufreq_lowest_freq;
-#ifdef SOC_BCM2835
- /* from freq to min_freq */
- for (idx = 0; idx < *count && freq >= min_freq; idx++) {
- if (freq > sc->arm_min_freq)
- volts = sc->max_voltage_core;
- else
- volts = sc->min_voltage_core;
- sets[idx].freq = freq;
- sets[idx].volts = volts;
- sets[idx].lat = TRANSITION_LATENCY;
- sets[idx].dev = dev;
- freq -= MHZSTEP;
- }
-#else
/* XXX RPi2 have only 900/600MHz */
idx = 0;
volts = sc->min_voltage_core;
@@ -1536,7 +1515,6 @@ bcm2835_cpufreq_make_freq_list(device_t dev, struct cf_setting *sets,
sets[idx].dev = dev;
idx++;
}
-#endif
*count = idx;
return (0);
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_intr.c b/sys/arm/broadcom/bcm2835/bcm2835_intr.c
index 5a8457bc4b67..65ada57c0b60 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_intr.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_intr.c
@@ -405,7 +405,8 @@ bcm_intc_attach(device_t dev)
sc->intc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
RF_ACTIVE);
if (sc->intc_irq_res == NULL) {
- if (intr_pic_claim_root(dev, xref, bcm2835_intc_intr, sc) != 0) {
+ if (intr_pic_claim_root(dev, xref, bcm2835_intc_intr, sc, INTR_ROOT_IRQ)
+ != 0) {
/* XXX clean up */
device_printf(dev, "could not set PIC as a root\n");
return (ENXIO);
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
index eabbc371bb19..be6b8971437d 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
@@ -61,9 +61,6 @@
#include "platform_if.h"
-#ifdef SOC_BCM2835
-static platform_devmap_init_t bcm2835_devmap_init;
-#endif
#ifdef SOC_BCM2836
static platform_devmap_init_t bcm2836_devmap_init;
#endif
@@ -91,20 +88,6 @@ bcm2835_late_init(platform_t plat)
}
}
-#ifdef SOC_BCM2835
-/*
- * Set up static device mappings.
- * All on-chip peripherals exist in a 16MB range starting at 0x20000000.
- * Map the entire range using 1MB section mappings.
- */
-static int
-bcm2835_devmap_init(platform_t plat)
-{
-
- devmap_add_entry(0x20000000, 0x01000000);
- return (0);
-}
-#endif
#ifdef SOC_BCM2836
static int
@@ -122,17 +105,6 @@ bcm2835_cpu_reset(platform_t plat)
bcmwd_watchdog_reset();
}
-#ifdef SOC_BCM2835
-static platform_method_t bcm2835_methods[] = {
- PLATFORMMETHOD(platform_devmap_init, bcm2835_devmap_init),
- PLATFORMMETHOD(platform_late_init, bcm2835_late_init),
- PLATFORMMETHOD(platform_cpu_reset, bcm2835_cpu_reset),
-
- PLATFORMMETHOD_END,
-};
-FDT_PLATFORM_DEF2(bcm2835, bcm2835_legacy, "bcm2835 (legacy)", 0, "raspberrypi,model-b", 100);
-FDT_PLATFORM_DEF2(bcm2835, bcm2835, "bcm2835", 0, "brcm,bcm2835", 100);
-#endif
#if defined(SOC_BCM2836) || defined(SOC_BRCM_BCM2837)
static platform_method_t bcm2836_methods[] = {
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_spi.c b/sys/arm/broadcom/bcm2835/bcm2835_spi.c
index fc488e349157..17419be0c8a7 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_spi.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_spi.c
@@ -298,7 +298,7 @@ bcm_spi_attach(device_t dev)
bcm_spi_printr(dev);
#endif
- device_add_child(dev, "spibus", -1);
+ device_add_child(dev, "spibus", DEVICE_UNIT_ANY);
return (bus_generic_attach(dev));
}
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_systimer.c b/sys/arm/broadcom/bcm2835/bcm2835_systimer.c
deleted file mode 100644
index 33775d0a2935..000000000000
--- a/sys/arm/broadcom/bcm2835/bcm2835_systimer.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
- * Copyright (c) 2012 Damjan Marion <dmarion@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/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/intr.h>
-#include <machine/machdep.h>
-
-#include <dev/ofw/openfirm.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <machine/bus.h>
-
-#define BCM2835_NUM_TIMERS 4
-
-#define DEFAULT_TIMER 3
-#define DEFAULT_TIMER_NAME "BCM2835-3"
-#define DEFAULT_FREQUENCY 1000000
-#define MIN_PERIOD 5LLU
-
-#define SYSTIMER_CS 0x00
-#define SYSTIMER_CLO 0x04
-#define SYSTIMER_CHI 0x08
-#define SYSTIMER_C0 0x0C
-#define SYSTIMER_C1 0x10
-#define SYSTIMER_C2 0x14
-#define SYSTIMER_C3 0x18
-
-struct systimer {
- int index;
- bool enabled;
- struct eventtimer et;
-};
-
-struct bcm_systimer_softc {
- struct resource* mem_res;
- struct resource* irq_res[BCM2835_NUM_TIMERS];
- void* intr_hl[BCM2835_NUM_TIMERS];
- uint32_t sysclk_freq;
- bus_space_tag_t bst;
- bus_space_handle_t bsh;
- struct systimer st[BCM2835_NUM_TIMERS];
-};
-
-static struct resource_spec bcm_systimer_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 },
- { -1, 0, 0 }
-};
-
-static struct ofw_compat_data compat_data[] = {
- {"broadcom,bcm2835-system-timer", 1},
- {"brcm,bcm2835-system-timer", 1},
- {NULL, 0}
-};
-
-static struct bcm_systimer_softc *bcm_systimer_sc = NULL;
-
-/* Read/Write macros for Timer used as timecounter */
-#define bcm_systimer_tc_read_4(reg) \
- bus_space_read_4(bcm_systimer_sc->bst, \
- bcm_systimer_sc->bsh, reg)
-
-#define bcm_systimer_tc_write_4(reg, val) \
- bus_space_write_4(bcm_systimer_sc->bst, \
- bcm_systimer_sc->bsh, reg, val)
-
-static unsigned bcm_systimer_tc_get_timecount(struct timecounter *);
-
-static delay_func bcm_systimer_delay;
-
-static struct timecounter bcm_systimer_tc = {
- .tc_name = DEFAULT_TIMER_NAME,
- .tc_get_timecount = bcm_systimer_tc_get_timecount,
- .tc_poll_pps = NULL,
- .tc_counter_mask = ~0u,
- .tc_frequency = 0,
- .tc_quality = 1000,
-};
-
-static unsigned
-bcm_systimer_tc_get_timecount(struct timecounter *tc)
-{
- if (bcm_systimer_sc == NULL)
- return (0);
-
- return bcm_systimer_tc_read_4(SYSTIMER_CLO);
-}
-
-static int
-bcm_systimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
-{
- struct systimer *st = et->et_priv;
- uint32_t clo, clo1;
- uint32_t count;
- register_t s;
-
- if (first != 0) {
- count = ((uint32_t)et->et_frequency * first) >> 32;
-
- s = intr_disable();
- clo = bcm_systimer_tc_read_4(SYSTIMER_CLO);
-restart:
- clo += count;
- /*
- * Clear pending interrupts
- */
- bcm_systimer_tc_write_4(SYSTIMER_CS, (1 << st->index));
- bcm_systimer_tc_write_4(SYSTIMER_C0 + st->index*4, clo);
- clo1 = bcm_systimer_tc_read_4(SYSTIMER_CLO);
- if ((int32_t)(clo1 - clo) >= 0) {
- count *= 2;
- clo = clo1;
- goto restart;
- }
- st->enabled = 1;
- intr_restore(s);
-
- return (0);
- }
-
- return (EINVAL);
-}
-
-static int
-bcm_systimer_stop(struct eventtimer *et)
-{
- struct systimer *st = et->et_priv;
- st->enabled = 0;
-
- return (0);
-}
-
-static int
-bcm_systimer_intr(void *arg)
-{
- struct systimer *st = (struct systimer *)arg;
- uint32_t cs;
-
- cs = bcm_systimer_tc_read_4(SYSTIMER_CS);
- if ((cs & (1 << st->index)) == 0)
- return (FILTER_STRAY);
-
- /* ACK interrupt */
- bcm_systimer_tc_write_4(SYSTIMER_CS, (1 << st->index));
- if (st->enabled) {
- if (st->et.et_active) {
- st->et.et_event_cb(&st->et, st->et.et_arg);
- }
- }
-
- return (FILTER_HANDLED);
-}
-
-static int
-bcm_systimer_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
- return (ENXIO);
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-bcm_systimer_attach(device_t dev)
-{
- struct bcm_systimer_softc *sc = device_get_softc(dev);
- int err;
- int rid = 0;
-
- if (bcm_systimer_sc != NULL)
- return (EINVAL);
-
- sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
- if (sc->mem_res == NULL) {
- device_printf(dev, "could not allocate memory resource\n");
- return (ENXIO);
- }
-
- sc->bst = rman_get_bustag(sc->mem_res);
- sc->bsh = rman_get_bushandle(sc->mem_res);
-
- /* Request the IRQ resources */
- err = bus_alloc_resources(dev, bcm_systimer_irq_spec,
- sc->irq_res);
- if (err) {
- device_printf(dev, "Error: could not allocate irq resources\n");
- return (ENXIO);
- }
-
- /* TODO: get frequency from FDT */
- sc->sysclk_freq = DEFAULT_FREQUENCY;
-
- /* Setup and enable the timer */
- if (bus_setup_intr(dev, sc->irq_res[DEFAULT_TIMER], INTR_TYPE_CLK,
- bcm_systimer_intr, NULL, &sc->st[DEFAULT_TIMER],
- &sc->intr_hl[DEFAULT_TIMER]) != 0) {
- bus_release_resources(dev, bcm_systimer_irq_spec,
- sc->irq_res);
- device_printf(dev, "Unable to setup the clock irq handler.\n");
- return (ENXIO);
- }
-
- sc->st[DEFAULT_TIMER].index = DEFAULT_TIMER;
- sc->st[DEFAULT_TIMER].enabled = 0;
- sc->st[DEFAULT_TIMER].et.et_name = DEFAULT_TIMER_NAME;
- sc->st[DEFAULT_TIMER].et.et_flags = ET_FLAGS_ONESHOT;
- sc->st[DEFAULT_TIMER].et.et_quality = 1000;
- sc->st[DEFAULT_TIMER].et.et_frequency = sc->sysclk_freq;
- sc->st[DEFAULT_TIMER].et.et_min_period =
- (MIN_PERIOD << 32) / sc->st[DEFAULT_TIMER].et.et_frequency + 1;
- sc->st[DEFAULT_TIMER].et.et_max_period =
- (0x7ffffffeLLU << 32) / sc->st[DEFAULT_TIMER].et.et_frequency;
- sc->st[DEFAULT_TIMER].et.et_start = bcm_systimer_start;
- sc->st[DEFAULT_TIMER].et.et_stop = bcm_systimer_stop;
- sc->st[DEFAULT_TIMER].et.et_priv = &sc->st[DEFAULT_TIMER];
- et_register(&sc->st[DEFAULT_TIMER].et);
-
- bcm_systimer_sc = sc;
-
- if (device_get_unit(dev) == 0)
- arm_set_delay(bcm_systimer_delay, sc);
-
- bcm_systimer_tc.tc_frequency = DEFAULT_FREQUENCY;
- tc_init(&bcm_systimer_tc);
-
- return (0);
-}
-
-static device_method_t bcm_systimer_methods[] = {
- DEVMETHOD(device_probe, bcm_systimer_probe),
- DEVMETHOD(device_attach, bcm_systimer_attach),
- { 0, 0 }
-};
-
-static driver_t bcm_systimer_driver = {
- "systimer",
- bcm_systimer_methods,
- sizeof(struct bcm_systimer_softc),
-};
-
-DRIVER_MODULE(bcm_systimer, simplebus, bcm_systimer_driver, 0, 0);
-
-static void
-bcm_systimer_delay(int usec, void *arg)
-{
- int32_t counts;
- uint32_t first, last;
-
- /* Get the number of times to count */
- counts = usec * (bcm_systimer_tc.tc_frequency / 1000000) + 1;
-
- first = bcm_systimer_tc_read_4(SYSTIMER_CLO);
-
- while (counts > 0) {
- last = bcm_systimer_tc_read_4(SYSTIMER_CLO);
- if (last == first)
- continue;
- if (last>first) {
- counts -= (int32_t)(last - first);
- } else {
- counts -= (int32_t)((0xFFFFFFFF - first) + last);
- }
- first = last;
- }
-}
diff --git a/sys/arm/broadcom/bcm2835/bcm2836.c b/sys/arm/broadcom/bcm2835/bcm2836.c
index 8ff824d34521..7ed9dedaa77e 100644
--- a/sys/arm/broadcom/bcm2835/bcm2836.c
+++ b/sys/arm/broadcom/bcm2835/bcm2836.c
@@ -538,7 +538,7 @@ bcm_lintc_init_pmu_on_ap(struct bcm_lintc_softc *sc, u_int cpu)
}
static void
-bcm_lintc_init_secondary(device_t dev)
+bcm_lintc_init_secondary(device_t dev, uint32_t rootnum)
{
u_int cpu;
struct bcm_lintc_softc *sc;
@@ -646,7 +646,8 @@ bcm_lintc_pic_attach(struct bcm_lintc_softc *sc)
if (pic == NULL)
return (ENXIO);
- error = intr_pic_claim_root(sc->bls_dev, xref, bcm_lintc_intr, sc);
+ error = intr_pic_claim_root(sc->bls_dev, xref, bcm_lintc_intr, sc,
+ INTR_ROOT_IRQ);
if (error != 0)
return (error);
diff --git a/sys/arm/broadcom/bcm2835/bcm2838_pci.c b/sys/arm/broadcom/bcm2835/bcm2838_pci.c
index f5304525a6fb..0f41dcff37ca 100644
--- a/sys/arm/broadcom/bcm2835/bcm2838_pci.c
+++ b/sys/arm/broadcom/bcm2835/bcm2838_pci.c
@@ -744,7 +744,7 @@ bcm_pcib_attach(device_t dev)
return (error);
/* Done. */
- device_add_child(dev, "pci", -1);
+ device_add_child(dev, "pci", DEVICE_UNIT_ANY);
return (bus_generic_attach(dev));
}
diff --git a/sys/arm/broadcom/bcm2835/files.bcm2835 b/sys/arm/broadcom/bcm2835/files.bcm2835
deleted file mode 100644
index fda25115b8d5..000000000000
--- a/sys/arm/broadcom/bcm2835/files.bcm2835
+++ /dev/null
@@ -1,2 +0,0 @@
-
-arm/broadcom/bcm2835/bcm2835_systimer.c standard
diff --git a/sys/arm/broadcom/bcm2835/std.bcm2835 b/sys/arm/broadcom/bcm2835/std.bcm2835
deleted file mode 100644
index 4bb1000d0da1..000000000000
--- a/sys/arm/broadcom/bcm2835/std.bcm2835
+++ /dev/null
@@ -1,9 +0,0 @@
-
-machine arm armv6
-cpu CPU_ARM1176
-makeoptions CONF_CFLAGS="-mcpu=arm1176jzf-s"
-options SOC_BCM2835
-
-files "../broadcom/bcm2835/files.bcm2835"
-files "../broadcom/bcm2835/files.bcm283x"
-