|  | @@ -1075,3 +1075,156 @@ static inline void configure_usart1_pins(unsigned pins)
 | 
	
		
			
				|  |  |  static struct resource uart2_resources[] = {
 | 
	
		
			
				|  |  |  	[0] = {
 | 
	
		
			
				|  |  |  		.start	= AT91SAM9RL_BASE_US2,
 | 
	
		
			
				|  |  | +		.end	= AT91SAM9RL_BASE_US2 + SZ_16K - 1,
 | 
	
		
			
				|  |  | +		.flags	= IORESOURCE_MEM,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	[1] = {
 | 
	
		
			
				|  |  | +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US2,
 | 
	
		
			
				|  |  | +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US2,
 | 
	
		
			
				|  |  | +		.flags	= IORESOURCE_IRQ,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static struct atmel_uart_data uart2_data = {
 | 
	
		
			
				|  |  | +	.use_dma_tx	= 1,
 | 
	
		
			
				|  |  | +	.use_dma_rx	= 1,
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static u64 uart2_dmamask = DMA_BIT_MASK(32);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static struct platform_device at91sam9rl_uart2_device = {
 | 
	
		
			
				|  |  | +	.name		= "atmel_usart",
 | 
	
		
			
				|  |  | +	.id		= 3,
 | 
	
		
			
				|  |  | +	.dev		= {
 | 
	
		
			
				|  |  | +				.dma_mask		= &uart2_dmamask,
 | 
	
		
			
				|  |  | +				.coherent_dma_mask	= DMA_BIT_MASK(32),
 | 
	
		
			
				|  |  | +				.platform_data		= &uart2_data,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	.resource	= uart2_resources,
 | 
	
		
			
				|  |  | +	.num_resources	= ARRAY_SIZE(uart2_resources),
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static inline void configure_usart2_pins(unsigned pins)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	at91_set_A_periph(AT91_PIN_PA13, 1);		/* TXD2 */
 | 
	
		
			
				|  |  | +	at91_set_A_periph(AT91_PIN_PA14, 0);		/* RXD2 */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (pins & ATMEL_UART_RTS)
 | 
	
		
			
				|  |  | +		at91_set_A_periph(AT91_PIN_PA29, 0);	/* RTS2 */
 | 
	
		
			
				|  |  | +	if (pins & ATMEL_UART_CTS)
 | 
	
		
			
				|  |  | +		at91_set_A_periph(AT91_PIN_PA30, 0);	/* CTS2 */
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static struct resource uart3_resources[] = {
 | 
	
		
			
				|  |  | +	[0] = {
 | 
	
		
			
				|  |  | +		.start	= AT91SAM9RL_BASE_US3,
 | 
	
		
			
				|  |  | +		.end	= AT91SAM9RL_BASE_US3 + SZ_16K - 1,
 | 
	
		
			
				|  |  | +		.flags	= IORESOURCE_MEM,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	[1] = {
 | 
	
		
			
				|  |  | +		.start	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US3,
 | 
	
		
			
				|  |  | +		.end	= NR_IRQS_LEGACY + AT91SAM9RL_ID_US3,
 | 
	
		
			
				|  |  | +		.flags	= IORESOURCE_IRQ,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static struct atmel_uart_data uart3_data = {
 | 
	
		
			
				|  |  | +	.use_dma_tx	= 1,
 | 
	
		
			
				|  |  | +	.use_dma_rx	= 1,
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static u64 uart3_dmamask = DMA_BIT_MASK(32);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static struct platform_device at91sam9rl_uart3_device = {
 | 
	
		
			
				|  |  | +	.name		= "atmel_usart",
 | 
	
		
			
				|  |  | +	.id		= 4,
 | 
	
		
			
				|  |  | +	.dev		= {
 | 
	
		
			
				|  |  | +				.dma_mask		= &uart3_dmamask,
 | 
	
		
			
				|  |  | +				.coherent_dma_mask	= DMA_BIT_MASK(32),
 | 
	
		
			
				|  |  | +				.platform_data		= &uart3_data,
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	.resource	= uart3_resources,
 | 
	
		
			
				|  |  | +	.num_resources	= ARRAY_SIZE(uart3_resources),
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static inline void configure_usart3_pins(unsigned pins)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	at91_set_A_periph(AT91_PIN_PB0, 1);		/* TXD3 */
 | 
	
		
			
				|  |  | +	at91_set_A_periph(AT91_PIN_PB1, 0);		/* RXD3 */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (pins & ATMEL_UART_RTS)
 | 
	
		
			
				|  |  | +		at91_set_B_periph(AT91_PIN_PD4, 0);	/* RTS3 */
 | 
	
		
			
				|  |  | +	if (pins & ATMEL_UART_CTS)
 | 
	
		
			
				|  |  | +		at91_set_B_periph(AT91_PIN_PD3, 0);	/* CTS3 */
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	struct platform_device *pdev;
 | 
	
		
			
				|  |  | +	struct atmel_uart_data *pdata;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	switch (id) {
 | 
	
		
			
				|  |  | +		case 0:		/* DBGU */
 | 
	
		
			
				|  |  | +			pdev = &at91sam9rl_dbgu_device;
 | 
	
		
			
				|  |  | +			configure_dbgu_pins();
 | 
	
		
			
				|  |  | +			break;
 | 
	
		
			
				|  |  | +		case AT91SAM9RL_ID_US0:
 | 
	
		
			
				|  |  | +			pdev = &at91sam9rl_uart0_device;
 | 
	
		
			
				|  |  | +			configure_usart0_pins(pins);
 | 
	
		
			
				|  |  | +			break;
 | 
	
		
			
				|  |  | +		case AT91SAM9RL_ID_US1:
 | 
	
		
			
				|  |  | +			pdev = &at91sam9rl_uart1_device;
 | 
	
		
			
				|  |  | +			configure_usart1_pins(pins);
 | 
	
		
			
				|  |  | +			break;
 | 
	
		
			
				|  |  | +		case AT91SAM9RL_ID_US2:
 | 
	
		
			
				|  |  | +			pdev = &at91sam9rl_uart2_device;
 | 
	
		
			
				|  |  | +			configure_usart2_pins(pins);
 | 
	
		
			
				|  |  | +			break;
 | 
	
		
			
				|  |  | +		case AT91SAM9RL_ID_US3:
 | 
	
		
			
				|  |  | +			pdev = &at91sam9rl_uart3_device;
 | 
	
		
			
				|  |  | +			configure_usart3_pins(pins);
 | 
	
		
			
				|  |  | +			break;
 | 
	
		
			
				|  |  | +		default:
 | 
	
		
			
				|  |  | +			return;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	pdata = pdev->dev.platform_data;
 | 
	
		
			
				|  |  | +	pdata->num = portnr;		/* update to mapped ID */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (portnr < ATMEL_MAX_UART)
 | 
	
		
			
				|  |  | +		at91_uarts[portnr] = pdev;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +void __init at91_add_device_serial(void)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	int i;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	for (i = 0; i < ATMEL_MAX_UART; i++) {
 | 
	
		
			
				|  |  | +		if (at91_uarts[i])
 | 
	
		
			
				|  |  | +			platform_device_register(at91_uarts[i]);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
 | 
	
		
			
				|  |  | +void __init at91_add_device_serial(void) {}
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* -------------------------------------------------------------------- */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * These devices are always present and don't need any board-specific
 | 
	
		
			
				|  |  | + * setup.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +static int __init at91_add_standard_devices(void)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	at91_add_device_hdmac();
 | 
	
		
			
				|  |  | +	at91_add_device_rtc();
 | 
	
		
			
				|  |  | +	at91_add_device_rtt();
 | 
	
		
			
				|  |  | +	at91_add_device_watchdog();
 | 
	
		
			
				|  |  | +	at91_add_device_tc();
 | 
	
		
			
				|  |  | +	return 0;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +arch_initcall(at91_add_standard_devices);
 |