Don't assume we're running on a pandaboard if the pandaboard-specific

code is compiled in, use FDT to detect it instead.
This commit is contained in:
Olivier Houchard 2016-11-19 00:55:46 +00:00
parent 31a2ddf253
commit 8917c565bd
7 changed files with 52 additions and 46 deletions

View file

@ -28,7 +28,7 @@ ident PANDABOARD
hints "PANDABOARD.hints"
include "std.armv6"
include "../ti/omap4/pandaboard/std.pandaboard"
include "../ti/omap4/std.omap4"
makeoptions MODULES_EXTRA=dtb/omap4

View file

@ -14,6 +14,8 @@ arm/ti/omap4/omap4_scm_padconf.c standard
arm/ti/omap4/omap4_mp.c optional smp
arm/ti/omap4/omap4_wugen.c standard
arm/ti/omap4/pandaboard/pandaboard.c standard
arm/ti/twl/twl.c optional twl
arm/ti/twl/twl_vreg.c optional twl twl_vreg
arm/ti/twl/twl_clks.c optional twl twl_clks

View file

@ -1,3 +0,0 @@
# $FreeBSD$
arm/ti/omap4/pandaboard/pandaboard.c standard

View file

@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <machine/fdt.h>
#include <arm/ti/omap4/omap4_reg.h>
#include <arm/ti/omap4/pandaboard/pandaboard.h>
/* Registers in the SCRM that control the AUX clocks */
#define SCRM_ALTCLKSRC (0x110)
@ -111,8 +112,8 @@ __FBSDID("$FreeBSD$");
* RETURNS:
* nothing.
*/
static void
usb_hub_init(void)
void
pandaboard_usb_hub_init(void)
{
bus_space_handle_t scrm_addr, gpio1_addr, gpio2_addr, scm_addr;
@ -169,39 +170,3 @@ usb_hub_init(void)
bus_space_unmap(fdtbus_bs_tag, gpio2_addr, OMAP44XX_GPIO2_SIZE);
bus_space_unmap(fdtbus_bs_tag, scm_addr, OMAP44XX_SCM_PADCONF_SIZE);
}
/**
* board_init - initialises the pandaboard
* @dummy: ignored
*
* This function is called before any of the driver are initialised, which is
* annoying because it means we can't use the SCM, PRCM and GPIO modules which
* would really be useful.
*
* So we don't have:
* - any drivers
* - no interrupts
*
* What we do have:
* - virt/phys mappings from the devmap (see omap4.c)
* -
*
*
* So we are hamstrung without the useful drivers and we have to go back to
* direct register manupulation. Luckly we don't have to do to much, basically
* just setup the usb hub/ethernet.
*
*/
static void
board_init(void *dummy)
{
/* Initialise the USB phy and hub */
usb_hub_init();
/*
* XXX Board identification e.g. read out from FPGA or similar should
* go here
*/
}
SYSINIT(board_init, SI_SUB_CPU, SI_ORDER_THIRD, board_init, NULL);

View file

@ -0,0 +1,32 @@
/*-
* Copyright (c) 2016 Olivier Houchard <cognet@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 ``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.
*
* $FreeBSD$
*/
#ifndef _PANDABOARD_H_
#define _PANDABOARD_H_
void pandaboard_usb_hub_init(void);
#endif /* _OMAP4_MP_H_ */

View file

@ -1,4 +0,0 @@
# $FreeBSD$
include "../ti/omap4/std.omap4"
files "../ti/omap4/pandaboard/files.pandaboard"

View file

@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/condvar.h>
#include <dev/fdt/simplebus.h>
#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/usb/usb.h>
@ -57,6 +58,8 @@ __FBSDID("$FreeBSD$");
#include <arm/ti/ti_prcm.h>
#include <arm/ti/usb/omap_usb.h>
#include <arm/ti/omap4/pandaboard/pandaboard.h>
/* EHCI */
#define OMAP_USBHOST_HCCAPBASE 0x0000
#define OMAP_USBHOST_HCSPARAMS 0x0004
@ -258,6 +261,7 @@ omap_ehci_init(struct omap_ehci_softc *isc)
static int
omap_ehci_probe(device_t dev)
{
phandle_t root;
if (!ofw_bus_status_okay(dev))
return (ENXIO);
@ -265,6 +269,16 @@ omap_ehci_probe(device_t dev)
if (!ofw_bus_is_compatible(dev, "ti,ehci-omap"))
return (ENXIO);
#ifdef SOC_OMAP4
/*
* If we're running a Pandaboard, run Pandaboard-specific
* init code.
*/
root = OF_finddevice("/");
if (fdt_is_compatible(root, "ti,omap4-panda"))
pandaboard_usb_hub_init();
#endif
device_set_desc(dev, OMAP_EHCI_HC_DEVSTR);
return (BUS_PROBE_DEFAULT);