|
@@ -963,3 +963,160 @@ DEV_CLK(usart, atmel_usart2, pba, 5);
|
|
|
|
|
|
static struct atmel_uart_data atmel_usart3_data = {
|
|
|
.use_dma_tx = 1,
|
|
|
+ .use_dma_rx = 1,
|
|
|
+};
|
|
|
+static struct resource atmel_usart3_resource[] = {
|
|
|
+ PBMEM(0xffe01800),
|
|
|
+ IRQ(9),
|
|
|
+};
|
|
|
+DEFINE_DEV_DATA(atmel_usart, 3);
|
|
|
+DEV_CLK(usart, atmel_usart3, pba, 6);
|
|
|
+
|
|
|
+static inline void configure_usart0_pins(int flags)
|
|
|
+{
|
|
|
+ u32 pin_mask = (1 << 8) | (1 << 9); /* RXD & TXD */
|
|
|
+ if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 6);
|
|
|
+ if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 7);
|
|
|
+ if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 10);
|
|
|
+
|
|
|
+ select_peripheral(PIOA, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void configure_usart1_pins(int flags)
|
|
|
+{
|
|
|
+ u32 pin_mask = (1 << 17) | (1 << 18); /* RXD & TXD */
|
|
|
+ if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 19);
|
|
|
+ if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 20);
|
|
|
+ if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 16);
|
|
|
+
|
|
|
+ select_peripheral(PIOA, pin_mask, PERIPH_A, AT32_GPIOF_PULLUP);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void configure_usart2_pins(int flags)
|
|
|
+{
|
|
|
+ u32 pin_mask = (1 << 26) | (1 << 27); /* RXD & TXD */
|
|
|
+ if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 30);
|
|
|
+ if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 29);
|
|
|
+ if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 28);
|
|
|
+
|
|
|
+ select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void configure_usart3_pins(int flags)
|
|
|
+{
|
|
|
+ u32 pin_mask = (1 << 18) | (1 << 17); /* RXD & TXD */
|
|
|
+ if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 16);
|
|
|
+ if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 15);
|
|
|
+ if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 19);
|
|
|
+
|
|
|
+ select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
|
|
|
+}
|
|
|
+
|
|
|
+static struct platform_device *__initdata at32_usarts[4];
|
|
|
+
|
|
|
+void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
|
|
|
+{
|
|
|
+ struct platform_device *pdev;
|
|
|
+ struct atmel_uart_data *pdata;
|
|
|
+
|
|
|
+ switch (hw_id) {
|
|
|
+ case 0:
|
|
|
+ pdev = &atmel_usart0_device;
|
|
|
+ configure_usart0_pins(flags);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ pdev = &atmel_usart1_device;
|
|
|
+ configure_usart1_pins(flags);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ pdev = &atmel_usart2_device;
|
|
|
+ configure_usart2_pins(flags);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ pdev = &atmel_usart3_device;
|
|
|
+ configure_usart3_pins(flags);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (PXSEG(pdev->resource[0].start) == P4SEG) {
|
|
|
+ /* Addresses in the P4 segment are permanently mapped 1:1 */
|
|
|
+ struct atmel_uart_data *data = pdev->dev.platform_data;
|
|
|
+ data->regs = (void __iomem *)pdev->resource[0].start;
|
|
|
+ }
|
|
|
+
|
|
|
+ pdev->id = line;
|
|
|
+ pdata = pdev->dev.platform_data;
|
|
|
+ pdata->num = line;
|
|
|
+ at32_usarts[line] = pdev;
|
|
|
+}
|
|
|
+
|
|
|
+struct platform_device *__init at32_add_device_usart(unsigned int id)
|
|
|
+{
|
|
|
+ platform_device_register(at32_usarts[id]);
|
|
|
+ return at32_usarts[id];
|
|
|
+}
|
|
|
+
|
|
|
+void __init at32_setup_serial_console(unsigned int usart_id)
|
|
|
+{
|
|
|
+ atmel_default_console_device = at32_usarts[usart_id];
|
|
|
+}
|
|
|
+
|
|
|
+/* --------------------------------------------------------------------
|
|
|
+ * Ethernet
|
|
|
+ * -------------------------------------------------------------------- */
|
|
|
+
|
|
|
+#ifdef CONFIG_CPU_AT32AP7000
|
|
|
+static struct macb_platform_data macb0_data;
|
|
|
+static struct resource macb0_resource[] = {
|
|
|
+ PBMEM(0xfff01800),
|
|
|
+ IRQ(25),
|
|
|
+};
|
|
|
+DEFINE_DEV_DATA(macb, 0);
|
|
|
+DEV_CLK(hclk, macb0, hsb, 8);
|
|
|
+DEV_CLK(pclk, macb0, pbb, 6);
|
|
|
+
|
|
|
+static struct macb_platform_data macb1_data;
|
|
|
+static struct resource macb1_resource[] = {
|
|
|
+ PBMEM(0xfff01c00),
|
|
|
+ IRQ(26),
|
|
|
+};
|
|
|
+DEFINE_DEV_DATA(macb, 1);
|
|
|
+DEV_CLK(hclk, macb1, hsb, 9);
|
|
|
+DEV_CLK(pclk, macb1, pbb, 7);
|
|
|
+
|
|
|
+struct platform_device *__init
|
|
|
+at32_add_device_eth(unsigned int id, struct macb_platform_data *data)
|
|
|
+{
|
|
|
+ struct platform_device *pdev;
|
|
|
+ u32 pin_mask;
|
|
|
+
|
|
|
+ switch (id) {
|
|
|
+ case 0:
|
|
|
+ pdev = &macb0_device;
|
|
|
+
|
|
|
+ pin_mask = (1 << 3); /* TXD0 */
|
|
|
+ pin_mask |= (1 << 4); /* TXD1 */
|
|
|
+ pin_mask |= (1 << 7); /* TXEN */
|
|
|
+ pin_mask |= (1 << 8); /* TXCK */
|
|
|
+ pin_mask |= (1 << 9); /* RXD0 */
|
|
|
+ pin_mask |= (1 << 10); /* RXD1 */
|
|
|
+ pin_mask |= (1 << 13); /* RXER */
|
|
|
+ pin_mask |= (1 << 15); /* RXDV */
|
|
|
+ pin_mask |= (1 << 16); /* MDC */
|
|
|
+ pin_mask |= (1 << 17); /* MDIO */
|
|
|
+
|
|
|
+ if (!data->is_rmii) {
|
|
|
+ pin_mask |= (1 << 0); /* COL */
|
|
|
+ pin_mask |= (1 << 1); /* CRS */
|
|
|
+ pin_mask |= (1 << 2); /* TXER */
|
|
|
+ pin_mask |= (1 << 5); /* TXD2 */
|
|
|
+ pin_mask |= (1 << 6); /* TXD3 */
|
|
|
+ pin_mask |= (1 << 11); /* RXD2 */
|
|
|
+ pin_mask |= (1 << 12); /* RXD3 */
|
|
|
+ pin_mask |= (1 << 14); /* RXCK */
|
|
|
+#ifndef CONFIG_BOARD_MIMC200
|
|
|
+ pin_mask |= (1 << 18); /* SPD */
|
|
|
+#endif
|
|
|
+ }
|