]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/mfd/kempld.h
Merge remote-tracking branch 'asoc/fix/rcar' into asoc-rcar
[mirror_ubuntu-bionic-kernel.git] / include / linux / mfd / kempld.h
1 /*
2 * Kontron PLD driver definitions
3 *
4 * Copyright (c) 2010-2012 Kontron Europe GmbH
5 * Author: Michael Brunner <michael.brunner@kontron.com>
6 *
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.
10 */
11
12 #ifndef _LINUX_MFD_KEMPLD_H_
13 #define _LINUX_MFD_KEMPLD_H_
14
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)
47
48 #define KEMPLD_CLK 33333333
49
50 #define KEMPLD_TYPE_RELEASE 0x0
51 #define KEMPLD_TYPE_DEBUG 0x1
52 #define KEMPLD_TYPE_CUSTOM 0x2
53
54 #define KEMPLD_VERSION_LEN 10
55
56 /**
57 * struct kempld_info - PLD device information structure
58 * @major: PLD major revision
59 * @minor: PLD minor revision
60 * @buildnr: PLD build number
61 * @number: PLD board specific index
62 * @type: PLD type
63 * @spec_major: PLD FW specification major revision
64 * @spec_minor: PLD FW specification minor revision
65 * @version: PLD version string
66 */
67 struct kempld_info {
68 unsigned int major;
69 unsigned int minor;
70 unsigned int buildnr;
71 unsigned int number;
72 unsigned int type;
73 unsigned int spec_major;
74 unsigned int spec_minor;
75 char version[KEMPLD_VERSION_LEN];
76 };
77
78 /**
79 * struct kempld_device_data - Internal representation of the PLD device
80 * @io_base: Pointer to the IO memory
81 * @io_index: Pointer to the IO index register
82 * @io_data: Pointer to the IO data register
83 * @pld_clock: PLD clock frequency
84 * @feature_mask: PLD feature mask
85 * @dev: Pointer to kernel device structure
86 * @info: KEMPLD info structure
87 * @lock: PLD mutex
88 */
89 struct kempld_device_data {
90 void __iomem *io_base;
91 void __iomem *io_index;
92 void __iomem *io_data;
93 u32 pld_clock;
94 u32 feature_mask;
95 struct device *dev;
96 struct kempld_info info;
97 struct mutex lock;
98 };
99
100 /**
101 * struct kempld_platform_data - PLD hardware configuration structure
102 * @pld_clock: PLD clock frequency
103 * @gpio_base GPIO base pin number
104 * @ioresource: IO addresses of the PLD
105 * @get_mutex: PLD specific get_mutex callback
106 * @release_mutex: PLD specific release_mutex callback
107 * @get_info: PLD specific get_info callback
108 * @register_cells: PLD specific register_cells callback
109 */
110 struct kempld_platform_data {
111 u32 pld_clock;
112 int gpio_base;
113 struct resource *ioresource;
114 void (*get_hardware_mutex) (struct kempld_device_data *);
115 void (*release_hardware_mutex) (struct kempld_device_data *);
116 int (*get_info) (struct kempld_device_data *);
117 int (*register_cells) (struct kempld_device_data *);
118 };
119
120 extern void kempld_get_mutex(struct kempld_device_data *pld);
121 extern void kempld_release_mutex(struct kempld_device_data *pld);
122 extern u8 kempld_read8(struct kempld_device_data *pld, u8 index);
123 extern void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data);
124 extern u16 kempld_read16(struct kempld_device_data *pld, u8 index);
125 extern void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data);
126 extern u32 kempld_read32(struct kempld_device_data *pld, u8 index);
127 extern void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data);
128
129 #endif /* _LINUX_MFD_KEMPLD_H_ */