openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

phymod.c (3445B)


      1 /*
      2  *         
      3  * 
      4  * 
      5  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      6  * 
      7  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      8  */
      9 
     10 #include <phymod/phymod.h>
     11 #include <phymod/phymod_system.h>
     12 #include <phymod/phymod_dispatch.h>
     13 #include <phymod/phymod_acc.h>
     14 
     15 int phymod_core_probe(const phymod_access_t* access, phymod_dispatch_type_t* type, int* is_probed)
     16 {
     17     uint32_t is_identified;
     18     phymod_dispatch_type_t idx;
     19     phymod_core_access_t core;
     20     uint32_t core_id;
     21     int rv=PHYMOD_E_NONE;
     22 
     23     *is_probed = 0;
     24 
     25     /*parameters validation*/
     26     if(PHYMOD_E_OK != phymod_access_t_validate(access)) {
     27         PHYMOD_RETURN_WITH_ERR(PHYMOD_E_PARAM, (_PHYMOD_MSG("access validation failed")));
     28     }
     29 
     30     if(type == NULL) {
     31         PHYMOD_RETURN_WITH_ERR(PHYMOD_E_PARAM, (_PHYMOD_MSG("type NULL parameter")));
     32     }
     33 
     34     core_id = 0;
     35     
     36     /*Identify phy type & driver*/
     37     PHYMOD_MEMCPY(&core.access, access, sizeof(core.access));
     38     core.type = phymodDispatchTypeCount;
     39     is_identified = 0;
     40     for(idx = 0 ; idx < phymodDispatchTypeCount ; idx++) {
     41         if(NULL != __phymod__dispatch__[idx]->f_phymod_core_identify) {
     42             rv = __phymod__dispatch__[idx]->f_phymod_core_identify(&core, core_id, &is_identified);
     43             if (rv == PHYMOD_E_NONE && is_identified) {
     44                 (*type) = idx;
     45                 *is_probed = 1;
     46                 break;
     47             }
     48         }
     49     }
     50          
     51     return PHYMOD_E_NONE;
     52 }
     53 
     54 int phymod_osr_mode_to_actual_os(phymod_osr_mode_t osr_mode, uint32_t* os_int, uint32_t* os_remainder)
     55 {
     56     if(PHYMOD_E_OK != phymod_osr_mode_t_validate(osr_mode)) {
     57         PHYMOD_RETURN_WITH_ERR(PHYMOD_E_PARAM, (_PHYMOD_MSG("osr_mode validation failed")));
     58     }
     59 
     60     if(os_int == NULL) {
     61         PHYMOD_RETURN_WITH_ERR(PHYMOD_E_PARAM, (_PHYMOD_MSG("os_int NULL parameter")));
     62     }
     63     if(os_remainder == NULL) {
     64         PHYMOD_RETURN_WITH_ERR(PHYMOD_E_PARAM, (_PHYMOD_MSG("os_remainder NULL parameter")));
     65     }
     66 
     67     *os_int = 0;
     68     *os_remainder = 0;
     69 
     70     switch (osr_mode) {
     71         case phymodOversampleMode1: 
     72             *os_int = 1;
     73             break;
     74         case phymodOversampleMode2: 
     75             *os_int = 2; 
     76             break;
     77         case phymodOversampleMode3: 
     78             *os_int = 3; 
     79             break;
     80         case phymodOversampleMode3P3: 
     81             *os_int = 3;
     82             *os_remainder = 300;
     83             break;
     84         case phymodOversampleMode4: 
     85             *os_int = 4; 
     86             break;
     87         case phymodOversampleMode5: 
     88             *os_int = 5; 
     89             break;
     90         case phymodOversampleMode7P5: 
     91             *os_int = 7;
     92             *os_remainder = 500;
     93             break;
     94         case phymodOversampleMode8: 
     95             *os_int = 8; 
     96             break;
     97         case phymodOversampleMode8P25:
     98             *os_int = 8;
     99             *os_remainder = 250;
    100             break;
    101         case phymodOversampleMode10: 
    102             *os_int = 10; 
    103             break;
    104         case phymodOversampleMode16P5:
    105             *os_int = 16;
    106             *os_remainder = 500;
    107             break;
    108         case phymodOversampleMode20P625:
    109             *os_int = 20;
    110             *os_remainder = 625;
    111             break;
    112         default:
    113             PHYMOD_RETURN_WITH_ERR(PHYMOD_E_INTERNAL, (_PHYMOD_MSG("OS mode not supported")));
    114     }
    115          
    116     return PHYMOD_E_NONE;
    117 }
    118 
    119 
    120 
    121