xref: /freebsd/sys/arm/include/platform.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
127521ff8SAndrew Turner /*-
227521ff8SAndrew Turner  * Copyright (c) 2014 Andrew Turner
327521ff8SAndrew Turner  * All rights reserved.
427521ff8SAndrew Turner  *
527521ff8SAndrew Turner  * Redistribution and use in source and binary forms, with or without
627521ff8SAndrew Turner  * modification, are permitted provided that the following conditions
727521ff8SAndrew Turner  * are met:
827521ff8SAndrew Turner  * 1. Redistributions of source code must retain the above copyright
927521ff8SAndrew Turner  *    notice, this list of conditions and the following disclaimer.
1027521ff8SAndrew Turner  * 2. Redistributions in binary form must reproduce the above copyright
1127521ff8SAndrew Turner  *    notice, this list of conditions and the following disclaimer in the
1227521ff8SAndrew Turner  *    documentation and/or other materials provided with the distribution.
1327521ff8SAndrew Turner  *
1427521ff8SAndrew Turner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1527521ff8SAndrew Turner  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1627521ff8SAndrew Turner  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1727521ff8SAndrew Turner  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1827521ff8SAndrew Turner  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1927521ff8SAndrew Turner  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2027521ff8SAndrew Turner  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2127521ff8SAndrew Turner  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2227521ff8SAndrew Turner  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2327521ff8SAndrew Turner  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2427521ff8SAndrew Turner  * SUCH DAMAGE.
2527521ff8SAndrew Turner  */
2627521ff8SAndrew Turner 
2727521ff8SAndrew Turner #ifndef	_MACHINE_PLATFORM_H_
2827521ff8SAndrew Turner #define	_MACHINE_PLATFORM_H_
2927521ff8SAndrew Turner 
30*6a3fc532SIan Lepore /*
31*6a3fc532SIan Lepore  * Initialization functions called by the common initarm() function in
32*6a3fc532SIan Lepore  * arm/machdep.c (but not necessarily from the custom initarm() functions of
33*6a3fc532SIan Lepore  * older code).
34*6a3fc532SIan Lepore  *
35*6a3fc532SIan Lepore  *  - platform_probe_and_attach() is called very early, after parsing the boot
36*6a3fc532SIan Lepore  *    params and after physical memory has been located and sized.
37*6a3fc532SIan Lepore  *
38*6a3fc532SIan Lepore  *  - platform_devmap_init() is called as one of the last steps of early virtual
39*6a3fc532SIan Lepore  *    memory initialization, shortly before the new page tables are installed.
40*6a3fc532SIan Lepore  *
41*6a3fc532SIan Lepore  *  - platform_lastaddr() is called after platform_devmap_init(), and must return
42*6a3fc532SIan Lepore  *    the address of the first byte of unusable KVA space.  This allows a
43*6a3fc532SIan Lepore  *    platform to carve out of the top of the KVA space whatever reserves it
44*6a3fc532SIan Lepore  *    needs for things like static device mapping, and this is called to get the
45*6a3fc532SIan Lepore  *    value before calling pmap_bootstrap() which uses the value to size the
46*6a3fc532SIan Lepore  *    available KVA.
47*6a3fc532SIan Lepore  *
48*6a3fc532SIan Lepore  *  - platform_gpio_init() is called after the static device mappings are
49*6a3fc532SIan Lepore  *    established and just before cninit().  The intention is that the routine
50*6a3fc532SIan Lepore  *    can do any hardware setup (such as gpio or pinmux) necessary to make the
51*6a3fc532SIan Lepore  *    console functional.
52*6a3fc532SIan Lepore  *
53*6a3fc532SIan Lepore  *  - platform_late_init() is called just after cninit().  This is the first of
54*6a3fc532SIan Lepore  *    the init routines that can use printf() and expect the output to appear on
55*6a3fc532SIan Lepore  *    a standard console.
56*6a3fc532SIan Lepore  *
57*6a3fc532SIan Lepore  */
5827521ff8SAndrew Turner void platform_probe_and_attach(void);
5927521ff8SAndrew Turner int platform_devmap_init(void);
6027521ff8SAndrew Turner vm_offset_t platform_lastaddr(void);
6127521ff8SAndrew Turner void platform_gpio_init(void);
6227521ff8SAndrew Turner void platform_late_init(void);
6327521ff8SAndrew Turner 
6427521ff8SAndrew Turner #endif	/* _MACHINE_PLATFORM_H_ */
65