halReturn_t HalGetGpioIrqNumber(GpioIndex_t gpio, unsigned int * irqNumber)
{
	halReturn_t 	halRet;
    GPIOInfo_t      *pGpioInfo;

	halRet = HalInitCheck();
	if(halRet != HAL_RET_SUCCESS)
	{
		return halRet;
	}

    pGpioInfo = GetGPIOInfo(gpio);
    if(!pGpioInfo)
    {
        SII_DEBUG_PRINT(MSG_ERR,"%d is NOT right gpio_index!\n",(int)gpio);
        return HAL_RET_FAILURE;
    }

    *irqNumber = gpio_to_irq(pGpioInfo->gpio_number);

	if(*irqNumber >=0)
    {
//        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"%s(%d)-->IRQ(%d) \n",pGpioInfo->gpio_descripion,pGpioInfo->gpio_number,*irqNumber);
        return HAL_RET_SUCCESS;

    }

    return HAL_RET_FAILURE;
}
Ejemplo n.º 2
0
/**
 * @brief Release GPIO pins needed by the MHL device.
 *
 *****************************************************************************/
halReturn_t HalGpioTerm(void)
{
    halReturn_t 	halRet;

    halRet = HalInitCheck();
    if(halRet != HAL_RET_SUCCESS)
    {
        return halRet;
    }

    gpio_free(W_INT_GPIO);
    gpio_free(W_RST_GPIO);
#ifdef MAKE_8240_DRIVER //(
    // don't do the stuff in the else branch
#elif defined(MAKE_833X_DRIVER) //)(
    // don't do the stuff in the else branch
#else //)(
    gpio_free(M2U_VBUS_CTRL_M);
#endif //)

    /* Set Gpio resource according config table in iomux.xls*/

    halRet = HalGpioConfigStatus(LOWPOWER);
    if (HAL_RET_FAILURE == halRet)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalGpioTerm: Config GPIO Block  Failed\n");
        return HAL_RET_FAILURE;
    }

    return HAL_RET_SUCCESS;
}
/**
 * @brief Platform specific function to set the output pin to control the MHL
 * 		  transmitter device.
 *
 *****************************************************************************/
halReturn_t HalGpioSetPin(GpioIndex_t gpio,int value)
{
	halReturn_t 	halRet;
    GPIOInfo_t      *pGpioInfo;
	halRet = HalInitCheck();
	if(halRet != HAL_RET_SUCCESS)
	{
		return halRet;
	}
    pGpioInfo = GetGPIOInfo(gpio);
    if(!pGpioInfo)
    {
        SII_DEBUG_PRINT(MSG_ERR,"%d is NOT right gpio_index!\n",(int)gpio);
        return HAL_RET_FAILURE;
    }
    if(pGpioInfo->gpio_direction != DIRECTION_OUT)
    {
        SII_DEBUG_PRINT(MSG_ERR,"gpio(%d) is NOT ouput gpio!\n",pGpioInfo->gpio_number);
        return HAL_RET_FAILURE;
    }

	gpio_set_value(pGpioInfo->gpio_number, value ? 1 : 0);


    if(value)
    {
       SII_DEBUG_PRINT(MSG_STAT,">> %s to HIGH <<\n",pGpioInfo->gpio_descripion);
    }
    else
    {
       SII_DEBUG_PRINT(MSG_STAT,">> %s to LOW <<\n",pGpioInfo->gpio_descripion);
    }

	return HAL_RET_SUCCESS;
}
/**
 * @brief Platform specific function to get the input pin value of the MHL
 * 		  transmitter device.
 *
 *****************************************************************************/
halReturn_t HalGpioGetPin(GpioIndex_t gpio,int * value)
{
	halReturn_t 	halRet;
    GPIOInfo_t      *pGpioInfo;

	halRet = HalInitCheck();
	if(halRet != HAL_RET_SUCCESS)
	{
		return halRet;
	}

    pGpioInfo = GetGPIOInfo(gpio);
    if(!pGpioInfo)
    {
        SII_DEBUG_PRINT(MSG_ERR,"%d is NOT right gpio_index!\n",(int)gpio);
        return HAL_RET_FAILURE;
    }
    if(pGpioInfo->gpio_direction != DIRECTION_IN)
    {
        SII_DEBUG_PRINT(MSG_ERR,"gpio(%d) is NOT input gpio!\n",pGpioInfo->gpio_number);
        return HAL_RET_FAILURE;
    }

	*value = gpio_get_value(pGpioInfo->gpio_number);
	return HAL_RET_SUCCESS;
}
Ejemplo n.º 5
0
halReturn_t HalOpenI2cDevice(char const *DeviceName, char const *DriverName)
{
    halReturn_t		retStatus;
    int32_t 		retVal;

    retStatus = HalInitCheck();
    if (retStatus != HAL_RET_SUCCESS)
    {
        return retStatus;
    }
    retVal = strnlen(DeviceName, I2C_NAME_SIZE);
    if (retVal >= I2C_NAME_SIZE)
    {
        printk("I2c device name too long!\n");
        return HAL_RET_PARAMETER_ERROR;
    }

    i2c_register_board_info(4, &i2c_mhl, 1);

    memcpy(gMhlI2cIdTable[0].name, DeviceName, retVal);
    gMhlI2cIdTable[0].name[retVal] = 0;
    gMhlI2cIdTable[0].driver_data = 0;

    gMhlDevice.driver.driver.name = "Sil_MHL";
    gMhlDevice.driver.id_table = gMhlI2cIdTable;
    gMhlDevice.driver.probe = MhlI2cProbe;
    gMhlDevice.driver.remove = MhlI2cRemove;

    //printk("gMhlDevice.driver.driver.name=%s\n", gMhlDevice.driver.driver.name);
    //printk("gMhlI2cIdTable.name=%s\n", gMhlI2cIdTable[0].name);
    retVal = i2c_add_driver(&mhl_i2c_driver);
    //printk("gMhlDevice.pI2cClient =%p\n", gMhlDevice.pI2cClient);
    if (retVal != 0)
    {
        printk("I2C driver add failed, retVal=%d\n", retVal);
        retStatus = HAL_RET_FAILURE;
    }
    else
    {
#if 0
        if (gMhlDevice.pI2cClient == NULL)
        {
            i2c_del_driver(&gMhlDevice.driver);
            printk("I2C driver add failed, retVal=%d\n", retVal);
            retStatus = HAL_RET_NO_DEVICE;
        }
        else
#endif
        {
            retStatus = HAL_RET_SUCCESS;
        }
    }

    //printk("GPIO_SCL=%d, GPIO_SDA=%d\n", GPIO_SCL, GPIO_SDA);

    return retStatus;
}
halReturn_t HalReleaseIsrLock()
{
	halReturn_t		retStatus;
	retStatus = HalInitCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}
	up(&gIsrLock);
	return retStatus;
}
halReturn_t HalTerm(void)
{
	halReturn_t		retStatus;
	retStatus = HalInitCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}
	//HalGpioTerm();
	gHalInitedFlag = false;
	return retStatus;
}
Ejemplo n.º 8
0
/**
 * @brief Platform specific function to control the reset pin of the MHL
 * 		  transmitter device.
 *
 *****************************************************************************/
int HalGpioGetTxIntPin(void)
{
    halReturn_t 	halRet;

    halRet = HalInitCheck();
    if(halRet != HAL_RET_SUCCESS)
    {
        return -1;
    }

    return gpio_get_value(W_INT_GPIO);
}
Ejemplo n.º 9
0
/**
 * @brief Platform specific function to control power on the USB port.
 *
 *****************************************************************************/
halReturn_t HalGpioSetUsbVbusPowerPin(bool value)
{
    halReturn_t 	halRet;

    halRet = HalInitCheck();
    if(halRet != HAL_RET_SUCCESS)
    {
        return halRet;
    }

    gpio_set_value(M2U_VBUS_CTRL_M, value);
    return HAL_RET_SUCCESS;
}
Ejemplo n.º 10
0
/**
 * @brief Platform specific function to control the reset pin of the MHL
 * 		  transmitter device.
 *
 *****************************************************************************/
halReturn_t HalGpioSetTxResetPin(bool value)
{
    halReturn_t 	halRet;

    halRet = HalInitCheck();
    if(halRet != HAL_RET_SUCCESS)
    {
        return halRet;
    }

    gpio_set_value(W_RST_GPIO, value);
    return HAL_RET_SUCCESS;
}
/**
 * @brief Request access to the specified I2c device.
 *
 *****************************************************************************/
halReturn_t HalOpenI2cDevice(char const *DeviceName, char const *DriverName)
{
	halReturn_t		retStatus;
    int32_t 		retVal;


	retStatus = HalInitCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}

    retVal = strnlen(DeviceName, I2C_NAME_SIZE);
    if (retVal >= I2C_NAME_SIZE)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "I2c device name too long!\n");
    	return HAL_RET_PARAMETER_ERROR;
    }
    
    memcpy(gMhlI2cIdTable[0].name, DeviceName, retVal);
    gMhlI2cIdTable[0].name[retVal] = 0;
    gMhlI2cIdTable[0].driver_data = 0;

    gMhlDevice.driver.driver.name = DriverName;
    gMhlDevice.driver.id_table = gMhlI2cIdTable;
    gMhlDevice.driver.probe = MhlI2cProbe;
    gMhlDevice.driver.remove = MhlI2cRemove;
    
    
    retVal = i2c_add_driver(&gMhlDevice.driver);
    if (retVal != 0)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "I2C driver add failed\n");
        retStatus = HAL_RET_FAILURE;
    }
    else
    {
    	if (gMhlDevice.pI2cClient == NULL)
        {
            i2c_del_driver(&gMhlDevice.driver);
        	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "I2C driver add failed\n");
            retStatus = HAL_RET_NO_DEVICE;
        }
    	else
    	{
    		retStatus = HAL_RET_SUCCESS;
    	}
    }
    return retStatus;
}
Ejemplo n.º 12
0
/**
 * @brief Platform specific function to control Vbus power on the MHL port.
 *
 *****************************************************************************/
halReturn_t HalGpioSetVbusPowerPin(bool powerOn)
{
    halReturn_t 	halRet;

    halRet = HalInitCheck();
    if(halRet != HAL_RET_SUCCESS)
    {
        return halRet;
    }

    SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                    "HalGpioSetVbusPowerPin called but this function is not implemented yet!\n");

    return HAL_RET_SUCCESS;
}
Ejemplo n.º 13
0
halReturn_t HalGpioTerm(void)
{
    halReturn_t 	halRet;
    int index;
    halRet = HalInitCheck();
    if(halRet != HAL_RET_SUCCESS)
    {
        return halRet;
    }
    for(index = 0; index < ARRAY_SIZE(GPIO_List); index++)
    {
        gpio_free(GPIO_List[index].gpio_number);
    }
    return HAL_RET_SUCCESS;
}
Ejemplo n.º 14
0
halReturn_t I2cAccessCheck(void)
{
    halReturn_t		retStatus;
    retStatus = HalInitCheck();
    if (retStatus != HAL_RET_SUCCESS)
    {
        return retStatus;
    }
    if(gMhlDevice.pI2cClient == NULL)
    {
        printk("I2C device not currently open\n");
        //retStatus = HAL_RET_DEVICE_NOT_OPEN;
        retStatus =HAL_RET_SUCCESS;
    }
    return retStatus;
}
/**
 *  @brief Check if I2c access is allowed.
 *
 *****************************************************************************/
halReturn_t I2cAccessCheck(void)
{
	halReturn_t		retStatus;

	retStatus = HalInitCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}

	if(gMhlDevice.pI2cClient == NULL)
	{
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "I2C device not currently open\n");
		retStatus = HAL_RET_DEVICE_NOT_OPEN;
	}
	return retStatus;
}
halReturn_t HalAcquireIsrLock()
{
	halReturn_t		retStatus;
	int				status;
	retStatus = HalInitCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}
	status = down_interruptible(&gIsrLock);
	if (status != 0)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalAcquireIsrLock failed to acquire lock\n");
		return HAL_RET_FAILURE;
	}
	return HAL_RET_SUCCESS;
}
halReturn_t HalCloseI2cDevice(void)
{
	halReturn_t		retStatus;
	retStatus = HalInitCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}
	if(gMhlDevice.pI2cClient == NULL)
	{
		printk("I2C device not currently open\n");
        retStatus = HAL_RET_DEVICE_NOT_OPEN;
	}
	else
	{
		i2c_del_driver(&gMhlDevice.driver);
		gMhlDevice.pI2cClient = NULL;
		retStatus = HAL_RET_SUCCESS;
	}
	return retStatus;
}