1b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa/* 2b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * Registration of Cobalt RTC platform device. 3b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * 4ada8e9514b5880f81cdbbd212d121380ceef7accYoichi Yuasa * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> 5b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * 6b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * This program is free software; you can redistribute it and/or modify 7b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * it under the terms of the GNU General Public License as published by 8b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * the Free Software Foundation; either version 2 of the License, or 9b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * (at your option) any later version. 10b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * 11b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * This program is distributed in the hope that it will be useful, 12b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * but WITHOUT ANY WARRANTY; without even the implied warranty of 13b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * GNU General Public License for more details. 15b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * 16b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * You should have received a copy of the GNU General Public License 17b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * along with this program; if not, write to the Free Software 18b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa */ 20b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa#include <linux/errno.h> 21b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa#include <linux/init.h> 22b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa#include <linux/ioport.h> 23d5ab1a6910fe850fa092888f210cf6c43136a7abYoichi Yuasa#include <linux/mc146818rtc.h> 24b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa#include <linux/platform_device.h> 25b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa 26b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasastatic struct resource cobalt_rtc_resource[] __initdata = { 27b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa { 28b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa .start = 0x70, 29b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa .end = 0x77, 30b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa .flags = IORESOURCE_IO, 31b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa }, 32b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa { 33d5ab1a6910fe850fa092888f210cf6c43136a7abYoichi Yuasa .start = RTC_IRQ, 34d5ab1a6910fe850fa092888f210cf6c43136a7abYoichi Yuasa .end = RTC_IRQ, 35b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa .flags = IORESOURCE_IRQ, 36b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa }, 37b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa}; 38b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa 39b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasastatic __init int cobalt_rtc_add(void) 40b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa{ 41b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa struct platform_device *pdev; 42b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa int retval; 43b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa 44b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa pdev = platform_device_alloc("rtc_cmos", -1); 45b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa if (!pdev) 46b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa return -ENOMEM; 47b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa 48b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa retval = platform_device_add_resources(pdev, cobalt_rtc_resource, 497034228792cc561e79ff8600f02884bd4c80e287Ralf Baechle ARRAY_SIZE(cobalt_rtc_resource)); 50b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa if (retval) 51b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa goto err_free_device; 52b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa 53b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa retval = platform_device_add(pdev); 54b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa if (retval) 55b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa goto err_free_device; 56b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa 57b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa return 0; 58b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa 59b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasaerr_free_device: 60b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa platform_device_put(pdev); 61b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa 62b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa return retval; 63b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasa} 64b0cc114c04c114b933661eba329d9776c0eab74cYoichi Yuasadevice_initcall(cobalt_rtc_add); 65