From: Piotr Dymacz Date: Fri, 13 Nov 2015 01:58:21 +0000 (+0100) Subject: Start using new QC/A related code plus minor fixes in ag7240.c and ag934x.c X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e2876a802ec986b4ab45963eb894eb3e68ba2355;p=oweals%2Fu-boot_mod.git Start using new QC/A related code plus minor fixes in ag7240.c and ag934x.c --- diff --git a/u-boot/common/cmd_custom.c b/u-boot/common/cmd_custom.c index 780e85f..96645b9 100755 --- a/u-boot/common/cmd_custom.c +++ b/u-boot/common/cmd_custom.c @@ -26,7 +26,9 @@ #include #include "../board/ar7240/common/ar7240_flash.h" -extern void ar933x_sys_frequency(u32 *cpu_freq, u32 *ddr_freq, u32 *ahb_freq); +/* TODO: remove extern and include header file*/ +extern void qca_sys_clocks(u32 *cpu_clk, u32 *ddr_clk, u32 *ahb_clk, + u32 *spi_clk, u32 *ref_clk); #if defined(OFFSET_MAC_ADDRESS) /* @@ -558,7 +560,7 @@ int do_set_clocks(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]){ if(argc == 1){ // read clocks - ar933x_sys_frequency(&cpu_freq, &ddr_freq, &ahb_freq); + qca_sys_clocks(&cpu_freq, &ddr_freq, &ahb_freq, NULL, NULL); // calculate SPI clock (we need to set bit 0 to 1 in SPI_FUNC_SELECT to access SPI registers) ar7240_reg_wr(AR7240_SPI_FS, 0x01); diff --git a/u-boot/cpu/mips/ar7240/Makefile b/u-boot/cpu/mips/ar7240/Makefile index 2b121bc..350f49a 100644 --- a/u-boot/cpu/mips/ar7240/Makefile +++ b/u-boot/cpu/mips/ar7240/Makefile @@ -4,23 +4,24 @@ LIB = lib$(SOC).a START = -OBJS = meminit.o +OBJS = meminit.o +OBJS += qca_common.o +OBJS += qca_clocks.o ifeq ($(BOARD), ap121) -OBJS += ar933x_serial.o -OBJS += ar933x_clocks.o -SOBJS += hornet_ddr_init.o + OBJS += qca_hs_uart.o + SOBJS += hornet_ddr_init.o else -OBJS += ar7240_serial.o + OBJS += qca_ls_uart.o endif ifeq ($(BOARD), db12x) -OBJS += ag934x.o + OBJS += ag934x.o else -OBJS += ag7240.o + OBJS += ag7240.o endif -SOBJS += +SOBJS += all: .depend $(START) $(LIB) diff --git a/u-boot/cpu/mips/ar7240/ag7240.c b/u-boot/cpu/mips/ar7240/ag7240.c index 37b16e2..31f5484 100644 --- a/u-boot/cpu/mips/ar7240/ag7240.c +++ b/u-boot/cpu/mips/ar7240/ag7240.c @@ -10,6 +10,8 @@ #include "ag7240.h" #include "ag7240_phy.h" +DECLARE_GLOBAL_DATA_PTR; + #if (CONFIG_COMMANDS & CFG_CMD_MII) #include #else @@ -20,13 +22,14 @@ #define ag7240_unit2mac(_unit) ag7240_macs[(_unit)] #define ag7240_name2mac(name) strcmp(name,"eth0") ? ag7240_unit2mac(1) : ag7240_unit2mac(0) -#define CHECK_BIT(var,pos) ((var) & (1<<(pos))) uint16_t ag7240_miiphy_read(char *devname, uint32_t phaddr, uint8_t reg); void ag7240_miiphy_write(char *devname, uint32_t phaddr, uint8_t reg, uint16_t data); ag7240_mac_t *ag7240_macs[CFG_AG7240_NMACS]; -extern void ar933x_sys_frequency(u32 *cpu_freq, u32 *ddr_freq, u32 *ahb_freq); +/* TODO: remove extern and include header file*/ +extern void qca_sys_clocks(u32 *cpu_clk, u32 *ddr_clk, u32 *ahb_clk, + u32 *spi_clk, u32 *ref_clk); extern void athrs26_reg_init(void); extern void athrs26_reg_init_lan(void); @@ -167,7 +170,7 @@ void ag7240_mii_setup(ag7240_mac_t *mac) ag7240_reg_wr(mac, AG7240_MAC_MII_MGMT_CFG, mgmt_cfg_val); } } else { - ar933x_sys_frequency(&cpu_freq, &ddr_freq, &ahb_freq); + qca_sys_clocks(&cpu_freq, &ddr_freq, &ahb_freq, NULL, NULL); switch (ahb_freq / 1000000) { case 150: @@ -454,45 +457,9 @@ static void ag7240_halt(struct eth_device *dev) static void ag7240_get_ethaddr(struct eth_device *dev) { unsigned char *mac = dev->enetaddr; -#ifdef OFFSET_MAC_ADDRESS - unsigned char buffer[6]; - - // get MAC address from flash and check it - memcpy(buffer, (void *)(CFG_FLASH_BASE + OFFSET_MAC_DATA_BLOCK + OFFSET_MAC_ADDRESS), 6); + bd_t *bd = gd->bd; - /* - * check first LSBit (I/G bit) and second LSBit (U/L bit) in MSByte of vendor part - * both of them should be 0: - * I/G bit == 0 -> Individual MAC address (unicast address) - * U/L bit == 0 -> Burned-In-Address (BIA) MAC address - */ - if(CHECK_BIT((buffer[0] & 0xFF), 0) == 0 && CHECK_BIT((buffer[0] & 0xFF), 1) == 0){ - mac[0] = (buffer[0] & 0xFF); - mac[1] = (buffer[1] & 0xFF); - mac[2] = (buffer[2] & 0xFF); - mac[3] = (buffer[3] & 0xFF); - mac[4] = (buffer[4] & 0xFF); - mac[5] = (buffer[5] & 0xFF); - } else { - // 00-03-7F (Atheros Communications, Inc.) - mac[0] = 0x00; - mac[1] = 0x03; - mac[2] = 0x7f; - mac[3] = 0x09; - mac[4] = 0x0b; - mac[5] = 0xad; - - printf("## Error: MAC address in FLASH is invalid, using fixed!\n"); - } -#else - // 00-03-7F (Atheros Communications, Inc.) - mac[0] = 0x00; - mac[1] = 0x03; - mac[2] = 0x7f; - mac[3] = 0x09; - mac[4] = 0x0b; - mac[5] = 0xad; -#endif + memcpy(mac, (void *)bd->bi_enetaddr, 6); } int ag7240_enet_initialize(bd_t * bis) diff --git a/u-boot/cpu/mips/ar7240/ag934x.c b/u-boot/cpu/mips/ar7240/ag934x.c index 327bea9..154f2df 100644 --- a/u-boot/cpu/mips/ar7240/ag934x.c +++ b/u-boot/cpu/mips/ar7240/ag934x.c @@ -10,18 +10,22 @@ #include "ag934x.h" #include "ag934x_phy.h" +DECLARE_GLOBAL_DATA_PTR; + #define _1000BASET 1000 #define _100BASET 100 #define _10BASET 10 #define ag7240_unit2mac(_unit) ag7240_macs[(_unit)] #define ag7240_name2mac(name) strcmp(name,"eth0") ? ag7240_unit2mac(1) : ag7240_unit2mac(0) -#define CHECK_BIT(var,pos) ((var) & (1<<(pos))) uint16_t ag7240_miiphy_read(char *devname, uint32_t phaddr, uint8_t reg); void ag7240_miiphy_write(char *devname, uint32_t phaddr, uint8_t reg, uint16_t data); ag7240_mac_t *ag7240_macs[CFG_AG7240_NMACS]; -extern void ar7240_sys_frequency(u32 *cpu_freq, u32 *ddr_freq, u32 *ahb_freq); + +/* TODO: remove extern and include header file*/ +extern void qca_sys_clocks(u32 *cpu_clk, u32 *ddr_clk, u32 *ahb_clk, + u32 *spi_clk, u32 *ref_clk); #ifdef CFG_ATHRS26_PHY extern void athrs26_reg_init(void); @@ -203,7 +207,7 @@ void ag7240_mii_setup(ag7240_mac_t *mac) ag7240_reg_wr(mac, AG7240_MAC_MII_MGMT_CFG, mgmt_cfg_val); } } else { - ar7240_sys_frequency(&cpu_freq, &ddr_freq, &ahb_freq); + qca_sys_clocks(&cpu_freq, &ddr_freq, &ahb_freq, NULL, NULL); // TODO: ?? switch (ahb_freq / 1000000) { @@ -510,45 +514,9 @@ static void ag7240_halt(struct eth_device *dev) static void ag7240_get_ethaddr(struct eth_device *dev) { unsigned char *mac = dev->enetaddr; -#ifdef OFFSET_MAC_ADDRESS - unsigned char buffer[6]; - - // get MAC address from flash and check it - memcpy(buffer, (void *)(CFG_FLASH_BASE + OFFSET_MAC_DATA_BLOCK + OFFSET_MAC_ADDRESS), 6); + bd_t *bd = gd->bd; - /* - * check first LSBit (I/G bit) and second LSBit (U/L bit) in MSByte of vendor part - * both of them should be 0: - * I/G bit == 0 -> Individual MAC address (unicast address) - * U/L bit == 0 -> Burned-In-Address (BIA) MAC address - */ - if(CHECK_BIT((buffer[0] & 0xFF), 0) == 0 && CHECK_BIT((buffer[0] & 0xFF), 1) == 0){ - mac[0] = (buffer[0] & 0xFF); - mac[1] = (buffer[1] & 0xFF); - mac[2] = (buffer[2] & 0xFF); - mac[3] = (buffer[3] & 0xFF); - mac[4] = (buffer[4] & 0xFF); - mac[5] = (buffer[5] & 0xFF); - } else { - // 00-03-7F (Atheros Communications, Inc.) - mac[0] = 0x00; - mac[1] = 0x03; - mac[2] = 0x7f; - mac[3] = 0x09; - mac[4] = 0x0b; - mac[5] = 0xad; - - printf("## Error: MAC address in FLASH is invalid, using fixed!\n"); - } -#else - // 00-03-7F (Atheros Communications, Inc.) - mac[0] = 0x00; - mac[1] = 0x03; - mac[2] = 0x7f; - mac[3] = 0x09; - mac[4] = 0x0b; - mac[5] = 0xad; -#endif + memcpy(mac, (void *)bd->bi_enetaddr, 6); } int ag7240_enet_initialize(bd_t * bis)