aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/fmc-sdb.h36
-rw-r--r--include/linux/fmc.h237
-rw-r--r--include/linux/hyperv.h70
-rw-r--r--include/linux/if_ether.h1
-rw-r--r--include/linux/ipmi-fru.h135
-rw-r--r--include/linux/kernel.h2
-rw-r--r--include/linux/mfd/palmas.h26
-rw-r--r--include/linux/sdb.h159
8 files changed, 653 insertions, 13 deletions
diff --git a/include/linux/fmc-sdb.h b/include/linux/fmc-sdb.h
new file mode 100644
index 000000000000..1974317a9b3d
--- /dev/null
+++ b/include/linux/fmc-sdb.h
@@ -0,0 +1,36 @@
1/*
2 * This file is separate from sdb.h, because I want that one to remain
3 * unchanged (as far as possible) from the official sdb distribution
4 *
5 * This file and associated functionality are a playground for me to
6 * understand stuff which will later be implemented in more generic places.
7 */
8#include <linux/sdb.h>
9
10/* This is the union of all currently defined types */
11union sdb_record {
12 struct sdb_interconnect ic;
13 struct sdb_device dev;
14 struct sdb_bridge bridge;
15 struct sdb_integration integr;
16 struct sdb_empty empty;
17};
18
19struct fmc_device;
20
21/* Every sdb table is turned into this structure */
22struct sdb_array {
23 int len;
24 int level;
25 unsigned long baseaddr;
26 struct fmc_device *fmc; /* the device that hosts it */
27 struct sdb_array *parent; /* NULL at root */
28 union sdb_record *record; /* copies of the struct */
29 struct sdb_array **subtree; /* only valid for bridge items */
30};
31
32extern int fmc_scan_sdb_tree(struct fmc_device *fmc, unsigned long address);
33extern void fmc_show_sdb_tree(const struct fmc_device *fmc);
34extern signed long fmc_find_sdb_device(struct sdb_array *tree, uint64_t vendor,
35 uint32_t device, unsigned long *sz);
36extern int fmc_free_sdb_tree(struct fmc_device *fmc);
diff --git a/include/linux/fmc.h b/include/linux/fmc.h
new file mode 100644
index 000000000000..a5f0aa5c2a8d
--- /dev/null
+++ b/include/linux/fmc.h
@@ -0,0 +1,237 @@
1/*
2 * Copyright (C) 2012 CERN (www.cern.ch)
3 * Author: Alessandro Rubini <rubini@gnudd.com>
4 *
5 * Released according to the GNU GPL, version 2 or any later version.
6 *
7 * This work is part of the White Rabbit project, a research effort led
8 * by CERN, the European Institute for Nuclear Research.
9 */
10#ifndef __LINUX_FMC_H__
11#define __LINUX_FMC_H__
12#include <linux/types.h>
13#include <linux/moduleparam.h>
14#include <linux/device.h>
15#include <linux/list.h>
16#include <linux/interrupt.h>
17#include <linux/io.h>
18
19struct fmc_device;
20struct fmc_driver;
21
22/*
23 * This bus abstraction is developed separately from drivers, so we need
24 * to check the version of the data structures we receive.
25 */
26
27#define FMC_MAJOR 3
28#define FMC_MINOR 0
29#define FMC_VERSION ((FMC_MAJOR << 16) | FMC_MINOR)
30#define __FMC_MAJOR(x) ((x) >> 16)
31#define __FMC_MINOR(x) ((x) & 0xffff)
32
33/*
34 * The device identification, as defined by the IPMI FRU (Field Replaceable
35 * Unit) includes four different strings to describe the device. Here we
36 * only match the "Board Manufacturer" and the "Board Product Name",
37 * ignoring the "Board Serial Number" and "Board Part Number". All 4 are
38 * expected to be strings, so they are treated as zero-terminated C strings.
39 * Unspecified string (NULL) means "any", so if both are unspecified this
40 * is a catch-all driver. So null entries are allowed and we use array
41 * and length. This is unlike pci and usb that use null-terminated arrays
42 */
43struct fmc_fru_id {
44 char *manufacturer;
45 char *product_name;
46};
47
48/*
49 * If the FPGA is already programmed (think Etherbone or the second
50 * SVEC slot), we can match on SDB devices in the memory image. This
51 * match uses an array of devices that must all be present, and the
52 * match is based on vendor and device only. Further checks are expected
53 * to happen in the probe function. Zero means "any" and catch-all is allowed.
54 */
55struct fmc_sdb_one_id {
56 uint64_t vendor;
57 uint32_t device;
58};
59struct fmc_sdb_id {
60 struct fmc_sdb_one_id *cores;
61 int cores_nr;
62};
63
64struct fmc_device_id {
65 struct fmc_fru_id *fru_id;
66 int fru_id_nr;
67 struct fmc_sdb_id *sdb_id;
68 int sdb_id_nr;
69};
70
71/* This sizes the module_param_array used by generic module parameters */
72#define FMC_MAX_CARDS 32
73
74/* The driver is a pretty simple thing */
75struct fmc_driver {
76 unsigned long version;
77 struct device_driver driver;
78 int (*probe)(struct fmc_device *);
79 int (*remove)(struct fmc_device *);
80 const struct fmc_device_id id_table;
81 /* What follows is for generic module parameters */
82 int busid_n;
83 int busid_val[FMC_MAX_CARDS];
84 int gw_n;
85 char *gw_val[FMC_MAX_CARDS];
86};
87#define to_fmc_driver(x) container_of((x), struct fmc_driver, driver)
88
89/* These are the generic parameters, that drivers may instantiate */
90#define FMC_PARAM_BUSID(_d) \
91 module_param_array_named(busid, _d.busid_val, int, &_d.busid_n, 0444)
92#define FMC_PARAM_GATEWARE(_d) \
93 module_param_array_named(gateware, _d.gw_val, charp, &_d.gw_n, 0444)
94
95/*
96 * Drivers may need to configure gpio pins in the carrier. To read input
97 * (a very uncommon operation, and definitely not in the hot paths), just
98 * configure one gpio only and get 0 or 1 as retval of the config method
99 */
100struct fmc_gpio {
101 char *carrier_name; /* name or NULL for virtual pins */
102 int gpio;
103 int _gpio; /* internal use by the carrier */
104 int mode; /* GPIOF_DIR_OUT etc, from <linux/gpio.h> */
105 int irqmode; /* IRQF_TRIGGER_LOW and so on */
106};
107
108/* The numbering of gpio pins allows access to raw pins or virtual roles */
109#define FMC_GPIO_RAW(x) (x) /* 4096 of them */
110#define __FMC_GPIO_IS_RAW(x) ((x) < 0x1000)
111#define FMC_GPIO_IRQ(x) ((x) + 0x1000) /* 256 of them */
112#define FMC_GPIO_LED(x) ((x) + 0x1100) /* 256 of them */
113#define FMC_GPIO_KEY(x) ((x) + 0x1200) /* 256 of them */
114#define FMC_GPIO_TP(x) ((x) + 0x1300) /* 256 of them */
115#define FMC_GPIO_USER(x) ((x) + 0x1400) /* 256 of them */
116/* We may add SCL and SDA, or other roles if the need arises */
117
118/* GPIOF_DIR_IN etc are missing before 3.0. copy from <linux/gpio.h> */
119#ifndef GPIOF_DIR_IN
120# define GPIOF_DIR_OUT (0 << 0)
121# define GPIOF_DIR_IN (1 << 0)
122# define GPIOF_INIT_LOW (0 << 1)
123# define GPIOF_INIT_HIGH (1 << 1)
124#endif
125
126/*
127 * The operations are offered by each carrier and should make driver
128 * design completely independent of the carrier. Named GPIO pins may be
129 * the exception.
130 */
131struct fmc_operations {
132 uint32_t (*read32)(struct fmc_device *fmc, int offset);
133 void (*write32)(struct fmc_device *fmc, uint32_t value, int offset);
134 int (*validate)(struct fmc_device *fmc, struct fmc_driver *drv);
135 int (*reprogram)(struct fmc_device *f, struct fmc_driver *d, char *gw);
136 int (*irq_request)(struct fmc_device *fmc, irq_handler_t h,
137 char *name, int flags);
138 void (*irq_ack)(struct fmc_device *fmc);
139 int (*irq_free)(struct fmc_device *fmc);
140 int (*gpio_config)(struct fmc_device *fmc, struct fmc_gpio *gpio,
141 int ngpio);
142 int (*read_ee)(struct fmc_device *fmc, int pos, void *d, int l);
143 int (*write_ee)(struct fmc_device *fmc, int pos, const void *d, int l);
144};
145
146/* Prefer this helper rather than calling of fmc->reprogram directly */
147extern int fmc_reprogram(struct fmc_device *f, struct fmc_driver *d, char *gw,
148 int sdb_entry);
149
150/*
151 * The device reports all information needed to access hw.
152 *
153 * If we have eeprom_len and not contents, the core reads it.
154 * Then, parsing of identifiers is done by the core which fills fmc_fru_id..
155 * Similarly a device that must be matched based on SDB cores must
156 * fill the entry point and the core will scan the bus (FIXME: sdb match)
157 */
158struct fmc_device {
159 unsigned long version;
160 unsigned long flags;
161 struct module *owner; /* char device must pin it */
162 struct fmc_fru_id id; /* for EEPROM-based match */
163 struct fmc_operations *op; /* carrier-provided */
164 int irq; /* according to host bus. 0 == none */
165 int eeprom_len; /* Usually 8kB, may be less */
166 int eeprom_addr; /* 0x50, 0x52 etc */
167 uint8_t *eeprom; /* Full contents or leading part */
168 char *carrier_name; /* "SPEC" or similar, for special use */
169 void *carrier_data; /* "struct spec *" or equivalent */
170 __iomem void *fpga_base; /* May be NULL (Etherbone) */
171 __iomem void *slot_base; /* Set by the driver */
172 struct fmc_device **devarray; /* Allocated by the bus */
173 int slot_id; /* Index in the slot array */
174 int nr_slots; /* Number of slots in this carrier */
175 unsigned long memlen; /* Used for the char device */
176 struct device dev; /* For Linux use */
177 struct device *hwdev; /* The underlying hardware device */
178 unsigned long sdbfs_entry;
179 struct sdb_array *sdb;
180 uint32_t device_id; /* Filled by the device */
181 char *mezzanine_name; /* Defaults to ``fmc'' */
182 void *mezzanine_data;
183};
184#define to_fmc_device(x) container_of((x), struct fmc_device, dev)
185
186#define FMC_DEVICE_HAS_GOLDEN 1
187#define FMC_DEVICE_HAS_CUSTOM 2
188#define FMC_DEVICE_NO_MEZZANINE 4
189#define FMC_DEVICE_MATCH_SDB 8 /* fmc-core must scan sdb in fpga */
190
191/*
192 * If fpga_base can be used, the carrier offers no readl/writel methods, and
193 * this expands to a single, fast, I/O access.
194 */
195static inline uint32_t fmc_readl(struct fmc_device *fmc, int offset)
196{
197 if (unlikely(fmc->op->read32))
198 return fmc->op->read32(fmc, offset);
199 return readl(fmc->fpga_base + offset);
200}
201static inline void fmc_writel(struct fmc_device *fmc, uint32_t val, int off)
202{
203 if (unlikely(fmc->op->write32))
204 fmc->op->write32(fmc, val, off);
205 else
206 writel(val, fmc->fpga_base + off);
207}
208
209/* pci-like naming */
210static inline void *fmc_get_drvdata(const struct fmc_device *fmc)
211{
212 return dev_get_drvdata(&fmc->dev);
213}
214
215static inline void fmc_set_drvdata(struct fmc_device *fmc, void *data)
216{
217 dev_set_drvdata(&fmc->dev, data);
218}
219
220/* The 4 access points */
221extern int fmc_driver_register(struct fmc_driver *drv);
222extern void fmc_driver_unregister(struct fmc_driver *drv);
223extern int fmc_device_register(struct fmc_device *tdev);
224extern void fmc_device_unregister(struct fmc_device *tdev);
225
226/* Two more for device sets, all driven by the same FPGA */
227extern int fmc_device_register_n(struct fmc_device **devs, int n);
228extern void fmc_device_unregister_n(struct fmc_device **devs, int n);
229
230/* Internal cross-calls between files; not exported to other modules */
231extern int fmc_match(struct device *dev, struct device_driver *drv);
232extern int fmc_fill_id_info(struct fmc_device *fmc);
233extern void fmc_free_id_info(struct fmc_device *fmc);
234extern void fmc_dump_eeprom(const struct fmc_device *fmc);
235extern void fmc_dump_sdb(const struct fmc_device *fmc);
236
237#endif /* __LINUX_FMC_H__ */
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index c2559847d7ee..fae8bac907ef 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -909,6 +909,7 @@ enum vmbus_channel_state {
909 CHANNEL_OFFER_STATE, 909 CHANNEL_OFFER_STATE,
910 CHANNEL_OPENING_STATE, 910 CHANNEL_OPENING_STATE,
911 CHANNEL_OPEN_STATE, 911 CHANNEL_OPEN_STATE,
912 CHANNEL_OPENED_STATE,
912}; 913};
913 914
914struct vmbus_channel_debug_info { 915struct vmbus_channel_debug_info {
@@ -1046,6 +1047,38 @@ struct vmbus_channel {
1046 * preserve the earlier behavior. 1047 * preserve the earlier behavior.
1047 */ 1048 */
1048 u32 target_vp; 1049 u32 target_vp;
1050 /*
1051 * Support for sub-channels. For high performance devices,
1052 * it will be useful to have multiple sub-channels to support
1053 * a scalable communication infrastructure with the host.
1054 * The support for sub-channels is implemented as an extention
1055 * to the current infrastructure.
1056 * The initial offer is considered the primary channel and this
1057 * offer message will indicate if the host supports sub-channels.
1058 * The guest is free to ask for sub-channels to be offerred and can
1059 * open these sub-channels as a normal "primary" channel. However,
1060 * all sub-channels will have the same type and instance guids as the
1061 * primary channel. Requests sent on a given channel will result in a
1062 * response on the same channel.
1063 */
1064
1065 /*
1066 * Sub-channel creation callback. This callback will be called in
1067 * process context when a sub-channel offer is received from the host.
1068 * The guest can open the sub-channel in the context of this callback.
1069 */
1070 void (*sc_creation_callback)(struct vmbus_channel *new_sc);
1071
1072 spinlock_t sc_lock;
1073 /*
1074 * All Sub-channels of a primary channel are linked here.
1075 */
1076 struct list_head sc_list;
1077 /*
1078 * The primary channel this sub-channel belongs to.
1079 * This will be NULL for the primary channel.
1080 */
1081 struct vmbus_channel *primary_channel;
1049}; 1082};
1050 1083
1051static inline void set_channel_read_state(struct vmbus_channel *c, bool state) 1084static inline void set_channel_read_state(struct vmbus_channel *c, bool state)
@@ -1057,6 +1090,34 @@ void vmbus_onmessage(void *context);
1057 1090
1058int vmbus_request_offers(void); 1091int vmbus_request_offers(void);
1059 1092
1093/*
1094 * APIs for managing sub-channels.
1095 */
1096
1097void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel,
1098 void (*sc_cr_cb)(struct vmbus_channel *new_sc));
1099
1100/*
1101 * Retrieve the (sub) channel on which to send an outgoing request.
1102 * When a primary channel has multiple sub-channels, we choose a
1103 * channel whose VCPU binding is closest to the VCPU on which
1104 * this call is being made.
1105 */
1106struct vmbus_channel *vmbus_get_outgoing_channel(struct vmbus_channel *primary);
1107
1108/*
1109 * Check if sub-channels have already been offerred. This API will be useful
1110 * when the driver is unloaded after establishing sub-channels. In this case,
1111 * when the driver is re-loaded, the driver would have to check if the
1112 * subchannels have already been established before attempting to request
1113 * the creation of sub-channels.
1114 * This function returns TRUE to indicate that subchannels have already been
1115 * created.
1116 * This function should be invoked after setting the callback function for
1117 * sub-channel creation.
1118 */
1119bool vmbus_are_subchannels_present(struct vmbus_channel *primary);
1120
1060/* The format must be the same as struct vmdata_gpa_direct */ 1121/* The format must be the same as struct vmdata_gpa_direct */
1061struct vmbus_channel_packet_page_buffer { 1122struct vmbus_channel_packet_page_buffer {
1062 u16 type; 1123 u16 type;
@@ -1327,6 +1388,15 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver);
1327 0x8e, 0x77, 0x05, 0x58, 0xeb, 0x10, 0x73, 0xf8 \ 1388 0x8e, 0x77, 0x05, 0x58, 0xeb, 0x10, 0x73, 0xf8 \
1328 } 1389 }
1329 1390
1391/*
1392 * Synthetic FC GUID
1393 * {2f9bcc4a-0069-4af3-b76b-6fd0be528cda}
1394 */
1395#define HV_SYNTHFC_GUID \
1396 .guid = { \
1397 0x4A, 0xCC, 0x9B, 0x2F, 0x69, 0x00, 0xF3, 0x4A, \
1398 0xB7, 0x6B, 0x6F, 0xD0, 0xBE, 0x52, 0x8C, 0xDA \
1399 }
1330 1400
1331/* 1401/*
1332 * Common header for Hyper-V ICs 1402 * Common header for Hyper-V ICs
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 12b4d55a02af..d5569734f672 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -30,7 +30,6 @@ static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
30 30
31int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr); 31int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
32 32
33int mac_pton(const char *s, u8 *mac);
34extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len); 33extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
35 34
36#endif /* _LINUX_IF_ETHER_H */ 35#endif /* _LINUX_IF_ETHER_H */
diff --git a/include/linux/ipmi-fru.h b/include/linux/ipmi-fru.h
new file mode 100644
index 000000000000..4d3a76380e32
--- /dev/null
+++ b/include/linux/ipmi-fru.h
@@ -0,0 +1,135 @@
1/*
2 * Copyright (C) 2012 CERN (www.cern.ch)
3 * Author: Alessandro Rubini <rubini@gnudd.com>
4 *
5 * Released according to the GNU GPL, version 2 or any later version.
6 *
7 * This work is part of the White Rabbit project, a research effort led
8 * by CERN, the European Institute for Nuclear Research.
9 */
10#ifndef __LINUX_IPMI_FRU_H__
11#define __LINUX_IPMI_FRU_H__
12#ifdef __KERNEL__
13# include <linux/types.h>
14# include <linux/string.h>
15#else
16# include <stdint.h>
17# include <string.h>
18#endif
19
20/*
21 * These structures match the unaligned crap we have in FRU1011.pdf
22 * (http://download.intel.com/design/servers/ipmi/FRU1011.pdf)
23 */
24
25/* chapter 8, page 5 */
26struct fru_common_header {
27 uint8_t format; /* 0x01 */
28 uint8_t internal_use_off; /* multiple of 8 bytes */
29 uint8_t chassis_info_off; /* multiple of 8 bytes */
30 uint8_t board_area_off; /* multiple of 8 bytes */
31 uint8_t product_area_off; /* multiple of 8 bytes */
32 uint8_t multirecord_off; /* multiple of 8 bytes */
33 uint8_t pad; /* must be 0 */
34 uint8_t checksum; /* sum modulo 256 must be 0 */
35};
36
37/* chapter 9, page 5 -- internal_use: not used by us */
38
39/* chapter 10, page 6 -- chassis info: not used by us */
40
41/* chapter 13, page 9 -- used by board_info_area below */
42struct fru_type_length {
43 uint8_t type_length;
44 uint8_t data[0];
45};
46
47/* chapter 11, page 7 */
48struct fru_board_info_area {
49 uint8_t format; /* 0x01 */
50 uint8_t area_len; /* multiple of 8 bytes */
51 uint8_t language; /* I hope it's 0 */
52 uint8_t mfg_date[3]; /* LSB, minutes since 1996-01-01 */
53 struct fru_type_length tl[0]; /* type-length stuff follows */
54
55 /*
56 * the TL there are in order:
57 * Board Manufacturer
58 * Board Product Name
59 * Board Serial Number
60 * Board Part Number
61 * FRU File ID (may be null)
62 * more manufacturer-specific stuff
63 * 0xc1 as a terminator
64 * 0x00 pad to a multiple of 8 bytes - 1
65 * checksum (sum of all stuff module 256 must be zero)
66 */
67};
68
69enum fru_type {
70 FRU_TYPE_BINARY = 0x00,
71 FRU_TYPE_BCDPLUS = 0x40,
72 FRU_TYPE_ASCII6 = 0x80,
73 FRU_TYPE_ASCII = 0xc0, /* not ascii: depends on language */
74};
75
76/*
77 * some helpers
78 */
79static inline struct fru_board_info_area *fru_get_board_area(
80 const struct fru_common_header *header)
81{
82 /* we know for sure that the header is 8 bytes in size */
83 return (struct fru_board_info_area *)(header + header->board_area_off);
84}
85
86static inline int fru_type(struct fru_type_length *tl)
87{
88 return tl->type_length & 0xc0;
89}
90
91static inline int fru_length(struct fru_type_length *tl)
92{
93 return (tl->type_length & 0x3f) + 1; /* len of whole record */
94}
95
96/* assume ascii-latin1 encoding */
97static inline int fru_strlen(struct fru_type_length *tl)
98{
99 return fru_length(tl) - 1;
100}
101
102static inline char *fru_strcpy(char *dest, struct fru_type_length *tl)
103{
104 int len = fru_strlen(tl);
105 memcpy(dest, tl->data, len);
106 dest[len] = '\0';
107 return dest;
108}
109
110static inline struct fru_type_length *fru_next_tl(struct fru_type_length *tl)
111{
112 return tl + fru_length(tl);
113}
114
115static inline int fru_is_eof(struct fru_type_length *tl)
116{
117 return tl->type_length == 0xc1;
118}
119
120/*
121 * External functions defined in fru-parse.c.
122 */
123extern int fru_header_cksum_ok(struct fru_common_header *header);
124extern int fru_bia_cksum_ok(struct fru_board_info_area *bia);
125
126/* All these 4 return allocated strings by calling fru_alloc() */
127extern char *fru_get_board_manufacturer(struct fru_common_header *header);
128extern char *fru_get_product_name(struct fru_common_header *header);
129extern char *fru_get_serial_number(struct fru_common_header *header);
130extern char *fru_get_part_number(struct fru_common_header *header);
131
132/* This must be defined by the caller of the above functions */
133extern void *fru_alloc(size_t size);
134
135#endif /* __LINUX_IMPI_FRU_H__ */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e9ef6d6b51d5..3afb969441d1 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -450,6 +450,8 @@ static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)
450extern int hex_to_bin(char ch); 450extern int hex_to_bin(char ch);
451extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); 451extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
452 452
453int mac_pton(const char *s, u8 *mac);
454
453/* 455/*
454 * General tracing related utility functions - trace_printk(), 456 * General tracing related utility functions - trace_printk(),
455 * tracing_on/tracing_off and tracing_start()/tracing_stop 457 * tracing_on/tracing_off and tracing_start()/tracing_stop
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 8f21daf62fb5..9b81b2bdc46b 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -20,6 +20,8 @@
20#include <linux/leds.h> 20#include <linux/leds.h>
21#include <linux/regmap.h> 21#include <linux/regmap.h>
22#include <linux/regulator/driver.h> 22#include <linux/regulator/driver.h>
23#include <linux/extcon.h>
24#include <linux/usb/phy_companion.h>
23 25
24#define PALMAS_NUM_CLIENTS 3 26#define PALMAS_NUM_CLIENTS 3
25 27
@@ -37,6 +39,12 @@ struct palmas_gpadc;
37struct palmas_resource; 39struct palmas_resource;
38struct palmas_usb; 40struct palmas_usb;
39 41
42enum palmas_usb_state {
43 PALMAS_USB_STATE_DISCONNECT,
44 PALMAS_USB_STATE_VBUS,
45 PALMAS_USB_STATE_ID,
46};
47
40struct palmas { 48struct palmas {
41 struct device *dev; 49 struct device *dev;
42 50
@@ -180,9 +188,6 @@ struct palmas_pmic_platform_data {
180}; 188};
181 189
182struct palmas_usb_platform_data { 190struct palmas_usb_platform_data {
183 /* Set this if platform wishes its own vbus control */
184 int no_control_vbus;
185
186 /* Do we enable the wakeup comparator on probe */ 191 /* Do we enable the wakeup comparator on probe */
187 int wakeup; 192 int wakeup;
188}; 193};
@@ -350,22 +355,19 @@ struct palmas_usb {
350 struct palmas *palmas; 355 struct palmas *palmas;
351 struct device *dev; 356 struct device *dev;
352 357
353 /* for vbus reporting with irqs disabled */ 358 struct extcon_dev edev;
354 spinlock_t lock;
355
356 struct regulator *vbus_reg;
357 359
358 /* used to set vbus, in atomic path */ 360 /* used to set vbus, in atomic path */
359 struct work_struct set_vbus_work; 361 struct work_struct set_vbus_work;
360 362
361 int irq1; 363 int id_otg_irq;
362 int irq2; 364 int id_irq;
363 int irq3; 365 int vbus_otg_irq;
364 int irq4; 366 int vbus_irq;
365 367
366 int vbus_enable; 368 int vbus_enable;
367 369
368 u8 linkstat; 370 enum palmas_usb_state linkstat;
369}; 371};
370 372
371#define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator) 373#define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
diff --git a/include/linux/sdb.h b/include/linux/sdb.h
new file mode 100644
index 000000000000..fbb76a46c8a5
--- /dev/null
+++ b/include/linux/sdb.h
@@ -0,0 +1,159 @@
1/*
2 * This is the official version 1.1 of sdb.h
3 */
4#ifndef __SDB_H__
5#define __SDB_H__
6#ifdef __KERNEL__
7#include <linux/types.h>
8#else
9#include <stdint.h>
10#endif
11
12/*
13 * All structures are 64 bytes long and are expected
14 * to live in an array, one for each interconnect.
15 * Most fields of the structures are shared among the
16 * various types, and most-specific fields are at the
17 * beginning (for alignment reasons, and to keep the
18 * magic number at the head of the interconnect record
19 */
20
21/* Product, 40 bytes at offset 24, 8-byte aligned
22 *
23 * device_id is vendor-assigned; version is device-specific,
24 * date is hex (e.g 0x20120501), name is UTF-8, blank-filled
25 * and not terminated with a 0 byte.
26 */
27struct sdb_product {
28 uint64_t vendor_id; /* 0x18..0x1f */
29 uint32_t device_id; /* 0x20..0x23 */
30 uint32_t version; /* 0x24..0x27 */
31 uint32_t date; /* 0x28..0x2b */
32 uint8_t name[19]; /* 0x2c..0x3e */
33 uint8_t record_type; /* 0x3f */
34};
35
36/*
37 * Component, 56 bytes at offset 8, 8-byte aligned
38 *
39 * The address range is first to last, inclusive
40 * (for example 0x100000 - 0x10ffff)
41 */
42struct sdb_component {
43 uint64_t addr_first; /* 0x08..0x0f */
44 uint64_t addr_last; /* 0x10..0x17 */
45 struct sdb_product product; /* 0x18..0x3f */
46};
47
48/* Type of the SDB record */
49enum sdb_record_type {
50 sdb_type_interconnect = 0x00,
51 sdb_type_device = 0x01,
52 sdb_type_bridge = 0x02,
53 sdb_type_integration = 0x80,
54 sdb_type_repo_url = 0x81,
55 sdb_type_synthesis = 0x82,
56 sdb_type_empty = 0xFF,
57};
58
59/* Type 0: interconnect (first of the array)
60 *
61 * sdb_records is the length of the table including this first
62 * record, version is 1. The bus type is enumerated later.
63 */
64#define SDB_MAGIC 0x5344422d /* "SDB-" */
65struct sdb_interconnect {
66 uint32_t sdb_magic; /* 0x00-0x03 */
67 uint16_t sdb_records; /* 0x04-0x05 */
68 uint8_t sdb_version; /* 0x06 */
69 uint8_t sdb_bus_type; /* 0x07 */
70 struct sdb_component sdb_component; /* 0x08-0x3f */
71};
72
73/* Type 1: device
74 *
75 * class is 0 for "custom device", other values are
76 * to be standardized; ABI version is for the driver,
77 * bus-specific bits are defined by each bus (see below)
78 */
79struct sdb_device {
80 uint16_t abi_class; /* 0x00-0x01 */
81 uint8_t abi_ver_major; /* 0x02 */
82 uint8_t abi_ver_minor; /* 0x03 */
83 uint32_t bus_specific; /* 0x04-0x07 */
84 struct sdb_component sdb_component; /* 0x08-0x3f */
85};
86
87/* Type 2: bridge
88 *
89 * child is the address of the nested SDB table
90 */
91struct sdb_bridge {
92 uint64_t sdb_child; /* 0x00-0x07 */
93 struct sdb_component sdb_component; /* 0x08-0x3f */
94};
95
96/* Type 0x80: integration
97 *
98 * all types with bit 7 set are meta-information, so
99 * software can ignore the types it doesn't know. Here we
100 * just provide product information for an aggregate device
101 */
102struct sdb_integration {
103 uint8_t reserved[24]; /* 0x00-0x17 */
104 struct sdb_product product; /* 0x08-0x3f */
105};
106
107/* Type 0x81: Top module repository url
108 *
109 * again, an informative field that software can ignore
110 */
111struct sdb_repo_url {
112 uint8_t repo_url[63]; /* 0x00-0x3e */
113 uint8_t record_type; /* 0x3f */
114};
115
116/* Type 0x82: Synthesis tool information
117 *
118 * this informative record
119 */
120struct sdb_synthesis {
121 uint8_t syn_name[16]; /* 0x00-0x0f */
122 uint8_t commit_id[16]; /* 0x10-0x1f */
123 uint8_t tool_name[8]; /* 0x20-0x27 */
124 uint32_t tool_version; /* 0x28-0x2b */
125 uint32_t date; /* 0x2c-0x2f */
126 uint8_t user_name[15]; /* 0x30-0x3e */
127 uint8_t record_type; /* 0x3f */
128};
129
130/* Type 0xff: empty
131 *
132 * this allows keeping empty slots during development,
133 * so they can be filled later with minimal efforts and
134 * no misleading description is ever shipped -- hopefully.
135 * It can also be used to pad a table to a desired length.
136 */
137struct sdb_empty {
138 uint8_t reserved[63]; /* 0x00-0x3e */
139 uint8_t record_type; /* 0x3f */
140};
141
142/* The type of bus, for bus-specific flags */
143enum sdb_bus_type {
144 sdb_wishbone = 0x00,
145 sdb_data = 0x01,
146};
147
148#define SDB_WB_WIDTH_MASK 0x0f
149#define SDB_WB_ACCESS8 0x01
150#define SDB_WB_ACCESS16 0x02
151#define SDB_WB_ACCESS32 0x04
152#define SDB_WB_ACCESS64 0x08
153#define SDB_WB_LITTLE_ENDIAN 0x80
154
155#define SDB_DATA_READ 0x04
156#define SDB_DATA_WRITE 0x02
157#define SDB_DATA_EXEC 0x01
158
159#endif /* __SDB_H__ */