diff options
| author | Joshua Kinard <kumba@gentoo.org> | 2015-04-16 15:49:09 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:04:11 -0400 |
| commit | 15beb694c66146e1133b9ff81d54e3ef3daa1d7c (patch) | |
| tree | de69c469d7f6260c51f8d22a6e0492c7f58f12f2 /arch/mips/sgi-ip32 | |
| parent | 9e522c0d28d1418c2983ffbc3903f7bed3354180 (diff) | |
mips: ip32: add platform data hooks to use DS1685 driver
This modifies the IP32 (SGI O2) platform and reset code to utilize the new
rtc-ds1685 driver. The old mc146818rtc.h header is removed and ip32_defconfig
is updated as well.
Signed-off-by: Joshua Kinard <kumba@gentoo.org>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/mips/sgi-ip32')
| -rw-r--r-- | arch/mips/sgi-ip32/ip32-platform.c | 46 | ||||
| -rw-r--r-- | arch/mips/sgi-ip32/ip32-reset.c | 131 |
2 files changed, 78 insertions, 99 deletions
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 | ||
| 17 | extern 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 | ||
| 91 | device_initcall(sgio2btns_devinit); | 94 | device_initcall(sgio2btns_devinit); |
| 92 | 95 | ||
| 93 | static 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 | |||
| 99 | static 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 | ||
| 101 | static __init int sgio2_cmos_devinit(void) | 111 | /* RTC registers on IP32 are each padded by 256 bytes (0x100). */ |
| 112 | static struct ds1685_rtc_platform_data | ||
| 113 | ip32_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 | |||
| 124 | struct 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 | ||
| 107 | device_initcall(sgio2_cmos_devinit); | 139 | device_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 | ||
| 36 | static struct timer_list power_timer, blink_timer, debounce_timer; | 37 | extern struct platform_device ip32_rtc_device; |
| 37 | static int has_panicked, shuting_down; | ||
| 38 | 38 | ||
| 39 | static void ip32_machine_restart(char *command) __noreturn; | 39 | static struct timer_list power_timer, blink_timer; |
| 40 | static void ip32_machine_halt(void) __noreturn; | 40 | static int has_panicked, shutting_down; |
| 41 | static void ip32_machine_power_off(void) __noreturn; | ||
| 42 | 41 | ||
| 43 | static void ip32_machine_restart(char *cmd) | 42 | static __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 | ||
| 49 | static 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 | ||
| 54 | static 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 | ||
| 80 | static void power_timeout(unsigned long data) | 65 | static void ip32_machine_restart(char *cmd) __noreturn; |
| 66 | static 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 | ||
| 85 | static void blink_timeout(unsigned long data) | 73 | static 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 | ||
| 92 | static void debounce(unsigned long data) | 80 | static 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); | 85 | static void power_timeout(unsigned long data) |
| 86 | { | ||
| 87 | ip32_poweroff(&ip32_rtc_device); | ||
| 117 | } | 88 | } |
| 118 | 89 | ||
| 119 | static inline void ip32_power_button(void) | 90 | void 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 | ||
| 139 | static 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 | |||
| 160 | static int panic_event(struct notifier_block *this, unsigned long event, | 110 | static 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 | ||
