void sam_lowsetup(void) { /* Enable clocking for all selected UART/USARTs */ #ifdef CONFIG_SAM34_UART0 sam_uart0_enableclk(); #endif #ifdef CONFIG_SAM34_UART1 sam_uart1_enableclk(); #endif #ifdef CONFIG_SAM34_USART0 sam_usart0_enableclk(); #endif #ifdef CONFIG_SAM34_USART1 sam_usart1_enableclk(); #endif #ifdef CONFIG_SAM34_USART2 sam_usart2_enableclk(); #endif #ifdef CONFIG_SAM34_USART3 sam_usart3_enableclk(); #endif /* Configure UART pins for all selected UART/USARTs */ #ifdef CONFIG_SAM34_UART0 (void)sam_configgpio(GPIO_UART0_RXD); (void)sam_configgpio(GPIO_UART0_TXD); #endif #ifdef CONFIG_SAM34_UART1 (void)sam_configgpio(GPIO_UART1_RXD); (void)sam_configgpio(GPIO_UART1_TXD); #endif #ifdef CONFIG_SAM34_USART0 (void)sam_configgpio(GPIO_USART0_RXD); (void)sam_configgpio(GPIO_USART0_TXD); #ifdef CONFIG_USART0_OFLOWCONTROL (void)sam_configgpio(GPIO_USART0_CTS); #endif #ifdef CONFIG_USART0_IFLOWCONTROL (void)sam_configgpio(GPIO_USART0_RTS); #endif #endif #ifdef CONFIG_SAM34_USART1 (void)sam_configgpio(GPIO_USART1_RXD); (void)sam_configgpio(GPIO_USART1_TXD); #ifdef CONFIG_USART1_OFLOWCONTROL (void)sam_configgpio(GPIO_USART1_CTS); #endif #ifdef CONFIG_USART1_IFLOWCONTROL (void)sam_configgpio(GPIO_USART1_RTS); #endif #endif #ifdef CONFIG_SAM34_USART2 (void)sam_configgpio(GPIO_USART2_RXD); (void)sam_configgpio(GPIO_USART2_TXD); #ifdef CONFIG_USART2_OFLOWCONTROL (void)sam_configgpio(GPIO_USART2_CTS); #endif #ifdef CONFIG_USART2_IFLOWCONTROL (void)sam_configgpio(GPIO_USART2_RTS); #endif #endif #ifdef CONFIG_SAM34_USART3 (void)sam_configgpio(GPIO_USART3_RXD); (void)sam_configgpio(GPIO_USART3_TXD); #ifdef CONFIG_USART3_OFLOWCONTROL (void)sam_configgpio(GPIO_USART3_CTS); #endif #ifdef CONFIG_USART3_IFLOWCONTROL (void)sam_configgpio(GPIO_USART3_RTS); #endif #endif /* Configure the console (only) */ #if defined(HAVE_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG) /* Reset and disable receiver and transmitter */ putreg32((UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS), SAM_CONSOLE_BASE + SAM_UART_CR_OFFSET); /* Disable all interrupts */ putreg32(0xffffffff, SAM_CONSOLE_BASE + SAM_UART_IDR_OFFSET); /* Set up the mode register */ putreg32(MR_VALUE, SAM_CONSOLE_BASE + SAM_UART_MR_OFFSET); /* Configure the console baud. NOTE: Oversampling by 8 is not supported. * This may limit BAUD rates for lower USART clocks. */ putreg32(((SAM_USART_CLOCK + (SAM_CONSOLE_BAUD << 3)) / (SAM_CONSOLE_BAUD << 4)), SAM_CONSOLE_BASE + SAM_UART_BRGR_OFFSET); /* Enable receiver & transmitter */ putreg32((UART_CR_RXEN | UART_CR_TXEN), SAM_CONSOLE_BASE + SAM_UART_CR_OFFSET); #endif }
void sam_lowsetup(void) { /* Enable clocking for all selected UART/USARTs (USARTs may not * necessarily be configured as UARTs). */ #ifdef CONFIG_SAMA5_UART0 sam_uart0_enableclk(); #endif #ifdef CONFIG_SAMA5_UART1 sam_uart1_enableclk(); #endif #ifdef CONFIG_SAMA5_UART2 sam_uart2_enableclk(); #endif #ifdef CONFIG_SAMA5_UART3 sam_uart3_enableclk(); #endif #ifdef CONFIG_SAMA5_UART4 sam_uart4_enableclk(); #endif #ifdef CONFIG_USART0_SERIALDRIVER sam_usart0_enableclk(); #endif #ifdef CONFIG_SAMA5_USART1 sam_usart1_enableclk(); #endif #ifdef CONFIG_SAMA5_USART2 sam_usart2_enableclk(); #endif #ifdef CONFIG_SAMA5_USART3 sam_usart3_enableclk(); #endif #ifdef CONFIG_SAMA5_FLEXCOM0 sam_flexcom0_enableclk(); #endif #ifdef CONFIG_SAMA5_FLEXCOM1 sam_flexcom1_enableclk(); #endif #ifdef CONFIG_SAMA5_FLEXCOM2 sam_flexcom2_enableclk(); #endif #ifdef CONFIG_SAMA5_FLEXCOM3 sam_flexcom3_enableclk(); #endif #ifdef CONFIG_SAMA5_FLEXCOM4 sam_flexcom4_enableclk(); #endif /* Configure UART pins for all selected UART/USARTs. USARTs pins are * only configured if the USART is also configured as as a UART. */ #ifdef CONFIG_SAMA5_UART0 (void)sam_configpio(PIO_UART0_RXD); (void)sam_configpio(PIO_UART0_TXD); #endif #ifdef CONFIG_SAMA5_UART1 (void)sam_configpio(PIO_UART1_RXD); (void)sam_configpio(PIO_UART1_TXD); #endif #ifdef CONFIG_SAMA5_UART2 (void)sam_configpio(PIO_UART2_RXD); (void)sam_configpio(PIO_UART2_TXD); #endif #ifdef CONFIG_SAMA5_UART3 (void)sam_configpio(PIO_UART3_RXD); (void)sam_configpio(PIO_UART3_TXD); #endif #ifdef CONFIG_SAMA5_UART4 (void)sam_configpio(PIO_UART4_RXD); (void)sam_configpio(PIO_UART4_TXD); #endif #if defined(CONFIG_USART0_SERIALDRIVER) && defined(CONFIG_SAMA5_USART0) (void)sam_configpio(PIO_USART0_RXD); (void)sam_configpio(PIO_USART0_TXD); #ifdef CONFIG_USART0_OFLOWCONTROL (void)sam_configpio(PIO_USART0_CTS); #endif #ifdef CONFIG_USART0_IFLOWCONTROL (void)sam_configpio(PIO_USART0_RTS); #endif #endif #if defined(CONFIG_USART1_SERIALDRIVER) && defined(CONFIG_SAMA5_USART1) (void)sam_configpio(PIO_USART1_RXD); (void)sam_configpio(PIO_USART1_TXD); #ifdef CONFIG_USART1_OFLOWCONTROL (void)sam_configpio(PIO_USART1_CTS); #endif #ifdef CONFIG_USART1_IFLOWCONTROL (void)sam_configpio(PIO_USART1_RTS); #endif #endif #if defined(CONFIG_USART2_SERIALDRIVER) && defined(CONFIG_SAMA5_USART2) (void)sam_configpio(PIO_USART2_RXD); (void)sam_configpio(PIO_USART2_TXD); #ifdef CONFIG_USART2_OFLOWCONTROL (void)sam_configpio(PIO_USART2_CTS); #endif #ifdef CONFIG_USART2_IFLOWCONTROL (void)sam_configpio(PIO_USART2_RTS); #endif #endif #if defined(CONFIG_USART3_SERIALDRIVER) && defined(CONFIG_SAMA5_USART3) (void)sam_configpio(PIO_USART3_RXD); (void)sam_configpio(PIO_USART3_TXD); #ifdef CONFIG_USART3_OFLOWCONTROL (void)sam_configpio(PIO_USART3_CTS); #endif #ifdef CONFIG_USART3_IFLOWCONTROL (void)sam_configpio(PIO_USART3_RTS); #endif #endif #if defined(CONFIG_USART4_SERIALDRIVER) && defined(CONFIG_SAMA5_USART4) (void)sam_configpio(PIO_USART4_RXD); (void)sam_configpio(PIO_USART4_TXD); #ifdef CONFIG_USART4_OFLOWCONTROL (void)sam_configpio(PIO_USART4_CTS); #endif #ifdef CONFIG_USART4_IFLOWCONTROL (void)sam_configpio(PIO_USART4_RTS); #endif #endif /* For Flexcom USARTs: * * FLEXCOM_IO0 = TXD * FLEXCOM_IO1 = RXD * FLEXCOM_IO2 = SCK * FLEXCOM_IO3 = CTS * FLEXCOM_IO4 = RTS */ #if defined(CONFIG_USART0_SERIALDRIVER) && defined(CONFIG_SAMA5_FLEXCOM0_USART) (void)sam_configpio(PIO_FLEXCOM0_IO0); (void)sam_configpio(PIO_FLEXCOM0_IO1); #ifdef CONFIG_USART0_OFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM0_IO3); #endif #ifdef CONFIG_USART0_IFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM0_IO4); #endif #endif #if defined(CONFIG_USART1_SERIALDRIVER) && defined(CONFIG_SAMA5_FLEXCOM1_USART) (void)sam_configpio(PIO_FLEXCOM1_IO0); (void)sam_configpio(PIO_FLEXCOM1_IO1); #ifdef CONFIG_USART1_OFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM1_IO3); #endif #ifdef CONFIG_USART1_IFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM1_IO4); #endif #endif #if defined(CONFIG_USART2_SERIALDRIVER) && defined(CONFIG_SAMA5_FLEXCOM2_USART) (void)sam_configpio(PIO_FLEXCOM2_IO0); (void)sam_configpio(PIO_FLEXCOM2_IO1); #ifdef CONFIG_USART2_OFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM2_IO3); #endif #ifdef CONFIG_USART2_IFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM2_IO4); #endif #endif #if defined(CONFIG_USART3_SERIALDRIVER) && defined(CONFIG_SAMA5_FLEXCOM3_USART) (void)sam_configpio(PIO_FLEXCOM3_IO0); (void)sam_configpio(PIO_FLEXCOM3_IO1); #ifdef CONFIG_USART3_OFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM3_IO3); #endif #ifdef CONFIG_USART3_IFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM3_IO4); #endif #endif #if defined(CONFIG_USART4_SERIALDRIVER) && defined(CONFIG_SAMA5_FLEXCOM4_USART) (void)sam_configpio(PIO_FLEXCOM4_IO0); (void)sam_configpio(PIO_FLEXCOM4_IO1); #ifdef CONFIG_USART4_OFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM4_IO3); #endif #ifdef CONFIG_USART4_IFLOWCONTROL (void)sam_configpio(PIO_FLEXCOM4_IO4); #endif #endif /* Configure the console (only) */ #if (defined(SAMA5_HAVE_UART_CONSOLE) || defined(SAMA5_HAVE_USART_CONSOLE)) && \ !defined(SUPPRESS_CONSOLE_CONFIG) /* Reset and disable receiver and transmitter */ putreg32((UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS), SAM_CONSOLE_VBASE + SAM_UART_CR_OFFSET); /* Disable all interrupts */ putreg32(0xffffffff, SAM_CONSOLE_VBASE + SAM_UART_IDR_OFFSET); /* Set up the mode register */ putreg32(MR_VALUE, SAM_CONSOLE_VBASE + SAM_UART_MR_OFFSET); /* Configure the console baud. NOTE: Oversampling by 8 is not supported. * This may limit BAUD rates for lower USART clocks. */ putreg32(((SAM_USART_CLOCK + (SAM_CONSOLE_BAUD << 3)) / (SAM_CONSOLE_BAUD << 4)), SAM_CONSOLE_VBASE + SAM_UART_BRGR_OFFSET); /* Enable receiver & transmitter */ putreg32((UART_CR_RXEN | UART_CR_TXEN), SAM_CONSOLE_VBASE + SAM_UART_CR_OFFSET); #elif defined(SAMA5_HAVE_FLEXCOM_CONSOLE) && !defined(SUPPRESS_CONSOLE_CONFIG) /* Select USART mode for the Flexcom */ putreg32(FLEX_MR_OPMODE_USART, SAM_CONSOLE_VBASE + SAM_FLEX_MR_OFFSET); /* Reset and disable receiver and transmitter */ putreg32((FLEXUS_CR_RSTRX | FLEXUS_CR_RSTTX | FLEXUS_CR_RXDIS | FLEXUS_CR_TXDIS), SAM_CONSOLE_VBASE + SAM_FLEXUS_CR_OFFSET); /* Disable all interrupts */ putreg32(0xffffffff, SAM_CONSOLE_VBASE + SAM_FLEXUS_IDR_OFFSET); /* Set up the mode register */ putreg32(MR_VALUE, SAM_CONSOLE_VBASE + SAM_FLEXUS_MR_OFFSET); /* Configure the console baud. NOTE: Oversampling by 8 is not supported. * This may limit BAUD rates for lower USART clocks. */ putreg32(((SAM_USART_CLOCK + (SAM_CONSOLE_BAUD << 3)) / (SAM_CONSOLE_BAUD << 4)), SAM_CONSOLE_VBASE + SAM_FLEXUS_BRGR_OFFSET); /* Enable receiver & transmitter */ putreg32((FLEXUS_CR_RXEN | FLEXUS_CR_TXEN), SAM_CONSOLE_VBASE + SAM_FLEXUS_CR_OFFSET); #endif #ifdef CONFIG_SAMA5_DBGU /* Initialize the DBGU (might be the serial console) */ sam_dbgu_initialize(); #endif }