diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-21 16:57:13 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-21 16:57:13 -0500 |
| commit | 7ed214ac2095f561a94335ca672b6c42a1ea40ff (patch) | |
| tree | da41901bff1d0d8d61170bf362384fdc61deb3ab /include/linux | |
| parent | 21eaab6d19ed43e82ed39c8deb7f192134fb4a0e (diff) | |
| parent | 29e5507ae4ab34397f538f06b7070c81a4e4a2bf (diff) | |
Merge tag 'char-misc-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver patches from Greg Kroah-Hartman:
"Here's the big char/misc driver patches for 3.9-rc1.
Nothing major here, just lots of different driver updates (mei,
hyperv, ipack, extcon, vmci, etc.).
All of these have been in the linux-next tree for a while."
* tag 'char-misc-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (209 commits)
w1: w1_therm: Add force-pullup option for "broken" sensors
w1: ds2482: Added 1-Wire pull-up support to the driver
vme: add missing put_device() after device_register() fails
extcon: max8997: Use workqueue to check cable state after completing boot of platform
extcon: max8997: Set default UART/USB path on probe
extcon: max8997: Consolidate duplicate code for checking ADC/CHG cable type
extcon: max8997: Set default of ADC debounce time during initialization
extcon: max8997: Remove duplicate code related to set H/W line path
extcon: max8997: Move defined constant to header file
extcon: max77693: Make max77693_extcon_cable static
extcon: max8997: Remove unreachable code
extcon: max8997: Make max8997_extcon_cable static
extcon: max77693: Remove unnecessary goto statement to improve readability
extcon: max77693: Convert to devm_input_allocate_device()
extcon: gpio: Rename filename of extcon-gpio.c according to kernel naming style
CREDITS: update email and address of Harald Hoyer
extcon: arizona: Use MICDET for final microphone identification
extcon: arizona: Always take the first HPDET reading as the final one
extcon: arizona: Clear _trig_sts bits after jack detection
extcon: arizona: Don't HPDET magic when headphones are enabled
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/extcon/extcon-gpio.h (renamed from include/linux/extcon/extcon_gpio.h) | 0 | ||||
| -rw-r--r-- | include/linux/hyperv.h | 248 | ||||
| -rw-r--r-- | include/linux/mfd/arizona/core.h | 4 | ||||
| -rw-r--r-- | include/linux/mfd/arizona/pdata.h | 21 | ||||
| -rw-r--r-- | include/linux/mfd/arizona/registers.h | 56 | ||||
| -rw-r--r-- | include/linux/mfd/max77693-private.h | 86 | ||||
| -rw-r--r-- | include/linux/mfd/max77693.h | 9 | ||||
| -rw-r--r-- | include/linux/mfd/max8997-private.h | 64 | ||||
| -rw-r--r-- | include/linux/mfd/max8997.h | 25 | ||||
| -rw-r--r-- | include/linux/ntb.h | 83 | ||||
| -rw-r--r-- | include/linux/vmw_vmci_api.h | 82 | ||||
| -rw-r--r-- | include/linux/vmw_vmci_defs.h | 880 |
12 files changed, 1524 insertions, 34 deletions
diff --git a/include/linux/extcon/extcon_gpio.h b/include/linux/extcon/extcon-gpio.h index 2d8307f7d67d..2d8307f7d67d 100644 --- a/include/linux/extcon/extcon_gpio.h +++ b/include/linux/extcon/extcon-gpio.h | |||
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index e73b852156b1..df77ba9a8166 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h | |||
| @@ -325,14 +325,28 @@ struct hv_ring_buffer { | |||
| 325 | 325 | ||
| 326 | u32 interrupt_mask; | 326 | u32 interrupt_mask; |
| 327 | 327 | ||
| 328 | /* Pad it to PAGE_SIZE so that data starts on page boundary */ | 328 | /* |
| 329 | u8 reserved[4084]; | 329 | * Win8 uses some of the reserved bits to implement |
| 330 | 330 | * interrupt driven flow management. On the send side | |
| 331 | /* NOTE: | 331 | * we can request that the receiver interrupt the sender |
| 332 | * The interrupt_mask field is used only for channels but since our | 332 | * when the ring transitions from being full to being able |
| 333 | * vmbus connection also uses this data structure and its data starts | 333 | * to handle a message of size "pending_send_sz". |
| 334 | * here, we commented out this field. | 334 | * |
| 335 | * Add necessary state for this enhancement. | ||
| 335 | */ | 336 | */ |
| 337 | u32 pending_send_sz; | ||
| 338 | |||
| 339 | u32 reserved1[12]; | ||
| 340 | |||
| 341 | union { | ||
| 342 | struct { | ||
| 343 | u32 feat_pending_send_sz:1; | ||
| 344 | }; | ||
| 345 | u32 value; | ||
| 346 | } feature_bits; | ||
| 347 | |||
| 348 | /* Pad it to PAGE_SIZE so that data starts on page boundary */ | ||
| 349 | u8 reserved2[4028]; | ||
| 336 | 350 | ||
| 337 | /* | 351 | /* |
| 338 | * Ring data starts here + RingDataStartOffset | 352 | * Ring data starts here + RingDataStartOffset |
| @@ -405,12 +419,22 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi, | |||
| 405 | */ | 419 | */ |
| 406 | #define HV_DRV_VERSION "3.1" | 420 | #define HV_DRV_VERSION "3.1" |
| 407 | 421 | ||
| 408 | |||
| 409 | /* | 422 | /* |
| 410 | * A revision number of vmbus that is used for ensuring both ends on a | 423 | * VMBUS version is 32 bit entity broken up into |
| 411 | * partition are using compatible versions. | 424 | * two 16 bit quantities: major_number. minor_number. |
| 425 | * | ||
| 426 | * 0 . 13 (Windows Server 2008) | ||
| 427 | * 1 . 1 (Windows 7) | ||
| 428 | * 2 . 4 (Windows 8) | ||
| 412 | */ | 429 | */ |
| 413 | #define VMBUS_REVISION_NUMBER 13 | 430 | |
| 431 | #define VERSION_WS2008 ((0 << 16) | (13)) | ||
| 432 | #define VERSION_WIN7 ((1 << 16) | (1)) | ||
| 433 | #define VERSION_WIN8 ((2 << 16) | (4)) | ||
| 434 | |||
| 435 | #define VERSION_INVAL -1 | ||
| 436 | |||
| 437 | #define VERSION_CURRENT VERSION_WIN8 | ||
| 414 | 438 | ||
| 415 | /* Make maximum size of pipe payload of 16K */ | 439 | /* Make maximum size of pipe payload of 16K */ |
| 416 | #define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384) | 440 | #define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384) |
| @@ -432,9 +456,13 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi, | |||
| 432 | struct vmbus_channel_offer { | 456 | struct vmbus_channel_offer { |
| 433 | uuid_le if_type; | 457 | uuid_le if_type; |
| 434 | uuid_le if_instance; | 458 | uuid_le if_instance; |
| 435 | u64 int_latency; /* in 100ns units */ | 459 | |
| 436 | u32 if_revision; | 460 | /* |
| 437 | u32 server_ctx_size; /* in bytes */ | 461 | * These two fields are not currently used. |
| 462 | */ | ||
| 463 | u64 reserved1; | ||
| 464 | u64 reserved2; | ||
| 465 | |||
| 438 | u16 chn_flags; | 466 | u16 chn_flags; |
| 439 | u16 mmio_megabytes; /* in bytes * 1024 * 1024 */ | 467 | u16 mmio_megabytes; /* in bytes * 1024 * 1024 */ |
| 440 | 468 | ||
| @@ -456,7 +484,11 @@ struct vmbus_channel_offer { | |||
| 456 | unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES]; | 484 | unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES]; |
| 457 | } pipe; | 485 | } pipe; |
| 458 | } u; | 486 | } u; |
| 459 | u32 padding; | 487 | /* |
| 488 | * The sub_channel_index is defined in win8. | ||
| 489 | */ | ||
| 490 | u16 sub_channel_index; | ||
| 491 | u16 reserved3; | ||
| 460 | } __packed; | 492 | } __packed; |
| 461 | 493 | ||
| 462 | /* Server Flags */ | 494 | /* Server Flags */ |
| @@ -652,7 +684,25 @@ struct vmbus_channel_offer_channel { | |||
| 652 | struct vmbus_channel_offer offer; | 684 | struct vmbus_channel_offer offer; |
| 653 | u32 child_relid; | 685 | u32 child_relid; |
| 654 | u8 monitorid; | 686 | u8 monitorid; |
| 655 | u8 monitor_allocated; | 687 | /* |
| 688 | * win7 and beyond splits this field into a bit field. | ||
| 689 | */ | ||
| 690 | u8 monitor_allocated:1; | ||
| 691 | u8 reserved:7; | ||
| 692 | /* | ||
| 693 | * These are new fields added in win7 and later. | ||
| 694 | * Do not access these fields without checking the | ||
| 695 | * negotiated protocol. | ||
| 696 | * | ||
| 697 | * If "is_dedicated_interrupt" is set, we must not set the | ||
| 698 | * associated bit in the channel bitmap while sending the | ||
| 699 | * interrupt to the host. | ||
| 700 | * | ||
| 701 | * connection_id is to be used in signaling the host. | ||
| 702 | */ | ||
| 703 | u16 is_dedicated_interrupt:1; | ||
| 704 | u16 reserved1:15; | ||
| 705 | u32 connection_id; | ||
| 656 | } __packed; | 706 | } __packed; |
| 657 | 707 | ||
| 658 | /* Rescind Offer parameters */ | 708 | /* Rescind Offer parameters */ |
| @@ -683,8 +733,15 @@ struct vmbus_channel_open_channel { | |||
| 683 | /* GPADL for the channel's ring buffer. */ | 733 | /* GPADL for the channel's ring buffer. */ |
| 684 | u32 ringbuffer_gpadlhandle; | 734 | u32 ringbuffer_gpadlhandle; |
| 685 | 735 | ||
| 686 | /* GPADL for the channel's server context save area. */ | 736 | /* |
| 687 | u32 server_contextarea_gpadlhandle; | 737 | * Starting with win8, this field will be used to specify |
| 738 | * the target virtual processor on which to deliver the interrupt for | ||
| 739 | * the host to guest communication. | ||
| 740 | * Prior to win8, incoming channel interrupts would only | ||
| 741 | * be delivered on cpu 0. Setting this value to 0 would | ||
| 742 | * preserve the earlier behavior. | ||
| 743 | */ | ||
| 744 | u32 target_vp; | ||
| 688 | 745 | ||
| 689 | /* | 746 | /* |
| 690 | * The upstream ring buffer begins at offset zero in the memory | 747 | * The upstream ring buffer begins at offset zero in the memory |
| @@ -848,6 +905,27 @@ struct vmbus_close_msg { | |||
| 848 | struct vmbus_channel_close_channel msg; | 905 | struct vmbus_channel_close_channel msg; |
| 849 | }; | 906 | }; |
| 850 | 907 | ||
| 908 | /* Define connection identifier type. */ | ||
| 909 | union hv_connection_id { | ||
| 910 | u32 asu32; | ||
| 911 | struct { | ||
| 912 | u32 id:24; | ||
| 913 | u32 reserved:8; | ||
| 914 | } u; | ||
| 915 | }; | ||
| 916 | |||
| 917 | /* Definition of the hv_signal_event hypercall input structure. */ | ||
| 918 | struct hv_input_signal_event { | ||
| 919 | union hv_connection_id connectionid; | ||
| 920 | u16 flag_number; | ||
| 921 | u16 rsvdz; | ||
| 922 | }; | ||
| 923 | |||
| 924 | struct hv_input_signal_event_buffer { | ||
| 925 | u64 align8; | ||
| 926 | struct hv_input_signal_event event; | ||
| 927 | }; | ||
| 928 | |||
| 851 | struct vmbus_channel { | 929 | struct vmbus_channel { |
| 852 | struct list_head listentry; | 930 | struct list_head listentry; |
| 853 | 931 | ||
| @@ -882,8 +960,42 @@ struct vmbus_channel { | |||
| 882 | 960 | ||
| 883 | void (*onchannel_callback)(void *context); | 961 | void (*onchannel_callback)(void *context); |
| 884 | void *channel_callback_context; | 962 | void *channel_callback_context; |
| 963 | |||
| 964 | /* | ||
| 965 | * A channel can be marked for efficient (batched) | ||
| 966 | * reading: | ||
| 967 | * If batched_reading is set to "true", we read until the | ||
| 968 | * channel is empty and hold off interrupts from the host | ||
| 969 | * during the entire read process. | ||
| 970 | * If batched_reading is set to "false", the client is not | ||
| 971 | * going to perform batched reading. | ||
| 972 | * | ||
| 973 | * By default we will enable batched reading; specific | ||
| 974 | * drivers that don't want this behavior can turn it off. | ||
| 975 | */ | ||
| 976 | |||
| 977 | bool batched_reading; | ||
| 978 | |||
| 979 | bool is_dedicated_interrupt; | ||
| 980 | struct hv_input_signal_event_buffer sig_buf; | ||
| 981 | struct hv_input_signal_event *sig_event; | ||
| 982 | |||
| 983 | /* | ||
| 984 | * Starting with win8, this field will be used to specify | ||
| 985 | * the target virtual processor on which to deliver the interrupt for | ||
| 986 | * the host to guest communication. | ||
| 987 | * Prior to win8, incoming channel interrupts would only | ||
| 988 | * be delivered on cpu 0. Setting this value to 0 would | ||
| 989 | * preserve the earlier behavior. | ||
| 990 | */ | ||
| 991 | u32 target_vp; | ||
| 885 | }; | 992 | }; |
| 886 | 993 | ||
| 994 | static inline void set_channel_read_state(struct vmbus_channel *c, bool state) | ||
| 995 | { | ||
| 996 | c->batched_reading = state; | ||
| 997 | } | ||
| 998 | |||
| 887 | void vmbus_onmessage(void *context); | 999 | void vmbus_onmessage(void *context); |
| 888 | 1000 | ||
| 889 | int vmbus_request_offers(void); | 1001 | int vmbus_request_offers(void); |
| @@ -1047,6 +1159,100 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver); | |||
| 1047 | g8, g9, ga, gb, gc, gd, ge, gf }, | 1159 | g8, g9, ga, gb, gc, gd, ge, gf }, |
| 1048 | 1160 | ||
| 1049 | /* | 1161 | /* |
| 1162 | * GUID definitions of various offer types - services offered to the guest. | ||
| 1163 | */ | ||
| 1164 | |||
| 1165 | /* | ||
| 1166 | * Network GUID | ||
| 1167 | * {f8615163-df3e-46c5-913f-f2d2f965ed0e} | ||
| 1168 | */ | ||
| 1169 | #define HV_NIC_GUID \ | ||
| 1170 | .guid = { \ | ||
| 1171 | 0x63, 0x51, 0x61, 0xf8, 0x3e, 0xdf, 0xc5, 0x46, \ | ||
| 1172 | 0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e \ | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | /* | ||
| 1176 | * IDE GUID | ||
| 1177 | * {32412632-86cb-44a2-9b5c-50d1417354f5} | ||
| 1178 | */ | ||
| 1179 | #define HV_IDE_GUID \ | ||
| 1180 | .guid = { \ | ||
| 1181 | 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, \ | ||
| 1182 | 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5 \ | ||
| 1183 | } | ||
| 1184 | |||
| 1185 | /* | ||
| 1186 | * SCSI GUID | ||
| 1187 | * {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} | ||
| 1188 | */ | ||
| 1189 | #define HV_SCSI_GUID \ | ||
| 1190 | .guid = { \ | ||
| 1191 | 0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, \ | ||
| 1192 | 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f \ | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | /* | ||
| 1196 | * Shutdown GUID | ||
| 1197 | * {0e0b6031-5213-4934-818b-38d90ced39db} | ||
| 1198 | */ | ||
| 1199 | #define HV_SHUTDOWN_GUID \ | ||
| 1200 | .guid = { \ | ||
| 1201 | 0x31, 0x60, 0x0b, 0x0e, 0x13, 0x52, 0x34, 0x49, \ | ||
| 1202 | 0x81, 0x8b, 0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb \ | ||
| 1203 | } | ||
| 1204 | |||
| 1205 | /* | ||
| 1206 | * Time Synch GUID | ||
| 1207 | * {9527E630-D0AE-497b-ADCE-E80AB0175CAF} | ||
| 1208 | */ | ||
| 1209 | #define HV_TS_GUID \ | ||
| 1210 | .guid = { \ | ||
| 1211 | 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, \ | ||
| 1212 | 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf \ | ||
| 1213 | } | ||
| 1214 | |||
| 1215 | /* | ||
| 1216 | * Heartbeat GUID | ||
| 1217 | * {57164f39-9115-4e78-ab55-382f3bd5422d} | ||
| 1218 | */ | ||
| 1219 | #define HV_HEART_BEAT_GUID \ | ||
| 1220 | .guid = { \ | ||
| 1221 | 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, \ | ||
| 1222 | 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d \ | ||
| 1223 | } | ||
| 1224 | |||
| 1225 | /* | ||
| 1226 | * KVP GUID | ||
| 1227 | * {a9a0f4e7-5a45-4d96-b827-8a841e8c03e6} | ||
| 1228 | */ | ||
| 1229 | #define HV_KVP_GUID \ | ||
| 1230 | .guid = { \ | ||
| 1231 | 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, \ | ||
| 1232 | 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6 \ | ||
| 1233 | } | ||
| 1234 | |||
| 1235 | /* | ||
| 1236 | * Dynamic memory GUID | ||
| 1237 | * {525074dc-8985-46e2-8057-a307dc18a502} | ||
| 1238 | */ | ||
| 1239 | #define HV_DM_GUID \ | ||
| 1240 | .guid = { \ | ||
| 1241 | 0xdc, 0x74, 0x50, 0X52, 0x85, 0x89, 0xe2, 0x46, \ | ||
| 1242 | 0x80, 0x57, 0xa3, 0x07, 0xdc, 0x18, 0xa5, 0x02 \ | ||
| 1243 | } | ||
| 1244 | |||
| 1245 | /* | ||
| 1246 | * Mouse GUID | ||
| 1247 | * {cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a} | ||
| 1248 | */ | ||
| 1249 | #define HV_MOUSE_GUID \ | ||
| 1250 | .guid = { \ | ||
| 1251 | 0x9e, 0xb6, 0xa8, 0xcf, 0x4a, 0x5b, 0xc0, 0x4c, \ | ||
| 1252 | 0xb9, 0x8b, 0x8b, 0xa1, 0xa1, 0xf3, 0xf9, 0x5a \ | ||
| 1253 | } | ||
| 1254 | |||
| 1255 | /* | ||
| 1050 | * Common header for Hyper-V ICs | 1256 | * Common header for Hyper-V ICs |
| 1051 | */ | 1257 | */ |
| 1052 | 1258 | ||
| @@ -1150,5 +1356,11 @@ int hv_kvp_init(struct hv_util_service *); | |||
| 1150 | void hv_kvp_deinit(void); | 1356 | void hv_kvp_deinit(void); |
| 1151 | void hv_kvp_onchannelcallback(void *); | 1357 | void hv_kvp_onchannelcallback(void *); |
| 1152 | 1358 | ||
| 1359 | /* | ||
| 1360 | * Negotiated version with the Host. | ||
| 1361 | */ | ||
| 1362 | |||
| 1363 | extern __u32 vmbus_proto_version; | ||
| 1364 | |||
| 1153 | #endif /* __KERNEL__ */ | 1365 | #endif /* __KERNEL__ */ |
| 1154 | #endif /* _HYPERV_H */ | 1366 | #endif /* _HYPERV_H */ |
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h index a580363a7d29..a710255528d7 100644 --- a/include/linux/mfd/arizona/core.h +++ b/include/linux/mfd/arizona/core.h | |||
| @@ -75,8 +75,10 @@ enum arizona_type { | |||
| 75 | #define ARIZONA_IRQ_DCS_HP_DONE 47 | 75 | #define ARIZONA_IRQ_DCS_HP_DONE 47 |
| 76 | #define ARIZONA_IRQ_FLL2_CLOCK_OK 48 | 76 | #define ARIZONA_IRQ_FLL2_CLOCK_OK 48 |
| 77 | #define ARIZONA_IRQ_FLL1_CLOCK_OK 49 | 77 | #define ARIZONA_IRQ_FLL1_CLOCK_OK 49 |
| 78 | #define ARIZONA_IRQ_MICD_CLAMP_RISE 50 | ||
| 79 | #define ARIZONA_IRQ_MICD_CLAMP_FALL 51 | ||
| 78 | 80 | ||
| 79 | #define ARIZONA_NUM_IRQ 50 | 81 | #define ARIZONA_NUM_IRQ 52 |
| 80 | 82 | ||
| 81 | struct snd_soc_dapm_context; | 83 | struct snd_soc_dapm_context; |
| 82 | 84 | ||
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h index ec3e2a2a6d77..96d64f2b8d78 100644 --- a/include/linux/mfd/arizona/pdata.h +++ b/include/linux/mfd/arizona/pdata.h | |||
| @@ -105,9 +105,30 @@ struct arizona_pdata { | |||
| 105 | */ | 105 | */ |
| 106 | int max_channels_clocked[ARIZONA_MAX_AIF]; | 106 | int max_channels_clocked[ARIZONA_MAX_AIF]; |
| 107 | 107 | ||
| 108 | /** GPIO5 is used for jack detection */ | ||
| 109 | bool jd_gpio5; | ||
| 110 | |||
| 111 | /** Use the headphone detect circuit to identify the accessory */ | ||
| 112 | bool hpdet_acc_id; | ||
| 113 | |||
| 114 | /** GPIO used for mic isolation with HPDET */ | ||
| 115 | int hpdet_id_gpio; | ||
| 116 | |||
| 108 | /** GPIO for mic detection polarity */ | 117 | /** GPIO for mic detection polarity */ |
| 109 | int micd_pol_gpio; | 118 | int micd_pol_gpio; |
| 110 | 119 | ||
| 120 | /** Mic detect ramp rate */ | ||
| 121 | int micd_bias_start_time; | ||
| 122 | |||
| 123 | /** Mic detect sample rate */ | ||
| 124 | int micd_rate; | ||
| 125 | |||
| 126 | /** Mic detect debounce level */ | ||
| 127 | int micd_dbtime; | ||
| 128 | |||
| 129 | /** Force MICBIAS on for mic detect */ | ||
| 130 | bool micd_force_micbias; | ||
| 131 | |||
| 111 | /** Headset polarity configurations */ | 132 | /** Headset polarity configurations */ |
| 112 | struct arizona_micd_config *micd_configs; | 133 | struct arizona_micd_config *micd_configs; |
| 113 | int num_micd_configs; | 134 | int num_micd_configs; |
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h index 1f6fe31a4d5c..188d89abd963 100644 --- a/include/linux/mfd/arizona/registers.h +++ b/include/linux/mfd/arizona/registers.h | |||
| @@ -119,6 +119,8 @@ | |||
| 119 | #define ARIZONA_ACCESSORY_DETECT_MODE_1 0x293 | 119 | #define ARIZONA_ACCESSORY_DETECT_MODE_1 0x293 |
| 120 | #define ARIZONA_HEADPHONE_DETECT_1 0x29B | 120 | #define ARIZONA_HEADPHONE_DETECT_1 0x29B |
| 121 | #define ARIZONA_HEADPHONE_DETECT_2 0x29C | 121 | #define ARIZONA_HEADPHONE_DETECT_2 0x29C |
| 122 | #define ARIZONA_HP_DACVAL 0x29F | ||
| 123 | #define ARIZONA_MICD_CLAMP_CONTROL 0x2A2 | ||
| 122 | #define ARIZONA_MIC_DETECT_1 0x2A3 | 124 | #define ARIZONA_MIC_DETECT_1 0x2A3 |
| 123 | #define ARIZONA_MIC_DETECT_2 0x2A4 | 125 | #define ARIZONA_MIC_DETECT_2 0x2A4 |
| 124 | #define ARIZONA_MIC_DETECT_3 0x2A5 | 126 | #define ARIZONA_MIC_DETECT_3 0x2A5 |
| @@ -1194,6 +1196,14 @@ | |||
| 1194 | /* | 1196 | /* |
| 1195 | * R64 (0x40) - Wake control | 1197 | * R64 (0x40) - Wake control |
| 1196 | */ | 1198 | */ |
| 1199 | #define ARIZONA_WKUP_MICD_CLAMP_FALL 0x0080 /* WKUP_MICD_CLAMP_FALL */ | ||
| 1200 | #define ARIZONA_WKUP_MICD_CLAMP_FALL_MASK 0x0080 /* WKUP_MICD_CLAMP_FALL */ | ||
| 1201 | #define ARIZONA_WKUP_MICD_CLAMP_FALL_SHIFT 7 /* WKUP_MICD_CLAMP_FALL */ | ||
| 1202 | #define ARIZONA_WKUP_MICD_CLAMP_FALL_WIDTH 1 /* WKUP_MICD_CLAMP_FALL */ | ||
| 1203 | #define ARIZONA_WKUP_MICD_CLAMP_RISE 0x0040 /* WKUP_MICD_CLAMP_RISE */ | ||
| 1204 | #define ARIZONA_WKUP_MICD_CLAMP_RISE_MASK 0x0040 /* WKUP_MICD_CLAMP_RISE */ | ||
| 1205 | #define ARIZONA_WKUP_MICD_CLAMP_RISE_SHIFT 6 /* WKUP_MICD_CLAMP_RISE */ | ||
| 1206 | #define ARIZONA_WKUP_MICD_CLAMP_RISE_WIDTH 1 /* WKUP_MICD_CLAMP_RISE */ | ||
| 1197 | #define ARIZONA_WKUP_GP5_FALL 0x0020 /* WKUP_GP5_FALL */ | 1207 | #define ARIZONA_WKUP_GP5_FALL 0x0020 /* WKUP_GP5_FALL */ |
| 1198 | #define ARIZONA_WKUP_GP5_FALL_MASK 0x0020 /* WKUP_GP5_FALL */ | 1208 | #define ARIZONA_WKUP_GP5_FALL_MASK 0x0020 /* WKUP_GP5_FALL */ |
| 1199 | #define ARIZONA_WKUP_GP5_FALL_SHIFT 5 /* WKUP_GP5_FALL */ | 1209 | #define ARIZONA_WKUP_GP5_FALL_SHIFT 5 /* WKUP_GP5_FALL */ |
| @@ -2035,6 +2045,9 @@ | |||
| 2035 | /* | 2045 | /* |
| 2036 | * R667 (0x29B) - Headphone Detect 1 | 2046 | * R667 (0x29B) - Headphone Detect 1 |
| 2037 | */ | 2047 | */ |
| 2048 | #define ARIZONA_HP_IMPEDANCE_RANGE_MASK 0x0600 /* HP_IMPEDANCE_RANGE - [10:9] */ | ||
| 2049 | #define ARIZONA_HP_IMPEDANCE_RANGE_SHIFT 9 /* HP_IMPEDANCE_RANGE - [10:9] */ | ||
| 2050 | #define ARIZONA_HP_IMPEDANCE_RANGE_WIDTH 2 /* HP_IMPEDANCE_RANGE - [10:9] */ | ||
| 2038 | #define ARIZONA_HP_STEP_SIZE 0x0100 /* HP_STEP_SIZE */ | 2051 | #define ARIZONA_HP_STEP_SIZE 0x0100 /* HP_STEP_SIZE */ |
| 2039 | #define ARIZONA_HP_STEP_SIZE_MASK 0x0100 /* HP_STEP_SIZE */ | 2052 | #define ARIZONA_HP_STEP_SIZE_MASK 0x0100 /* HP_STEP_SIZE */ |
| 2040 | #define ARIZONA_HP_STEP_SIZE_SHIFT 8 /* HP_STEP_SIZE */ | 2053 | #define ARIZONA_HP_STEP_SIZE_SHIFT 8 /* HP_STEP_SIZE */ |
| @@ -2069,6 +2082,21 @@ | |||
| 2069 | #define ARIZONA_HP_LVL_SHIFT 0 /* HP_LVL - [6:0] */ | 2082 | #define ARIZONA_HP_LVL_SHIFT 0 /* HP_LVL - [6:0] */ |
| 2070 | #define ARIZONA_HP_LVL_WIDTH 7 /* HP_LVL - [6:0] */ | 2083 | #define ARIZONA_HP_LVL_WIDTH 7 /* HP_LVL - [6:0] */ |
| 2071 | 2084 | ||
| 2085 | #define ARIZONA_HP_DONE_B 0x8000 /* HP_DONE */ | ||
| 2086 | #define ARIZONA_HP_DONE_B_MASK 0x8000 /* HP_DONE */ | ||
| 2087 | #define ARIZONA_HP_DONE_B_SHIFT 15 /* HP_DONE */ | ||
| 2088 | #define ARIZONA_HP_DONE_B_WIDTH 1 /* HP_DONE */ | ||
| 2089 | #define ARIZONA_HP_LVL_B_MASK 0x7FFF /* HP_LVL - [14:0] */ | ||
| 2090 | #define ARIZONA_HP_LVL_B_SHIFT 0 /* HP_LVL - [14:0] */ | ||
| 2091 | #define ARIZONA_HP_LVL_B_WIDTH 15 /* HP_LVL - [14:0] */ | ||
| 2092 | |||
| 2093 | /* | ||
| 2094 | * R674 (0x2A2) - MICD clamp control | ||
| 2095 | */ | ||
| 2096 | #define ARIZONA_MICD_CLAMP_MODE_MASK 0x000F /* MICD_CLAMP_MODE - [3:0] */ | ||
| 2097 | #define ARIZONA_MICD_CLAMP_MODE_SHIFT 0 /* MICD_CLAMP_MODE - [3:0] */ | ||
| 2098 | #define ARIZONA_MICD_CLAMP_MODE_WIDTH 4 /* MICD_CLAMP_MODE - [3:0] */ | ||
| 2099 | |||
| 2072 | /* | 2100 | /* |
| 2073 | * R675 (0x2A3) - Mic Detect 1 | 2101 | * R675 (0x2A3) - Mic Detect 1 |
| 2074 | */ | 2102 | */ |
| @@ -5239,6 +5267,14 @@ | |||
| 5239 | /* | 5267 | /* |
| 5240 | * R3408 (0xD50) - AOD wkup and trig | 5268 | * R3408 (0xD50) - AOD wkup and trig |
| 5241 | */ | 5269 | */ |
| 5270 | #define ARIZONA_MICD_CLAMP_FALL_TRIG_STS 0x0080 /* MICD_CLAMP_FALL_TRIG_STS */ | ||
| 5271 | #define ARIZONA_MICD_CLAMP_FALL_TRIG_STS_MASK 0x0080 /* MICD_CLAMP_FALL_TRIG_STS */ | ||
| 5272 | #define ARIZONA_MICD_CLAMP_FALL_TRIG_STS_SHIFT 7 /* MICD_CLAMP_FALL_TRIG_STS */ | ||
| 5273 | #define ARIZONA_MICD_CLAMP_FALL_TRIG_STS_WIDTH 1 /* MICD_CLAMP_FALL_TRIG_STS */ | ||
| 5274 | #define ARIZONA_MICD_CLAMP_RISE_TRIG_STS 0x0040 /* MICD_CLAMP_RISE_TRIG_STS */ | ||
| 5275 | #define ARIZONA_MICD_CLAMP_RISE_TRIG_STS_MASK 0x0040 /* MICD_CLAMP_RISE_TRIG_STS */ | ||
| 5276 | #define ARIZONA_MICD_CLAMP_RISE_TRIG_STS_SHIFT 6 /* MICD_CLAMP_RISE_TRIG_STS */ | ||
| 5277 | #define ARIZONA_MICD_CLAMP_RISE_TRIG_STS_WIDTH 1 /* MICD_CLAMP_RISE_TRIG_STS */ | ||
| 5242 | #define ARIZONA_GP5_FALL_TRIG_STS 0x0020 /* GP5_FALL_TRIG_STS */ | 5278 | #define ARIZONA_GP5_FALL_TRIG_STS 0x0020 /* GP5_FALL_TRIG_STS */ |
| 5243 | #define ARIZONA_GP5_FALL_TRIG_STS_MASK 0x0020 /* GP5_FALL_TRIG_STS */ | 5279 | #define ARIZONA_GP5_FALL_TRIG_STS_MASK 0x0020 /* GP5_FALL_TRIG_STS */ |
| 5244 | #define ARIZONA_GP5_FALL_TRIG_STS_SHIFT 5 /* GP5_FALL_TRIG_STS */ | 5280 | #define ARIZONA_GP5_FALL_TRIG_STS_SHIFT 5 /* GP5_FALL_TRIG_STS */ |
| @@ -5267,6 +5303,12 @@ | |||
| 5267 | /* | 5303 | /* |
| 5268 | * R3409 (0xD51) - AOD IRQ1 | 5304 | * R3409 (0xD51) - AOD IRQ1 |
| 5269 | */ | 5305 | */ |
| 5306 | #define ARIZONA_MICD_CLAMP_FALL_EINT1 0x0080 /* MICD_CLAMP_FALL_EINT1 */ | ||
| 5307 | #define ARIZONA_MICD_CLAMP_FALL_EINT1_MASK 0x0080 /* MICD_CLAMP_FALL_EINT1 */ | ||
| 5308 | #define ARIZONA_MICD_CLAMP_FALL_EINT1_SHIFT 7 /* MICD_CLAMP_FALL_EINT1 */ | ||
| 5309 | #define ARIZONA_MICD_CLAMP_RISE_EINT1 0x0040 /* MICD_CLAMP_RISE_EINT1 */ | ||
| 5310 | #define ARIZONA_MICD_CLAMP_RISE_EINT1_MASK 0x0040 /* MICD_CLAMP_RISE_EINT1 */ | ||
| 5311 | #define ARIZONA_MICD_CLAMP_RISE_EINT1_SHIFT 6 /* MICD_CLAMP_RISE_EINT1 */ | ||
| 5270 | #define ARIZONA_GP5_FALL_EINT1 0x0020 /* GP5_FALL_EINT1 */ | 5312 | #define ARIZONA_GP5_FALL_EINT1 0x0020 /* GP5_FALL_EINT1 */ |
| 5271 | #define ARIZONA_GP5_FALL_EINT1_MASK 0x0020 /* GP5_FALL_EINT1 */ | 5313 | #define ARIZONA_GP5_FALL_EINT1_MASK 0x0020 /* GP5_FALL_EINT1 */ |
| 5272 | #define ARIZONA_GP5_FALL_EINT1_SHIFT 5 /* GP5_FALL_EINT1 */ | 5314 | #define ARIZONA_GP5_FALL_EINT1_SHIFT 5 /* GP5_FALL_EINT1 */ |
| @@ -5295,6 +5337,12 @@ | |||
| 5295 | /* | 5337 | /* |
| 5296 | * R3410 (0xD52) - AOD IRQ2 | 5338 | * R3410 (0xD52) - AOD IRQ2 |
| 5297 | */ | 5339 | */ |
| 5340 | #define ARIZONA_MICD_CLAMP_FALL_EINT2 0x0080 /* MICD_CLAMP_FALL_EINT2 */ | ||
| 5341 | #define ARIZONA_MICD_CLAMP_FALL_EINT2_MASK 0x0080 /* MICD_CLAMP_FALL_EINT2 */ | ||
| 5342 | #define ARIZONA_MICD_CLAMP_FALL_EINT2_SHIFT 7 /* MICD_CLAMP_FALL_EINT2 */ | ||
| 5343 | #define ARIZONA_MICD_CLAMP_RISE_EINT2 0x0040 /* MICD_CLAMP_RISE_EINT2 */ | ||
| 5344 | #define ARIZONA_MICD_CLAMP_RISE_EINT2_MASK 0x0040 /* MICD_CLAMP_RISE_EINT2 */ | ||
| 5345 | #define ARIZONA_MICD_CLAMP_RISE_EINT2_SHIFT 6 /* MICD_CLAMP_RISE_EINT2 */ | ||
| 5298 | #define ARIZONA_GP5_FALL_EINT2 0x0020 /* GP5_FALL_EINT2 */ | 5346 | #define ARIZONA_GP5_FALL_EINT2 0x0020 /* GP5_FALL_EINT2 */ |
| 5299 | #define ARIZONA_GP5_FALL_EINT2_MASK 0x0020 /* GP5_FALL_EINT2 */ | 5347 | #define ARIZONA_GP5_FALL_EINT2_MASK 0x0020 /* GP5_FALL_EINT2 */ |
| 5300 | #define ARIZONA_GP5_FALL_EINT2_SHIFT 5 /* GP5_FALL_EINT2 */ | 5348 | #define ARIZONA_GP5_FALL_EINT2_SHIFT 5 /* GP5_FALL_EINT2 */ |
| @@ -5379,6 +5427,10 @@ | |||
| 5379 | /* | 5427 | /* |
| 5380 | * R3413 (0xD55) - AOD IRQ Raw Status | 5428 | * R3413 (0xD55) - AOD IRQ Raw Status |
| 5381 | */ | 5429 | */ |
| 5430 | #define ARIZONA_MICD_CLAMP_STS 0x0008 /* MICD_CLAMP_STS */ | ||
| 5431 | #define ARIZONA_MICD_CLAMP_STS_MASK 0x0008 /* MICD_CLAMP_STS */ | ||
| 5432 | #define ARIZONA_MICD_CLAMP_STS_SHIFT 3 /* MICD_CLAMP_STS */ | ||
| 5433 | #define ARIZONA_MICD_CLAMP_STS_WIDTH 1 /* MICD_CLAMP_STS */ | ||
| 5382 | #define ARIZONA_GP5_STS 0x0004 /* GP5_STS */ | 5434 | #define ARIZONA_GP5_STS 0x0004 /* GP5_STS */ |
| 5383 | #define ARIZONA_GP5_STS_MASK 0x0004 /* GP5_STS */ | 5435 | #define ARIZONA_GP5_STS_MASK 0x0004 /* GP5_STS */ |
| 5384 | #define ARIZONA_GP5_STS_SHIFT 2 /* GP5_STS */ | 5436 | #define ARIZONA_GP5_STS_SHIFT 2 /* GP5_STS */ |
| @@ -5395,6 +5447,10 @@ | |||
| 5395 | /* | 5447 | /* |
| 5396 | * R3414 (0xD56) - Jack detect debounce | 5448 | * R3414 (0xD56) - Jack detect debounce |
| 5397 | */ | 5449 | */ |
| 5450 | #define ARIZONA_MICD_CLAMP_DB 0x0008 /* MICD_CLAMP_DB */ | ||
| 5451 | #define ARIZONA_MICD_CLAMP_DB_MASK 0x0008 /* MICD_CLAMP_DB */ | ||
| 5452 | #define ARIZONA_MICD_CLAMP_DB_SHIFT 3 /* MICD_CLAMP_DB */ | ||
| 5453 | #define ARIZONA_MICD_CLAMP_DB_WIDTH 1 /* MICD_CLAMP_DB */ | ||
| 5398 | #define ARIZONA_JD2_DB 0x0002 /* JD2_DB */ | 5454 | #define ARIZONA_JD2_DB 0x0002 /* JD2_DB */ |
| 5399 | #define ARIZONA_JD2_DB_MASK 0x0002 /* JD2_DB */ | 5455 | #define ARIZONA_JD2_DB_MASK 0x0002 /* JD2_DB */ |
| 5400 | #define ARIZONA_JD2_DB_SHIFT 1 /* JD2_DB */ | 5456 | #define ARIZONA_JD2_DB_SHIFT 1 /* JD2_DB */ |
diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h index 1eeae5c07915..5b18ecde69b5 100644 --- a/include/linux/mfd/max77693-private.h +++ b/include/linux/mfd/max77693-private.h | |||
| @@ -106,6 +106,92 @@ enum max77693_muic_reg { | |||
| 106 | MAX77693_MUIC_REG_END, | 106 | MAX77693_MUIC_REG_END, |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | /* MAX77693 MUIC - STATUS1~3 Register */ | ||
| 110 | #define STATUS1_ADC_SHIFT (0) | ||
| 111 | #define STATUS1_ADCLOW_SHIFT (5) | ||
| 112 | #define STATUS1_ADCERR_SHIFT (6) | ||
| 113 | #define STATUS1_ADC1K_SHIFT (7) | ||
| 114 | #define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT) | ||
| 115 | #define STATUS1_ADCLOW_MASK (0x1 << STATUS1_ADCLOW_SHIFT) | ||
| 116 | #define STATUS1_ADCERR_MASK (0x1 << STATUS1_ADCERR_SHIFT) | ||
| 117 | #define STATUS1_ADC1K_MASK (0x1 << STATUS1_ADC1K_SHIFT) | ||
| 118 | |||
| 119 | #define STATUS2_CHGTYP_SHIFT (0) | ||
| 120 | #define STATUS2_CHGDETRUN_SHIFT (3) | ||
| 121 | #define STATUS2_DCDTMR_SHIFT (4) | ||
| 122 | #define STATUS2_DXOVP_SHIFT (5) | ||
| 123 | #define STATUS2_VBVOLT_SHIFT (6) | ||
| 124 | #define STATUS2_VIDRM_SHIFT (7) | ||
| 125 | #define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT) | ||
| 126 | #define STATUS2_CHGDETRUN_MASK (0x1 << STATUS2_CHGDETRUN_SHIFT) | ||
| 127 | #define STATUS2_DCDTMR_MASK (0x1 << STATUS2_DCDTMR_SHIFT) | ||
| 128 | #define STATUS2_DXOVP_MASK (0x1 << STATUS2_DXOVP_SHIFT) | ||
| 129 | #define STATUS2_VBVOLT_MASK (0x1 << STATUS2_VBVOLT_SHIFT) | ||
| 130 | #define STATUS2_VIDRM_MASK (0x1 << STATUS2_VIDRM_SHIFT) | ||
| 131 | |||
| 132 | #define STATUS3_OVP_SHIFT (2) | ||
| 133 | #define STATUS3_OVP_MASK (0x1 << STATUS3_OVP_SHIFT) | ||
| 134 | |||
| 135 | /* MAX77693 CDETCTRL1~2 register */ | ||
| 136 | #define CDETCTRL1_CHGDETEN_SHIFT (0) | ||
| 137 | #define CDETCTRL1_CHGTYPMAN_SHIFT (1) | ||
| 138 | #define CDETCTRL1_DCDEN_SHIFT (2) | ||
| 139 | #define CDETCTRL1_DCD2SCT_SHIFT (3) | ||
| 140 | #define CDETCTRL1_CDDELAY_SHIFT (4) | ||
| 141 | #define CDETCTRL1_DCDCPL_SHIFT (5) | ||
| 142 | #define CDETCTRL1_CDPDET_SHIFT (7) | ||
| 143 | #define CDETCTRL1_CHGDETEN_MASK (0x1 << CDETCTRL1_CHGDETEN_SHIFT) | ||
| 144 | #define CDETCTRL1_CHGTYPMAN_MASK (0x1 << CDETCTRL1_CHGTYPMAN_SHIFT) | ||
| 145 | #define CDETCTRL1_DCDEN_MASK (0x1 << CDETCTRL1_DCDEN_SHIFT) | ||
| 146 | #define CDETCTRL1_DCD2SCT_MASK (0x1 << CDETCTRL1_DCD2SCT_SHIFT) | ||
| 147 | #define CDETCTRL1_CDDELAY_MASK (0x1 << CDETCTRL1_CDDELAY_SHIFT) | ||
| 148 | #define CDETCTRL1_DCDCPL_MASK (0x1 << CDETCTRL1_DCDCPL_SHIFT) | ||
| 149 | #define CDETCTRL1_CDPDET_MASK (0x1 << CDETCTRL1_CDPDET_SHIFT) | ||
| 150 | |||
| 151 | #define CDETCTRL2_VIDRMEN_SHIFT (1) | ||
| 152 | #define CDETCTRL2_DXOVPEN_SHIFT (3) | ||
| 153 | #define CDETCTRL2_VIDRMEN_MASK (0x1 << CDETCTRL2_VIDRMEN_SHIFT) | ||
| 154 | #define CDETCTRL2_DXOVPEN_MASK (0x1 << CDETCTRL2_DXOVPEN_SHIFT) | ||
| 155 | |||
| 156 | /* MAX77693 MUIC - CONTROL1~3 register */ | ||
| 157 | #define COMN1SW_SHIFT (0) | ||
| 158 | #define COMP2SW_SHIFT (3) | ||
| 159 | #define COMN1SW_MASK (0x7 << COMN1SW_SHIFT) | ||
| 160 | #define COMP2SW_MASK (0x7 << COMP2SW_SHIFT) | ||
| 161 | #define COMP_SW_MASK (COMP2SW_MASK | COMN1SW_MASK) | ||
| 162 | #define CONTROL1_SW_USB ((1 << COMP2SW_SHIFT) \ | ||
| 163 | | (1 << COMN1SW_SHIFT)) | ||
| 164 | #define CONTROL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \ | ||
| 165 | | (2 << COMN1SW_SHIFT)) | ||
| 166 | #define CONTROL1_SW_UART ((3 << COMP2SW_SHIFT) \ | ||
| 167 | | (3 << COMN1SW_SHIFT)) | ||
| 168 | #define CONTROL1_SW_OPEN ((0 << COMP2SW_SHIFT) \ | ||
| 169 | | (0 << COMN1SW_SHIFT)) | ||
| 170 | |||
| 171 | #define CONTROL2_LOWPWR_SHIFT (0) | ||
| 172 | #define CONTROL2_ADCEN_SHIFT (1) | ||
| 173 | #define CONTROL2_CPEN_SHIFT (2) | ||
| 174 | #define CONTROL2_SFOUTASRT_SHIFT (3) | ||
| 175 | #define CONTROL2_SFOUTORD_SHIFT (4) | ||
| 176 | #define CONTROL2_ACCDET_SHIFT (5) | ||
| 177 | #define CONTROL2_USBCPINT_SHIFT (6) | ||
| 178 | #define CONTROL2_RCPS_SHIFT (7) | ||
| 179 | #define CONTROL2_LOWPWR_MASK (0x1 << CONTROL2_LOWPWR_SHIFT) | ||
| 180 | #define CONTROL2_ADCEN_MASK (0x1 << CONTROL2_ADCEN_SHIFT) | ||
| 181 | #define CONTROL2_CPEN_MASK (0x1 << CONTROL2_CPEN_SHIFT) | ||
| 182 | #define CONTROL2_SFOUTASRT_MASK (0x1 << CONTROL2_SFOUTASRT_SHIFT) | ||
| 183 | #define CONTROL2_SFOUTORD_MASK (0x1 << CONTROL2_SFOUTORD_SHIFT) | ||
| 184 | #define CONTROL2_ACCDET_MASK (0x1 << CONTROL2_ACCDET_SHIFT) | ||
| 185 | #define CONTROL2_USBCPINT_MASK (0x1 << CONTROL2_USBCPINT_SHIFT) | ||
| 186 | #define CONTROL2_RCPS_MASK (0x1 << CONTROL2_RCPS_SHIFT) | ||
| 187 | |||
| 188 | #define CONTROL3_JIGSET_SHIFT (0) | ||
| 189 | #define CONTROL3_BTLDSET_SHIFT (2) | ||
| 190 | #define CONTROL3_ADCDBSET_SHIFT (4) | ||
| 191 | #define CONTROL3_JIGSET_MASK (0x3 << CONTROL3_JIGSET_SHIFT) | ||
| 192 | #define CONTROL3_BTLDSET_MASK (0x3 << CONTROL3_BTLDSET_SHIFT) | ||
| 193 | #define CONTROL3_ADCDBSET_MASK (0x3 << CONTROL3_ADCDBSET_SHIFT) | ||
| 194 | |||
| 109 | /* Slave addr = 0x90: Haptic */ | 195 | /* Slave addr = 0x90: Haptic */ |
| 110 | enum max77693_haptic_reg { | 196 | enum max77693_haptic_reg { |
| 111 | MAX77693_HAPTIC_REG_STATUS = 0x00, | 197 | MAX77693_HAPTIC_REG_STATUS = 0x00, |
diff --git a/include/linux/mfd/max77693.h b/include/linux/mfd/max77693.h index fe03b2d35d4f..3109a6c5c948 100644 --- a/include/linux/mfd/max77693.h +++ b/include/linux/mfd/max77693.h | |||
| @@ -38,6 +38,15 @@ struct max77693_reg_data { | |||
| 38 | struct max77693_muic_platform_data { | 38 | struct max77693_muic_platform_data { |
| 39 | struct max77693_reg_data *init_data; | 39 | struct max77693_reg_data *init_data; |
| 40 | int num_init_data; | 40 | int num_init_data; |
| 41 | |||
| 42 | int detcable_delay_ms; | ||
| 43 | |||
| 44 | /* | ||
| 45 | * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB | ||
| 46 | * h/w path of COMP2/COMN1 on CONTROL1 register. | ||
| 47 | */ | ||
| 48 | int path_usb; | ||
| 49 | int path_uart; | ||
| 41 | }; | 50 | }; |
| 42 | 51 | ||
| 43 | struct max77693_platform_data { | 52 | struct max77693_platform_data { |
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h index 6ae21bf47d64..fb465dfbb59e 100644 --- a/include/linux/mfd/max8997-private.h +++ b/include/linux/mfd/max8997-private.h | |||
| @@ -194,6 +194,70 @@ enum max8997_muic_reg { | |||
| 194 | MAX8997_MUIC_REG_END = 0xf, | 194 | MAX8997_MUIC_REG_END = 0xf, |
| 195 | }; | 195 | }; |
| 196 | 196 | ||
| 197 | /* MAX8997-MUIC STATUS1 register */ | ||
| 198 | #define STATUS1_ADC_SHIFT 0 | ||
| 199 | #define STATUS1_ADCLOW_SHIFT 5 | ||
| 200 | #define STATUS1_ADCERR_SHIFT 6 | ||
| 201 | #define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT) | ||
| 202 | #define STATUS1_ADCLOW_MASK (0x1 << STATUS1_ADCLOW_SHIFT) | ||
| 203 | #define STATUS1_ADCERR_MASK (0x1 << STATUS1_ADCERR_SHIFT) | ||
| 204 | |||
| 205 | /* MAX8997-MUIC STATUS2 register */ | ||
| 206 | #define STATUS2_CHGTYP_SHIFT 0 | ||
| 207 | #define STATUS2_CHGDETRUN_SHIFT 3 | ||
| 208 | #define STATUS2_DCDTMR_SHIFT 4 | ||
| 209 | #define STATUS2_DBCHG_SHIFT 5 | ||
| 210 | #define STATUS2_VBVOLT_SHIFT 6 | ||
| 211 | #define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT) | ||
| 212 | #define STATUS2_CHGDETRUN_MASK (0x1 << STATUS2_CHGDETRUN_SHIFT) | ||
| 213 | #define STATUS2_DCDTMR_MASK (0x1 << STATUS2_DCDTMR_SHIFT) | ||
| 214 | #define STATUS2_DBCHG_MASK (0x1 << STATUS2_DBCHG_SHIFT) | ||
| 215 | #define STATUS2_VBVOLT_MASK (0x1 << STATUS2_VBVOLT_SHIFT) | ||
| 216 | |||
| 217 | /* MAX8997-MUIC STATUS3 register */ | ||
| 218 | #define STATUS3_OVP_SHIFT 2 | ||
| 219 | #define STATUS3_OVP_MASK (0x1 << STATUS3_OVP_SHIFT) | ||
| 220 | |||
| 221 | /* MAX8997-MUIC CONTROL1 register */ | ||
| 222 | #define COMN1SW_SHIFT 0 | ||
| 223 | #define COMP2SW_SHIFT 3 | ||
| 224 | #define COMN1SW_MASK (0x7 << COMN1SW_SHIFT) | ||
| 225 | #define COMP2SW_MASK (0x7 << COMP2SW_SHIFT) | ||
| 226 | #define COMP_SW_MASK (COMP2SW_MASK | COMN1SW_MASK) | ||
| 227 | |||
| 228 | #define CONTROL1_SW_USB ((1 << COMP2SW_SHIFT) \ | ||
| 229 | | (1 << COMN1SW_SHIFT)) | ||
| 230 | #define CONTROL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \ | ||
| 231 | | (2 << COMN1SW_SHIFT)) | ||
| 232 | #define CONTROL1_SW_UART ((3 << COMP2SW_SHIFT) \ | ||
| 233 | | (3 << COMN1SW_SHIFT)) | ||
| 234 | #define CONTROL1_SW_OPEN ((0 << COMP2SW_SHIFT) \ | ||
| 235 | | (0 << COMN1SW_SHIFT)) | ||
| 236 | |||
| 237 | #define CONTROL2_LOWPWR_SHIFT (0) | ||
| 238 | #define CONTROL2_ADCEN_SHIFT (1) | ||
| 239 | #define CONTROL2_CPEN_SHIFT (2) | ||
| 240 | #define CONTROL2_SFOUTASRT_SHIFT (3) | ||
| 241 | #define CONTROL2_SFOUTORD_SHIFT (4) | ||
| 242 | #define CONTROL2_ACCDET_SHIFT (5) | ||
| 243 | #define CONTROL2_USBCPINT_SHIFT (6) | ||
| 244 | #define CONTROL2_RCPS_SHIFT (7) | ||
| 245 | #define CONTROL2_LOWPWR_MASK (0x1 << CONTROL2_LOWPWR_SHIFT) | ||
| 246 | #define CONTROL2_ADCEN_MASK (0x1 << CONTROL2_ADCEN_SHIFT) | ||
| 247 | #define CONTROL2_CPEN_MASK (0x1 << CONTROL2_CPEN_SHIFT) | ||
| 248 | #define CONTROL2_SFOUTASRT_MASK (0x1 << CONTROL2_SFOUTASRT_SHIFT) | ||
| 249 | #define CONTROL2_SFOUTORD_MASK (0x1 << CONTROL2_SFOUTORD_SHIFT) | ||
| 250 | #define CONTROL2_ACCDET_MASK (0x1 << CONTROL2_ACCDET_SHIFT) | ||
| 251 | #define CONTROL2_USBCPINT_MASK (0x1 << CONTROL2_USBCPINT_SHIFT) | ||
| 252 | #define CONTROL2_RCPS_MASK (0x1 << CONTROL2_RCPS_SHIFT) | ||
| 253 | |||
| 254 | #define CONTROL3_JIGSET_SHIFT (0) | ||
| 255 | #define CONTROL3_BTLDSET_SHIFT (2) | ||
| 256 | #define CONTROL3_ADCDBSET_SHIFT (4) | ||
| 257 | #define CONTROL3_JIGSET_MASK (0x3 << CONTROL3_JIGSET_SHIFT) | ||
| 258 | #define CONTROL3_BTLDSET_MASK (0x3 << CONTROL3_BTLDSET_SHIFT) | ||
| 259 | #define CONTROL3_ADCDBSET_MASK (0x3 << CONTROL3_ADCDBSET_SHIFT) | ||
| 260 | |||
| 197 | enum max8997_haptic_reg { | 261 | enum max8997_haptic_reg { |
| 198 | MAX8997_HAPTIC_REG_GENERAL = 0x00, | 262 | MAX8997_HAPTIC_REG_GENERAL = 0x00, |
| 199 | MAX8997_HAPTIC_REG_CONF1 = 0x01, | 263 | MAX8997_HAPTIC_REG_CONF1 = 0x01, |
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h index 1d4a4fe6ac33..cf815577bd68 100644 --- a/include/linux/mfd/max8997.h +++ b/include/linux/mfd/max8997.h | |||
| @@ -78,21 +78,6 @@ struct max8997_regulator_data { | |||
| 78 | struct device_node *reg_node; | 78 | struct device_node *reg_node; |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | enum max8997_muic_usb_type { | ||
| 82 | MAX8997_USB_HOST, | ||
| 83 | MAX8997_USB_DEVICE, | ||
| 84 | }; | ||
| 85 | |||
| 86 | enum max8997_muic_charger_type { | ||
| 87 | MAX8997_CHARGER_TYPE_NONE = 0, | ||
| 88 | MAX8997_CHARGER_TYPE_USB, | ||
| 89 | MAX8997_CHARGER_TYPE_DOWNSTREAM_PORT, | ||
| 90 | MAX8997_CHARGER_TYPE_DEDICATED_CHG, | ||
| 91 | MAX8997_CHARGER_TYPE_500MA, | ||
| 92 | MAX8997_CHARGER_TYPE_1A, | ||
| 93 | MAX8997_CHARGER_TYPE_DEAD_BATTERY = 7, | ||
| 94 | }; | ||
| 95 | |||
| 96 | struct max8997_muic_reg_data { | 81 | struct max8997_muic_reg_data { |
| 97 | u8 addr; | 82 | u8 addr; |
| 98 | u8 data; | 83 | u8 data; |
| @@ -107,6 +92,16 @@ struct max8997_muic_reg_data { | |||
| 107 | struct max8997_muic_platform_data { | 92 | struct max8997_muic_platform_data { |
| 108 | struct max8997_muic_reg_data *init_data; | 93 | struct max8997_muic_reg_data *init_data; |
| 109 | int num_init_data; | 94 | int num_init_data; |
| 95 | |||
| 96 | /* Check cable state after certain delay */ | ||
| 97 | int detcable_delay_ms; | ||
| 98 | |||
| 99 | /* | ||
| 100 | * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB | ||
| 101 | * h/w path of COMP2/COMN1 on CONTROL1 register. | ||
| 102 | */ | ||
| 103 | int path_usb; | ||
| 104 | int path_uart; | ||
| 110 | }; | 105 | }; |
| 111 | 106 | ||
| 112 | enum max8997_haptic_motor_type { | 107 | enum max8997_haptic_motor_type { |
diff --git a/include/linux/ntb.h b/include/linux/ntb.h new file mode 100644 index 000000000000..f6a15205853b --- /dev/null +++ b/include/linux/ntb.h | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | /* | ||
| 2 | * This file is provided under a dual BSD/GPLv2 license. When using or | ||
| 3 | * redistributing this file, you may do so under either license. | ||
| 4 | * | ||
| 5 | * GPL LICENSE SUMMARY | ||
| 6 | * | ||
| 7 | * Copyright(c) 2012 Intel Corporation. All rights reserved. | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of version 2 of the GNU General Public License as | ||
| 11 | * published by the Free Software Foundation. | ||
| 12 | * | ||
| 13 | * BSD LICENSE | ||
| 14 | * | ||
| 15 | * Copyright(c) 2012 Intel Corporation. All rights reserved. | ||
| 16 | * | ||
| 17 | * Redistribution and use in source and binary forms, with or without | ||
| 18 | * modification, are permitted provided that the following conditions | ||
| 19 | * are met: | ||
| 20 | * | ||
| 21 | * * Redistributions of source code must retain the above copyright | ||
| 22 | * notice, this list of conditions and the following disclaimer. | ||
| 23 | * * Redistributions in binary form must reproduce the above copy | ||
| 24 | * notice, this list of conditions and the following disclaimer in | ||
| 25 | * the documentation and/or other materials provided with the | ||
| 26 | * distribution. | ||
| 27 | * * Neither the name of Intel Corporation nor the names of its | ||
| 28 | * contributors may be used to endorse or promote products derived | ||
| 29 | * from this software without specific prior written permission. | ||
| 30 | * | ||
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 35 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 36 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 37 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 38 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 39 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 40 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 41 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 42 | * | ||
| 43 | * Intel PCIe NTB Linux driver | ||
| 44 | * | ||
| 45 | * Contact Information: | ||
| 46 | * Jon Mason <jon.mason@intel.com> | ||
| 47 | */ | ||
| 48 | |||
| 49 | struct ntb_transport_qp; | ||
| 50 | |||
| 51 | struct ntb_client { | ||
| 52 | struct device_driver driver; | ||
| 53 | int (*probe) (struct pci_dev *pdev); | ||
| 54 | void (*remove) (struct pci_dev *pdev); | ||
| 55 | }; | ||
| 56 | |||
| 57 | int ntb_register_client(struct ntb_client *drvr); | ||
| 58 | void ntb_unregister_client(struct ntb_client *drvr); | ||
| 59 | int ntb_register_client_dev(char *device_name); | ||
| 60 | void ntb_unregister_client_dev(char *device_name); | ||
| 61 | |||
| 62 | struct ntb_queue_handlers { | ||
| 63 | void (*rx_handler) (struct ntb_transport_qp *qp, void *qp_data, | ||
| 64 | void *data, int len); | ||
| 65 | void (*tx_handler) (struct ntb_transport_qp *qp, void *qp_data, | ||
| 66 | void *data, int len); | ||
| 67 | void (*event_handler) (void *data, int status); | ||
| 68 | }; | ||
| 69 | |||
| 70 | unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp); | ||
| 71 | unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp); | ||
| 72 | struct ntb_transport_qp * | ||
| 73 | ntb_transport_create_queue(void *data, struct pci_dev *pdev, | ||
| 74 | const struct ntb_queue_handlers *handlers); | ||
| 75 | void ntb_transport_free_queue(struct ntb_transport_qp *qp); | ||
| 76 | int ntb_transport_rx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data, | ||
| 77 | unsigned int len); | ||
| 78 | int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data, | ||
| 79 | unsigned int len); | ||
| 80 | void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len); | ||
| 81 | void ntb_transport_link_up(struct ntb_transport_qp *qp); | ||
| 82 | void ntb_transport_link_down(struct ntb_transport_qp *qp); | ||
| 83 | bool ntb_transport_link_query(struct ntb_transport_qp *qp); | ||
diff --git a/include/linux/vmw_vmci_api.h b/include/linux/vmw_vmci_api.h new file mode 100644 index 000000000000..023430e265fe --- /dev/null +++ b/include/linux/vmw_vmci_api.h | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /* | ||
| 2 | * VMware VMCI Driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2012 VMware, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License as published by the | ||
| 8 | * Free Software Foundation version 2 and no later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, but | ||
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 13 | * for more details. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #ifndef __VMW_VMCI_API_H__ | ||
| 17 | #define __VMW_VMCI_API_H__ | ||
| 18 | |||
| 19 | #include <linux/uidgid.h> | ||
| 20 | #include <linux/vmw_vmci_defs.h> | ||
| 21 | |||
| 22 | #undef VMCI_KERNEL_API_VERSION | ||
| 23 | #define VMCI_KERNEL_API_VERSION_1 1 | ||
| 24 | #define VMCI_KERNEL_API_VERSION_2 2 | ||
| 25 | #define VMCI_KERNEL_API_VERSION VMCI_KERNEL_API_VERSION_2 | ||
| 26 | |||
| 27 | typedef void (vmci_device_shutdown_fn) (void *device_registration, | ||
| 28 | void *user_data); | ||
| 29 | |||
| 30 | int vmci_datagram_create_handle(u32 resource_id, u32 flags, | ||
| 31 | vmci_datagram_recv_cb recv_cb, | ||
| 32 | void *client_data, | ||
| 33 | struct vmci_handle *out_handle); | ||
| 34 | int vmci_datagram_create_handle_priv(u32 resource_id, u32 flags, u32 priv_flags, | ||
| 35 | vmci_datagram_recv_cb recv_cb, | ||
| 36 | void *client_data, | ||
| 37 | struct vmci_handle *out_handle); | ||
| 38 | int vmci_datagram_destroy_handle(struct vmci_handle handle); | ||
| 39 | int vmci_datagram_send(struct vmci_datagram *msg); | ||
| 40 | int vmci_doorbell_create(struct vmci_handle *handle, u32 flags, | ||
| 41 | u32 priv_flags, | ||
| 42 | vmci_callback notify_cb, void *client_data); | ||
| 43 | int vmci_doorbell_destroy(struct vmci_handle handle); | ||
| 44 | int vmci_doorbell_notify(struct vmci_handle handle, u32 priv_flags); | ||
| 45 | u32 vmci_get_context_id(void); | ||
| 46 | bool vmci_is_context_owner(u32 context_id, kuid_t uid); | ||
| 47 | |||
| 48 | int vmci_event_subscribe(u32 event, | ||
| 49 | vmci_event_cb callback, void *callback_data, | ||
| 50 | u32 *subid); | ||
| 51 | int vmci_event_unsubscribe(u32 subid); | ||
| 52 | u32 vmci_context_get_priv_flags(u32 context_id); | ||
| 53 | int vmci_qpair_alloc(struct vmci_qp **qpair, | ||
| 54 | struct vmci_handle *handle, | ||
| 55 | u64 produce_qsize, | ||
| 56 | u64 consume_qsize, | ||
| 57 | u32 peer, u32 flags, u32 priv_flags); | ||
| 58 | int vmci_qpair_detach(struct vmci_qp **qpair); | ||
| 59 | int vmci_qpair_get_produce_indexes(const struct vmci_qp *qpair, | ||
| 60 | u64 *producer_tail, | ||
| 61 | u64 *consumer_head); | ||
| 62 | int vmci_qpair_get_consume_indexes(const struct vmci_qp *qpair, | ||
| 63 | u64 *consumer_tail, | ||
| 64 | u64 *producer_head); | ||
| 65 | s64 vmci_qpair_produce_free_space(const struct vmci_qp *qpair); | ||
| 66 | s64 vmci_qpair_produce_buf_ready(const struct vmci_qp *qpair); | ||
| 67 | s64 vmci_qpair_consume_free_space(const struct vmci_qp *qpair); | ||
| 68 | s64 vmci_qpair_consume_buf_ready(const struct vmci_qp *qpair); | ||
| 69 | ssize_t vmci_qpair_enqueue(struct vmci_qp *qpair, | ||
| 70 | const void *buf, size_t buf_size, int mode); | ||
| 71 | ssize_t vmci_qpair_dequeue(struct vmci_qp *qpair, | ||
| 72 | void *buf, size_t buf_size, int mode); | ||
| 73 | ssize_t vmci_qpair_peek(struct vmci_qp *qpair, void *buf, size_t buf_size, | ||
| 74 | int mode); | ||
| 75 | ssize_t vmci_qpair_enquev(struct vmci_qp *qpair, | ||
| 76 | void *iov, size_t iov_size, int mode); | ||
| 77 | ssize_t vmci_qpair_dequev(struct vmci_qp *qpair, | ||
| 78 | void *iov, size_t iov_size, int mode); | ||
| 79 | ssize_t vmci_qpair_peekv(struct vmci_qp *qpair, void *iov, size_t iov_size, | ||
| 80 | int mode); | ||
| 81 | |||
| 82 | #endif /* !__VMW_VMCI_API_H__ */ | ||
diff --git a/include/linux/vmw_vmci_defs.h b/include/linux/vmw_vmci_defs.h new file mode 100644 index 000000000000..65ac54c61c18 --- /dev/null +++ b/include/linux/vmw_vmci_defs.h | |||
| @@ -0,0 +1,880 @@ | |||
| 1 | /* | ||
| 2 | * VMware VMCI Driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2012 VMware, Inc. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License as published by the | ||
| 8 | * Free Software Foundation version 2 and no later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, but | ||
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 13 | * for more details. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #ifndef _VMW_VMCI_DEF_H_ | ||
| 17 | #define _VMW_VMCI_DEF_H_ | ||
| 18 | |||
| 19 | #include <linux/atomic.h> | ||
| 20 | |||
| 21 | /* Register offsets. */ | ||
| 22 | #define VMCI_STATUS_ADDR 0x00 | ||
| 23 | #define VMCI_CONTROL_ADDR 0x04 | ||
| 24 | #define VMCI_ICR_ADDR 0x08 | ||
| 25 | #define VMCI_IMR_ADDR 0x0c | ||
| 26 | #define VMCI_DATA_OUT_ADDR 0x10 | ||
| 27 | #define VMCI_DATA_IN_ADDR 0x14 | ||
| 28 | #define VMCI_CAPS_ADDR 0x18 | ||
| 29 | #define VMCI_RESULT_LOW_ADDR 0x1c | ||
| 30 | #define VMCI_RESULT_HIGH_ADDR 0x20 | ||
| 31 | |||
| 32 | /* Max number of devices. */ | ||
| 33 | #define VMCI_MAX_DEVICES 1 | ||
| 34 | |||
| 35 | /* Status register bits. */ | ||
| 36 | #define VMCI_STATUS_INT_ON 0x1 | ||
| 37 | |||
| 38 | /* Control register bits. */ | ||
| 39 | #define VMCI_CONTROL_RESET 0x1 | ||
| 40 | #define VMCI_CONTROL_INT_ENABLE 0x2 | ||
| 41 | #define VMCI_CONTROL_INT_DISABLE 0x4 | ||
| 42 | |||
| 43 | /* Capabilities register bits. */ | ||
| 44 | #define VMCI_CAPS_HYPERCALL 0x1 | ||
| 45 | #define VMCI_CAPS_GUESTCALL 0x2 | ||
| 46 | #define VMCI_CAPS_DATAGRAM 0x4 | ||
| 47 | #define VMCI_CAPS_NOTIFICATIONS 0x8 | ||
| 48 | |||
| 49 | /* Interrupt Cause register bits. */ | ||
| 50 | #define VMCI_ICR_DATAGRAM 0x1 | ||
| 51 | #define VMCI_ICR_NOTIFICATION 0x2 | ||
| 52 | |||
| 53 | /* Interrupt Mask register bits. */ | ||
| 54 | #define VMCI_IMR_DATAGRAM 0x1 | ||
| 55 | #define VMCI_IMR_NOTIFICATION 0x2 | ||
| 56 | |||
| 57 | /* Interrupt type. */ | ||
| 58 | enum { | ||
| 59 | VMCI_INTR_TYPE_INTX = 0, | ||
| 60 | VMCI_INTR_TYPE_MSI = 1, | ||
| 61 | VMCI_INTR_TYPE_MSIX = 2, | ||
| 62 | }; | ||
| 63 | |||
| 64 | /* Maximum MSI/MSI-X interrupt vectors in the device. */ | ||
| 65 | #define VMCI_MAX_INTRS 2 | ||
| 66 | |||
| 67 | /* | ||
| 68 | * Supported interrupt vectors. There is one for each ICR value above, | ||
| 69 | * but here they indicate the position in the vector array/message ID. | ||
| 70 | */ | ||
| 71 | enum { | ||
| 72 | VMCI_INTR_DATAGRAM = 0, | ||
| 73 | VMCI_INTR_NOTIFICATION = 1, | ||
| 74 | }; | ||
| 75 | |||
| 76 | /* | ||
| 77 | * A single VMCI device has an upper limit of 128MB on the amount of | ||
| 78 | * memory that can be used for queue pairs. | ||
| 79 | */ | ||
| 80 | #define VMCI_MAX_GUEST_QP_MEMORY (128 * 1024 * 1024) | ||
| 81 | |||
| 82 | /* | ||
| 83 | * Queues with pre-mapped data pages must be small, so that we don't pin | ||
| 84 | * too much kernel memory (especially on vmkernel). We limit a queuepair to | ||
| 85 | * 32 KB, or 16 KB per queue for symmetrical pairs. | ||
| 86 | */ | ||
| 87 | #define VMCI_MAX_PINNED_QP_MEMORY (32 * 1024) | ||
| 88 | |||
| 89 | /* | ||
| 90 | * We have a fixed set of resource IDs available in the VMX. | ||
| 91 | * This allows us to have a very simple implementation since we statically | ||
| 92 | * know how many will create datagram handles. If a new caller arrives and | ||
| 93 | * we have run out of slots we can manually increment the maximum size of | ||
| 94 | * available resource IDs. | ||
| 95 | * | ||
| 96 | * VMCI reserved hypervisor datagram resource IDs. | ||
| 97 | */ | ||
| 98 | enum { | ||
| 99 | VMCI_RESOURCES_QUERY = 0, | ||
| 100 | VMCI_GET_CONTEXT_ID = 1, | ||
| 101 | VMCI_SET_NOTIFY_BITMAP = 2, | ||
| 102 | VMCI_DOORBELL_LINK = 3, | ||
| 103 | VMCI_DOORBELL_UNLINK = 4, | ||
| 104 | VMCI_DOORBELL_NOTIFY = 5, | ||
| 105 | /* | ||
| 106 | * VMCI_DATAGRAM_REQUEST_MAP and VMCI_DATAGRAM_REMOVE_MAP are | ||
| 107 | * obsoleted by the removal of VM to VM communication. | ||
| 108 | */ | ||
| 109 | VMCI_DATAGRAM_REQUEST_MAP = 6, | ||
| 110 | VMCI_DATAGRAM_REMOVE_MAP = 7, | ||
| 111 | VMCI_EVENT_SUBSCRIBE = 8, | ||
| 112 | VMCI_EVENT_UNSUBSCRIBE = 9, | ||
| 113 | VMCI_QUEUEPAIR_ALLOC = 10, | ||
| 114 | VMCI_QUEUEPAIR_DETACH = 11, | ||
| 115 | |||
| 116 | /* | ||
| 117 | * VMCI_VSOCK_VMX_LOOKUP was assigned to 12 for Fusion 3.0/3.1, | ||
| 118 | * WS 7.0/7.1 and ESX 4.1 | ||
| 119 | */ | ||
| 120 | VMCI_HGFS_TRANSPORT = 13, | ||
| 121 | VMCI_UNITY_PBRPC_REGISTER = 14, | ||
| 122 | VMCI_RPC_PRIVILEGED = 15, | ||
| 123 | VMCI_RPC_UNPRIVILEGED = 16, | ||
| 124 | VMCI_RESOURCE_MAX = 17, | ||
| 125 | }; | ||
| 126 | |||
| 127 | /* | ||
| 128 | * struct vmci_handle - Ownership information structure | ||
| 129 | * @context: The VMX context ID. | ||
| 130 | * @resource: The resource ID (used for locating in resource hash). | ||
| 131 | * | ||
| 132 | * The vmci_handle structure is used to track resources used within | ||
| 133 | * vmw_vmci. | ||
| 134 | */ | ||
| 135 | struct vmci_handle { | ||
| 136 | u32 context; | ||
| 137 | u32 resource; | ||
| 138 | }; | ||
| 139 | |||
| 140 | #define vmci_make_handle(_cid, _rid) \ | ||
| 141 | (struct vmci_handle){ .context = _cid, .resource = _rid } | ||
| 142 | |||
| 143 | static inline bool vmci_handle_is_equal(struct vmci_handle h1, | ||
| 144 | struct vmci_handle h2) | ||
| 145 | { | ||
| 146 | return h1.context == h2.context && h1.resource == h2.resource; | ||
| 147 | } | ||
| 148 | |||
| 149 | #define VMCI_INVALID_ID ~0 | ||
| 150 | static const struct vmci_handle VMCI_INVALID_HANDLE = { | ||
| 151 | .context = VMCI_INVALID_ID, | ||
| 152 | .resource = VMCI_INVALID_ID | ||
| 153 | }; | ||
| 154 | |||
| 155 | static inline bool vmci_handle_is_invalid(struct vmci_handle h) | ||
| 156 | { | ||
| 157 | return vmci_handle_is_equal(h, VMCI_INVALID_HANDLE); | ||
| 158 | } | ||
| 159 | |||
| 160 | /* | ||
| 161 | * The below defines can be used to send anonymous requests. | ||
| 162 | * This also indicates that no response is expected. | ||
| 163 | */ | ||
| 164 | #define VMCI_ANON_SRC_CONTEXT_ID VMCI_INVALID_ID | ||
| 165 | #define VMCI_ANON_SRC_RESOURCE_ID VMCI_INVALID_ID | ||
| 166 | static const struct vmci_handle VMCI_ANON_SRC_HANDLE = { | ||
| 167 | .context = VMCI_ANON_SRC_CONTEXT_ID, | ||
| 168 | .resource = VMCI_ANON_SRC_RESOURCE_ID | ||
| 169 | }; | ||
| 170 | |||
| 171 | /* The lowest 16 context ids are reserved for internal use. */ | ||
| 172 | #define VMCI_RESERVED_CID_LIMIT ((u32) 16) | ||
| 173 | |||
| 174 | /* | ||
| 175 | * Hypervisor context id, used for calling into hypervisor | ||
| 176 | * supplied services from the VM. | ||
| 177 | */ | ||
| 178 | #define VMCI_HYPERVISOR_CONTEXT_ID 0 | ||
| 179 | |||
| 180 | /* | ||
| 181 | * Well-known context id, a logical context that contains a set of | ||
| 182 | * well-known services. This context ID is now obsolete. | ||
| 183 | */ | ||
| 184 | #define VMCI_WELL_KNOWN_CONTEXT_ID 1 | ||
| 185 | |||
| 186 | /* | ||
| 187 | * Context ID used by host endpoints. | ||
| 188 | */ | ||
| 189 | #define VMCI_HOST_CONTEXT_ID 2 | ||
| 190 | |||
| 191 | #define VMCI_CONTEXT_IS_VM(_cid) (VMCI_INVALID_ID != (_cid) && \ | ||
| 192 | (_cid) > VMCI_HOST_CONTEXT_ID) | ||
| 193 | |||
| 194 | /* | ||
| 195 | * The VMCI_CONTEXT_RESOURCE_ID is used together with vmci_make_handle to make | ||
| 196 | * handles that refer to a specific context. | ||
| 197 | */ | ||
| 198 | #define VMCI_CONTEXT_RESOURCE_ID 0 | ||
| 199 | |||
| 200 | /* | ||
| 201 | * VMCI error codes. | ||
| 202 | */ | ||
| 203 | enum { | ||
| 204 | VMCI_SUCCESS_QUEUEPAIR_ATTACH = 5, | ||
| 205 | VMCI_SUCCESS_QUEUEPAIR_CREATE = 4, | ||
| 206 | VMCI_SUCCESS_LAST_DETACH = 3, | ||
| 207 | VMCI_SUCCESS_ACCESS_GRANTED = 2, | ||
| 208 | VMCI_SUCCESS_ENTRY_DEAD = 1, | ||
| 209 | VMCI_SUCCESS = 0, | ||
| 210 | VMCI_ERROR_INVALID_RESOURCE = (-1), | ||
| 211 | VMCI_ERROR_INVALID_ARGS = (-2), | ||
| 212 | VMCI_ERROR_NO_MEM = (-3), | ||
| 213 | VMCI_ERROR_DATAGRAM_FAILED = (-4), | ||
| 214 | VMCI_ERROR_MORE_DATA = (-5), | ||
| 215 | VMCI_ERROR_NO_MORE_DATAGRAMS = (-6), | ||
| 216 | VMCI_ERROR_NO_ACCESS = (-7), | ||
| 217 | VMCI_ERROR_NO_HANDLE = (-8), | ||
| 218 | VMCI_ERROR_DUPLICATE_ENTRY = (-9), | ||
| 219 | VMCI_ERROR_DST_UNREACHABLE = (-10), | ||
| 220 | VMCI_ERROR_PAYLOAD_TOO_LARGE = (-11), | ||
| 221 | VMCI_ERROR_INVALID_PRIV = (-12), | ||
| 222 | VMCI_ERROR_GENERIC = (-13), | ||
| 223 | VMCI_ERROR_PAGE_ALREADY_SHARED = (-14), | ||
| 224 | VMCI_ERROR_CANNOT_SHARE_PAGE = (-15), | ||
| 225 | VMCI_ERROR_CANNOT_UNSHARE_PAGE = (-16), | ||
| 226 | VMCI_ERROR_NO_PROCESS = (-17), | ||
| 227 | VMCI_ERROR_NO_DATAGRAM = (-18), | ||
| 228 | VMCI_ERROR_NO_RESOURCES = (-19), | ||
| 229 | VMCI_ERROR_UNAVAILABLE = (-20), | ||
| 230 | VMCI_ERROR_NOT_FOUND = (-21), | ||
| 231 | VMCI_ERROR_ALREADY_EXISTS = (-22), | ||
| 232 | VMCI_ERROR_NOT_PAGE_ALIGNED = (-23), | ||
| 233 | VMCI_ERROR_INVALID_SIZE = (-24), | ||
| 234 | VMCI_ERROR_REGION_ALREADY_SHARED = (-25), | ||
| 235 | VMCI_ERROR_TIMEOUT = (-26), | ||
| 236 | VMCI_ERROR_DATAGRAM_INCOMPLETE = (-27), | ||
| 237 | VMCI_ERROR_INCORRECT_IRQL = (-28), | ||
| 238 | VMCI_ERROR_EVENT_UNKNOWN = (-29), | ||
| 239 | VMCI_ERROR_OBSOLETE = (-30), | ||
| 240 | VMCI_ERROR_QUEUEPAIR_MISMATCH = (-31), | ||
| 241 | VMCI_ERROR_QUEUEPAIR_NOTSET = (-32), | ||
| 242 | VMCI_ERROR_QUEUEPAIR_NOTOWNER = (-33), | ||
| 243 | VMCI_ERROR_QUEUEPAIR_NOTATTACHED = (-34), | ||
| 244 | VMCI_ERROR_QUEUEPAIR_NOSPACE = (-35), | ||
| 245 | VMCI_ERROR_QUEUEPAIR_NODATA = (-36), | ||
| 246 | VMCI_ERROR_BUSMEM_INVALIDATION = (-37), | ||
| 247 | VMCI_ERROR_MODULE_NOT_LOADED = (-38), | ||
| 248 | VMCI_ERROR_DEVICE_NOT_FOUND = (-39), | ||
| 249 | VMCI_ERROR_QUEUEPAIR_NOT_READY = (-40), | ||
| 250 | VMCI_ERROR_WOULD_BLOCK = (-41), | ||
| 251 | |||
| 252 | /* VMCI clients should return error code within this range */ | ||
| 253 | VMCI_ERROR_CLIENT_MIN = (-500), | ||
| 254 | VMCI_ERROR_CLIENT_MAX = (-550), | ||
| 255 | |||
| 256 | /* Internal error codes. */ | ||
| 257 | VMCI_SHAREDMEM_ERROR_BAD_CONTEXT = (-1000), | ||
| 258 | }; | ||
| 259 | |||
| 260 | /* VMCI reserved events. */ | ||
| 261 | enum { | ||
| 262 | /* Only applicable to guest endpoints */ | ||
| 263 | VMCI_EVENT_CTX_ID_UPDATE = 0, | ||
| 264 | |||
| 265 | /* Applicable to guest and host */ | ||
| 266 | VMCI_EVENT_CTX_REMOVED = 1, | ||
| 267 | |||
| 268 | /* Only applicable to guest endpoints */ | ||
| 269 | VMCI_EVENT_QP_RESUMED = 2, | ||
| 270 | |||
| 271 | /* Applicable to guest and host */ | ||
| 272 | VMCI_EVENT_QP_PEER_ATTACH = 3, | ||
| 273 | |||
| 274 | /* Applicable to guest and host */ | ||
| 275 | VMCI_EVENT_QP_PEER_DETACH = 4, | ||
| 276 | |||
| 277 | /* | ||
| 278 | * Applicable to VMX and vmk. On vmk, | ||
| 279 | * this event has the Context payload type. | ||
| 280 | */ | ||
| 281 | VMCI_EVENT_MEM_ACCESS_ON = 5, | ||
| 282 | |||
| 283 | /* | ||
| 284 | * Applicable to VMX and vmk. Same as | ||
| 285 | * above for the payload type. | ||
| 286 | */ | ||
| 287 | VMCI_EVENT_MEM_ACCESS_OFF = 6, | ||
| 288 | VMCI_EVENT_MAX = 7, | ||
| 289 | }; | ||
| 290 | |||
| 291 | /* | ||
| 292 | * Of the above events, a few are reserved for use in the VMX, and | ||
| 293 | * other endpoints (guest and host kernel) should not use them. For | ||
| 294 | * the rest of the events, we allow both host and guest endpoints to | ||
| 295 | * subscribe to them, to maintain the same API for host and guest | ||
| 296 | * endpoints. | ||
| 297 | */ | ||
| 298 | #define VMCI_EVENT_VALID_VMX(_event) ((_event) == VMCI_EVENT_MEM_ACCESS_ON || \ | ||
| 299 | (_event) == VMCI_EVENT_MEM_ACCESS_OFF) | ||
| 300 | |||
| 301 | #define VMCI_EVENT_VALID(_event) ((_event) < VMCI_EVENT_MAX && \ | ||
| 302 | !VMCI_EVENT_VALID_VMX(_event)) | ||
| 303 | |||
| 304 | /* Reserved guest datagram resource ids. */ | ||
| 305 | #define VMCI_EVENT_HANDLER 0 | ||
| 306 | |||
| 307 | /* | ||
| 308 | * VMCI coarse-grained privileges (per context or host | ||
| 309 | * process/endpoint. An entity with the restricted flag is only | ||
| 310 | * allowed to interact with the hypervisor and trusted entities. | ||
| 311 | */ | ||
| 312 | enum { | ||
| 313 | VMCI_NO_PRIVILEGE_FLAGS = 0, | ||
| 314 | VMCI_PRIVILEGE_FLAG_RESTRICTED = 1, | ||
| 315 | VMCI_PRIVILEGE_FLAG_TRUSTED = 2, | ||
| 316 | VMCI_PRIVILEGE_ALL_FLAGS = (VMCI_PRIVILEGE_FLAG_RESTRICTED | | ||
| 317 | VMCI_PRIVILEGE_FLAG_TRUSTED), | ||
| 318 | VMCI_DEFAULT_PROC_PRIVILEGE_FLAGS = VMCI_NO_PRIVILEGE_FLAGS, | ||
| 319 | VMCI_LEAST_PRIVILEGE_FLAGS = VMCI_PRIVILEGE_FLAG_RESTRICTED, | ||
| 320 | VMCI_MAX_PRIVILEGE_FLAGS = VMCI_PRIVILEGE_FLAG_TRUSTED, | ||
| 321 | }; | ||
| 322 | |||
| 323 | /* 0 through VMCI_RESERVED_RESOURCE_ID_MAX are reserved. */ | ||
| 324 | #define VMCI_RESERVED_RESOURCE_ID_MAX 1023 | ||
| 325 | |||
| 326 | /* | ||
| 327 | * Driver version. | ||
| 328 | * | ||
| 329 | * Increment major version when you make an incompatible change. | ||
| 330 | * Compatibility goes both ways (old driver with new executable | ||
| 331 | * as well as new driver with old executable). | ||
| 332 | */ | ||
| 333 | |||
| 334 | /* Never change VMCI_VERSION_SHIFT_WIDTH */ | ||
| 335 | #define VMCI_VERSION_SHIFT_WIDTH 16 | ||
| 336 | #define VMCI_MAKE_VERSION(_major, _minor) \ | ||
| 337 | ((_major) << VMCI_VERSION_SHIFT_WIDTH | (u16) (_minor)) | ||
| 338 | |||
| 339 | #define VMCI_VERSION_MAJOR(v) ((u32) (v) >> VMCI_VERSION_SHIFT_WIDTH) | ||
| 340 | #define VMCI_VERSION_MINOR(v) ((u16) (v)) | ||
| 341 | |||
| 342 | /* | ||
| 343 | * VMCI_VERSION is always the current version. Subsequently listed | ||
| 344 | * versions are ways of detecting previous versions of the connecting | ||
| 345 | * application (i.e., VMX). | ||
| 346 | * | ||
| 347 | * VMCI_VERSION_NOVMVM: This version removed support for VM to VM | ||
| 348 | * communication. | ||
| 349 | * | ||
| 350 | * VMCI_VERSION_NOTIFY: This version introduced doorbell notification | ||
| 351 | * support. | ||
| 352 | * | ||
| 353 | * VMCI_VERSION_HOSTQP: This version introduced host end point support | ||
| 354 | * for hosted products. | ||
| 355 | * | ||
| 356 | * VMCI_VERSION_PREHOSTQP: This is the version prior to the adoption of | ||
| 357 | * support for host end-points. | ||
| 358 | * | ||
| 359 | * VMCI_VERSION_PREVERS2: This fictional version number is intended to | ||
| 360 | * represent the version of a VMX which doesn't call into the driver | ||
| 361 | * with ioctl VERSION2 and thus doesn't establish its version with the | ||
| 362 | * driver. | ||
| 363 | */ | ||
| 364 | |||
| 365 | #define VMCI_VERSION VMCI_VERSION_NOVMVM | ||
| 366 | #define VMCI_VERSION_NOVMVM VMCI_MAKE_VERSION(11, 0) | ||
| 367 | #define VMCI_VERSION_NOTIFY VMCI_MAKE_VERSION(10, 0) | ||
| 368 | #define VMCI_VERSION_HOSTQP VMCI_MAKE_VERSION(9, 0) | ||
| 369 | #define VMCI_VERSION_PREHOSTQP VMCI_MAKE_VERSION(8, 0) | ||
| 370 | #define VMCI_VERSION_PREVERS2 VMCI_MAKE_VERSION(1, 0) | ||
| 371 | |||
| 372 | #define VMCI_SOCKETS_MAKE_VERSION(_p) \ | ||
| 373 | ((((_p)[0] & 0xFF) << 24) | (((_p)[1] & 0xFF) << 16) | ((_p)[2])) | ||
| 374 | |||
| 375 | /* | ||
| 376 | * The VMCI IOCTLs. We use identity code 7, as noted in ioctl-number.h, and | ||
| 377 | * we start at sequence 9f. This gives us the same values that our shipping | ||
| 378 | * products use, starting at 1951, provided we leave out the direction and | ||
| 379 | * structure size. Note that VMMon occupies the block following us, starting | ||
| 380 | * at 2001. | ||
| 381 | */ | ||
| 382 | #define IOCTL_VMCI_VERSION _IO(7, 0x9f) /* 1951 */ | ||
| 383 | #define IOCTL_VMCI_INIT_CONTEXT _IO(7, 0xa0) | ||
| 384 | #define IOCTL_VMCI_QUEUEPAIR_SETVA _IO(7, 0xa4) | ||
| 385 | #define IOCTL_VMCI_NOTIFY_RESOURCE _IO(7, 0xa5) | ||
| 386 | #define IOCTL_VMCI_NOTIFICATIONS_RECEIVE _IO(7, 0xa6) | ||
| 387 | #define IOCTL_VMCI_VERSION2 _IO(7, 0xa7) | ||
| 388 | #define IOCTL_VMCI_QUEUEPAIR_ALLOC _IO(7, 0xa8) | ||
| 389 | #define IOCTL_VMCI_QUEUEPAIR_SETPAGEFILE _IO(7, 0xa9) | ||
| 390 | #define IOCTL_VMCI_QUEUEPAIR_DETACH _IO(7, 0xaa) | ||
| 391 | #define IOCTL_VMCI_DATAGRAM_SEND _IO(7, 0xab) | ||
| 392 | #define IOCTL_VMCI_DATAGRAM_RECEIVE _IO(7, 0xac) | ||
| 393 | #define IOCTL_VMCI_CTX_ADD_NOTIFICATION _IO(7, 0xaf) | ||
| 394 | #define IOCTL_VMCI_CTX_REMOVE_NOTIFICATION _IO(7, 0xb0) | ||
| 395 | #define IOCTL_VMCI_CTX_GET_CPT_STATE _IO(7, 0xb1) | ||
| 396 | #define IOCTL_VMCI_CTX_SET_CPT_STATE _IO(7, 0xb2) | ||
| 397 | #define IOCTL_VMCI_GET_CONTEXT_ID _IO(7, 0xb3) | ||
| 398 | #define IOCTL_VMCI_SOCKETS_VERSION _IO(7, 0xb4) | ||
| 399 | #define IOCTL_VMCI_SOCKETS_GET_AF_VALUE _IO(7, 0xb8) | ||
| 400 | #define IOCTL_VMCI_SOCKETS_GET_LOCAL_CID _IO(7, 0xb9) | ||
| 401 | #define IOCTL_VMCI_SET_NOTIFY _IO(7, 0xcb) /* 1995 */ | ||
| 402 | /*IOCTL_VMMON_START _IO(7, 0xd1)*/ /* 2001 */ | ||
| 403 | |||
| 404 | /* | ||
| 405 | * struct vmci_queue_header - VMCI Queue Header information. | ||
| 406 | * | ||
| 407 | * A Queue cannot stand by itself as designed. Each Queue's header | ||
| 408 | * contains a pointer into itself (the producer_tail) and into its peer | ||
| 409 | * (consumer_head). The reason for the separation is one of | ||
| 410 | * accessibility: Each end-point can modify two things: where the next | ||
| 411 | * location to enqueue is within its produce_q (producer_tail); and | ||
| 412 | * where the next dequeue location is in its consume_q (consumer_head). | ||
| 413 | * | ||
| 414 | * An end-point cannot modify the pointers of its peer (guest to | ||
| 415 | * guest; NOTE that in the host both queue headers are mapped r/w). | ||
| 416 | * But, each end-point needs read access to both Queue header | ||
| 417 | * structures in order to determine how much space is used (or left) | ||
| 418 | * in the Queue. This is because for an end-point to know how full | ||
| 419 | * its produce_q is, it needs to use the consumer_head that points into | ||
| 420 | * the produce_q but -that- consumer_head is in the Queue header for | ||
| 421 | * that end-points consume_q. | ||
| 422 | * | ||
| 423 | * Thoroughly confused? Sorry. | ||
| 424 | * | ||
| 425 | * producer_tail: the point to enqueue new entrants. When you approach | ||
| 426 | * a line in a store, for example, you walk up to the tail. | ||
| 427 | * | ||
| 428 | * consumer_head: the point in the queue from which the next element is | ||
| 429 | * dequeued. In other words, who is next in line is he who is at the | ||
| 430 | * head of the line. | ||
| 431 | * | ||
| 432 | * Also, producer_tail points to an empty byte in the Queue, whereas | ||
| 433 | * consumer_head points to a valid byte of data (unless producer_tail == | ||
| 434 | * consumer_head in which case consumer_head does not point to a valid | ||
| 435 | * byte of data). | ||
| 436 | * | ||
| 437 | * For a queue of buffer 'size' bytes, the tail and head pointers will be in | ||
| 438 | * the range [0, size-1]. | ||
| 439 | * | ||
| 440 | * If produce_q_header->producer_tail == consume_q_header->consumer_head | ||
| 441 | * then the produce_q is empty. | ||
| 442 | */ | ||
| 443 | struct vmci_queue_header { | ||
| 444 | /* All fields are 64bit and aligned. */ | ||
| 445 | struct vmci_handle handle; /* Identifier. */ | ||
| 446 | atomic64_t producer_tail; /* Offset in this queue. */ | ||
| 447 | atomic64_t consumer_head; /* Offset in peer queue. */ | ||
| 448 | }; | ||
| 449 | |||
| 450 | /* | ||
| 451 | * struct vmci_datagram - Base struct for vmci datagrams. | ||
| 452 | * @dst: A vmci_handle that tracks the destination of the datagram. | ||
| 453 | * @src: A vmci_handle that tracks the source of the datagram. | ||
| 454 | * @payload_size: The size of the payload. | ||
| 455 | * | ||
| 456 | * vmci_datagram structs are used when sending vmci datagrams. They include | ||
| 457 | * the necessary source and destination information to properly route | ||
| 458 | * the information along with the size of the package. | ||
| 459 | */ | ||
| 460 | struct vmci_datagram { | ||
| 461 | struct vmci_handle dst; | ||
| 462 | struct vmci_handle src; | ||
| 463 | u64 payload_size; | ||
| 464 | }; | ||
| 465 | |||
| 466 | /* | ||
| 467 | * Second flag is for creating a well-known handle instead of a per context | ||
| 468 | * handle. Next flag is for deferring datagram delivery, so that the | ||
| 469 | * datagram callback is invoked in a delayed context (not interrupt context). | ||
| 470 | */ | ||
| 471 | #define VMCI_FLAG_DG_NONE 0 | ||
| 472 | #define VMCI_FLAG_WELLKNOWN_DG_HND 0x1 | ||
| 473 | #define VMCI_FLAG_ANYCID_DG_HND 0x2 | ||
| 474 | #define VMCI_FLAG_DG_DELAYED_CB 0x4 | ||
| 475 | |||
| 476 | /* | ||
| 477 | * Maximum supported size of a VMCI datagram for routable datagrams. | ||
| 478 | * Datagrams going to the hypervisor are allowed to be larger. | ||
| 479 | */ | ||
| 480 | #define VMCI_MAX_DG_SIZE (17 * 4096) | ||
| 481 | #define VMCI_MAX_DG_PAYLOAD_SIZE (VMCI_MAX_DG_SIZE - \ | ||
| 482 | sizeof(struct vmci_datagram)) | ||
| 483 | #define VMCI_DG_PAYLOAD(_dg) (void *)((char *)(_dg) + \ | ||
| 484 | sizeof(struct vmci_datagram)) | ||
| 485 | #define VMCI_DG_HEADERSIZE sizeof(struct vmci_datagram) | ||
| 486 | #define VMCI_DG_SIZE(_dg) (VMCI_DG_HEADERSIZE + (size_t)(_dg)->payload_size) | ||
| 487 | #define VMCI_DG_SIZE_ALIGNED(_dg) ((VMCI_DG_SIZE(_dg) + 7) & (~((size_t) 0x7))) | ||
| 488 | #define VMCI_MAX_DATAGRAM_QUEUE_SIZE (VMCI_MAX_DG_SIZE * 2) | ||
| 489 | |||
| 490 | struct vmci_event_payload_qp { | ||
| 491 | struct vmci_handle handle; /* queue_pair handle. */ | ||
| 492 | u32 peer_id; /* Context id of attaching/detaching VM. */ | ||
| 493 | u32 _pad; | ||
| 494 | }; | ||
| 495 | |||
| 496 | /* Flags for VMCI queue_pair API. */ | ||
| 497 | enum { | ||
| 498 | /* Fail alloc if QP not created by peer. */ | ||
| 499 | VMCI_QPFLAG_ATTACH_ONLY = 1 << 0, | ||
| 500 | |||
| 501 | /* Only allow attaches from local context. */ | ||
| 502 | VMCI_QPFLAG_LOCAL = 1 << 1, | ||
| 503 | |||
| 504 | /* Host won't block when guest is quiesced. */ | ||
| 505 | VMCI_QPFLAG_NONBLOCK = 1 << 2, | ||
| 506 | |||
| 507 | /* Pin data pages in ESX. Used with NONBLOCK */ | ||
| 508 | VMCI_QPFLAG_PINNED = 1 << 3, | ||
| 509 | |||
| 510 | /* Update the following flag when adding new flags. */ | ||
| 511 | VMCI_QP_ALL_FLAGS = (VMCI_QPFLAG_ATTACH_ONLY | VMCI_QPFLAG_LOCAL | | ||
| 512 | VMCI_QPFLAG_NONBLOCK | VMCI_QPFLAG_PINNED), | ||
| 513 | |||
| 514 | /* Convenience flags */ | ||
| 515 | VMCI_QP_ASYMM = (VMCI_QPFLAG_NONBLOCK | VMCI_QPFLAG_PINNED), | ||
| 516 | VMCI_QP_ASYMM_PEER = (VMCI_QPFLAG_ATTACH_ONLY | VMCI_QP_ASYMM), | ||
| 517 | }; | ||
| 518 | |||
| 519 | /* | ||
| 520 | * We allow at least 1024 more event datagrams from the hypervisor past the | ||
| 521 | * normally allowed datagrams pending for a given context. We define this | ||
| 522 | * limit on event datagrams from the hypervisor to guard against DoS attack | ||
| 523 | * from a malicious VM which could repeatedly attach to and detach from a queue | ||
| 524 | * pair, causing events to be queued at the destination VM. However, the rate | ||
| 525 | * at which such events can be generated is small since it requires a VM exit | ||
| 526 | * and handling of queue pair attach/detach call at the hypervisor. Event | ||
| 527 | * datagrams may be queued up at the destination VM if it has interrupts | ||
| 528 | * disabled or if it is not draining events for some other reason. 1024 | ||
| 529 | * datagrams is a grossly conservative estimate of the time for which | ||
| 530 | * interrupts may be disabled in the destination VM, but at the same time does | ||
| 531 | * not exacerbate the memory pressure problem on the host by much (size of each | ||
| 532 | * event datagram is small). | ||
| 533 | */ | ||
| 534 | #define VMCI_MAX_DATAGRAM_AND_EVENT_QUEUE_SIZE \ | ||
| 535 | (VMCI_MAX_DATAGRAM_QUEUE_SIZE + \ | ||
| 536 | 1024 * (sizeof(struct vmci_datagram) + \ | ||
| 537 | sizeof(struct vmci_event_data_max))) | ||
| 538 | |||
| 539 | /* | ||
| 540 | * Struct used for querying, via VMCI_RESOURCES_QUERY, the availability of | ||
| 541 | * hypervisor resources. Struct size is 16 bytes. All fields in struct are | ||
| 542 | * aligned to their natural alignment. | ||
| 543 | */ | ||
| 544 | struct vmci_resource_query_hdr { | ||
| 545 | struct vmci_datagram hdr; | ||
| 546 | u32 num_resources; | ||
| 547 | u32 _padding; | ||
| 548 | }; | ||
| 549 | |||
| 550 | /* | ||
| 551 | * Convenience struct for negotiating vectors. Must match layout of | ||
| 552 | * VMCIResourceQueryHdr minus the struct vmci_datagram header. | ||
| 553 | */ | ||
| 554 | struct vmci_resource_query_msg { | ||
| 555 | u32 num_resources; | ||
| 556 | u32 _padding; | ||
| 557 | u32 resources[1]; | ||
| 558 | }; | ||
| 559 | |||
| 560 | /* | ||
| 561 | * The maximum number of resources that can be queried using | ||
| 562 | * VMCI_RESOURCE_QUERY is 31, as the result is encoded in the lower 31 | ||
| 563 | * bits of a positive return value. Negative values are reserved for | ||
| 564 | * errors. | ||
| 565 | */ | ||
| 566 | #define VMCI_RESOURCE_QUERY_MAX_NUM 31 | ||
| 567 | |||
| 568 | /* Maximum size for the VMCI_RESOURCE_QUERY request. */ | ||
| 569 | #define VMCI_RESOURCE_QUERY_MAX_SIZE \ | ||
| 570 | (sizeof(struct vmci_resource_query_hdr) + \ | ||
| 571 | sizeof(u32) * VMCI_RESOURCE_QUERY_MAX_NUM) | ||
| 572 | |||
| 573 | /* | ||
| 574 | * Struct used for setting the notification bitmap. All fields in | ||
| 575 | * struct are aligned to their natural alignment. | ||
| 576 | */ | ||
| 577 | struct vmci_notify_bm_set_msg { | ||
| 578 | struct vmci_datagram hdr; | ||
| 579 | u32 bitmap_ppn; | ||
| 580 | u32 _pad; | ||
| 581 | }; | ||
| 582 | |||
| 583 | /* | ||
| 584 | * Struct used for linking a doorbell handle with an index in the | ||
| 585 | * notify bitmap. All fields in struct are aligned to their natural | ||
| 586 | * alignment. | ||
| 587 | */ | ||
| 588 | struct vmci_doorbell_link_msg { | ||
| 589 | struct vmci_datagram hdr; | ||
| 590 | struct vmci_handle handle; | ||
| 591 | u64 notify_idx; | ||
| 592 | }; | ||
| 593 | |||
| 594 | /* | ||
| 595 | * Struct used for unlinking a doorbell handle from an index in the | ||
| 596 | * notify bitmap. All fields in struct are aligned to their natural | ||
| 597 | * alignment. | ||
| 598 | */ | ||
| 599 | struct vmci_doorbell_unlink_msg { | ||
| 600 | struct vmci_datagram hdr; | ||
| 601 | struct vmci_handle handle; | ||
| 602 | }; | ||
| 603 | |||
| 604 | /* | ||
| 605 | * Struct used for generating a notification on a doorbell handle. All | ||
| 606 | * fields in struct are aligned to their natural alignment. | ||
| 607 | */ | ||
| 608 | struct vmci_doorbell_notify_msg { | ||
| 609 | struct vmci_datagram hdr; | ||
| 610 | struct vmci_handle handle; | ||
| 611 | }; | ||
| 612 | |||
| 613 | /* | ||
| 614 | * This struct is used to contain data for events. Size of this struct is a | ||
| 615 | * multiple of 8 bytes, and all fields are aligned to their natural alignment. | ||
| 616 | */ | ||
| 617 | struct vmci_event_data { | ||
| 618 | u32 event; /* 4 bytes. */ | ||
| 619 | u32 _pad; | ||
| 620 | /* Event payload is put here. */ | ||
| 621 | }; | ||
| 622 | |||
| 623 | /* | ||
| 624 | * Define the different VMCI_EVENT payload data types here. All structs must | ||
| 625 | * be a multiple of 8 bytes, and fields must be aligned to their natural | ||
| 626 | * alignment. | ||
| 627 | */ | ||
| 628 | struct vmci_event_payld_ctx { | ||
| 629 | u32 context_id; /* 4 bytes. */ | ||
| 630 | u32 _pad; | ||
| 631 | }; | ||
| 632 | |||
| 633 | struct vmci_event_payld_qp { | ||
| 634 | struct vmci_handle handle; /* queue_pair handle. */ | ||
| 635 | u32 peer_id; /* Context id of attaching/detaching VM. */ | ||
| 636 | u32 _pad; | ||
| 637 | }; | ||
| 638 | |||
| 639 | /* | ||
| 640 | * We define the following struct to get the size of the maximum event | ||
| 641 | * data the hypervisor may send to the guest. If adding a new event | ||
| 642 | * payload type above, add it to the following struct too (inside the | ||
| 643 | * union). | ||
| 644 | */ | ||
| 645 | struct vmci_event_data_max { | ||
| 646 | struct vmci_event_data event_data; | ||
| 647 | union { | ||
| 648 | struct vmci_event_payld_ctx context_payload; | ||
| 649 | struct vmci_event_payld_qp qp_payload; | ||
| 650 | } ev_data_payload; | ||
| 651 | }; | ||
| 652 | |||
| 653 | /* | ||
| 654 | * Struct used for VMCI_EVENT_SUBSCRIBE/UNSUBSCRIBE and | ||
| 655 | * VMCI_EVENT_HANDLER messages. Struct size is 32 bytes. All fields | ||
| 656 | * in struct are aligned to their natural alignment. | ||
| 657 | */ | ||
| 658 | struct vmci_event_msg { | ||
| 659 | struct vmci_datagram hdr; | ||
| 660 | |||
| 661 | /* Has event type and payload. */ | ||
| 662 | struct vmci_event_data event_data; | ||
| 663 | |||
| 664 | /* Payload gets put here. */ | ||
| 665 | }; | ||
| 666 | |||
| 667 | /* Event with context payload. */ | ||
| 668 | struct vmci_event_ctx { | ||
| 669 | struct vmci_event_msg msg; | ||
| 670 | struct vmci_event_payld_ctx payload; | ||
| 671 | }; | ||
| 672 | |||
| 673 | /* Event with QP payload. */ | ||
| 674 | struct vmci_event_qp { | ||
| 675 | struct vmci_event_msg msg; | ||
| 676 | struct vmci_event_payld_qp payload; | ||
| 677 | }; | ||
| 678 | |||
| 679 | /* | ||
| 680 | * Structs used for queue_pair alloc and detach messages. We align fields of | ||
| 681 | * these structs to 64bit boundaries. | ||
| 682 | */ | ||
| 683 | struct vmci_qp_alloc_msg { | ||
| 684 | struct vmci_datagram hdr; | ||
| 685 | struct vmci_handle handle; | ||
| 686 | u32 peer; | ||
| 687 | u32 flags; | ||
| 688 | u64 produce_size; | ||
| 689 | u64 consume_size; | ||
| 690 | u64 num_ppns; | ||
| 691 | |||
| 692 | /* List of PPNs placed here. */ | ||
| 693 | }; | ||
| 694 | |||
| 695 | struct vmci_qp_detach_msg { | ||
| 696 | struct vmci_datagram hdr; | ||
| 697 | struct vmci_handle handle; | ||
| 698 | }; | ||
| 699 | |||
| 700 | /* VMCI Doorbell API. */ | ||
| 701 | #define VMCI_FLAG_DELAYED_CB 0x01 | ||
| 702 | |||
| 703 | typedef void (*vmci_callback) (void *client_data); | ||
| 704 | |||
| 705 | /* | ||
| 706 | * struct vmci_qp - A vmw_vmci queue pair handle. | ||
| 707 | * | ||
| 708 | * This structure is used as a handle to a queue pair created by | ||
| 709 | * VMCI. It is intentionally left opaque to clients. | ||
| 710 | */ | ||
| 711 | struct vmci_qp; | ||
| 712 | |||
| 713 | /* Callback needed for correctly waiting on events. */ | ||
| 714 | typedef int (*vmci_datagram_recv_cb) (void *client_data, | ||
| 715 | struct vmci_datagram *msg); | ||
| 716 | |||
| 717 | /* VMCI Event API. */ | ||
| 718 | typedef void (*vmci_event_cb) (u32 sub_id, const struct vmci_event_data *ed, | ||
| 719 | void *client_data); | ||
| 720 | |||
| 721 | /* | ||
| 722 | * We use the following inline function to access the payload data | ||
| 723 | * associated with an event data. | ||
| 724 | */ | ||
| 725 | static inline const void * | ||
| 726 | vmci_event_data_const_payload(const struct vmci_event_data *ev_data) | ||
| 727 | { | ||
| 728 | return (const char *)ev_data + sizeof(*ev_data); | ||
| 729 | } | ||
| 730 | |||
| 731 | static inline void *vmci_event_data_payload(struct vmci_event_data *ev_data) | ||
| 732 | { | ||
| 733 | return (void *)vmci_event_data_const_payload(ev_data); | ||
| 734 | } | ||
| 735 | |||
| 736 | /* | ||
| 737 | * Helper to add a given offset to a head or tail pointer. Wraps the | ||
| 738 | * value of the pointer around the max size of the queue. | ||
| 739 | */ | ||
| 740 | static inline void vmci_qp_add_pointer(atomic64_t *var, | ||
| 741 | size_t add, | ||
| 742 | u64 size) | ||
| 743 | { | ||
| 744 | u64 new_val = atomic64_read(var); | ||
| 745 | |||
| 746 | if (new_val >= size - add) | ||
| 747 | new_val -= size; | ||
| 748 | |||
| 749 | new_val += add; | ||
| 750 | |||
| 751 | atomic64_set(var, new_val); | ||
| 752 | } | ||
| 753 | |||
| 754 | /* | ||
| 755 | * Helper routine to get the Producer Tail from the supplied queue. | ||
| 756 | */ | ||
| 757 | static inline u64 | ||
| 758 | vmci_q_header_producer_tail(const struct vmci_queue_header *q_header) | ||
| 759 | { | ||
| 760 | struct vmci_queue_header *qh = (struct vmci_queue_header *)q_header; | ||
| 761 | return atomic64_read(&qh->producer_tail); | ||
| 762 | } | ||
| 763 | |||
| 764 | /* | ||
| 765 | * Helper routine to get the Consumer Head from the supplied queue. | ||
| 766 | */ | ||
| 767 | static inline u64 | ||
| 768 | vmci_q_header_consumer_head(const struct vmci_queue_header *q_header) | ||
| 769 | { | ||
| 770 | struct vmci_queue_header *qh = (struct vmci_queue_header *)q_header; | ||
| 771 | return atomic64_read(&qh->consumer_head); | ||
| 772 | } | ||
| 773 | |||
| 774 | /* | ||
| 775 | * Helper routine to increment the Producer Tail. Fundamentally, | ||
| 776 | * vmci_qp_add_pointer() is used to manipulate the tail itself. | ||
| 777 | */ | ||
| 778 | static inline void | ||
| 779 | vmci_q_header_add_producer_tail(struct vmci_queue_header *q_header, | ||
| 780 | size_t add, | ||
| 781 | u64 queue_size) | ||
| 782 | { | ||
| 783 | vmci_qp_add_pointer(&q_header->producer_tail, add, queue_size); | ||
| 784 | } | ||
| 785 | |||
| 786 | /* | ||
| 787 | * Helper routine to increment the Consumer Head. Fundamentally, | ||
| 788 | * vmci_qp_add_pointer() is used to manipulate the head itself. | ||
| 789 | */ | ||
| 790 | static inline void | ||
| 791 | vmci_q_header_add_consumer_head(struct vmci_queue_header *q_header, | ||
| 792 | size_t add, | ||
| 793 | u64 queue_size) | ||
| 794 | { | ||
| 795 | vmci_qp_add_pointer(&q_header->consumer_head, add, queue_size); | ||
| 796 | } | ||
| 797 | |||
| 798 | /* | ||
| 799 | * Helper routine for getting the head and the tail pointer for a queue. | ||
| 800 | * Both the VMCIQueues are needed to get both the pointers for one queue. | ||
| 801 | */ | ||
| 802 | static inline void | ||
| 803 | vmci_q_header_get_pointers(const struct vmci_queue_header *produce_q_header, | ||
| 804 | const struct vmci_queue_header *consume_q_header, | ||
| 805 | u64 *producer_tail, | ||
| 806 | u64 *consumer_head) | ||
| 807 | { | ||
| 808 | if (producer_tail) | ||
| 809 | *producer_tail = vmci_q_header_producer_tail(produce_q_header); | ||
| 810 | |||
| 811 | if (consumer_head) | ||
| 812 | *consumer_head = vmci_q_header_consumer_head(consume_q_header); | ||
| 813 | } | ||
| 814 | |||
| 815 | static inline void vmci_q_header_init(struct vmci_queue_header *q_header, | ||
| 816 | const struct vmci_handle handle) | ||
| 817 | { | ||
| 818 | q_header->handle = handle; | ||
| 819 | atomic64_set(&q_header->producer_tail, 0); | ||
| 820 | atomic64_set(&q_header->consumer_head, 0); | ||
| 821 | } | ||
| 822 | |||
| 823 | /* | ||
| 824 | * Finds available free space in a produce queue to enqueue more | ||
| 825 | * data or reports an error if queue pair corruption is detected. | ||
| 826 | */ | ||
| 827 | static s64 | ||
| 828 | vmci_q_header_free_space(const struct vmci_queue_header *produce_q_header, | ||
| 829 | const struct vmci_queue_header *consume_q_header, | ||
| 830 | const u64 produce_q_size) | ||
| 831 | { | ||
| 832 | u64 tail; | ||
| 833 | u64 head; | ||
| 834 | u64 free_space; | ||
| 835 | |||
| 836 | tail = vmci_q_header_producer_tail(produce_q_header); | ||
| 837 | head = vmci_q_header_consumer_head(consume_q_header); | ||
| 838 | |||
| 839 | if (tail >= produce_q_size || head >= produce_q_size) | ||
| 840 | return VMCI_ERROR_INVALID_SIZE; | ||
| 841 | |||
| 842 | /* | ||
| 843 | * Deduct 1 to avoid tail becoming equal to head which causes | ||
| 844 | * ambiguity. If head and tail are equal it means that the | ||
| 845 | * queue is empty. | ||
| 846 | */ | ||
| 847 | if (tail >= head) | ||
| 848 | free_space = produce_q_size - (tail - head) - 1; | ||
| 849 | else | ||
| 850 | free_space = head - tail - 1; | ||
| 851 | |||
| 852 | return free_space; | ||
| 853 | } | ||
| 854 | |||
| 855 | /* | ||
| 856 | * vmci_q_header_free_space() does all the heavy lifting of | ||
| 857 | * determing the number of free bytes in a Queue. This routine, | ||
| 858 | * then subtracts that size from the full size of the Queue so | ||
| 859 | * the caller knows how many bytes are ready to be dequeued. | ||
| 860 | * Results: | ||
| 861 | * On success, available data size in bytes (up to MAX_INT64). | ||
| 862 | * On failure, appropriate error code. | ||
| 863 | */ | ||
| 864 | static inline s64 | ||
| 865 | vmci_q_header_buf_ready(const struct vmci_queue_header *consume_q_header, | ||
| 866 | const struct vmci_queue_header *produce_q_header, | ||
| 867 | const u64 consume_q_size) | ||
| 868 | { | ||
| 869 | s64 free_space; | ||
| 870 | |||
| 871 | free_space = vmci_q_header_free_space(consume_q_header, | ||
| 872 | produce_q_header, consume_q_size); | ||
| 873 | if (free_space < VMCI_SUCCESS) | ||
| 874 | return free_space; | ||
| 875 | |||
| 876 | return consume_q_size - free_space - 1; | ||
| 877 | } | ||
| 878 | |||
| 879 | |||
| 880 | #endif /* _VMW_VMCI_DEF_H_ */ | ||
