Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Zodiac Inflight Innovations |
| 4 | * |
| 5 | * Author: Martyn Welch <martyn.welch@collabora.co.uk> |
| 6 | * |
| 7 | * Based on twl4030_wdt.c by Timo Kokkonen <timo.t.kokkonen at nokia.com>: |
| 8 | * |
| 9 | * Copyright (C) Nokia Corporation |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 12 | #include <linux/delay.h> |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 13 | #include <linux/i2c.h> |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 14 | #include <linux/ihex.h> |
| 15 | #include <linux/firmware.h> |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/sysfs.h> |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/version.h> |
| 22 | #include <linux/watchdog.h> |
| 23 | |
| 24 | #define ZIIRAVE_TIMEOUT_MIN 3 |
| 25 | #define ZIIRAVE_TIMEOUT_MAX 255 |
Andrey Smirnov | 39d0387 | 2019-08-12 13:08:48 -0700 | [diff] [blame] | 26 | #define ZIIRAVE_TIMEOUT_DEFAULT 30 |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 27 | |
| 28 | #define ZIIRAVE_PING_VALUE 0x0 |
| 29 | |
| 30 | #define ZIIRAVE_STATE_INITIAL 0x0 |
| 31 | #define ZIIRAVE_STATE_OFF 0x1 |
| 32 | #define ZIIRAVE_STATE_ON 0x2 |
| 33 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 34 | #define ZIIRAVE_FW_NAME "ziirave_wdt.fw" |
| 35 | |
Martyn Welch | 0ce72f3 | 2016-02-26 16:05:12 +0000 | [diff] [blame] | 36 | static char *ziirave_reasons[] = {"power cycle", "hw watchdog", NULL, NULL, |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 37 | "host request", NULL, "illegal configuration", |
| 38 | "illegal instruction", "illegal trap", |
| 39 | "unknown"}; |
| 40 | |
| 41 | #define ZIIRAVE_WDT_FIRM_VER_MAJOR 0x1 |
| 42 | #define ZIIRAVE_WDT_BOOT_VER_MAJOR 0x3 |
| 43 | #define ZIIRAVE_WDT_RESET_REASON 0x5 |
| 44 | #define ZIIRAVE_WDT_STATE 0x6 |
| 45 | #define ZIIRAVE_WDT_TIMEOUT 0x7 |
| 46 | #define ZIIRAVE_WDT_TIME_LEFT 0x8 |
| 47 | #define ZIIRAVE_WDT_PING 0x9 |
| 48 | #define ZIIRAVE_WDT_RESET_DURATION 0xa |
| 49 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 50 | #define ZIIRAVE_FIRM_PKT_TOTAL_SIZE 20 |
| 51 | #define ZIIRAVE_FIRM_PKT_DATA_SIZE 16 |
| 52 | #define ZIIRAVE_FIRM_FLASH_MEMORY_START 0x1600 |
| 53 | #define ZIIRAVE_FIRM_FLASH_MEMORY_END 0x2bbf |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 54 | #define ZIIRAVE_FIRM_PAGE_SIZE 128 |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 55 | |
| 56 | /* Received and ready for next Download packet. */ |
| 57 | #define ZIIRAVE_FIRM_DOWNLOAD_ACK 1 |
| 58 | /* Currently writing to flash. Retry Download status in a moment! */ |
| 59 | #define ZIIRAVE_FIRM_DOWNLOAD_BUSY 2 |
| 60 | |
| 61 | /* Wait for ACK timeout in ms */ |
| 62 | #define ZIIRAVE_FIRM_WAIT_FOR_ACK_TIMEOUT 50 |
| 63 | |
| 64 | /* Firmware commands */ |
| 65 | #define ZIIRAVE_CMD_DOWNLOAD_START 0x10 |
| 66 | #define ZIIRAVE_CMD_DOWNLOAD_END 0x11 |
| 67 | #define ZIIRAVE_CMD_DOWNLOAD_SET_READ_ADDR 0x12 |
| 68 | #define ZIIRAVE_CMD_DOWNLOAD_READ_BYTE 0x13 |
| 69 | #define ZIIRAVE_CMD_RESET_PROCESSOR 0x0b |
| 70 | #define ZIIRAVE_CMD_JUMP_TO_BOOTLOADER 0x0c |
| 71 | #define ZIIRAVE_CMD_DOWNLOAD_PACKET 0x0e |
| 72 | |
Andrey Smirnov | 42abc12 | 2019-08-12 13:08:49 -0700 | [diff] [blame] | 73 | #define ZIIRAVE_FW_VERSION_FMT "02.%02u.%02u" |
| 74 | #define ZIIRAVE_BL_VERSION_FMT "01.%02u.%02u" |
| 75 | |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 76 | struct ziirave_wdt_rev { |
| 77 | unsigned char major; |
| 78 | unsigned char minor; |
| 79 | }; |
| 80 | |
| 81 | struct ziirave_wdt_data { |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 82 | struct mutex sysfs_mutex; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 83 | struct watchdog_device wdd; |
| 84 | struct ziirave_wdt_rev bootloader_rev; |
| 85 | struct ziirave_wdt_rev firmware_rev; |
| 86 | int reset_reason; |
| 87 | }; |
| 88 | |
| 89 | static int wdt_timeout; |
| 90 | module_param(wdt_timeout, int, 0); |
| 91 | MODULE_PARM_DESC(wdt_timeout, "Watchdog timeout in seconds"); |
| 92 | |
| 93 | static int reset_duration; |
| 94 | module_param(reset_duration, int, 0); |
| 95 | MODULE_PARM_DESC(reset_duration, |
| 96 | "Watchdog reset pulse duration in milliseconds"); |
| 97 | |
| 98 | static bool nowayout = WATCHDOG_NOWAYOUT; |
| 99 | module_param(nowayout, bool, 0); |
| 100 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started default=" |
| 101 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
| 102 | |
| 103 | static int ziirave_wdt_revision(struct i2c_client *client, |
| 104 | struct ziirave_wdt_rev *rev, u8 command) |
| 105 | { |
| 106 | int ret; |
| 107 | |
| 108 | ret = i2c_smbus_read_byte_data(client, command); |
| 109 | if (ret < 0) |
| 110 | return ret; |
| 111 | |
| 112 | rev->major = ret; |
| 113 | |
| 114 | ret = i2c_smbus_read_byte_data(client, command + 1); |
| 115 | if (ret < 0) |
| 116 | return ret; |
| 117 | |
| 118 | rev->minor = ret; |
| 119 | |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | static int ziirave_wdt_set_state(struct watchdog_device *wdd, int state) |
| 124 | { |
| 125 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 126 | |
| 127 | return i2c_smbus_write_byte_data(client, ZIIRAVE_WDT_STATE, state); |
| 128 | } |
| 129 | |
| 130 | static int ziirave_wdt_start(struct watchdog_device *wdd) |
| 131 | { |
| 132 | return ziirave_wdt_set_state(wdd, ZIIRAVE_STATE_ON); |
| 133 | } |
| 134 | |
| 135 | static int ziirave_wdt_stop(struct watchdog_device *wdd) |
| 136 | { |
| 137 | return ziirave_wdt_set_state(wdd, ZIIRAVE_STATE_OFF); |
| 138 | } |
| 139 | |
| 140 | static int ziirave_wdt_ping(struct watchdog_device *wdd) |
| 141 | { |
| 142 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 143 | |
| 144 | return i2c_smbus_write_byte_data(client, ZIIRAVE_WDT_PING, |
| 145 | ZIIRAVE_PING_VALUE); |
| 146 | } |
| 147 | |
| 148 | static int ziirave_wdt_set_timeout(struct watchdog_device *wdd, |
| 149 | unsigned int timeout) |
| 150 | { |
| 151 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 152 | int ret; |
| 153 | |
| 154 | ret = i2c_smbus_write_byte_data(client, ZIIRAVE_WDT_TIMEOUT, timeout); |
| 155 | if (!ret) |
| 156 | wdd->timeout = timeout; |
| 157 | |
| 158 | return ret; |
| 159 | } |
| 160 | |
| 161 | static unsigned int ziirave_wdt_get_timeleft(struct watchdog_device *wdd) |
| 162 | { |
| 163 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 164 | int ret; |
| 165 | |
| 166 | ret = i2c_smbus_read_byte_data(client, ZIIRAVE_WDT_TIME_LEFT); |
| 167 | if (ret < 0) |
| 168 | ret = 0; |
| 169 | |
| 170 | return ret; |
| 171 | } |
| 172 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 173 | static int ziirave_firm_wait_for_ack(struct watchdog_device *wdd) |
| 174 | { |
| 175 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 176 | int ret; |
| 177 | unsigned long timeout; |
| 178 | |
| 179 | timeout = jiffies + msecs_to_jiffies(ZIIRAVE_FIRM_WAIT_FOR_ACK_TIMEOUT); |
| 180 | do { |
| 181 | if (time_after(jiffies, timeout)) |
| 182 | return -ETIMEDOUT; |
| 183 | |
| 184 | usleep_range(5000, 10000); |
| 185 | |
| 186 | ret = i2c_smbus_read_byte(client); |
| 187 | if (ret < 0) { |
| 188 | dev_err(&client->dev, "Failed to read byte\n"); |
| 189 | return ret; |
| 190 | } |
| 191 | } while (ret == ZIIRAVE_FIRM_DOWNLOAD_BUSY); |
| 192 | |
| 193 | return ret == ZIIRAVE_FIRM_DOWNLOAD_ACK ? 0 : -EIO; |
| 194 | } |
| 195 | |
| 196 | static int ziirave_firm_set_read_addr(struct watchdog_device *wdd, u16 addr) |
| 197 | { |
| 198 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 199 | u8 address[2]; |
| 200 | |
| 201 | address[0] = addr & 0xff; |
| 202 | address[1] = (addr >> 8) & 0xff; |
| 203 | |
| 204 | return i2c_smbus_write_block_data(client, |
| 205 | ZIIRAVE_CMD_DOWNLOAD_SET_READ_ADDR, |
| 206 | ARRAY_SIZE(address), address); |
| 207 | } |
| 208 | |
| 209 | static int ziirave_firm_write_block_data(struct watchdog_device *wdd, |
| 210 | u8 command, u8 length, const u8 *data, |
| 211 | bool wait_for_ack) |
| 212 | { |
| 213 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 214 | int ret; |
| 215 | |
| 216 | ret = i2c_smbus_write_block_data(client, command, length, data); |
| 217 | if (ret) { |
| 218 | dev_err(&client->dev, |
| 219 | "Failed to send command 0x%02x: %d\n", command, ret); |
| 220 | return ret; |
| 221 | } |
| 222 | |
| 223 | if (wait_for_ack) |
| 224 | ret = ziirave_firm_wait_for_ack(wdd); |
| 225 | |
| 226 | return ret; |
| 227 | } |
| 228 | |
| 229 | static int ziirave_firm_write_byte(struct watchdog_device *wdd, u8 command, |
| 230 | u8 byte, bool wait_for_ack) |
| 231 | { |
| 232 | return ziirave_firm_write_block_data(wdd, command, 1, &byte, |
| 233 | wait_for_ack); |
| 234 | } |
| 235 | |
| 236 | /* |
| 237 | * ziirave_firm_write_pkt() - Build and write a firmware packet |
| 238 | * |
| 239 | * A packet to send to the firmware is composed by following bytes: |
| 240 | * Length | Addr0 | Addr1 | Data0 .. Data15 | Checksum | |
| 241 | * Where, |
| 242 | * Length: A data byte containing the length of the data. |
| 243 | * Addr0: Low byte of the address. |
| 244 | * Addr1: High byte of the address. |
| 245 | * Data0 .. Data15: Array of 16 bytes of data. |
| 246 | * Checksum: Checksum byte to verify data integrity. |
| 247 | */ |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 248 | static int __ziirave_firm_write_pkt(struct watchdog_device *wdd, |
| 249 | u32 addr, const u8 *data, u8 len) |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 250 | { |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 251 | const u16 addr16 = (u16)addr / 2; |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 252 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 253 | u8 i, checksum = 0, packet[ZIIRAVE_FIRM_PKT_TOTAL_SIZE]; |
| 254 | int ret; |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 255 | |
Andrey Smirnov | 08188e8 | 2019-08-12 13:08:51 -0700 | [diff] [blame^] | 256 | /* Check max data size */ |
| 257 | if (len > ZIIRAVE_FIRM_PKT_DATA_SIZE) { |
| 258 | dev_err(&client->dev, "Firmware packet too long (%d)\n", |
| 259 | len); |
| 260 | return -EMSGSIZE; |
| 261 | } |
| 262 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 263 | memset(packet, 0, ARRAY_SIZE(packet)); |
| 264 | |
| 265 | /* Packet length */ |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 266 | packet[0] = len; |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 267 | /* Packet address */ |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 268 | packet[1] = addr16 & 0xff; |
| 269 | packet[2] = (addr16 & 0xff00) >> 8; |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 270 | |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 271 | memcpy(packet + 3, data, len); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 272 | |
| 273 | /* Packet checksum */ |
| 274 | for (i = 0; i < ZIIRAVE_FIRM_PKT_TOTAL_SIZE - 1; i++) |
| 275 | checksum += packet[i]; |
| 276 | packet[ZIIRAVE_FIRM_PKT_TOTAL_SIZE - 1] = checksum; |
| 277 | |
| 278 | ret = ziirave_firm_write_block_data(wdd, ZIIRAVE_CMD_DOWNLOAD_PACKET, |
| 279 | ARRAY_SIZE(packet), packet, true); |
| 280 | if (ret) |
| 281 | dev_err(&client->dev, |
| 282 | "Failed to write firmware packet at address 0x%04x: %d\n", |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 283 | addr16, ret); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 284 | |
| 285 | return ret; |
| 286 | } |
| 287 | |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 288 | static int ziirave_firm_write_pkt(struct watchdog_device *wdd, |
| 289 | u32 addr, const u8 *data, u8 len) |
| 290 | { |
| 291 | const u8 max_write_len = ZIIRAVE_FIRM_PAGE_SIZE - |
| 292 | (addr - ALIGN_DOWN(addr, ZIIRAVE_FIRM_PAGE_SIZE)); |
| 293 | int ret; |
| 294 | |
| 295 | if (len > max_write_len) { |
| 296 | /* |
| 297 | * If data crossed page boundary we need to split this |
| 298 | * write in two |
| 299 | */ |
| 300 | ret = __ziirave_firm_write_pkt(wdd, addr, data, max_write_len); |
| 301 | if (ret) |
| 302 | return ret; |
| 303 | |
| 304 | addr += max_write_len; |
| 305 | data += max_write_len; |
| 306 | len -= max_write_len; |
| 307 | } |
| 308 | |
| 309 | return __ziirave_firm_write_pkt(wdd, addr, data, len); |
| 310 | } |
| 311 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 312 | static int ziirave_firm_verify(struct watchdog_device *wdd, |
| 313 | const struct firmware *fw) |
| 314 | { |
| 315 | struct i2c_client *client = to_i2c_client(wdd->parent); |
| 316 | const struct ihex_binrec *rec; |
| 317 | int i, ret; |
| 318 | u8 data[ZIIRAVE_FIRM_PKT_DATA_SIZE]; |
| 319 | u16 addr; |
| 320 | |
| 321 | for (rec = (void *)fw->data; rec; rec = ihex_next_binrec(rec)) { |
| 322 | /* Zero length marks end of records */ |
| 323 | if (!be16_to_cpu(rec->len)) |
| 324 | break; |
| 325 | |
| 326 | addr = (be32_to_cpu(rec->addr) & 0xffff) >> 1; |
| 327 | if (addr < ZIIRAVE_FIRM_FLASH_MEMORY_START || |
| 328 | addr > ZIIRAVE_FIRM_FLASH_MEMORY_END) |
| 329 | continue; |
| 330 | |
| 331 | ret = ziirave_firm_set_read_addr(wdd, addr); |
| 332 | if (ret) { |
| 333 | dev_err(&client->dev, |
| 334 | "Failed to send SET_READ_ADDR command: %d\n", |
| 335 | ret); |
| 336 | return ret; |
| 337 | } |
| 338 | |
| 339 | for (i = 0; i < ARRAY_SIZE(data); i++) { |
| 340 | ret = i2c_smbus_read_byte_data(client, |
| 341 | ZIIRAVE_CMD_DOWNLOAD_READ_BYTE); |
| 342 | if (ret < 0) { |
| 343 | dev_err(&client->dev, |
| 344 | "Failed to READ DATA: %d\n", ret); |
| 345 | return ret; |
| 346 | } |
| 347 | data[i] = ret; |
| 348 | } |
| 349 | |
| 350 | if (memcmp(data, rec->data, be16_to_cpu(rec->len))) { |
| 351 | dev_err(&client->dev, |
| 352 | "Firmware mismatch at address 0x%04x\n", addr); |
| 353 | return -EINVAL; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | static int ziirave_firm_upload(struct watchdog_device *wdd, |
| 361 | const struct firmware *fw) |
| 362 | { |
| 363 | struct i2c_client *client = to_i2c_client(wdd->parent); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 364 | const struct ihex_binrec *rec; |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 365 | int ret; |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 366 | |
| 367 | ret = ziirave_firm_write_byte(wdd, ZIIRAVE_CMD_JUMP_TO_BOOTLOADER, 1, |
| 368 | false); |
Andrey Smirnov | b774fce | 2019-08-12 13:08:47 -0700 | [diff] [blame] | 369 | if (ret) { |
| 370 | dev_err(&client->dev, "Failed to jump to bootloader\n"); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 371 | return ret; |
Andrey Smirnov | b774fce | 2019-08-12 13:08:47 -0700 | [diff] [blame] | 372 | } |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 373 | |
| 374 | msleep(500); |
| 375 | |
| 376 | ret = ziirave_firm_write_byte(wdd, ZIIRAVE_CMD_DOWNLOAD_START, 1, true); |
Andrey Smirnov | b774fce | 2019-08-12 13:08:47 -0700 | [diff] [blame] | 377 | if (ret) { |
| 378 | dev_err(&client->dev, "Failed to start download\n"); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 379 | return ret; |
Andrey Smirnov | b774fce | 2019-08-12 13:08:47 -0700 | [diff] [blame] | 380 | } |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 381 | |
| 382 | msleep(500); |
| 383 | |
| 384 | for (rec = (void *)fw->data; rec; rec = ihex_next_binrec(rec)) { |
| 385 | /* Zero length marks end of records */ |
| 386 | if (!be16_to_cpu(rec->len)) |
| 387 | break; |
| 388 | |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 389 | ret = ziirave_firm_write_pkt(wdd, be32_to_cpu(rec->addr), |
| 390 | rec->data, be16_to_cpu(rec->len)); |
| 391 | if (ret) |
| 392 | return ret; |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 393 | } |
| 394 | |
Andrey Smirnov | 5870f49 | 2019-08-12 13:08:50 -0700 | [diff] [blame] | 395 | /* |
| 396 | * Finish firmware download process by sending a zero length |
| 397 | * payload |
| 398 | */ |
| 399 | ret = ziirave_firm_write_pkt(wdd, 0, NULL, 0); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 400 | if (ret) { |
| 401 | dev_err(&client->dev, "Failed to send EMPTY packet: %d\n", ret); |
| 402 | return ret; |
| 403 | } |
| 404 | |
| 405 | /* This sleep seems to be required */ |
| 406 | msleep(20); |
| 407 | |
| 408 | /* Start firmware verification */ |
| 409 | ret = ziirave_firm_verify(wdd, fw); |
| 410 | if (ret) { |
| 411 | dev_err(&client->dev, |
| 412 | "Failed to verify firmware: %d\n", ret); |
| 413 | return ret; |
| 414 | } |
| 415 | |
| 416 | /* End download operation */ |
| 417 | ret = ziirave_firm_write_byte(wdd, ZIIRAVE_CMD_DOWNLOAD_END, 1, false); |
Andrey Smirnov | b774fce | 2019-08-12 13:08:47 -0700 | [diff] [blame] | 418 | if (ret) { |
| 419 | dev_err(&client->dev, |
| 420 | "Failed to end firmware download: %d\n", ret); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 421 | return ret; |
Andrey Smirnov | b774fce | 2019-08-12 13:08:47 -0700 | [diff] [blame] | 422 | } |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 423 | |
| 424 | /* Reset the processor */ |
| 425 | ret = ziirave_firm_write_byte(wdd, ZIIRAVE_CMD_RESET_PROCESSOR, 1, |
| 426 | false); |
Andrey Smirnov | b774fce | 2019-08-12 13:08:47 -0700 | [diff] [blame] | 427 | if (ret) { |
| 428 | dev_err(&client->dev, |
| 429 | "Failed to reset the watchdog: %d\n", ret); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 430 | return ret; |
Andrey Smirnov | b774fce | 2019-08-12 13:08:47 -0700 | [diff] [blame] | 431 | } |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 432 | |
| 433 | msleep(500); |
| 434 | |
| 435 | return 0; |
| 436 | } |
| 437 | |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 438 | static const struct watchdog_info ziirave_wdt_info = { |
| 439 | .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, |
| 440 | .identity = "Zodiac RAVE Watchdog", |
| 441 | }; |
| 442 | |
| 443 | static const struct watchdog_ops ziirave_wdt_ops = { |
| 444 | .owner = THIS_MODULE, |
| 445 | .start = ziirave_wdt_start, |
| 446 | .stop = ziirave_wdt_stop, |
| 447 | .ping = ziirave_wdt_ping, |
| 448 | .set_timeout = ziirave_wdt_set_timeout, |
| 449 | .get_timeleft = ziirave_wdt_get_timeleft, |
| 450 | }; |
| 451 | |
| 452 | static ssize_t ziirave_wdt_sysfs_show_firm(struct device *dev, |
| 453 | struct device_attribute *attr, |
| 454 | char *buf) |
| 455 | { |
| 456 | struct i2c_client *client = to_i2c_client(dev->parent); |
| 457 | struct ziirave_wdt_data *w_priv = i2c_get_clientdata(client); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 458 | int ret; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 459 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 460 | ret = mutex_lock_interruptible(&w_priv->sysfs_mutex); |
| 461 | if (ret) |
| 462 | return ret; |
| 463 | |
Andrey Smirnov | 42abc12 | 2019-08-12 13:08:49 -0700 | [diff] [blame] | 464 | ret = sprintf(buf, ZIIRAVE_FW_VERSION_FMT, w_priv->firmware_rev.major, |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 465 | w_priv->firmware_rev.minor); |
| 466 | |
| 467 | mutex_unlock(&w_priv->sysfs_mutex); |
| 468 | |
| 469 | return ret; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | static DEVICE_ATTR(firmware_version, S_IRUGO, ziirave_wdt_sysfs_show_firm, |
| 473 | NULL); |
| 474 | |
| 475 | static ssize_t ziirave_wdt_sysfs_show_boot(struct device *dev, |
| 476 | struct device_attribute *attr, |
| 477 | char *buf) |
| 478 | { |
| 479 | struct i2c_client *client = to_i2c_client(dev->parent); |
| 480 | struct ziirave_wdt_data *w_priv = i2c_get_clientdata(client); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 481 | int ret; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 482 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 483 | ret = mutex_lock_interruptible(&w_priv->sysfs_mutex); |
| 484 | if (ret) |
| 485 | return ret; |
| 486 | |
Andrey Smirnov | 42abc12 | 2019-08-12 13:08:49 -0700 | [diff] [blame] | 487 | ret = sprintf(buf, ZIIRAVE_BL_VERSION_FMT, w_priv->bootloader_rev.major, |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 488 | w_priv->bootloader_rev.minor); |
| 489 | |
| 490 | mutex_unlock(&w_priv->sysfs_mutex); |
| 491 | |
| 492 | return ret; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | static DEVICE_ATTR(bootloader_version, S_IRUGO, ziirave_wdt_sysfs_show_boot, |
| 496 | NULL); |
| 497 | |
| 498 | static ssize_t ziirave_wdt_sysfs_show_reason(struct device *dev, |
| 499 | struct device_attribute *attr, |
| 500 | char *buf) |
| 501 | { |
| 502 | struct i2c_client *client = to_i2c_client(dev->parent); |
| 503 | struct ziirave_wdt_data *w_priv = i2c_get_clientdata(client); |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 504 | int ret; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 505 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 506 | ret = mutex_lock_interruptible(&w_priv->sysfs_mutex); |
| 507 | if (ret) |
| 508 | return ret; |
| 509 | |
| 510 | ret = sprintf(buf, "%s", ziirave_reasons[w_priv->reset_reason]); |
| 511 | |
| 512 | mutex_unlock(&w_priv->sysfs_mutex); |
| 513 | |
| 514 | return ret; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | static DEVICE_ATTR(reset_reason, S_IRUGO, ziirave_wdt_sysfs_show_reason, |
| 518 | NULL); |
| 519 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 520 | static ssize_t ziirave_wdt_sysfs_store_firm(struct device *dev, |
| 521 | struct device_attribute *attr, |
| 522 | const char *buf, size_t count) |
| 523 | { |
| 524 | struct i2c_client *client = to_i2c_client(dev->parent); |
| 525 | struct ziirave_wdt_data *w_priv = i2c_get_clientdata(client); |
| 526 | const struct firmware *fw; |
| 527 | int err; |
| 528 | |
| 529 | err = request_ihex_firmware(&fw, ZIIRAVE_FW_NAME, dev); |
| 530 | if (err) { |
| 531 | dev_err(&client->dev, "Failed to request ihex firmware\n"); |
| 532 | return err; |
| 533 | } |
| 534 | |
| 535 | err = mutex_lock_interruptible(&w_priv->sysfs_mutex); |
| 536 | if (err) |
| 537 | goto release_firmware; |
| 538 | |
| 539 | err = ziirave_firm_upload(&w_priv->wdd, fw); |
| 540 | if (err) { |
| 541 | dev_err(&client->dev, "The firmware update failed: %d\n", err); |
| 542 | goto unlock_mutex; |
| 543 | } |
| 544 | |
| 545 | /* Update firmware version */ |
| 546 | err = ziirave_wdt_revision(client, &w_priv->firmware_rev, |
| 547 | ZIIRAVE_WDT_FIRM_VER_MAJOR); |
| 548 | if (err) { |
| 549 | dev_err(&client->dev, "Failed to read firmware version: %d\n", |
| 550 | err); |
| 551 | goto unlock_mutex; |
| 552 | } |
| 553 | |
Andrey Smirnov | 42abc12 | 2019-08-12 13:08:49 -0700 | [diff] [blame] | 554 | dev_info(&client->dev, |
| 555 | "Firmware updated to version " ZIIRAVE_FW_VERSION_FMT "\n", |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 556 | w_priv->firmware_rev.major, w_priv->firmware_rev.minor); |
| 557 | |
| 558 | /* Restore the watchdog timeout */ |
| 559 | err = ziirave_wdt_set_timeout(&w_priv->wdd, w_priv->wdd.timeout); |
| 560 | if (err) |
| 561 | dev_err(&client->dev, "Failed to set timeout: %d\n", err); |
| 562 | |
| 563 | unlock_mutex: |
| 564 | mutex_unlock(&w_priv->sysfs_mutex); |
| 565 | |
| 566 | release_firmware: |
| 567 | release_firmware(fw); |
| 568 | |
| 569 | return err ? err : count; |
| 570 | } |
| 571 | |
| 572 | static DEVICE_ATTR(update_firmware, S_IWUSR, NULL, |
| 573 | ziirave_wdt_sysfs_store_firm); |
| 574 | |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 575 | static struct attribute *ziirave_wdt_attrs[] = { |
| 576 | &dev_attr_firmware_version.attr, |
| 577 | &dev_attr_bootloader_version.attr, |
| 578 | &dev_attr_reset_reason.attr, |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 579 | &dev_attr_update_firmware.attr, |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 580 | NULL |
| 581 | }; |
Guenter Roeck | 2c2f308 | 2016-01-03 15:11:57 -0800 | [diff] [blame] | 582 | ATTRIBUTE_GROUPS(ziirave_wdt); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 583 | |
| 584 | static int ziirave_wdt_init_duration(struct i2c_client *client) |
| 585 | { |
| 586 | int ret; |
| 587 | |
| 588 | if (!reset_duration) { |
| 589 | /* See if the reset pulse duration is provided in an of_node */ |
| 590 | if (!client->dev.of_node) |
| 591 | ret = -ENODEV; |
| 592 | else |
| 593 | ret = of_property_read_u32(client->dev.of_node, |
| 594 | "reset-duration-ms", |
| 595 | &reset_duration); |
| 596 | if (ret) { |
| 597 | dev_info(&client->dev, |
| 598 | "Unable to set reset pulse duration, using default\n"); |
| 599 | return 0; |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | if (reset_duration < 1 || reset_duration > 255) |
| 604 | return -EINVAL; |
| 605 | |
| 606 | dev_info(&client->dev, "Setting reset duration to %dms", |
| 607 | reset_duration); |
| 608 | |
| 609 | return i2c_smbus_write_byte_data(client, ZIIRAVE_WDT_RESET_DURATION, |
| 610 | reset_duration); |
| 611 | } |
| 612 | |
| 613 | static int ziirave_wdt_probe(struct i2c_client *client, |
| 614 | const struct i2c_device_id *id) |
| 615 | { |
| 616 | int ret; |
| 617 | struct ziirave_wdt_data *w_priv; |
| 618 | int val; |
| 619 | |
| 620 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
| 621 | return -ENODEV; |
| 622 | |
| 623 | w_priv = devm_kzalloc(&client->dev, sizeof(*w_priv), GFP_KERNEL); |
| 624 | if (!w_priv) |
| 625 | return -ENOMEM; |
| 626 | |
Enric Balletbo i Serra | 217209d | 2016-08-10 18:18:03 +0200 | [diff] [blame] | 627 | mutex_init(&w_priv->sysfs_mutex); |
| 628 | |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 629 | w_priv->wdd.info = &ziirave_wdt_info; |
| 630 | w_priv->wdd.ops = &ziirave_wdt_ops; |
| 631 | w_priv->wdd.min_timeout = ZIIRAVE_TIMEOUT_MIN; |
| 632 | w_priv->wdd.max_timeout = ZIIRAVE_TIMEOUT_MAX; |
| 633 | w_priv->wdd.parent = &client->dev; |
Guenter Roeck | 2c2f308 | 2016-01-03 15:11:57 -0800 | [diff] [blame] | 634 | w_priv->wdd.groups = ziirave_wdt_groups; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 635 | |
Wolfram Sang | 1545116 | 2019-04-19 20:16:01 +0200 | [diff] [blame] | 636 | watchdog_init_timeout(&w_priv->wdd, wdt_timeout, &client->dev); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 637 | |
| 638 | /* |
| 639 | * The default value set in the watchdog should be perfectly valid, so |
| 640 | * pass that in if we haven't provided one via the module parameter or |
| 641 | * of property. |
| 642 | */ |
| 643 | if (w_priv->wdd.timeout == 0) { |
| 644 | val = i2c_smbus_read_byte_data(client, ZIIRAVE_WDT_TIMEOUT); |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 645 | if (val < 0) { |
| 646 | dev_err(&client->dev, "Failed to read timeout\n"); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 647 | return val; |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 648 | } |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 649 | |
Andrey Smirnov | 39d0387 | 2019-08-12 13:08:48 -0700 | [diff] [blame] | 650 | if (val > ZIIRAVE_TIMEOUT_MAX || |
| 651 | val < ZIIRAVE_TIMEOUT_MIN) |
| 652 | val = ZIIRAVE_TIMEOUT_DEFAULT; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 653 | |
| 654 | w_priv->wdd.timeout = val; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 655 | } |
| 656 | |
Andrey Smirnov | 39d0387 | 2019-08-12 13:08:48 -0700 | [diff] [blame] | 657 | ret = ziirave_wdt_set_timeout(&w_priv->wdd, w_priv->wdd.timeout); |
| 658 | if (ret) { |
| 659 | dev_err(&client->dev, "Failed to set timeout\n"); |
| 660 | return ret; |
| 661 | } |
| 662 | |
| 663 | dev_info(&client->dev, "Timeout set to %ds\n", w_priv->wdd.timeout); |
| 664 | |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 665 | watchdog_set_nowayout(&w_priv->wdd, nowayout); |
| 666 | |
| 667 | i2c_set_clientdata(client, w_priv); |
| 668 | |
| 669 | /* If in unconfigured state, set to stopped */ |
| 670 | val = i2c_smbus_read_byte_data(client, ZIIRAVE_WDT_STATE); |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 671 | if (val < 0) { |
| 672 | dev_err(&client->dev, "Failed to read state\n"); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 673 | return val; |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 674 | } |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 675 | |
| 676 | if (val == ZIIRAVE_STATE_INITIAL) |
| 677 | ziirave_wdt_stop(&w_priv->wdd); |
| 678 | |
| 679 | ret = ziirave_wdt_init_duration(client); |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 680 | if (ret) { |
| 681 | dev_err(&client->dev, "Failed to init duration\n"); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 682 | return ret; |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 683 | } |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 684 | |
| 685 | ret = ziirave_wdt_revision(client, &w_priv->firmware_rev, |
| 686 | ZIIRAVE_WDT_FIRM_VER_MAJOR); |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 687 | if (ret) { |
| 688 | dev_err(&client->dev, "Failed to read firmware version\n"); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 689 | return ret; |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 690 | } |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 691 | |
Andrey Smirnov | 42abc12 | 2019-08-12 13:08:49 -0700 | [diff] [blame] | 692 | dev_info(&client->dev, |
| 693 | "Firmware version: " ZIIRAVE_FW_VERSION_FMT "\n", |
| 694 | w_priv->firmware_rev.major, w_priv->firmware_rev.minor); |
| 695 | |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 696 | ret = ziirave_wdt_revision(client, &w_priv->bootloader_rev, |
| 697 | ZIIRAVE_WDT_BOOT_VER_MAJOR); |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 698 | if (ret) { |
| 699 | dev_err(&client->dev, "Failed to read bootloader version\n"); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 700 | return ret; |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 701 | } |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 702 | |
Andrey Smirnov | 42abc12 | 2019-08-12 13:08:49 -0700 | [diff] [blame] | 703 | dev_info(&client->dev, |
| 704 | "Bootloader version: " ZIIRAVE_BL_VERSION_FMT "\n", |
| 705 | w_priv->bootloader_rev.major, w_priv->bootloader_rev.minor); |
| 706 | |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 707 | w_priv->reset_reason = i2c_smbus_read_byte_data(client, |
| 708 | ZIIRAVE_WDT_RESET_REASON); |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 709 | if (w_priv->reset_reason < 0) { |
| 710 | dev_err(&client->dev, "Failed to read reset reason\n"); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 711 | return w_priv->reset_reason; |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 712 | } |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 713 | |
| 714 | if (w_priv->reset_reason >= ARRAY_SIZE(ziirave_reasons) || |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 715 | !ziirave_reasons[w_priv->reset_reason]) { |
| 716 | dev_err(&client->dev, "Invalid reset reason\n"); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 717 | return -ENODEV; |
Andrey Smirnov | 4a9600c | 2019-08-12 13:08:46 -0700 | [diff] [blame] | 718 | } |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 719 | |
| 720 | ret = watchdog_register_device(&w_priv->wdd); |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 721 | |
Guenter Roeck | 2c2f308 | 2016-01-03 15:11:57 -0800 | [diff] [blame] | 722 | return ret; |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | static int ziirave_wdt_remove(struct i2c_client *client) |
| 726 | { |
| 727 | struct ziirave_wdt_data *w_priv = i2c_get_clientdata(client); |
| 728 | |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 729 | watchdog_unregister_device(&w_priv->wdd); |
| 730 | |
| 731 | return 0; |
| 732 | } |
| 733 | |
Arvind Yadav | 68c82be | 2017-08-21 22:18:38 +0530 | [diff] [blame] | 734 | static const struct i2c_device_id ziirave_wdt_id[] = { |
Enric Balletbo i Serra | 22daf7a | 2016-07-09 11:43:19 +0200 | [diff] [blame] | 735 | { "rave-wdt", 0 }, |
Martyn Welch | 2a7b753 | 2015-12-01 15:32:47 +0000 | [diff] [blame] | 736 | { } |
| 737 | }; |
| 738 | MODULE_DEVICE_TABLE(i2c, ziirave_wdt_id); |
| 739 | |
| 740 | static const struct of_device_id zrv_wdt_of_match[] = { |
| 741 | { .compatible = "zii,rave-wdt", }, |
| 742 | { }, |
| 743 | }; |
| 744 | MODULE_DEVICE_TABLE(of, zrv_wdt_of_match); |
| 745 | |
| 746 | static struct i2c_driver ziirave_wdt_driver = { |
| 747 | .driver = { |
| 748 | .name = "ziirave_wdt", |
| 749 | .of_match_table = zrv_wdt_of_match, |
| 750 | }, |
| 751 | .probe = ziirave_wdt_probe, |
| 752 | .remove = ziirave_wdt_remove, |
| 753 | .id_table = ziirave_wdt_id, |
| 754 | }; |
| 755 | |
| 756 | module_i2c_driver(ziirave_wdt_driver); |
| 757 | |
| 758 | MODULE_AUTHOR("Martyn Welch <martyn.welch@collabora.co.uk"); |
| 759 | MODULE_DESCRIPTION("Zodiac Aerospace RAVE Switch Watchdog Processor Driver"); |
| 760 | MODULE_LICENSE("GPL"); |