コード例 #1
0
ファイル: i2c-adap-pxa.c プロジェクト: muromec/linux-ezxdev
void ezx_i2c_pm_resume(void)
{
        /* enable clocks */
        CKEN |= CKEN14_I2C;
        set_GPIO_mode(117 | GPIO_ALT_FN_1_IN);
        set_GPIO_mode(118 | GPIO_ALT_FN_1_IN);
        /* enable irqs */
        enable_irq(i2c_pxa_data.irq);
        /* disable unit */
        _ICR(adap) &= ~ICR_IUE;
        /* reset the unit */
        _ICR(adap) |= ICR_UR;
        udelay(100);
        _ICR(adap) |= ICR_FM;
        /* disable unit */
        _ICR(adap) &= ~ICR_IUE;
        /* XXX: I2C_PXA_SLAVE_ADDR == I2C_PXA_PWR_SLAVE_ADDR ??? */
        /* set our slave address */
        _ISAR(adap) = I2C_PXA_SLAVE_ADDR;
        /* set control register values */
        _ICR(adap) = I2C_ICR_INIT;
        /* set clear interrupt bits */
        _ISR(adap) = I2C_ISR_INIT;
        /* enable unit */
        _ICR(adap) |= ICR_IUE;
        udelay(100);					
}
コード例 #2
0
static void i2c_pxa_reset(struct pxa_i2c *i2c)
{
	pr_debug("Resetting I2C Controller Unit\n");

	/* abort any transfer currently under way */
	i2c_pxa_abort(i2c);

	/* reset according to 9.8 */
	writel(ICR_UR, _ICR(i2c));
	writel(I2C_ISR_INIT, _ISR(i2c));
	writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c));

	writel(i2c->slave_addr, _ISAR(i2c));

	/* set control register values */
	writel(I2C_ICR_INIT, _ICR(i2c));

#ifdef CONFIG_I2C_PXA_SLAVE
	dev_info(&i2c->adap.dev, "Enabling slave mode\n");
	writel(readl(_ICR(i2c)) | ICR_SADIE | ICR_ALDIE | ICR_SSDIE, _ICR(i2c));
#endif

	i2c_pxa_set_slave(i2c, 0);

	/* enable unit */
	writel(readl(_ICR(i2c)) | ICR_IUE, _ICR(i2c));
	udelay(100);
}
コード例 #3
0
ファイル: i2c-adap-pxa.c プロジェクト: muromec/linux-ezxdev
static void i2c_pxa_reset(struct i2c_algo_pxa_data *adap)
{
        /* set the global I2C clocks on */
        CKEN |= CKEN14_I2C;

	set_GPIO_mode(117 | GPIO_ALT_FN_1_IN);
	set_GPIO_mode(118 | GPIO_ALT_FN_1_IN);

#ifdef CONFIG_POWER_I2C
        /* set the global PWR_I2C clock on */
        CKEN |= CKEN15_PWRI2C;

	/* Enable PI2C controller PWR_SCL and PWR_SDA */
	PCFR |= PCFR_PI2CEN;

	/* Setup GPIO3 and GPIO4 to ALT_FN1_IN (PWR_SCL and PWR_SDA) */
	set_GPIO_mode(3 | GPIO_ALT_FN_1_IN);
	set_GPIO_mode(4 | GPIO_ALT_FN_1_IN);

#endif

        /* disable unit */
	_ICR(adap) &= ~ICR_IUE;

        /* reset the unit */
	_ICR(adap) |= ICR_UR;
        udelay(100);
	_ICR(adap) |= ICR_FM;
	
        /* disable unit */
	_ICR(adap) &= ~ICR_IUE;

	/* XXX: I2C_PXA_SLAVE_ADDR == I2C_PXA_PWR_SLAVE_ADDR ??? */
        /* set our slave address */
	_ISAR(adap) = I2C_PXA_SLAVE_ADDR;

        /* set control register values */
	_ICR(adap) = I2C_ICR_INIT;

        /* set clear interrupt bits */
	_ISR(adap) = I2C_ISR_INIT;

        /* enable unit */
	_ICR(adap) |= ICR_IUE;
        udelay(100);

}
コード例 #4
0
ファイル: i2c-adap-pxa.c プロジェクト: muromec/linux-ezxdev
static int ezx_i2c_pm_callback(struct pm_dev *pm_dev, pm_request_t req, void *data)
{
	switch(req)
	{
	case PM_SUSPEND:
		/* disable IRQs */
		if (i2c_pxa_data.irq) 
		          disable_irq(i2c_pxa_data.irq);
		/* disable PI2C Controller */
		PCFR &= ~PCFR_PI2CEN;
		
		/* disable clocks */
		CKEN &= ~CKEN14_I2C;

#ifdef CONFIG_POWER_I2C
		if (i2c_pxa_pwr_data.irq)
		          disable_irq(i2c_pxa_pwr_data.irq);
		/* disable PI2C Controller */
		PCFR &= ~PCFR_PI2CEN;
		CKEN &= ~CKEN15_PWRI2C;
#endif		
		break;
	case PM_RESUME:
        /* enable clocks */
        CKEN |= CKEN14_I2C;

        set_GPIO_mode(117 | GPIO_ALT_FN_1_IN);
        set_GPIO_mode(118 | GPIO_ALT_FN_1_IN);
        /* enable irqs */
        enable_irq(i2c_pxa_data.irq);
#ifdef CONFIG_POWER_I2C
      	/* set the global PWR_I2C clock on */
        CKEN |= CKEN15_PWRI2C;

		/* Enable PI2C controller PWR_SCL and PWR_SDA */
		PCFR |= PCFR_PI2CEN;
        set_GPIO_mode(3 | GPIO_ALT_FN_1_IN);
        set_GPIO_mode(4 | GPIO_ALT_FN_1_IN);
		enable_irq(i2c_pxa_pwr_data.irq);
#endif	
	
 	    /* disable unit */
		_ICR(adap) &= ~ICR_IUE;

	    /* reset the unit */
		_ICR(adap) |= ICR_UR;
	    udelay(100);
		_ICR(adap) |= ICR_FM;
        /* disable unit */
		_ICR(adap) &= ~ICR_IUE;

		/* XXX: I2C_PXA_SLAVE_ADDR == I2C_PXA_PWR_SLAVE_ADDR ??? */
	    /* set our slave address */
		_ISAR(adap) = I2C_PXA_SLAVE_ADDR;

	    /* set control register values */
		_ICR(adap) = I2C_ICR_INIT;

    	/* set clear interrupt bits */
		_ISR(adap) = I2C_ISR_INIT;

        /* enable unit */
		_ICR(adap) |= ICR_IUE;
        udelay(100);	
		break;
	}
	return 0;
}