FreeBSD/sys/dev/cesa/cesa.c
/*
 * Set CESA TDMA decode windows.
 */
Set CESA TDMA decode windows.
Set CESA TDMA decode windows .
static int
decode_win_cesa_setup(struct cesa_softc *sc)
{
	struct mem_region availmem_regions[FDT_MEM_REGIONS];
	int availmem_regions_sz;
	uint32_t br, cr, i;
	if (fdt_get_mem_regions(availmem_regions, &availmem_regions_sz,
	    NULL) != 0)
		return (ENXIO);
	if (availmem_regions_sz > MV_WIN_CESA_MAX) {
		device_printf(sc->sc_dev, "Too much memory regions, cannot "
		    " set CESA windows to cover whole DRAM \n");
		return (ENXIO);
	}
	for (i = 0; i < MV_WIN_CESA_MAX; i++) {
		CESA_TDMA_WRITE(sc, MV_WIN_CESA_BASE(i), 0);
		CESA_TDMA_WRITE(sc, MV_WIN_CESA_CTRL(i), 0);
	}
	for (i = 0; i < availmem_regions_sz; i++) {
		br = availmem_regions[i].mr_start;
		cr = availmem_regions[i].mr_size;
		if (cr & 0xffff0000) {
			cr = (((cr - 1) & 0xffff0000) |
			(MV_WIN_DDR_ATTR(i) << MV_WIN_CPU_ATTR_SHIFT) |
			    (MV_WIN_DDR_TARGET << MV_WIN_CPU_TARGET_SHIFT) |
			    MV_WIN_CPU_ENABLE_BIT);
			CESA_TDMA_WRITE(sc, MV_WIN_CESA_BASE(i), br);
			CESA_TDMA_WRITE(sc, MV_WIN_CESA_CTRL(i), cr);
		}
	}
	return (0);
}
static int decode_win_cesa_setup ( struct cesa_softc * sc ) { struct mem_region availmem_regions [ FDT_MEM_REGIONS ] ; int availmem_regions_sz ; uint32_t br , cr , i ; if ( fdt_get_mem_regions ( availmem_regions , & availmem_regions_sz , NULL ) != 0 ) return ( ENXIO ) ; if ( availmem_regions_sz > MV_WIN_CESA_MAX ) { device_printf ( sc -> sc_dev , " " " \n " ) ; return ( ENXIO ) ; } for ( i = 0 ; i < MV_WIN_CESA_MAX ; i ++ ) { CESA_TDMA_WRITE ( sc , MV_WIN_CESA_BASE ( i ) , 0 ) ; CESA_TDMA_WRITE ( sc , MV_WIN_CESA_CTRL ( i ) , 0 ) ; } for ( i = 0 ; i < availmem_regions_sz ; i ++ ) { br = availmem_regions [ i ] . mr_start ; cr = availmem_regions [ i ] . mr_size ; if ( cr & 0xffff0000 ) { cr = ( ( ( cr - 1 ) & 0xffff0000 ) | ( MV_WIN_DDR_ATTR ( i ) << MV_WIN_CPU_ATTR_SHIFT ) | ( MV_WIN_DDR_TARGET << MV_WIN_CPU_TARGET_SHIFT ) | MV_WIN_CPU_ENABLE_BIT ) ; CESA_TDMA_WRITE ( sc , MV_WIN_CESA_BASE ( i ) , br ) ; CESA_TDMA_WRITE ( sc , MV_WIN_CESA_CTRL ( i ) , cr ) ; } } return ( 0 ) ; }
Set CESA TDMA decode windows.
Set CESA TDMA decode windows .
/* Grab physical memory regions information from DTS */ /* Disable and clear all CESA windows */ /* Fill CESA TDMA decoding windows with information acquired from DTS */ /* Don't add entries with size lower than 64KB */