imx51_machdep.c revision 248557
188757Sache/*-
288757Sache * Copyright (c) 1994-1998 Mark Brinicombe.
388757Sache * Copyright (c) 1994 Brini.
488757Sache * Copyright (c) 2012 The FreeBSD Foundation
588757Sache * All rights reserved.
688757Sache *
788757Sache *
888757Sache * This code is derived from software written for Brini by Mark Brinicombe
988757Sache * Portions of this software were developed by Oleksandr Rybalko
1088757Sache * under sponsorship from the FreeBSD Foundation.
1188757Sache *
1288757Sache * Redistribution and use in source and binary forms, with or without
1388757Sache * modification, are permitted provided that the following conditions
1488757Sache * are met:
1588757Sache * 1. Redistributions of source code must retain the above copyright
1688757Sache *    notice, this list of conditions and the following disclaimer.
1788757Sache * 2. Redistributions in binary form must reproduce the above copyright
1888757Sache *    notice, this list of conditions and the following disclaimer in the
1988757Sache *    documentation and/or other materials provided with the distribution.
2088757Sache * 3. All advertising materials mentioning features or use of this software
2188757Sache *    must display the following acknowledgement:
2288757Sache *      This product includes software developed by Brini.
2388757Sache * 4. The name of the company nor the name of the author may be used to
2488757Sache *    endorse or promote products derived from this software without specific
2588757Sache *    prior written permission.
2688757Sache *
2788757Sache * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
2888757Sache * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2988757Sache * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
3088757Sache * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
3188757Sache * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3288757Sache * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3388757Sache * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3488757Sache * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3588757Sache * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3688757Sache * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3788757Sache * SUCH DAMAGE.
3888757Sache *
3988757Sache * from: FreeBSD: //depot/projects/arm/src/sys/arm/at91/kb920x_machdep.c, rev 45
4088757Sache */
4188757Sache
4288757Sache#include "opt_platform.h"
4388757Sache
4488757Sache#include <sys/cdefs.h>
4588757Sache__FBSDID("$FreeBSD: head/sys/arm/freescale/imx/imx_machdep.c 248557 2013-03-20 15:39:27Z ray $");
4688757Sache
4788757Sache#define _ARM32_BUS_DMA_PRIVATE
4888757Sache#include <sys/param.h>
4988757Sache#include <sys/systm.h>
5088757Sache#include <sys/bus.h>
5188757Sache#include <sys/reboot.h>
5288757Sache
5388757Sache#include <vm/vm.h>
5488757Sache#include <vm/pmap.h>
5588757Sache
5688757Sache#include <machine/bus.h>
5788757Sache#include <machine/frame.h> /* For trapframe_t, used in <machine/machdep.h> */
5888757Sache#include <machine/machdep.h>
5988757Sache#include <machine/pmap.h>
6088757Sache
6188757Sache#include <dev/fdt/fdt_common.h>
6288757Sache
6388757Sache#define	IMX51_DEV_VIRT_BASE	0xe0000000
6488757Sachevm_offset_t
6588757Sacheinitarm_lastaddr(void)
6688757Sache{
6788757Sache
6888757Sache	boothowto |= RB_VERBOSE|RB_MULTIPLE;
6988757Sache	bootverbose = 1;
7088757Sache
7188757Sache	if (fdt_immr_addr(IMX51_DEV_VIRT_BASE) != 0)
7288757Sache		while (1);
7388757Sache
7488757Sache	/* Platform-specific initialisation */
7588757Sache	return (fdt_immr_va - ARM_NOCACHE_KVA_SIZE);
7688757Sache}
7788757Sache
7888757Sache/*
7988757Sache * Set initial values of GPIO output ports
8088757Sache */
8188757Sachevoid
8288757Sacheinitarm_gpio_init(void)
8388757Sache{
8488757Sache
85}
86
87void
88initarm_late_init(void)
89{
90
91}
92
93#define FDT_DEVMAP_MAX	2
94static struct pmap_devmap fdt_devmap[FDT_DEVMAP_MAX] = {
95	{ 0, 0, 0, 0, 0, },
96	{ 0, 0, 0, 0, 0, }
97};
98
99/*
100 * Construct pmap_devmap[] with DT-derived config data.
101 */
102int
103platform_devmap_init(void)
104{
105
106	/*
107	 * Map segment where UART1 and UART2 located.
108	 */
109	fdt_devmap[0].pd_va = IMX51_DEV_VIRT_BASE + 0x03f00000;
110	fdt_devmap[0].pd_pa = 0x73f00000;
111	fdt_devmap[0].pd_size = 0x00100000;
112	fdt_devmap[0].pd_prot = VM_PROT_READ | VM_PROT_WRITE;
113	fdt_devmap[0].pd_cache = PTE_NOCACHE;
114
115	pmap_devmap_bootstrap_table = &fdt_devmap[0];
116	return (0);
117}
118
119struct arm32_dma_range *
120bus_dma_get_range(void)
121{
122
123	return (NULL);
124}
125
126int
127bus_dma_get_range_nb(void)
128{
129
130	return (0);
131}
132
133void
134cpu_reset(void)
135{
136
137	printf("Reset ...\n");
138	/* Clear n_reset flag */
139	*((volatile u_int16_t *)(IMX51_DEV_VIRT_BASE + 0x03f98000)) =
140	    (u_int16_t)0;
141	while (1);
142}
143