Exemple #1
0
static void init_adc(void) {
	/* Configure the ADC */
	REG_STORE(AT91C_PMC_PCER, (1 << AT91C_ID_ADC));
	REG_STORE(AT91C_ADC_MR, 0);
	REG_ORIN(AT91C_ADC_MR, AT91C_ADC_TRGEN_DIS);
	REG_ORIN(AT91C_ADC_MR, 0x00000500); // 4MHz
	REG_ORIN(AT91C_ADC_MR, 0x001f0000); // 64uS
	REG_ORIN(AT91C_ADC_MR, 0x03000000); // 750nS
	REG_STORE(AT91C_ADC_CHER, AT91C_ADC_CH6 | AT91C_ADC_CH4);
	REG_STORE(AT91C_ADC_CR, AT91C_ADC_START);
}
Exemple #2
0
static int omap3_clk_config(struct time_dev_conf *conf) {
	volatile struct gptimerxx_x *gptimer = GPTIMER1_BASE;

	REG_ORIN(CM_FCLKEN_WKUP, 1);
	REG_ORIN(CM_ICLKEN_WKUP, 1);
	REG_ANDIN(CM_CLKSEL_WKUP, ~1);

	REG_STORE(&gptimer->cfg, 0x2);

	REG_STORE(&gptimer->tpir, 232000);
	REG_STORE(&gptimer->tnir, -768000);

	REG_STORE(&gptimer->tcrr, OMAP_LOAD_VALUE);
	REG_STORE(&gptimer->tldr, OMAP_LOAD_VALUE);

	REG_STORE(&gptimer->tclr, GPTIMER_TCLR_START | GPTIMER_TCLR_AUTORELOAD);

	REG_STORE(&gptimer->tier, GPTIMER_TIER_OVERFLOW);
	REG_STORE(&gptimer->twer, GPTIMER_TIER_OVERFLOW);

	return 0;
}
Exemple #3
0
static int ti81xx_start(struct usb_hcd *hcd) {
	struct ti81xx_usb *tiusb = hcd2ti(hcd);
	int ret;

	assert(tiusb == (void *) 0x47401000);

	ret = irq_attach(TI8168_USB0_IRQ, ti81xx_irq, 0, hcd, "ti8168 usb0 irq");
	if (0 != ret) {
		return ret;
	}

	REG_ORIN(&tiusb->ctrl, TI81_USB_CTRL_RST);

	while((REG_LOAD(&tiusb->ctrl) & TI81_USB_CTRL_RST));

	REG_STORE(&tiusb->phy_utmi, TI81_USB_PHYUTMI_DEFAULT);

	{
		uint32_t regval = REG_LOAD(&tiusb->mode);
		regval &= ~TI81_USB_MODE_IDDIG;
		regval |= 0x80;
		REG_STORE(&tiusb->mode, regval);
	}

	REG_ORIN(0x48140620, 0x00000003);
	REG_ORIN(0x48140624, 0xf);

	REG_STORE(&tiusb->irq_set0, 0xffffffff);
	REG_STORE(&tiusb->irq_set1, TI81_USB_IRQ_STAT1_ALL_BUT_SOF);
	REG8_STORE(&tiusb->m_devctl, TI81_USB_DEVCTL_SESSION);
	REG8_STORE(&tiusb->m_intrusbe, 0xff);

	ti81xx_endp_fifo_init(tiusb);

	return 0;
}
static int stm32_uart_setup(struct uart *dev, const struct uart_params *params) {
	struct uart_stm32 *uart = (struct uart_stm32 *) dev->base_addr;

	REG_ORIN(RCC_APB1RSTR,RCC_APB1PWR);
	REG_ORIN(RCC_APB2ENR,RCC_APB2GPIOx);
	REG_ORIN(RCC_APB2ENR,RCC_APB2AFIO);

	REG_ORIN(RCC_APB2ENR,RCC_APB2ENR_USART1EN);

	gpio_settings(UART_GPIO, TX_PIN ,
			GPIO_MODE_OUTPUT | GPIO_MODE_OUT_ALTERNATE);
	gpio_settings(UART_GPIO, RX_PIN, GPIO_MODE_INPUT);

	REG_STORE(&uart->brr, SYS_CLOCK / params->baud_rate);
	REG_ORIN(&uart->cr1, USART_FLAG_RE | USART_FLAG_TE);

	REG_ORIN(&uart->cr1, USART_FLAG_UE);

	return 0;
}