#include <ar7240_soc.h>
#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)
/*
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);
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)
#include "ag7240.h"
#include "ag7240_phy.h"
+DECLARE_GLOBAL_DATA_PTR;
+
#if (CONFIG_COMMANDS & CFG_CMD_MII)
#include <miiphy.h>
#else
#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);
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:
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)
#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);
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) {
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)