| 1 | /* |
| 2 | * SPI driver definitions for the CPLD chip on the Mikrotik RB4xx boards |
| 3 | * |
| 4 | * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org> |
| 5 | * |
| 6 | * This file was based on the patches for Linux 2.6.27.39 published by |
| 7 | * MikroTik for their RouterBoard 4xx series devices. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License version 2 as published |
| 11 | * by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #define CPLD_GPIO_nLED1 0 |
| 15 | #define CPLD_GPIO_nLED2 1 |
| 16 | #define CPLD_GPIO_nLED3 2 |
| 17 | #define CPLD_GPIO_nLED4 3 |
| 18 | #define CPLD_GPIO_FAN 4 |
| 19 | #define CPLD_GPIO_ALE 5 |
| 20 | #define CPLD_GPIO_CLE 6 |
| 21 | #define CPLD_GPIO_nCE 7 |
| 22 | #define CPLD_GPIO_nLED5 8 |
| 23 | |
| 24 | #define CPLD_NUM_GPIOS 9 |
| 25 | |
| 26 | #define CPLD_CFG_nLED1 BIT(CPLD_GPIO_nLED1) |
| 27 | #define CPLD_CFG_nLED2 BIT(CPLD_GPIO_nLED2) |
| 28 | #define CPLD_CFG_nLED3 BIT(CPLD_GPIO_nLED3) |
| 29 | #define CPLD_CFG_nLED4 BIT(CPLD_GPIO_nLED4) |
| 30 | #define CPLD_CFG_FAN BIT(CPLD_GPIO_FAN) |
| 31 | #define CPLD_CFG_ALE BIT(CPLD_GPIO_ALE) |
| 32 | #define CPLD_CFG_CLE BIT(CPLD_GPIO_CLE) |
| 33 | #define CPLD_CFG_nCE BIT(CPLD_GPIO_nCE) |
| 34 | #define CPLD_CFG_nLED5 BIT(CPLD_GPIO_nLED5) |
| 35 | |
| 36 | struct rb4xx_cpld_platform_data { |
| 37 | unsigned gpio_base; |
| 38 | }; |
| 39 | |
| 40 | extern int rb4xx_cpld_change_cfg(unsigned mask, unsigned value); |
| 41 | extern int rb4xx_cpld_read(unsigned char *rx_buf, |
| 42 | const unsigned char *verify_buf, |
| 43 | unsigned cnt); |
| 44 | extern int rb4xx_cpld_read_from(unsigned addr, |
| 45 | unsigned char *rx_buf, |
| 46 | const unsigned char *verify_buf, |
| 47 | unsigned cnt); |
| 48 | extern int rb4xx_cpld_write(const unsigned char *buf, unsigned count); |
| 49 | |