Commit | Line | Data |
---|---|---|
722d94a3 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
43620a17 KS |
2 | /* |
3 | * Kontron PLD driver definitions | |
4 | * | |
5 | * Copyright (c) 2010-2012 Kontron Europe GmbH | |
6 | * Author: Michael Brunner <michael.brunner@kontron.com> | |
43620a17 KS |
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_I2C 0x36 | |
41 | #define KEMPLD_CFG 0x37 | |
42 | #define KEMPLD_CFG_GPIO_I2C_MUX (1 << 0) | |
43 | #define KEMPLD_CFG_BIOS_WP (1 << 7) | |
44 | ||
45 | #define KEMPLD_CLK 33333333 | |
46 | ||
47 | #define KEMPLD_TYPE_RELEASE 0x0 | |
48 | #define KEMPLD_TYPE_DEBUG 0x1 | |
49 | #define KEMPLD_TYPE_CUSTOM 0x2 | |
50 | ||
58a9e5b9 MB |
51 | #define KEMPLD_VERSION_LEN 10 |
52 | ||
43620a17 KS |
53 | /** |
54 | * struct kempld_info - PLD device information structure | |
55 | * @major: PLD major revision | |
56 | * @minor: PLD minor revision | |
57 | * @buildnr: PLD build number | |
58 | * @number: PLD board specific index | |
59 | * @type: PLD type | |
60 | * @spec_major: PLD FW specification major revision | |
61 | * @spec_minor: PLD FW specification minor revision | |
58a9e5b9 | 62 | * @version: PLD version string |
43620a17 KS |
63 | */ |
64 | struct kempld_info { | |
65 | unsigned int major; | |
66 | unsigned int minor; | |
67 | unsigned int buildnr; | |
68 | unsigned int number; | |
69 | unsigned int type; | |
70 | unsigned int spec_major; | |
71 | unsigned int spec_minor; | |
58a9e5b9 | 72 | char version[KEMPLD_VERSION_LEN]; |
43620a17 KS |
73 | }; |
74 | ||
75 | /** | |
76 | * struct kempld_device_data - Internal representation of the PLD device | |
77 | * @io_base: Pointer to the IO memory | |
78 | * @io_index: Pointer to the IO index register | |
79 | * @io_data: Pointer to the IO data register | |
80 | * @pld_clock: PLD clock frequency | |
81 | * @feature_mask: PLD feature mask | |
82 | * @dev: Pointer to kernel device structure | |
83 | * @info: KEMPLD info structure | |
84 | * @lock: PLD mutex | |
85 | */ | |
86 | struct kempld_device_data { | |
87 | void __iomem *io_base; | |
88 | void __iomem *io_index; | |
89 | void __iomem *io_data; | |
90 | u32 pld_clock; | |
91 | u32 feature_mask; | |
92 | struct device *dev; | |
93 | struct kempld_info info; | |
94 | struct mutex lock; | |
95 | }; | |
96 | ||
97 | /** | |
98 | * struct kempld_platform_data - PLD hardware configuration structure | |
99 | * @pld_clock: PLD clock frequency | |
100 | * @gpio_base GPIO base pin number | |
101 | * @ioresource: IO addresses of the PLD | |
102 | * @get_mutex: PLD specific get_mutex callback | |
103 | * @release_mutex: PLD specific release_mutex callback | |
104 | * @get_info: PLD specific get_info callback | |
105 | * @register_cells: PLD specific register_cells callback | |
106 | */ | |
107 | struct kempld_platform_data { | |
108 | u32 pld_clock; | |
109 | int gpio_base; | |
110 | struct resource *ioresource; | |
111 | void (*get_hardware_mutex) (struct kempld_device_data *); | |
112 | void (*release_hardware_mutex) (struct kempld_device_data *); | |
113 | int (*get_info) (struct kempld_device_data *); | |
114 | int (*register_cells) (struct kempld_device_data *); | |
115 | }; | |
116 | ||
117 | extern void kempld_get_mutex(struct kempld_device_data *pld); | |
118 | extern void kempld_release_mutex(struct kempld_device_data *pld); | |
119 | extern u8 kempld_read8(struct kempld_device_data *pld, u8 index); | |
120 | extern void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data); | |
121 | extern u16 kempld_read16(struct kempld_device_data *pld, u8 index); | |
122 | extern void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data); | |
123 | extern u32 kempld_read32(struct kempld_device_data *pld, u8 index); | |
124 | extern void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data); | |
125 | ||
126 | #endif /* _LINUX_MFD_KEMPLD_H_ */ |