162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 362306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 462306a36Sopenharmony_ci * for more details. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <linux/init.h> 1062306a36Sopenharmony_ci#include <linux/kernel.h> 1162306a36Sopenharmony_ci#include <linux/platform_device.h> 1262306a36Sopenharmony_ci#include <bcm63xx_cpu.h> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cistatic struct resource uart0_resources[] = { 1562306a36Sopenharmony_ci { 1662306a36Sopenharmony_ci /* start & end filled at runtime */ 1762306a36Sopenharmony_ci .flags = IORESOURCE_MEM, 1862306a36Sopenharmony_ci }, 1962306a36Sopenharmony_ci { 2062306a36Sopenharmony_ci /* start filled at runtime */ 2162306a36Sopenharmony_ci .flags = IORESOURCE_IRQ, 2262306a36Sopenharmony_ci }, 2362306a36Sopenharmony_ci}; 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistatic struct resource uart1_resources[] = { 2662306a36Sopenharmony_ci { 2762306a36Sopenharmony_ci /* start & end filled at runtime */ 2862306a36Sopenharmony_ci .flags = IORESOURCE_MEM, 2962306a36Sopenharmony_ci }, 3062306a36Sopenharmony_ci { 3162306a36Sopenharmony_ci /* start filled at runtime */ 3262306a36Sopenharmony_ci .flags = IORESOURCE_IRQ, 3362306a36Sopenharmony_ci }, 3462306a36Sopenharmony_ci}; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cistatic struct platform_device bcm63xx_uart_devices[] = { 3762306a36Sopenharmony_ci { 3862306a36Sopenharmony_ci .name = "bcm63xx_uart", 3962306a36Sopenharmony_ci .id = 0, 4062306a36Sopenharmony_ci .num_resources = ARRAY_SIZE(uart0_resources), 4162306a36Sopenharmony_ci .resource = uart0_resources, 4262306a36Sopenharmony_ci }, 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci { 4562306a36Sopenharmony_ci .name = "bcm63xx_uart", 4662306a36Sopenharmony_ci .id = 1, 4762306a36Sopenharmony_ci .num_resources = ARRAY_SIZE(uart1_resources), 4862306a36Sopenharmony_ci .resource = uart1_resources, 4962306a36Sopenharmony_ci } 5062306a36Sopenharmony_ci}; 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ciint __init bcm63xx_uart_register(unsigned int id) 5362306a36Sopenharmony_ci{ 5462306a36Sopenharmony_ci if (id >= ARRAY_SIZE(bcm63xx_uart_devices)) 5562306a36Sopenharmony_ci return -ENODEV; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci if (id == 1 && (!BCMCPU_IS_3368() && !BCMCPU_IS_6358() && 5862306a36Sopenharmony_ci !BCMCPU_IS_6368())) 5962306a36Sopenharmony_ci return -ENODEV; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci if (id == 0) { 6262306a36Sopenharmony_ci uart0_resources[0].start = bcm63xx_regset_address(RSET_UART0); 6362306a36Sopenharmony_ci uart0_resources[0].end = uart0_resources[0].start + 6462306a36Sopenharmony_ci RSET_UART_SIZE - 1; 6562306a36Sopenharmony_ci uart0_resources[1].start = bcm63xx_get_irq_number(IRQ_UART0); 6662306a36Sopenharmony_ci } 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci if (id == 1) { 6962306a36Sopenharmony_ci uart1_resources[0].start = bcm63xx_regset_address(RSET_UART1); 7062306a36Sopenharmony_ci uart1_resources[0].end = uart1_resources[0].start + 7162306a36Sopenharmony_ci RSET_UART_SIZE - 1; 7262306a36Sopenharmony_ci uart1_resources[1].start = bcm63xx_get_irq_number(IRQ_UART1); 7362306a36Sopenharmony_ci } 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci return platform_device_register(&bcm63xx_uart_devices[id]); 7662306a36Sopenharmony_ci} 77