aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/configs/ip32_defconfig3
-rw-r--r--arch/mips/include/asm/mach-ip32/mc146818rtc.h36
-rw-r--r--arch/mips/sgi-ip32/ip32-platform.c46
-rw-r--r--arch/mips/sgi-ip32/ip32-reset.c131
4 files changed, 80 insertions, 136 deletions
diff --git a/arch/mips/configs/ip32_defconfig b/arch/mips/configs/ip32_defconfig
index 70ffe9b55829..fe48220157a9 100644
--- a/arch/mips/configs/ip32_defconfig
+++ b/arch/mips/configs/ip32_defconfig
@@ -105,7 +105,8 @@ CONFIG_RTC_CLASS=y
105# CONFIG_RTC_HCTOSYS is not set 105# CONFIG_RTC_HCTOSYS is not set
106# CONFIG_RTC_INTF_SYSFS is not set 106# CONFIG_RTC_INTF_SYSFS is not set
107# CONFIG_RTC_INTF_PROC is not set 107# CONFIG_RTC_INTF_PROC is not set
108CONFIG_RTC_DRV_CMOS=y 108CONFIG_RTC_DRV_DS1685_FAMILY=y
109CONFIG_RTC_DRV_DS1685=y
109CONFIG_EXT2_FS=y 110CONFIG_EXT2_FS=y
110CONFIG_EXT2_FS_XATTR=y 111CONFIG_EXT2_FS_XATTR=y
111CONFIG_EXT2_FS_POSIX_ACL=y 112CONFIG_EXT2_FS_POSIX_ACL=y
diff --git a/arch/mips/include/asm/mach-ip32/mc146818rtc.h b/arch/mips/include/asm/mach-ip32/mc146818rtc.h
deleted file mode 100644
index 6b6bab43d5c1..000000000000
--- a/arch/mips/include/asm/mach-ip32/mc146818rtc.h
+++ /dev/null
@@ -1,36 +0,0 @@
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) 1998, 2001, 03 by Ralf Baechle
7 * Copyright (C) 2000 Harald Koerfgen
8 *
9 * RTC routines for IP32 style attached Dallas chip.
10 */
11#ifndef __ASM_MACH_IP32_MC146818RTC_H
12#define __ASM_MACH_IP32_MC146818RTC_H
13
14#include <asm/ip32/mace.h>
15
16#define RTC_PORT(x) (0x70 + (x))
17
18static unsigned char CMOS_READ(unsigned long addr)
19{
20 return mace->isa.rtc[addr << 8];
21}
22
23static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
24{
25 mace->isa.rtc[addr << 8] = data;
26}
27
28/*
29 * FIXME: Do it right. For now just assume that no one lives in 20th century
30 * and no O2 user in 22th century ;-)
31 */
32#define mc146818_decode_year(year) ((year) + 2000)
33
34#define RTC_ALWAYS_BCD 0
35
36#endif /* __ASM_MACH_IP32_MC146818RTC_H */
diff --git a/arch/mips/sgi-ip32/ip32-platform.c b/arch/mips/sgi-ip32/ip32-platform.c
index 511e9ff2acfd..b522477129a5 100644
--- a/arch/mips/sgi-ip32/ip32-platform.c
+++ b/arch/mips/sgi-ip32/ip32-platform.c
@@ -9,10 +9,13 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/serial_8250.h> 11#include <linux/serial_8250.h>
12#include <linux/rtc/ds1685.h>
12 13
13#include <asm/ip32/mace.h> 14#include <asm/ip32/mace.h>
14#include <asm/ip32/ip32_ints.h> 15#include <asm/ip32/ip32_ints.h>
15 16
17extern void ip32_prepare_poweroff(void);
18
16#define MACEISA_SERIAL1_OFFS offsetof(struct sgi_mace, isa.serial1) 19#define MACEISA_SERIAL1_OFFS offsetof(struct sgi_mace, isa.serial1)
17#define MACEISA_SERIAL2_OFFS offsetof(struct sgi_mace, isa.serial2) 20#define MACEISA_SERIAL2_OFFS offsetof(struct sgi_mace, isa.serial2)
18 21
@@ -90,18 +93,47 @@ static __init int sgio2btns_devinit(void)
90 93
91device_initcall(sgio2btns_devinit); 94device_initcall(sgio2btns_devinit);
92 95
93static struct resource sgio2_cmos_rsrc[] = { 96#define MACE_RTC_RES_START (MACE_BASE + offsetof(struct sgi_mace, isa.rtc))
97#define MACE_RTC_RES_END (MACE_RTC_RES_START + 32767)
98
99static struct resource ip32_rtc_resources[] = {
94 { 100 {
95 .start = 0x70, 101 .start = MACEISA_RTC_IRQ,
96 .end = 0x71, 102 .end = MACEISA_RTC_IRQ,
97 .flags = IORESOURCE_IO 103 .flags = IORESOURCE_IRQ
104 }, {
105 .start = MACE_RTC_RES_START,
106 .end = MACE_RTC_RES_END,
107 .flags = IORESOURCE_MEM,
98 } 108 }
99}; 109};
100 110
101static __init int sgio2_cmos_devinit(void) 111/* RTC registers on IP32 are each padded by 256 bytes (0x100). */
112static struct ds1685_rtc_platform_data
113ip32_rtc_platform_data[] = {
114 {
115 .regstep = 0x100,
116 .bcd_mode = true,
117 .no_irq = false,
118 .uie_unsupported = false,
119 .alloc_io_resources = true,
120 .plat_prepare_poweroff = ip32_prepare_poweroff,
121 },
122};
123
124struct platform_device ip32_rtc_device = {
125 .name = "rtc-ds1685",
126 .id = -1,
127 .dev = {
128 .platform_data = ip32_rtc_platform_data,
129 },
130 .num_resources = ARRAY_SIZE(ip32_rtc_resources),
131 .resource = ip32_rtc_resources,
132};
133
134+static int __init sgio2_rtc_devinit(void)
102{ 135{
103 return IS_ERR(platform_device_register_simple("rtc_cmos", -1, 136 return platform_device_register(&ip32_rtc_device);
104 sgio2_cmos_rsrc, 1));
105} 137}
106 138
107device_initcall(sgio2_cmos_devinit); 139device_initcall(sgio2_cmos_devinit);
diff --git a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c
index 44b3470a0bbb..8bd415c8729f 100644
--- a/arch/mips/sgi-ip32/ip32-reset.c
+++ b/arch/mips/sgi-ip32/ip32-reset.c
@@ -11,10 +11,11 @@
11#include <linux/compiler.h> 11#include <linux/compiler.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h>
14#include <linux/sched.h> 15#include <linux/sched.h>
15#include <linux/notifier.h> 16#include <linux/notifier.h>
16#include <linux/delay.h> 17#include <linux/delay.h>
17#include <linux/ds17287rtc.h> 18#include <linux/rtc/ds1685.h>
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
19#include <linux/pm.h> 20#include <linux/pm.h>
20 21
@@ -33,53 +34,40 @@
33#define POWERDOWN_FREQ (HZ / 4) 34#define POWERDOWN_FREQ (HZ / 4)
34#define PANIC_FREQ (HZ / 8) 35#define PANIC_FREQ (HZ / 8)
35 36
36static struct timer_list power_timer, blink_timer, debounce_timer; 37extern struct platform_device ip32_rtc_device;
37static int has_panicked, shuting_down;
38 38
39static void ip32_machine_restart(char *command) __noreturn; 39static struct timer_list power_timer, blink_timer;
40static void ip32_machine_halt(void) __noreturn; 40static int has_panicked, shutting_down;
41static void ip32_machine_power_off(void) __noreturn;
42 41
43static void ip32_machine_restart(char *cmd) 42static __noreturn void ip32_poweroff(void *data)
44{ 43{
45 crime->control = CRIME_CONTROL_HARD_RESET; 44 void (*poweroff_func)(struct platform_device *) =
46 while (1); 45 symbol_get(ds1685_rtc_poweroff);
47} 46
47#ifdef CONFIG_MODULES
48 /* If the first __symbol_get failed, our module wasn't loaded. */
49 if (!poweroff_func) {
50 request_module("rtc-ds1685");
51 poweroff_func = symbol_get(ds1685_rtc_poweroff);
52 }
53#endif
48 54
49static inline void ip32_machine_halt(void) 55 if (!poweroff_func)
50{ 56 pr_emerg("RTC not available for power-off. Spinning forever ...\n");
51 ip32_machine_power_off(); 57 else {
52} 58 (*poweroff_func)((struct platform_device *)data);
59 symbol_put(ds1685_rtc_poweroff);
60 }
53 61
54static void ip32_machine_power_off(void) 62 unreachable();
55{
56 unsigned char reg_a, xctrl_a, xctrl_b;
57
58 disable_irq(MACEISA_RTC_IRQ);
59 reg_a = CMOS_READ(RTC_REG_A);
60
61 /* setup for kickstart & wake-up (DS12287 Ref. Man. p. 19) */
62 reg_a &= ~DS_REGA_DV2;
63 reg_a |= DS_REGA_DV1;
64
65 CMOS_WRITE(reg_a | DS_REGA_DV0, RTC_REG_A);
66 wbflush();
67 xctrl_b = CMOS_READ(DS_B1_XCTRL4B)
68 | DS_XCTRL4B_ABE | DS_XCTRL4B_KFE;
69 CMOS_WRITE(xctrl_b, DS_B1_XCTRL4B);
70 xctrl_a = CMOS_READ(DS_B1_XCTRL4A) & ~DS_XCTRL4A_IFS;
71 CMOS_WRITE(xctrl_a, DS_B1_XCTRL4A);
72 wbflush();
73 /* adios amigos... */
74 CMOS_WRITE(xctrl_a | DS_XCTRL4A_PAB, DS_B1_XCTRL4A);
75 CMOS_WRITE(reg_a, RTC_REG_A);
76 wbflush();
77 while (1);
78} 63}
79 64
80static void power_timeout(unsigned long data) 65static void ip32_machine_restart(char *cmd) __noreturn;
66static void ip32_machine_restart(char *cmd)
81{ 67{
82 ip32_machine_power_off(); 68 msleep(20);
69 crime->control = CRIME_CONTROL_HARD_RESET;
70 unreachable();
83} 71}
84 72
85static void blink_timeout(unsigned long data) 73static void blink_timeout(unsigned long data)
@@ -89,44 +77,27 @@ static void blink_timeout(unsigned long data)
89 mod_timer(&blink_timer, jiffies + data); 77 mod_timer(&blink_timer, jiffies + data);
90} 78}
91 79
92static void debounce(unsigned long data) 80static void ip32_machine_halt(void)
93{ 81{
94 unsigned char reg_a, reg_c, xctrl_a; 82 ip32_poweroff(&ip32_rtc_device);
95 83}
96 reg_c = CMOS_READ(RTC_INTR_FLAGS);
97 reg_a = CMOS_READ(RTC_REG_A);
98 CMOS_WRITE(reg_a | DS_REGA_DV0, RTC_REG_A);
99 wbflush();
100 xctrl_a = CMOS_READ(DS_B1_XCTRL4A);
101 if ((xctrl_a & DS_XCTRL4A_IFS) || (reg_c & RTC_IRQF )) {
102 /* Interrupt still being sent. */
103 debounce_timer.expires = jiffies + 50;
104 add_timer(&debounce_timer);
105
106 /* clear interrupt source */
107 CMOS_WRITE(xctrl_a & ~DS_XCTRL4A_IFS, DS_B1_XCTRL4A);
108 CMOS_WRITE(reg_a & ~DS_REGA_DV0, RTC_REG_A);
109 return;
110 }
111 CMOS_WRITE(reg_a & ~DS_REGA_DV0, RTC_REG_A);
112
113 if (has_panicked)
114 ip32_machine_restart(NULL);
115 84
116 enable_irq(MACEISA_RTC_IRQ); 85static void power_timeout(unsigned long data)
86{
87 ip32_poweroff(&ip32_rtc_device);
117} 88}
118 89
119static inline void ip32_power_button(void) 90void ip32_prepare_poweroff(void)
120{ 91{
121 if (has_panicked) 92 if (has_panicked)
122 return; 93 return;
123 94
124 if (shuting_down || kill_cad_pid(SIGINT, 1)) { 95 if (shutting_down || kill_cad_pid(SIGINT, 1)) {
125 /* No init process or button pressed twice. */ 96 /* No init process or button pressed twice. */
126 ip32_machine_power_off(); 97 ip32_poweroff(&ip32_rtc_device);
127 } 98 }
128 99
129 shuting_down = 1; 100 shutting_down = 1;
130 blink_timer.data = POWERDOWN_FREQ; 101 blink_timer.data = POWERDOWN_FREQ;
131 blink_timeout(POWERDOWN_FREQ); 102 blink_timeout(POWERDOWN_FREQ);
132 103
@@ -136,27 +107,6 @@ static inline void ip32_power_button(void)
136 add_timer(&power_timer); 107 add_timer(&power_timer);
137} 108}
138 109
139static irqreturn_t ip32_rtc_int(int irq, void *dev_id)
140{
141 unsigned char reg_c;
142
143 reg_c = CMOS_READ(RTC_INTR_FLAGS);
144 if (!(reg_c & RTC_IRQF)) {
145 printk(KERN_WARNING
146 "%s: RTC IRQ without RTC_IRQF\n", __func__);
147 }
148 /* Wait until interrupt goes away */
149 disable_irq_nosync(MACEISA_RTC_IRQ);
150 init_timer(&debounce_timer);
151 debounce_timer.function = debounce;
152 debounce_timer.expires = jiffies + 50;
153 add_timer(&debounce_timer);
154
155 printk(KERN_DEBUG "Power button pressed\n");
156 ip32_power_button();
157 return IRQ_HANDLED;
158}
159
160static int panic_event(struct notifier_block *this, unsigned long event, 110static int panic_event(struct notifier_block *this, unsigned long event,
161 void *ptr) 111 void *ptr)
162{ 112{
@@ -190,15 +140,12 @@ static __init int ip32_reboot_setup(void)
190 140
191 _machine_restart = ip32_machine_restart; 141 _machine_restart = ip32_machine_restart;
192 _machine_halt = ip32_machine_halt; 142 _machine_halt = ip32_machine_halt;
193 pm_power_off = ip32_machine_power_off; 143 pm_power_off = ip32_machine_halt;
194 144
195 init_timer(&blink_timer); 145 init_timer(&blink_timer);
196 blink_timer.function = blink_timeout; 146 blink_timer.function = blink_timeout;
197 atomic_notifier_chain_register(&panic_notifier_list, &panic_block); 147 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
198 148
199 if (request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL))
200 panic("Can't allocate MACEISA RTC IRQ");
201
202 return 0; 149 return 0;
203} 150}
204 151