LM3643 Initial Commit : Synchronous Boost Dual LED Flash Driver
authora0414807local <a0414807local@uva0414807>
Mon, 16 May 2016 04:21:45 +0000 (13:21 +0900)
committera0414807local <a0414807local@uva0414807>
Mon, 16 May 2016 04:21:45 +0000 (13:21 +0900)
Signed-off-by: a0414807local <a0414807local@uva0414807>
18 files changed:
LM3643/TxnwLedLm3643.sdf [new file with mode: 0644]
LM3643/TxnwLedLm3643.sln [new file with mode: 0644]
LM3643/TxnwLedLm3643/Device.c [new file with mode: 0644]
LM3643/TxnwLedLm3643/Device.h [new file with mode: 0644]
LM3643/TxnwLedLm3643/Driver.c [new file with mode: 0644]
LM3643/TxnwLedLm3643/Driver.h [new file with mode: 0644]
LM3643/TxnwLedLm3643/Public.h [new file with mode: 0644]
LM3643/TxnwLedLm3643/ReadMe.txt [new file with mode: 0644]
LM3643/TxnwLedLm3643/Trace.h [new file with mode: 0644]
LM3643/TxnwLedLm3643/TxnwLedLm3643.inf [new file with mode: 0644]
LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj [new file with mode: 0644]
LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj.filters [new file with mode: 0644]
LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj.user [new file with mode: 0644]
LM3643/TxnwLedLm3643/runsdvui.cmd [new file with mode: 0644]
LM3643/TxnwLedLm3643/spb.c [new file with mode: 0644]
LM3643/TxnwLedLm3643/spb.h [new file with mode: 0644]
LM3643/asl/RPI2/ACPITABL.dat [new file with mode: 0644]
LM3643/asl/RPI2/rpi2.asl [new file with mode: 0644]

diff --git a/LM3643/TxnwLedLm3643.sdf b/LM3643/TxnwLedLm3643.sdf
new file mode 100644 (file)
index 0000000..4ce790b
Binary files /dev/null and b/LM3643/TxnwLedLm3643.sdf differ
diff --git a/LM3643/TxnwLedLm3643.sln b/LM3643/TxnwLedLm3643.sln
new file mode 100644 (file)
index 0000000..e594abf
--- /dev/null
@@ -0,0 +1,48 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 14\r
+VisualStudioVersion = 14.0.24720.0\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TxnwLedLm3643", "TxnwLedLm3643\TxnwLedLm3643.vcxproj", "{5915E3D1-66EC-4270-BE1A-D80F05A1F58A}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|ARM = Debug|ARM\r
+               Debug|ARM64 = Debug|ARM64\r
+               Debug|x64 = Debug|x64\r
+               Debug|x86 = Debug|x86\r
+               Release|ARM = Release|ARM\r
+               Release|ARM64 = Release|ARM64\r
+               Release|x64 = Release|x64\r
+               Release|x86 = Release|x86\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|ARM.ActiveCfg = Debug|ARM\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|ARM.Build.0 = Debug|ARM\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|ARM.Deploy.0 = Debug|ARM\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|ARM64.ActiveCfg = Debug|ARM64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|ARM64.Build.0 = Debug|ARM64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|ARM64.Deploy.0 = Debug|ARM64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|x64.ActiveCfg = Debug|x64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|x64.Build.0 = Debug|x64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|x64.Deploy.0 = Debug|x64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|x86.ActiveCfg = Debug|Win32\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|x86.Build.0 = Debug|Win32\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Debug|x86.Deploy.0 = Debug|Win32\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|ARM.ActiveCfg = Debug|ARM\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|ARM.Build.0 = Debug|ARM\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|ARM.Deploy.0 = Debug|ARM\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|ARM64.ActiveCfg = Release|ARM64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|ARM64.Build.0 = Release|ARM64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|ARM64.Deploy.0 = Release|ARM64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|x64.ActiveCfg = Release|x64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|x64.Build.0 = Release|x64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|x64.Deploy.0 = Release|x64\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|x86.ActiveCfg = Release|Win32\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|x86.Build.0 = Release|Win32\r
+               {5915E3D1-66EC-4270-BE1A-D80F05A1F58A}.Release|x86.Deploy.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/LM3643/TxnwLedLm3643/Device.c b/LM3643/TxnwLedLm3643/Device.c
new file mode 100644 (file)
index 0000000..4133a06
--- /dev/null
@@ -0,0 +1,430 @@
+/*++\r
+Copyright (c) Texas Instruments Inc. All Rights Reserved.\r
+Sample code for Dual LED FLASH LM3643.\r
+\r
+The MIT License (MIT)\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.\r
+\r
+Module Name:\r
+\r
+    device.c - Device handling events for example driver.\r
+\r
+Abstract:\r
+\r
+   This file contains the device entry points and callbacks.\r
+    \r
+Environment:\r
+\r
+    Kernel-mode Driver Framework\r
+\r
+--*/\r
+\r
+#include "driver.h"\r
+#include "device.tmh"\r
+#include "spb.h"\r
+#include "public.h"\r
+\r
+#ifdef ALLOC_PRAGMA\r
+       #pragma alloc_text(PAGE, OnD0Exit)\r
+#endif\r
+\r
+\r
+NTSTATUS\r
+RegUpdateSynchronously(\r
+       IN SPB_CONTEXT *SpbContext,\r
+       IN UCHAR Address,\r
+       IN UCHAR Mask,\r
+       IN UCHAR Data\r
+       )\r
+{\r
+       NTSTATUS status;\r
+       BYTE rData;\r
+\r
+       status = SpbReadDataSynchronously(SpbContext, Address, &rData, 1);\r
+       if (!NT_SUCCESS(status))\r
+               return status;\r
+\r
+       rData &= ~Mask;\r
+       rData |= (Data & Mask);\r
+\r
+       status = SpbWriteDataSynchronously(SpbContext, Address, &rData, 1);\r
+\r
+       return status;\r
+}\r
+\r
+NTSTATUS\r
+OnD0Entry(\r
+       IN WDFDEVICE Device,\r
+       IN WDF_POWER_DEVICE_STATE PreviousState\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This routine will power on the hardware\r
+\r
+       Arguments:\r
+\r
+       Device - WDF device to power on\r
+       PreviousState - Prior power state\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS indicating success or failure\r
+\r
+       */\r
+{\r
+       NTSTATUS status;\r
+       PDEVICE_EXTENSION devContext;\r
+\r
+       devContext = GetDeviceContext(Device);\r
+\r
+       UNREFERENCED_PARAMETER(PreviousState);\r
+\r
+       BYTE rData;\r
+       SPB_CONTEXT *SpbContext = &devContext->I2CContext;\r
+       status = SpbReadDataSynchronously(SpbContext, 0x0C, &rData, 1);\r
+\r
+       devContext->ServiceInterruptsAfterD0Entry = TRUE;\r
+\r
+       return status;\r
+}\r
+\r
+NTSTATUS\r
+OnD0Exit(\r
+       IN WDFDEVICE Device,\r
+       IN WDF_POWER_DEVICE_STATE TargetState\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This routine will power down the hardware\r
+\r
+       Arguments:\r
+\r
+       Device - WDF device to power off\r
+\r
+       PreviousState - Prior power state\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS indicating success or failure\r
+\r
+       */\r
+{\r
+       NTSTATUS status;\r
+       PDEVICE_EXTENSION devContext;\r
+\r
+       PAGED_CODE();\r
+       devContext = GetDeviceContext(Device);\r
+       UNREFERENCED_PARAMETER(TargetState);\r
+\r
+       SPB_CONTEXT *SpbContext = &devContext->I2CContext;\r
+       status = RegUpdateSynchronously(SpbContext, 0x01, 0x03, 0);\r
+       return status;\r
+}\r
+\r
+NTSTATUS\r
+OnPrepareHardware(\r
+       IN WDFDEVICE FxDevice,\r
+       IN WDFCMRESLIST FxResourcesRaw,\r
+       IN WDFCMRESLIST FxResourcesTranslated\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This routine is called by the PnP manager and supplies thie device instance\r
+       with it's SPB resources (CmResourceTypeConnection) needed to find the I2C\r
+       driver.\r
+\r
+       Arguments:\r
+\r
+       FxDevice - a handle to the framework device object\r
+       FxResourcesRaw - list of translated hardware resources that\r
+       the PnP manager has assigned to the device\r
+       FxResourcesTranslated - list of raw hardware resources that\r
+       the PnP manager has assigned to the device\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS indicating sucess or failure\r
+\r
+       --*/\r
+{\r
+       NTSTATUS status;\r
+       PCM_PARTIAL_RESOURCE_DESCRIPTOR res;\r
+       PDEVICE_EXTENSION devContext;\r
+       ULONG resourceCount;\r
+       ULONG i;\r
+\r
+       UNREFERENCED_PARAMETER(FxResourcesRaw);\r
+\r
+       status = STATUS_INSUFFICIENT_RESOURCES;\r
+       devContext = GetDeviceContext(FxDevice);\r
+       resourceCount = WdfCmResourceListGetCount(FxResourcesTranslated);\r
+\r
+       for (i = 0; i < resourceCount; i++)\r
+       {\r
+               res = WdfCmResourceListGetDescriptor(FxResourcesTranslated, i);\r
+\r
+               if (res->Type == CmResourceTypeConnection &&\r
+                       res->u.Connection.Class == CM_RESOURCE_CONNECTION_CLASS_SERIAL &&\r
+                       res->u.Connection.Type == CM_RESOURCE_CONNECTION_TYPE_SERIAL_I2C)\r
+               {\r
+                       devContext->I2CContext.I2cResHubId.LowPart =\r
+                               res->u.Connection.IdLowPart;\r
+                       devContext->I2CContext.I2cResHubId.HighPart =\r
+                               res->u.Connection.IdHighPart;\r
+\r
+                       status = STATUS_SUCCESS;\r
+               }\r
+       }\r
+\r
+       if (!NT_SUCCESS(status))\r
+               goto exit;\r
+\r
+       //\r
+       // Initialize Spb so the driver can issue reads/writes\r
+       //\r
+       status = SpbTargetInitialize(FxDevice, &devContext->I2CContext);\r
+\r
+       if (!NT_SUCCESS(status))\r
+               goto exit;\r
+       \r
+       // \r
+       // Read Device Id - LM3643 ID should be 0x02\r
+       // \r
+       BYTE rData;\r
+       SPB_CONTEXT *SpbContext = &devContext->I2CContext;\r
+       status = SpbReadDataSynchronously(SpbContext, 0x0C, &rData, 1);\r
+\r
+       // \r
+       // Add additional chip initialize code here if it is needed\r
+       // such as TX-pin, IVFM Levels/Hysteresis, Selection etc \r
+       \r
+exit:\r
+\r
+       return status;\r
+}\r
+\r
+NTSTATUS\r
+OnReleaseHardware(\r
+       IN WDFDEVICE FxDevice,\r
+       IN WDFCMRESLIST FxResourcesTranslated\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This routine cleans up any resources provided.\r
+\r
+       Arguments:\r
+\r
+       FxDevice - a handle to the framework device object\r
+       FxResourcesRaw - list of translated hardware resources that\r
+       the PnP manager has assigned to the device\r
+       FxResourcesTranslated - list of raw hardware resources that\r
+       the PnP manager has assigned to the device\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS indicating sucesss or failure\r
+\r
+       --*/\r
+{\r
+       NTSTATUS status;\r
+       PDEVICE_EXTENSION devContext;\r
+\r
+       UNREFERENCED_PARAMETER(FxResourcesTranslated);\r
+\r
+       devContext = GetDeviceContext(FxDevice);\r
+       \r
+       BYTE rData;\r
+       SPB_CONTEXT *SpbContext = &devContext->I2CContext;\r
+       status = SpbReadDataSynchronously(SpbContext, 0x01, &rData, 1);\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               return status;\r
+       }\r
+\r
+       rData &= (~0x03); //LED1, 2 OFF\r
+       SpbWriteDataSynchronously(SpbContext, 0x01, &rData, 1);\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               return status;\r
+       }\r
+\r
+       SpbTargetDeinitialize(FxDevice, &GetDeviceContext(FxDevice)->I2CContext);\r
+\r
+       return status;\r
+}\r
+\r
+\r
+\r
+VOID\r
+OnDeviceControl(\r
+       IN WDFQUEUE Queue,\r
+       IN WDFREQUEST Request,\r
+       IN size_t OutputBufferLength,\r
+       IN size_t InputBufferLength,\r
+       IN ULONG IoControlCode\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This event is called when the framework receives\r
+       IRP_MJ_INTERNAL DEVICE_CONTROL requests from the system.\r
+\r
+       Arguments:\r
+\r
+       Queue - Handle to the framework queue object that is associated\r
+       with the I/O request.\r
+\r
+       Request - Handle to a framework request object.\r
+\r
+       OutputBufferLength - length of the request's output buffer,\r
+       if an output buffer is available.\r
+\r
+       InputBufferLength - length of the request's input buffer,\r
+       if an input buffer is available.\r
+\r
+       IoControlCode - the driver-defined or system-defined I/O control code\r
+       (IOCTL) that is associated with the request.\r
+\r
+       Return Value:\r
+\r
+       None, status is indicated when completing the request\r
+\r
+       --*/\r
+{\r
+       NTSTATUS status;\r
+       PDEVICE_EXTENSION devContext;\r
+       WDFDEVICE device;\r
+       BOOLEAN requestPending;\r
+       BYTE rData = 0, wData = 0;\r
+       USHORT rData2b = 0;\r
+       ULONG* inputVal;\r
+       ULONG* retVal;\r
+\r
+       UNREFERENCED_PARAMETER(OutputBufferLength);\r
+       UNREFERENCED_PARAMETER(InputBufferLength);\r
+\r
+       device = WdfIoQueueGetDevice(Queue);\r
+       devContext = GetDeviceContext(device);\r
+       requestPending = FALSE;\r
+\r
+       SPB_CONTEXT *SpbContext = &devContext->I2CContext;\r
+       \r
+       WdfRequestRetrieveInputBuffer(Request, sizeof(ULONG), (void**)&inputVal, NULL);\r
+       WdfRequestRetrieveOutputBuffer(Request, sizeof(ULONG),(void**)&retVal, NULL);\r
+       wData = (*inputVal) & 0xff;\r
+\r
+       switch (IoControlCode) {\r
+\r
+       case IOCTL_LM3643_DEVID:\r
+               status = SpbReadDataSynchronously(SpbContext, 0x0C, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_MODE:\r
+               status = RegUpdateSynchronously(SpbContext, 0x01, 0x0C, (wData << 2));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x01, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_TORCH_PIN_ENABLE:\r
+               status = RegUpdateSynchronously(SpbContext, 0x01, 0x10, (wData << 4));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x01, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_STROBE_PIN_ENABLE:\r
+               status = RegUpdateSynchronously(SpbContext, 0x01, 0x20, (wData << 5));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x01, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_STATUS:              \r
+               status = SpbReadDataSynchronously(SpbContext, 0x0A, &rData, 1);\r
+               rData2b |= ( ( rData& 0xff) << 8);\r
+               status = SpbReadDataSynchronously(SpbContext, 0x0B, &rData, 1);\r
+               rData2b |= (rData & 0xff);\r
+               *retVal = (ULONG)rData2b;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_LED1_ENABLE:\r
+               status = RegUpdateSynchronously(SpbContext, 0x01, 0x01, (wData << 0));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x01, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_LED1_BRT_FLASH:\r
+               status = RegUpdateSynchronously(SpbContext, 0x03, 0x3f, (wData << 0));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x03, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_LED1_BRT_TORCH:\r
+               status = RegUpdateSynchronously(SpbContext, 0x05, 0x3f, (wData << 0));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x05, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;
+\r
+       case  IOCTL_LM3643_LED2_ENABLE:\r
+               status = RegUpdateSynchronously(SpbContext, 0x01, 0x02, (wData << 1));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x01, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;
+
+       case  IOCTL_LM3643_LED2_BRT_FLASH:\r
+               status = RegUpdateSynchronously(SpbContext, 0x04, 0x3f, (wData << 0));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x04, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_LED2_BRT_TORCH:\r
+               status = RegUpdateSynchronously(SpbContext, 0x06, 0x3f, (wData << 0));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x06, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;\r
+\r
+       case  IOCTL_LM3643_FLASH_TOUT:\r
+               status = RegUpdateSynchronously(SpbContext, 0x08, 0x0f, (wData << 0));\r
+               status |= SpbReadDataSynchronously(SpbContext, 0x08, &rData, 1);\r
+               *retVal = (ULONG)rData;\r
+               break;
+\r
+       default:\r
+               status = STATUS_NOT_SUPPORTED;\r
+               break;\r
+       }\r
+\r
+       if (!requestPending)\r
+       {\r
+               WdfRequestCompleteWithInformation(Request, status, sizeof(ULONG));\r
+       }\r
+\r
+       return;\r
+}\r
+\r
+\r
diff --git a/LM3643/TxnwLedLm3643/Device.h b/LM3643/TxnwLedLm3643/Device.h
new file mode 100644 (file)
index 0000000..46e74fc
--- /dev/null
@@ -0,0 +1,56 @@
+/*++\r
+Copyright (c) Texas Instruments Inc. All Rights Reserved.\r
+Sample code for Dual LED FLASH LM3643.\r
+\r
+The MIT License (MIT)\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.\r
+\r
+Module Name:\r
+\r
+    device.h\r
+\r
+Abstract:\r
+\r
+    This file contains the device definitions.\r
+\r
+Environment:\r
+\r
+    Kernel-mode Driver Framework\r
+\r
+--*/\r
+\r
+\r
+\r
+#pragma once\r
+\r
+\r
+EVT_WDF_DEVICE_D0_ENTRY OnD0Entry;\r
+\r
+EVT_WDF_DEVICE_D0_EXIT OnD0Exit;\r
+\r
+EVT_WDF_INTERRUPT_ISR OnInterruptIsr;\r
+\r
+EVT_WDF_DEVICE_PREPARE_HARDWARE OnPrepareHardware;\r
+\r
+EVT_WDF_DEVICE_RELEASE_HARDWARE OnReleaseHardware;\r
+\r
+//EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL OnInternalDeviceControl;\r
+\r
+EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL OnDeviceControl;\r
diff --git a/LM3643/TxnwLedLm3643/Driver.c b/LM3643/TxnwLedLm3643/Driver.c
new file mode 100644 (file)
index 0000000..30b6463
--- /dev/null
@@ -0,0 +1,279 @@
+/*++\r
+Copyright (c) Texas Instruments Inc. All Rights Reserved.\r
+Sample code for Dual LED FLASH LM3643.\r
+\r
+The MIT License (MIT)\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.\r
+\r
+Module Name:\r
+\r
+    driver.c\r
+\r
+Abstract:\r
+\r
+    This file contains the driver entry points and callbacks.\r
+\r
+Environment:\r
+\r
+    Kernel-mode Driver Framework\r
+\r
+--*/\r
+\r
+#include "driver.h"\r
+#include "driver.tmh"\r
+#include "Public.h"\r
+\r
+#ifdef ALLOC_PRAGMA\r
+#pragma alloc_text (INIT, DriverEntry)\r
+#pragma alloc_text (PAGE, TxnwLedLm3643EvtDeviceAdd)\r
+#pragma alloc_text (PAGE, TxnwLedLm3643EvtDriverContextCleanup)\r
+#endif\r
+
+#define TXN_DEVICE_NAME L"TxnwLedLm3643"\r
+\r
+NTSTATUS\r
+DriverEntry(\r
+    _In_ PDRIVER_OBJECT  DriverObject,\r
+    _In_ PUNICODE_STRING RegistryPath\r
+    )\r
+/*++\r
+\r
+Routine Description:\r
+    DriverEntry initializes the driver and is the first routine called by the\r
+    system after the driver is loaded. DriverEntry specifies the other entry\r
+    points in the function driver, such as EvtDevice and DriverUnload.\r
+\r
+Parameters Description:\r
+\r
+    DriverObject - represents the instance of the function driver that is loaded\r
+    into memory. DriverEntry must initialize members of DriverObject before it\r
+    returns to the caller. DriverObject is allocated by the system before the\r
+    driver is loaded, and it is released by the system after the system unloads\r
+    the function driver from memory.\r
+\r
+    RegistryPath - represents the driver specific path in the Registry.\r
+    The function driver can use the path to store driver related data between\r
+    reboots. The path does not store hardware instance specific data.\r
+\r
+Return Value:\r
+\r
+    STATUS_SUCCESS if successful,\r
+    STATUS_UNSUCCESSFUL otherwise.\r
+\r
+--*/\r
+{\r
+    WDF_DRIVER_CONFIG config;\r
+    NTSTATUS status;\r
+    WDF_OBJECT_ATTRIBUTES attributes;\r
+\r
+    //\r
+    // Initialize WPP Tracing\r
+    //\r
+    WPP_INIT_TRACING( DriverObject, RegistryPath );\r
+\r
+\r
+    //\r
+    // Register a cleanup callback so that we can call WPP_CLEANUP when\r
+    // the framework driver object is deleted during driver unload.\r
+    //\r
+    WDF_OBJECT_ATTRIBUTES_INIT(&attributes);\r
+    attributes.EvtCleanupCallback = TxnwLedLm3643EvtDriverContextCleanup;\r
+\r
+    WDF_DRIVER_CONFIG_INIT(&config,\r
+                           TxnwLedLm3643EvtDeviceAdd\r
+                           );\r
+\r
+    status = WdfDriverCreate(DriverObject,\r
+                             RegistryPath,\r
+                             &attributes,\r
+                             &config,\r
+                             WDF_NO_HANDLE\r
+                             );\r
+\r
+    if (!NT_SUCCESS(status)) {\r
+        WPP_CLEANUP(DriverObject);\r
+        return status;\r
+    }\r
+\r
+    return status;\r
+}\r
+\r
+NTSTATUS\r
+TxnwLedLm3643EvtDeviceAdd(\r
+    _In_    WDFDRIVER       Driver,\r
+    _Inout_ PWDFDEVICE_INIT DeviceInit\r
+    )\r
+/*++\r
+Routine Description:\r
+\r
+    EvtDeviceAdd is called by the framework in response to AddDevice\r
+    call from the PnP manager. We create and initialize a device object to\r
+    represent a new instance of the device.\r
+\r
+Arguments:\r
+\r
+    Driver - Handle to a framework driver object created in DriverEntry\r
+\r
+    DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure.\r
+\r
+Return Value:\r
+\r
+    NTSTATUS\r
+\r
+--*/\r
+{\r
+       WDF_OBJECT_ATTRIBUTES attributes;\r
+       PDEVICE_EXTENSION devContext;\r
+       WDFDEVICE fxDevice;\r
+       WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;\r
+       WDF_IO_QUEUE_CONFIG queueConfig;\r
+    NTSTATUS status;\r
+\r
+\r
+    UNREFERENCED_PARAMETER(Driver);\r
+\r
+    PAGED_CODE();\r
+\r
+       WdfDeviceInitSetPowerPolicyOwnership(DeviceInit, FALSE);\r
+       //\r
+       // This driver handles D0 Entry and Exit to power on and off the\r
+       // controller. It also handles prepare/release hardware so that it \r
+       // can acquire and free SPB resources needed to communicate with the  \r
+       // touch controller.\r
+       //\r
+       WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);\r
+\r
+       pnpPowerCallbacks.EvtDeviceD0Entry = OnD0Entry;\r
+       pnpPowerCallbacks.EvtDeviceD0Exit = OnD0Exit;\r
+       pnpPowerCallbacks.EvtDevicePrepareHardware = OnPrepareHardware;\r
+       pnpPowerCallbacks.EvtDeviceReleaseHardware = OnReleaseHardware;\r
+\r
+       WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);\r
+\r
+       //\r
+       // Create a framework device object. This call will in turn create\r
+       // a WDM device object, attach to the lower stack, and set the\r
+       // appropriate flags and attributes.\r
+       //\r
+       WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_EXTENSION);\r
+\r
+       status = WdfDeviceCreate(&DeviceInit, &attributes, &fxDevice);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               goto exit;\r
+       }\r
+\r
+       devContext = GetDeviceContext(fxDevice);\r
+       devContext->FxDevice = fxDevice;\r
+\r
+       //\r
+       // Create a parallel dispatch queue to handle requests\r
+       //\r
+       WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(\r
+               &queueConfig,\r
+               WdfIoQueueDispatchSequential);\r
+       \r
+       queueConfig.EvtIoDeviceControl = OnDeviceControl;\r
+       queueConfig.PowerManaged = WdfFalse;\r
+\r
+       status = WdfIoQueueCreate(\r
+               fxDevice,\r
+               &queueConfig,\r
+               WDF_NO_OBJECT_ATTRIBUTES,\r
+               &devContext->DefaultQueue);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               goto exit;\r
+       }\r
+\r
+       //\r
+       // Register a manual I/O queue for Read Requests. This queue will be used \r
+       // for storing read-requests until data is available to complete them.\r
+       //\r
+       WDF_IO_QUEUE_CONFIG_INIT(&queueConfig, WdfIoQueueDispatchManual);\r
+\r
+       queueConfig.PowerManaged = WdfFalse;\r
+\r
+       status = WdfIoQueueCreate(\r
+               fxDevice,\r
+               &queueConfig,\r
+               WDF_NO_OBJECT_ATTRIBUTES,\r
+               &devContext->PingPongQueue);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               goto exit;\r
+       }\r
+       //\r
+       // Register one last manual I/O queue for parking idle power\r
+       // requests. This queue stores idle requests until they're cancelled,\r
+       // and could be used to complete a wait/wake request.\r
+       //\r
+\r
+       WDF_IO_QUEUE_CONFIG_INIT(&queueConfig, WdfIoQueueDispatchManual);\r
+\r
+       queueConfig.PowerManaged = WdfFalse;\r
+\r
+       status = WdfIoQueueCreate(\r
+               fxDevice,\r
+               &queueConfig,\r
+               WDF_NO_OBJECT_ATTRIBUTES,\r
+               &devContext->IdleQueue\r
+               );\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               goto exit;\r
+       }\r
+\r
+       DECLARE_CONST_UNICODE_STRING(symbolicLink, L"\\DosDevices\\" LM3643_DEVICE_NAME);\r
+       status = WdfDeviceCreateSymbolicLink(fxDevice, &symbolicLink);\r
+       \r
+exit:\r
+    return status;\r
+}\r
+\r
+VOID\r
+TxnwLedLm3643EvtDriverContextCleanup(\r
+    _In_ WDFOBJECT DriverObject\r
+    )\r
+/*++\r
+Routine Description:\r
+\r
+    Free all the resources allocated in DriverEntry.\r
+\r
+Arguments:\r
+\r
+    DriverObject - handle to a WDF Driver object.\r
+\r
+Return Value:\r
+\r
+    VOID.\r
+\r
+--*/\r
+{\r
+    UNREFERENCED_PARAMETER(DriverObject);\r
+\r
+    PAGED_CODE ();\r
+\r
+    WPP_CLEANUP( WdfDriverWdmGetDriverObject( (WDFDRIVER) DriverObject) );\r
+}\r
diff --git a/LM3643/TxnwLedLm3643/Driver.h b/LM3643/TxnwLedLm3643/Driver.h
new file mode 100644 (file)
index 0000000..9e2aaef
--- /dev/null
@@ -0,0 +1,81 @@
+/*++\r
+Copyright (c) Texas Instruments Inc. All Rights Reserved.\r
+Sample code for Dual LED FLASH LM3643.\r
+\r
+The MIT License (MIT)\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.\r
+\r
+Module Name:\r
+\r
+    driver.h\r
+\r
+Abstract:\r
+\r
+    This file contains the driver definitions.\r
+\r
+Environment:\r
+\r
+    Kernel-mode Driver Framework\r
+\r
+--*/\r
+\r
+#define INITGUID\r
+\r
+#include <ntddk.h>\r
+#include <wdf.h>\r
+\r
+#include "device.h"\r
+#include "spb.h"\r
+#include "trace.h"\r
+\r
+EXTERN_C_START\r
+\r
+//\r
+// WDFDRIVER Events\r
+//\r
+\r
+DRIVER_INITIALIZE DriverEntry;\r
+EVT_WDF_DRIVER_DEVICE_ADD TxnwLedLm3643EvtDeviceAdd;\r
+EVT_WDF_OBJECT_CONTEXT_CLEANUP TxnwLedLm3643EvtDriverContextCleanup;\r
+\r
+EXTERN_C_END\r
+\r
+\r
+#pragma once\r
+\r
+#include <wdm.h>\r
+#define RESHUB_USE_HELPER_ROUTINES\r
+#include <reshub.h>\r
+\r
+#define LED_POOL_TAG                  (ULONG)'cuoT'\r
+\r
+typedef struct _DEVICE_EXTENSION\r
+{\r
+       WDFDEVICE FxDevice;\r
+       WDFQUEUE DefaultQueue;\r
+       WDFQUEUE PingPongQueue;\r
+       WDFQUEUE IdleQueue;// Power related\r
+\r
+       BOOLEAN ServiceInterruptsAfterD0Entry;\r
+       SPB_CONTEXT I2CContext;\r
+\r
+} DEVICE_EXTENSION, *PDEVICE_EXTENSION;\r
+\r
+WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_EXTENSION, GetDeviceContext)\r
diff --git a/LM3643/TxnwLedLm3643/Public.h b/LM3643/TxnwLedLm3643/Public.h
new file mode 100644 (file)
index 0000000..d585ae8
--- /dev/null
@@ -0,0 +1,65 @@
+/*++\r
+Copyright (c) Texas Instruments Inc. All Rights Reserved.\r
+Sample code for Dual LED FLASH LM3643.\r
+\r
+The MIT License (MIT)\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.\r
+\r
+Module Name:\r
+\r
+    public.h\r
+\r
+Abstract:\r
+\r
+    This module contains the common declarations shared by driver\r
+    and user applications.\r
+\r
+Environment:\r
+\r
+    user and kernel\r
+\r
+--*/\r
+\r
+\r
+DEFINE_GUID (GUID_DEVINTERFACE_TxnwLedLm3643,\r
+    0x1851bf6e,0x6f89,0x4e0e,0x87,0x74,0x34,0x1e,0x44,0x2e,0x7c,0xe9);\r
+
+#define LM3643_DEVICE_NAME L"OEM_LED"
+#define LM3643_DEVICE_PATH L"\\\\.\\" LM3643_DEVICE_NAME\r
+
+#define FILE_DEVICE_LM3643 0xffffUL\r
+\r
+#define IOCTL_LM3643_DEVID                                     CTL_CODE(FILE_DEVICE_LM3643, 0x101, METHOD_BUFFERED, FILE_ANY_ACCESS)\r
+\r
+#define IOCTL_LM3643_MODE                                      CTL_CODE(FILE_DEVICE_LM3643, 0x102, METHOD_BUFFERED, FILE_ANY_ACCESS)\r
+#define IOCTL_LM3643_TORCH_PIN_ENABLE          CTL_CODE(FILE_DEVICE_LM3643, 0x103, METHOD_BUFFERED, FILE_ANY_ACCESS)\r
+#define IOCTL_LM3643_STROBE_PIN_ENABLE         CTL_CODE(FILE_DEVICE_LM3643, 0x104, METHOD_BUFFERED, FILE_ANY_ACCESS)\r
+\r
+#define IOCTL_LM3643_STATUS                                    CTL_CODE(FILE_DEVICE_LM3643, 0x105, METHOD_BUFFERED, FILE_ANY_ACCESS)\r
+\r
+#define IOCTL_LM3643_LED1_ENABLE                       CTL_CODE(FILE_DEVICE_LM3643, 0x110, METHOD_BUFFERED, FILE_ANY_ACCESS)\r
+#define IOCTL_LM3643_LED1_BRT_FLASH                    CTL_CODE(FILE_DEVICE_LM3643, 0x111, METHOD_BUFFERED, FILE_ANY_ACCESS)\r
+#define IOCTL_LM3643_LED1_BRT_TORCH                    CTL_CODE(FILE_DEVICE_LM3643, 0x112, METHOD_BUFFERED, FILE_ANY_ACCESS)
+\r
+#define IOCTL_LM3643_LED2_ENABLE                       CTL_CODE(FILE_DEVICE_LM3643, 0x120, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_LM3643_LED2_BRT_FLASH                    CTL_CODE(FILE_DEVICE_LM3643, 0x121, METHOD_BUFFERED, FILE_ANY_ACCESS)\r
+#define IOCTL_LM3643_LED2_BRT_TORCH                    CTL_CODE(FILE_DEVICE_LM3643, 0x122, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+#define IOCTL_LM3643_FLASH_TOUT                                CTL_CODE(FILE_DEVICE_LM3643, 0x150, METHOD_BUFFERED, FILE_ANY_ACCESS)
diff --git a/LM3643/TxnwLedLm3643/ReadMe.txt b/LM3643/TxnwLedLm3643/ReadMe.txt
new file mode 100644 (file)
index 0000000..af1d074
--- /dev/null
@@ -0,0 +1,38 @@
+========================================================================\r
+    TxnwLedLm3643 Project Overview\r
+========================================================================\r
+\r
+This file contains a summary of what you will find in each of the files that make up your project.\r
+\r
+TxnwLedLm3643.vcxproj\r
+    This is the main project file for projects generated using an Application Wizard. \r
+    It contains information about the version of the product that generated the file, and \r
+    information about the platforms, configurations, and project features selected with the\r
+    Application Wizard.\r
+\r
+TxnwLedLm3643.vcxproj.filters\r
+    This is the filters file for VC++ projects generated using an Application Wizard. \r
+    It contains information about the association between the files in your project \r
+    and the filters. This association is used in the IDE to show grouping of files with\r
+    similar extensions under a specific node (for e.g. ".cpp" files are associated with the\r
+    "Source Files" filter).\r
+\r
+Public.h\r
+    Header file to be shared with applications. \r
\r
+Driver.c & Driver.h\r
+    DriverEntry and WDFDRIVER related functionality and callbacks.\r
\r
+Device.cpp & Device.h\r
+    WDFDEVICE related functionality and callbacks.\r
+       \r
+Trace.h\r
+    Definitions for WPP tracing.\r
+       \r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+Learn more about Kernel Mode Driver Framework here:\r
+\r
+http://msdn.microsoft.com/en-us/library/ff544296(v=VS.85).aspx\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
diff --git a/LM3643/TxnwLedLm3643/Trace.h b/LM3643/TxnwLedLm3643/Trace.h
new file mode 100644 (file)
index 0000000..539cde4
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Module Name:\r
+\r
+    Trace.h\r
+\r
+Abstract:\r
+\r
+    Header file for the debug tracing related function defintions and macros.\r
+\r
+Environment:\r
+\r
+    Kernel mode\r
+\r
+--*/\r
+\r
+//\r
+// Define the tracing flags.\r
+//\r
+// Tracing GUID - 4b3dc37e-9b04-42ec-b3d5-6093b06f797e\r
+//\r
+\r
+#define WPP_CONTROL_GUIDS                                              \\r
+    WPP_DEFINE_CONTROL_GUID(                                           \\r
+        TxnwLedLm3643TraceGuid, (4b3dc37e,9b04,42ec,b3d5,6093b06f797e), \\r
+                                                                            \\r
+        WPP_DEFINE_BIT(MYDRIVER_ALL_INFO)                              \\r
+        WPP_DEFINE_BIT(TRACE_DRIVER)                                   \\r
+        WPP_DEFINE_BIT(TRACE_DEVICE)                                   \\r
+        WPP_DEFINE_BIT(TRACE_SPB)                                    \\r
+        )                             \r
+\r
+#define WPP_FLAG_LEVEL_LOGGER(flag, level)                                  \\r
+    WPP_LEVEL_LOGGER(flag)\r
+\r
+#define WPP_FLAG_LEVEL_ENABLED(flag, level)                                 \\r
+    (WPP_LEVEL_ENABLED(flag) &&                                             \\r
+     WPP_CONTROL(WPP_BIT_ ## flag).Level >= level)\r
+\r
+#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \\r
+           WPP_LEVEL_LOGGER(flags)\r
+               \r
+#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \\r
+           (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)\r
+\r
+//\r
+// This comment block is scanned by the trace preprocessor to define our\r
+// Trace function.\r
+//\r
+// begin_wpp config\r
+// FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...);\r
+// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...);\r
+// end_wpp\r
+//\r
diff --git a/LM3643/TxnwLedLm3643/TxnwLedLm3643.inf b/LM3643/TxnwLedLm3643/TxnwLedLm3643.inf
new file mode 100644 (file)
index 0000000..0c68e92
--- /dev/null
@@ -0,0 +1,69 @@
+; TxnwLedLm3643.INF
+; Copyright (c) 2016 Texas Instruments Inc.
+; Contact : daniel.jeong@ti.com
+;
+
+[Version]
+Signature   = "$WINDOWS NT$"
+Class       = HIDClass
+ClassGUID   = {745A17A0-74D3-11D0-B6FE-00A0C90F57DA}
+Provider    = %Provider_Name%
+DriverVer   = 05/17/2016,1.0
+CatalogFile = KmdfSamples.cat
+
+[DestinationDirs]
+DefaultDestDir = 12
+
+[SourceDisksNames]
+1 = %Installation_Disk%,,,""
+
+[SourceDisksFiles]
+TxnwLedLm3643.sys  = 1,,
+
+[Manufacturer]
+%Manufacturer_Name% = Standard,NTARM
+
+[Standard.NTARM]
+%LedDriver_Device_Desc% = LedDriver_Device.NT, ACPI\OEM_LED
+
+;*****************************************
+; LedDriver client driver Install Section
+;*****************************************
+
+[LedDriver_Device.NT]
+CopyFiles = LedDriver_Device.NT.CopyFiles
+
+[LedDriver_Device.NT.CopyFiles]
+TxnwLedLm3643.sys
+
+;-------------- Service installation
+[LedDriver_Device.NT.Services]
+AddService = TxnwLedLm3643, %SPSVCINST_ASSOCSERVICE%, LedDriver_Service_Inst
+
+; ------------- LedDriver driver install section
+[LedDriver_Service_Inst]
+DisplayName    = %LedDriver_Service_Desc%
+ServiceType    = %SERVICE_KERNEL_DRIVER%
+StartType      = %SERVICE_DEMAND_START%
+ErrorControl   = %SERVICE_ERROR_NORMAL%
+ServiceBinary  = %12%\TxnwLedLm3643.sys
+LoadOrderGroup = Base
+
+; ------------- Strings section
+[Strings]
+Provider_Name           = "Texas Instruments Inc."
+Manufacturer_Name       = "Texas Instruments Inc."
+Installation_Disk       = "LED Driver Installation Disk"
+LedDriver_Device_Desc   = "Dual LED Flash LM3643 Driver"
+LedDriver_Service_Desc  = "Dual LED Flash LM3643 Service"
+
+; ------------- non-localizable strings
+SPSVCINST_ASSOCSERVICE  = 0x00000002
+SERVICE_KERNEL_DRIVER   = 1
+SERVICE_BOOT_START      = 0
+SERVICE_SYSTEM_START    = 1
+SERVICE_DEMAND_START    = 3
+SERVICE_ERROR_NORMAL    = 1
+SERVICE_ERROR_IGNORE    = 0
+SERVICE_ERROR_CRITICAL  = 3
+
diff --git a/LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj b/LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj
new file mode 100644 (file)
index 0000000..f1dec8e
--- /dev/null
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|ARM">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>ARM</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|ARM">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>ARM</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|ARM64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>ARM64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|ARM64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>ARM64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="ReadMe.txt" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="Device.c" />\r
+    <ClCompile Include="Driver.c" />\r
+    <ClCompile Include="spb.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="Device.h" />\r
+    <ClInclude Include="Driver.h" />\r
+    <ClInclude Include="Public.h" />\r
+    <ClInclude Include="spb.h" />\r
+    <ClInclude Include="Trace.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Inf Include="TxnwLedLm3643.inf" />\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{5915E3D1-66EC-4270-BE1A-D80F05A1F58A}</ProjectGuid>\r
+    <TemplateGuid>{497e31cb-056b-4f31-abb8-447fd55ee5a5}</TemplateGuid>\r
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>\r
+    <Configuration>Debug</Configuration>\r
+    <Platform Condition="'$(Platform)' == ''">Win32</Platform>\r
+    <RootNamespace>TxnwLedLm3643</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <TargetVersion>Windows10</TargetVersion>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\r
+    <ConfigurationType>Driver</ConfigurationType>\r
+    <DriverType>KMDF</DriverType>\r
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <TargetVersion>Windows10</TargetVersion>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\r
+    <ConfigurationType>Driver</ConfigurationType>\r
+    <DriverType>KMDF</DriverType>\r
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <TargetVersion>Windows10</TargetVersion>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\r
+    <ConfigurationType>Driver</ConfigurationType>\r
+    <DriverType>KMDF</DriverType>\r
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <TargetVersion>Windows10</TargetVersion>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\r
+    <ConfigurationType>Driver</ConfigurationType>\r
+    <DriverType>KMDF</DriverType>\r
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">\r
+    <TargetVersion>Windows10</TargetVersion>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\r
+    <ConfigurationType>Driver</ConfigurationType>\r
+    <DriverType>KMDF</DriverType>\r
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>\r
+    <KMDF_VERSION_MAJOR>1</KMDF_VERSION_MAJOR>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">\r
+    <TargetVersion>Windows10</TargetVersion>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\r
+    <ConfigurationType>Driver</ConfigurationType>\r
+    <DriverType>KMDF</DriverType>\r
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">\r
+    <TargetVersion>Windows10</TargetVersion>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\r
+    <ConfigurationType>Driver</ConfigurationType>\r
+    <DriverType>KMDF</DriverType>\r
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">\r
+    <TargetVersion>Windows10</TargetVersion>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\r
+    <ConfigurationType>Driver</ConfigurationType>\r
+    <DriverType>KMDF</DriverType>\r
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">\r
+    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">\r
+    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">\r
+    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">\r
+    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <WppEnabled>true</WppEnabled>\r
+      <WppRecorderEnabled>true</WppRecorderEnabled>\r
+      <WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>\r
+      <WppKernelMode>true</WppKernelMode>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WppEnabled>true</WppEnabled>\r
+      <WppRecorderEnabled>true</WppRecorderEnabled>\r
+      <WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>\r
+      <WppKernelMode>true</WppKernelMode>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <ClCompile>\r
+      <WppEnabled>true</WppEnabled>\r
+      <WppRecorderEnabled>true</WppRecorderEnabled>\r
+      <WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>\r
+      <WppKernelMode>true</WppKernelMode>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <ClCompile>\r
+      <WppEnabled>true</WppEnabled>\r
+      <WppRecorderEnabled>true</WppRecorderEnabled>\r
+      <WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>\r
+      <WppKernelMode>true</WppKernelMode>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">\r
+    <ClCompile>\r
+      <WppEnabled>true</WppEnabled>\r
+      <WppRecorderEnabled>true</WppRecorderEnabled>\r
+      <WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>\r
+      <WppKernelMode>true</WppKernelMode>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">\r
+    <ClCompile>\r
+      <WppEnabled>true</WppEnabled>\r
+      <WppRecorderEnabled>true</WppRecorderEnabled>\r
+      <WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>\r
+      <WppKernelMode>true</WppKernelMode>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">\r
+    <ClCompile>\r
+      <WppEnabled>true</WppEnabled>\r
+      <WppRecorderEnabled>true</WppRecorderEnabled>\r
+      <WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>\r
+      <WppKernelMode>true</WppKernelMode>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">\r
+    <ClCompile>\r
+      <WppEnabled>true</WppEnabled>\r
+      <WppRecorderEnabled>true</WppRecorderEnabled>\r
+      <WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>\r
+      <WppKernelMode>true</WppKernelMode>\r
+    </ClCompile>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <FilesToPackage Include="$(TargetPath)" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj.filters b/LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj.filters
new file mode 100644 (file)
index 0000000..65b7f24
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <Filter Include="Source Files">\r
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
+    </Filter>\r
+    <Filter Include="Header Files">\r
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
+    </Filter>\r
+    <Filter Include="Resource Files">\r
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
+    </Filter>\r
+    <Filter Include="Driver Files">\r
+      <UniqueIdentifier>{8E41214B-6785-4CFE-B992-037D68949A14}</UniqueIdentifier>\r
+      <Extensions>inf;inv;inx;mof;mc;</Extensions>\r
+    </Filter>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="ReadMe.txt" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Inf Include="TxnwLedLm3643.inf">\r
+      <Filter>Driver Files</Filter>\r
+    </Inf>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="Device.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="Driver.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="Trace.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="spb.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="Public.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="Device.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="Driver.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="spb.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+  </ItemGroup>\r
+</Project>
\ No newline at end of file
diff --git a/LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj.user b/LM3643/TxnwLedLm3643/TxnwLedLm3643.vcxproj.user
new file mode 100644 (file)
index 0000000..6fb136b
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup />\r
+</Project>
\ No newline at end of file
diff --git a/LM3643/TxnwLedLm3643/runsdvui.cmd b/LM3643/TxnwLedLm3643/runsdvui.cmd
new file mode 100644 (file)
index 0000000..b526a09
--- /dev/null
@@ -0,0 +1,2 @@
+cd /d "C:\Dev\WinDrv\LM3643-2016-0217\LM3643\TxnwLedLm3643\TxnwLedLm3643" &msbuild "TxnwLedLm3643.vcxproj" /t:sdvViewer /p:configuration="Debug" /p:platform=ARM\r
+exit %errorlevel% 
\ No newline at end of file
diff --git a/LM3643/TxnwLedLm3643/spb.c b/LM3643/TxnwLedLm3643/spb.c
new file mode 100644 (file)
index 0000000..0a2565f
--- /dev/null
@@ -0,0 +1,508 @@
+/*++\r
+The Microsoft Public License (MS-PL)\r
+Copyright (c) 2015 Microsoft\r
+\r
+This license governs use of the accompanying software. If you use the software, you\r
+accept this license. If you do not accept the license, do not use the software.\r
+\r
+1. Definitions\r
+The terms "reproduce," "reproduction," "derivative works," and "distribution" have \r
+the same meaning here as under U.S. copyright law.\r
+A "contribution" is the original software, or any additions or changes to the software.\r
+A "contributor" is any person that distributes its contribution under this license.\r
+"Licensed patents" are a contributor's patent claims that read directly on its contribution.\r
+\r
+2. Grant of Rights\r
+(A) Copyright Grant- Subject to the terms of this license, including the license conditions \r
+and limitations in section 3, each contributor grants you a non-exclusive, worldwide, \r
+royalty-free copyright license to reproduce its contribution, prepare derivative works of \r
+its contribution, and distribute its contribution or any derivative works that you create.\r
+(B) Patent Grant- Subject to the terms of this license, including the license conditions \r
+and limitations in section 3, each contributor grants you a non-exclusive, worldwide, \r
+royalty-free license under its licensed patents to make, have made, use, sell, offer for \r
+sale, import, and/or otherwise dispose of its contribution in the software or derivative \r
+works of the contribution in the software.\r
+\r
+3. Conditions and Limitations\r
+(A) No Trademark License- This license does not grant you rights to use any contributors' \r
+name, logo, or trademarks.\r
+(B) If you bring a patent claim against any contributor over patents that you claim are \r
+infringed by the software, your patent license from such contributor to the software ends \r
+automatically.\r
+(C) If you distribute any portion of the software, you must retain all copyright, patent, \r
+trademark, and attribution notices that are present in the software.\r
+(D) If you distribute any portion of the software in source code form, you may do so only \r
+under this license by including a complete copy of this license with your distribution. \r
+If you distribute any portion of the software in compiled or object code form, you may \r
+only do so under a license that complies with this license.\r
+(E) The software is licensed "as-is." You bear the risk of using it. The contributors \r
+give no express warranties, guarantees or conditions. You may have additional consumer \r
+rights under your local laws which this license cannot change. To the extent permitted \r
+under your local laws, the contributors exclude the implied warranties of merchantability, \r
+fitness for a particular purpose and non-infringement.\r
+Sample code. Dealpoint ID #843729.\r
+\r
+Module Name:\r
+\r
+spb.c\r
+\r
+Abstract:\r
+\r
+Contains all I2C-specific functionality\r
+\r
+Environment:\r
+\r
+Kernel mode\r
+\r
+Revision History:\r
+    Modified for LED driver. \r
+--*/\r
+#include "driver.h"\r
+#include "spb.tmh"\r
+\r
+#ifdef ALLOC_PRAGMA\r
+#endif\r
+\r
+NTSTATUS\r
+SpbDoWriteDataSynchronously(\r
+       IN SPB_CONTEXT *SpbContext,\r
+       IN UCHAR Address,\r
+       IN PVOID Data,\r
+       IN ULONG Length\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This helper routine abstracts creating and sending an I/O\r
+       request (I2C Write) to the Spb I/O target.\r
+\r
+       Arguments:\r
+\r
+       SpbContext - Pointer to the current device context\r
+       Address    - The I2C register address to write to\r
+       Data       - A buffer to receive the data at at the above address\r
+       Length     - The amount of data to be read from the above address\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS Status indicating success or failure\r
+\r
+       --*/\r
+{\r
+       PUCHAR buffer;\r
+       ULONG length;\r
+       WDFMEMORY memory;\r
+       WDF_MEMORY_DESCRIPTOR memoryDescriptor;\r
+       NTSTATUS status;\r
+\r
+       //\r
+       // The address pointer and data buffer must be combined\r
+       // into one contiguous buffer representing the write transaction.\r
+       //\r
+       length = Length + 1;\r
+       memory = NULL;\r
+\r
+       if (length > DEFAULT_SPB_BUFFER_SIZE)\r
+       {\r
+               status = WdfMemoryCreate(\r
+                       WDF_NO_OBJECT_ATTRIBUTES,\r
+                       NonPagedPool,\r
+                       LED_POOL_TAG,\r
+                       length,\r
+                       &memory,\r
+                       &buffer);\r
+\r
+               if (!NT_SUCCESS(status))\r
+               {\r
+                       TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB, "Error allocating memory for Spb write - %!STATUS!", status);\r
+                       goto exit;\r
+               }\r
+\r
+               WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(\r
+                       &memoryDescriptor,\r
+                       memory,\r
+                       NULL);\r
+       }\r
+       else\r
+       {\r
+               buffer = (PUCHAR)WdfMemoryGetBuffer(SpbContext->WriteMemory, NULL);\r
+\r
+               WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(\r
+                       &memoryDescriptor,\r
+                       (PVOID)buffer,\r
+                       length);\r
+       }\r
+\r
+       //\r
+       // Transaction starts by specifying the address bytes\r
+       //\r
+       RtlCopyMemory(buffer, &Address, sizeof(Address));\r
+\r
+       //\r
+       // Address is followed by the data payload\r
+       //\r
+       RtlCopyMemory((buffer + sizeof(Address)), Data, length - sizeof(Address));\r
+\r
+       status = WdfIoTargetSendWriteSynchronously(\r
+               SpbContext->SpbIoTarget,\r
+               NULL,\r
+               &memoryDescriptor,\r
+               NULL,\r
+               NULL,\r
+               NULL);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error writing to Spb - %!STATUS!",status);\r
+               goto exit;\r
+       }\r
+\r
+exit:\r
+\r
+       if (NULL != memory)\r
+       {\r
+               WdfObjectDelete(memory);\r
+       }\r
+\r
+       return status;\r
+}\r
+\r
+NTSTATUS\r
+SpbWriteDataSynchronously(\r
+       IN SPB_CONTEXT *SpbContext,\r
+       IN UCHAR Address,\r
+       IN PVOID Data,\r
+       IN ULONG Length\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This routine abstracts creating and sending an I/O\r
+       request (I2C Write) to the Spb I/O target and utilizes\r
+       a helper routine to do work inside of locked code.\r
+\r
+       Arguments:\r
+\r
+       SpbContext - Pointer to the current device context\r
+       Address    - The I2C register address to write to\r
+       Data       - A buffer to receive the data at at the above address\r
+       Length     - The amount of data to be read from the above address\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS Status indicating success or failure\r
+\r
+       --*/\r
+{\r
+       NTSTATUS status;\r
+\r
+       WdfWaitLockAcquire(SpbContext->SpbLock, NULL);\r
+\r
+       status = SpbDoWriteDataSynchronously(\r
+               SpbContext,\r
+               Address,\r
+               Data,\r
+               Length);\r
+\r
+       WdfWaitLockRelease(SpbContext->SpbLock);\r
+\r
+       return status;\r
+}\r
+\r
+NTSTATUS\r
+SpbReadDataSynchronously(\r
+       _In_ SPB_CONTEXT *SpbContext,\r
+       _In_ UCHAR Address,\r
+       _In_reads_bytes_(Length) PVOID Data,\r
+       _In_ ULONG Length\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This helper routine abstracts creating and sending an I/O\r
+       request (I2C Read) to the Spb I/O target.\r
+\r
+       Arguments:\r
+\r
+       SpbContext - Pointer to the current device context\r
+       Address    - The I2C register address to read from\r
+       Data       - A buffer to receive the data at at the above address\r
+       Length     - The amount of data to be read from the above address\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS Status indicating success or failure\r
+\r
+       --*/\r
+{\r
+       PUCHAR buffer;\r
+       WDFMEMORY memory;\r
+       WDF_MEMORY_DESCRIPTOR memoryDescriptor;\r
+       NTSTATUS status;\r
+       ULONG_PTR bytesRead;\r
+\r
+       WdfWaitLockAcquire(SpbContext->SpbLock, NULL);\r
+\r
+       memory = NULL;\r
+       status = STATUS_INVALID_PARAMETER;\r
+       bytesRead = 0;\r
+\r
+       //\r
+       // Read transactions start by writing an address pointer\r
+       //\r
+       status = SpbDoWriteDataSynchronously(\r
+               SpbContext,\r
+               Address,\r
+               NULL,\r
+               0);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               //TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error setting address pointer for Spb read - %!STATUS!",status);\r
+               goto exit;\r
+       }\r
+\r
+       if (Length > DEFAULT_SPB_BUFFER_SIZE)\r
+       {\r
+               status = WdfMemoryCreate(\r
+                       WDF_NO_OBJECT_ATTRIBUTES,\r
+                       NonPagedPool,\r
+                       LED_POOL_TAG,\r
+                       Length,\r
+                       &memory,\r
+                       &buffer);\r
+\r
+               if (!NT_SUCCESS(status))\r
+               {\r
+                       //TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error allocating memory for Spb read - %!STATUS!",status);\r
+                       goto exit;\r
+               }\r
+\r
+               WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(\r
+                       &memoryDescriptor,\r
+                       memory,\r
+                       NULL);\r
+       }\r
+       else\r
+       {\r
+               buffer = (PUCHAR)WdfMemoryGetBuffer(SpbContext->ReadMemory, NULL);\r
+\r
+               WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(\r
+                       &memoryDescriptor,\r
+                       (PVOID)buffer,\r
+                       Length);\r
+       }\r
+\r
+\r
+       status = WdfIoTargetSendReadSynchronously(\r
+               SpbContext->SpbIoTarget,\r
+               NULL,\r
+               &memoryDescriptor,\r
+               NULL,\r
+               NULL,\r
+               &bytesRead);\r
+\r
+       if (!NT_SUCCESS(status) ||\r
+               bytesRead != Length)\r
+       {\r
+               //TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error reading from Spb - %!STATUS!",status);\r
+               goto exit;\r
+       }\r
+\r
+       //\r
+       // Copy back to the caller's buffer\r
+       //\r
+       RtlCopyMemory(Data, buffer, Length);\r
+\r
+exit:\r
+       if (NULL != memory)\r
+       {\r
+               WdfObjectDelete(memory);\r
+       }\r
+\r
+       WdfWaitLockRelease(SpbContext->SpbLock);\r
+\r
+       return status;\r
+}\r
+\r
+VOID\r
+SpbTargetDeinitialize(\r
+       IN WDFDEVICE FxDevice,\r
+       IN SPB_CONTEXT *SpbContext\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This helper routine is used to free any members added to the SPB_CONTEXT,\r
+       note the SPB I/O target is parented to the device and will be\r
+       closed and free'd when the device is removed.\r
+\r
+       Arguments:\r
+\r
+       FxDevice   - Handle to the framework device object\r
+       SpbContext - Pointer to the current device context\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS Status indicating success or failure\r
+\r
+       --*/\r
+{\r
+       UNREFERENCED_PARAMETER(FxDevice);\r
+       UNREFERENCED_PARAMETER(SpbContext);\r
+\r
+       //\r
+       // Free any SPB_CONTEXT allocations here\r
+       //\r
+       if (SpbContext->SpbLock != NULL)\r
+       {\r
+               WdfObjectDelete(SpbContext->SpbLock);\r
+       }\r
+\r
+       if (SpbContext->ReadMemory != NULL)\r
+       {\r
+               WdfObjectDelete(SpbContext->ReadMemory);\r
+       }\r
+\r
+       if (SpbContext->WriteMemory != NULL)\r
+       {\r
+               WdfObjectDelete(SpbContext->WriteMemory);\r
+       }\r
+}\r
+\r
+NTSTATUS\r
+SpbTargetInitialize(\r
+       IN WDFDEVICE FxDevice,\r
+       IN SPB_CONTEXT *SpbContext\r
+       )\r
+       /*++\r
+\r
+       Routine Description:\r
+\r
+       This helper routine opens the Spb I/O target and\r
+       initializes a request object used for the lifetime\r
+       of communication between this driver and Spb.\r
+\r
+       Arguments:\r
+\r
+       FxDevice   - Handle to the framework device object\r
+       SpbContext - Pointer to the current device context\r
+\r
+       Return Value:\r
+\r
+       NTSTATUS Status indicating success or failure\r
+\r
+       --*/\r
+{\r
+       WDF_OBJECT_ATTRIBUTES objectAttributes;\r
+       WDF_IO_TARGET_OPEN_PARAMS openParams;\r
+       UNICODE_STRING spbDeviceName;\r
+       WCHAR spbDeviceNameBuffer[RESOURCE_HUB_PATH_SIZE];\r
+       NTSTATUS status;\r
+\r
+       WDF_OBJECT_ATTRIBUTES_INIT(&objectAttributes);\r
+       objectAttributes.ParentObject = FxDevice;\r
+\r
+       status = WdfIoTargetCreate(\r
+               FxDevice,\r
+               &objectAttributes,\r
+               &SpbContext->SpbIoTarget);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error creating IoTarget object - %!STATUS!",status);\r
+               WdfObjectDelete(SpbContext->SpbIoTarget);\r
+               goto exit;\r
+       }\r
+\r
+       RtlInitEmptyUnicodeString(\r
+               &spbDeviceName,\r
+               spbDeviceNameBuffer,\r
+               sizeof(spbDeviceNameBuffer));\r
+\r
+       status = RESOURCE_HUB_CREATE_PATH_FROM_ID(\r
+               &spbDeviceName,\r
+               SpbContext->I2cResHubId.LowPart,\r
+               SpbContext->I2cResHubId.HighPart);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error creating Spb resource hub path string - %!STATUS!",status);\r
+               goto exit;\r
+       }\r
+\r
+       WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(\r
+               &openParams,\r
+               &spbDeviceName,\r
+               (GENERIC_READ | GENERIC_WRITE));\r
+\r
+       openParams.ShareAccess = 0;\r
+       openParams.CreateDisposition = FILE_OPEN;\r
+       openParams.FileAttributes = FILE_ATTRIBUTE_NORMAL;\r
+\r
+       status = WdfIoTargetOpen(SpbContext->SpbIoTarget, &openParams);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error opening Spb target for communication - %!STATUS!",status);\r
+               goto exit;\r
+       }\r
+\r
+       //\r
+       // Allocate some fixed-size buffers from NonPagedPool for typical\r
+       // Spb transaction sizes to avoid pool fragmentation in most cases\r
+       //\r
+       status = WdfMemoryCreate(\r
+               WDF_NO_OBJECT_ATTRIBUTES,\r
+               NonPagedPool,\r
+               LED_POOL_TAG,\r
+               DEFAULT_SPB_BUFFER_SIZE,\r
+               &SpbContext->WriteMemory,\r
+               NULL);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error allocating default memory for Spb write - %!STATUS!",status);\r
+               goto exit;\r
+       }\r
+\r
+       status = WdfMemoryCreate(\r
+               WDF_NO_OBJECT_ATTRIBUTES,\r
+               NonPagedPool,\r
+               LED_POOL_TAG,\r
+               DEFAULT_SPB_BUFFER_SIZE,\r
+               &SpbContext->ReadMemory,\r
+               NULL);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error allocating default memory for Spb read - %!STATUS!",status);\r
+               goto exit;\r
+       }\r
+\r
+       //\r
+       // Allocate a waitlock to guard access to the default buffers\r
+       //\r
+       status = WdfWaitLockCreate(\r
+               WDF_NO_OBJECT_ATTRIBUTES,\r
+               &SpbContext->SpbLock);\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               TraceEvents(TRACE_LEVEL_ERROR, TRACE_SPB,"Error creating Spb Waitlock - %!STATUS!",status);\r
+               goto exit;\r
+       }\r
+\r
+exit:\r
+\r
+       if (!NT_SUCCESS(status))\r
+       {\r
+               SpbTargetDeinitialize(FxDevice, SpbContext);\r
+       }\r
+\r
+       return status;\r
+}\r
diff --git a/LM3643/TxnwLedLm3643/spb.h b/LM3643/TxnwLedLm3643/spb.h
new file mode 100644 (file)
index 0000000..c2741a9
--- /dev/null
@@ -0,0 +1,108 @@
+/*++\r
+The Microsoft Public License (MS-PL)\r
+Copyright (c) 2015 Microsoft\r
+\r
+This license governs use of the accompanying software. If you use the software, you\r
+accept this license. If you do not accept the license, do not use the software.\r
+\r
+1. Definitions\r
+The terms "reproduce," "reproduction," "derivative works," and "distribution" have\r
+the same meaning here as under U.S. copyright law.\r
+A "contribution" is the original software, or any additions or changes to the software.\r
+A "contributor" is any person that distributes its contribution under this license.\r
+"Licensed patents" are a contributor's patent claims that read directly on its contribution.\r
+\r
+2. Grant of Rights\r
+(A) Copyright Grant- Subject to the terms of this license, including the license conditions\r
+and limitations in section 3, each contributor grants you a non-exclusive, worldwide,\r
+royalty-free copyright license to reproduce its contribution, prepare derivative works of\r
+its contribution, and distribute its contribution or any derivative works that you create.\r
+(B) Patent Grant- Subject to the terms of this license, including the license conditions\r
+and limitations in section 3, each contributor grants you a non-exclusive, worldwide,\r
+royalty-free license under its licensed patents to make, have made, use, sell, offer for\r
+sale, import, and/or otherwise dispose of its contribution in the software or derivative\r
+works of the contribution in the software.\r
+\r
+3. Conditions and Limitations\r
+(A) No Trademark License- This license does not grant you rights to use any contributors'\r
+name, logo, or trademarks.\r
+(B) If you bring a patent claim against any contributor over patents that you claim are\r
+infringed by the software, your patent license from such contributor to the software ends\r
+automatically.\r
+(C) If you distribute any portion of the software, you must retain all copyright, patent,\r
+trademark, and attribution notices that are present in the software.\r
+(D) If you distribute any portion of the software in source code form, you may do so only\r
+under this license by including a complete copy of this license with your distribution.\r
+If you distribute any portion of the software in compiled or object code form, you may\r
+only do so under a license that complies with this license.\r
+(E) The software is licensed "as-is." You bear the risk of using it. The contributors\r
+give no express warranties, guarantees or conditions. You may have additional consumer\r
+rights under your local laws which this license cannot change. To the extent permitted\r
+under your local laws, the contributors exclude the implied warranties of merchantability,\r
+fitness for a particular purpose and non-infringement.\r
+Sample code. Dealpoint ID #843729.\r
+\r
+Module Name:\r
+\r
+spb.h\r
+\r
+Abstract:\r
+\r
+This module contains the touch driver I2C helper definitions.\r
+\r
+Environment:\r
+\r
+Kernel Mode\r
+\r
+Revision History:\r
+    Modified for LED driver. \r
+\r
+--*/\r
+\r
+#pragma once\r
+\r
+#include <wdm.h>\r
+#include <wdf.h>\r
+\r
+#define DEFAULT_SPB_BUFFER_SIZE 64\r
+\r
+//\r
+// SPB (I2C) context\r
+//\r
+\r
+typedef struct _SPB_CONTEXT\r
+{\r
+       WDFIOTARGET SpbIoTarget;\r
+       LARGE_INTEGER I2cResHubId;\r
+       WDFMEMORY WriteMemory;\r
+       WDFMEMORY ReadMemory;\r
+       WDFWAITLOCK SpbLock;\r
+} SPB_CONTEXT;\r
+\r
+NTSTATUS\r
+SpbReadDataSynchronously(\r
+       _In_ SPB_CONTEXT *SpbContext,\r
+       _In_ UCHAR Address,\r
+       _In_reads_bytes_(Length) PVOID Data,\r
+       _In_ ULONG Length\r
+       );\r
+\r
+VOID\r
+SpbTargetDeinitialize(\r
+       IN WDFDEVICE FxDevice,\r
+       IN SPB_CONTEXT *SpbContext\r
+       );\r
+\r
+NTSTATUS\r
+SpbTargetInitialize(\r
+       IN WDFDEVICE FxDevice,\r
+       IN SPB_CONTEXT *SpbContext\r
+       );\r
+\r
+NTSTATUS\r
+SpbWriteDataSynchronously(\r
+       IN SPB_CONTEXT *SpbContext,\r
+       IN UCHAR Address,\r
+       IN PVOID Data,\r
+       IN ULONG Length\r
+       );\r
diff --git a/LM3643/asl/RPI2/ACPITABL.dat b/LM3643/asl/RPI2/ACPITABL.dat
new file mode 100644 (file)
index 0000000..49b3cd8
Binary files /dev/null and b/LM3643/asl/RPI2/ACPITABL.dat differ
diff --git a/LM3643/asl/RPI2/rpi2.asl b/LM3643/asl/RPI2/rpi2.asl
new file mode 100644 (file)
index 0000000..4dc1bb8
--- /dev/null
@@ -0,0 +1,41 @@
+//
+//    Copyright (c) Texas Instruments Inc. All Rights Reserved.
+//
+//    The MIT License(MIT)
+//
+//    Permission is hereby granted, free of charge, to any person obtaining a copy
+//    of this software and associated documentation files(the "Software"), to deal
+//    in the Software without restriction, including without limitation the rights
+//    to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+//    copies of the Software, and to permit persons to whom the Software is
+//    furnished to do so, subject to the following conditions :
+//
+//    The above copyright notice and this permission notice shall be included in
+//    all copies or substantial portions of the Software.
+//
+//    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+//    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+//    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+//    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+//    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+//    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+//    THE SOFTWARE.
+//
+DefinitionBlock ("ACPITABL.dat", "SSDT", 1, "MSFT", "SPBT", 1)
+{
+    Scope (\_SB)
+    {
+        //
+        // Test peripheral device node for RPi2
+        //
+        Device(SPBT)
+        {
+            Name(_HID, "OEM_LED")
+            Name(_UID, 0)
+            Name(_CRS, ResourceTemplate()
+            {
+                I2CSerialBus(0x63, ControllerInitiated, 100000, AddressingMode7Bit, "\\_SB.I2C1", , )            
+            })
+        }
+    }
+}