blob: a7fe85818ee8dea3fc5ddbec12e3a797c6185e31 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2012 Ian McKellar
3 * Copyright (c) 2013 Travis Geiselbrecht
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files
7 * (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25#include <err.h>
26#include <stdio.h>
27#include <debug.h>
28#include <platform.h>
29#include <dev/usb.h>
30#include <arch/arm/cm.h>
31
32#include "ti_driverlib.h"
33
34
35void stellaris_debug_early_init(void);
36void stellaris_debug_init(void);
37
38void stellaris_gpio_early_init(void);
39void stellaris_gpio_init(void);
40
41void stellaris_usbc_early_init(void);
42void stellaris_usbc_init(void);
43
44void platform_early_init(void)
45{
46 //
47 // Enable lazy stacking for interrupt handlers. This allows floating-point
48 // instructions to be used within interrupt handlers, but at the expense of
49 // extra stack usage.
50 //
51// FPULazyStackingEnable();
52
53 //
54 // Set the clocking to run directly from the crystal.
55 //
56 SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
57
58 // start the generic systick timer
59 arm_cm_systick_init(SysCtlClockGet());
60
61 stellaris_gpio_early_init();
62
63 stellaris_debug_early_init();
64
65 stellaris_usbc_early_init();
66}
67
68void platform_init(void)
69{
70 stellaris_gpio_init();
71 stellaris_debug_init();
72 stellaris_usbc_init();
73
74 // print device information
75 printf("raw revision registers: 0x%lx 0x%lx\n", HWREG(SYSCTL_DID0), HWREG(SYSCTL_DID1));
76
77 printf("stellaris device class: ");
78 if (CLASS_IS_SANDSTORM) printf("sandstorm");
79 if (CLASS_IS_FURY) printf("fury");
80 if (CLASS_IS_DUSTDEVIL) printf("dustdevil");
81 if (CLASS_IS_TEMPEST) printf("tempst");
82 if (CLASS_IS_FIRESTORM) printf("firestorm");
83 if (CLASS_IS_BLIZZARD) printf("blizzard");
84 printf("\n");
85
86 printf("revision register: ");
87 uint rev = (HWREG(SYSCTL_DID0) & SYSCTL_DID0_MAJ_M) >> 8;
88 printf("%c", rev + 'A');
89 printf("%ld", HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MIN_M));
90 printf("\n");
91
92}
93
94// vim: set ts=4 sw=4 noexpandtab: