File indexing completed on 2025-05-11 08:22:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #include <bsp.h>
0029 #include <bsp/bootcard.h>
0030 #include <bsp/irq-generic.h>
0031 #include <bsp/fdt.h>
0032 #include <bsp/linker-symbols.h>
0033 #include <bsp/i2c.h>
0034 #include <rtems/sysinit.h>
0035 #include "bsp-soc-detect.h"
0036 #include <arm/ti/ti_pinmux.h>
0037 #include <ofw/ofw.h>
0038 #include <bsp/i2c.h>
0039 #include <string.h>
0040 #include <stdlib.h>
0041 #include <ctype.h>
0042
0043 #include "bspdebug.h"
0044
0045 void bsp_start(void)
0046 {
0047 const char *type;
0048
0049 bsp_soc_detect();
0050
0051 switch (ti_chip()) {
0052 case CHIP_AM335X:
0053 type = "am335x-based";
0054 break;
0055 case CHIP_OMAP_3:
0056 type = "dm3730-based";
0057 break;
0058 default:
0059 type = "Unknown SOC";
0060 break;
0061 }
0062
0063 bsp_interrupt_initialize();
0064 printk("\nRTEMS Beagleboard: %s\n", type);
0065 printk(" ARM Debug: 0x%08x\n", (intptr_t) bbb_arm_debug_registers());
0066 rtems_cache_coherent_add_area(
0067 bsp_section_nocacheheap_begin,
0068 (uintptr_t) bsp_section_nocacheheap_size
0069 );
0070 }
0071
0072 uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
0073 {
0074 return intr[0];
0075 }
0076
0077 static void traverse_fdt_nodes( phandle_t node )
0078 {
0079
0080 for (node = rtems_ofw_child(node); node != 0; node = rtems_ofw_peer(node)) {
0081 traverse_fdt_nodes(node);
0082
0083 if (!rtems_ofw_node_status(node))
0084 continue;
0085
0086
0087
0088
0089 beagle_pinmux_init(node);
0090 beagle_i2c_init(node);
0091 }
0092 }
0093
0094 static void bbb_drivers_initialize(void)
0095 {
0096 phandle_t node = rtems_ofw_peer(0);
0097
0098 traverse_fdt_nodes(node);
0099 }
0100
0101 int beagle_get_node_unit(phandle_t node)
0102 {
0103 char name[30];
0104 char prop[30];
0105 char prop_val[30];
0106 static int unit;
0107 phandle_t aliases;
0108 int rv;
0109 int i;
0110
0111 rv = rtems_ofw_get_prop(node, "name", name, sizeof(name));
0112 if (rv <= 0)
0113 return unit++;
0114
0115 aliases = rtems_ofw_find_device("/aliases");
0116
0117 rv = rtems_ofw_next_prop(aliases, NULL, &prop[0], sizeof(prop));
0118
0119 while (rv > 0) {
0120 rv = rtems_ofw_get_prop(aliases, prop, prop_val, sizeof(prop_val));
0121
0122 if (strstr(prop_val, name) != NULL) {
0123 for (i = strlen(prop) - 1; i >= 0; i--) {
0124 if (!isdigit((int)prop[i]))
0125 break;
0126 }
0127
0128 return strtol(&prop[i + 1], NULL, 10);
0129 }
0130 rv = rtems_ofw_next_prop(aliases, prop, prop, sizeof(prop));
0131 }
0132
0133 return unit++;
0134 }
0135
0136 RTEMS_SYSINIT_ITEM(
0137 bbb_drivers_initialize,
0138 RTEMS_SYSINIT_BSP_PRE_DRIVERS,
0139 RTEMS_SYSINIT_ORDER_LAST
0140 );