[e16e8f2] | 1 | /* |
---|
| 2 | * kempld_wdt.h - Kontron PLD watchdog driver definitions |
---|
| 3 | * |
---|
| 4 | * Copyright (c) 2010 Kontron Embedded Modules GmbH |
---|
| 5 | * Author: Michael Brunner <michael.brunner@kontron.com> |
---|
| 6 | * |
---|
| 7 | * This program is free software; you can redistribute it and/or modify |
---|
| 8 | * it under the terms of the GNU General Public License 2 as published |
---|
| 9 | * by the Free Software Foundation. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; see the file COPYING. If not, write to |
---|
| 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #ifndef _KEMPLD_WDT_H_ |
---|
| 22 | #define _KEMPLD_WDT_H_ |
---|
| 23 | #include <stdint.h> |
---|
| 24 | |
---|
| 25 | #define KEMPLD_IOPORT 0x0a80 |
---|
| 26 | #define KEMPLD_IODATA (KEMPLD_IOPORT+1) |
---|
| 27 | |
---|
| 28 | #define KEMPLD_MUTEX_KEY 0x80 |
---|
| 29 | |
---|
| 30 | /* watchdog register definitions */ |
---|
| 31 | #define KEMPLD_WDT_KICK 0x16 |
---|
| 32 | #define KEMPLD_WDT_REV 0x16 |
---|
| 33 | #define KEMPLD_WDT_REV_GET(x) (x & 0xf) |
---|
| 34 | #define KEMPLD_WDT_CFG 0x17 |
---|
| 35 | #define KEMPLD_WDT_CFG_STAGE_TIMEOUT_OCCURED(x) (1<<x) |
---|
| 36 | #define KEMPLD_WDT_CFG_ENABLE_LOCK 0x8 |
---|
| 37 | #define KEMPLD_WDT_CFG_ENABLE 0x10 |
---|
| 38 | #define KEMPLD_WDT_CFG_AUTO_RELOAD 0x40 |
---|
| 39 | #define KEMPLD_WDT_CFG_GLOBAL_LOCK 0x80 |
---|
| 40 | #define KEMPLD_WDT_STAGE_CFG(x) (0x18+x) |
---|
| 41 | #define KEMPLD_WDT_STAGE_CFG_ACTION_MASK 0x7 |
---|
| 42 | #define KEMPLD_WDT_STAGE_CFG_GET_ACTION(x) (x & 0x7) |
---|
| 43 | #define KEMPLD_WDT_STAGE_CFG_ASSERT 0x8 |
---|
| 44 | #define KEMPLD_WDT_STAGE_CFG_PRESCALER_MASK 0x30 |
---|
| 45 | #define KEMPLD_WDT_STAGE_CFG_GET_PRESCALER(x) ((x & 0x30)>>4) |
---|
| 46 | #define KEMPLD_WDT_STAGE_CFG_SET_PRESCALER(x) ((x & 0x30)<<4) |
---|
| 47 | #define KEMPLD_WDT_STAGE_TIMEOUT(x) (0x1b+x*4) |
---|
| 48 | #define KEMPLD_WDT_MAX_STAGES 3 |
---|
| 49 | |
---|
| 50 | #define KEMPLD_WDT_ACTION_NONE 0x0 |
---|
| 51 | #define KEMPLD_WDT_ACTION_RESET 0x1 |
---|
| 52 | #define KEMPLD_WDT_ACTION_NMI 0x2 |
---|
| 53 | #define KEMPLD_WDT_ACTION_SMI 0x3 |
---|
| 54 | #define KEMPLD_WDT_ACTION_SCI 0x4 |
---|
| 55 | #define KEMPLD_WDT_ACTION_DELAY 0x5 |
---|
| 56 | |
---|
| 57 | #define KEMPLD_WDT_PRESCALER_21BIT 0x0 |
---|
| 58 | #define KEMPLD_WDT_PRESCALER_17BIT 0x1 |
---|
| 59 | #define KEMPLD_WDT_PRESCALER_12BIT 0x2 |
---|
| 60 | |
---|
| 61 | const int kempld_prescaler_bits[] = { 21, 17, 12 }; |
---|
| 62 | |
---|
| 63 | struct kempld_watchdog_stage { |
---|
| 64 | int num; |
---|
| 65 | uint32_t timeout_mask; |
---|
| 66 | }; |
---|
| 67 | |
---|
| 68 | /** |
---|
| 69 | * struct kempld_device_data - Internal representation of the PLD device |
---|
| 70 | * @io_base: Pointer to the IO memory |
---|
| 71 | * @io_index: Pointer to the IO index register |
---|
| 72 | * @io_data: Pointer to the IO data register |
---|
| 73 | * @pld_clock: PLD clock frequency |
---|
| 74 | * @lock: PLD spin-lock |
---|
| 75 | * @lock_flags: PLD spin-lock flags |
---|
| 76 | * @have_mutex: Bool value that indicates if mutex is aquired |
---|
| 77 | * @last_index: Last written index value |
---|
| 78 | * @rscr: Kernel resource structure |
---|
| 79 | * @dev: Pointer to kernel device structure |
---|
| 80 | * @info: KEMPLD info structure |
---|
| 81 | */ |
---|
| 82 | struct kempld_device_data { |
---|
| 83 | uint16_t io_base; |
---|
| 84 | uint16_t io_index; |
---|
| 85 | uint16_t io_data; |
---|
| 86 | uint32_t pld_clock; |
---|
| 87 | /* spinlock_t lock; |
---|
| 88 | unsigned long lock_flags; */ |
---|
| 89 | int have_mutex; |
---|
| 90 | uint8_t last_index; |
---|
| 91 | /* struct resource rscr; |
---|
| 92 | struct device *dev; |
---|
| 93 | struct kempld_info info;*/ |
---|
| 94 | }; |
---|
| 95 | |
---|
| 96 | struct watchdog_info { |
---|
| 97 | uint32_t options; /* Options the card/driver supports */ |
---|
| 98 | uint32_t firmware_version; /* Firmware version of the card */ |
---|
| 99 | uint8_t identity[32]; /* Identity of the board */ |
---|
| 100 | }; |
---|
| 101 | |
---|
| 102 | struct kempld_watchdog_data { |
---|
| 103 | unsigned int revision; |
---|
| 104 | int timeout; |
---|
| 105 | int pretimeout; |
---|
| 106 | unsigned long is_open; |
---|
| 107 | unsigned long expect_close; |
---|
| 108 | int stages; |
---|
| 109 | struct kempld_watchdog_stage *timeout_stage; |
---|
| 110 | struct kempld_watchdog_stage *pretimeout_stage; |
---|
| 111 | struct kempld_device_data *pld; |
---|
| 112 | struct kempld_watchdog_stage *stage[KEMPLD_WDT_MAX_STAGES]; |
---|
| 113 | struct watchdog_info ident; |
---|
| 114 | }; |
---|
| 115 | |
---|
| 116 | #endif /* _KEMPLD_WDT_H_ */ |
---|
| 117 | #define KEMPLD_PRESCALER(x) (0xffffffff>>(32-kempld_prescaler_bits[x])) |
---|