ssize_t SendRcp(struct device *dev, struct device_attribute *attr,
				const char *buf, size_t count)
{
	unsigned long	keyCode;
	int				status = -EINVAL;
	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"SendRcp received string: ""%s""\n", buf);
	if(HalAcquireIsrLock() != HAL_RET_SUCCESS)
	{
		return -ERESTARTSYS;
	}
	while(gDriverContext.flags & MHL_STATE_FLAG_RCP_READY) {
		if(strict_strtoul(buf, 0, &keyCode)) {
			SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Unable to convert keycode string\n");
			break;
		}
		if(keyCode >= 0xFE) {
			SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"keycode (0x%x) is too large to be valid\n", (int)keyCode);
			break;
		}
		gDriverContext.flags &= ~(MHL_STATE_FLAG_RCP_RECEIVED |
								  MHL_STATE_FLAG_RCP_ACK |
								  MHL_STATE_FLAG_RCP_NAK);
		gDriverContext.flags |= MHL_STATE_FLAG_RCP_SENT;
		gDriverContext.keyCode = (uint8_t)keyCode;
		SiiMhlTxRcpSend((uint8_t)keyCode);
		status = count;
		break;
	}
	HalReleaseIsrLock();
	return status;
}
/**
 * @brief Write a series of bytes to an I2c device using SMBus protocol.
 *
 *****************************************************************************/
halReturn_t HalSmbusWriteBlock(uint8_t command, uint8_t const *blockData,
								  uint8_t length)
{
	halReturn_t		retStatus;
	int32_t			status;
	
	retStatus = I2cAccessCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}

	if(length > I2C_SMBUS_BLOCK_MAX)
	{
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
    			"HalSmbusWriteBlock, bufferLen param too big (%d) max size (%d)!\n",
    			length, I2C_SMBUS_BLOCK_MAX);
        return HAL_RET_PARAMETER_ERROR;

	}
	status = i2c_smbus_write_i2c_block_data(gMhlDevice.pI2cClient, command,
											length, blockData);
	if (status < 0)
	{
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
    			"i2c_smbus_write_i2c_block_data returned error: %d\n",status);
		return HAL_RET_FAILURE;
	}

	return HAL_RET_SUCCESS;
}
예제 #3
0
static halReturn_t HalGpioConfigStatus(enum iomux_func status)
{
    int ret = 0;
    struct iomux_block *pMhlGpioBlock = NULL;
    struct block_config *pMhlGpioBlockConfig = NULL;

    /* get gpio block*/
    pMhlGpioBlock = iomux_get_block(MHL_GPIO_BLOCK_NAME);
    if (IS_ERR(pMhlGpioBlock))
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalGpioSetResource: Get GPIO Block Failed\n");
        return HAL_RET_FAILURE;
    }

    /* get gpio block config*/
    pMhlGpioBlockConfig = iomux_get_blockconfig(MHL_GPIO_BLOCK_NAME);
    if (IS_ERR(pMhlGpioBlockConfig))
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalGpioSetResource: get GPIO Block Config Failed\n");
        return HAL_RET_FAILURE;
    }

    /* config gpio work mode*/
    ret = blockmux_set(pMhlGpioBlock, pMhlGpioBlockConfig, status);
    if (ret)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalGpioConfigStatus: Config GPIO Block  Failed\n");
        return HAL_RET_FAILURE;
    }

    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;
}
int32_t StopMhlTxDevice(void)
{
	halReturn_t		halStatus;
	printk("Stopping %s\n", MHL_PART_NAME);
	HalRemoveIrqHandler();
    //HalRemoveSilMonRequestIrqHandler();
#ifdef RGB_BOARD
    //HalRemoveSilExtDeviceIrqHandler();
#endif
	halStatus = HalCloseI2cDevice();
    if (halStatus != HAL_RET_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
    			"Closing of I2c device failed, error code: %d\n",halStatus);
    	return -EIO;
    }
	halStatus = HalTerm();
    if (halStatus != HAL_RET_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
    			"Termination of HAL failed, error code: %d\n",halStatus);
    	return -EIO;
    }
	SiiOsTerm();
	return 0;
}
/**
 * @brief Read a series of bytes from an I2c device using SMBus protocol.
 *
 *****************************************************************************/
halReturn_t HalSmbusReadBlock(uint8_t command, uint8_t *buffer, uint8_t *bufferLen)
{
	halReturn_t		retStatus;
	int32_t			status;
	
	retStatus = I2cAccessCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}

	if(*bufferLen > I2C_SMBUS_BLOCK_MAX)
	{
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
    			"HalSmbusReadBlock, bufferLen param too big (%d) max size (%d)!\n",
    			*bufferLen, I2C_SMBUS_BLOCK_MAX);
        return HAL_RET_PARAMETER_ERROR;

	}
	status = i2c_smbus_read_i2c_block_data(gMhlDevice.pI2cClient, command,
										   *bufferLen, buffer);
	if (status < 0)
	{
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
    			"i2c_smbus_read_i2c_block_data returned error: %d\n",status);
		return HAL_RET_FAILURE;
	}

	*bufferLen = (uint8_t)status;	/* return # of bytes read */
	
	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;
}
halReturn_t HalInstallIrqHandler(fwIrqHandler_t irqHandler)
{
	//int				retStatus;
	halReturn_t 	halRet;

	init_waitqueue_head(&mhl_irq_wq);
	
	mhl_irq_task = kthread_create(mhl_irq_kthread, NULL, "hdmi_update_kthread"); 
	wake_up_process(mhl_irq_task);

	
	if(irqHandler == NULL)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInstallIrqHandler: irqHandler cannot be NULL!\n");
		return HAL_RET_PARAMETER_ERROR;
	}
	halRet = I2cAccessCheck();
	if (halRet != HAL_RET_SUCCESS)
	{
		return halRet;
	}
	#if 0
	if(gMhlDevice.pI2cClient->irq == 0)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInstallIrqHandler: No IRQ assigned to I2C device!\n");
		return HAL_RET_FAILURE;
	}
#endif


#if 0
	mt_set_gpio_mode(GPIO_MHL_EINT_PIN, GPIO_MODE_01);
	mt_set_gpio_dir(GPIO_MHL_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_select(GPIO_MHL_EINT_PIN,  GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO_MHL_EINT_PIN, true);
#endif
	mt65xx_eint_set_sens(CUST_EINT_MHL_NUM, MT65xx_LEVEL_SENSITIVE);
    mt65xx_eint_registration(CUST_EINT_MHL_NUM, 0, MT65XX_EINT_POL_NEG, &mhl8338_irq_handler, 0);

	#if 0
	gMhlDevice.irqHandler = irqHandler;
	retStatus = request_threaded_irq(gMhlDevice.pI2cClient->irq, NULL,
									 HalThreadedIrqHandler,
									 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
									 gMhlI2cIdTable[0].name,
									 &gMhlDevice);
	if(retStatus != 0)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInstallIrqHandler: request_threaded_irq failed, status: %d\n",
				retStatus);
		gMhlDevice.irqHandler = NULL;
		return HAL_RET_FAILURE;
	}
	#endif
	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;
}
/**
 * @brief Configure platform GPIOs needed by the MHL device.
 *
 *****************************************************************************/
halReturn_t HalGpioInit(void)
{
	int status;
    int i ,j;

#if 0 // pinmux need not be configed here in aml platform. by Jets, Nov/25/2013
    HalSetPinMux();
#endif

	aml_get_gpio();

    for(i =0; i< ARRAY_SIZE(GPIO_List);i++)
    {
    	/* Request  GPIO . */
        status = gpio_request(GPIO_List[i].gpio_number, GPIO_List[i].gpio_descripion);
    	if (status < 0 && status != -EBUSY)
    	{
    		SII_DEBUG_PRINT(MSG_ERR,"HalInit gpio_request for GPIO %d (H/W Reset) failed, status: %d\n", GPIO_List[i].gpio_number, status);
            for(j = 0; j < i;j++)
            {
                gpio_free(GPIO_List[j].gpio_number);
            }
            return HAL_RET_FAILURE;
    	}

        if(GPIO_List[i].gpio_direction == DIRECTION_OUT)
        {
            status = gpio_direction_output(GPIO_List[i].gpio_number, GPIO_List[i].init_value);
        }
        else
        {
            status = gpio_direction_input(GPIO_List[i].gpio_number);
        }

    	if (status < 0)
    	{
            SII_DEBUG_PRINT(MSG_ERR,"HalInit gpio_direction_output for GPIO %d (H/W Reset) failed, status: %d\n", GPIO_List[i].gpio_number, status);
            for(j = 0; j <= i;j++)
            {
                gpio_free(GPIO_List[j].gpio_number);
            }
    		return HAL_RET_FAILURE;
    	}
//        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"initialize %s successfully\n",GPIO_List[i].gpio_descripion);
    }



   	return HAL_RET_SUCCESS;
}
예제 #11
0
/**
 * @brief SilMon IRQ handler,
 *
 *****************************************************************************/
static irqreturn_t HalSilMonRequestIrqHandler(int irq, void *data)
{
	pMhlDeviceContext	pMhlDevContext = (pMhlDeviceContext)data;

    int gpio_value;
	unsigned long		flags;
//  SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"------------- HalSilMonRequestIrqHandler irq coming! -------------\n");
    spin_lock_irqsave(&pMhlDevContext->SilMonRequestIRQ_Lock, flags);

    if(HalGpioGetPin(GPIO_REQ_IN,&gpio_value)<0)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalSilMonRequestIrqHandler GPIO(%d) get error\n",gpio_value);
        spin_unlock_irqrestore(&pMhlDevContext->SilMonRequestIRQ_Lock, flags);
        return IRQ_HANDLED;
    }

    /*
    the following is for void wrongly invoke irq, it may be caused by EMI when plug in/out MHL cable;
    */
    if((gMhlDevice.SilMonControlReleased&& gpio_value)
       ||(!gMhlDevice.SilMonControlReleased&&!gpio_value))
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalSilMonRequestIrqHandler, wrong IRQ coming, please check you board\n");
        spin_unlock_irqrestore(&pMhlDevContext->SilMonRequestIRQ_Lock, flags);
        return IRQ_HANDLED;
    }

    if(gpio_value)
    {
        HalGpioSetPin(GPIO_GNT,1);
        HalEnableI2C(true);
        enable_irq(pMhlDevContext->pI2cClient->irq);
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"release SiliMon control\n");
        gMhlDevice.SilMonControlReleased = true;
    }
    else
    {
        disable_irq(pMhlDevContext->pI2cClient->irq);       
        HalEnableI2C(false);
        HalGpioSetPin(GPIO_GNT,0);
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"under SiliMon control \n");
        gMhlDevice.SilMonControlReleased = false;
    }

    spin_unlock_irqrestore(&pMhlDevContext->SilMonRequestIRQ_Lock, flags);

	return IRQ_HANDLED;
}
halReturn_t HalInit(void)
{
	//halReturn_t	status;
	if (gHalInitedFlag)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Error: Hal layer already inited!\n");
		return HAL_RET_ALREADY_INITIALIZED;
	}
	gMhlDevice.driver.driver.name = NULL;
	gMhlDevice.driver.id_table = NULL;
	gMhlDevice.driver.probe = NULL;
	gMhlDevice.driver.remove = NULL;
	gMhlDevice.pI2cClient = NULL;
	gMhlDevice.irqHandler = NULL;
#ifdef RGB_BOARD
	gMhlDevice.ExtDeviceirqHandler = NULL;
#endif
	/*
	status = HalGpioInit();
	if(status != HAL_RET_SUCCESS)
	{
		return status;
	}
	*/
	gHalInitedFlag = true;
	return HAL_RET_SUCCESS;
}
예제 #13
0
/*
 *  @brief Interrupt handler for MHL transmitter interrupts.
 *
 *  @param[in]		irq		The number of the asserted IRQ line that caused
 *  						this handler to be called.
 *  @param[in]		data	Data pointer passed when the interrupt was enabled,
 *  						which in this case is a pointer to the
 *  						MhlDeviceContext of the I2c device.
 *
 *  @return     Always returns IRQ_HANDLED.
 *
 *****************************************************************************/
static irqreturn_t HalThreadedIrqHandler(int irq, void *data)
{
	pMhlDeviceContext	pMhlDevContext = (pMhlDeviceContext)data;

//	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalThreadedIrqHandler called\n");
	if (HalAcquireIsrLock() == HAL_RET_SUCCESS)
    {
/*
        if(pMhlDevContext->CheckDevice &&!pMhlDevContext->CheckDevice(0))//mhl device check;
        {
            SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"mhl device errror\n");
            HalReleaseIsrLock();
            return IRQ_HANDLED;
        }
*/
        if(pMhlDevContext->irqHandler)
        {
            (pMhlDevContext->irqHandler)();
        }
		HalReleaseIsrLock();
	}
    else
    {
        SII_DEBUG_PRINT(MSG_ERR,"------------- irq missing! -------------\n");
    }

	return IRQ_HANDLED;
}
ssize_t ReadDevCap(struct device *dev, struct device_attribute *attr,
					char *buf)
{
	uint8_t		regValue;
	int			status = -EINVAL;
	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "ReadDevCap called\n");
	if(HalAcquireIsrLock() != HAL_RET_SUCCESS)
	{
		return -ERESTARTSYS;
	}
	do {
		if(gDriverContext.flags & MHL_STATE_FLAG_CONNECTED) {
			status = SiiTxGetPeerDevCapEntry(gDriverContext.devCapOffset,
											 &regValue);
			if(status != 0) {
				status = -EAGAIN;
				break;
			}
			status = scnprintf(buf, PAGE_SIZE, "offset:0x%02x=0x%02x",
								gDriverContext.devCapOffset, regValue);
		}
	} while(false);
	HalReleaseIsrLock();
	return status;
}
/**
 * @brief Read a series of bytes from an I2c device.
 *
 *****************************************************************************/
halReturn_t HalI2cMasterRead(uint8_t i2cAddr, uint8_t length,
								uint8_t *buffer)
{
    struct i2c_msg	i2cMsg;
    
	halReturn_t		retStatus;
	int32_t			status;
	
	retStatus = I2cAccessCheck();
	if (retStatus != HAL_RET_SUCCESS)
	{
		return retStatus;
	}

    i2cMsg.addr = (i2cAddr >> 1);
    i2cMsg.flags = I2C_M_RD;
    i2cMsg.len = length;
    i2cMsg.buf = buffer;

    status = i2c_transfer(gMhlDevice.pI2cClient->adapter, &i2cMsg, 1);
	if (status < 0)
	{
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "i2c_transfer error: %d\n",status);
		return HAL_RET_FAILURE;
	}

	return HAL_RET_SUCCESS;
}
예제 #16
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;
}
halReturn_t HalInstallSilExtDeviceIrqHandler(fwIrqHandler_t irqHandler)
{
	int				retStatus;
	halReturn_t 	halRet;
	halRet = I2cAccessCheck();
	if (halRet != HAL_RET_SUCCESS)
	{
		return halRet;
	}
    halRet = HalGetGpioIrqNumber(GPIO_V_INT, &gMhlDevice.SilExtDeviceIRQ);
    if(halRet!= HAL_RET_SUCCESS)
    {
        return halRet;
    } 
    gMhlDevice.ExtDeviceirqHandler = irqHandler;
	retStatus = request_threaded_irq(gMhlDevice.SilExtDeviceIRQ,NULL,
									 HalSilExtDeviceIrqHandler,
									 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
									 gMhlI2cIdTable[0].name,
									 &gMhlDevice);
	if(retStatus != 0)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInstallIrqHandler: request_threaded_irq failed, status: %d\n",
				retStatus);
        gMhlDevice.ExtDeviceirqHandler = NULL;
		return HAL_RET_FAILURE;
	}
	return HAL_RET_SUCCESS;
}
halReturn_t HalInstallSilMonRequestIrqHandler(void)
{
	int				retStatus;
	halReturn_t 	halRet;
	halRet = I2cAccessCheck();
	if (halRet != HAL_RET_SUCCESS)
	{
		return halRet;
	}
    halRet = HalGetGpioIrqNumber(GPIO_REQ_IN, &gMhlDevice.SilMonRequestIRQ);
    if(halRet!= HAL_RET_SUCCESS)
    {
        return halRet;
    }   
    spin_lock_init(&gMhlDevice.SilMonRequestIRQ_Lock);
    gMhlDevice.SilMonControlReleased  = true;
	retStatus = request_threaded_irq(gMhlDevice.SilMonRequestIRQ, NULL,
									 HalSilMonRequestIrqHandler,
									 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT,
									 gMhlI2cIdTable[0].name,
									 &gMhlDevice);
	if(retStatus != 0)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInstallIrqHandler: request_threaded_irq failed, status: %d\n",
				retStatus);
		return HAL_RET_FAILURE;
	}
	return HAL_RET_SUCCESS;
}
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;
}
/**
 *  @brief Close the MHL transmitter device
 *
 *  This is the file operation handler for release requests received from the
 *  system.  It is called when the last process calls close() on the File
 *  structure created by open().
 *
 *  Since this driver is only concerned with restricting access to one process
 *  at at time all that needs to be done here is to flag that the driver is no
 *  longer open by any process.
 *
 *  @param[in]		pInode	pointer to inode representing transmitter device
 *  @param[in]		pFile	pointer to file descriptor being closed.
 *
 *  @return		Always returns 0 to indicate success.
 *
 *****************************************************************************/
int32_t SiiMhlRelease(struct inode *pInode, struct file *pFile)
{
	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "Close %s\n", MHL_DRIVER_NAME);

	bTxOpen = false;	// flag driver has been closed

	return 0;
}
halReturn_t HalInitCheck(void)
{
	if (!(gHalInitedFlag))
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Error: Hal layer not currently initialize!\n");
		return HAL_RET_NOT_INITIALIZED;
	}
	return HAL_RET_SUCCESS;
}
예제 #22
0
/**
 * @brief Install IRQ handler.
 *
 *****************************************************************************/
halReturn_t HalInstallIrqHandler(fwIrqHandler_t irqHandler)
{
	int				retStatus;
	halReturn_t 	halRet;

	if(irqHandler == NULL)
	{
		SII_DEBUG_PRINT(MSG_ERR,"HalInstallIrqHandler: irqHandler cannot be NULL!\n");
		return HAL_RET_PARAMETER_ERROR;
	}

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

	if(gMhlDevice.pI2cClient->irq == 0)
	{
		SII_DEBUG_PRINT(MSG_ERR,"HalInstallIrqHandler: No IRQ assigned to I2C device!\n");
		return HAL_RET_FAILURE;
	}

	gMhlDevice.irqHandler = irqHandler;

	aml_config_gpio_irq();

	retStatus = request_threaded_irq(gMhlDevice.pI2cClient->irq, NULL,
									 HalThreadedIrqHandler,
									 IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
									 gMhlI2cIdTable[0].name,
									 &gMhlDevice);

	if(retStatus != 0)
	{
		SII_DEBUG_PRINT(MSG_ERR,"sii5293 HalInstallIrqHandler: request_threaded_irq failed, status: %d\n",
				retStatus);
		gMhlDevice.irqHandler = NULL;
		return HAL_RET_FAILURE;
	}

	return HAL_RET_SUCCESS;
}
int32_t SiiMhlOpen(struct inode *pInode, struct file *pFile)
{
	if (bTxOpen) {
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
				"Driver already open, failing open request\n");
		return -EBUSY;
	}
	bTxOpen = true;
	return 0;
}
예제 #24
0
halReturn_t HalGpioSetResource(void)
{
    int status;
    struct iomux_pin        *pIntPin = NULL; //interrupt pin "T28"
    struct iomux_pin        *pRstPin = NULL; //Reset pin "T26"
    /*Set interrupt GPIO resource*/
    pIntPin = iomux_get_pin(PIN_NAME_INT);
    if( !pIntPin )
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                        "HalGpioSetResource: get pin of GPIO %d failed\n",
                        W_INT_GPIO);
        return HAL_RET_FAILURE;
    }
    status = pinmux_setpullupdown(pIntPin, PULLUP);
    if (status < 0)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                        "HalGpioSetResource: pinmux_setpullupdown of GPIO %d failed, status = %d \n",
                        W_INT_GPIO,status);
        return HAL_RET_FAILURE;
    }

    /*Set Reset GPIO resource*/
    pRstPin = iomux_get_pin(PIN_NAME_RST);
    if( !pRstPin )
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                        "HalGpioSetResource get pin of GPIO %d failed\n",
                        W_RST_GPIO);
        return HAL_RET_FAILURE;
    }
    status = pinmux_setpullupdown(pIntPin, PULLUP);
    if (status < 0)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                        "HalGpioSetResource: pinmux_setpullupdown of GPIO %d failed, status = %d \n",
                        W_RST_GPIO,status);
        return HAL_RET_FAILURE;
    }

    return HAL_RET_SUCCESS;
}
static irqreturn_t HalSilMonRequestIrqHandler(int irq, void *data)
{
	pMhlDeviceContext	pMhlDevContext = (pMhlDeviceContext)data;
    int gpio_value;
	unsigned long		flags;
    spin_lock_irqsave(&pMhlDevContext->SilMonRequestIRQ_Lock, flags);
    if(HalGpioGetPin(GPIO_REQ_IN,&gpio_value)<0)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalSilMonRequestIrqHandler GPIO(%d) get error\n",gpio_value);
        spin_unlock_irqrestore(&pMhlDevContext->SilMonRequestIRQ_Lock, flags);
        return IRQ_HANDLED;
    }
    if((gMhlDevice.SilMonControlReleased&& gpio_value)
       ||(!gMhlDevice.SilMonControlReleased&&!gpio_value))
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalSilMonRequestIrqHandler, wrong IRQ coming, please check you board\n");
        spin_unlock_irqrestore(&pMhlDevContext->SilMonRequestIRQ_Lock, flags);
        return IRQ_HANDLED;
    }
    if(gpio_value)
    {
        //HalGpioSetPin(GPIO_GNT,1);
        HalEnableI2C(true);
        enable_irq(pMhlDevContext->pI2cClient->irq);
#ifdef RGB_BOARD
        enable_irq(pMhlDevContext->SilExtDeviceIRQ);
#endif
        gMhlDevice.SilMonControlReleased = true;
    }
    else
    {
        disable_irq(pMhlDevContext->pI2cClient->irq);
#ifdef RGB_BOARD
        disable_irq(pMhlDevContext->SilExtDeviceIRQ);
#endif       
        HalEnableI2C(false);
        //HalGpioSetPin(GPIO_GNT,0);
        gMhlDevice.SilMonControlReleased = false;
    }
    spin_unlock_irqrestore(&pMhlDevContext->SilMonRequestIRQ_Lock, flags);
	return IRQ_HANDLED;
}
static void HalSetPinMux(void)
{
#define PADCONF_SDMMC2_CLK_OFFSET			0x128   //GPIO130 OFFSET
    int i;
    unsigned short x,old;
    void * base = NULL;
    base = ioremap(IO_PHY_ADDRESS, 
                          0x10000);

    if (base == NULL)
    {
        SII_DEBUG_PRINT(MSG_ERR,"IO Mapping failed\n");
        return ;
    } 
    else
    {
        SII_DEBUG_PRINT(MSG_STAT,"iobase = 0x%x\n",base);
    }

    for(i = 0 ;i<10;i++) //GPIO130 ~~ GPIO139
    {
        old = ioread16(base + PAD_CONF_OFFSET + PADCONF_SDMMC2_CLK_OFFSET + i*2);

        switch(i)
        {
        case 5: 
                x = (IEN | EN | PTU | M4 );break; 


        default:               
                x = (M4 | IDIS);break;
        }

        iowrite16(x,base + PAD_CONF_OFFSET + PADCONF_SDMMC2_CLK_OFFSET + i*2);

//        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"GPIO%d {0x%x}:0x%x => 0x%x ;\n",130+ i,(int)(base + 0x2030 + 0x128 + i*2),old,x);
    }

    iounmap(base);
}
halReturn_t HalGpioInit(void)
{
    int status;
    int i ,j;
    HalSetPinMux();
    for(i =0; i< ARRAY_SIZE(GPIO_List); i++)
    {
        status = gpio_request(GPIO_List[i].gpio_number, GPIO_List[i].gpio_descripion);
        if (status < 0 && status != -EBUSY)
        {
            SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInit gpio_request for GPIO %d (H/W Reset) failed, status: %d\n", GPIO_List[i].gpio_number, status);
            for(j = 0; j < i; j++)
            {
                gpio_free(GPIO_List[j].gpio_number);
            }
            return HAL_RET_FAILURE;
        }
        if(GPIO_List[i].gpio_direction == DIRECTION_OUT)
        {
            status = gpio_direction_output(GPIO_List[i].gpio_number, GPIO_List[i].init_value);
        }
        else
        {
            status = gpio_direction_input(GPIO_List[i].gpio_number);
        }
        if (status < 0)
        {
            SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInit gpio_direction_output for GPIO %d (H/W Reset) failed, status: %d\n", GPIO_List[i].gpio_number, status);
            for(j = 0; j <= i; j++)
            {
                gpio_free(GPIO_List[j].gpio_number);
            }
            return HAL_RET_FAILURE;
        }
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"initialize %s successfully\n",GPIO_List[i].gpio_descripion);
    }
    return HAL_RET_SUCCESS;
}
ssize_t SelectDevCap(struct device *dev, struct device_attribute *attr,
					 const char *buf, size_t count)
{
	unsigned long	devCapOffset;
	int				status = -EINVAL;
	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "SelectDevCap received string: ""%s""\n", buf);
	do {
		if(strict_strtoul(buf, 0, &devCapOffset)) {
			SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
							"Unable to convert register offset string\n");
			break;
		}
		if(devCapOffset >= 0x0F) {
			SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
					"dev cap offset (0x%x) is too large to be valid\n",
					devCapOffset);
			break;
		}
		gDriverContext.devCapOffset = (uint8_t)devCapOffset;
		status = count;
	} while(false);
	return status;
}
예제 #29
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;
}
ssize_t SendRcpAck(struct device *dev, struct device_attribute *attr,
				const char *buf, size_t count)
{
	unsigned long	keyCode = 0x100;	
	unsigned long	errCode = 0x100;
	char			*pStr;
	int				status = -EINVAL;
	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"SendRcpAck received buf len = %d\n", count);
	while(count)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"SendRcpAck received string: ""%s""\n", buf);
		pStr = strstr(buf, "keycode=");
		if(pStr != NULL) 
        {
               	if(strict_strtoul(pStr + strlen("keycode="), 0, &keyCode)) {
				SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "Unable to convert keycode string\n");
				break;
                }                 
        }
		pStr = strstr(buf, "errorcode=");
		if(pStr != NULL) {
               	if(strict_strtoul(pStr + strlen("errorcode="), 0, &errCode)) {
				SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE, "Unable to convert keycode string\n");
				break;
                } 
        }
        while(--count&&*buf++);
    }
    if((keyCode > 0xFF) || (errCode > 0xFF)) {
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Invalid key code or error code "\
						"specified, key code: 0x%02x  error code: 0x%02x\n",
						(int)keyCode, (int)errCode);
		return status;
	}
	if(HalAcquireIsrLock() != HAL_RET_SUCCESS)
	{
		return -ERESTARTSYS;
	}
	while(gDriverContext.flags & MHL_STATE_FLAG_RCP_READY) {
		if((keyCode != gDriverContext.keyCode)
			|| !(gDriverContext.flags & MHL_STATE_FLAG_RCP_RECEIVED)) {
			SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
					"Attempting to ACK a key code that was not received!\n");
			break;
		}
		if(errCode == 0) {
			SiiMhlTxRcpkSend((uint8_t)keyCode);
		} else {
			SiiMhlTxRcpeSend((uint8_t)errCode);
		}
		status = count;
		break;
	}
	HalReleaseIsrLock();
	return status;
}