]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/tsec.h
arm: fixloop(): do not use r8 for relocation
[karo-tx-uboot.git] / include / tsec.h
index c05b5f090ea35c260e5c06a9d4c9f38139e170c0..1e903659ebacfd63157812122837e0ee96add75b 100644 (file)
@@ -7,7 +7,7 @@
  *  terms of the GNU Public License, Version 2, incorporated
  *  herein by reference.
  *
- * Copyright 2004, 2007 Freescale Semiconductor, Inc.
+ * Copyright 2004, 2007, 2009  Freescale Semiconductor, Inc.
  * (C) Copyright 2003, Motorola, Inc.
  * maintained by Xianghua Xiao (x.xiao@motorola.com)
  * author Andy Fleming
 #include <net.h>
 #include <config.h>
 
-#ifndef CFG_TSEC1_OFFSET
-    #define CFG_TSEC1_OFFSET   (0x24000)
-#endif
-
-#define TSEC_SIZE      0x01000
-
-/* FIXME:  Should these be pushed back to 83xx and 85xx config files? */
-#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) \
-       || defined(CONFIG_MPC83XX)
-    #define TSEC_BASE_ADDR     (CFG_IMMR + CFG_TSEC1_OFFSET)
-#endif
+#define TSEC_SIZE              0x01000
+#define TSEC_MDIO_OFFSET       0x01000
 
 #define STD_TSEC_INFO(num) \
 {                      \
        .regs = (tsec_t *)(TSEC_BASE_ADDR + ((num - 1) * TSEC_SIZE)), \
-       .miiregs = (tsec_t *)TSEC_BASE_ADDR, \
+       .miiregs = (tsec_mdio_t *)(MDIO_BASE_ADDR), \
+       .miiregs_sgmii = (tsec_mdio_t *)(MDIO_BASE_ADDR \
+                                        + (num - 1) * TSEC_MDIO_OFFSET), \
        .devname = CONFIG_TSEC##num##_NAME, \
        .phyaddr = TSEC##num##_PHY_ADDR, \
        .flags = TSEC##num##_FLAGS \
 #define SET_STD_TSEC_INFO(x, num) \
 {                      \
        x.regs = (tsec_t *)(TSEC_BASE_ADDR + ((num - 1) * TSEC_SIZE)); \
-       x.miiregs = (tsec_t *)TSEC_BASE_ADDR; \
+       x.miiregs = (tsec_mdio_t *)(MDIO_BASE_ADDR); \
+       x.miiregs_sgmii = (tsec_mdio_t *)(MDIO_BASE_ADDR \
+                                         + (num - 1) * TSEC_MDIO_OFFSET); \
        x.devname = CONFIG_TSEC##num##_NAME; \
        x.phyaddr = TSEC##num##_PHY_ADDR; \
        x.flags = TSEC##num##_FLAGS;\
 }
 
-
-
 #define MAC_ADDR_LEN 6
 
 /* #define TSEC_TIMEOUT        1000000 */
 
 #define PHY_AUTONEGOTIATE_TIMEOUT      5000 /* in ms */
 
+/* TBI register addresses */
+#define TBI_CR                 0x00
+#define TBI_SR                 0x01
+#define TBI_ANA                        0x04
+#define TBI_ANLPBPA            0x05
+#define TBI_ANEX               0x06
+#define TBI_TBICON             0x11
+
+/* TBI MDIO register bit fields*/
+#define TBICON_CLK_SELECT      0x0020
+#define TBIANA_ASYMMETRIC_PAUSE 0x0100
+#define TBIANA_SYMMETRIC_PAUSE  0x0080
+#define TBIANA_HALF_DUPLEX     0x0040
+#define TBIANA_FULL_DUPLEX     0x0020
+#define TBICR_PHY_RESET                0x8000
+#define TBICR_ANEG_ENABLE      0x1000
+#define TBICR_RESTART_ANEG     0x0200
+#define TBICR_FULL_DUPLEX      0x0100
+#define TBICR_SPEED1_SET       0x0040
+
+
 /* MAC register bits */
 #define MACCFG1_SOFT_RESET     0x80000000
 #define MACCFG1_RESET_RX_MC    0x00080000
 #define miim_end -2
 #define miim_read -1
 
-#ifndef CFG_TBIPA_VALUE
-    #define CFG_TBIPA_VALUE    0x1f
+#ifndef CONFIG_SYS_TBIPA_VALUE
+    #define CONFIG_SYS_TBIPA_VALUE     0x1f
 #endif
 #define MIIMCFG_INIT_VALUE     0x00000003
 #define MIIMCFG_RESET          0x80000000
 #define MIIM_EXT_PAGE_ACCESS   0x1f
 
 /* Broadcom BCM54xx -- taken from linux sungem_phy */
+#define MIIM_BCM54xx_AUXCNTL                   0x18
+#define MIIM_BCM54xx_AUXCNTL_ENCODE(val)       ((val & 0x7) << 12)|(val & 0x7)
 #define MIIM_BCM54xx_AUXSTATUS                 0x19
 #define MIIM_BCM54xx_AUXSTATUS_LINKMODE_MASK   0x0700
 #define MIIM_BCM54xx_AUXSTATUS_LINKMODE_SHIFT  8
 
+#define MIIM_BCM54XX_SHD       0x1c    /* 0x1c shadow registers */
+#define MIIM_BCM54XX_SHD_WRITE 0x8000
+#define MIIM_BCM54XX_SHD_VAL(x)        ((x & 0x1f) << 10)
+#define MIIM_BCM54XX_SHD_DATA(x)       ((x & 0x3ff) << 0)
+#define MIIM_BCM54XX_SHD_WR_ENCODE(val, data)  \
+       (MIIM_BCM54XX_SHD_WRITE | MIIM_BCM54XX_SHD_VAL(val) | \
+        MIIM_BCM54XX_SHD_DATA(data))
+
+#define MIIM_BCM54XX_EXP_DATA  0x15    /* Expansion register data */
+#define MIIM_BCM54XX_EXP_SEL   0x17    /* Expansion register select */
+#define MIIM_BCM54XX_EXP_SEL_SSD       0x0e00  /* Secondary SerDes select */
+#define MIIM_BCM54XX_EXP_SEL_ER        0x0f00  /* Expansion register select */
+
 /* Cicada Auxiliary Control/Status Register */
 #define MIIM_CIS8201_AUX_CONSTAT       0x1c
 #define MIIM_CIS8201_AUXCONSTAT_INIT   0x0004
 #define MIIM_88E1121_PHY_LED_PAGE      3
 #define MIIM_88E1121_PHY_LED_DEF       0x0030
 
+/* 88E1121 PHY IRQ Enable/Status Register */
+#define MIIM_88E1121_PHY_IRQ_EN                18
+#define MIIM_88E1121_PHY_IRQ_STATUS    19
+
 #define MIIM_88E1121_PHY_PAGE          22
 
 /* 88E1145 Extended PHY Specific Control Register */
@@ -436,6 +469,22 @@ typedef struct tsec_hash_regs
        uint    res2[24];
 } tsec_hash_t;
 
+typedef struct tsec_mdio {
+       uint    res1[4];
+       uint    ieventm;
+       uint    imaskm;
+       uint    res2;
+       uint    emapm;
+       uint    res3[320];
+       uint    miimcfg;        /* MII Management: Configuration */
+       uint    miimcom;        /* MII Management: Command */
+       uint    miimadd;        /* MII Management: Address */
+       uint    miimcon;        /* MII Management: Control */
+       uint    miimstat;       /* MII Management: Status */
+       uint    miimind;        /* MII Management: Indicators */
+       uint    res4[690];
+} tsec_mdio_t;
+
 typedef struct tsec
 {
        /* General Control and Status Registers (0x2_n000) */
@@ -501,12 +550,7 @@ typedef struct tsec
 
        uint    res51c;
 
-       uint    miimcfg;        /* MII Management: Configuration */
-       uint    miimcom;        /* MII Management: Command */
-       uint    miimadd;        /* MII Management: Address */
-       uint    miimcon;        /* MII Management: Control */
-       uint    miimstat;       /* MII Management: Status */
-       uint    miimind;        /* MII Management: Indicators */
+       uint    resmdio[6];
 
        uint    res538;
 
@@ -540,11 +584,14 @@ typedef struct tsec
 
 /* This flag currently only has
  * meaning if we're using the eTSEC */
-#define TSEC_REDUCED (1 << 1)
+#define TSEC_REDUCED   (1 << 1)        /* MAC-PHY interface uses RGMII */
+#define TSEC_SGMII     (1 << 2)        /* MAC-PHY interface uses SGMII */
+#define TSEC_FIBER     (1 << 3)        /* PHY uses fiber, eg 1000 Base-X */
 
 struct tsec_private {
        volatile tsec_t *regs;
-       volatile tsec_t *phyregs;
+       volatile tsec_mdio_t *phyregs;
+       volatile tsec_mdio_t *phyregs_sgmii;
        struct phy_info *phyinfo;
        uint phyaddr;
        u32 flags;
@@ -603,13 +650,13 @@ struct phy_info {
 
 struct tsec_info_struct {
        tsec_t *regs;
-       tsec_t *miiregs;
+       tsec_mdio_t *miiregs;
+       tsec_mdio_t *miiregs_sgmii;
        char *devname;
        unsigned int phyaddr;
        u32 flags;
 };
 
-int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info);
 int tsec_standard_init(bd_t *bis);
 int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsec_info, int num);