aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/atm/iphase.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/atm/iphase.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/atm/iphase.c')
-rw-r--r--drivers/atm/iphase.c283
1 files changed, 130 insertions, 153 deletions
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 4217f29a85e..cb90f7a3e07 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -56,6 +56,7 @@
56#include <linux/interrupt.h> 56#include <linux/interrupt.h>
57#include <linux/wait.h> 57#include <linux/wait.h>
58#include <linux/slab.h> 58#include <linux/slab.h>
59#include <asm/system.h>
59#include <asm/io.h> 60#include <asm/io.h>
60#include <linux/atomic.h> 61#include <linux/atomic.h>
61#include <asm/uaccess.h> 62#include <asm/uaccess.h>
@@ -817,152 +818,127 @@ static void ia_hw_type(IADEV *iadev) {
817 818
818} 819}
819 820
820static u32 ia_phy_read32(struct iadev_priv *ia, unsigned int reg) 821static void IaFrontEndIntr(IADEV *iadev) {
821{ 822 volatile IA_SUNI *suni;
822 return readl(ia->phy + (reg >> 2)); 823 volatile ia_mb25_t *mb25;
823} 824 volatile suni_pm7345_t *suni_pm7345;
824 825
825static void ia_phy_write32(struct iadev_priv *ia, unsigned int reg, u32 val) 826 if(iadev->phy_type & FE_25MBIT_PHY) {
826{ 827 mb25 = (ia_mb25_t*)iadev->phy;
827 writel(val, ia->phy + (reg >> 2)); 828 iadev->carrier_detect = Boolean(mb25->mb25_intr_status & MB25_IS_GSB);
828} 829 } else if (iadev->phy_type & FE_DS3_PHY) {
829 830 suni_pm7345 = (suni_pm7345_t *)iadev->phy;
830static void ia_frontend_intr(struct iadev_priv *iadev) 831 /* clear FRMR interrupts */
831{ 832 (void) suni_pm7345->suni_ds3_frm_intr_stat;
832 u32 status; 833 iadev->carrier_detect =
833 834 Boolean(!(suni_pm7345->suni_ds3_frm_stat & SUNI_DS3_LOSV));
834 if (iadev->phy_type & FE_25MBIT_PHY) { 835 } else if (iadev->phy_type & FE_E3_PHY ) {
835 status = ia_phy_read32(iadev, MB25_INTR_STATUS); 836 suni_pm7345 = (suni_pm7345_t *)iadev->phy;
836 iadev->carrier_detect = (status & MB25_IS_GSB) ? 1 : 0; 837 (void) suni_pm7345->suni_e3_frm_maint_intr_ind;
837 } else if (iadev->phy_type & FE_DS3_PHY) { 838 iadev->carrier_detect =
838 ia_phy_read32(iadev, SUNI_DS3_FRM_INTR_STAT); 839 Boolean(!(suni_pm7345->suni_e3_frm_fram_intr_ind_stat&SUNI_E3_LOS));
839 status = ia_phy_read32(iadev, SUNI_DS3_FRM_STAT); 840 }
840 iadev->carrier_detect = (status & SUNI_DS3_LOSV) ? 0 : 1; 841 else {
841 } else if (iadev->phy_type & FE_E3_PHY) { 842 suni = (IA_SUNI *)iadev->phy;
842 ia_phy_read32(iadev, SUNI_E3_FRM_MAINT_INTR_IND); 843 (void) suni->suni_rsop_status;
843 status = ia_phy_read32(iadev, SUNI_E3_FRM_FRAM_INTR_IND_STAT); 844 iadev->carrier_detect = Boolean(!(suni->suni_rsop_status & SUNI_LOSV));
844 iadev->carrier_detect = (status & SUNI_E3_LOS) ? 0 : 1; 845 }
845 } else { 846 if (iadev->carrier_detect)
846 status = ia_phy_read32(iadev, SUNI_RSOP_STATUS); 847 printk("IA: SUNI carrier detected\n");
847 iadev->carrier_detect = (status & SUNI_LOSV) ? 0 : 1; 848 else
848 } 849 printk("IA: SUNI carrier lost signal\n");
849 850 return;
850 printk(KERN_INFO "IA: SUNI carrier %s\n",
851 iadev->carrier_detect ? "detected" : "lost signal");
852} 851}
853 852
854static void ia_mb25_init(struct iadev_priv *iadev) 853static void ia_mb25_init (IADEV *iadev)
855{ 854{
855 volatile ia_mb25_t *mb25 = (ia_mb25_t*)iadev->phy;
856#if 0 856#if 0
857 mb25->mb25_master_ctrl = MB25_MC_DRIC | MB25_MC_DREC | MB25_MC_ENABLED; 857 mb25->mb25_master_ctrl = MB25_MC_DRIC | MB25_MC_DREC | MB25_MC_ENABLED;
858#endif 858#endif
859 ia_phy_write32(iadev, MB25_MASTER_CTRL, MB25_MC_DRIC | MB25_MC_DREC); 859 mb25->mb25_master_ctrl = MB25_MC_DRIC | MB25_MC_DREC;
860 ia_phy_write32(iadev, MB25_DIAG_CONTROL, 0); 860 mb25->mb25_diag_control = 0;
861 861 /*
862 iadev->carrier_detect = 862 * Initialize carrier detect state
863 (ia_phy_read32(iadev, MB25_INTR_STATUS) & MB25_IS_GSB) ? 1 : 0; 863 */
864} 864 iadev->carrier_detect = Boolean(mb25->mb25_intr_status & MB25_IS_GSB);
865 865 return;
866struct ia_reg { 866}
867 u16 reg;
868 u16 val;
869};
870
871static void ia_phy_write(struct iadev_priv *iadev,
872 const struct ia_reg *regs, int len)
873{
874 while (len--) {
875 ia_phy_write32(iadev, regs->reg, regs->val);
876 regs++;
877 }
878}
879
880static void ia_suni_pm7345_init_ds3(struct iadev_priv *iadev)
881{
882 static const struct ia_reg suni_ds3_init [] = {
883 { SUNI_DS3_FRM_INTR_ENBL, 0x17 },
884 { SUNI_DS3_FRM_CFG, 0x01 },
885 { SUNI_DS3_TRAN_CFG, 0x01 },
886 { SUNI_CONFIG, 0 },
887 { SUNI_SPLR_CFG, 0 },
888 { SUNI_SPLT_CFG, 0 }
889 };
890 u32 status;
891
892 status = ia_phy_read32(iadev, SUNI_DS3_FRM_STAT);
893 iadev->carrier_detect = (status & SUNI_DS3_LOSV) ? 0 : 1;
894
895 ia_phy_write(iadev, suni_ds3_init, ARRAY_SIZE(suni_ds3_init));
896}
897
898static void ia_suni_pm7345_init_e3(struct iadev_priv *iadev)
899{
900 static const struct ia_reg suni_e3_init [] = {
901 { SUNI_E3_FRM_FRAM_OPTIONS, 0x04 },
902 { SUNI_E3_FRM_MAINT_OPTIONS, 0x20 },
903 { SUNI_E3_FRM_FRAM_INTR_ENBL, 0x1d },
904 { SUNI_E3_FRM_MAINT_INTR_ENBL, 0x30 },
905 { SUNI_E3_TRAN_STAT_DIAG_OPTIONS, 0 },
906 { SUNI_E3_TRAN_FRAM_OPTIONS, 0x01 },
907 { SUNI_CONFIG, SUNI_PM7345_E3ENBL },
908 { SUNI_SPLR_CFG, 0x41 },
909 { SUNI_SPLT_CFG, 0x41 }
910 };
911 u32 status;
912
913 status = ia_phy_read32(iadev, SUNI_E3_FRM_FRAM_INTR_IND_STAT);
914 iadev->carrier_detect = (status & SUNI_E3_LOS) ? 0 : 1;
915 ia_phy_write(iadev, suni_e3_init, ARRAY_SIZE(suni_e3_init));
916}
917 867
918static void ia_suni_pm7345_init(struct iadev_priv *iadev) 868static void ia_suni_pm7345_init (IADEV *iadev)
919{ 869{
920 static const struct ia_reg suni_init [] = { 870 volatile suni_pm7345_t *suni_pm7345 = (suni_pm7345_t *)iadev->phy;
921 /* Enable RSOP loss of signal interrupt. */ 871 if (iadev->phy_type & FE_DS3_PHY)
922 { SUNI_INTR_ENBL, 0x28 }, 872 {
923 /* Clear error counters. */ 873 iadev->carrier_detect =
924 { SUNI_ID_RESET, 0 }, 874 Boolean(!(suni_pm7345->suni_ds3_frm_stat & SUNI_DS3_LOSV));
925 /* Clear "PMCTST" in master test register. */ 875 suni_pm7345->suni_ds3_frm_intr_enbl = 0x17;
926 { SUNI_MASTER_TEST, 0 }, 876 suni_pm7345->suni_ds3_frm_cfg = 1;
927 877 suni_pm7345->suni_ds3_tran_cfg = 1;
928 { SUNI_RXCP_CTRL, 0x2c }, 878 suni_pm7345->suni_config = 0;
929 { SUNI_RXCP_FCTRL, 0x81 }, 879 suni_pm7345->suni_splr_cfg = 0;
930 880 suni_pm7345->suni_splt_cfg = 0;
931 { SUNI_RXCP_IDLE_PAT_H1, 0 }, 881 }
932 { SUNI_RXCP_IDLE_PAT_H2, 0 }, 882 else
933 { SUNI_RXCP_IDLE_PAT_H3, 0 }, 883 {
934 { SUNI_RXCP_IDLE_PAT_H4, 0x01 }, 884 iadev->carrier_detect =
935 885 Boolean(!(suni_pm7345->suni_e3_frm_fram_intr_ind_stat & SUNI_E3_LOS));
936 { SUNI_RXCP_IDLE_MASK_H1, 0xff }, 886 suni_pm7345->suni_e3_frm_fram_options = 0x4;
937 { SUNI_RXCP_IDLE_MASK_H2, 0xff }, 887 suni_pm7345->suni_e3_frm_maint_options = 0x20;
938 { SUNI_RXCP_IDLE_MASK_H3, 0xff }, 888 suni_pm7345->suni_e3_frm_fram_intr_enbl = 0x1d;
939 { SUNI_RXCP_IDLE_MASK_H4, 0xfe }, 889 suni_pm7345->suni_e3_frm_maint_intr_enbl = 0x30;
940 890 suni_pm7345->suni_e3_tran_stat_diag_options = 0x0;
941 { SUNI_RXCP_CELL_PAT_H1, 0 }, 891 suni_pm7345->suni_e3_tran_fram_options = 0x1;
942 { SUNI_RXCP_CELL_PAT_H2, 0 }, 892 suni_pm7345->suni_config = SUNI_PM7345_E3ENBL;
943 { SUNI_RXCP_CELL_PAT_H3, 0 }, 893 suni_pm7345->suni_splr_cfg = 0x41;
944 { SUNI_RXCP_CELL_PAT_H4, 0x01 }, 894 suni_pm7345->suni_splt_cfg = 0x41;
945 895 }
946 { SUNI_RXCP_CELL_MASK_H1, 0xff }, 896 /*
947 { SUNI_RXCP_CELL_MASK_H2, 0xff }, 897 * Enable RSOP loss of signal interrupt.
948 { SUNI_RXCP_CELL_MASK_H3, 0xff }, 898 */
949 { SUNI_RXCP_CELL_MASK_H4, 0xff }, 899 suni_pm7345->suni_intr_enbl = 0x28;
950 900
951 { SUNI_TXCP_CTRL, 0xa4 }, 901 /*
952 { SUNI_TXCP_INTR_EN_STS, 0x10 }, 902 * Clear error counters
953 { SUNI_TXCP_IDLE_PAT_H5, 0x55 } 903 */
954 }; 904 suni_pm7345->suni_id_reset = 0;
955 905
956 if (iadev->phy_type & FE_DS3_PHY) 906 /*
957 ia_suni_pm7345_init_ds3(iadev); 907 * Clear "PMCTST" in master test register.
958 else 908 */
959 ia_suni_pm7345_init_e3(iadev); 909 suni_pm7345->suni_master_test = 0;
960 910
961 ia_phy_write(iadev, suni_init, ARRAY_SIZE(suni_init)); 911 suni_pm7345->suni_rxcp_ctrl = 0x2c;
962 912 suni_pm7345->suni_rxcp_fctrl = 0x81;
963 ia_phy_write32(iadev, SUNI_CONFIG, ia_phy_read32(iadev, SUNI_CONFIG) & 913
964 ~(SUNI_PM7345_LLB | SUNI_PM7345_CLB | 914 suni_pm7345->suni_rxcp_idle_pat_h1 =
965 SUNI_PM7345_DLB | SUNI_PM7345_PLB)); 915 suni_pm7345->suni_rxcp_idle_pat_h2 =
916 suni_pm7345->suni_rxcp_idle_pat_h3 = 0;
917 suni_pm7345->suni_rxcp_idle_pat_h4 = 1;
918
919 suni_pm7345->suni_rxcp_idle_mask_h1 = 0xff;
920 suni_pm7345->suni_rxcp_idle_mask_h2 = 0xff;
921 suni_pm7345->suni_rxcp_idle_mask_h3 = 0xff;
922 suni_pm7345->suni_rxcp_idle_mask_h4 = 0xfe;
923
924 suni_pm7345->suni_rxcp_cell_pat_h1 =
925 suni_pm7345->suni_rxcp_cell_pat_h2 =
926 suni_pm7345->suni_rxcp_cell_pat_h3 = 0;
927 suni_pm7345->suni_rxcp_cell_pat_h4 = 1;
928
929 suni_pm7345->suni_rxcp_cell_mask_h1 =
930 suni_pm7345->suni_rxcp_cell_mask_h2 =
931 suni_pm7345->suni_rxcp_cell_mask_h3 =
932 suni_pm7345->suni_rxcp_cell_mask_h4 = 0xff;
933
934 suni_pm7345->suni_txcp_ctrl = 0xa4;
935 suni_pm7345->suni_txcp_intr_en_sts = 0x10;
936 suni_pm7345->suni_txcp_idle_pat_h5 = 0x55;
937
938 suni_pm7345->suni_config &= ~(SUNI_PM7345_LLB |
939 SUNI_PM7345_CLB |
940 SUNI_PM7345_DLB |
941 SUNI_PM7345_PLB);
966#ifdef __SNMP__ 942#ifdef __SNMP__
967 suni_pm7345->suni_rxcp_intr_en_sts |= SUNI_OOCDE; 943 suni_pm7345->suni_rxcp_intr_en_sts |= SUNI_OOCDE;
968#endif /* __SNMP__ */ 944#endif /* __SNMP__ */
@@ -1319,8 +1295,8 @@ static void rx_dle_intr(struct atm_dev *dev)
1319 if (ia_vcc == NULL) 1295 if (ia_vcc == NULL)
1320 { 1296 {
1321 atomic_inc(&vcc->stats->rx_err); 1297 atomic_inc(&vcc->stats->rx_err);
1322 atm_return(vcc, skb->truesize);
1323 dev_kfree_skb_any(skb); 1298 dev_kfree_skb_any(skb);
1299 atm_return(vcc, atm_guess_pdu2truesize(len));
1324 goto INCR_DLE; 1300 goto INCR_DLE;
1325 } 1301 }
1326 // get real pkt length pwang_test 1302 // get real pkt length pwang_test
@@ -1333,8 +1309,8 @@ static void rx_dle_intr(struct atm_dev *dev)
1333 atomic_inc(&vcc->stats->rx_err); 1309 atomic_inc(&vcc->stats->rx_err);
1334 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)", 1310 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
1335 length, skb->len);) 1311 length, skb->len);)
1336 atm_return(vcc, skb->truesize);
1337 dev_kfree_skb_any(skb); 1312 dev_kfree_skb_any(skb);
1313 atm_return(vcc, atm_guess_pdu2truesize(len));
1338 goto INCR_DLE; 1314 goto INCR_DLE;
1339 } 1315 }
1340 skb_trim(skb, length); 1316 skb_trim(skb, length);
@@ -1449,10 +1425,10 @@ static int rx_init(struct atm_dev *dev)
1449 iadev->dma + IPHASE5575_RX_LIST_ADDR); 1425 iadev->dma + IPHASE5575_RX_LIST_ADDR);
1450 IF_INIT(printk("Tx Dle list addr: 0x%p value: 0x%0x\n", 1426 IF_INIT(printk("Tx Dle list addr: 0x%p value: 0x%0x\n",
1451 iadev->dma+IPHASE5575_TX_LIST_ADDR, 1427 iadev->dma+IPHASE5575_TX_LIST_ADDR,
1452 readl(iadev->dma + IPHASE5575_TX_LIST_ADDR)); 1428 *(u32*)(iadev->dma+IPHASE5575_TX_LIST_ADDR));
1453 printk("Rx Dle list addr: 0x%p value: 0x%0x\n", 1429 printk("Rx Dle list addr: 0x%p value: 0x%0x\n",
1454 iadev->dma+IPHASE5575_RX_LIST_ADDR, 1430 iadev->dma+IPHASE5575_RX_LIST_ADDR,
1455 readl(iadev->dma + IPHASE5575_RX_LIST_ADDR));) 1431 *(u32*)(iadev->dma+IPHASE5575_RX_LIST_ADDR));)
1456 1432
1457 writew(0xffff, iadev->reass_reg+REASS_MASK_REG); 1433 writew(0xffff, iadev->reass_reg+REASS_MASK_REG);
1458 writew(0, iadev->reass_reg+MODE_REG); 1434 writew(0, iadev->reass_reg+MODE_REG);
@@ -2232,7 +2208,7 @@ static irqreturn_t ia_int(int irq, void *dev_id)
2232 if (status & STAT_DLERINT) 2208 if (status & STAT_DLERINT)
2233 { 2209 {
2234 /* Clear this bit by writing a 1 to it. */ 2210 /* Clear this bit by writing a 1 to it. */
2235 writel(STAT_DLERINT, iadev->reg + IPHASE5575_BUS_STATUS_REG); 2211 *(u_int *)(iadev->reg+IPHASE5575_BUS_STATUS_REG) = STAT_DLERINT;
2236 rx_dle_intr(dev); 2212 rx_dle_intr(dev);
2237 } 2213 }
2238 if (status & STAT_SEGINT) 2214 if (status & STAT_SEGINT)
@@ -2243,13 +2219,13 @@ static irqreturn_t ia_int(int irq, void *dev_id)
2243 } 2219 }
2244 if (status & STAT_DLETINT) 2220 if (status & STAT_DLETINT)
2245 { 2221 {
2246 writel(STAT_DLETINT, iadev->reg + IPHASE5575_BUS_STATUS_REG); 2222 *(u_int *)(iadev->reg+IPHASE5575_BUS_STATUS_REG) = STAT_DLETINT;
2247 tx_dle_intr(dev); 2223 tx_dle_intr(dev);
2248 } 2224 }
2249 if (status & (STAT_FEINT | STAT_ERRINT | STAT_MARKINT)) 2225 if (status & (STAT_FEINT | STAT_ERRINT | STAT_MARKINT))
2250 { 2226 {
2251 if (status & STAT_FEINT) 2227 if (status & STAT_FEINT)
2252 ia_frontend_intr(iadev); 2228 IaFrontEndIntr(iadev);
2253 } 2229 }
2254 } 2230 }
2255 return IRQ_RETVAL(handled); 2231 return IRQ_RETVAL(handled);
@@ -2299,7 +2275,7 @@ static int reset_sar(struct atm_dev *dev)
2299} 2275}
2300 2276
2301 2277
2302static int ia_init(struct atm_dev *dev) 2278static int __devinit ia_init(struct atm_dev *dev)
2303{ 2279{
2304 IADEV *iadev; 2280 IADEV *iadev;
2305 unsigned long real_base; 2281 unsigned long real_base;
@@ -2362,7 +2338,7 @@ static int ia_init(struct atm_dev *dev)
2362 { 2338 {
2363 printk(DEV_LABEL " (itf %d): can't set up page mapping\n", 2339 printk(DEV_LABEL " (itf %d): can't set up page mapping\n",
2364 dev->number); 2340 dev->number);
2365 return -ENOMEM; 2341 return error;
2366 } 2342 }
2367 IF_INIT(printk(DEV_LABEL " (itf %d): rev.%d,base=%p,irq=%d\n", 2343 IF_INIT(printk(DEV_LABEL " (itf %d): rev.%d,base=%p,irq=%d\n",
2368 dev->number, iadev->pci->revision, base, iadev->irq);) 2344 dev->number, iadev->pci->revision, base, iadev->irq);)
@@ -2492,7 +2468,7 @@ static void ia_free_rx(IADEV *iadev)
2492 iadev->rx_dle_dma); 2468 iadev->rx_dle_dma);
2493} 2469}
2494 2470
2495static int ia_start(struct atm_dev *dev) 2471static int __devinit ia_start(struct atm_dev *dev)
2496{ 2472{
2497 IADEV *iadev; 2473 IADEV *iadev;
2498 int error; 2474 int error;
@@ -2580,7 +2556,7 @@ static int ia_start(struct atm_dev *dev)
2580 goto err_free_rx; 2556 goto err_free_rx;
2581 } 2557 }
2582 /* Get iadev->carrier_detect status */ 2558 /* Get iadev->carrier_detect status */
2583 ia_frontend_intr(iadev); 2559 IaFrontEndIntr(iadev);
2584 } 2560 }
2585 return 0; 2561 return 0;
2586 2562
@@ -2851,7 +2827,7 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2851 2827
2852 case 0xb: 2828 case 0xb:
2853 if (!capable(CAP_NET_ADMIN)) return -EPERM; 2829 if (!capable(CAP_NET_ADMIN)) return -EPERM;
2854 ia_frontend_intr(iadev); 2830 IaFrontEndIntr(iadev);
2855 break; 2831 break;
2856 case 0xa: 2832 case 0xa:
2857 if (!capable(CAP_NET_ADMIN)) return -EPERM; 2833 if (!capable(CAP_NET_ADMIN)) return -EPERM;
@@ -3168,7 +3144,8 @@ static const struct atmdev_ops ops = {
3168 .owner = THIS_MODULE, 3144 .owner = THIS_MODULE,
3169}; 3145};
3170 3146
3171static int ia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 3147static int __devinit ia_init_one(struct pci_dev *pdev,
3148 const struct pci_device_id *ent)
3172{ 3149{
3173 struct atm_dev *dev; 3150 struct atm_dev *dev;
3174 IADEV *iadev; 3151 IADEV *iadev;
@@ -3228,7 +3205,7 @@ err_out:
3228 return ret; 3205 return ret;
3229} 3206}
3230 3207
3231static void ia_remove_one(struct pci_dev *pdev) 3208static void __devexit ia_remove_one(struct pci_dev *pdev)
3232{ 3209{
3233 struct atm_dev *dev = pci_get_drvdata(pdev); 3210 struct atm_dev *dev = pci_get_drvdata(pdev);
3234 IADEV *iadev = INPH_IA_DEV(dev); 3211 IADEV *iadev = INPH_IA_DEV(dev);
@@ -3269,7 +3246,7 @@ static struct pci_driver ia_driver = {
3269 .name = DEV_LABEL, 3246 .name = DEV_LABEL,
3270 .id_table = ia_pci_tbl, 3247 .id_table = ia_pci_tbl,
3271 .probe = ia_init_one, 3248 .probe = ia_init_one,
3272 .remove = ia_remove_one, 3249 .remove = __devexit_p(ia_remove_one),
3273}; 3250};
3274 3251
3275static int __init ia_module_init(void) 3252static int __init ia_module_init(void)