2 * Copyright (C) 2015 Piotr Dymacz <piotr@dymacz.pl>
4 * SPDX-License-Identifier:GPL-2.0
10 #include <asm/mipsregs.h>
11 #include <asm/addrspace.h>
12 #include <soc/qca_soc_common.h>
14 #define ALIGN_SIZE "8"
16 DECLARE_GLOBAL_DATA_PTR;
18 static u32 mac_is_not_valid = 1;
21 * Prints available information about the board
23 void print_board_info(void)
25 u32 ahb_clk, cpu_clk, ddr_clk, spi_clk, ref_clk;
31 #ifdef BOARD_CUSTOM_STRING
32 printf("%" ALIGN_SIZE "s %s\n", "BOARD:", BOARD_CUSTOM_STRING);
35 /* SOC name, version and revision */
36 qca_soc_name_rev(buffer);
37 printf("%" ALIGN_SIZE "s %s\n", "SOC:", buffer);
41 printf("%" ALIGN_SIZE "s %s\n", "CPU:", buffer);
43 /* RAM size and type */
44 printf("%" ALIGN_SIZE "s ", "RAM:");
45 print_size(bd->bi_memsize, "");
47 switch (qca_mem_type()) {
48 case QCA_RST_BOOTSTRAP_MEM_TYPE_SDR_VAL:
51 case QCA_RST_BOOTSTRAP_MEM_TYPE_DDR1_VAL:
54 case QCA_RST_BOOTSTRAP_MEM_TYPE_DDR2_VAL:
62 /* SPI NOR FLASH sizes and types */
63 printf("%" ALIGN_SIZE "s ", "FLASH:");
65 for (bank = 0; bank < CFG_MAX_FLASH_BANKS; bank++) {
66 if (flash_info[bank].size == 0)
70 printf("%" ALIGN_SIZE "s ", " ");
72 print_size(flash_info[bank].size, "");
74 if (flash_info[bank].manuf_name != NULL)
75 printf(" %s", flash_info[bank].manuf_name);
77 if (flash_info[bank].model_name != NULL)
78 printf(" %s", flash_info[bank].model_name);
84 printf("%" ALIGN_SIZE "s %02X:%02X:%02X:%02X:%02X:%02X", "MAC:",
85 bd->bi_enetaddr[0],bd->bi_enetaddr[1], bd->bi_enetaddr[2],
86 bd->bi_enetaddr[3], bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
88 if (mac_is_not_valid) {
95 printf("%" ALIGN_SIZE "s CPU/RAM/AHB/SPI/REF\n", "CLOCKS:");
97 qca_sys_clocks(&cpu_clk, &ddr_clk, &ahb_clk, &spi_clk, &ref_clk);
98 cpu_clk = cpu_clk / 1000000;
99 ddr_clk = ddr_clk / 1000000;
100 ahb_clk = ahb_clk / 1000000;
101 spi_clk = spi_clk / 1000000;
102 ref_clk = ref_clk / 1000000;
104 printf("%" ALIGN_SIZE "s %d/%d/%d/%3d/%3d MHz\n",
105 " ", cpu_clk, ddr_clk, ahb_clk, spi_clk, ref_clk);
111 * Reads MAC address if available or uses fixed one
113 void macaddr_init(u8 *mac_addr)
116 u8 fixed_mac[6] = {0x00, 0x03, 0x7F, 0x09, 0x0B, 0xAD};
118 #if defined(OFFSET_MAC_ADDRESS)
119 memcpy(buffer, (void *)(CFG_FLASH_BASE
120 + OFFSET_MAC_DATA_BLOCK + OFFSET_MAC_ADDRESS), 6);
123 * Check first LSBit (I/G bit) and second LSBit (U/L bit) in MSByte of vendor part
124 * both of them should be 0:
125 * I/G bit == 0 -> Individual MAC address (unicast address)
126 * U/L bit == 0 -> Burned-In-Address (BIA) MAC address
128 if (CHECK_BIT((buffer[0] & 0xFF), 0) != 0 ||
129 CHECK_BIT((buffer[0] & 0xFF), 1) != 0) {
130 memcpy(buffer, fixed_mac, 6);
132 mac_is_not_valid = 0;
135 memcpy(buffer, fixed_mac, 6);
138 memcpy(mac_addr, buffer, 6);
142 * Returns main CPU clock in Hz
144 u32 main_cpu_clk(void)
148 qca_sys_clocks(&cpu_clk, NULL, NULL, NULL, NULL);
154 * Calls full chip reset
156 void full_reset(void)
158 qca_full_chip_reset();