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