Exemple #1
0
static void lradc_keypad_hwinit ()
{
	/* Clear the Clock Gate and SFTRST for normal operation */
	HW_LRADC_CTRL0_CLR(BM_LRADC_CTRL0_SFTRST);
	HW_LRADC_CTRL0_CLR(BM_LRADC_CTRL0_CLKGATE);

	/* Disable on-chip ground reference */
	HW_LRADC_CTRL0_CLR(BM_LRADC_CTRL0_ONCHIP_GROUNDREF);

	/* Configure 6Mhz frequency */
	HW_LRADC_CTRL3_CLR(BM_LRADC_CTRL3_CYCLE_TIME);
	HW_LRADC_CTRL3_SET(BF_LRADC_CTRL3_CYCLE_TIME(LRADC_CLOCK_6MHZ));

	/* Select VddIO input on channel 6 */
	HW_LRADC_CTRL4_CLR(BM_LRADC_CTRL4_LRADC6SELECT);
	HW_LRADC_CTRL4_SET(BF_LRADC_CTRL4_LRADC6SELECT(lradc_vddio_ch));

	/*
	 * Clear the divide by two for channel 6 since it has a HW
	 * divide-by-two built in, and enable this feature for the
	 * button channel
	 */
	HW_LRADC_CTRL2_CLR(BF_LRADC_CTRL2_DIVIDE_BY_TWO(1<<VDDIO_VOLTAGE_CH));
	HW_LRADC_CTRL2_SET(BF_LRADC_CTRL2_DIVIDE_BY_TWO(1<<lradc_keypad_ch));

	/* Clear the accumulator & NUM_SAMPLES */
	HW_LRADC_CHn_CLR(VDDIO_VOLTAGE_CH, 0xFFFFFFFF);
	HW_LRADC_CHn_CLR(lradc_keypad_ch, 0xFFFFFFFF);
}
void hw_lradc_reinit(int enable_ground_ref, unsigned freq)
{
	__raw_writel(BM_LRADC_CTRL0_SFTRST,
		     mxs_lradc.base + HW_LRADC_CTRL0_SET);
	udelay(1);
	__raw_writel(BM_LRADC_CTRL0_SFTRST,
		     mxs_lradc.base + HW_LRADC_CTRL0_CLR);

	/* Clear the Clock Gate for normal operation */
	__raw_writel(BM_LRADC_CTRL0_CLKGATE,
		     mxs_lradc.base + HW_LRADC_CTRL0_CLR);

	if (enable_ground_ref)
		__raw_writel(BM_LRADC_CTRL0_ONCHIP_GROUNDREF,
			     mxs_lradc.base + HW_LRADC_CTRL0_SET);
	else
		__raw_writel(BM_LRADC_CTRL0_ONCHIP_GROUNDREF,
			    mxs_lradc.base + HW_LRADC_CTRL0_CLR);

	__raw_writel(BM_LRADC_CTRL3_CYCLE_TIME,
		     mxs_lradc.base + HW_LRADC_CTRL3_CLR);
	__raw_writel(BF_LRADC_CTRL3_CYCLE_TIME(freq),
		     mxs_lradc.base + HW_LRADC_CTRL3_SET);

	__raw_writel(BM_LRADC_CTRL4_LRADC6SELECT | BM_LRADC_CTRL4_LRADC7SELECT,
		     mxs_lradc.base + HW_LRADC_CTRL4_CLR);
	__raw_writel(BF_LRADC_CTRL4_LRADC6SELECT(mxs_lradc.vddio_voltage),
		     mxs_lradc.base + HW_LRADC_CTRL4_SET);
	__raw_writel(BF_LRADC_CTRL4_LRADC7SELECT(mxs_lradc.battery_voltage),
		     mxs_lradc.base + HW_LRADC_CTRL4_SET);
}