1fb82a3a7SYoichi Yuasa /* 2fb82a3a7SYoichi Yuasa * Registration of Cobalt UART platform device. 3fb82a3a7SYoichi Yuasa * 4*ada8e951SYoichi Yuasa * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> 5fb82a3a7SYoichi Yuasa * 6fb82a3a7SYoichi Yuasa * This program is free software; you can redistribute it and/or modify 7fb82a3a7SYoichi Yuasa * it under the terms of the GNU General Public License as published by 8fb82a3a7SYoichi Yuasa * the Free Software Foundation; either version 2 of the License, or 9fb82a3a7SYoichi Yuasa * (at your option) any later version. 10fb82a3a7SYoichi Yuasa * 11fb82a3a7SYoichi Yuasa * This program is distributed in the hope that it will be useful, 12fb82a3a7SYoichi Yuasa * but WITHOUT ANY WARRANTY; without even the implied warranty of 13fb82a3a7SYoichi Yuasa * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14fb82a3a7SYoichi Yuasa * GNU General Public License for more details. 15fb82a3a7SYoichi Yuasa * 16fb82a3a7SYoichi Yuasa * You should have received a copy of the GNU General Public License 17fb82a3a7SYoichi Yuasa * along with this program; if not, write to the Free Software 18fb82a3a7SYoichi Yuasa * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19fb82a3a7SYoichi Yuasa */ 20fb82a3a7SYoichi Yuasa #include <linux/errno.h> 21fb82a3a7SYoichi Yuasa #include <linux/init.h> 22fb82a3a7SYoichi Yuasa #include <linux/ioport.h> 23fb82a3a7SYoichi Yuasa #include <linux/platform_device.h> 24fb82a3a7SYoichi Yuasa #include <linux/serial_8250.h> 25fb82a3a7SYoichi Yuasa 26fb82a3a7SYoichi Yuasa #include <cobalt.h> 27d5ab1a69SYoichi Yuasa #include <irq.h> 28fb82a3a7SYoichi Yuasa 29fb82a3a7SYoichi Yuasa static struct resource cobalt_uart_resource[] __initdata = { 30fb82a3a7SYoichi Yuasa { 31fb82a3a7SYoichi Yuasa .start = 0x1c800000, 32fb82a3a7SYoichi Yuasa .end = 0x1c800007, 33fb82a3a7SYoichi Yuasa .flags = IORESOURCE_MEM, 34fb82a3a7SYoichi Yuasa }, 35fb82a3a7SYoichi Yuasa { 36d5ab1a69SYoichi Yuasa .start = SERIAL_IRQ, 37d5ab1a69SYoichi Yuasa .end = SERIAL_IRQ, 38fb82a3a7SYoichi Yuasa .flags = IORESOURCE_IRQ, 39fb82a3a7SYoichi Yuasa }, 40fb82a3a7SYoichi Yuasa }; 41fb82a3a7SYoichi Yuasa 42fb82a3a7SYoichi Yuasa static struct plat_serial8250_port cobalt_serial8250_port[] = { 43fb82a3a7SYoichi Yuasa { 44d5ab1a69SYoichi Yuasa .irq = SERIAL_IRQ, 45fb82a3a7SYoichi Yuasa .uartclk = 18432000, 46fb82a3a7SYoichi Yuasa .iotype = UPIO_MEM, 47fb82a3a7SYoichi Yuasa .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, 48fb82a3a7SYoichi Yuasa .mapbase = 0x1c800000, 49fb82a3a7SYoichi Yuasa }, 50fb82a3a7SYoichi Yuasa {}, 51fb82a3a7SYoichi Yuasa }; 52fb82a3a7SYoichi Yuasa 53fb82a3a7SYoichi Yuasa static __init int cobalt_uart_add(void) 54fb82a3a7SYoichi Yuasa { 55fb82a3a7SYoichi Yuasa struct platform_device *pdev; 56fb82a3a7SYoichi Yuasa int retval; 57fb82a3a7SYoichi Yuasa 58fb82a3a7SYoichi Yuasa /* 59ac1a236aSMartin Michlmayr * Cobalt Qube1 has no UART. 60fb82a3a7SYoichi Yuasa */ 61ac1a236aSMartin Michlmayr if (cobalt_board_id == COBALT_BRD_ID_QUBE1) 62fb82a3a7SYoichi Yuasa return 0; 63fb82a3a7SYoichi Yuasa 64fb82a3a7SYoichi Yuasa pdev = platform_device_alloc("serial8250", -1); 65fb82a3a7SYoichi Yuasa if (!pdev) 66fb82a3a7SYoichi Yuasa return -ENOMEM; 67fb82a3a7SYoichi Yuasa 68fb82a3a7SYoichi Yuasa pdev->id = PLAT8250_DEV_PLATFORM; 69fb82a3a7SYoichi Yuasa pdev->dev.platform_data = cobalt_serial8250_port; 70fb82a3a7SYoichi Yuasa 71fb82a3a7SYoichi Yuasa retval = platform_device_add_resources(pdev, cobalt_uart_resource, ARRAY_SIZE(cobalt_uart_resource)); 72fb82a3a7SYoichi Yuasa if (retval) 73fb82a3a7SYoichi Yuasa goto err_free_device; 74fb82a3a7SYoichi Yuasa 75fb82a3a7SYoichi Yuasa retval = platform_device_add(pdev); 76fb82a3a7SYoichi Yuasa if (retval) 77fb82a3a7SYoichi Yuasa goto err_free_device; 78fb82a3a7SYoichi Yuasa 79fb82a3a7SYoichi Yuasa return 0; 80fb82a3a7SYoichi Yuasa 81fb82a3a7SYoichi Yuasa err_free_device: 82fb82a3a7SYoichi Yuasa platform_device_put(pdev); 83fb82a3a7SYoichi Yuasa 84fb82a3a7SYoichi Yuasa return retval; 85fb82a3a7SYoichi Yuasa } 86fb82a3a7SYoichi Yuasa device_initcall(cobalt_uart_add); 87