Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) |
| 7 | */ |
Ralf Baechle | e971290 | 2007-05-24 12:54:04 +0100 | [diff] [blame] | 8 | #include <linux/init.h> |
| 9 | #include <linux/platform_device.h> |
Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 10 | #include <linux/serial_8250.h> |
Joshua Kinard | 15beb69 | 2015-04-16 12:49:09 -0700 | [diff] [blame] | 11 | #include <linux/rtc/ds1685.h> |
Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 12 | |
| 13 | #include <asm/ip32/mace.h> |
| 14 | #include <asm/ip32/ip32_ints.h> |
| 15 | |
Joshua Kinard | 15beb69 | 2015-04-16 12:49:09 -0700 | [diff] [blame] | 16 | extern void ip32_prepare_poweroff(void); |
| 17 | |
Thomas Bogendoerfer | c990081 | 2008-01-05 12:13:11 +0100 | [diff] [blame] | 18 | #define MACEISA_SERIAL1_OFFS offsetof(struct sgi_mace, isa.serial1) |
| 19 | #define MACEISA_SERIAL2_OFFS offsetof(struct sgi_mace, isa.serial2) |
| 20 | |
| 21 | #define MACE_PORT(offset,_irq) \ |
Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 22 | { \ |
Thomas Bogendoerfer | c990081 | 2008-01-05 12:13:11 +0100 | [diff] [blame] | 23 | .mapbase = MACE_BASE + offset, \ |
| 24 | .irq = _irq, \ |
Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 25 | .uartclk = 1843200, \ |
| 26 | .iotype = UPIO_MEM, \ |
Thomas Bogendoerfer | c990081 | 2008-01-05 12:13:11 +0100 | [diff] [blame] | 27 | .flags = UPF_SKIP_TEST|UPF_IOREMAP, \ |
Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 28 | .regshift = 8, \ |
| 29 | } |
| 30 | |
| 31 | static struct plat_serial8250_port uart8250_data[] = { |
Thomas Bogendoerfer | c990081 | 2008-01-05 12:13:11 +0100 | [diff] [blame] | 32 | MACE_PORT(MACEISA_SERIAL1_OFFS, MACEISA_SERIAL1_IRQ), |
| 33 | MACE_PORT(MACEISA_SERIAL2_OFFS, MACEISA_SERIAL2_IRQ), |
Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 34 | { }, |
| 35 | }; |
| 36 | |
| 37 | static struct platform_device uart8250_device = { |
| 38 | .name = "serial8250", |
| 39 | .id = PLAT8250_DEV_PLATFORM, |
| 40 | .dev = { |
| 41 | .platform_data = uart8250_data, |
| 42 | }, |
| 43 | }; |
| 44 | |
| 45 | static int __init uart8250_init(void) |
| 46 | { |
Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 47 | return platform_device_register(&uart8250_device); |
| 48 | } |
| 49 | |
| 50 | device_initcall(uart8250_init); |
Ralf Baechle | e971290 | 2007-05-24 12:54:04 +0100 | [diff] [blame] | 51 | |
| 52 | static __init int meth_devinit(void) |
| 53 | { |
| 54 | struct platform_device *pd; |
| 55 | int ret; |
| 56 | |
| 57 | pd = platform_device_alloc("meth", -1); |
| 58 | if (!pd) |
| 59 | return -ENOMEM; |
| 60 | |
| 61 | ret = platform_device_add(pd); |
| 62 | if (ret) |
| 63 | platform_device_put(pd); |
| 64 | |
| 65 | return ret; |
| 66 | } |
| 67 | |
| 68 | device_initcall(meth_devinit); |
Ralf Baechle | e7c4782 | 2007-07-10 17:33:01 +0100 | [diff] [blame] | 69 | |
Thomas Bogendoerfer | 8fa9cc1 | 2008-07-05 01:12:13 +0200 | [diff] [blame] | 70 | static __init int sgio2audio_devinit(void) |
| 71 | { |
| 72 | struct platform_device *pd; |
| 73 | int ret; |
| 74 | |
| 75 | pd = platform_device_alloc("sgio2audio", -1); |
| 76 | if (!pd) |
| 77 | return -ENOMEM; |
| 78 | |
| 79 | ret = platform_device_add(pd); |
| 80 | if (ret) |
| 81 | platform_device_put(pd); |
| 82 | |
| 83 | return ret; |
| 84 | } |
| 85 | |
| 86 | device_initcall(sgio2audio_devinit); |
| 87 | |
| 88 | static __init int sgio2btns_devinit(void) |
| 89 | { |
Thomas Bogendoerfer | 36a0a3c | 2008-07-16 15:18:58 +0200 | [diff] [blame] | 90 | return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0)); |
Thomas Bogendoerfer | 8fa9cc1 | 2008-07-05 01:12:13 +0200 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | device_initcall(sgio2btns_devinit); |
| 94 | |
Joshua Kinard | 15beb69 | 2015-04-16 12:49:09 -0700 | [diff] [blame] | 95 | #define MACE_RTC_RES_START (MACE_BASE + offsetof(struct sgi_mace, isa.rtc)) |
| 96 | #define MACE_RTC_RES_END (MACE_RTC_RES_START + 32767) |
| 97 | |
| 98 | static struct resource ip32_rtc_resources[] = { |
Thomas Bogendoerfer | 656e950 | 2008-09-23 00:53:20 +0200 | [diff] [blame] | 99 | { |
Joshua Kinard | 15beb69 | 2015-04-16 12:49:09 -0700 | [diff] [blame] | 100 | .start = MACEISA_RTC_IRQ, |
| 101 | .end = MACEISA_RTC_IRQ, |
| 102 | .flags = IORESOURCE_IRQ |
| 103 | }, { |
| 104 | .start = MACE_RTC_RES_START, |
| 105 | .end = MACE_RTC_RES_END, |
| 106 | .flags = IORESOURCE_MEM, |
Thomas Bogendoerfer | 656e950 | 2008-09-23 00:53:20 +0200 | [diff] [blame] | 107 | } |
| 108 | }; |
| 109 | |
Joshua Kinard | 15beb69 | 2015-04-16 12:49:09 -0700 | [diff] [blame] | 110 | /* RTC registers on IP32 are each padded by 256 bytes (0x100). */ |
| 111 | static struct ds1685_rtc_platform_data |
| 112 | ip32_rtc_platform_data[] = { |
| 113 | { |
| 114 | .regstep = 0x100, |
| 115 | .bcd_mode = true, |
| 116 | .no_irq = false, |
| 117 | .uie_unsupported = false, |
| 118 | .alloc_io_resources = true, |
| 119 | .plat_prepare_poweroff = ip32_prepare_poweroff, |
| 120 | }, |
| 121 | }; |
| 122 | |
| 123 | struct platform_device ip32_rtc_device = { |
| 124 | .name = "rtc-ds1685", |
| 125 | .id = -1, |
| 126 | .dev = { |
| 127 | .platform_data = ip32_rtc_platform_data, |
| 128 | }, |
| 129 | .num_resources = ARRAY_SIZE(ip32_rtc_resources), |
| 130 | .resource = ip32_rtc_resources, |
| 131 | }; |
| 132 | |
Joshua Kinard | 4305689 | 2015-04-19 21:45:25 -0400 | [diff] [blame] | 133 | static __init int sgio2_rtc_devinit(void) |
Thomas Bogendoerfer | 656e950 | 2008-09-23 00:53:20 +0200 | [diff] [blame] | 134 | { |
Joshua Kinard | 15beb69 | 2015-04-16 12:49:09 -0700 | [diff] [blame] | 135 | return platform_device_register(&ip32_rtc_device); |
Thomas Bogendoerfer | 656e950 | 2008-09-23 00:53:20 +0200 | [diff] [blame] | 136 | } |
| 137 | |
Joshua Kinard | 4305689 | 2015-04-19 21:45:25 -0400 | [diff] [blame] | 138 | device_initcall(sgio2_rtc_devinit); |