2 * Kontron PLD driver definitions
4 * Copyright (c) 2010-2012 Kontron Europe GmbH
5 * Author: Michael Brunner <michael.brunner@kontron.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License 2 as published
9 * by the Free Software Foundation.
12 #ifndef _LINUX_MFD_KEMPLD_H_
13 #define _LINUX_MFD_KEMPLD_H_
15 /* kempld register definitions */
16 #define KEMPLD_IOINDEX 0xa80
17 #define KEMPLD_IODATA 0xa81
18 #define KEMPLD_MUTEX_KEY 0x80
19 #define KEMPLD_VERSION 0x00
20 #define KEMPLD_VERSION_LSB 0x00
21 #define KEMPLD_VERSION_MSB 0x01
22 #define KEMPLD_VERSION_GET_MINOR(x) (x & 0x1f)
23 #define KEMPLD_VERSION_GET_MAJOR(x) ((x >> 5) & 0x1f)
24 #define KEMPLD_VERSION_GET_NUMBER(x) ((x >> 10) & 0xf)
25 #define KEMPLD_VERSION_GET_TYPE(x) ((x >> 14) & 0x3)
26 #define KEMPLD_BUILDNR 0x02
27 #define KEMPLD_BUILDNR_LSB 0x02
28 #define KEMPLD_BUILDNR_MSB 0x03
29 #define KEMPLD_FEATURE 0x04
30 #define KEMPLD_FEATURE_LSB 0x04
31 #define KEMPLD_FEATURE_MSB 0x05
32 #define KEMPLD_FEATURE_BIT_I2C (1 << 0)
33 #define KEMPLD_FEATURE_BIT_WATCHDOG (1 << 1)
34 #define KEMPLD_FEATURE_BIT_GPIO (1 << 2)
35 #define KEMPLD_FEATURE_MASK_UART (7 << 3)
36 #define KEMPLD_FEATURE_BIT_NMI (1 << 8)
37 #define KEMPLD_FEATURE_BIT_SMI (1 << 9)
38 #define KEMPLD_FEATURE_BIT_SCI (1 << 10)
39 #define KEMPLD_SPEC 0x06
40 #define KEMPLD_SPEC_GET_MINOR(x) (x & 0x0f)
41 #define KEMPLD_SPEC_GET_MAJOR(x) ((x >> 4) & 0x0f)
42 #define KEMPLD_IRQ_GPIO 0x35
43 #define KEMPLD_IRQ_I2C 0x36
44 #define KEMPLD_CFG 0x37
45 #define KEMPLD_CFG_GPIO_I2C_MUX (1 << 0)
46 #define KEMPLD_CFG_BIOS_WP (1 << 7)
48 #define KEMPLD_CLK 33333333
50 #define KEMPLD_TYPE_RELEASE 0x0
51 #define KEMPLD_TYPE_DEBUG 0x1
52 #define KEMPLD_TYPE_CUSTOM 0x2
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
61 * @spec_major: PLD FW specification major revision
62 * @spec_minor: PLD FW specification minor revision
70 unsigned int spec_major;
71 unsigned int spec_minor;
75 * struct kempld_device_data - Internal representation of the PLD device
76 * @io_base: Pointer to the IO memory
77 * @io_index: Pointer to the IO index register
78 * @io_data: Pointer to the IO data register
79 * @pld_clock: PLD clock frequency
80 * @feature_mask: PLD feature mask
81 * @dev: Pointer to kernel device structure
82 * @info: KEMPLD info structure
85 struct kempld_device_data {
86 void __iomem *io_base;
87 void __iomem *io_index;
88 void __iomem *io_data;
92 struct kempld_info info;
97 * struct kempld_platform_data - PLD hardware configuration structure
98 * @pld_clock: PLD clock frequency
99 * @gpio_base GPIO base pin number
100 * @ioresource: IO addresses of the PLD
101 * @get_mutex: PLD specific get_mutex callback
102 * @release_mutex: PLD specific release_mutex callback
103 * @get_info: PLD specific get_info callback
104 * @register_cells: PLD specific register_cells callback
106 struct kempld_platform_data {
109 struct resource *ioresource;
110 void (*get_hardware_mutex) (struct kempld_device_data *);
111 void (*release_hardware_mutex) (struct kempld_device_data *);
112 int (*get_info) (struct kempld_device_data *);
113 int (*register_cells) (struct kempld_device_data *);
116 extern void kempld_get_mutex(struct kempld_device_data *pld);
117 extern void kempld_release_mutex(struct kempld_device_data *pld);
118 extern u8 kempld_read8(struct kempld_device_data *pld, u8 index);
119 extern void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data);
120 extern u16 kempld_read16(struct kempld_device_data *pld, u8 index);
121 extern void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data);
122 extern u32 kempld_read32(struct kempld_device_data *pld, u8 index);
123 extern void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data);
125 #endif /* _LINUX_MFD_KEMPLD_H_ */