]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/qe/uec.c
arm: mx5: clock: add support for changing CPU clock via cmdline
[karo-tx-uboot.git] / drivers / qe / uec.c
index 282ab237516d89876d5b07a9526bcecd2f25b24a..68045733b8b8c223ceef99b132181e8124fe1e60 100644 (file)
@@ -1,22 +1,9 @@
 /*
- * Copyright (C) 2006-2010 Freescale Semiconductor, Inc.
+ * Copyright (C) 2006-2011 Freescale Semiconductor, Inc.
  *
  * Dave Liu <daveliu@freescale.com>
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include "common.h"
@@ -30,6 +17,7 @@
 #include "uec.h"
 #include "uec_phy.h"
 #include "miiphy.h"
+#include <phy.h>
 
 /* Default UTBIPAR SMI address */
 #ifndef CONFIG_UTBIPAR_INIT_TBIPA
@@ -67,9 +55,6 @@ static uec_info_t uec_info[] = {
 
 static struct eth_device *devlist[MAXCONTROLLERS];
 
-u16 phy_read (struct uec_mii_info *mii_info, u16 regnum);
-void phy_write (struct uec_mii_info *mii_info, u16 regnum, u16 val);
-
 static int uec_mac_enable(uec_private_t *uec, comm_dir_e mode)
 {
        uec_t           *uec_regs;
@@ -266,13 +251,10 @@ static int uec_open(uec_private_t *uec, comm_dir_e mode)
 
 static int uec_stop(uec_private_t *uec, comm_dir_e mode)
 {
-       ucc_fast_private_t      *uccf;
-
        if (!uec || !uec->uccf) {
                printf("%s: No handle passed.\n", __FUNCTION__);
                return -EINVAL;
        }
-       uccf = uec->uccf;
 
        /* check if the UCC number is in range. */
        if (uec->uec_info->uf_info.ucc_num >= UCC_MAX_NUM) {
@@ -324,10 +306,9 @@ static int uec_set_mac_duplex(uec_private_t *uec, int duplex)
 }
 
 static int uec_set_mac_if_mode(uec_private_t *uec,
-               enum fsl_phy_enet_if if_mode, int speed)
+               phy_interface_t if_mode, int speed)
 {
-       enum fsl_phy_enet_if    enet_if_mode;
-       uec_info_t              *uec_info;
+       phy_interface_t         enet_if_mode;
        uec_t                   *uec_regs;
        u32                     upsmr;
        u32                     maccfg2;
@@ -337,7 +318,6 @@ static int uec_set_mac_if_mode(uec_private_t *uec,
                return -EINVAL;
        }
 
-       uec_info = uec->uec_info;
        uec_regs = uec->uec_regs;
        enet_if_mode = if_mode;
 
@@ -348,15 +328,15 @@ static int uec_set_mac_if_mode(uec_private_t *uec,
        upsmr &= ~(UPSMR_RPM | UPSMR_TBIM | UPSMR_R10M | UPSMR_RMM);
 
        switch (speed) {
-               case 10:
+               case SPEED_10:
                        maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE;
                        switch (enet_if_mode) {
-                               case MII:
+                               case PHY_INTERFACE_MODE_MII:
                                        break;
-                               case RGMII:
+                               case PHY_INTERFACE_MODE_RGMII:
                                        upsmr |= (UPSMR_RPM | UPSMR_R10M);
                                        break;
-                               case RMII:
+                               case PHY_INTERFACE_MODE_RMII:
                                        upsmr |= (UPSMR_R10M | UPSMR_RMM);
                                        break;
                                default:
@@ -364,15 +344,15 @@ static int uec_set_mac_if_mode(uec_private_t *uec,
                                        break;
                        }
                        break;
-               case 100:
+               case SPEED_100:
                        maccfg2 |= MACCFG2_INTERFACE_MODE_NIBBLE;
                        switch (enet_if_mode) {
-                               case MII:
+                               case PHY_INTERFACE_MODE_MII:
                                        break;
-                               case RGMII:
+                               case PHY_INTERFACE_MODE_RGMII:
                                        upsmr |= UPSMR_RPM;
                                        break;
-                               case RMII:
+                               case PHY_INTERFACE_MODE_RMII:
                                        upsmr |= UPSMR_RMM;
                                        break;
                                default:
@@ -380,23 +360,24 @@ static int uec_set_mac_if_mode(uec_private_t *uec,
                                        break;
                        }
                        break;
-               case 1000:
+               case SPEED_1000:
                        maccfg2 |= MACCFG2_INTERFACE_MODE_BYTE;
                        switch (enet_if_mode) {
-                               case GMII:
+                               case PHY_INTERFACE_MODE_GMII:
                                        break;
-                               case TBI:
+                               case PHY_INTERFACE_MODE_TBI:
                                        upsmr |= UPSMR_TBIM;
                                        break;
-                               case RTBI:
+                               case PHY_INTERFACE_MODE_RTBI:
                                        upsmr |= (UPSMR_RPM | UPSMR_TBIM);
                                        break;
-                               case RGMII_RXID:
-                               case RGMII_ID:
-                               case RGMII:
+                               case PHY_INTERFACE_MODE_RGMII_RXID:
+                               case PHY_INTERFACE_MODE_RGMII_TXID:
+                               case PHY_INTERFACE_MODE_RGMII_ID:
+                               case PHY_INTERFACE_MODE_RGMII:
                                        upsmr |= UPSMR_RPM;
                                        break;
-                               case SGMII:
+                               case PHY_INTERFACE_MODE_SGMII:
                                        upsmr |= UPSMR_SGMM;
                                        break;
                                default:
@@ -517,12 +498,10 @@ bus_fail:
 static void adjust_link(struct eth_device *dev)
 {
        uec_private_t           *uec = (uec_private_t *)dev->priv;
-       uec_t                   *uec_regs;
        struct uec_mii_info     *mii_info = uec->mii_info;
 
        extern void change_phy_interface_mode(struct eth_device *dev,
-                                enum fsl_phy_enet_if mode, int speed);
-       uec_regs = uec->uec_regs;
+                                phy_interface_t mode, int speed);
 
        if (mii_info->link) {
                /* Now we make sure that we can be in full duplex mode.
@@ -539,19 +518,19 @@ static void adjust_link(struct eth_device *dev)
                }
 
                if (mii_info->speed != uec->oldspeed) {
-                       enum fsl_phy_enet_if    mode = \
+                       phy_interface_t mode =
                                uec->uec_info->enet_interface_type;
                        if (uec->uec_info->uf_info.eth_type == GIGA_ETH) {
                                switch (mii_info->speed) {
-                               case 1000:
+                               case SPEED_1000:
                                        break;
-                               case 100:
+                               case SPEED_100:
                                        printf ("switching to rgmii 100\n");
-                                       mode = RGMII;
+                                       mode = PHY_INTERFACE_MODE_RGMII;
                                        break;
-                               case 10:
+                               case SPEED_10:
                                        printf ("switching to rgmii 10\n");
-                                       mode = RGMII;
+                                       mode = PHY_INTERFACE_MODE_RGMII;
                                        break;
                                default:
                                        printf("%s: Ack,Speed(%d)is illegal\n",
@@ -588,9 +567,25 @@ static void phy_change(struct eth_device *dev)
 {
        uec_private_t   *uec = (uec_private_t *)dev->priv;
 
+#if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025)
+       ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+
+       /* QE9 and QE12 need to be set for enabling QE MII managment signals */
+       setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE9);
+       setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
        /* Update the link, speed, duplex */
        uec->mii_info->phyinfo->read_status(uec->mii_info);
 
+#if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025)
+       /*
+        * QE12 is muxed with LBCTL, it needs to be released for enabling
+        * LBCTL signal for LBC usage.
+        */
+       clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
        /* Adjust the interface according to speed */
        adjust_link(dev);
 }
@@ -1097,8 +1092,8 @@ static int uec_startup(uec_private_t *uec)
        out_be32(&uec_regs->utbipar, utbipar);
 
        /* Configure the TBI for SGMII operation */
-       if ((uec->uec_info->enet_interface_type == SGMII) &&
-          (uec->uec_info->speed == 1000)) {
+       if ((uec->uec_info->enet_interface_type == PHY_INTERFACE_MODE_SGMII) &&
+          (uec->uec_info->speed == SPEED_1000)) {
                uec_write_phy_reg(uec->dev, uec_regs->utbipar,
                        ENET_TBI_MII_ANA, TBIANA_SETTINGS);
 
@@ -1198,10 +1193,19 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
        uec_private_t           *uec;
        int                     err, i;
        struct phy_info         *curphy;
+#if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025)
+       ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+#endif
 
        uec = (uec_private_t *)dev->priv;
 
        if (uec->the_first_run == 0) {
+#if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025)
+       /* QE9 and QE12 need to be set for enabling QE MII managment signals */
+       setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE9);
+       setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
                err = init_phy(dev);
                if (err) {
                        printf("%s: Cannot initialize PHY, aborting.\n",
@@ -1228,6 +1232,11 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
                        udelay(100000);
                } while (1);
 
+#if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025)
+               /* QE12 needs to be released for enabling LBCTL signal*/
+               clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
                if (err || i <= 0)
                        printf("warning: %s: timeout on PHY link\n", dev->name);
 
@@ -1261,7 +1270,7 @@ static void uec_halt(struct eth_device* dev)
        uec_stop(uec, COMM_DIR_RX_AND_TX);
 }
 
-static int uec_send(struct eth_device* dev, volatile void *buf, int len)
+static int uec_send(struct eth_device *dev, void *buf, int len)
 {
        uec_private_t           *uec;
        ucc_fast_private_t      *uccf;