2 Private data structures for the I2C DXE driver.
4 This file defines common data structures, macro definitions and some module
5 internal function header files.
7 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/DevicePathLib.h>
19 #include <Library/MemoryAllocationLib.h>
20 #include <Library/TimerLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/UefiLib.h>
25 #include <Protocol/DriverBinding.h>
26 #include <Protocol/I2cEnumerate.h>
27 #include <Protocol/I2cHost.h>
28 #include <Protocol/I2cIo.h>
29 #include <Protocol/I2cMaster.h>
30 #include <Protocol/I2cBusConfigurationManagement.h>
31 #include <Protocol/LoadedImage.h>
33 #define I2C_DEVICE_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'D')
34 #define I2C_HOST_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'H')
35 #define I2C_REQUEST_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'R')
38 // Synchronize access to the list of requests
40 #define TPL_I2C_SYNC TPL_NOTIFY
46 EFI_I2C_ENUMERATE_PROTOCOL
*I2cEnumerate
;
47 EFI_I2C_HOST_PROTOCOL
*I2cHost
;
48 EFI_HANDLE Controller
;
49 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
50 EFI_HANDLE DriverBindingHandle
;
58 // Structure identification
68 // Upper level API to support the I2C device I/O
70 EFI_I2C_IO_PROTOCOL I2cIo
;
73 // Device path for this device
75 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
78 // Platform specific data for this device
80 CONST EFI_I2C_DEVICE
*I2cDevice
;
83 // Context for the common I/O support including the
84 // lower level API to the host controller.
86 I2C_BUS_CONTEXT
*I2cBusContext
;
89 #define I2C_DEVICE_CONTEXT_FROM_PROTOCOL(a) CR (a, I2C_DEVICE_CONTEXT, I2cIo, I2C_DEVICE_SIGNATURE)
101 // Next request in the pending request list
106 // I2C bus configuration for the operation
108 UINTN I2cBusConfiguration
;
111 // I2C slave address for the operation
116 // Event to set for asynchronous operations, NULL for
117 // synchronous operations
122 // I2C operation description
124 EFI_I2C_REQUEST_PACKET
*RequestPacket
;
127 // Optional buffer to receive the I2C operation completion status
132 #define I2C_REQUEST_FROM_ENTRY(a) CR (a, I2C_REQUEST, Link, I2C_REQUEST_SIGNATURE);
139 // Structure identification
144 // Current I2C bus configuration
146 UINTN I2cBusConfiguration
;
149 // I2C bus configuration management event
151 EFI_EVENT I2cBusConfigurationEvent
;
154 // I2C operation completion event
159 // I2C operation and I2C bus configuration management status
164 // I2C bus configuration management operation pending
166 BOOLEAN I2cBusConfigurationManagementPending
;
169 // I2C request list maintained by I2C Host
171 LIST_ENTRY RequestList
;
176 EFI_I2C_HOST_PROTOCOL I2cHost
;
179 // I2C bus configuration management protocol
181 EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL
*I2cBusConfigurationManagement
;
184 // Lower level API for I2C master (controller)
186 EFI_I2C_MASTER_PROTOCOL
*I2cMaster
;
189 #define I2C_HOST_CONTEXT_FROM_PROTOCOL(a) CR (a, I2C_HOST_CONTEXT, I2cHost, I2C_HOST_SIGNATURE)
194 extern EFI_COMPONENT_NAME_PROTOCOL gI2cBusComponentName
;
195 extern EFI_COMPONENT_NAME2_PROTOCOL gI2cBusComponentName2
;
196 extern EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding
;
198 extern EFI_COMPONENT_NAME_PROTOCOL gI2cHostComponentName
;
199 extern EFI_COMPONENT_NAME2_PROTOCOL gI2cHostComponentName2
;
200 extern EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding
;
205 This routine allocates the necessary resources for the driver.
207 This routine is called by I2cBusDriverStart to complete the driver
210 @param[in] I2cBus Address of an I2C_BUS_CONTEXT structure
211 @param[in] Controller Handle to the controller
212 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
214 @retval EFI_SUCCESS Driver API properly initialized
219 IN I2C_BUS_CONTEXT
*I2cBus
,
220 IN EFI_HANDLE Controller
,
221 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
225 Unregister an I2C device.
227 This function removes the protocols installed on the controller handle and
228 frees the resources allocated for the I2C device.
230 @param This The pointer to EFI_DRIVER_BINDING_PROTOCOL instance.
231 @param Controller The controller handle of the I2C device.
232 @param Handle The child handle.
234 @retval EFI_SUCCESS The I2C device is successfully unregistered.
235 @return Others Some error occurs when unregistering the I2C device.
239 UnRegisterI2cDevice (
240 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
241 IN EFI_HANDLE Controller
,
246 Create a path for the I2C device
248 Append the I2C slave path to the I2C master controller path.
250 @param[in] I2cDeviceContext Address of an I2C_DEVICE_CONTEXT structure.
251 @param[in] BuildControllerNode Flag to build controller node in device path.
253 @retval EFI_SUCCESS The I2C device path is built successfully.
254 @return Others It is failed to built device path.
258 I2cBusDevicePathAppend (
259 IN I2C_DEVICE_CONTEXT
*I2cDeviceContext
,
260 IN BOOLEAN BuildControllerNode
264 Queue an I2C transaction for execution on the I2C device.
266 This routine must be called at or below TPL_NOTIFY. For synchronous
267 requests this routine must be called at or below TPL_CALLBACK.
269 This routine queues an I2C transaction to the I2C controller for
270 execution on the I2C bus.
272 When Event is NULL, QueueRequest() operates synchronously and returns
273 the I2C completion status as its return value.
275 When Event is not NULL, QueueRequest() synchronously returns EFI_SUCCESS
276 indicating that the asynchronous I2C transaction was queued. The values
277 above are returned in the buffer pointed to by I2cStatus upon the
278 completion of the I2C transaction when I2cStatus is not NULL.
280 The upper layer driver writer provides the following to the platform
283 1. Vendor specific GUID for the I2C part
284 2. Guidance on proper construction of the slave address array when the
285 I2C device uses more than one slave address. The I2C bus protocol
286 uses the SlaveAddressIndex to perform relative to physical address
287 translation to access the blocks of hardware within the I2C device.
289 @param[in] This Pointer to an EFI_I2C_IO_PROTOCOL structure.
290 @param[in] SlaveAddressIndex Index value into an array of slave addresses
291 for the I2C device. The values in the array
292 are specified by the board designer, with the
293 third party I2C device driver writer providing
294 the slave address order.
296 For devices that have a single slave address,
297 this value must be zero. If the I2C device
298 uses more than one slave address then the
299 third party (upper level) I2C driver writer
300 needs to specify the order of entries in the
303 \ref ThirdPartyI2cDrivers "Third Party I2C
304 Drivers" section in I2cMaster.h.
305 @param[in] Event Event to signal for asynchronous transactions,
306 NULL for synchronous transactions
307 @param[in] RequestPacket Pointer to an EFI_I2C_REQUEST_PACKET structure
308 describing the I2C transaction
309 @param[out] I2cStatus Optional buffer to receive the I2C transaction
312 @retval EFI_SUCCESS The asynchronous transaction was successfully
313 queued when Event is not NULL.
314 @retval EFI_SUCCESS The transaction completed successfully when
316 @retval EFI_ABORTED The request did not complete because the driver
317 binding Stop() routine was called.
318 @retval EFI_BAD_BUFFER_SIZE The RequestPacket->LengthInBytes value is too
320 @retval EFI_DEVICE_ERROR There was an I2C error (NACK) during the
322 @retval EFI_INVALID_PARAMETER RequestPacket is NULL
323 @retval EFI_NOT_FOUND Reserved bit set in the SlaveAddress parameter
324 @retval EFI_NO_MAPPING The EFI_I2C_HOST_PROTOCOL could not set the
325 bus configuration required to access this I2C
327 @retval EFI_NO_RESPONSE The I2C device is not responding to the slave
328 address selected by SlaveAddressIndex.
329 EFI_DEVICE_ERROR will be returned if the
330 controller cannot distinguish when the NACK
332 @retval EFI_OUT_OF_RESOURCES Insufficient memory for I2C transaction
333 @retval EFI_UNSUPPORTED The controller does not support the requested
340 IN CONST EFI_I2C_IO_PROTOCOL
*This
,
341 IN UINTN SlaveAddressIndex
,
342 IN EFI_EVENT Event OPTIONAL
,
343 IN EFI_I2C_REQUEST_PACKET
*RequestPacket
,
344 OUT EFI_STATUS
*I2cStatus OPTIONAL
348 Tests to see if this driver supports a given controller. If a child device is provided,
349 it further tests to see if this driver supports creating a handle for the specified child device.
351 This function checks to see if the driver specified by This supports the device specified by
352 ControllerHandle. Drivers will typically use the device path attached to
353 ControllerHandle and/or the services from the bus I/O abstraction attached to
354 ControllerHandle to determine if the driver supports ControllerHandle. This function
355 may be called many times during platform initialization. In order to reduce boot times, the tests
356 performed by this function must be very small, and take as little time as possible to execute. This
357 function must not change the state of any hardware devices, and this function must be aware that the
358 device specified by ControllerHandle may already be managed by the same driver or a
359 different driver. This function must match its calls to AllocatePages() with FreePages(),
360 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
361 Since ControllerHandle may have been previously started by the same driver, if a protocol is
362 already in the opened state, then it must not be closed with CloseProtocol(). This is required
363 to guarantee the state of ControllerHandle is not modified by this function.
365 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
366 @param[in] ControllerHandle The handle of the controller to test. This handle
367 must support a protocol interface that supplies
368 an I/O abstraction to the driver.
369 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
370 parameter is ignored by device drivers, and is optional for bus
371 drivers. For bus drivers, if this parameter is not NULL, then
372 the bus driver must determine if the bus controller specified
373 by ControllerHandle and the child controller specified
374 by RemainingDevicePath are both supported by this
377 @retval EFI_SUCCESS The device specified by ControllerHandle and
378 RemainingDevicePath is supported by the driver specified by This.
379 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
380 RemainingDevicePath is already being managed by the driver
382 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
383 RemainingDevicePath is already being managed by a different
384 driver or an application that requires exclusive access.
385 Currently not implemented.
386 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
387 RemainingDevicePath is not supported by the driver specified by This.
391 I2cBusDriverSupported (
392 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
393 IN EFI_HANDLE Controller
,
394 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
398 Starts a device controller or a bus controller.
400 The Start() function is designed to be invoked from the EFI boot service ConnectController().
401 As a result, much of the error checking on the parameters to Start() has been moved into this
402 common boot service. It is legal to call Start() from other locations,
403 but the following calling restrictions must be followed or the system behavior will not be deterministic.
404 1. ControllerHandle must be a valid EFI_HANDLE.
405 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
406 EFI_DEVICE_PATH_PROTOCOL.
407 3. Prior to calling Start(), the Supported() function for the driver specified by This must
408 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
410 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
411 @param[in] ControllerHandle The handle of the controller to start. This handle
412 must support a protocol interface that supplies
413 an I/O abstraction to the driver.
414 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
415 parameter is ignored by device drivers, and is optional for bus
416 drivers. For a bus driver, if this parameter is NULL, then handles
417 for all the children of Controller are created by this driver.
418 If this parameter is not NULL and the first Device Path Node is
419 not the End of Device Path Node, then only the handle for the
420 child device specified by the first Device Path Node of
421 RemainingDevicePath is created by this driver.
422 If the first Device Path Node of RemainingDevicePath is
423 the End of Device Path Node, no child handle is created by this
426 @retval EFI_SUCCESS The device was started.
427 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
428 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
429 @retval Others The driver failded to start the device.
435 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
436 IN EFI_HANDLE Controller
,
437 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
441 Stops a device controller or a bus controller.
443 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
444 As a result, much of the error checking on the parameters to Stop() has been moved
445 into this common boot service. It is legal to call Stop() from other locations,
446 but the following calling restrictions must be followed or the system behavior will not be deterministic.
447 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
448 same driver's Start() function.
449 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
450 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
451 Start() function, and the Start() function must have called OpenProtocol() on
452 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
454 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
455 @param[in] ControllerHandle A handle to the device being stopped. The handle must
456 support a bus specific I/O protocol for the driver
457 to use to stop the device.
458 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
459 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
460 if NumberOfChildren is 0.
462 @retval EFI_SUCCESS The device was stopped.
463 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
469 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
470 IN EFI_HANDLE Controller
,
471 IN UINTN NumberOfChildren
,
472 IN EFI_HANDLE
*ChildHandleBuffer
476 Retrieves a Unicode string that is the user readable name of the driver.
478 This function retrieves the user readable name of a driver in the form of a
479 Unicode string. If the driver specified by This has a user readable name in
480 the language specified by Language, then a pointer to the driver name is
481 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
482 by This does not support the language specified by Language,
483 then EFI_UNSUPPORTED is returned.
485 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
486 EFI_COMPONENT_NAME_PROTOCOL instance.
488 @param Language[in] A pointer to a Null-terminated ASCII string
489 array indicating the language. This is the
490 language of the driver name that the caller is
491 requesting, and it must match one of the
492 languages specified in SupportedLanguages. The
493 number of languages supported by a driver is up
494 to the driver writer. Language is specified
495 in RFC 4646 or ISO 639-2 language code format.
497 @param DriverName[out] A pointer to the Unicode string to return.
498 This Unicode string is the name of the
499 driver specified by This in the language
500 specified by Language.
502 @retval EFI_SUCCESS The Unicode string for the Driver specified by
503 This and the language specified by Language was
504 returned in DriverName.
506 @retval EFI_INVALID_PARAMETER Language is NULL.
508 @retval EFI_INVALID_PARAMETER DriverName is NULL.
510 @retval EFI_UNSUPPORTED The driver specified by This does not support
511 the language specified by Language.
516 I2cBusComponentNameGetDriverName (
517 IN EFI_COMPONENT_NAME2_PROTOCOL
*This
,
519 OUT CHAR16
**DriverName
523 Retrieves a Unicode string that is the user readable name of the controller
524 that is being managed by a driver.
526 This function retrieves the user readable name of the controller specified by
527 ControllerHandle and ChildHandle in the form of a Unicode string. If the
528 driver specified by This has a user readable name in the language specified by
529 Language, then a pointer to the controller name is returned in ControllerName,
530 and EFI_SUCCESS is returned. If the driver specified by This is not currently
531 managing the controller specified by ControllerHandle and ChildHandle,
532 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
533 support the language specified by Language, then EFI_UNSUPPORTED is returned.
535 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
536 EFI_COMPONENT_NAME_PROTOCOL instance.
538 @param ControllerHandle[in] The handle of a controller that the driver
539 specified by This is managing. This handle
540 specifies the controller whose name is to be
543 @param ChildHandle[in] The handle of the child controller to retrieve
544 the name of. This is an optional parameter that
545 may be NULL. It will be NULL for device
546 drivers. It will also be NULL for a bus drivers
547 that wish to retrieve the name of the bus
548 controller. It will not be NULL for a bus
549 driver that wishes to retrieve the name of a
552 @param Language[in] A pointer to a Null-terminated ASCII string
553 array indicating the language. This is the
554 language of the driver name that the caller is
555 requesting, and it must match one of the
556 languages specified in SupportedLanguages. The
557 number of languages supported by a driver is up
558 to the driver writer. Language is specified in
559 RFC 4646 or ISO 639-2 language code format.
561 @param ControllerName[out] A pointer to the Unicode string to return.
562 This Unicode string is the name of the
563 controller specified by ControllerHandle and
564 ChildHandle in the language specified by
565 Language from the point of view of the driver
568 @retval EFI_SUCCESS The Unicode string for the user readable name in
569 the language specified by Language for the
570 driver specified by This was returned in
573 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
575 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
578 @retval EFI_INVALID_PARAMETER Language is NULL.
580 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
582 @retval EFI_UNSUPPORTED The driver specified by This is not currently
583 managing the controller specified by
584 ControllerHandle and ChildHandle.
586 @retval EFI_UNSUPPORTED The driver specified by This does not support
587 the language specified by Language.
592 I2cBusComponentNameGetControllerName (
593 IN EFI_COMPONENT_NAME2_PROTOCOL
*This
,
594 IN EFI_HANDLE ControllerHandle
,
595 IN EFI_HANDLE ChildHandle OPTIONAL
,
597 OUT CHAR16
**ControllerName
601 The user entry point for the I2C bus module. The user code starts with
604 @param[in] ImageHandle The firmware allocated handle for the EFI image.
605 @param[in] SystemTable A pointer to the EFI System Table.
607 @retval EFI_SUCCESS The entry point is executed successfully.
608 @retval other Some error occurs when executing this entry point.
614 IN EFI_HANDLE ImageHandle
,
615 IN EFI_SYSTEM_TABLE
*SystemTable
619 This is the unload handle for I2C bus module.
621 Disconnect the driver specified by ImageHandle from all the devices in the handle database.
622 Uninstall all the protocols installed in the driver entry point.
624 @param[in] ImageHandle The drivers' driver image.
626 @retval EFI_SUCCESS The image is unloaded.
627 @retval Others Failed to unload the image.
633 IN EFI_HANDLE ImageHandle
637 Release all the resources allocated for the I2C device.
639 This function releases all the resources allocated for the I2C device.
641 @param I2cDeviceContext The I2C child device involved for the operation.
645 ReleaseI2cDeviceContext (
646 IN I2C_DEVICE_CONTEXT
*I2cDeviceContext
650 Complete the current request
652 @param[in] I2cHost Address of an I2C_HOST_CONTEXT structure.
653 @param[in] Status Status of the I<sub>2</sub>C operation.
655 @return This routine returns the input status value.
659 I2cHostRequestComplete (
660 I2C_HOST_CONTEXT
*I2cHost
,
665 Enable access to the I2C bus configuration
667 @param[in] I2cHostContext Address of an I2C_HOST_CONTEXT structure
669 @retval EFI_SUCCESS The operation completed successfully.
670 @retval EFI_ABORTED The request did not complete because the driver
672 @retval EFI_BAD_BUFFER_SIZE The WriteBytes or ReadBytes buffer size is too large.
673 @retval EFI_DEVICE_ERROR There was an I2C error (NACK) during the operation.
674 This could indicate the slave device is not present.
675 @retval EFI_INVALID_PARAMETER RequestPacket is NULL
676 @retval EFI_NO_MAPPING Invalid I2cBusConfiguration value
677 @retval EFI_NO_RESPONSE The I2C device is not responding to the
678 slave address. EFI_DEVICE_ERROR may also be
679 returned if the controller can not distinguish
680 when the NACK occurred.
681 @retval EFI_NOT_FOUND I2C slave address exceeds maximum address
682 @retval EFI_NOT_READY I2C bus is busy or operation pending, wait for
683 the event and then read status.
684 @retval EFI_OUT_OF_RESOURCES Insufficient memory for I2C operation
685 @retval EFI_TIMEOUT The transaction did not complete within an internally
686 specified timeout period.
690 I2cHostRequestEnable (
691 I2C_HOST_CONTEXT
*I2cHost
695 Tests to see if this driver supports a given controller. If a child device is provided,
696 it further tests to see if this driver supports creating a handle for the specified child device.
698 This function checks to see if the driver specified by This supports the device specified by
699 ControllerHandle. Drivers will typically use the device path attached to
700 ControllerHandle and/or the services from the bus I/O abstraction attached to
701 ControllerHandle to determine if the driver supports ControllerHandle. This function
702 may be called many times during platform initialization. In order to reduce boot times, the tests
703 performed by this function must be very small, and take as little time as possible to execute. This
704 function must not change the state of any hardware devices, and this function must be aware that the
705 device specified by ControllerHandle may already be managed by the same driver or a
706 different driver. This function must match its calls to AllocatePages() with FreePages(),
707 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
708 Since ControllerHandle may have been previously started by the same driver, if a protocol is
709 already in the opened state, then it must not be closed with CloseProtocol(). This is required
710 to guarantee the state of ControllerHandle is not modified by this function.
712 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
713 @param[in] ControllerHandle The handle of the controller to test. This handle
714 must support a protocol interface that supplies
715 an I/O abstraction to the driver.
716 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
717 parameter is ignored by device drivers, and is optional for bus
718 drivers. For bus drivers, if this parameter is not NULL, then
719 the bus driver must determine if the bus controller specified
720 by ControllerHandle and the child controller specified
721 by RemainingDevicePath are both supported by this
724 @retval EFI_SUCCESS The device specified by ControllerHandle and
725 RemainingDevicePath is supported by the driver specified by This.
726 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
727 RemainingDevicePath is already being managed by the driver
729 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
730 RemainingDevicePath is already being managed by a different
731 driver or an application that requires exclusive access.
732 Currently not implemented.
733 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
734 RemainingDevicePath is not supported by the driver specified by This.
738 I2cHostDriverSupported (
739 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
740 IN EFI_HANDLE Controller
,
741 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
745 Starts a device controller or a bus controller.
747 The Start() function is designed to be invoked from the EFI boot service ConnectController().
748 As a result, much of the error checking on the parameters to Start() has been moved into this
749 common boot service. It is legal to call Start() from other locations,
750 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
751 1. ControllerHandle must be a valid EFI_HANDLE.
752 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
753 EFI_DEVICE_PATH_PROTOCOL.
754 3. Prior to calling Start(), the Supported() function for the driver specified by This must
755 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
757 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
758 @param[in] ControllerHandle The handle of the controller to start. This handle
759 must support a protocol interface that supplies
760 an I/O abstraction to the driver.
761 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
762 parameter is ignored by device drivers, and is optional for bus
763 drivers. For a bus driver, if this parameter is NULL, then handles
764 for all the children of Controller are created by this driver.
765 If this parameter is not NULL and the first Device Path Node is
766 not the End of Device Path Node, then only the handle for the
767 child device specified by the first Device Path Node of
768 RemainingDevicePath is created by this driver.
769 If the first Device Path Node of RemainingDevicePath is
770 the End of Device Path Node, no child handle is created by this
773 @retval EFI_SUCCESS The device was started.
774 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
775 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
776 @retval Others The driver failded to start the device.
782 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
783 IN EFI_HANDLE Controller
,
784 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
788 Stops a device controller or a bus controller.
790 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
791 As a result, much of the error checking on the parameters to Stop() has been moved
792 into this common boot service. It is legal to call Stop() from other locations,
793 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
794 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
795 same driver's Start() function.
796 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
797 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
798 Start() function, and the Start() function must have called OpenProtocol() on
799 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
801 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
802 @param[in] ControllerHandle A handle to the device being stopped. The handle must
803 support a bus specific I/O protocol for the driver
804 to use to stop the device.
805 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
806 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
807 if NumberOfChildren is 0.
809 @retval EFI_SUCCESS The device was stopped.
810 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
816 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
817 IN EFI_HANDLE Controller
,
818 IN UINTN NumberOfChildren
,
819 IN EFI_HANDLE
*ChildHandleBuffer
823 Retrieves a Unicode string that is the user readable name of the driver.
825 This function retrieves the user readable name of a driver in the form of a
826 Unicode string. If the driver specified by This has a user readable name in
827 the language specified by Language, then a pointer to the driver name is
828 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
829 by This does not support the language specified by Language,
830 then EFI_UNSUPPORTED is returned.
832 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
833 EFI_COMPONENT_NAME_PROTOCOL instance.
835 @param Language[in] A pointer to a Null-terminated ASCII string
836 array indicating the language. This is the
837 language of the driver name that the caller is
838 requesting, and it must match one of the
839 languages specified in SupportedLanguages. The
840 number of languages supported by a driver is up
841 to the driver writer. Language is specified
842 in RFC 4646 or ISO 639-2 language code format.
844 @param DriverName[out] A pointer to the Unicode string to return.
845 This Unicode string is the name of the
846 driver specified by This in the language
847 specified by Language.
849 @retval EFI_SUCCESS The Unicode string for the Driver specified by
850 This and the language specified by Language was
851 returned in DriverName.
853 @retval EFI_INVALID_PARAMETER Language is NULL.
855 @retval EFI_INVALID_PARAMETER DriverName is NULL.
857 @retval EFI_UNSUPPORTED The driver specified by This does not support
858 the language specified by Language.
863 I2cHostComponentNameGetDriverName (
864 IN EFI_COMPONENT_NAME2_PROTOCOL
*This
,
866 OUT CHAR16
**DriverName
870 Retrieves a Unicode string that is the user readable name of the controller
871 that is being managed by a driver.
873 This function retrieves the user readable name of the controller specified by
874 ControllerHandle and ChildHandle in the form of a Unicode string. If the
875 driver specified by This has a user readable name in the language specified by
876 Language, then a pointer to the controller name is returned in ControllerName,
877 and EFI_SUCCESS is returned. If the driver specified by This is not currently
878 managing the controller specified by ControllerHandle and ChildHandle,
879 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
880 support the language specified by Language, then EFI_UNSUPPORTED is returned.
882 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
883 EFI_COMPONENT_NAME_PROTOCOL instance.
885 @param ControllerHandle[in] The handle of a controller that the driver
886 specified by This is managing. This handle
887 specifies the controller whose name is to be
890 @param ChildHandle[in] The handle of the child controller to retrieve
891 the name of. This is an optional parameter that
892 may be NULL. It will be NULL for device
893 drivers. It will also be NULL for a bus drivers
894 that wish to retrieve the name of the bus
895 controller. It will not be NULL for a bus
896 driver that wishes to retrieve the name of a
899 @param Language[in] A pointer to a Null-terminated ASCII string
900 array indicating the language. This is the
901 language of the driver name that the caller is
902 requesting, and it must match one of the
903 languages specified in SupportedLanguages. The
904 number of languages supported by a driver is up
905 to the driver writer. Language is specified in
906 RFC 4646 or ISO 639-2 language code format.
908 @param ControllerName[out] A pointer to the Unicode string to return.
909 This Unicode string is the name of the
910 controller specified by ControllerHandle and
911 ChildHandle in the language specified by
912 Language from the point of view of the driver
915 @retval EFI_SUCCESS The Unicode string for the user readable name in
916 the language specified by Language for the
917 driver specified by This was returned in
920 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
922 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
925 @retval EFI_INVALID_PARAMETER Language is NULL.
927 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
929 @retval EFI_UNSUPPORTED The driver specified by This is not currently
930 managing the controller specified by
931 ControllerHandle and ChildHandle.
933 @retval EFI_UNSUPPORTED The driver specified by This does not support
934 the language specified by Language.
939 I2cHostComponentNameGetControllerName (
940 IN EFI_COMPONENT_NAME2_PROTOCOL
*This
,
941 IN EFI_HANDLE ControllerHandle
,
942 IN EFI_HANDLE ChildHandle OPTIONAL
,
944 OUT CHAR16
**ControllerName
948 Handle the bus available event
950 This routine is called at TPL_I2C_SYNC.
952 @param[in] Event Address of an EFI_EVENT handle
953 @param[in] Context Address of an I2C_HOST_CONTEXT structure
958 I2cHostRequestCompleteEvent (
964 Handle the I2C bus configuration available event
966 This routine is called at TPL_I2C_SYNC.
968 @param[in] Event Address of an EFI_EVENT handle
969 @param[in] Context Address of an I2C_HOST_CONTEXT structure
974 I2cHostI2cBusConfigurationAvailable (
980 Queue an I2C operation for execution on the I2C controller.
982 This routine must be called at or below TPL_NOTIFY. For synchronous
983 requests this routine must be called at or below TPL_CALLBACK.
985 N.B. The typical consumers of this API are the I2C bus driver and
986 on rare occasions the I2C test application. Extreme care must be
987 taken by other consumers of this API to prevent confusing the
988 third party I2C drivers due to a state change at the I2C device
989 which the third party I2C drivers did not initiate. I2C platform
990 drivers may use this API within these guidelines.
992 This layer uses the concept of I2C bus configurations to describe
993 the I2C bus. An I2C bus configuration is defined as a unique
994 setting of the multiplexers and switches in the I2C bus which
995 enable access to one or more I2C devices. When using a switch
996 to divide a bus, due to speed differences, the I2C platform layer
997 would define an I2C bus configuration for the I2C devices on each
998 side of the switch. When using a multiplexer, the I2C platform
999 layer defines an I2C bus configuration for each of the selector
1000 values required to control the multiplexer. See Figure 1 in the
1001 <a href="http://www.nxp.com/documents/user_manual/UM10204.pdf">I<sup>2</sup>C
1002 Specification</a> for a complex I2C bus configuration.
1004 The I2C host driver processes all operations in FIFO order. Prior to
1005 performing the operation, the I2C host driver calls the I2C platform
1006 driver to reconfigure the switches and multiplexers in the I2C bus
1007 enabling access to the specified I2C device. The I2C platform driver
1008 also selects the maximum bus speed for the device. After the I2C bus
1009 is configured, the I2C host driver calls the I2C port driver to
1010 initialize the I2C controller and start the I2C operation.
1012 @param[in] This Address of an EFI_I2C_HOST_PROTOCOL instance.
1013 @param[in] I2cBusConfiguration I2C bus configuration to access the I2C
1015 @param[in] SlaveAddress Address of the device on the I2C bus.
1016 @param[in] Event Event to set for asynchronous operations,
1017 NULL for synchronous operations
1018 @param[in] RequestPacket Address of an EFI_I2C_REQUEST_PACKET
1019 structure describing the I2C operation
1020 @param[out] I2cStatus Optional buffer to receive the I2C operation
1023 @retval EFI_SUCCESS The operation completed successfully.
1024 @retval EFI_ABORTED The request did not complete because the driver
1026 @retval EFI_BAD_BUFFER_SIZE The WriteBytes or ReadBytes buffer size is too large.
1027 @retval EFI_DEVICE_ERROR There was an I2C error (NACK) during the operation.
1028 This could indicate the slave device is not present.
1029 @retval EFI_INVALID_PARAMETER RequestPacket is NULL
1030 @retval EFI_INVALID_PARAMETER TPL is too high
1031 @retval EFI_NO_MAPPING Invalid I2cBusConfiguration value
1032 @retval EFI_NO_RESPONSE The I2C device is not responding to the
1033 slave address. EFI_DEVICE_ERROR may also be
1034 returned if the controller can not distinguish
1035 when the NACK occurred.
1036 @retval EFI_NOT_FOUND I2C slave address exceeds maximum address
1037 @retval EFI_NOT_READY I2C bus is busy or operation pending, wait for
1038 the event and then read status pointed to by
1040 @retval EFI_OUT_OF_RESOURCES Insufficient memory for I2C operation
1041 @retval EFI_TIMEOUT The transaction did not complete within an internally
1042 specified timeout period.
1047 I2cHostQueueRequest (
1048 IN CONST EFI_I2C_HOST_PROTOCOL
*This
,
1049 IN UINTN I2cBusConfiguration
,
1050 IN UINTN SlaveAddress
,
1051 IN EFI_EVENT Event OPTIONAL
,
1052 IN EFI_I2C_REQUEST_PACKET
*RequestPacket
,
1053 OUT EFI_STATUS
*I2cStatus OPTIONAL
1057 The user Entry Point for I2C host module. The user code starts with this function.
1059 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1060 @param[in] SystemTable A pointer to the EFI System Table.
1062 @retval EFI_SUCCESS The entry point is executed successfully.
1063 @retval other Some error occurs when executing this entry point.
1069 IN EFI_HANDLE ImageHandle
,
1070 IN EFI_SYSTEM_TABLE
*SystemTable
1074 This is the unload handle for I2C host module.
1076 Disconnect the driver specified by ImageHandle from all the devices in the handle database.
1077 Uninstall all the protocols installed in the driver entry point.
1079 @param[in] ImageHandle The drivers' driver image.
1081 @retval EFI_SUCCESS The image is unloaded.
1082 @retval Others Failed to unload the image.
1088 IN EFI_HANDLE ImageHandle
1091 #endif // __I2C_DXE_H__