1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Kontron PLD driver definitions 4 * 5 * Copyright (c) 2010-2012 Kontron Europe GmbH 6 * Author: Michael Brunner <michael.brunner@kontron.com> 7 */ 8 9 #ifndef _LINUX_MFD_KEMPLD_H_ 10 #define _LINUX_MFD_KEMPLD_H_ 11 12 /* kempld register definitions */ 13 #define KEMPLD_IOINDEX 0xa80 14 #define KEMPLD_IODATA 0xa81 15 #define KEMPLD_MUTEX_KEY 0x80 16 #define KEMPLD_VERSION 0x00 17 #define KEMPLD_VERSION_LSB 0x00 18 #define KEMPLD_VERSION_MSB 0x01 19 #define KEMPLD_VERSION_GET_MINOR(x) (x & 0x1f) 20 #define KEMPLD_VERSION_GET_MAJOR(x) ((x >> 5) & 0x1f) 21 #define KEMPLD_VERSION_GET_NUMBER(x) ((x >> 10) & 0xf) 22 #define KEMPLD_VERSION_GET_TYPE(x) ((x >> 14) & 0x3) 23 #define KEMPLD_BUILDNR 0x02 24 #define KEMPLD_BUILDNR_LSB 0x02 25 #define KEMPLD_BUILDNR_MSB 0x03 26 #define KEMPLD_FEATURE 0x04 27 #define KEMPLD_FEATURE_LSB 0x04 28 #define KEMPLD_FEATURE_MSB 0x05 29 #define KEMPLD_FEATURE_BIT_I2C (1 << 0) 30 #define KEMPLD_FEATURE_BIT_WATCHDOG (1 << 1) 31 #define KEMPLD_FEATURE_BIT_GPIO (1 << 2) 32 #define KEMPLD_FEATURE_MASK_UART (7 << 3) 33 #define KEMPLD_FEATURE_BIT_NMI (1 << 8) 34 #define KEMPLD_FEATURE_BIT_SMI (1 << 9) 35 #define KEMPLD_FEATURE_BIT_SCI (1 << 10) 36 #define KEMPLD_SPEC 0x06 37 #define KEMPLD_SPEC_GET_MINOR(x) (x & 0x0f) 38 #define KEMPLD_SPEC_GET_MAJOR(x) ((x >> 4) & 0x0f) 39 #define KEMPLD_IRQ_GPIO 0x35 40 #define KEMPLD_IRQ_GPIO_MASK 0x0f 41 #define KEMPLD_IRQ_I2C 0x36 42 #define KEMPLD_CFG 0x37 43 #define KEMPLD_CFG_GPIO_I2C_MUX (1 << 0) 44 #define KEMPLD_CFG_BIOS_WP (1 << 7) 45 46 #define KEMPLD_CLK 33333333 47 48 #define KEMPLD_TYPE_RELEASE 0x0 49 #define KEMPLD_TYPE_DEBUG 0x1 50 #define KEMPLD_TYPE_CUSTOM 0x2 51 52 #define KEMPLD_VERSION_LEN 10 53 54 /** 55 * struct kempld_info - PLD device information structure 56 * @major: PLD major revision 57 * @minor: PLD minor revision 58 * @buildnr: PLD build number 59 * @number: PLD board specific index 60 * @type: PLD type 61 * @spec_major: PLD FW specification major revision 62 * @spec_minor: PLD FW specification minor revision 63 * @version: PLD version string 64 */ 65 struct kempld_info { 66 unsigned int major; 67 unsigned int minor; 68 unsigned int buildnr; 69 unsigned int number; 70 unsigned int type; 71 unsigned int spec_major; 72 unsigned int spec_minor; 73 char version[KEMPLD_VERSION_LEN]; 74 }; 75 76 /** 77 * struct kempld_device_data - Internal representation of the PLD device 78 * @io_base: Pointer to the IO memory 79 * @io_index: Pointer to the IO index register 80 * @io_data: Pointer to the IO data register 81 * @pld_clock: PLD clock frequency 82 * @feature_mask: PLD feature mask 83 * @dev: Pointer to kernel device structure 84 * @info: KEMPLD info structure 85 * @lock: PLD mutex 86 */ 87 struct kempld_device_data { 88 void __iomem *io_base; 89 void __iomem *io_index; 90 void __iomem *io_data; 91 u32 pld_clock; 92 u32 feature_mask; 93 struct device *dev; 94 struct kempld_info info; 95 struct mutex lock; 96 }; 97 98 /** 99 * struct kempld_platform_data - PLD hardware configuration structure 100 * @pld_clock: PLD clock frequency 101 * @gpio_base GPIO base pin number 102 * @ioresource: IO addresses of the PLD 103 * @get_mutex: PLD specific get_mutex callback 104 * @release_mutex: PLD specific release_mutex callback 105 * @get_info: PLD specific get_info callback 106 * @register_cells: PLD specific register_cells callback 107 */ 108 struct kempld_platform_data { 109 u32 pld_clock; 110 int gpio_base; 111 struct resource *ioresource; 112 void (*get_hardware_mutex) (struct kempld_device_data *); 113 void (*release_hardware_mutex) (struct kempld_device_data *); 114 int (*get_info) (struct kempld_device_data *); 115 int (*register_cells) (struct kempld_device_data *); 116 }; 117 118 extern void kempld_get_mutex(struct kempld_device_data *pld); 119 extern void kempld_release_mutex(struct kempld_device_data *pld); 120 extern u8 kempld_read8(struct kempld_device_data *pld, u8 index); 121 extern void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data); 122 extern u16 kempld_read16(struct kempld_device_data *pld, u8 index); 123 extern void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data); 124 extern u32 kempld_read32(struct kempld_device_data *pld, u8 index); 125 extern void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data); 126 127 #endif /* _LINUX_MFD_KEMPLD_H_ */ 128