board: arm: ipq5332: update ethernet configuration

Change-Id: If66707a68ddf5681016acd95332d4056b31fb3fc
Signed-off-by: Vandhiadevan Karunamoorthy <quic_vkarunam@quicinc.com>
This commit is contained in:
Vandhiadevan Karunamoorthy 2022-10-19 07:21:53 +05:30 committed by Gerrit - the friendly Code Review server
parent e3b2150af9
commit bc5f3cca5a
6 changed files with 609 additions and 519 deletions

View file

@ -905,14 +905,76 @@ void qca808x_phy_reset_init_done(void)
}
}
int get_sfp_gpio(int sfp_gpio[2])
{
int sfp_gpio_cnt = -1, node;
int res = -1;
node = fdt_path_offset(gd->fdt_blob, "/ess-switch");
if (node >= 0) {
sfp_gpio_cnt = fdtdec_get_uint(gd->fdt_blob, node,
"sfp_gpio_cnt", -1);
if (sfp_gpio_cnt >= 1) {
res = fdtdec_get_int_array(gd->fdt_blob, node,
"sfp_gpio",
(u32 *)sfp_gpio,
sfp_gpio_cnt);
if (res >= 0)
return sfp_gpio_cnt;
}
}
return res;
}
void sfp_reset_init(void)
{
int sfp_gpio[2] = {-1, -1}, sfp_gpio_cnt, i;
unsigned int *sfp_gpio_base;
uint32_t cfg;
sfp_gpio_cnt = get_sfp_gpio(sfp_gpio);
if (sfp_gpio_cnt >= 1) {
for (i = 0; i < sfp_gpio_cnt; i++) {
if (sfp_gpio[i] >= 0) {
sfp_gpio_base =
(unsigned int *)GPIO_CONFIG_ADDR(
sfp_gpio[i]);
cfg = GPIO_OE | GPIO_DRV_8_MA | GPIO_PULL_UP;
writel(cfg, sfp_gpio_base);
}
}
}
}
void qca8081_napa_reset(void)
{
unsigned int *napa_gpio_base;
int node, gpio;
uint32_t cfg;
node = fdt_path_offset(gd->fdt_blob, "/ess-switch");
if (node >= 0) {
gpio = fdtdec_get_uint(gd->fdt_blob, node , "napa_gpio", -1);
if (gpio != -1) {
napa_gpio_base =
(unsigned int *)GPIO_CONFIG_ADDR(gpio);
cfg = GPIO_OE | GPIO_DRV_8_MA | GPIO_PULL_UP;
writel(cfg, napa_gpio_base);
mdelay(100);
gpio_set_value(gpio, 0x1);
}
}
}
void bring_phy_out_of_reset(void)
{
qca8081_napa_reset();
aquantia_phy_reset_init();
qca808x_phy_reset_init();
sfp_reset_init();
mdelay(500);
aquantia_phy_reset_init_done();
qca808x_phy_reset_init_done();
mdelay(500);
}
void ipq5332_eth_initialize(void)

File diff suppressed because it is too large Load diff

View file

@ -82,7 +82,8 @@ void ppe_ipo_action_set(union ipo_action_u *hw_act, int rule_id)
}
}
void ipq5332_ppe_acl_set(int rule_id, int rule_type, int field0, int field1, int mask, int permit, int deny)
void ipq5332_ppe_acl_set(int rule_id, int rule_type, int field0, int field1,
int mask, int permit, int deny)
{
union ipo_rule_reg_u hw_reg = {0};
union ipo_mask_reg_u hw_mask = {0};
@ -198,14 +199,16 @@ void ppe_port_bridge_txmac_set(int port_id, int status)
uint32_t reg_value = 0;
ipq5332_ppe_reg_read(IPE_L2_BASE_ADDR + PORT_BRIDGE_CTRL_ADDRESS +
(port_id * PORT_BRIDGE_CTRL_INC), &reg_value);
((port_id * PORT_BRIDGE_CTRL_INC) + PORT_BRIDGE_CTRL_INC),
&reg_value);
if (status == 0)
reg_value |= TX_MAC_EN;
else
reg_value &= ~TX_MAC_EN;
ipq5332_ppe_reg_write(IPE_L2_BASE_ADDR + PORT_BRIDGE_CTRL_ADDRESS +
(port_id * PORT_BRIDGE_CTRL_INC), reg_value);
((port_id * PORT_BRIDGE_CTRL_INC) + PORT_BRIDGE_CTRL_INC),
reg_value);
}
@ -221,8 +224,10 @@ void ppe_port_txmac_status_set(uint32_t port)
ipq5332_ppe_reg_write(PPE_SWITCH_NSS_SWITCH_XGMAC0 +
(port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION), reg_value);
pr_debug("NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION Address = 0x%x -> Value = %u\n",
PPE_SWITCH_NSS_SWITCH_XGMAC0 + (port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION),
pr_debug("NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION Address"
" = 0x%x -> Value = %u\n",
PPE_SWITCH_NSS_SWITCH_XGMAC0 +
(port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION),
reg_value);
}
@ -233,7 +238,8 @@ void ppe_port_rxmac_status_set(uint32_t port)
pr_debug("DEBUGGING rxmac_status_set......... PORTID = %d\n", port);
ipq5332_ppe_reg_read(PPE_SWITCH_NSS_SWITCH_XGMAC0 +
MAC_RX_CONFIGURATION_ADDRESS +
(port * NSS_SWITCH_XGMAC_MAC_RX_CONFIGURATION), &reg_value);
(port * NSS_SWITCH_XGMAC_MAC_RX_CONFIGURATION),
&reg_value);
reg_value |= 0x300000c0;
reg_value |=RE;
@ -241,9 +247,11 @@ void ppe_port_rxmac_status_set(uint32_t port)
reg_value |=CST;
ipq5332_ppe_reg_write(PPE_SWITCH_NSS_SWITCH_XGMAC0 +
MAC_RX_CONFIGURATION_ADDRESS +
(port * NSS_SWITCH_XGMAC_MAC_RX_CONFIGURATION), reg_value);
(port * NSS_SWITCH_XGMAC_MAC_RX_CONFIGURATION),
reg_value);
pr_debug("NSS_SWITCH_XGMAC_MAC_RX_CONFIGURATION Address = 0x%x -> Value = %u\n",
pr_debug("NSS_SWITCH_XGMAC_MAC_RX_CONFIGURATION Address"
" = 0x%x -> Value = %u\n",
PPE_SWITCH_NSS_SWITCH_XGMAC0 + MAC_RX_CONFIGURATION_ADDRESS +
(port * NSS_SWITCH_XGMAC_MAC_RX_CONFIGURATION),
reg_value);
@ -251,11 +259,12 @@ void ppe_port_rxmac_status_set(uint32_t port)
void ppe_mac_packet_filter_set(uint32_t port)
{
pr_debug("DEBUGGING mac_packet_filter_set......... PORTID = %d\n", port);
pr_debug("DEBUGGING mac_packet_filter_set...... PORTID = %d\n", port);
ipq5332_ppe_reg_write(PPE_SWITCH_NSS_SWITCH_XGMAC0 +
MAC_PACKET_FILTER_ADDRESS +
(port * MAC_PACKET_FILTER_INC), 0x80000081);
pr_debug("NSS_SWITCH_XGMAC_MAC_PACKET_FILTER Address = 0x%x -> Value = %u\n",
pr_debug("NSS_SWITCH_XGMAC_MAC_PACKET_FILTER Address"
" = 0x%x -> Value = %u\n",
PPE_SWITCH_NSS_SWITCH_XGMAC0 + MAC_PACKET_FILTER_ADDRESS +
(port * MAC_PACKET_FILTER_ADDRESS),
0x80000081);
@ -267,43 +276,28 @@ void ppe_mac_packet_filter_set(uint32_t port)
*/
void ipq5332_port_mac_clock_reset(int port)
{
int reg_val, reg_val1;
int reg_val;
reg_val = readl(NSS_CC_PPE_RESET_ADDR);
reg_val1 = readl(NSS_CC_UNIPHY_MISC_RESET);
switch(port) {
case 0:
/* Assert */
reg_val |= GCC_PPE_PORT1_MAC_ARES;
reg_val1 |= GCC_PORT1_ARES;
writel(reg_val, NSS_CC_PPE_RESET_ADDR);
writel(reg_val1, NSS_CC_UNIPHY_MISC_RESET);
mdelay(150);
/* De-Assert */
reg_val = readl(NSS_CC_PPE_RESET_ADDR);
reg_val1 = readl(NSS_CC_UNIPHY_MISC_RESET);
reg_val &= ~GCC_PPE_PORT1_MAC_ARES;
reg_val1 &= ~GCC_PORT1_ARES;
break;
case 1:
/* Assert */
reg_val |= GCC_PPE_PORT2_MAC_ARES;
reg_val1 |= GCC_PORT2_ARES;
writel(reg_val, NSS_CC_PPE_RESET_ADDR);
writel(reg_val1, NSS_CC_UNIPHY_MISC_RESET);
mdelay(150);
/* De-Assert */
reg_val = readl(NSS_CC_PPE_RESET_ADDR);
reg_val1 = readl(NSS_CC_UNIPHY_MISC_RESET);
reg_val &= ~GCC_PPE_PORT2_MAC_ARES;
reg_val1 &= ~GCC_PORT2_ARES;
break;
default:
break;
}
writel(reg_val, NSS_CC_PPE_RESET_ADDR);
writel(reg_val1, NSS_CC_UNIPHY_MISC_RESET);
mdelay(150);
/* PPE Reset */
writel(0x1, NSS_CC_PPE_BCR);
udelay(10);
writel(0x0, NSS_CC_PPE_BCR);
reg_val = readl(NSS_CC_UNIPHY_PORT1_RX_CBCR + (port * 0x8));
reg_val |= GCC_PORT1_ARES;
writel(reg_val, NSS_CC_UNIPHY_PORT1_RX_CBCR + (port * 0x8));
mdelay(10);
reg_val = readl(NSS_CC_UNIPHY_PORT1_RX_CBCR + (port * 0x8));
reg_val &= ~GCC_PORT1_ARES;
writel(reg_val, NSS_CC_UNIPHY_PORT1_RX_CBCR + (port * 0x8));
reg_val = readl(NSS_CC_UNIPHY_PORT1_RX_CBCR + 0x4 + (port * 0x8));
reg_val |= GCC_PORT1_ARES;
writel(reg_val, NSS_CC_UNIPHY_PORT1_RX_CBCR + 0x4 + (port * 0x8));
mdelay(10);
reg_val = readl(NSS_CC_UNIPHY_PORT1_RX_CBCR + 0x4 + (port * 0x8));
reg_val &= ~GCC_PORT1_ARES;
writel(reg_val, NSS_CC_UNIPHY_PORT1_RX_CBCR + 0x4 + (port * 0x8));
}
void ipq5332_speed_clock_set(int port_id, int clk[4])
@ -313,14 +307,15 @@ void ipq5332_speed_clock_set(int port_id, int clk[4])
for (i = 0; i < 6; i++)
{
reg_val[i] = readl(NSS_CC_PORT1_RX_CMD_RCGR + (i * 0x4) + (port_id * 0x18));
reg_val[i] = readl(NSS_CC_PORT1_RX_CMD_RCGR + (i * 0x4) +
(port_id * 0x18));
}
reg_val[0] &= ~0x1;
reg_val[1] &= ~0x71f;
reg_val[2] &= ~0x1ff;
reg_val[2] &= ~0xf;
reg_val[3] &= ~0x1;
reg_val[4] &= ~0x71f;
reg_val[5] &= ~0x1ff;
reg_val[5] &= ~0xf;
reg_val[1] |= clk[0];
reg_val[2] |= clk[1];
@ -334,7 +329,8 @@ void ipq5332_speed_clock_set(int port_id, int clk[4])
/* Port Tx direction speed clock cfg */
writel(reg_val[4], NSS_CC_PORT1_RX_CMD_RCGR + 0x10 + (port_id * 0x18));
writel(reg_val[5], NSS_CC_PORT1_RX_CMD_RCGR + 0x14 + (port_id * 0x18));
writel(reg_val[3] | 0x1, NSS_CC_PORT1_RX_CMD_RCGR + 0xc + (port_id * 0x18));
writel(reg_val[3] | 0x1, NSS_CC_PORT1_RX_CMD_RCGR + 0xc +
(port_id * 0x18));
}
int phy_status_get_from_ppe(int port_id)
@ -342,10 +338,9 @@ int phy_status_get_from_ppe(int port_id)
uint32_t reg_field = 0;
ipq5332_ppe_reg_read(PORT_PHY_STATUS_ADDRESS, &reg_field);
if (port_id == (PORT5 - PPE_UNIPHY_INSTANCE1))
reg_field >>= PORT_PHY_STATUS_PORT5_1_OFFSET;
else
reg_field >>= PORT_PHY_STATUS_PORT6_OFFSET;
if (port_id == 1)
reg_field >>= PORT_PHY_STATUS_PORT2_OFFSET;
return ((reg_field >> 7) & 0x1) ? 0 : 1;
}
@ -362,15 +357,17 @@ void ppe_xgmac_10g_r_speed_set(uint32_t port)
ipq5332_ppe_reg_write(PPE_SWITCH_NSS_SWITCH_XGMAC0 +
(port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION), reg_value);
pr_debug("NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION Address = 0x%x -> Value = %u\n",
PPE_SWITCH_NSS_SWITCH_XGMAC0 + (port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION),
reg_value);
pr_debug("NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION Address = 0x%x"
"-> Value = %u\n",
PPE_SWITCH_NSS_SWITCH_XGMAC0 +
(port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION),
reg_value);
}
void ipq5332_10g_r_speed_set(int port, int status)
{
ppe_xgmac_10g_r_speed_set(port);
ppe_port_bridge_txmac_set(port + 1, status);
ppe_port_bridge_txmac_set(port, status);
ppe_port_txmac_status_set(port);
ppe_port_rxmac_status_set(port);
ppe_mac_packet_filter_set(port);
@ -408,12 +405,15 @@ void ppe_xgmac_speed_set(uint32_t port, int speed)
reg_value |=JD;
ipq5332_ppe_reg_write(PPE_SWITCH_NSS_SWITCH_XGMAC0 +
(port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION), reg_value);
pr_debug("NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION Address = 0x%x -> Value = %u\n",
PPE_SWITCH_NSS_SWITCH_XGMAC0 + (port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION),
reg_value);
pr_debug("NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION Address = 0x%x"
" -> Value = %u\n",
PPE_SWITCH_NSS_SWITCH_XGMAC0 +
(port * NSS_SWITCH_XGMAC_MAC_TX_CONFIGURATION),
reg_value);
}
void ipq5332_uxsgmii_speed_set(int port, int speed, int duplex,
int status)
{
@ -433,7 +433,7 @@ void ipq5332_uxsgmii_speed_set(int port, int speed, int duplex,
ppe_uniphy_usxgmii_duplex_set(uniphy_index, duplex);
ppe_uniphy_usxgmii_port_reset(uniphy_index);
#endif
ppe_port_bridge_txmac_set(port + 1, status);
ppe_port_bridge_txmac_set(port, status);
ppe_port_txmac_status_set(port);
ppe_port_rxmac_status_set(port);
ppe_mac_packet_filter_set(port);
@ -441,7 +441,7 @@ void ipq5332_uxsgmii_speed_set(int port, int speed, int duplex,
void ipq5332_pqsgmii_speed_set(int port, int speed, int status)
{
ppe_port_bridge_txmac_set(port + 1, status);
ppe_port_bridge_txmac_set(port, status);
ipq5332_ppe_reg_write(IPQ5332_PPE_MAC_SPEED + (0x200 * port), speed);
ipq5332_ppe_reg_write(IPQ5332_PPE_MAC_ENABLE + (0x200 * port), 0x73);
ipq5332_ppe_reg_write(IPQ5332_PPE_MAC_MIB_CTL + (0x200 * port), 0x1);
@ -464,12 +464,12 @@ static void ipq5332_ppe_flow_port_map_tbl_port_num_set(int queue, int port)
static void ipq5332_ppe_flow_map_tbl_set(int queue, int port)
{
uint32_t val = port | 0x401000; /* c_drr_wt = 1, e_drr_wt = 1 */
ipq5332_ppe_reg_write(IPQ5332_PPE_L0_FLOW_MAP_TBL + queue * IPQ5332_PPE_L0_FLOW_MAP_TBL_INC,
val);
ipq5332_ppe_reg_write(IPQ5332_PPE_L0_FLOW_MAP_TBL + queue *
IPQ5332_PPE_L0_FLOW_MAP_TBL_INC, val);
val = port | 0x100400; /* c_drr_wt = 1, e_drr_wt = 1 */
ipq5332_ppe_reg_write(IPQ5332_PPE_L1_FLOW_MAP_TBL + port * IPQ5332_PPE_L1_FLOW_MAP_TBL_INC,
val);
ipq5332_ppe_reg_write(IPQ5332_PPE_L1_FLOW_MAP_TBL + port *
IPQ5332_PPE_L1_FLOW_MAP_TBL_INC, val);
}
/*
@ -477,6 +477,38 @@ static void ipq5332_ppe_flow_map_tbl_set(int queue, int port)
*/
static void ipq5332_ppe_tdm_configuration(void)
{
#ifndef CONFIG_IPQ5332_RUMI
ipq5332_ppe_reg_write(0xc000, 0x22);
ipq5332_ppe_reg_write(0xc010, 0x30);
ipq5332_ppe_reg_write(0xc020, 0x21);
ipq5332_ppe_reg_write(0xc030, 0x31);
ipq5332_ppe_reg_write(0xc040, 0x22);
ipq5332_ppe_reg_write(0xc050, 0x32);
ipq5332_ppe_reg_write(0xc060, 0x20);
ipq5332_ppe_reg_write(0xc070, 0x30);
ipq5332_ppe_reg_write(0xc080, 0x22);
ipq5332_ppe_reg_write(0xc090, 0x31);
ipq5332_ppe_reg_write(0xc0a0, 0x21);
ipq5332_ppe_reg_write(0xc0b0, 0x32);
ipq5332_ppe_reg_write(0xc0c0, 0x20);
ipq5332_ppe_reg_write(0xc0d0, 0x30);
ipq5332_ppe_reg_write(0xc0e0, 0x21);
ipq5332_ppe_reg_write(0xc0f0, 0x31);
ipq5332_ppe_reg_write(0xc100, 0x22);
ipq5332_ppe_reg_write(0xc110, 0x32);
ipq5332_ppe_reg_write(0xc120, 0x20);
ipq5332_ppe_reg_write(0xc130, 0x30);
ipq5332_ppe_reg_write(0xc140, 0x22);
ipq5332_ppe_reg_write(0xc150, 0x31);
ipq5332_ppe_reg_write(0xc160, 0x21);
ipq5332_ppe_reg_write(0xc170, 0x32);
ipq5332_ppe_reg_write(0xc180, 0x22);
ipq5332_ppe_reg_write(0xc190, 0x30);
ipq5332_ppe_reg_write(0xc1a0, 0x20);
ipq5332_ppe_reg_write(0xc1b0, 0x31);
ipq5332_ppe_reg_write(0xc1c0, 0x22);
ipq5332_ppe_reg_write(0xc1d0, 0x32);
#else
ipq5332_ppe_reg_write(0xc000, 0x20);
ipq5332_ppe_reg_write(0xc010, 0x32);
ipq5332_ppe_reg_write(0xc020, 0x21);
@ -484,11 +516,11 @@ static void ipq5332_ppe_tdm_configuration(void)
ipq5332_ppe_reg_write(0xc040, 0x22);
ipq5332_ppe_reg_write(0xc050, 0x31);
ipq5332_ppe_reg_write(0xb000, 0x80000006);
ipq5332_ppe_reg_write(0x47a000, 0xfa10);
ipq5332_ppe_reg_write(0x47a010, 0xfc21);
ipq5332_ppe_reg_write(0x47a020, 0xf902);
ipq5332_ppe_reg_write(0x400000, 0x3);
#endif
}
/*
@ -585,8 +617,10 @@ static void ipq5332_ppe_enable_port_counter(void)
*/
static void ipq5332_ppe_c_sp_cfg_tbl_drr_id_set(int id)
{
ipq5332_ppe_reg_write(IPQ5332_PPE_L0_C_SP_CFG_TBL + (id * 0x80), id * 2);
ipq5332_ppe_reg_write(IPQ5332_PPE_L1_C_SP_CFG_TBL + (id * 0x80), id * 2);
ipq5332_ppe_reg_write(IPQ5332_PPE_L0_C_SP_CFG_TBL +
(id * 0x80), id * 2);
ipq5332_ppe_reg_write(IPQ5332_PPE_L1_C_SP_CFG_TBL +
(id * 0x80), id * 2);
}
/*
@ -594,8 +628,10 @@ static void ipq5332_ppe_c_sp_cfg_tbl_drr_id_set(int id)
*/
static void ipq5332_ppe_e_sp_cfg_tbl_drr_id_set(int id)
{
ipq5332_ppe_reg_write(IPQ5332_PPE_L0_E_SP_CFG_TBL + (id * 0x80), id * 2 + 1);
ipq5332_ppe_reg_write(IPQ5332_PPE_L1_E_SP_CFG_TBL + (id * 0x80), id * 2 + 1);
ipq5332_ppe_reg_write(IPQ5332_PPE_L0_E_SP_CFG_TBL +
(id * 0x80), id * 2 + 1);
ipq5332_ppe_reg_write(IPQ5332_PPE_L1_E_SP_CFG_TBL +
(id * 0x80), id * 2 + 1);
}
static void ppe_port_mux_set(int port_id, int port_type, int mode)
@ -611,13 +647,14 @@ static void ppe_port_mux_set(int port_id, int port_type, int mode)
else if (port_type == PORT_XGMAC_TYPE)
mux_mac_type = IPQ5332_PORT_MUX_XMAC_TYPE;
else
printf("\nAttention!!!..Port type configured wrongly..port_id = %d, mode = %d, port_type = %d",
port_id, mode, port_type);
printf("\nAttention!!!..Port type configured wrongly.."
"port_id = %d, mode = %d, port_type = %d",
port_id, mode, port_type);
port_mux_ctrl.val = 0;
ipq5332_ppe_reg_read(IPQ5332_PORT_MUX_CTRL, &(port_mux_ctrl.val));
pr_debug("\nBEFORE UPDATE: Port MUX CTRL value is %u", port_mux_ctrl.val);
pr_debug("\nBEFORE UPDATE: Port MUX CTRL value is %u",
port_mux_ctrl.val);
switch (port_id) {
case PORT1:
@ -633,7 +670,8 @@ static void ppe_port_mux_set(int port_id, int port_type, int mode)
}
ipq5332_ppe_reg_write(IPQ5332_PORT_MUX_CTRL, port_mux_ctrl.val);
pr_debug("\nAFTER UPDATE: Port MUX CTRL value is %u", port_mux_ctrl.val);
pr_debug("\nAFTER UPDATE: Port MUX CTRL value is %u",
port_mux_ctrl.val);
}
void ppe_port_mux_mac_type_set(int port_id, int mode)
@ -653,8 +691,9 @@ void ppe_port_mux_mac_type_set(int port_id, int mode)
port_type = PORT_XGMAC_TYPE;
break;
default:
printf("\nError during port_type set: mode is %d, port_id is: %d",
mode, port_id);
printf("\nError during port_type set: mode is %d, "
"port_id is: %d",
mode, port_id);
return;
}
ppe_port_mux_set(port_id, port_type, mode);
@ -701,6 +740,7 @@ void ipq5332_ppe_provision_init(void)
{
int i;
uint32_t queue;
uint32_t bridge_ctrl;
/* tdm/sched configuration */
ipq5332_ppe_tdm_configuration();
@ -709,28 +749,20 @@ void ipq5332_ppe_provision_init(void)
/* Add CPU port 0 to VSI 2 */
ipq5332_ppe_vp_port_tbl_set(0, 2);
/* Add port 1 - 4 to VSI 2 */
/* Add port 1 - 2 to VSI 2 */
ipq5332_ppe_vp_port_tbl_set(1, 2);
ipq5332_ppe_vp_port_tbl_set(2, 2);
ipq5332_ppe_vp_port_tbl_set(3, 2);
ipq5332_ppe_vp_port_tbl_set(4, 2);
ipq5332_ppe_vp_port_tbl_set(5, 2);
ipq5332_ppe_vp_port_tbl_set(6, 2);
#else
ipq5332_ppe_vp_port_tbl_set(1, 2);
ipq5332_ppe_vp_port_tbl_set(2, 3);
ipq5332_ppe_vp_port_tbl_set(3, 4);
ipq5332_ppe_vp_port_tbl_set(4, 5);
ipq5332_ppe_vp_port_tbl_set(5, 6);
ipq5332_ppe_vp_port_tbl_set(6, 7);
#endif
/* Unicast priority map */
ipq5332_ppe_reg_write(IPQ5332_PPE_QM_UPM_TBL, 0);
/* Port0 - 7 unicast queue settings */
for (i = 0; i < 8; i++) {
/* Port0 - 3 unicast queue settings */
for (i = 0; i < 3; i++) {
if (i == 0)
queue = 0;
else
@ -748,7 +780,7 @@ void ipq5332_ppe_provision_init(void)
ipq5332_ppe_reg_write(0x403000, 0x00401000);
/* Port1 - 7 multicast queue */
for (i = 1; i < 8; i++) {
for (i = 1; i < 3; i++) {
ipq5332_ppe_reg_write(0x409100 + ((i - 1) * 0x40), i);
ipq5332_ppe_reg_write(0x403100 + ((i - 1) * 0x40), 0x401000 | i);
}
@ -771,57 +803,51 @@ void ipq5332_ppe_provision_init(void)
/*
* Port0 - TX_EN is set by default, Port1 - LRN_EN is set
* Port0 -> CPU Port
* Port1-6 -> Ethernet Ports
* Port7 -> EIP197
* Port1-2 -> Ethernet Ports
*/
for (i = 0; i < 8; i++) {
if (i == 0)
ipq5332_ppe_reg_write(IPQ5332_PPE_PORT_BRIDGE_CTRL_OFFSET + (i * 4),
for (i = 0; i < 3; i++) {
bridge_ctrl = IPQ5332_PPE_PORT_BRIDGE_CTRL_OFFSET;
if (i == 0) {
ipq5332_ppe_reg_write(bridge_ctrl + (i * 4),
IPQ5332_PPE_PORT_BRIDGE_CTRL_PROMISC_EN |
IPQ5332_PPE_PORT_BRIDGE_CTRL_TXMAC_EN |
IPQ5332_PPE_PORT_BRIDGE_CTRL_PORT_ISOLATION_BMP |
IPQ5332_PPE_PORT_BRIDGE_CTRL_STATION_LRN_EN |
IPQ5332_PPE_PORT_BRIDGE_CTRL_NEW_ADDR_LRN_EN);
else if (i == 7)
ipq5332_ppe_reg_write(IPQ5332_PPE_PORT_BRIDGE_CTRL_OFFSET + (i * 4),
IPQ5332_PPE_PORT_BRIDGE_CTRL_PROMISC_EN |
IPQ5332_PPE_PORT_BRIDGE_CTRL_PORT_ISOLATION_BMP |
IPQ5332_PPE_PORT_BRIDGE_CTRL_STATION_LRN_EN |
IPQ5332_PPE_PORT_BRIDGE_CTRL_NEW_ADDR_LRN_EN);
else
ipq5332_ppe_reg_write(IPQ5332_PPE_PORT_BRIDGE_CTRL_OFFSET + (i * 4),
} else {
ipq5332_ppe_reg_write(bridge_ctrl + (i * 4),
IPQ5332_PPE_PORT_BRIDGE_CTRL_PROMISC_EN |
IPQ5332_PPE_PORT_BRIDGE_CTRL_PORT_ISOLATION_BMP);
}
}
/* Global learning */
ipq5332_ppe_reg_write(0x060038, 0xc0);
#ifdef CONFIG_IPQ5332_BRIDGED_MODE
ipq5332_vsi_setup(2, 0x7f);
ipq5332_vsi_setup(2, 0x7);
#else
ipq5332_vsi_setup(2, 0x03);
ipq5332_vsi_setup(3, 0x05);
ipq5332_vsi_setup(4, 0x09);
ipq5332_vsi_setup(5, 0x11);
ipq5332_vsi_setup(6, 0x21);
ipq5332_vsi_setup(7, 0x41);
#endif
/* Port 0-7 STP */
for (i = 0; i < 8; i++)
/* Port 0-3 STP */
for (i = 0; i < 3; i++)
ipq5332_ppe_reg_write(IPQ5332_PPE_STP_BASE + (0x4 * i), 0x3);
ipq5332_ppe_interface_mode_init();
/* Port 1-2 disable */
for (i = 0; i < 2; i++) {
ipq5332_gmac_port_disable(i);
ppe_port_bridge_txmac_set(i + 1, 1);
ppe_port_bridge_txmac_set(i, 1);
}
/* Allowing DHCP packets */
ipq5332_ppe_acl_set(0, ADPT_ACL_HPPE_IPV4_DIP_RULE, UDP_PKT, 67, 0xffff, 0, 0);
ipq5332_ppe_acl_set(1, ADPT_ACL_HPPE_IPV4_DIP_RULE, UDP_PKT, 68, 0xffff, 0, 0);
ipq5332_ppe_acl_set(0, ADPT_ACL_HPPE_IPV4_DIP_RULE, UDP_PKT, 67,
0xffff, 0, 0);
ipq5332_ppe_acl_set(1, ADPT_ACL_HPPE_IPV4_DIP_RULE, UDP_PKT, 68,
0xffff, 0, 0);
/* Dropping all the UDP packets */
ipq5332_ppe_acl_set(2, ADPT_ACL_HPPE_IPV4_DIP_RULE, UDP_PKT, 0, 0, 0, 1);
ipq5332_ppe_acl_set(2, ADPT_ACL_HPPE_IPV4_DIP_RULE, UDP_PKT, 0, 0, 0,
1);
}

View file

@ -115,9 +115,8 @@ union ipo_action_u {
#define IPQ5332_PORT_MUX_CTRL_INC 0x4
#define IPQ5332_PORT_MUX_CTRL_DEFAULT 0x0
#define PORT_PHY_STATUS_ADDRESS 0x44
#define PORT_PHY_STATUS_PORT5_1_OFFSET 8
#define PORT_PHY_STATUS_PORT6_OFFSET 16
#define PORT_PHY_STATUS_ADDRESS 0x40
#define PORT_PHY_STATUS_PORT2_OFFSET 8
#define IPQ5332_PPE_IPE_L3_BASE_ADDR 0x200000
#define IPQ5332_PPE_L3_VP_PORT_TBL_ADDR (IPQ5332_PPE_IPE_L3_BASE_ADDR + 0x4000)
@ -260,3 +259,7 @@ union ipo_action_u {
#define IPO_ACTION_ADDRESS 0x8000
#define IPO_ACTION_INC 0x20
#define NSS_CC_PORT1_RX_CMD_RCGR 0x39B00450
#define GCC_PORT1_ARES 1 << 2
#define NSS_CC_PPE_BCR 0x39B003E4

View file

@ -72,8 +72,9 @@ static int ppe_uniphy_calibration(uint32_t uniphy_index)
printf("uniphy callibration time out!\n");
return -1;
}
reg_value = readl(PPE_UNIPHY_BASE + (uniphy_index * PPE_UNIPHY_REG_INC)
+ PPE_UNIPHY_OFFSET_CALIB_4);
reg_value = readl(PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC)
+ PPE_UNIPHY_OFFSET_CALIB_4);
calibration_done = (reg_value >> 0x7) & 0x1;
}
@ -82,70 +83,41 @@ static int ppe_uniphy_calibration(uint32_t uniphy_index)
static void ppe_uniphy_reset(enum uniphy_reset_type rst_type, bool enable)
{
uint32_t mode, node;
uint32_t reg_val, reg_val1;
uint32_t reg_val;
switch(rst_type) {
case UNIPHY0_SOFT_RESET:
node = fdt_path_offset(gd->fdt_blob, "/ess-switch");
if (node < 0) {
printf("\nError: ess-switch not specified in dts");
return;
}
mode = fdtdec_get_uint(gd->fdt_blob, node, "switch_mac_mode1", -1);
if (mode < 0) {
printf("\nError: switch_mac_mode1 not specified in dts");
return;
}
reg_val = readl(GCC_UNIPHY0_MISC);
reg_val1 = readl(NSS_CC_UNIPHY_MISC_RESET);
if (mode == EPORT_WRAPPER_MAX) {
if (enable) {
reg_val |= 0x1;
reg_val1 |= 0xffc000;
} else {
reg_val &= ~0x1;
reg_val1 &= ~0xffc000;
}
reg_val = readl(GCC_UNIPHY0_SYS_CBCR);
if (enable) {
reg_val |= 0x4;
} else {
if (enable) {
reg_val |= 0x1;
reg_val1 |= 0xff0000;
} else {
reg_val &= ~0x1;
reg_val1 &= ~0xff0000;
}
reg_val &= ~0x4;
}
writel(reg_val, GCC_UNIPHY0_MISC);
writel(reg_val1, NSS_CC_UNIPHY_MISC_RESET);
writel(reg_val, GCC_UNIPHY0_SYS_CBCR);
break;
case UNIPHY0_XPCS_RESET:
reg_val = readl(GCC_UNIPHY0_MISC);
if (enable)
reg_val |= 0x4;
reg_val |= 0x1;
else
reg_val &= ~0x4;
reg_val &= ~0x1;
writel(reg_val, GCC_UNIPHY0_MISC);
break;
case UNIPHY1_SOFT_RESET:
reg_val = readl(GCC_UNIPHY0_MISC + GCC_UNIPHY_REG_INC);
reg_val1 = readl(NSS_CC_UNIPHY_MISC_RESET);
reg_val = readl(GCC_UNIPHY1_SYS_CBCR);
if (enable) {
reg_val |= 0x1;
reg_val1 |= 0xC000;
reg_val |= 0x4;
} else {
reg_val &= ~0x1;
reg_val1 &= ~0xC000;
reg_val &= ~0x4;
}
writel(reg_val, GCC_UNIPHY0_MISC + GCC_UNIPHY_REG_INC);
writel(reg_val1, NSS_CC_UNIPHY_MISC_RESET);
writel(reg_val, GCC_UNIPHY1_SYS_CBCR);
break;
case UNIPHY1_XPCS_RESET:
reg_val = readl(GCC_UNIPHY0_MISC + GCC_UNIPHY_REG_INC);
if (enable)
reg_val |= 0x4;
reg_val |= 0x1;
else
reg_val &= ~0x4;
reg_val &= ~0x1;
writel(reg_val, GCC_UNIPHY0_MISC + GCC_UNIPHY_REG_INC);
break;
default:
@ -218,22 +190,27 @@ static void ppe_uniphy_sgmii_mode_set(uint32_t uniphy_index, uint32_t mode)
{
if ((uniphy_index == 1) && (mode == EPORT_WRAPPER_SGMII_PLUS)) {
writel(UNIPHY_MISC_SRC_PHY_MODE, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC) + UNIPHY_MISC_SOURCE_SELECTION_REG_OFFSET);
(uniphy_index * PPE_UNIPHY_REG_INC) +
UNIPHY_MISC_SOURCE_SELECTION_REG_OFFSET);
ppe_uniphy_set_forceMode(uniphy_index);
writel(UNIPHY_MISC2_REG_SGMII_PLUS_MODE, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC) + UNIPHY_MISC2_REG_OFFSET);
(uniphy_index * PPE_UNIPHY_REG_INC) +
UNIPHY_MISC2_REG_OFFSET);
} else {
writel(UNIPHY_MISC2_REG_SGMII_MODE, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC) + UNIPHY_MISC2_REG_OFFSET);
(uniphy_index * PPE_UNIPHY_REG_INC) +
UNIPHY_MISC2_REG_OFFSET);
}
writel(UNIPHY_PLL_RESET_REG_VALUE, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC) + UNIPHY_PLL_RESET_REG_OFFSET);
(uniphy_index * PPE_UNIPHY_REG_INC) +
UNIPHY_PLL_RESET_REG_OFFSET);
mdelay(500);
writel(UNIPHY_PLL_RESET_REG_DEFAULT_VALUE, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC) + UNIPHY_PLL_RESET_REG_OFFSET);
(uniphy_index * PPE_UNIPHY_REG_INC) +
UNIPHY_PLL_RESET_REG_OFFSET);
mdelay(500);
if (uniphy_index == 0)
ppe_uniphy_reset(UNIPHY0_XPCS_RESET, true);
@ -248,23 +225,27 @@ static void ppe_uniphy_sgmii_mode_set(uint32_t uniphy_index, uint32_t mode)
switch (mode) {
case EPORT_WRAPPER_SGMII_FIBER:
writel(0x400, PPE_UNIPHY_BASE + (uniphy_index * PPE_UNIPHY_REG_INC)
writel(0x400, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC)
+ PPE_UNIPHY_MODE_CONTROL);
break;
case EPORT_WRAPPER_SGMII0_RGMII4:
case EPORT_WRAPPER_SGMII1_RGMII4:
case EPORT_WRAPPER_SGMII4_RGMII4:
writel(0x420, PPE_UNIPHY_BASE + (uniphy_index * PPE_UNIPHY_REG_INC)
writel(0x420, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC)
+ PPE_UNIPHY_MODE_CONTROL);
break;
case EPORT_WRAPPER_SGMII_PLUS:
if (uniphy_index == 1)
writel(0x20, PPE_UNIPHY_BASE + (uniphy_index * PPE_UNIPHY_REG_INC)
writel(0x20, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC)
+ PPE_UNIPHY_MODE_CONTROL);
else
writel(0x820, PPE_UNIPHY_BASE + (uniphy_index * PPE_UNIPHY_REG_INC)
writel(0x820, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC)
+ PPE_UNIPHY_MODE_CONTROL);
break;
@ -347,10 +328,12 @@ static void ppe_uniphy_usxgmii_mode_set(uint32_t uniphy_index)
writel(UNIPHY_MISC2_REG_VALUE, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC) + UNIPHY_MISC2_REG_OFFSET);
writel(UNIPHY_PLL_RESET_REG_VALUE, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC) + UNIPHY_PLL_RESET_REG_OFFSET);
(uniphy_index * PPE_UNIPHY_REG_INC) +
UNIPHY_PLL_RESET_REG_OFFSET);
mdelay(500);
writel(UNIPHY_PLL_RESET_REG_DEFAULT_VALUE, PPE_UNIPHY_BASE +
(uniphy_index * PPE_UNIPHY_REG_INC) + UNIPHY_PLL_RESET_REG_OFFSET);
(uniphy_index * PPE_UNIPHY_REG_INC) +
UNIPHY_PLL_RESET_REG_OFFSET);
mdelay(500);
if (uniphy_index == 0)

View file

@ -72,6 +72,8 @@
#define VR_MII_AN_INTR_STS 0x1f8002
#define CL37_ANCMPLT_INTR (1 << 0)
#define GCC_UNIPHY0_MISC 0x1816050
enum uniphy_reset_type {
UNIPHY0_SOFT_RESET = 0,
UNIPHY0_XPCS_RESET,