diff --git a/ptxdist/local_src/common/ecu_mmc.h b/ptxdist/local_src/common/ecu_mmc.h index 67f1d15..cf8c008 100644 --- a/ptxdist/local_src/common/ecu_mmc.h +++ b/ptxdist/local_src/common/ecu_mmc.h @@ -42,6 +42,12 @@ struct qa_mmc_dev { struct device* mmc_device; }; +/* fixme: enum?? */ +#define COMP_CAP_DEV_SENSOR_UNKNOWN (0) +#define COMP_CAP_DEV_SENSOR_WALTERSCHEID (1) +#define COMP_CAP_DEV_SENSOR_FAG (2) +unsigned int get_comp_cap_dev_sensor_mode(void); + extern int qa_mmc_calc( struct qa_mmc_dev *dev ); extern int get_cnt_value( struct comp_cap_dev *dev, int* value ); diff --git a/ptxdist/local_src/ecu01-comp-cap/mmc.c b/ptxdist/local_src/ecu01-comp-cap/mmc.c index 75fb52c..9d2cd05 100755 --- a/ptxdist/local_src/ecu01-comp-cap/mmc.c +++ b/ptxdist/local_src/ecu01-comp-cap/mmc.c @@ -75,6 +75,44 @@ static struct qa_mmc_dev mmc = { } }; +unsigned int get_comp_cap_dev_sensor_mode(void) +{ + static unsigned int comp_cap_dev_sensor_mode = COMP_CAP_DEV_SENSOR_UNKNOWN; +#define PIN_V_NAMUR_VALID 32 //IMX_GPIO_NR(2, 0) +#define PIN_V_SENSOR_VALID 40 //IMX_GPIO_NR(2, 8) + + if (comp_cap_dev_sensor_mode == COMP_CAP_DEV_SENSOR_UNKNOWN) + { + int iRet; + iRet = gpio_get_value(PIN_V_NAMUR_VALID); + (void)printk(KERN_EMERG "pin namur = %d\n"); + iRet = gpio_get_value(PIN_V_SENSOR_VALID); + (void)printk(KERN_EMERG "pin namur = %d\n"); + if (iRet) + comp_cap_dev_sensor_mode = COMP_CAP_DEV_SENSOR_FAG; + else + comp_cap_dev_sensor_mode = COMP_CAP_DEV_SENSOR_WALTERSCHEID; + + /* print diag once */ + switch(comp_cap_dev_sensor_mode) + { + case COMP_CAP_DEV_SENSOR_WALTERSCHEID: + (void)printk(KERN_EMERG "ecu01-compcap: running in FAG mode.\n"); + break; + case COMP_CAP_DEV_SENSOR_FAG: + (void)printk(KERN_EMERG "ecu01-compcap: running in FAG mode.\n"); + break; + default: + (void)printk(KERN_EMERG "ecu01-compcap: running in unsupported mode=%d.\n", + comp_cap_dev_sensor_mode); + break; + } + } + + return comp_cap_dev_sensor_mode; +} + + /* * Open and close */ @@ -92,6 +130,10 @@ static int qa_mmc_open(struct inode *inode, struct file *file) if (dev == NULL) return -1; + /* Init sensor mode */ + /* fixme: |open()| should fail if we cannot get the info */ + (void)get_comp_cap_dev_sensor_mode(); + //init 0-1-2 //start 1-0-2 // Initialisierung diff --git a/ptxdist/local_src/ecu01-comp-cap/mmc_imp.c b/ptxdist/local_src/ecu01-comp-cap/mmc_imp.c index 8fc2ae9..5a14f51 100644 --- a/ptxdist/local_src/ecu01-comp-cap/mmc_imp.c +++ b/ptxdist/local_src/ecu01-comp-cap/mmc_imp.c @@ -263,7 +263,7 @@ int qa_mmc_calc( struct qa_mmc_dev *dev ) // Interrupt from these signals should be preventet by disabling them if the bridge from Pin C3 to C4 // is installed for FAG Sensors - if ( 0x6 == (i_mmc_error & 0x6) ) { + if (get_comp_cap_dev_sensor_mode() == COMP_CAP_DEV_SENSOR_FAG) { // There are 2 cases for shorter period than before // 1. Normal: The periode decereased because the speed raised.