Exemplo n.º 1
0
/**
 *	This is really acting as a filter driver, so only the zynq HAL can know if the SDHCI
 *	controller is enabled.
 *
 *	If it is, we ask the generic SDHCI driver to do its stuff, otherwise we return an error.
 **/
static BT_HANDLE zynq_sdhci_probe(const BT_INTEGRATED_DEVICE *pDevice, BT_ERROR *pError) {

	BT_ERROR Error;
	BT_BOOL bEnabled = BT_FALSE;
	volatile ZYNQ_SLCR_REGS *pRegs = bt_ioremap((void *)ZYNQ_SLCR, BT_SIZE_4K);

	const BT_RESOURCE *pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_ENUM, 0);
	if(!pResource) {
		goto err_out;
	}

	switch(pResource->ulStart) {
	case 0:
		bEnabled = (pRegs->SDIO_CLK_CTRL & ZYNQ_SLCR_CLK_CTRL_CLKACT_0);
		if(bEnabled) {	// Attempt to reset the device!
			zynq_slcr_unlock(pRegs);
			pRegs->SDIO_RST_CTRL |= 0x11;
			pRegs->SDIO_RST_CTRL &= ~0x11;
			zynq_slcr_lock(pRegs);
		}
		break;

	case 1:
		bEnabled = (pRegs->SDIO_CLK_CTRL & ZYNQ_SLCR_CLK_CTRL_CLKACT_0);
		if(bEnabled) {
			zynq_slcr_unlock(pRegs);
			pRegs->SDIO_RST_CTRL |= 0x22;
			pRegs->SDIO_RST_CTRL &= ~0x22;
			zynq_slcr_lock(pRegs);
		}
		break;

	default:
		break;
	}

	bt_iounmap(pRegs);

	if(!bEnabled) {
		Error = BT_ERR_GENERIC;
		goto err_out;
	}

	BT_INTEGRATED_DRIVER *pDriver = BT_GetIntegratedDriverByName("mmc,sdhci");
	if(!pDriver) {
		Error = BT_ERR_GENERIC;
		goto err_out;
	}

	return pDriver->pfnProbe(pDevice, pError);

err_out:
	if(pError) {
		*pError = Error;
	}

	return NULL;
}
Exemplo n.º 2
0
/**
 *	This is really acting as a filter driver, so only the zynq HAL can know if the SDHCI
 *	controller is enabled.
 *
 *	If it is, we ask the generic SDHCI driver to do its stuff, otherwise we return an error.
 **/
static BT_HANDLE zynq_sdhci_probe(const BT_INTEGRATED_DEVICE *pDevice, BT_ERROR *pError) {

	BT_ERROR Error;

	BT_BOOL bEnabled = BT_FALSE;
	const BT_RESOURCE *pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_ENUM, 0);
	if(!pResource) {
		goto err_out;
	}

	switch(pResource->ulStart) {
	case 0:
		bEnabled = (ZYNQ_SLCR->SDIO_CLK_CTRL & ZYNQ_SLCR_CLK_CTRL_CLKACT_0);
		break;

	case 1:
		bEnabled = (ZYNQ_SLCR->SDIO_CLK_CTRL & ZYNQ_SLCR_CLK_CTRL_CLKACT_0);
		break;

	default:
		break;
	}

	if(!bEnabled) {
		Error = BT_ERR_GENERIC;
		goto err_out;
	}

	BT_INTEGRATED_DRIVER *pDriver = BT_GetIntegratedDriverByName("mmc,sdhci");
	if(!pDriver) {
		Error = BT_ERR_GENERIC;
		goto err_out;
	}

	return pDriver->pfnProbe(pDevice, pError);

err_out:
	if(pError) {
		*pError = Error;
	}

	return NULL;
}