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