iwlwifi: add default WEP key host command
[safe/jmp/linux-2.6] / drivers / spi / spi_imx.c
index 6ccf8a1..1b06471 100644 (file)
                                                        32.768 KHz Clock */
 
 /* SPI DMA Register Bit Fields & Masks */
-#define SPI_DMA_RHDMA  (0xF << 4)      /* RXFIFO Half Status */
+#define SPI_DMA_RHDMA  (0x1 << 4)      /* RXFIFO Half Status */
 #define SPI_DMA_RFDMA  (0x1 << 5)      /* RXFIFO Full Status */
 #define SPI_DMA_TEDMA  (0x1 << 6)      /* TXFIFO Empty Status */
 #define SPI_DMA_THDMA  (0x1 << 7)      /* TXFIFO Half Status */
 #define SPI_FIFO_BYTE_WIDTH            (2)
 #define SPI_FIFO_OVERFLOW_MARGIN       (2)
 
-/* DMA burst lenght for half full/empty request trigger */
+/* DMA burst length for half full/empty request trigger */
 #define SPI_DMA_BLR                    (SPI_FIFO_DEPTH * SPI_FIFO_BYTE_WIDTH / 2)
 
 /* Dummy char output to achieve reads.
@@ -1163,6 +1163,9 @@ msg_rejected:
        return -EINVAL;
 }
 
+/* the spi->mode bits understood by this driver: */
+#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH)
+
 /* On first setup bad values must free chip_data memory since will cause
    spi_new_device to fail. Bad value setup from protocol driver are simply not
    applied and notified to the calling driver. */
@@ -1174,6 +1177,12 @@ static int setup(struct spi_device *spi)
        u32 tmp;
        int status = 0;
 
+       if (spi->mode & ~MODEBITS) {
+               dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n",
+                       spi->mode & ~MODEBITS);
+               return -EINVAL;
+       }
+
        /* Get controller data */
        chip_info = spi->controller_data;
 
@@ -1185,7 +1194,7 @@ static int setup(struct spi_device *spi)
                chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
                if (!chip) {
                        dev_err(&spi->dev,
-                               "setup - cannot allocate controller state");
+                               "setup - cannot allocate controller state\n");
                        return -ENOMEM;
                }
                chip->control = SPI_DEFAULT_CONTROL;
@@ -1197,7 +1206,7 @@ static int setup(struct spi_device *spi)
                        if (!chip_info) {
                                dev_err(&spi->dev,
                                        "setup - "
-                                       "cannot allocate controller data");
+                                       "cannot allocate controller data\n");
                                status = -ENOMEM;
                                goto err_first_setup;
                        }
@@ -1245,21 +1254,6 @@ static int setup(struct spi_device *spi)
 
        /* SPI mode */
        tmp = spi->mode;
-       if (tmp & SPI_LSB_FIRST) {
-               status = -EINVAL;
-               if (first_setup) {
-                       dev_err(&spi->dev,
-                               "setup - "
-                               "HW doesn't support LSB first transfer\n");
-                       goto err_first_setup;
-               } else {
-                       dev_err(&spi->dev,
-                               "setup - "
-                               "HW doesn't support LSB first transfer, "
-                               "default to MSB first\n");
-                       spi->mode &= ~SPI_LSB_FIRST;
-               }
-       }
        if (tmp & SPI_CS_HIGH) {
                u32_EDIT(chip->control,
                                SPI_CONTROL_SSPOL, SPI_CONTROL_SSPOL_ACT_HIGH);
@@ -1355,19 +1349,19 @@ static int setup(struct spi_device *spi)
                spi->bits_per_word,
                spi_speed_hz(SPI_CONTROL_DATARATE_MIN),
                spi->max_speed_hz);
+       return status;
 
 err_first_setup:
        kfree(chip);
        return status;
 }
 
-static void cleanup(const struct spi_device *spi)
+static void cleanup(struct spi_device *spi)
 {
-       struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
-       kfree(chip);
+       kfree(spi_get_ctldata(spi));
 }
 
-static int init_queue(struct driver_data *drv_data)
+static int __init init_queue(struct driver_data *drv_data)
 {
        INIT_LIST_HEAD(&drv_data->queue);
        spin_lock_init(&drv_data->lock);
@@ -1380,7 +1374,7 @@ static int init_queue(struct driver_data *drv_data)
 
        INIT_WORK(&drv_data->work, pump_messages);
        drv_data->workqueue = create_singlethread_workqueue(
-                                       drv_data->master->cdev.dev->bus_id);
+                                       drv_data->master->dev.parent->bus_id);
        if (drv_data->workqueue == NULL)
                return -EBUSY;
 
@@ -1450,7 +1444,7 @@ static int destroy_queue(struct driver_data *drv_data)
        return 0;
 }
 
-static int spi_imx_probe(struct platform_device *pdev)
+static int __init spi_imx_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct spi_imx_master *platform_info;
@@ -1628,7 +1622,7 @@ err_no_mem:
        return status;
 }
 
-static int __devexit spi_imx_remove(struct platform_device *pdev)
+static int __exit spi_imx_remove(struct platform_device *pdev)
 {
        struct driver_data *drv_data = platform_get_drvdata(pdev);
        int irq;
@@ -1692,17 +1686,6 @@ static void spi_imx_shutdown(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM
-static int suspend_devices(struct device *dev, void *pm_message)
-{
-       pm_message_t *state = pm_message;
-
-       if (dev->power.power_state.event != state->event) {
-               dev_warn(dev, "pm state does not match request\n");
-               return -1;
-       }
-
-       return 0;
-}
 
 static int spi_imx_suspend(struct platform_device *pdev, pm_message_t state)
 {
@@ -1741,12 +1724,11 @@ static int spi_imx_resume(struct platform_device *pdev)
 
 static struct platform_driver driver = {
        .driver = {
-               .name = "imx-spi",
+               .name = "spi_imx",
                .bus = &platform_bus_type,
                .owner = THIS_MODULE,
        },
-       .probe = spi_imx_probe,
-       .remove = __devexit_p(spi_imx_remove),
+       .remove = __exit_p(spi_imx_remove),
        .shutdown = spi_imx_shutdown,
        .suspend = spi_imx_suspend,
        .resume = spi_imx_resume,
@@ -1754,7 +1736,7 @@ static struct platform_driver driver = {
 
 static int __init spi_imx_init(void)
 {
-       return platform_driver_register(&driver);
+       return platform_driver_probe(&driver, spi_imx_probe);
 }
 module_init(spi_imx_init);
 
@@ -1765,5 +1747,5 @@ static void __exit spi_imx_exit(void)
 module_exit(spi_imx_exit);
 
 MODULE_AUTHOR("Andrea Paterniani, <a.paterniani@swapp-eng.it>");
-MODULE_DESCRIPTION("iMX SPI Contoller Driver");
+MODULE_DESCRIPTION("iMX SPI Controller Driver");
 MODULE_LICENSE("GPL");