avionic design with actual uboot and tooling
submodule of avionic design uboot bootloader and with included tools to get you started , read readme.md and readme-tk1-loader.md
This commit is contained in:
9
u-boot/drivers/net/ldpaa_eth/Makefile
Normal file
9
u-boot/drivers/net/ldpaa_eth/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Copyright 2014 Freescale Semiconductor, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
|
||||
obj-y += ldpaa_wriop.o
|
||||
obj-y += ldpaa_eth.o
|
||||
obj-$(CONFIG_LS2080A) += ls2080a.o
|
||||
1031
u-boot/drivers/net/ldpaa_eth/ldpaa_eth.c
Normal file
1031
u-boot/drivers/net/ldpaa_eth/ldpaa_eth.c
Normal file
File diff suppressed because it is too large
Load Diff
151
u-boot/drivers/net/ldpaa_eth/ldpaa_eth.h
Normal file
151
u-boot/drivers/net/ldpaa_eth/ldpaa_eth.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freescale Semiconductor
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef __LDPAA_ETH_H
|
||||
#define __LDPAA_ETH_H
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <fsl-mc/fsl_mc.h>
|
||||
#include <fsl-mc/fsl_dpaa_fd.h>
|
||||
#include <fsl-mc/fsl_dprc.h>
|
||||
#include <fsl-mc/fsl_dpni.h>
|
||||
#include <fsl-mc/fsl_dpbp.h>
|
||||
#include <fsl-mc/fsl_dpio.h>
|
||||
#include <fsl-mc/fsl_qbman_portal.h>
|
||||
#include <fsl-mc/fsl_mc_private.h>
|
||||
|
||||
|
||||
enum ldpaa_eth_type {
|
||||
LDPAA_ETH_1G_E,
|
||||
LDPAA_ETH_10G_E,
|
||||
};
|
||||
|
||||
/* Arbitrary values for now, but we'll need to tune */
|
||||
#define LDPAA_ETH_NUM_BUFS (7 * 7)
|
||||
#define LDPAA_ETH_REFILL_THRESH (LDPAA_ETH_NUM_BUFS/2)
|
||||
#define LDPAA_ETH_RX_BUFFER_SIZE 2048
|
||||
|
||||
/* Hardware requires alignment for buffer address and length: 256-byte
|
||||
* for ingress, 64-byte for egress. Using 256 for both.
|
||||
*/
|
||||
#define LDPAA_ETH_BUF_ALIGN 256
|
||||
|
||||
/* So far we're only accomodating a skb backpointer in the frame's
|
||||
* software annotation, but the hardware options are either 0 or 64.
|
||||
*/
|
||||
#define LDPAA_ETH_SWA_SIZE 64
|
||||
|
||||
/* Annotation valid bits in FD FRC */
|
||||
#define LDPAA_FD_FRC_FASV 0x8000
|
||||
#define LDPAA_FD_FRC_FAEADV 0x4000
|
||||
#define LDPAA_FD_FRC_FAPRV 0x2000
|
||||
#define LDPAA_FD_FRC_FAIADV 0x1000
|
||||
#define LDPAA_FD_FRC_FASWOV 0x0800
|
||||
#define LDPAA_FD_FRC_FAICFDV 0x0400
|
||||
|
||||
/* Annotation bits in FD CTRL */
|
||||
#define LDPAA_FD_CTRL_ASAL 0x00020000 /* ASAL = 128 */
|
||||
#define LDPAA_FD_CTRL_PTA 0x00800000
|
||||
#define LDPAA_FD_CTRL_PTV1 0x00400000
|
||||
|
||||
/* TODO: we may want to move this and other WRIOP related defines
|
||||
* to a separate header
|
||||
*/
|
||||
/* Frame annotation status */
|
||||
struct ldpaa_fas {
|
||||
u8 reserved;
|
||||
u8 ppid;
|
||||
__le16 ifpid;
|
||||
__le32 status;
|
||||
} __packed;
|
||||
|
||||
/* Debug frame, otherwise supposed to be discarded */
|
||||
#define LDPAA_ETH_FAS_DISC 0x80000000
|
||||
/* MACSEC frame */
|
||||
#define LDPAA_ETH_FAS_MS 0x40000000
|
||||
#define LDPAA_ETH_FAS_PTP 0x08000000
|
||||
/* Ethernet multicast frame */
|
||||
#define LDPAA_ETH_FAS_MC 0x04000000
|
||||
/* Ethernet broadcast frame */
|
||||
#define LDPAA_ETH_FAS_BC 0x02000000
|
||||
#define LDPAA_ETH_FAS_KSE 0x00040000
|
||||
#define LDPAA_ETH_FAS_EOFHE 0x00020000
|
||||
#define LDPAA_ETH_FAS_MNLE 0x00010000
|
||||
#define LDPAA_ETH_FAS_TIDE 0x00008000
|
||||
#define LDPAA_ETH_FAS_PIEE 0x00004000
|
||||
/* Frame length error */
|
||||
#define LDPAA_ETH_FAS_FLE 0x00002000
|
||||
/* Frame physical error; our favourite pastime */
|
||||
#define LDPAA_ETH_FAS_FPE 0x00001000
|
||||
#define LDPAA_ETH_FAS_PTE 0x00000080
|
||||
#define LDPAA_ETH_FAS_ISP 0x00000040
|
||||
#define LDPAA_ETH_FAS_PHE 0x00000020
|
||||
#define LDPAA_ETH_FAS_BLE 0x00000010
|
||||
/* L3 csum validation performed */
|
||||
#define LDPAA_ETH_FAS_L3CV 0x00000008
|
||||
/* L3 csum error */
|
||||
#define LDPAA_ETH_FAS_L3CE 0x00000004
|
||||
/* L4 csum validation performed */
|
||||
#define LDPAA_ETH_FAS_L4CV 0x00000002
|
||||
/* L4 csum error */
|
||||
#define LDPAA_ETH_FAS_L4CE 0x00000001
|
||||
/* These bits always signal errors */
|
||||
#define LDPAA_ETH_RX_ERR_MASK (LDPAA_ETH_FAS_DISC | \
|
||||
LDPAA_ETH_FAS_KSE | \
|
||||
LDPAA_ETH_FAS_EOFHE | \
|
||||
LDPAA_ETH_FAS_MNLE | \
|
||||
LDPAA_ETH_FAS_TIDE | \
|
||||
LDPAA_ETH_FAS_PIEE | \
|
||||
LDPAA_ETH_FAS_FLE | \
|
||||
LDPAA_ETH_FAS_FPE | \
|
||||
LDPAA_ETH_FAS_PTE | \
|
||||
LDPAA_ETH_FAS_ISP | \
|
||||
LDPAA_ETH_FAS_PHE | \
|
||||
LDPAA_ETH_FAS_BLE | \
|
||||
LDPAA_ETH_FAS_L3CE | \
|
||||
LDPAA_ETH_FAS_L4CE)
|
||||
/* Unsupported features in the ingress */
|
||||
#define LDPAA_ETH_RX_UNSUPP_MASK LDPAA_ETH_FAS_MS
|
||||
/* TODO trim down the bitmask; not all of them apply to Tx-confirm */
|
||||
#define LDPAA_ETH_TXCONF_ERR_MASK (LDPAA_ETH_FAS_KSE | \
|
||||
LDPAA_ETH_FAS_EOFHE | \
|
||||
LDPAA_ETH_FAS_MNLE | \
|
||||
LDPAA_ETH_FAS_TIDE)
|
||||
|
||||
struct ldpaa_eth_priv {
|
||||
struct eth_device *net_dev;
|
||||
int dpmac_id;
|
||||
uint16_t dpmac_handle;
|
||||
|
||||
uint16_t tx_data_offset;
|
||||
|
||||
uint32_t rx_dflt_fqid;
|
||||
uint16_t tx_qdid;
|
||||
uint16_t tx_flow_id;
|
||||
|
||||
enum ldpaa_eth_type type; /* 1G or 10G ethernet */
|
||||
struct phy_device *phydev;
|
||||
};
|
||||
|
||||
struct dprc_endpoint dpmac_endpoint;
|
||||
struct dprc_endpoint dpni_endpoint;
|
||||
|
||||
extern struct fsl_mc_io *dflt_mc_io;
|
||||
extern struct fsl_dpbp_obj *dflt_dpbp;
|
||||
extern struct fsl_dpio_obj *dflt_dpio;
|
||||
extern struct fsl_dpni_obj *dflt_dpni;
|
||||
extern uint16_t dflt_dprc_handle;
|
||||
|
||||
static void ldpaa_dpbp_drain_cnt(int count);
|
||||
static void ldpaa_dpbp_drain(void);
|
||||
static int ldpaa_dpbp_seed(uint16_t bpid);
|
||||
static void ldpaa_dpbp_free(void);
|
||||
static int ldpaa_dpni_setup(struct ldpaa_eth_priv *priv);
|
||||
static int ldpaa_dpbp_setup(void);
|
||||
static int ldpaa_dpni_bind(struct ldpaa_eth_priv *priv);
|
||||
static int ldpaa_dpmac_setup(struct ldpaa_eth_priv *priv);
|
||||
static int ldpaa_dpmac_bind(struct ldpaa_eth_priv *priv);
|
||||
#endif /* __LDPAA_H */
|
||||
157
u-boot/drivers/net/ldpaa_eth/ldpaa_wriop.c
Normal file
157
u-boot/drivers/net/ldpaa_eth/ldpaa_wriop.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Freescale Semiconductor
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/types.h>
|
||||
#include <malloc.h>
|
||||
#include <net.h>
|
||||
#include <linux/compat.h>
|
||||
#include <asm/arch/fsl_serdes.h>
|
||||
#include <fsl-mc/ldpaa_wriop.h>
|
||||
|
||||
struct wriop_dpmac_info dpmac_info[NUM_WRIOP_PORTS];
|
||||
|
||||
__weak phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtc)
|
||||
{
|
||||
return PHY_INTERFACE_MODE_NONE;
|
||||
}
|
||||
|
||||
void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl)
|
||||
{
|
||||
phy_interface_t enet_if;
|
||||
|
||||
dpmac_info[dpmac_id].enabled = 0;
|
||||
dpmac_info[dpmac_id].id = 0;
|
||||
dpmac_info[dpmac_id].phy_addr = -1;
|
||||
dpmac_info[dpmac_id].enet_if = PHY_INTERFACE_MODE_NONE;
|
||||
|
||||
enet_if = wriop_dpmac_enet_if(dpmac_id, lane_prtcl);
|
||||
if (enet_if != PHY_INTERFACE_MODE_NONE) {
|
||||
dpmac_info[dpmac_id].enabled = 1;
|
||||
dpmac_info[dpmac_id].id = dpmac_id;
|
||||
dpmac_info[dpmac_id].enet_if = enet_if;
|
||||
}
|
||||
}
|
||||
|
||||
/*TODO what it do */
|
||||
static int wriop_dpmac_to_index(int dpmac_id)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
|
||||
if (dpmac_info[i].id == dpmac_id)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wriop_disable_dpmac(int dpmac_id)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return;
|
||||
|
||||
dpmac_info[i].enabled = 0;
|
||||
wriop_dpmac_disable(dpmac_id);
|
||||
}
|
||||
|
||||
void wriop_enable_dpmac(int dpmac_id)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return;
|
||||
|
||||
dpmac_info[i].enabled = 1;
|
||||
wriop_dpmac_enable(dpmac_id);
|
||||
}
|
||||
|
||||
u8 wriop_is_enabled_dpmac(int dpmac_id)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return -1;
|
||||
|
||||
return dpmac_info[i].enabled;
|
||||
}
|
||||
|
||||
|
||||
void wriop_set_mdio(int dpmac_id, struct mii_dev *bus)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return;
|
||||
|
||||
dpmac_info[i].bus = bus;
|
||||
}
|
||||
|
||||
struct mii_dev *wriop_get_mdio(int dpmac_id)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return NULL;
|
||||
|
||||
return dpmac_info[i].bus;
|
||||
}
|
||||
|
||||
void wriop_set_phy_address(int dpmac_id, int address)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return;
|
||||
|
||||
dpmac_info[i].phy_addr = address;
|
||||
}
|
||||
|
||||
int wriop_get_phy_address(int dpmac_id)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return -1;
|
||||
|
||||
return dpmac_info[i].phy_addr;
|
||||
}
|
||||
|
||||
void wriop_set_phy_dev(int dpmac_id, struct phy_device *phydev)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return;
|
||||
|
||||
dpmac_info[i].phydev = phydev;
|
||||
}
|
||||
|
||||
struct phy_device *wriop_get_phy_dev(int dpmac_id)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return NULL;
|
||||
|
||||
return dpmac_info[i].phydev;
|
||||
}
|
||||
|
||||
phy_interface_t wriop_get_enet_if(int dpmac_id)
|
||||
{
|
||||
int i = wriop_dpmac_to_index(dpmac_id);
|
||||
|
||||
if (i == -1)
|
||||
return PHY_INTERFACE_MODE_NONE;
|
||||
|
||||
if (dpmac_info[i].enabled)
|
||||
return dpmac_info[i].enet_if;
|
||||
|
||||
return PHY_INTERFACE_MODE_NONE;
|
||||
}
|
||||
81
u-boot/drivers/net/ldpaa_eth/ls2080a.c
Normal file
81
u-boot/drivers/net/ldpaa_eth/ls2080a.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2015 Freescale Semiconductor, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
#include <common.h>
|
||||
#include <phy.h>
|
||||
#include <fsl-mc/ldpaa_wriop.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/arch/fsl_serdes.h>
|
||||
|
||||
u32 dpmac_to_devdisr[] = {
|
||||
[WRIOP1_DPMAC1] = FSL_CHASSIS3_DEVDISR2_DPMAC1,
|
||||
[WRIOP1_DPMAC2] = FSL_CHASSIS3_DEVDISR2_DPMAC2,
|
||||
[WRIOP1_DPMAC3] = FSL_CHASSIS3_DEVDISR2_DPMAC3,
|
||||
[WRIOP1_DPMAC4] = FSL_CHASSIS3_DEVDISR2_DPMAC4,
|
||||
[WRIOP1_DPMAC5] = FSL_CHASSIS3_DEVDISR2_DPMAC5,
|
||||
[WRIOP1_DPMAC6] = FSL_CHASSIS3_DEVDISR2_DPMAC6,
|
||||
[WRIOP1_DPMAC7] = FSL_CHASSIS3_DEVDISR2_DPMAC7,
|
||||
[WRIOP1_DPMAC8] = FSL_CHASSIS3_DEVDISR2_DPMAC8,
|
||||
[WRIOP1_DPMAC9] = FSL_CHASSIS3_DEVDISR2_DPMAC9,
|
||||
[WRIOP1_DPMAC10] = FSL_CHASSIS3_DEVDISR2_DPMAC10,
|
||||
[WRIOP1_DPMAC11] = FSL_CHASSIS3_DEVDISR2_DPMAC11,
|
||||
[WRIOP1_DPMAC12] = FSL_CHASSIS3_DEVDISR2_DPMAC12,
|
||||
[WRIOP1_DPMAC13] = FSL_CHASSIS3_DEVDISR2_DPMAC13,
|
||||
[WRIOP1_DPMAC14] = FSL_CHASSIS3_DEVDISR2_DPMAC14,
|
||||
[WRIOP1_DPMAC15] = FSL_CHASSIS3_DEVDISR2_DPMAC15,
|
||||
[WRIOP1_DPMAC16] = FSL_CHASSIS3_DEVDISR2_DPMAC16,
|
||||
[WRIOP1_DPMAC17] = FSL_CHASSIS3_DEVDISR2_DPMAC17,
|
||||
[WRIOP1_DPMAC18] = FSL_CHASSIS3_DEVDISR2_DPMAC18,
|
||||
[WRIOP1_DPMAC19] = FSL_CHASSIS3_DEVDISR2_DPMAC19,
|
||||
[WRIOP1_DPMAC20] = FSL_CHASSIS3_DEVDISR2_DPMAC20,
|
||||
[WRIOP1_DPMAC21] = FSL_CHASSIS3_DEVDISR2_DPMAC21,
|
||||
[WRIOP1_DPMAC22] = FSL_CHASSIS3_DEVDISR2_DPMAC22,
|
||||
[WRIOP1_DPMAC23] = FSL_CHASSIS3_DEVDISR2_DPMAC23,
|
||||
[WRIOP1_DPMAC24] = FSL_CHASSIS3_DEVDISR2_DPMAC24,
|
||||
};
|
||||
|
||||
static int is_device_disabled(int dpmac_id)
|
||||
{
|
||||
struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
|
||||
u32 devdisr2 = in_le32(&gur->devdisr2);
|
||||
|
||||
return dpmac_to_devdisr[dpmac_id] & devdisr2;
|
||||
}
|
||||
|
||||
void wriop_dpmac_disable(int dpmac_id)
|
||||
{
|
||||
struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
|
||||
|
||||
setbits_le32(&gur->devdisr2, dpmac_to_devdisr[dpmac_id]);
|
||||
}
|
||||
|
||||
void wriop_dpmac_enable(int dpmac_id)
|
||||
{
|
||||
struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
|
||||
|
||||
clrbits_le32(&gur->devdisr2, dpmac_to_devdisr[dpmac_id]);
|
||||
}
|
||||
|
||||
phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl)
|
||||
{
|
||||
enum srds_prtcl;
|
||||
|
||||
if (is_device_disabled(dpmac_id + 1))
|
||||
return PHY_INTERFACE_MODE_NONE;
|
||||
|
||||
if (lane_prtcl >= SGMII1 && lane_prtcl <= SGMII16)
|
||||
return PHY_INTERFACE_MODE_SGMII;
|
||||
|
||||
if (lane_prtcl >= XFI1 && lane_prtcl <= XFI8)
|
||||
return PHY_INTERFACE_MODE_XGMII;
|
||||
|
||||
if (lane_prtcl >= XAUI1 && lane_prtcl <= XAUI2)
|
||||
return PHY_INTERFACE_MODE_XGMII;
|
||||
|
||||
if (lane_prtcl >= QSGMII_A && lane_prtcl <= QSGMII_D)
|
||||
return PHY_INTERFACE_MODE_QSGMII;
|
||||
|
||||
return PHY_INTERFACE_MODE_NONE;
|
||||
}
|
||||
Reference in New Issue
Block a user