]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Added possibility to specify startbit in driver
authormahi <devnull@localhost>
Mon, 20 Jun 2011 18:47:46 +0000 (20:47 +0200)
committermahi <devnull@localhost>
Mon, 20 Jun 2011 18:47:46 +0000 (20:47 +0200)
arch/ppc/mpc55xx/drivers/Spi.c

index 6a8e6551c6b4f2f47b0f2f158b660eef43425f6d..07872630f9fcd09b730be139bfd0927d66804cd1 100644 (file)
 // E2 read = cmd + addr + data = 1 + 2 + 64 ) = 67 ~ 72\r
 #define SPI_INTERNAL_MTU    72\r
 \r
+/* The depth of the HW FIFO */\r
 #define FIFO_DEPTH                     5\r
 \r
+/* Define for debug purposes, checks that SPI/DMA is ok */\r
 //#define STEP_VALIDATION              1\r
 \r
 #define MODULE_NAME    "/driver/Spi"\r
@@ -1034,9 +1036,12 @@ uint8 clk_table_pbr[] = { 2, 3, 5, 7 };
  * @param ctar_unit - The ctar unit number to setup\r
  * @param width - The width in bits of the data to send with the CTAR\r
  */\r
-static void Spi_SetupCTAR(Spi_HWUnitType unit,\r
-               const Spi_ExternalDeviceType *extDev, Spi_ChannelType ctar_unit,\r
-               uint8 width) {\r
+static void Spi_SetupCTAR(     Spi_HWUnitType unit,\r
+                                                       const Spi_ExternalDeviceType *extDev,\r
+                                                       Spi_ChannelType ctar_unit,\r
+                                                       Spi_TransferStartType transferStart,\r
+                                                       uint8 width)\r
+{\r
        uint32 clock;\r
        uint32 pre_br;\r
        int i;\r
@@ -1199,7 +1204,8 @@ static void Spi_SetupCTAR(Spi_HWUnitType unit,
                        clk_table_asc[spiHw->CTAR[ctar_unit].B.DT]*1000/(clock/1000000));\r
 \r
        /* Data is transferred MSB first */\r
-       spiHw->CTAR[ctar_unit].B.LSBFE = 0;\r
+\r
+       spiHw->CTAR[ctar_unit].B.LSBFE = (transferStart == SPI_TRANSFER_START_MSB ) ? 0 : 1;\r
 \r
        /* Set mode */\r
        spiHw->CTAR[ctar_unit].B.FMSZ = width - 1;\r
@@ -1420,9 +1426,10 @@ void Spi_Init(const Spi_ConfigType *ConfigPtr) {
                                chConfig = &Spi_Global.configPtr->SpiChannelConfig[channelIndex];\r
 \r
                                // Form a channel code from\r
-                               // <external_device_id><channel width>\r
-                               channelCode = ((jobConfig->DeviceAssignment << 8)\r
-                                               + chConfig->SpiDataWidth);\r
+                               // <MSB/LSB><external_device_id><channel width>\r
+                               channelCode = ( ((uint32_t)chConfig->SpiTransferStart << 16) +\r
+                                                               (jobConfig->DeviceAssignment << 8) +\r
+                                                               chConfig->SpiDataWidth);\r
 \r
                                for (k = 0; k < 7; k++) {\r
                                        if (spiUnit->channelCodes[k] == channelCode) {\r
@@ -1438,15 +1445,19 @@ void Spi_Init(const Spi_ConfigType *ConfigPtr) {
                                                // Assign the CTAR index to channel info..\r
                                                DEBUG(DEBUG_LOW,"%s: Channel %d uses    CTAR %d@%d . device=%d,width=%d\n",MODULE_NAME,channelIndex,k,jobConfig->SpiHwUnit,jobConfig->DeviceAssignment,chConfig->SpiDataWidth);\r
 \r
-                                               Spi_SetupCTAR(jobConfig->SpiHwUnit,\r
-                                                               Spi_GetExternalDevicePtrFromIndex(\r
-                                                                               jobConfig->DeviceAssignment),\r
-                                                               (Spi_ChannelType) k, chConfig->SpiDataWidth);\r
+                                               Spi_SetupCTAR(\r
+                                                               jobConfig->SpiHwUnit,\r
+                                                               Spi_GetExternalDevicePtrFromIndex( jobConfig->DeviceAssignment),\r
+                                                               (Spi_ChannelType) k,\r
+                                                               chConfig->SpiTransferStart,\r
+                                                               chConfig->SpiDataWidth);\r
 \r
                                                Spi_ChannelInfo[channelIndex].ctarId = k;\r
                                                break;\r
                                        }\r
                                }\r
+                               /* No more CTARS */\r
+                               assert(k<7);\r
                        }\r
                }\r
        }\r