Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
0007  */
0008 #include <linux/init.h>
0009 #include <linux/platform_device.h>
0010 #include <linux/serial_8250.h>
0011 #include <linux/rtc/ds1685.h>
0012 
0013 #include <asm/ip32/mace.h>
0014 #include <asm/ip32/ip32_ints.h>
0015 
0016 extern void ip32_prepare_poweroff(void);
0017 
0018 #define MACEISA_SERIAL1_OFFS   offsetof(struct sgi_mace, isa.serial1)
0019 #define MACEISA_SERIAL2_OFFS   offsetof(struct sgi_mace, isa.serial2)
0020 
0021 #define MACE_PORT(offset,_irq)                      \
0022 {                                   \
0023     .mapbase    = MACE_BASE + offset,               \
0024     .irq        = _irq,                     \
0025     .uartclk    = 1843200,                  \
0026     .iotype     = UPIO_MEM,                 \
0027     .flags      = UPF_SKIP_TEST|UPF_IOREMAP,            \
0028     .regshift   = 8,                        \
0029 }
0030 
0031 static struct plat_serial8250_port uart8250_data[] = {
0032     MACE_PORT(MACEISA_SERIAL1_OFFS, MACEISA_SERIAL1_IRQ),
0033     MACE_PORT(MACEISA_SERIAL2_OFFS, MACEISA_SERIAL2_IRQ),
0034     { },
0035 };
0036 
0037 static struct platform_device uart8250_device = {
0038     .name           = "serial8250",
0039     .id         = PLAT8250_DEV_PLATFORM,
0040     .dev            = {
0041         .platform_data  = uart8250_data,
0042     },
0043 };
0044 
0045 static int __init uart8250_init(void)
0046 {
0047     return platform_device_register(&uart8250_device);
0048 }
0049 
0050 device_initcall(uart8250_init);
0051 
0052 static __init int meth_devinit(void)
0053 {
0054     struct platform_device *pd;
0055     int ret;
0056 
0057     pd = platform_device_alloc("meth", -1);
0058     if (!pd)
0059         return -ENOMEM;
0060 
0061     ret = platform_device_add(pd);
0062     if (ret)
0063         platform_device_put(pd);
0064 
0065     return ret;
0066 }
0067 
0068 device_initcall(meth_devinit);
0069 
0070 static __init int sgio2audio_devinit(void)
0071 {
0072     struct platform_device *pd;
0073     int ret;
0074 
0075     pd = platform_device_alloc("sgio2audio", -1);
0076     if (!pd)
0077         return -ENOMEM;
0078 
0079     ret = platform_device_add(pd);
0080     if (ret)
0081         platform_device_put(pd);
0082 
0083     return ret;
0084 }
0085 
0086 device_initcall(sgio2audio_devinit);
0087 
0088 static __init int sgio2btns_devinit(void)
0089 {
0090     return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
0091 }
0092 
0093 device_initcall(sgio2btns_devinit);
0094 
0095 #define MACE_RTC_RES_START (MACE_BASE + offsetof(struct sgi_mace, isa.rtc))
0096 #define MACE_RTC_RES_END (MACE_RTC_RES_START + 32767)
0097 
0098 static struct resource ip32_rtc_resources[] = {
0099     {
0100         .start  = MACEISA_RTC_IRQ,
0101         .end    = MACEISA_RTC_IRQ,
0102         .flags  = IORESOURCE_IRQ
0103     }, {
0104         .start  = MACE_RTC_RES_START,
0105         .end    = MACE_RTC_RES_END,
0106         .flags  = IORESOURCE_MEM,
0107     }
0108 };
0109 
0110 /* RTC registers on IP32 are each padded by 256 bytes (0x100). */
0111 static struct ds1685_rtc_platform_data
0112 ip32_rtc_platform_data[] = {
0113     {
0114         .regstep = 0x100,
0115         .bcd_mode = true,
0116         .no_irq = false,
0117         .uie_unsupported = false,
0118         .access_type = ds1685_reg_direct,
0119         .plat_prepare_poweroff = ip32_prepare_poweroff,
0120     },
0121 };
0122 
0123 struct platform_device ip32_rtc_device = {
0124     .name           = "rtc-ds1685",
0125     .id         = -1,
0126     .dev            = {
0127         .platform_data  = ip32_rtc_platform_data,
0128     },
0129     .num_resources      = ARRAY_SIZE(ip32_rtc_resources),
0130     .resource       = ip32_rtc_resources,
0131 };
0132 
0133 static __init int sgio2_rtc_devinit(void)
0134 {
0135     return platform_device_register(&ip32_rtc_device);
0136 }
0137 
0138 device_initcall(sgio2_rtc_devinit);