Create root DMA tag and fix MBUS windows on DMA coherent platforms
Armada 38x SoCs, in order to work properly in IO-coherent mode, requires an update of the MBUS windows attributesd. This patch also configures nexus coherent dma tag, because all busses and children devices have to inherit this setting in runtime. The latter has to be executed as a sysinit (SI_SUB_DRIVERS type), so that bus_dma_tag_create() can be executed properly. Submitted by: Michal Mazur <mkm@semihalf.com> Marcin Wojtas <mw@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Reviewed by: ian Differential revision: https://reviews.freebsd.org/D11203
This commit is contained in:
parent
474612c372
commit
3361fdc431
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=320199
@ -128,6 +128,7 @@ static uint32_t dev_mask = 0;
|
||||
static int cpu_wins_no = 0;
|
||||
static int eth_port = 0;
|
||||
static int usb_port = 0;
|
||||
static boolean_t platform_io_coherent = false;
|
||||
|
||||
static struct decode_win cpu_win_tbl[MAX_CPU_WIN];
|
||||
|
||||
@ -1064,7 +1065,7 @@ ddr_size(int i)
|
||||
uint32_t
|
||||
ddr_attr(int i)
|
||||
{
|
||||
uint32_t dev, rev;
|
||||
uint32_t dev, rev, attr;
|
||||
|
||||
soc_id(&dev, &rev);
|
||||
if (dev == MV_DEV_88RC8180)
|
||||
@ -1072,10 +1073,14 @@ ddr_attr(int i)
|
||||
if (dev == MV_DEV_88F6781)
|
||||
return (0);
|
||||
|
||||
return (i == 0 ? 0xe :
|
||||
attr = (i == 0 ? 0xe :
|
||||
(i == 1 ? 0xd :
|
||||
(i == 2 ? 0xb :
|
||||
(i == 3 ? 0x7 : 0xff))));
|
||||
if (platform_io_coherent)
|
||||
attr |= 0x10;
|
||||
|
||||
return (attr);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@ -2479,6 +2484,10 @@ fdt_win_setup(void)
|
||||
if (node == -1)
|
||||
panic("fdt_win_setup: no root node");
|
||||
|
||||
/* Allow for coherent transactions on the A38x MBUS */
|
||||
if (ofw_bus_node_is_compatible(node, "marvell,armada380"))
|
||||
platform_io_coherent = true;
|
||||
|
||||
/*
|
||||
* Traverse through all children of root and simple-bus nodes.
|
||||
* For each found device retrieve decode windows data (if applicable).
|
||||
|
@ -46,10 +46,13 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/devmap.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
|
||||
#include <arm/arm/nexusvar.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/fdt.h>
|
||||
#include <machine/machdep.h>
|
||||
@ -87,6 +90,39 @@ int armada38x_mbus_optimization(void);
|
||||
#define MPP_SEL(pin,func) (((func) & 0xf) << \
|
||||
(((pin) % MPP_PINS_PER_REG) * 4))
|
||||
|
||||
static void
|
||||
mv_busdma_tag_init(void *arg __unused)
|
||||
{
|
||||
phandle_t node;
|
||||
bus_dma_tag_t dmat;
|
||||
|
||||
/*
|
||||
* If this platform has coherent DMA, create the parent DMA tag to pass
|
||||
* down the coherent flag to all busses and devices on the platform,
|
||||
* otherwise return without doing anything. By default create tag
|
||||
* for all A38x-based platforms only.
|
||||
*/
|
||||
if ((node = OF_finddevice("/")) == -1)
|
||||
return;
|
||||
if (ofw_bus_node_is_compatible(node, "marvell,armada380") == 0)
|
||||
return;
|
||||
|
||||
bus_dma_tag_create(NULL, /* No parent tag */
|
||||
1, 0, /* alignment, bounds */
|
||||
BUS_SPACE_MAXADDR, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
NULL, NULL, /* filter, filterarg */
|
||||
BUS_SPACE_MAXSIZE, /* maxsize */
|
||||
BUS_SPACE_UNRESTRICTED, /* nsegments */
|
||||
BUS_SPACE_MAXSIZE, /* maxsegsize */
|
||||
BUS_DMA_COHERENT, /* flags */
|
||||
NULL, NULL, /* lockfunc, lockarg */
|
||||
&dmat);
|
||||
|
||||
nexus_set_dma_tag(dmat);
|
||||
}
|
||||
SYSINIT(mv_busdma_tag, SI_SUB_DRIVERS, SI_ORDER_ANY, mv_busdma_tag_init, NULL);
|
||||
|
||||
static int
|
||||
platform_mpp_init(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user