2011-06-23 02:00:47

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 00/11] RFC spi-dw updates

From: Dirk Brandewie <[email protected]>

This patch set contains a number of changes were buried inside of one
large patch in my last patch set. The rework of the message/transfer
handling changes are not part of this patch set.


This patch set applies after commit ca632f5 on spi/next


Dirk Brandewie (11):
spi-dw: expose platform data stucture.
spi-dw: update function naming convention to match file naming
spi-dw: change MRST prefix to generic prefix
spi-dw: remove unused definition
spi-dw: split spi_dw_enable_chip() into spi_dw_enable()/spi_dw_disable()
spi-dw: Force error on out of range chip select.
spi-dw: Set number of available chip selects correctly
spi-dw: Ensure fifo lenght is set.
spi-dw: Fix condition in spi_dw_{writer/reader}
spi-dw: Move checking of max_speed_hz value to be a prerequisite in spi_dw_setup
spi-dw: remove noop else clause

drivers/spi/spi-dw-mid.c | 30 +++---
drivers/spi/spi-dw-mmio.c | 38 ++++----
drivers/spi/spi-dw-pci.c | 34 +++---
drivers/spi/spi-dw.c | 247 ++++++++++++++++++++------------------------
drivers/spi/spi-dw.h | 82 ++++++---------
include/linux/spi/spi-dw.h | 42 ++++++++
6 files changed, 241 insertions(+), 232 deletions(-)
create mode 100644 include/linux/spi/spi-dw.h

--
1.7.3.4


2011-06-23 02:00:49

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 01/11] spi-dw: expose platform data stucture.

From: Dirk Brandewie <[email protected]>

Expose the platform data structure for use by client drivers. ATM
there are not any in-tree drivers using the driver (that I can
find). This patch exposes the platform data needed for client drivers.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.c | 3 ---
drivers/spi/spi-dw.h | 18 +-----------------
include/linux/spi/spi-dw.h | 42 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+), 20 deletions(-)
create mode 100644 include/linux/spi/spi-dw.h

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index ece5f69..61f7ed8 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -38,9 +38,6 @@
#define QUEUE_RUNNING 0
#define QUEUE_STOPPED 1

-#define MRST_SPI_DEASSERT 0
-#define MRST_SPI_ASSERT 1
-
/* Slave spi_dev related */
struct chip_data {
u16 cr0;
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 7a5e78d..92bee30 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -3,6 +3,7 @@

#include <linux/io.h>
#include <linux/scatterlist.h>
+#include <linux/spi/spi-dw.h>

/* Bit fields in CTRLR0 */
#define SPI_DFS_OFFSET 0
@@ -49,11 +50,6 @@
/* TX RX interrupt level threshold, max can be 256 */
#define SPI_INT_THRESHOLD 32

-enum dw_ssi_type {
- SSI_MOTO_SPI = 0,
- SSI_TI_SSP,
- SSI_NS_MICROWIRE,
-};

struct dw_spi_reg {
u32 ctrl0;
@@ -208,18 +204,6 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
dw_writel(dws, imr, new_mask);
}

-/*
- * Each SPI slave device to work with dw_api controller should
- * has such a structure claiming its working mode (PIO/DMA etc),
- * which can be save in the "controller_data" member of the
- * struct spi_device
- */
-struct dw_spi_chip {
- u8 poll_mode; /* 0 for contoller polling mode */
- u8 type; /* SPI/SSP/Micrwire */
- u8 enable_dma;
- void (*cs_control)(u32 command);
-};

extern int dw_spi_add_host(struct dw_spi *dws);
extern void dw_spi_remove_host(struct dw_spi *dws);
diff --git a/include/linux/spi/spi-dw.h b/include/linux/spi/spi-dw.h
new file mode 100644
index 0000000..787b154
--- /dev/null
+++ b/include/linux/spi/spi-dw.h
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright (c) 2009, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _SPI_DW_H_
+#define _SPI_DW_H_
+enum spi_dw_ssi_type {
+ SSI_MOTO_SPI = 0,
+ SSI_TI_SSP,
+ SSI_NS_MICROWIRE,
+};
+
+#define MRST_SPI_DEASSERT 0
+#define MRST_SPI_ASSERT 1
+
+/*
+ * Each SPI slave device to work with dw_api controller should
+ * has such a structure claiming its working mode (PIO/DMA etc),
+ * which can be save in the "controller_data" member of the
+ * struct spi_device
+ */
+struct spi_dw_chip {
+ u8 poll_mode; /* 0 for contoller polling mode */
+ u8 type; /* SPI/SSP/Micrwire */
+ u8 enable_dma;
+ void (*cs_control)(u32 command);
+};
+#endif
--
1.7.3.4

2011-06-23 02:00:52

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 02/11] spi-dw: update function naming convention to match file naming

From: Dirk Brandewie <[email protected]>

The file naming convention for drivers in the SPI subsystem is now
being enforced update internal naming convention to match file naming.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw-mid.c | 26 +++---
drivers/spi/spi-dw-mmio.c | 38 +++++-----
drivers/spi/spi-dw-pci.c | 34 ++++----
drivers/spi/spi-dw.c | 196 ++++++++++++++++++++++----------------------
drivers/spi/spi-dw.h | 48 ++++++------
5 files changed, 171 insertions(+), 171 deletions(-)

diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index 130e555..7659cef 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -36,12 +36,12 @@ struct mid_dma {

static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param)
{
- struct dw_spi *dws = param;
+ struct spi_dw *dws = param;

return dws->dmac && (&dws->dmac->dev == chan->device->dev);
}

-static int mid_spi_dma_init(struct dw_spi *dws)
+static int mid_spi_dma_init(struct spi_dw *dws)
{
struct mid_dma *dw_dma = dws->dma_priv;
struct intel_mid_dma_slave *rxs, *txs;
@@ -86,7 +86,7 @@ err_exit:

}

-static void mid_spi_dma_exit(struct dw_spi *dws)
+static void mid_spi_dma_exit(struct spi_dw *dws)
{
dma_release_channel(dws->txchan);
dma_release_channel(dws->rxchan);
@@ -97,16 +97,16 @@ static void mid_spi_dma_exit(struct dw_spi *dws)
* callback for rx/tx channel will each increment it by 1.
* Reaching 2 means the whole spi transaction is done.
*/
-static void dw_spi_dma_done(void *arg)
+static void spi_dw_dma_done(void *arg)
{
- struct dw_spi *dws = arg;
+ struct spi_dw *dws = arg;

if (++dws->dma_chan_done != 2)
return;
- dw_spi_xfer_done(dws);
+ spi_dw_xfer_done(dws);
}

-static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
+static int mid_spi_dma_transfer(struct spi_dw *dws, int cs_change)
{
struct dma_async_tx_descriptor *txdesc = NULL, *rxdesc = NULL;
struct dma_chan *txchan, *rxchan;
@@ -115,7 +115,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)

/* 1. setup DMA related registers */
if (cs_change) {
- spi_enable_chip(dws, 0);
+ spi_dw_enable_chip(dws, 0);
dw_writew(dws, dmardlr, 0xf);
dw_writew(dws, dmatdlr, 0x10);
if (dws->tx_dma)
@@ -123,7 +123,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
if (dws->rx_dma)
dma_ctrl |= 0x1;
dw_writew(dws, dmacr, dma_ctrl);
- spi_enable_chip(dws, 1);
+ spi_dw_enable_chip(dws, 1);
}

dws->dma_chan_done = 0;
@@ -149,7 +149,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
1,
DMA_TO_DEVICE,
DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP);
- txdesc->callback = dw_spi_dma_done;
+ txdesc->callback = spi_dw_dma_done;
txdesc->callback_param = dws;

/* 3. Prepare the RX dma transfer */
@@ -171,7 +171,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
1,
DMA_FROM_DEVICE,
DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP);
- rxdesc->callback = dw_spi_dma_done;
+ rxdesc->callback = spi_dw_dma_done;
rxdesc->callback_param = dws;

/* rx must be started before tx due to spi instinct */
@@ -180,7 +180,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
return 0;
}

-static struct dw_spi_dma_ops mid_dma_ops = {
+static struct spi_dw_dma_ops mid_dma_ops = {
.dma_init = mid_spi_dma_init,
.dma_exit = mid_spi_dma_exit,
.dma_transfer = mid_spi_dma_transfer,
@@ -198,7 +198,7 @@ static struct dw_spi_dma_ops mid_dma_ops = {
#define CLK_SPI_CDIV_MASK 0x00000e00
#define CLK_SPI_DISABLE_OFFSET 8

-int dw_spi_mid_init(struct dw_spi *dws)
+int spi_dw_mid_init(struct spi_dw *dws)
{
u32 *clk_reg, clk_cdiv;

diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index 34eb665..d98d28d 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -18,21 +18,21 @@

#include "spi-dw.h"

-#define DRIVER_NAME "dw_spi_mmio"
+#define DRIVER_NAME "spi_dw_mmio"

-struct dw_spi_mmio {
- struct dw_spi dws;
+struct spi_dw_mmio {
+ struct spi_dw dws;
struct clk *clk;
};

-static int __devinit dw_spi_mmio_probe(struct platform_device *pdev)
+static int __devinit spi_dw_mmio_probe(struct platform_device *pdev)
{
- struct dw_spi_mmio *dwsmmio;
- struct dw_spi *dws;
+ struct spi_dw_mmio *dwsmmio;
+ struct spi_dw *dws;
struct resource *mem, *ioarea;
int ret;

- dwsmmio = kzalloc(sizeof(struct dw_spi_mmio), GFP_KERNEL);
+ dwsmmio = kzalloc(sizeof(struct spi_dw_mmio), GFP_KERNEL);
if (!dwsmmio) {
ret = -ENOMEM;
goto err_end;
@@ -82,7 +82,7 @@ static int __devinit dw_spi_mmio_probe(struct platform_device *pdev)
dws->num_cs = 4;
dws->max_freq = clk_get_rate(dwsmmio->clk);

- ret = dw_spi_add_host(dws);
+ ret = spi_dw_add_host(dws);
if (ret)
goto err_clk;

@@ -105,9 +105,9 @@ err_end:
return ret;
}

-static int __devexit dw_spi_mmio_remove(struct platform_device *pdev)
+static int __devexit spi_dw_mmio_remove(struct platform_device *pdev)
{
- struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
+ struct spi_dw_mmio *dwsmmio = platform_get_drvdata(pdev);
struct resource *mem;

platform_set_drvdata(pdev, NULL);
@@ -117,7 +117,7 @@ static int __devexit dw_spi_mmio_remove(struct platform_device *pdev)
dwsmmio->clk = NULL;

free_irq(dwsmmio->dws.irq, &dwsmmio->dws);
- dw_spi_remove_host(&dwsmmio->dws);
+ spi_dw_remove_host(&dwsmmio->dws);
iounmap(dwsmmio->dws.regs);
kfree(dwsmmio);

@@ -126,25 +126,25 @@ static int __devexit dw_spi_mmio_remove(struct platform_device *pdev)
return 0;
}

-static struct platform_driver dw_spi_mmio_driver = {
- .remove = __devexit_p(dw_spi_mmio_remove),
+static struct platform_driver spi_dw_mmio_driver = {
+ .remove = __devexit_p(spi_dw_mmio_remove),
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
},
};

-static int __init dw_spi_mmio_init(void)
+static int __init spi_dw_mmio_init(void)
{
- return platform_driver_probe(&dw_spi_mmio_driver, dw_spi_mmio_probe);
+ return platform_driver_probe(&spi_dw_mmio_driver, spi_dw_mmio_probe);
}
-module_init(dw_spi_mmio_init);
+module_init(spi_dw_mmio_init);

-static void __exit dw_spi_mmio_exit(void)
+static void __exit spi_dw_mmio_exit(void)
{
- platform_driver_unregister(&dw_spi_mmio_driver);
+ platform_driver_unregister(&spi_dw_mmio_driver);
}
-module_exit(dw_spi_mmio_exit);
+module_exit(spi_dw_mmio_exit);

MODULE_AUTHOR("Jean-Hugues Deschenes <[email protected]>");
MODULE_DESCRIPTION("Memory-mapped I/O interface driver for DW SPI Core");
diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index c5f37f0..af9db5c 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -24,18 +24,18 @@

#include "spi-dw.h"

-#define DRIVER_NAME "dw_spi_pci"
+#define DRIVER_NAME "spi_dw_pci"

-struct dw_spi_pci {
+struct spi_dw_pci {
struct pci_dev *pdev;
- struct dw_spi dws;
+ struct spi_dw dws;
};

static int __devinit spi_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
- struct dw_spi_pci *dwpci;
- struct dw_spi *dws;
+ struct spi_dw_pci *dwpci;
+ struct spi_dw *dws;
int pci_bar = 0;
int ret;

@@ -46,7 +46,7 @@ static int __devinit spi_pci_probe(struct pci_dev *pdev,
if (ret)
return ret;

- dwpci = kzalloc(sizeof(struct dw_spi_pci), GFP_KERNEL);
+ dwpci = kzalloc(sizeof(struct spi_dw_pci), GFP_KERNEL);
if (!dwpci) {
ret = -ENOMEM;
goto err_disable;
@@ -80,12 +80,12 @@ static int __devinit spi_pci_probe(struct pci_dev *pdev,
* clock rate, FIFO depth.
*/
if (pdev->device == 0x0800) {
- ret = dw_spi_mid_init(dws);
+ ret = spi_dw_mid_init(dws);
if (ret)
goto err_unmap;
}

- ret = dw_spi_add_host(dws);
+ ret = spi_dw_add_host(dws);
if (ret)
goto err_unmap;

@@ -106,10 +106,10 @@ err_disable:

static void __devexit spi_pci_remove(struct pci_dev *pdev)
{
- struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
+ struct spi_dw_pci *dwpci = pci_get_drvdata(pdev);

pci_set_drvdata(pdev, NULL);
- dw_spi_remove_host(&dwpci->dws);
+ spi_dw_remove_host(&dwpci->dws);
iounmap(dwpci->dws.regs);
pci_release_region(pdev, 0);
kfree(dwpci);
@@ -119,10 +119,10 @@ static void __devexit spi_pci_remove(struct pci_dev *pdev)
#ifdef CONFIG_PM
static int spi_suspend(struct pci_dev *pdev, pm_message_t state)
{
- struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
+ struct spi_dw_pci *dwpci = pci_get_drvdata(pdev);
int ret;

- ret = dw_spi_suspend_host(&dwpci->dws);
+ ret = spi_dw_suspend_host(&dwpci->dws);
if (ret)
return ret;
pci_save_state(pdev);
@@ -133,7 +133,7 @@ static int spi_suspend(struct pci_dev *pdev, pm_message_t state)

static int spi_resume(struct pci_dev *pdev)
{
- struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
+ struct spi_dw_pci *dwpci = pci_get_drvdata(pdev);
int ret;

pci_set_power_state(pdev, PCI_D0);
@@ -141,7 +141,7 @@ static int spi_resume(struct pci_dev *pdev)
ret = pci_enable_device(pdev);
if (ret)
return ret;
- return dw_spi_resume_host(&dwpci->dws);
+ return spi_dw_resume_host(&dwpci->dws);
}
#else
#define spi_suspend NULL
@@ -154,7 +154,7 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
{},
};

-static struct pci_driver dw_spi_driver = {
+static struct pci_driver spi_dw_driver = {
.name = DRIVER_NAME,
.id_table = pci_ids,
.probe = spi_pci_probe,
@@ -165,12 +165,12 @@ static struct pci_driver dw_spi_driver = {

static int __init mrst_spi_init(void)
{
- return pci_register_driver(&dw_spi_driver);
+ return pci_register_driver(&spi_dw_driver);
}

static void __exit mrst_spi_exit(void)
{
- pci_unregister_driver(&dw_spi_driver);
+ pci_unregister_driver(&spi_dw_driver);
}

module_init(mrst_spi_init);
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 61f7ed8..fb09a9d 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -59,17 +59,17 @@ struct chip_data {
};

#ifdef CONFIG_DEBUG_FS
-static int spi_show_regs_open(struct inode *inode, struct file *file)
+static int spi_dw_show_regs_open(struct inode *inode, struct file *file)
{
file->private_data = inode->i_private;
return 0;
}

#define SPI_REGS_BUFSIZE 1024
-static ssize_t spi_show_regs(struct file *file, char __user *user_buf,
+static ssize_t spi_dw_show_regs(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
- struct dw_spi *dws;
+ struct spi_dw *dws;
char *buf;
u32 len = 0;
ssize_t ret;
@@ -81,7 +81,7 @@ static ssize_t spi_show_regs(struct file *file, char __user *user_buf,
return 0;

len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
- "MRST SPI0 registers:\n");
+ "DW SPI0 registers:\n");
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
"=================================\n");
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
@@ -122,43 +122,43 @@ static ssize_t spi_show_regs(struct file *file, char __user *user_buf,
return ret;
}

-static const struct file_operations mrst_spi_regs_ops = {
+static const struct file_operations spi_dw_regs_ops = {
.owner = THIS_MODULE,
- .open = spi_show_regs_open,
- .read = spi_show_regs,
+ .open = spi_dw_show_regs_open,
+ .read = spi_dw_show_regs,
.llseek = default_llseek,
};

-static int mrst_spi_debugfs_init(struct dw_spi *dws)
+static int spi_dw_debugfs_init(struct spi_dw *dws)
{
dws->debugfs = debugfs_create_dir("mrst_spi", NULL);
if (!dws->debugfs)
return -ENOMEM;

debugfs_create_file("registers", S_IFREG | S_IRUGO,
- dws->debugfs, (void *)dws, &mrst_spi_regs_ops);
+ dws->debugfs, (void *)dws, &spi_dw_regs_ops);
return 0;
}

-static void mrst_spi_debugfs_remove(struct dw_spi *dws)
+static void spi_dw_debugfs_remove(struct spi_dw *dws)
{
if (dws->debugfs)
debugfs_remove_recursive(dws->debugfs);
}

#else
-static inline int mrst_spi_debugfs_init(struct dw_spi *dws)
+static inline int spi_dw_debugfs_init(struct spi_dw *dws)
{
return 0;
}

-static inline void mrst_spi_debugfs_remove(struct dw_spi *dws)
+static inline void spi_dw_debugfs_remove(struct spi_dw *dws)
{
}
#endif /* CONFIG_DEBUG_FS */

/* Return the max entries we can fill into tx fifo */
-static inline u32 tx_max(struct dw_spi *dws)
+static inline u32 tx_max(struct spi_dw *dws)
{
u32 tx_left, tx_room, rxtx_gap;

@@ -180,14 +180,14 @@ static inline u32 tx_max(struct dw_spi *dws)
}

/* Return the max entries we should read out of rx fifo */
-static inline u32 rx_max(struct dw_spi *dws)
+static inline u32 rx_max(struct spi_dw *dws)
{
u32 rx_left = (dws->rx_end - dws->rx) / dws->n_bytes;

return min(rx_left, (u32)dw_readw(dws, rxflr));
}

-static void dw_writer(struct dw_spi *dws)
+static void spi_dw_writer(struct spi_dw *dws)
{
u32 max = tx_max(dws);
u16 txw = 0;
@@ -205,7 +205,7 @@ static void dw_writer(struct dw_spi *dws)
}
}

-static void dw_reader(struct dw_spi *dws)
+static void spi_dw_reader(struct spi_dw *dws)
{
u32 max = rx_max(dws);
u16 rxw;
@@ -223,7 +223,7 @@ static void dw_reader(struct dw_spi *dws)
}
}

-static void *next_transfer(struct dw_spi *dws)
+static void *spi_dw_next_transfer(struct spi_dw *dws)
{
struct spi_message *msg = dws->cur_msg;
struct spi_transfer *trans = dws->cur_transfer;
@@ -244,7 +244,7 @@ static void *next_transfer(struct dw_spi *dws)
* a dma-capable memory, and this func just need translate
* the virt addr to physical
*/
-static int map_dma_buffers(struct dw_spi *dws)
+static int spi_dw_map_dma_buffers(struct spi_dw *dws)
{
if (!dws->cur_msg->is_dma_mapped
|| !dws->dma_inited
@@ -262,7 +262,7 @@ static int map_dma_buffers(struct dw_spi *dws)
}

/* Caller already set message->status; dma and pio irqs are blocked */
-static void giveback(struct dw_spi *dws)
+static void spi_dw_giveback(struct spi_dw *dws)
{
struct spi_transfer *last_transfer;
unsigned long flags;
@@ -290,34 +290,34 @@ static void giveback(struct dw_spi *dws)
msg->complete(msg->context);
}

-static void int_error_stop(struct dw_spi *dws, const char *msg)
+static void spi_dw_int_error_stop(struct spi_dw *dws, const char *msg)
{
/* Stop the hw */
- spi_enable_chip(dws, 0);
+ spi_dw_enable_chip(dws, 0);

dev_err(&dws->master->dev, "%s\n", msg);
dws->cur_msg->state = ERROR_STATE;
tasklet_schedule(&dws->pump_transfers);
}

-void dw_spi_xfer_done(struct dw_spi *dws)
+void spi_dw_xfer_done(struct spi_dw *dws)
{
/* Update total byte transferred return count actual bytes read */
dws->cur_msg->actual_length += dws->len;

/* Move to next transfer */
- dws->cur_msg->state = next_transfer(dws);
+ dws->cur_msg->state = spi_dw_next_transfer(dws);

/* Handle end of message */
if (dws->cur_msg->state == DONE_STATE) {
dws->cur_msg->status = 0;
- giveback(dws);
+ spi_dw_giveback(dws);
} else
tasklet_schedule(&dws->pump_transfers);
}
-EXPORT_SYMBOL_GPL(dw_spi_xfer_done);
+EXPORT_SYMBOL_GPL(spi_dw_xfer_done);

-static irqreturn_t interrupt_transfer(struct dw_spi *dws)
+static irqreturn_t spi_dw_interrupt_transfer(struct spi_dw *dws)
{
u16 irq_status = dw_readw(dws, isr);

@@ -326,36 +326,36 @@ static irqreturn_t interrupt_transfer(struct dw_spi *dws)
dw_readw(dws, txoicr);
dw_readw(dws, rxoicr);
dw_readw(dws, rxuicr);
- int_error_stop(dws, "interrupt_transfer: fifo overrun/underrun");
+ spi_dw_int_error_stop(dws, "spi-dw: fifo overrun/underrun");
return IRQ_HANDLED;
}

- dw_reader(dws);
+ spi_dw_reader(dws);
if (dws->rx_end == dws->rx) {
- spi_mask_intr(dws, SPI_INT_TXEI);
- dw_spi_xfer_done(dws);
+ spi_dw_mask_intr(dws, SPI_INT_TXEI);
+ spi_dw_xfer_done(dws);
return IRQ_HANDLED;
}
if (irq_status & SPI_INT_TXEI) {
- spi_mask_intr(dws, SPI_INT_TXEI);
- dw_writer(dws);
+ spi_dw_mask_intr(dws, SPI_INT_TXEI);
+ spi_dw_writer(dws);
/* Enable TX irq always, it will be disabled when RX finished */
- spi_umask_intr(dws, SPI_INT_TXEI);
+ spi_dw_umask_intr(dws, SPI_INT_TXEI);
}

return IRQ_HANDLED;
}

-static irqreturn_t dw_spi_irq(int irq, void *dev_id)
+static irqreturn_t spi_dw_irq(int irq, void *dev_id)
{
- struct dw_spi *dws = dev_id;
+ struct spi_dw *dws = dev_id;
u16 irq_status = dw_readw(dws, isr) & 0x3f;

if (!irq_status)
return IRQ_NONE;

if (!dws->cur_msg) {
- spi_mask_intr(dws, SPI_INT_TXEI);
+ spi_dw_mask_intr(dws, SPI_INT_TXEI);
return IRQ_HANDLED;
}

@@ -363,20 +363,20 @@ static irqreturn_t dw_spi_irq(int irq, void *dev_id)
}

/* Must be called inside pump_transfers() */
-static void poll_transfer(struct dw_spi *dws)
+static void spi_dw_poll_transfer(struct spi_dw *dws)
{
do {
- dw_writer(dws);
- dw_reader(dws);
+ spi_dw_writer(dws);
+ spi_dw_reader(dws);
cpu_relax();
} while (dws->rx_end > dws->rx);

- dw_spi_xfer_done(dws);
+ spi_dw_xfer_done(dws);
}

-static void pump_transfers(unsigned long data)
+static void spi_dw_pump_transfers(unsigned long data)
{
- struct dw_spi *dws = (struct dw_spi *)data;
+ struct spi_dw *dws = (struct spi_dw *)data;
struct spi_message *message = NULL;
struct spi_transfer *transfer = NULL;
struct spi_transfer *previous = NULL;
@@ -496,7 +496,7 @@ static void pump_transfers(unsigned long data)
}

/* Check if current transfer is a DMA transaction */
- dws->dma_mapped = map_dma_buffers(dws);
+ dws->dma_mapped = spi_dw_map_dma_buffers(dws);

/*
* Interrupt mode
@@ -508,7 +508,7 @@ static void pump_transfers(unsigned long data)
txint_level = (templen > txint_level) ? txint_level : templen;

imask |= SPI_INT_TXEI | SPI_INT_TXOI | SPI_INT_RXUI | SPI_INT_RXOI;
- dws->transfer_handler = interrupt_transfer;
+ dws->transfer_handler = spi_dw_interrupt_transfer;
}

/*
@@ -518,22 +518,22 @@ static void pump_transfers(unsigned long data)
* 3. control value changes
*/
if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div || imask) {
- spi_enable_chip(dws, 0);
+ spi_dw_enable_chip(dws, 0);

if (dw_readw(dws, ctrl0) != cr0)
dw_writew(dws, ctrl0, cr0);

- spi_set_clk(dws, clk_div ? clk_div : chip->clk_div);
- spi_chip_sel(dws, spi->chip_select);
+ spi_dw_set_clk(dws, clk_div ? clk_div : chip->clk_div);
+ spi_dw_chip_sel(dws, spi->chip_select);

/* Set the interrupt mask, for poll mode just disable all int */
- spi_mask_intr(dws, 0xff);
+ spi_dw_mask_intr(dws, 0xff);
if (imask)
- spi_umask_intr(dws, imask);
+ spi_dw_umask_intr(dws, imask);
if (txint_level)
dw_writew(dws, txfltr, txint_level);

- spi_enable_chip(dws, 1);
+ spi_dw_enable_chip(dws, 1);
if (cs_change)
dws->prev_chip = chip;
}
@@ -542,19 +542,19 @@ static void pump_transfers(unsigned long data)
dws->dma_ops->dma_transfer(dws, cs_change);

if (chip->poll_mode)
- poll_transfer(dws);
+ spi_dw_poll_transfer(dws);

return;

early_exit:
- giveback(dws);
+ spi_dw_giveback(dws);
return;
}

-static void pump_messages(struct work_struct *work)
+static void spi_dw_pump_messages(struct work_struct *work)
{
- struct dw_spi *dws =
- container_of(work, struct dw_spi, pump_messages);
+ struct spi_dw *dws =
+ container_of(work, struct spi_dw, pump_messages);
unsigned long flags;

/* Lock queue and check for queue work */
@@ -590,9 +590,9 @@ static void pump_messages(struct work_struct *work)
}

/* spi_device use this to queue in their spi_msg */
-static int dw_spi_transfer(struct spi_device *spi, struct spi_message *msg)
+static int spi_dw_transfer(struct spi_device *spi, struct spi_message *msg)
{
- struct dw_spi *dws = spi_master_get_devdata(spi->master);
+ struct spi_dw *dws = spi_master_get_devdata(spi->master);
unsigned long flags;

spin_lock_irqsave(&dws->lock, flags);
@@ -616,7 +616,7 @@ static int dw_spi_transfer(struct spi_device *spi, struct spi_message *msg)
else {
/* If no other data transaction in air, just go */
spin_unlock_irqrestore(&dws->lock, flags);
- pump_messages(&dws->pump_messages);
+ spi_dw_pump_messages(&dws->pump_messages);
return 0;
}
}
@@ -626,7 +626,7 @@ static int dw_spi_transfer(struct spi_device *spi, struct spi_message *msg)
}

/* This may be called twice for each spi dev */
-static int dw_spi_setup(struct spi_device *spi)
+static int spi_dw_setup(struct spi_device *spi)
{
struct dw_spi_chip *chip_info = NULL;
struct chip_data *chip;
@@ -692,13 +692,13 @@ static int dw_spi_setup(struct spi_device *spi)
return 0;
}

-static void dw_spi_cleanup(struct spi_device *spi)
+static void spi_dw_cleanup(struct spi_device *spi)
{
struct chip_data *chip = spi_get_ctldata(spi);
kfree(chip);
}

-static int __devinit init_queue(struct dw_spi *dws)
+static int __devinit spi_dw_init_queue(struct spi_dw *dws)
{
INIT_LIST_HEAD(&dws->queue);
spin_lock_init(&dws->lock);
@@ -707,9 +707,9 @@ static int __devinit init_queue(struct dw_spi *dws)
dws->busy = 0;

tasklet_init(&dws->pump_transfers,
- pump_transfers, (unsigned long)dws);
+ spi_dw_pump_transfers, (unsigned long)dws);

- INIT_WORK(&dws->pump_messages, pump_messages);
+ INIT_WORK(&dws->pump_messages, spi_dw_pump_messages);
dws->workqueue = create_singlethread_workqueue(
dev_name(dws->master->dev.parent));
if (dws->workqueue == NULL)
@@ -718,7 +718,7 @@ static int __devinit init_queue(struct dw_spi *dws)
return 0;
}

-static int start_queue(struct dw_spi *dws)
+static int spi_dw_start_queue(struct spi_dw *dws)
{
unsigned long flags;

@@ -741,7 +741,7 @@ static int start_queue(struct dw_spi *dws)
return 0;
}

-static int stop_queue(struct dw_spi *dws)
+static int spi_dw_stop_queue(struct spi_dw *dws)
{
unsigned long flags;
unsigned limit = 50;
@@ -762,11 +762,11 @@ static int stop_queue(struct dw_spi *dws)
return status;
}

-static int destroy_queue(struct dw_spi *dws)
+static int destroy_queue(struct spi_dw *dws)
{
int status;

- status = stop_queue(dws);
+ status = spi_dw_stop_queue(dws);
if (status != 0)
return status;
destroy_workqueue(dws->workqueue);
@@ -774,11 +774,11 @@ static int destroy_queue(struct dw_spi *dws)
}

/* Restart the controller, disable all interrupts, clean rx fifo */
-static void spi_hw_init(struct dw_spi *dws)
+static void spi_dw_hw_init(struct spi_dw *dws)
{
- spi_enable_chip(dws, 0);
- spi_mask_intr(dws, 0xff);
- spi_enable_chip(dws, 1);
+ spi_dw_enable_chip(dws, 0);
+ spi_dw_mask_intr(dws, 0xff);
+ spi_dw_enable_chip(dws, 1);

/*
* Try to detect the FIFO depth if not set by interface driver,
@@ -797,7 +797,7 @@ static void spi_hw_init(struct dw_spi *dws)
}
}

-int __devinit dw_spi_add_host(struct dw_spi *dws)
+int __devinit spi_dw_add_host(struct spi_dw *dws)
{
struct spi_master *master;
int ret;
@@ -816,8 +816,8 @@ int __devinit dw_spi_add_host(struct dw_spi *dws)
dws->dma_inited = 0;
dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60);

- ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED,
- "dw_spi", dws);
+ ret = request_irq(dws->irq, spi_dw_irq, IRQF_SHARED,
+ "spi_dw", dws);
if (ret < 0) {
dev_err(&master->dev, "can not get IRQ\n");
goto err_free_master;
@@ -826,12 +826,12 @@ int __devinit dw_spi_add_host(struct dw_spi *dws)
master->mode_bits = SPI_CPOL | SPI_CPHA;
master->bus_num = dws->bus_num;
master->num_chipselect = dws->num_cs;
- master->cleanup = dw_spi_cleanup;
- master->setup = dw_spi_setup;
- master->transfer = dw_spi_transfer;
+ master->cleanup = spi_dw_cleanup;
+ master->setup = spi_dw_setup;
+ master->transfer = spi_dw_transfer;

/* Basic HW init */
- spi_hw_init(dws);
+ spi_dw_hw_init(dws);

if (dws->dma_ops && dws->dma_ops->dma_init) {
ret = dws->dma_ops->dma_init(dws);
@@ -842,12 +842,12 @@ int __devinit dw_spi_add_host(struct dw_spi *dws)
}

/* Initial and start queue */
- ret = init_queue(dws);
+ ret = spi_dw_init_queue(dws);
if (ret) {
dev_err(&master->dev, "problem initializing queue\n");
goto err_diable_hw;
}
- ret = start_queue(dws);
+ ret = spi_dw_start_queue(dws);
if (ret) {
dev_err(&master->dev, "problem starting queue\n");
goto err_diable_hw;
@@ -860,7 +860,7 @@ int __devinit dw_spi_add_host(struct dw_spi *dws)
goto err_queue_alloc;
}

- mrst_spi_debugfs_init(dws);
+ spi_dw_debugfs_init(dws);
return 0;

err_queue_alloc:
@@ -868,65 +868,65 @@ err_queue_alloc:
if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws);
err_diable_hw:
- spi_enable_chip(dws, 0);
+ spi_dw_enable_chip(dws, 0);
free_irq(dws->irq, dws);
err_free_master:
spi_master_put(master);
exit:
return ret;
}
-EXPORT_SYMBOL_GPL(dw_spi_add_host);
+EXPORT_SYMBOL_GPL(spi_dw_add_host);

-void __devexit dw_spi_remove_host(struct dw_spi *dws)
+void __devexit spi_dw_remove_host(struct spi_dw *dws)
{
int status = 0;

if (!dws)
return;
- mrst_spi_debugfs_remove(dws);
+ spi_dw_debugfs_remove(dws);

/* Remove the queue */
status = destroy_queue(dws);
if (status != 0)
- dev_err(&dws->master->dev, "dw_spi_remove: workqueue will not "
+ dev_err(&dws->master->dev, "spi_dw_remove: workqueue will not "
"complete, message memory not freed\n");

if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws);
- spi_enable_chip(dws, 0);
+ spi_dw_enable_chip(dws, 0);
/* Disable clk */
- spi_set_clk(dws, 0);
+ spi_dw_set_clk(dws, 0);
free_irq(dws->irq, dws);

/* Disconnect from the SPI framework */
spi_unregister_master(dws->master);
}
-EXPORT_SYMBOL_GPL(dw_spi_remove_host);
+EXPORT_SYMBOL_GPL(spi_dw_remove_host);

-int dw_spi_suspend_host(struct dw_spi *dws)
+int spi_dw_suspend_host(struct spi_dw *dws)
{
int ret = 0;

- ret = stop_queue(dws);
+ ret = spi_dw_stop_queue(dws);
if (ret)
return ret;
- spi_enable_chip(dws, 0);
- spi_set_clk(dws, 0);
+ spi_dw_enable_chip(dws, 0);
+ spi_dw_set_clk(dws, 0);
return ret;
}
-EXPORT_SYMBOL_GPL(dw_spi_suspend_host);
+EXPORT_SYMBOL_GPL(spi_dw_suspend_host);

-int dw_spi_resume_host(struct dw_spi *dws)
+int spi_dw_resume_host(struct spi_dw *dws)
{
int ret;

- spi_hw_init(dws);
- ret = start_queue(dws);
+ spi_dw_hw_init(dws);
+ ret = spi_dw_start_queue(dws);
if (ret)
dev_err(&dws->master->dev, "fail to start queue (%d)\n", ret);
return ret;
}
-EXPORT_SYMBOL_GPL(dw_spi_resume_host);
+EXPORT_SYMBOL_GPL(spi_dw_resume_host);

MODULE_AUTHOR("Feng Tang <[email protected]>");
MODULE_DESCRIPTION("Driver for DesignWare SPI controller core");
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 92bee30..83b9a59 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -51,7 +51,7 @@
#define SPI_INT_THRESHOLD 32


-struct dw_spi_reg {
+struct spi_dw_reg {
u32 ctrl0;
u32 ctrl1;
u32 ssienr;
@@ -80,14 +80,14 @@ struct dw_spi_reg {
though only low 16 bits matters */
} __packed;

-struct dw_spi;
-struct dw_spi_dma_ops {
- int (*dma_init)(struct dw_spi *dws);
- void (*dma_exit)(struct dw_spi *dws);
- int (*dma_transfer)(struct dw_spi *dws, int cs_change);
+struct spi_dw;
+struct spi_dw_dma_ops {
+ int (*dma_init)(struct spi_dw *dws);
+ void (*dma_exit)(struct spi_dw *dws);
+ int (*dma_transfer)(struct spi_dw *dws, int cs_change);
};

-struct dw_spi {
+struct spi_dw {
struct spi_master *master;
struct spi_device *cur_dev;
struct device *parent_dev;
@@ -133,7 +133,7 @@ struct dw_spi {
u8 max_bits_per_word; /* maxim is 16b */
u32 dma_width;
int cs_change;
- irqreturn_t (*transfer_handler)(struct dw_spi *dws);
+ irqreturn_t (*transfer_handler)(struct spi_dw *dws);
void (*cs_control)(u32 command);

/* Dma info */
@@ -145,7 +145,7 @@ struct dw_spi {
int dma_chan_done;
struct device *dma_dev;
dma_addr_t dma_addr; /* phy address of the Data register */
- struct dw_spi_dma_ops *dma_ops;
+ struct spi_dw_dma_ops *dma_ops;
void *dma_priv; /* platform relate info */
struct pci_dev *dmac;

@@ -157,25 +157,25 @@ struct dw_spi {
};

#define dw_readl(dw, name) \
- __raw_readl(&(((struct dw_spi_reg *)dw->regs)->name))
+ __raw_readl(&(((struct spi_dw_reg *)dw->regs)->name))
#define dw_writel(dw, name, val) \
- __raw_writel((val), &(((struct dw_spi_reg *)dw->regs)->name))
+ __raw_writel((val), &(((struct spi_dw_reg *)dw->regs)->name))
#define dw_readw(dw, name) \
- __raw_readw(&(((struct dw_spi_reg *)dw->regs)->name))
+ __raw_readw(&(((struct spi_dw_reg *)dw->regs)->name))
#define dw_writew(dw, name, val) \
- __raw_writew((val), &(((struct dw_spi_reg *)dw->regs)->name))
+ __raw_writew((val), &(((struct spi_dw_reg *)dw->regs)->name))

-static inline void spi_enable_chip(struct dw_spi *dws, int enable)
+static inline void spi_dw_enable_chip(struct spi_dw *dws, int enable)
{
dw_writel(dws, ssienr, (enable ? 1 : 0));
}

-static inline void spi_set_clk(struct dw_spi *dws, u16 div)
+static inline void spi_dw_set_clk(struct spi_dw *dws, u16 div)
{
dw_writel(dws, baudr, div);
}

-static inline void spi_chip_sel(struct dw_spi *dws, u16 cs)
+static inline void spi_dw_chip_sel(struct spi_dw *dws, u16 cs)
{
if (cs > dws->num_cs)
return;
@@ -187,7 +187,7 @@ static inline void spi_chip_sel(struct dw_spi *dws, u16 cs)
}

/* Disable IRQ bits */
-static inline void spi_mask_intr(struct dw_spi *dws, u32 mask)
+static inline void spi_dw_mask_intr(struct spi_dw *dws, u32 mask)
{
u32 new_mask;

@@ -196,7 +196,7 @@ static inline void spi_mask_intr(struct dw_spi *dws, u32 mask)
}

/* Enable IRQ bits */
-static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
+static inline void spi_dw_umask_intr(struct spi_dw *dws, u32 mask)
{
u32 new_mask;

@@ -205,12 +205,12 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
}


-extern int dw_spi_add_host(struct dw_spi *dws);
-extern void dw_spi_remove_host(struct dw_spi *dws);
-extern int dw_spi_suspend_host(struct dw_spi *dws);
-extern int dw_spi_resume_host(struct dw_spi *dws);
-extern void dw_spi_xfer_done(struct dw_spi *dws);
+extern int spi_dw_add_host(struct spi_dw *dws);
+extern void spi_dw_remove_host(struct spi_dw *dws);
+extern int spi_dw_suspend_host(struct spi_dw *dws);
+extern int spi_dw_resume_host(struct spi_dw *dws);
+extern void spi_dw_xfer_done(struct spi_dw *dws);

/* platform related setup */
-extern int dw_spi_mid_init(struct dw_spi *dws); /* Intel MID platforms */
+extern int spi_dw_mid_init(struct spi_dw *dws); /* Intel MID platforms */
#endif /* DW_SPI_HEADER_H */
--
1.7.3.4

2011-06-23 02:00:54

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 03/11] spi-dw: change MRST prefix to generic prefix

From: Dirk Brandewie <[email protected]>

The designware SPI core is now used in multiple SOC's. Make the
prefix more generic and match other naming changes.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.c | 10 +++++-----
drivers/spi/spi-dw.h | 3 +--
include/linux/spi/spi-dw.h | 4 ++--
3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index fb09a9d..3d98e4c 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -131,7 +131,7 @@ static const struct file_operations spi_dw_regs_ops = {

static int spi_dw_debugfs_init(struct spi_dw *dws)
{
- dws->debugfs = debugfs_create_dir("mrst_spi", NULL);
+ dws->debugfs = debugfs_create_dir("spi-dw", NULL);
if (!dws->debugfs)
return -ENOMEM;

@@ -283,7 +283,7 @@ static void spi_dw_giveback(struct spi_dw *dws)
transfer_list);

if (!last_transfer->cs_change && dws->cs_control)
- dws->cs_control(MRST_SPI_DEASSERT);
+ dws->cs_control(SPI_DW_DEASSERT);

msg->state = NULL;
if (msg->complete)
@@ -443,7 +443,7 @@ static void spi_dw_pump_transfers(unsigned long data)
if (transfer->speed_hz != speed) {
speed = transfer->speed_hz;
if (speed > dws->max_freq) {
- printk(KERN_ERR "MRST SPI0: unsupported"
+ printk(KERN_ERR "DW SPI: unsupported"
"freq: %dHz\n", speed);
message->status = -EIO;
goto early_exit;
@@ -466,7 +466,7 @@ static void spi_dw_pump_transfers(unsigned long data)
dws->n_bytes = dws->dma_width = bits >> 3;
break;
default:
- printk(KERN_ERR "MRST SPI0: unsupported bits:"
+ printk(KERN_ERR "DW SPI: unsupported bits:"
"%db\n", bits);
message->status = -EIO;
goto early_exit;
@@ -669,7 +669,7 @@ static int spi_dw_setup(struct spi_device *spi)
chip->n_bytes = 2;
chip->dma_width = 2;
} else {
- /* Never take >16b case for MRST SPIC */
+ /* Never take >16b case for DW SPIC */
dev_err(&spi->dev, "invalid wordsize\n");
return -EINVAL;
}
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 83b9a59..0148356 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -50,7 +50,6 @@
/* TX RX interrupt level threshold, max can be 256 */
#define SPI_INT_THRESHOLD 32

-
struct spi_dw_reg {
u32 ctrl0;
u32 ctrl1;
@@ -181,7 +180,7 @@ static inline void spi_dw_chip_sel(struct spi_dw *dws, u16 cs)
return;

if (dws->cs_control)
- dws->cs_control(1);
+ dws->cs_control(SPI_DW_ASSERT);

dw_writel(dws, ser, 1 << cs);
}
diff --git a/include/linux/spi/spi-dw.h b/include/linux/spi/spi-dw.h
index 787b154..4fb72d9 100644
--- a/include/linux/spi/spi-dw.h
+++ b/include/linux/spi/spi-dw.h
@@ -24,8 +24,8 @@ enum spi_dw_ssi_type {
SSI_NS_MICROWIRE,
};

-#define MRST_SPI_DEASSERT 0
-#define MRST_SPI_ASSERT 1
+#define SPI_DW_DEASSERT 0
+#define SPI_DW_ASSERT 1

/*
* Each SPI slave device to work with dw_api controller should
--
1.7.3.4

2011-06-23 02:00:56

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 04/11] spi-dw: remove unused definition

From: Dirk Brandewie <[email protected]>

Remove unused #define

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.h | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 0148356..6a1ee63 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -47,9 +47,6 @@
#define SPI_INT_RXFI (1 << 4)
#define SPI_INT_MSTI (1 << 5)

-/* TX RX interrupt level threshold, max can be 256 */
-#define SPI_INT_THRESHOLD 32
-
struct spi_dw_reg {
u32 ctrl0;
u32 ctrl1;
--
1.7.3.4

2011-06-23 02:03:00

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 05/11] spi-dw: split spi_dw_enable_chip() into spi_dw_enable()/spi_dw_disable()

From: Dirk Brandewie <[email protected]>

Split spi_dw_enable_chip() into two inline functions for readabilty.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw-mid.c | 4 ++--
drivers/spi/spi-dw.c | 16 ++++++++--------
drivers/spi/spi-dw.h | 9 +++++++--
3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index 7659cef..78e64d3 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -115,7 +115,7 @@ static int mid_spi_dma_transfer(struct spi_dw *dws, int cs_change)

/* 1. setup DMA related registers */
if (cs_change) {
- spi_dw_enable_chip(dws, 0);
+ spi_dw_disable(dws);
dw_writew(dws, dmardlr, 0xf);
dw_writew(dws, dmatdlr, 0x10);
if (dws->tx_dma)
@@ -123,7 +123,7 @@ static int mid_spi_dma_transfer(struct spi_dw *dws, int cs_change)
if (dws->rx_dma)
dma_ctrl |= 0x1;
dw_writew(dws, dmacr, dma_ctrl);
- spi_dw_enable_chip(dws, 1);
+ spi_dw_enable(dws);
}

dws->dma_chan_done = 0;
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 3d98e4c..ad92826 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -293,7 +293,7 @@ static void spi_dw_giveback(struct spi_dw *dws)
static void spi_dw_int_error_stop(struct spi_dw *dws, const char *msg)
{
/* Stop the hw */
- spi_dw_enable_chip(dws, 0);
+ spi_dw_disable(dws);

dev_err(&dws->master->dev, "%s\n", msg);
dws->cur_msg->state = ERROR_STATE;
@@ -518,7 +518,7 @@ static void spi_dw_pump_transfers(unsigned long data)
* 3. control value changes
*/
if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div || imask) {
- spi_dw_enable_chip(dws, 0);
+ spi_dw_disable(dws);

if (dw_readw(dws, ctrl0) != cr0)
dw_writew(dws, ctrl0, cr0);
@@ -533,7 +533,7 @@ static void spi_dw_pump_transfers(unsigned long data)
if (txint_level)
dw_writew(dws, txfltr, txint_level);

- spi_dw_enable_chip(dws, 1);
+ spi_dw_enable(dws);
if (cs_change)
dws->prev_chip = chip;
}
@@ -776,9 +776,9 @@ static int destroy_queue(struct spi_dw *dws)
/* Restart the controller, disable all interrupts, clean rx fifo */
static void spi_dw_hw_init(struct spi_dw *dws)
{
- spi_dw_enable_chip(dws, 0);
+ spi_dw_disable(dws);
spi_dw_mask_intr(dws, 0xff);
- spi_dw_enable_chip(dws, 1);
+ spi_dw_enable(dws);

/*
* Try to detect the FIFO depth if not set by interface driver,
@@ -868,7 +868,7 @@ err_queue_alloc:
if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws);
err_diable_hw:
- spi_dw_enable_chip(dws, 0);
+ spi_dw_disable(dws);
free_irq(dws->irq, dws);
err_free_master:
spi_master_put(master);
@@ -893,7 +893,7 @@ void __devexit spi_dw_remove_host(struct spi_dw *dws)

if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws);
- spi_dw_enable_chip(dws, 0);
+ spi_dw_disable(dws);
/* Disable clk */
spi_dw_set_clk(dws, 0);
free_irq(dws->irq, dws);
@@ -910,7 +910,7 @@ int spi_dw_suspend_host(struct spi_dw *dws)
ret = spi_dw_stop_queue(dws);
if (ret)
return ret;
- spi_dw_enable_chip(dws, 0);
+ spi_dw_disable(dws);
spi_dw_set_clk(dws, 0);
return ret;
}
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 6a1ee63..860bc34 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -161,9 +161,14 @@ struct spi_dw {
#define dw_writew(dw, name, val) \
__raw_writew((val), &(((struct spi_dw_reg *)dw->regs)->name))

-static inline void spi_dw_enable_chip(struct spi_dw *dws, int enable)
+static inline void spi_dw_enable(struct spi_dw *dws)
{
- dw_writel(dws, ssienr, (enable ? 1 : 0));
+ dw_writel(dws, ssienr, 1);
+}
+
+static inline void spi_dw_disable(struct spi_dw *dws)
+{
+ dw_writel(dws, ssienr, 0);
}

static inline void spi_dw_set_clk(struct spi_dw *dws, u16 div)
--
1.7.3.4

2011-06-23 02:02:42

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 06/11] spi-dw: Force error on out of range chip select.

From: Dirk Brandewie <[email protected]>

BUG_ON() if the selected chip select is out of range.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.h | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 860bc34..3fa4c13 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -178,8 +178,7 @@ static inline void spi_dw_set_clk(struct spi_dw *dws, u16 div)

static inline void spi_dw_chip_sel(struct spi_dw *dws, u16 cs)
{
- if (cs > dws->num_cs)
- return;
+ BUG_ON(cs >= dws->master->num_chipselect);

if (dws->cs_control)
dws->cs_control(SPI_DW_ASSERT);
--
1.7.3.4

2011-06-23 02:02:28

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 07/11] spi-dw: Set number of available chip selects correctly

From: Dirk Brandewie <[email protected]>

Only four chip selects are available directly off the pins of the
master.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw-mid.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index 78e64d3..1d11268 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -211,7 +211,9 @@ int spi_dw_mid_init(struct spi_dw *dws)
dws->max_freq = MRST_SPI_CLK_BASE / (clk_cdiv + 1);
iounmap(clk_reg);

- dws->num_cs = 16;
+ dws->num_cs = 4; /* spi_dw_chip_sel() bits 0-3 are
+ * valid in the slave enable register
+ */
dws->fifo_len = 40; /* FIFO has 40 words buffer */

#ifdef CONFIG_SPI_DW_MID_DMA
--
1.7.3.4

2011-06-23 02:02:02

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 08/11] spi-dw: Ensure fifo lenght is set.

From: Dirk Brandewie <[email protected]>

Bug on fifo_len not being set. The fifo sizing routine does not work
since the txfltr register can not be written while the controller is
enabled. The max value of txfltr can be larger than the fifo. The
register allows values upto 0x3f (63) the fifo depth on the Intel
SOC's if 40

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.c | 18 ++----------------
1 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index ad92826..cc38aa0 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -776,25 +776,11 @@ static int destroy_queue(struct spi_dw *dws)
/* Restart the controller, disable all interrupts, clean rx fifo */
static void spi_dw_hw_init(struct spi_dw *dws)
{
+ BUG_ON(!dws->fifo_len);
+
spi_dw_disable(dws);
spi_dw_mask_intr(dws, 0xff);
spi_dw_enable(dws);
-
- /*
- * Try to detect the FIFO depth if not set by interface driver,
- * the depth could be from 2 to 256 from HW spec
- */
- if (!dws->fifo_len) {
- u32 fifo;
- for (fifo = 2; fifo <= 257; fifo++) {
- dw_writew(dws, txfltr, fifo);
- if (fifo != dw_readw(dws, txfltr))
- break;
- }
-
- dws->fifo_len = (fifo == 257) ? 0 : fifo;
- dw_writew(dws, txfltr, 0);
- }
}

int __devinit spi_dw_add_host(struct spi_dw *dws)
--
1.7.3.4

2011-06-23 02:01:48

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 09/11] spi-dw: Fix condition in spi_dw_{writer/reader}

From: Dirk Brandewie <[email protected]>

Fix the condition based on whether the current transfer has a tx/rx
buffer.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index cc38aa0..35b952b 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -193,8 +193,8 @@ static void spi_dw_writer(struct spi_dw *dws)
u16 txw = 0;

while (max--) {
- /* Set the tx word if the transfer's original "tx" is not null */
- if (dws->tx_end - dws->len) {
+ /* Set the tx word if the transfer's "tx" is not null */
+ if (dws->tx) {
if (dws->n_bytes == 1)
txw = *(u8 *)(dws->tx);
else
@@ -213,7 +213,7 @@ static void spi_dw_reader(struct spi_dw *dws)
while (max--) {
rxw = dw_readw(dws, dr);
/* Care rx only if the transfer's original "rx" is not null */
- if (dws->rx_end - dws->len) {
+ if (dws->rx) {
if (dws->n_bytes == 1)
*(u8 *)(dws->rx) = rxw;
else
--
1.7.3.4

2011-06-23 02:00:58

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 10/11] spi-dw: Move checking of max_speed_hz value to be a prerequisite in spi_dw_setup

From: Dirk Brandewie <[email protected]>

Move the check of spi->max_speed_hz to be a prerequisite of
spi_dw_setup().

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 35b952b..7b3f607 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -634,6 +634,11 @@ static int spi_dw_setup(struct spi_device *spi)
if (spi->bits_per_word != 8 && spi->bits_per_word != 16)
return -EINVAL;

+ if (!spi->max_speed_hz) {
+ dev_err(&spi->dev, "No max speed HZ parameter\n");
+ return -EINVAL;
+ }
+
/* Only alloc on first setup */
chip = spi_get_ctldata(spi);
if (!chip) {
@@ -675,10 +680,6 @@ static int spi_dw_setup(struct spi_device *spi)
}
chip->bits_per_word = spi->bits_per_word;

- if (!spi->max_speed_hz) {
- dev_err(&spi->dev, "No max speed HZ parameter\n");
- return -EINVAL;
- }
chip->speed_hz = spi->max_speed_hz;

chip->tmode = 0; /* Tx & Rx */
--
1.7.3.4

2011-06-23 02:01:12

by Dirk Brandewie

[permalink] [raw]
Subject: [PATCH 11/11] spi-dw: remove noop else clause

From: Dirk Brandewie <[email protected]>

The value of spi->bits_per_word is checked on function entry to be 8
or 16. The else clause has no meaning since it can never be reached.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 7b3f607..5ddd45f 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -667,17 +667,14 @@ static int spi_dw_setup(struct spi_device *spi)
chip->enable_dma = chip_info->enable_dma;
}

- if (spi->bits_per_word <= 8) {
+ if (spi->bits_per_word == 8) {
chip->n_bytes = 1;
chip->dma_width = 1;
- } else if (spi->bits_per_word <= 16) {
+ } else if (spi->bits_per_word == 16) {
chip->n_bytes = 2;
chip->dma_width = 2;
- } else {
- /* Never take >16b case for DW SPIC */
- dev_err(&spi->dev, "invalid wordsize\n");
- return -EINVAL;
}
+
chip->bits_per_word = spi->bits_per_word;

chip->speed_hz = spi->max_speed_hz;
--
1.7.3.4

2011-06-23 02:32:05

by Feng Tang

[permalink] [raw]
Subject: Re: [PATCH 00/11] RFC spi-dw updates

Hi Dirk,

On Thu, 23 Jun 2011 10:00:02 +0800
"[email protected]" <[email protected]> wrote:

> From: Dirk Brandewie <[email protected]>
>
> This patch set contains a number of changes were buried inside of one
> large patch in my last patch set. The rework of the message/transfer
> handling changes are not part of this patch set.
>
>
> This patch set applies after commit ca632f5 on spi/next
>
>
> Dirk Brandewie (11):
> spi-dw: expose platform data stucture.
> spi-dw: update function naming convention to match file naming
> spi-dw: change MRST prefix to generic prefix
> spi-dw: remove unused definition
> spi-dw: split spi_dw_enable_chip() into
> spi_dw_enable()/spi_dw_disable() spi-dw: Force error on out of range
> chip select. spi-dw: Set number of available chip selects correctly
> spi-dw: Ensure fifo lenght is set.
> spi-dw: Fix condition in spi_dw_{writer/reader}
> spi-dw: Move checking of max_speed_hz value to be a prerequisite in
> spi_dw_setup spi-dw: remove noop else clause

Most of the patches looks good to me, I'll reply to the rest separately.

Thanks,
Feng

>
> drivers/spi/spi-dw-mid.c | 30 +++---
> drivers/spi/spi-dw-mmio.c | 38 ++++----
> drivers/spi/spi-dw-pci.c | 34 +++---
> drivers/spi/spi-dw.c | 247
> ++++++++++++++++++++------------------------
> drivers/spi/spi-dw.h | 82 ++++++---------
> include/linux/spi/spi-dw.h | 42 ++++++++ 6 files changed, 241
> insertions(+), 232 deletions(-) create mode 100644
> include/linux/spi/spi-dw.h
>

2011-06-23 02:35:14

by Feng Tang

[permalink] [raw]
Subject: Re: [PATCH 08/11] spi-dw: Ensure fifo lenght is set.



On Thu, 23 Jun 2011 10:00:10 +0800
"[email protected]" <[email protected]> wrote:

> From: Dirk Brandewie <[email protected]>
>
> Bug on fifo_len not being set. The fifo sizing routine does not work
> since the txfltr register can not be written while the controller is
> enabled. The max value of txfltr can be larger than the fifo. The
> register allows values upto 0x3f (63) the fifo depth on the Intel
> SOC's if 40
>
> Signed-off-by: Dirk Brandewie <[email protected]>
> ---
> drivers/spi/spi-dw.c | 18 ++----------------
> 1 files changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> index ad92826..cc38aa0 100644
> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -776,25 +776,11 @@ static int destroy_queue(struct spi_dw *dws)
> /* Restart the controller, disable all interrupts, clean rx fifo */
> static void spi_dw_hw_init(struct spi_dw *dws)
> {
> + BUG_ON(!dws->fifo_len);
> +
> spi_dw_disable(dws);
> spi_dw_mask_intr(dws, 0xff);
> spi_dw_enable(dws);
> -
> - /*
> - * Try to detect the FIFO depth if not set by interface
> driver,
> - * the depth could be from 2 to 256 from HW spec
> - */
> - if (!dws->fifo_len) {
> - u32 fifo;
> - for (fifo = 2; fifo <= 257; fifo++) {
> - dw_writew(dws, txfltr, fifo);
> - if (fifo != dw_readw(dws, txfltr))
> - break;
> - }
> -
> - dws->fifo_len = (fifo == 257) ? 0 : fifo;
> - dw_writew(dws, txfltr, 0);
> - }
> }

This code is requested by other community developers, the FIFO
length is adjustable for the dw_spi core when deployed on
different platforms, for those who are not certain about the
FIFO len, they can use this code to probe the FIFO len.

So we need to keep it.

>
> int __devinit spi_dw_add_host(struct spi_dw *dws)

2011-06-23 02:38:28

by Feng Tang

[permalink] [raw]
Subject: Re: [PATCH 09/11] spi-dw: Fix condition in spi_dw_{writer/reader}

On Thu, 23 Jun 2011 10:00:11 +0800
"[email protected]" <[email protected]> wrote:

> From: Dirk Brandewie <[email protected]>
>
> Fix the condition based on whether the current transfer has a tx/rx
> buffer.
>
> Signed-off-by: Dirk Brandewie <[email protected]>
> ---
> drivers/spi/spi-dw.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> index cc38aa0..35b952b 100644
> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -193,8 +193,8 @@ static void spi_dw_writer(struct spi_dw *dws)
> u16 txw = 0;
>
> while (max--) {
> - /* Set the tx word if the transfer's original "tx"
> is not null */
> - if (dws->tx_end - dws->len) {
> + /* Set the tx word if the transfer's "tx" is not
> null */
> + if (dws->tx) {

No, in current mainstream code, the dws->tx is changing, see code:
dws->tx += dws->n_bytes;
so we have to use if (dws->tx_end - dws->len) for now, maybe
we can use some bit to indicate whether the original tx is null

> if (dws->n_bytes == 1)
> txw = *(u8 *)(dws->tx);
> else
> @@ -213,7 +213,7 @@ static void spi_dw_reader(struct spi_dw *dws)
> while (max--) {
> rxw = dw_readw(dws, dr);
> /* Care rx only if the transfer's original "rx" is
> not null */
> - if (dws->rx_end - dws->len) {
> + if (dws->rx) {
> if (dws->n_bytes == 1)
> *(u8 *)(dws->rx) = rxw;
> else

2011-06-23 02:40:37

by Feng Tang

[permalink] [raw]
Subject: Re: [PATCH 11/11] spi-dw: remove noop else clause

On Thu, 23 Jun 2011 10:00:13 +0800
"[email protected]" <[email protected]> wrote:

> From: Dirk Brandewie <[email protected]>
>
> The value of spi->bits_per_word is checked on function entry to be 8
> or 16. The else clause has no meaning since it can never be reached.
>
> Signed-off-by: Dirk Brandewie <[email protected]>
> ---
> drivers/spi/spi-dw.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> index 7b3f607..5ddd45f 100644
> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -667,17 +667,14 @@ static int spi_dw_setup(struct spi_device *spi)
> chip->enable_dma = chip_info->enable_dma;
> }
>
> - if (spi->bits_per_word <= 8) {
> + if (spi->bits_per_word == 8) {
> chip->n_bytes = 1;
> chip->dma_width = 1;
> - } else if (spi->bits_per_word <= 16) {
> + } else if (spi->bits_per_word == 16) {
> chip->n_bytes = 2;
> chip->dma_width = 2;
> - } else {
> - /* Never take >16b case for DW SPIC */
> - dev_err(&spi->dev, "invalid wordsize\n");
> - return -EINVAL;
> }

These "else" case is used to ban the slave spi devices which
try to use 32 bits per word mode. This is like to tell those
spi devices with 32 bpw capability "we don't support 32b, pls
change"

> +
> chip->bits_per_word = spi->bits_per_word;
>
> chip->speed_hz = spi->max_speed_hz;

2011-06-23 03:01:29

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 08/11] spi-dw: Ensure fifo lenght is set.

On 06/22/2011 07:41 PM, Feng Tang wrote:
>
>
> On Thu, 23 Jun 2011 10:00:10 +0800
> "[email protected]"<[email protected]> wrote:
>
>> From: Dirk Brandewie<[email protected]>
>>
>> Bug on fifo_len not being set. The fifo sizing routine does not work
>> since the txfltr register can not be written while the controller is
>> enabled. The max value of txfltr can be larger than the fifo. The
>> register allows values upto 0x3f (63) the fifo depth on the Intel
>> SOC's if 40
>>
>> Signed-off-by: Dirk Brandewie<[email protected]>
>> ---
>> drivers/spi/spi-dw.c | 18 ++----------------
>> 1 files changed, 2 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
>> index ad92826..cc38aa0 100644
>> --- a/drivers/spi/spi-dw.c
>> +++ b/drivers/spi/spi-dw.c
>> @@ -776,25 +776,11 @@ static int destroy_queue(struct spi_dw *dws)
>> /* Restart the controller, disable all interrupts, clean rx fifo */
>> static void spi_dw_hw_init(struct spi_dw *dws)
>> {
>> + BUG_ON(!dws->fifo_len);
>> +
>> spi_dw_disable(dws);
>> spi_dw_mask_intr(dws, 0xff);
>> spi_dw_enable(dws);
>> -
>> - /*
>> - * Try to detect the FIFO depth if not set by interface
>> driver,
>> - * the depth could be from 2 to 256 from HW spec
>> - */
>> - if (!dws->fifo_len) {
>> - u32 fifo;
>> - for (fifo = 2; fifo<= 257; fifo++) {
>> - dw_writew(dws, txfltr, fifo);
>> - if (fifo != dw_readw(dws, txfltr))
>> - break;
>> - }
>> -
>> - dws->fifo_len = (fifo == 257) ? 0 : fifo;
>> - dw_writew(dws, txfltr, 0);
>> - }
>> }
>
> This code is requested by other community developers, the FIFO
> length is adjustable for the dw_spi core when deployed on
> different platforms, for those who are not certain about the
> FIFO len, they can use this code to probe the FIFO len.
>
> So we need to keep it.
>

Then I have bad documentation because document I have says that you can NOt
write to txfltr while the controller is enabled. The sizing routine as it
stands can't work for the implementation in Moorsetown and Medfield.

If there are other SOC's that are implementing different semantics for txfltr we
will need to handle this differently and do some runtime detection of how the
fifo should be sized.

Can you give ne a reference to the person that requiested the sizing code so I
can follow-up
>>
>> int __devinit spi_dw_add_host(struct spi_dw *dws)

2011-06-23 03:09:37

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 09/11] spi-dw: Fix condition in spi_dw_{writer/reader}

On 06/22/2011 07:45 PM, Feng Tang wrote:
> On Thu, 23 Jun 2011 10:00:11 +0800
> "[email protected]"<[email protected]> wrote:
>
>> From: Dirk Brandewie<[email protected]>
>>
>> Fix the condition based on whether the current transfer has a tx/rx
>> buffer.
>>
>> Signed-off-by: Dirk Brandewie<[email protected]>
>> ---
>> drivers/spi/spi-dw.c | 6 +++---
>> 1 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
>> index cc38aa0..35b952b 100644
>> --- a/drivers/spi/spi-dw.c
>> +++ b/drivers/spi/spi-dw.c
>> @@ -193,8 +193,8 @@ static void spi_dw_writer(struct spi_dw *dws)
>> u16 txw = 0;
>>
>> while (max--) {
>> - /* Set the tx word if the transfer's original "tx"
>> is not null */
>> - if (dws->tx_end - dws->len) {
>> + /* Set the tx word if the transfer's "tx" is not
>> null */
>> + if (dws->tx) {
>
> No, in current mainstream code, the dws->tx is changing, see code:
> dws->tx += dws->n_bytes;
> so we have to use if (dws->tx_end - dws->len) for now, maybe
> we can use some bit to indicate whether the original tx is null

If dws->tx is non-null then it points to a valid buffer, it is unconditionally
set with dws->tx = (void *)transfer->tx_buf when the transfer is setup. if the
original transfer->tx_buf is non-null then this change works.

>
>> if (dws->n_bytes == 1)
>> txw = *(u8 *)(dws->tx);
>> else
>> @@ -213,7 +213,7 @@ static void spi_dw_reader(struct spi_dw *dws)
>> while (max--) {
>> rxw = dw_readw(dws, dr);
>> /* Care rx only if the transfer's original "rx" is
>> not null */
>> - if (dws->rx_end - dws->len) {
>> + if (dws->rx) {
>> if (dws->n_bytes == 1)
>> *(u8 *)(dws->rx) = rxw;
>> else

2011-06-23 03:13:49

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 11/11] spi-dw: remove noop else clause

On 06/22/2011 07:47 PM, Feng Tang wrote:
> On Thu, 23 Jun 2011 10:00:13 +0800
> "[email protected]"<[email protected]> wrote:
>
>> From: Dirk Brandewie<[email protected]>
>>
>> The value of spi->bits_per_word is checked on function entry to be 8
>> or 16. The else clause has no meaning since it can never be reached.
>>
>> Signed-off-by: Dirk Brandewie<[email protected]>
>> ---
>> drivers/spi/spi-dw.c | 9 +++------
>> 1 files changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
>> index 7b3f607..5ddd45f 100644
>> --- a/drivers/spi/spi-dw.c
>> +++ b/drivers/spi/spi-dw.c
>> @@ -667,17 +667,14 @@ static int spi_dw_setup(struct spi_device *spi)
>> chip->enable_dma = chip_info->enable_dma;
>> }
>>
>> - if (spi->bits_per_word<= 8) {
>> + if (spi->bits_per_word == 8) {
>> chip->n_bytes = 1;
>> chip->dma_width = 1;
>> - } else if (spi->bits_per_word<= 16) {
>> + } else if (spi->bits_per_word == 16) {
>> chip->n_bytes = 2;
>> chip->dma_width = 2;
>> - } else {
>> - /* Never take>16b case for DW SPIC */
>> - dev_err(&spi->dev, "invalid wordsize\n");
>> - return -EINVAL;
>> }
>
> These "else" case is used to ban the slave spi devices which
> try to use 32 bits per word mode. This is like to tell those
> spi devices with 32 bpw capability "we don't support 32b, pls
> change"

The function has the prerequisite code:
if (spi->bits_per_word != 8 && spi->bits_per_word != 16)
return -EINVAL;

at the begining of the function so we will never be able to reach the else
clause that is being removed.

>
>> +
>> chip->bits_per_word = spi->bits_per_word;
>>
>> chip->speed_hz = spi->max_speed_hz;

2011-06-23 03:15:40

by Feng Tang

[permalink] [raw]
Subject: Re: [PATCH 08/11] spi-dw: Ensure fifo lenght is set.

On Thu, 23 Jun 2011 11:01:25 +0800
Dirk Brandewie <[email protected]> wrote:


> >> - /*
> >> - * Try to detect the FIFO depth if not set by interface
> >> driver,
> >> - * the depth could be from 2 to 256 from HW spec
> >> - */
> >> - if (!dws->fifo_len) {
> >> - u32 fifo;
> >> - for (fifo = 2; fifo<= 257; fifo++) {
> >> - dw_writew(dws, txfltr, fifo);
> >> - if (fifo != dw_readw(dws, txfltr))
> >> - break;
> >> - }
> >> -
> >> - dws->fifo_len = (fifo == 257) ? 0 : fifo;
> >> - dw_writew(dws, txfltr, 0);
> >> - }
> >> }
> >
> > This code is requested by other community developers, the FIFO
> > length is adjustable for the dw_spi core when deployed on
> > different platforms, for those who are not certain about the
> > FIFO len, they can use this code to probe the FIFO len.
> >
> > So we need to keep it.
> >
>
> Then I have bad documentation because document I have says that you
> can NOt write to txfltr while the controller is enabled. The sizing
> routine as it stands can't work for the implementation in Moorsetown
> and Medfield.
>
> If there are other SOC's that are implementing different semantics
> for txfltr we will need to handle this differently and do some
> runtime detection of how the fifo should be sized.
>
> Can you give ne a reference to the person that requiested the sizing
> code so I can follow-up

Git-show c587b6fa0510

commit c587b6fa05106606053fc5e8e344f07cd34ace23
Author: Feng Tang <[email protected]>
Date: Thu Jan 21 10:41:10 2010 +0800

spi/dw_spi: add a FIFO depth detection

FIFO depth is configurable for each implementation of DW core,
so add a depth detection for those interface drivers who don't set
the fifo_len explicitly

Signed-off-by: Feng Tang <[email protected]>
Acked-by: Jean-Hugues Deschenes <[email protected]>
Signed-off-by: Grant Likely <[email protected]>

I added the code per request from Jean-Hugues Deschenes.

Recently Alek Du has tested this code on his Medfield platform.

Thanks,
Feng

2011-06-23 03:18:40

by Feng Tang

[permalink] [raw]
Subject: Re: [PATCH 09/11] spi-dw: Fix condition in spi_dw_{writer/reader}

On Thu, 23 Jun 2011 11:09:34 +0800
Dirk Brandewie <[email protected]> wrote:

> On 06/22/2011 07:45 PM, Feng Tang wrote:
> > On Thu, 23 Jun 2011 10:00:11 +0800
> > "[email protected]"<[email protected]> wrote:
> >
> >> From: Dirk Brandewie<[email protected]>
> >>
> >> Fix the condition based on whether the current transfer has a tx/rx
> >> buffer.
> >>
> >> Signed-off-by: Dirk Brandewie<[email protected]>
> >> ---
> >> drivers/spi/spi-dw.c | 6 +++---
> >> 1 files changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> >> index cc38aa0..35b952b 100644
> >> --- a/drivers/spi/spi-dw.c
> >> +++ b/drivers/spi/spi-dw.c
> >> @@ -193,8 +193,8 @@ static void spi_dw_writer(struct spi_dw *dws)
> >> u16 txw = 0;
> >>
> >> while (max--) {
> >> - /* Set the tx word if the transfer's original "tx"
> >> is not null */
> >> - if (dws->tx_end - dws->len) {
> >> + /* Set the tx word if the transfer's "tx" is not
> >> null */
> >> + if (dws->tx) {
> >
> > No, in current mainstream code, the dws->tx is changing, see code:
> > dws->tx += dws->n_bytes;
> > so we have to use if (dws->tx_end - dws->len) for now, maybe
> > we can use some bit to indicate whether the original tx is null
>
> If dws->tx is non-null then it points to a valid buffer, it is
> unconditionally set with dws->tx = (void *)transfer->tx_buf when the
> transfer is setup. if the original transfer->tx_buf is non-null then
> this change works.

dws->tx is changing as I said, non-null doesn't mean the value is valid,
when the original tx is null, we don't access it at all, it's just a
indicator of whether the dws->len of zeor has been filled to FIFO.

This logic may looks confusing, but it's correct after years of test.

>
> >
> >> if (dws->n_bytes == 1)
> >> txw = *(u8 *)(dws->tx);
> >> else
> >> @@ -213,7 +213,7 @@ static void spi_dw_reader(struct spi_dw *dws)
> >> while (max--) {
> >> rxw = dw_readw(dws, dr);
> >> /* Care rx only if the transfer's original "rx"
> >> is not null */
> >> - if (dws->rx_end - dws->len) {
> >> + if (dws->rx) {
> >> if (dws->n_bytes == 1)
> >> *(u8 *)(dws->rx) = rxw;
> >> else
>

2011-06-23 03:30:07

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 09/11] spi-dw: Fix condition in spi_dw_{writer/reader}

This patch should have been:

spi-dw: Fix condition in spi_dw_{writer/reader}

From: Dirk Brandewie <[email protected]>

Fix the condition based on whether the current transfer has a tx/rx
buffer.

Signed-off-by: Dirk Brandewie <[email protected]>
---
drivers/spi/spi-dw.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 96ae4a7..0a848bc 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -193,15 +193,15 @@ static void spi_dw_writer(struct spi_dw *dws)
u16 txw = 0;

while (max--) {
- /* Set the tx word if the transfer's original "tx" is not null */
- if (dws->tx_end - dws->len) {
+ /* Set the tx word if the transfer's "tx" is not null */
+ if (dws->tx) {
if (dws->n_bytes == 1)
txw = *(u8 *)(dws->tx);
else
txw = *(u16 *)(dws->tx);
+ dws->tx += dws->n_bytes;
}
dw_writew(dws, dr, txw);
- dws->tx += dws->n_bytes;
}
}

@@ -213,13 +213,13 @@ static void spi_dw_reader(struct spi_dw *dws)
while (max--) {
rxw = dw_readw(dws, dr);
/* Care rx only if the transfer's original "rx" is not null */
- if (dws->rx_end - dws->len) {
+ if (dws->rx) {
if (dws->n_bytes == 1)
*(u8 *)(dws->rx) = rxw;
else
*(u16 *)(dws->rx) = rxw;
+ dws->rx += dws->n_bytes;
}
- dws->rx += dws->n_bytes;
}
}

2011-06-23 03:47:28

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 01/11] spi-dw: expose platform data stucture.

On Wed, Jun 22, 2011 at 8:00 PM, <[email protected]> wrote:
> From: Dirk Brandewie <[email protected]>
>
> Expose the platform data structure for use by client drivers. ATM
> there are not any in-tree drivers using the driver (that I can
> find). This patch exposes the platform data needed for client drivers.

? Why would client drivers want to muck with this configuration? I
can understand the dw_spi driver being able to have per-spi_device
configuration, but spi_drivers absolutely should not have visibility
into bus-specific details. Am I misunderstanding something.

g.

>
> Signed-off-by: Dirk Brandewie <[email protected]>
> ---
> ?drivers/spi/spi-dw.c ? ? ? | ? ?3 ---
> ?drivers/spi/spi-dw.h ? ? ? | ? 18 +-----------------
> ?include/linux/spi/spi-dw.h | ? 42 ++++++++++++++++++++++++++++++++++++++++++
> ?3 files changed, 43 insertions(+), 20 deletions(-)
> ?create mode 100644 include/linux/spi/spi-dw.h
>
> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> index ece5f69..61f7ed8 100644
> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -38,9 +38,6 @@
> ?#define QUEUE_RUNNING ?0
> ?#define QUEUE_STOPPED ?1
>
> -#define MRST_SPI_DEASSERT ? ? ?0
> -#define MRST_SPI_ASSERT ? ? ? ? ? ? ? ?1
> -
> ?/* Slave spi_dev related */
> ?struct chip_data {
> ? ? ? ?u16 cr0;
> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
> index 7a5e78d..92bee30 100644
> --- a/drivers/spi/spi-dw.h
> +++ b/drivers/spi/spi-dw.h
> @@ -3,6 +3,7 @@
>
> ?#include <linux/io.h>
> ?#include <linux/scatterlist.h>
> +#include <linux/spi/spi-dw.h>
>
> ?/* Bit fields in CTRLR0 */
> ?#define SPI_DFS_OFFSET ? ? ? ? ? ? ? ? 0
> @@ -49,11 +50,6 @@
> ?/* TX RX interrupt level threshold, max can be 256 */
> ?#define SPI_INT_THRESHOLD ? ? ? ? ? ? ?32
>
> -enum dw_ssi_type {
> - ? ? ? SSI_MOTO_SPI = 0,
> - ? ? ? SSI_TI_SSP,
> - ? ? ? SSI_NS_MICROWIRE,
> -};
>
> ?struct dw_spi_reg {
> ? ? ? ?u32 ? ? ctrl0;
> @@ -208,18 +204,6 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
> ? ? ? ?dw_writel(dws, imr, new_mask);
> ?}
>
> -/*
> - * Each SPI slave device to work with dw_api controller should
> - * has such a structure claiming its working mode (PIO/DMA etc),
> - * which can be save in the "controller_data" member of the
> - * struct spi_device
> - */
> -struct dw_spi_chip {
> - ? ? ? u8 poll_mode; ? /* 0 for contoller polling mode */
> - ? ? ? u8 type; ? ? ? ?/* SPI/SSP/Micrwire */
> - ? ? ? u8 enable_dma;
> - ? ? ? void (*cs_control)(u32 command);
> -};
>
> ?extern int dw_spi_add_host(struct dw_spi *dws);
> ?extern void dw_spi_remove_host(struct dw_spi *dws);
> diff --git a/include/linux/spi/spi-dw.h b/include/linux/spi/spi-dw.h
> new file mode 100644
> index 0000000..787b154
> --- /dev/null
> +++ b/include/linux/spi/spi-dw.h
> @@ -0,0 +1,42 @@
> +/*
> + *
> + * Copyright (c) 2009, Intel Corporation.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE. ?See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along with
> + * this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#ifndef _SPI_DW_H_
> +#define _SPI_DW_H_
> +enum spi_dw_ssi_type {
> + ? ? ? SSI_MOTO_SPI = 0,
> + ? ? ? SSI_TI_SSP,
> + ? ? ? SSI_NS_MICROWIRE,
> +};
> +
> +#define MRST_SPI_DEASSERT ? ? ?0
> +#define MRST_SPI_ASSERT ? ? ? ? ? ? ? ?1
> +
> +/*
> + * Each SPI slave device to work with dw_api controller should
> + * has such a structure claiming its working mode (PIO/DMA etc),
> + * which can be save in the "controller_data" member of the
> + * struct spi_device
> + */
> +struct spi_dw_chip {
> + ? ? ? u8 poll_mode; ? /* 0 for contoller polling mode */
> + ? ? ? u8 type; ? ? ? ?/* SPI/SSP/Micrwire */
> + ? ? ? u8 enable_dma;
> + ? ? ? void (*cs_control)(u32 command);
> +};
> +#endif
> --
> 1.7.3.4
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> spi-devel-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
>



--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

2011-06-23 03:52:07

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 06/11] spi-dw: Force error on out of range chip select.

On Wed, Jun 22, 2011 at 8:00 PM, <[email protected]> wrote:
> From: Dirk Brandewie <[email protected]>
>
> BUG_ON() if the selected chip select is out of range.
>
> Signed-off-by: Dirk Brandewie <[email protected]>
> ---
> ?drivers/spi/spi-dw.h | ? ?3 +--
> ?1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
> index 860bc34..3fa4c13 100644
> --- a/drivers/spi/spi-dw.h
> +++ b/drivers/spi/spi-dw.h
> @@ -178,8 +178,7 @@ static inline void spi_dw_set_clk(struct spi_dw *dws, u16 div)
>
> ?static inline void spi_dw_chip_sel(struct spi_dw *dws, u16 cs)
> ?{
> - ? ? ? if (cs > dws->num_cs)
> - ? ? ? ? ? ? ? return;
> + ? ? ? BUG_ON(cs >= dws->master->num_chipselect);

BUG is rather an over-reaction. The transfer should be rejected if
the cs# is invalid, and a warning message is appropriate, but BUG() is
too extreme.

g.

2011-06-23 03:54:02

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 07/11] spi-dw: Set number of available chip selects correctly

On Wed, Jun 22, 2011 at 8:00 PM, <[email protected]> wrote:
> From: Dirk Brandewie <[email protected]>
>
> Only four chip selects are available directly off the pins of the
> master.
>
> Signed-off-by: Dirk Brandewie <[email protected]>
> ---
> ?drivers/spi/spi-dw-mid.c | ? ?4 +++-
> ?1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
> index 78e64d3..1d11268 100644
> --- a/drivers/spi/spi-dw-mid.c
> +++ b/drivers/spi/spi-dw-mid.c
> @@ -211,7 +211,9 @@ int spi_dw_mid_init(struct spi_dw *dws)
> ? ? ? ?dws->max_freq = MRST_SPI_CLK_BASE / (clk_cdiv + 1);
> ? ? ? ?iounmap(clk_reg);
>
> - ? ? ? dws->num_cs = 16;
> + ? ? ? dws->num_cs = 4; ? ? ? ?/* spi_dw_chip_sel() bits 0-3 are
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?* valid in the slave enable register
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*/

I thought someone had told me that the dw spio core supported using
the 4 cs lines in a multiplex mode to create up to 15 cs lines, but I
may be misremembering.

g.

2011-06-23 03:55:43

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 08/11] spi-dw: Ensure fifo lenght is set.

On Wed, Jun 22, 2011 at 8:00 PM, <[email protected]> wrote:
> From: Dirk Brandewie <[email protected]>
>
> Bug on fifo_len not being set. ?The fifo sizing routine does not work
> since the txfltr register can not be written while the controller is
> enabled. The max value of txfltr can be larger than the fifo. ?The
> register allows values upto 0x3f (63) the fifo depth on the Intel
> SOC's if 40
>
> Signed-off-by: Dirk Brandewie <[email protected]>
> ---
> ?drivers/spi/spi-dw.c | ? 18 ++----------------
> ?1 files changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> index ad92826..cc38aa0 100644
> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -776,25 +776,11 @@ static int destroy_queue(struct spi_dw *dws)
> ?/* Restart the controller, disable all interrupts, clean rx fifo */
> ?static void spi_dw_hw_init(struct spi_dw *dws)
> ?{
> + ? ? ? BUG_ON(!dws->fifo_len);
> +

Ditto here. BUG is too big a reaction. Fail to initialize the
device, sure, and print a warning, but don't BUG.

g.

> ? ? ? ?spi_dw_disable(dws);
> ? ? ? ?spi_dw_mask_intr(dws, 0xff);
> ? ? ? ?spi_dw_enable(dws);
> -
> - ? ? ? /*
> - ? ? ? ?* Try to detect the FIFO depth if not set by interface driver,
> - ? ? ? ?* the depth could be from 2 to 256 from HW spec
> - ? ? ? ?*/
> - ? ? ? if (!dws->fifo_len) {
> - ? ? ? ? ? ? ? u32 fifo;
> - ? ? ? ? ? ? ? for (fifo = 2; fifo <= 257; fifo++) {
> - ? ? ? ? ? ? ? ? ? ? ? dw_writew(dws, txfltr, fifo);
> - ? ? ? ? ? ? ? ? ? ? ? if (fifo != dw_readw(dws, txfltr))
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
> - ? ? ? ? ? ? ? }
> -
> - ? ? ? ? ? ? ? dws->fifo_len = (fifo == 257) ? 0 : fifo;
> - ? ? ? ? ? ? ? dw_writew(dws, txfltr, 0);
> - ? ? ? }
> ?}
>
> ?int __devinit spi_dw_add_host(struct spi_dw *dws)
> --
> 1.7.3.4
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> spi-devel-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
>



--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

2011-06-23 04:00:43

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 01/11] spi-dw: expose platform data stucture.

On 06/22/2011 08:47 PM, Grant Likely wrote:
> On Wed, Jun 22, 2011 at 8:00 PM,<[email protected]> wrote:
>> From: Dirk Brandewie<[email protected]>
>>
>> Expose the platform data structure for use by client drivers. ATM
>> there are not any in-tree drivers using the driver (that I can
>> find). This patch exposes the platform data needed for client drivers.
>
> ? Why would client drivers want to muck with this configuration? I
> can understand the dw_spi driver being able to have per-spi_device
> configuration, but spi_drivers absolutely should not have visibility
> into bus-specific details. Am I misunderstanding something.
>

Most of these config options don't need to be client configurable IMHO but they
are being used ATM by drivers that aren't upstream and the current controller
driver uses them. This patch is to give a smooth transition (bisectable) to my
change that reworks the core message and transfer handling code.

This allows me to provide patches to the developers of the out of tree drivers
that should be coming in RSN and exposes the interface they are using now.

--Dirk
> g.
>
>>
>> Signed-off-by: Dirk Brandewie<[email protected]>
>> ---
>> drivers/spi/spi-dw.c | 3 ---
>> drivers/spi/spi-dw.h | 18 +-----------------
>> include/linux/spi/spi-dw.h | 42 ++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 43 insertions(+), 20 deletions(-)
>> create mode 100644 include/linux/spi/spi-dw.h
>>
>> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
>> index ece5f69..61f7ed8 100644
>> --- a/drivers/spi/spi-dw.c
>> +++ b/drivers/spi/spi-dw.c
>> @@ -38,9 +38,6 @@
>> #define QUEUE_RUNNING 0
>> #define QUEUE_STOPPED 1
>>
>> -#define MRST_SPI_DEASSERT 0
>> -#define MRST_SPI_ASSERT 1
>> -
>> /* Slave spi_dev related */
>> struct chip_data {
>> u16 cr0;
>> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
>> index 7a5e78d..92bee30 100644
>> --- a/drivers/spi/spi-dw.h
>> +++ b/drivers/spi/spi-dw.h
>> @@ -3,6 +3,7 @@
>>
>> #include<linux/io.h>
>> #include<linux/scatterlist.h>
>> +#include<linux/spi/spi-dw.h>
>>
>> /* Bit fields in CTRLR0 */
>> #define SPI_DFS_OFFSET 0
>> @@ -49,11 +50,6 @@
>> /* TX RX interrupt level threshold, max can be 256 */
>> #define SPI_INT_THRESHOLD 32
>>
>> -enum dw_ssi_type {
>> - SSI_MOTO_SPI = 0,
>> - SSI_TI_SSP,
>> - SSI_NS_MICROWIRE,
>> -};
>>
>> struct dw_spi_reg {
>> u32 ctrl0;
>> @@ -208,18 +204,6 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
>> dw_writel(dws, imr, new_mask);
>> }
>>
>> -/*
>> - * Each SPI slave device to work with dw_api controller should
>> - * has such a structure claiming its working mode (PIO/DMA etc),
>> - * which can be save in the "controller_data" member of the
>> - * struct spi_device
>> - */
>> -struct dw_spi_chip {
>> - u8 poll_mode; /* 0 for contoller polling mode */
>> - u8 type; /* SPI/SSP/Micrwire */
>> - u8 enable_dma;
>> - void (*cs_control)(u32 command);
>> -};
>>
>> extern int dw_spi_add_host(struct dw_spi *dws);
>> extern void dw_spi_remove_host(struct dw_spi *dws);
>> diff --git a/include/linux/spi/spi-dw.h b/include/linux/spi/spi-dw.h
>> new file mode 100644
>> index 0000000..787b154
>> --- /dev/null
>> +++ b/include/linux/spi/spi-dw.h
>> @@ -0,0 +1,42 @@
>> +/*
>> + *
>> + * Copyright (c) 2009, Intel Corporation.
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms and conditions of the GNU General Public License,
>> + * version 2, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope it will be useful, but WITHOUT
>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
>> + * more details.
>> + *
>> + * You should have received a copy of the GNU General Public License along with
>> + * this program; if not, write to the Free Software Foundation, Inc.,
>> + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
>> + */
>> +
>> +#ifndef _SPI_DW_H_
>> +#define _SPI_DW_H_
>> +enum spi_dw_ssi_type {
>> + SSI_MOTO_SPI = 0,
>> + SSI_TI_SSP,
>> + SSI_NS_MICROWIRE,
>> +};
>> +
>> +#define MRST_SPI_DEASSERT 0
>> +#define MRST_SPI_ASSERT 1
>> +
>> +/*
>> + * Each SPI slave device to work with dw_api controller should
>> + * has such a structure claiming its working mode (PIO/DMA etc),
>> + * which can be save in the "controller_data" member of the
>> + * struct spi_device
>> + */
>> +struct spi_dw_chip {
>> + u8 poll_mode; /* 0 for contoller polling mode */
>> + u8 type; /* SPI/SSP/Micrwire */
>> + u8 enable_dma;
>> + void (*cs_control)(u32 command);
>> +};
>> +#endif
>> --
>> 1.7.3.4
>>
>>
>> ------------------------------------------------------------------------------
>> Simplify data backup and recovery for your virtual environment with vRanger.
>> Installation's a snap, and flexible recovery options mean your data is safe,
>> secure and there when you need it. Data protection magic?
>> Nope - It's vRanger. Get your free trial download today.
>> http://p.sf.net/sfu/quest-sfdev2dev
>> _______________________________________________
>> spi-devel-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
>>
>
>
>

2011-06-23 04:03:44

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 01/11] spi-dw: expose platform data stucture.



Dirk Brandewie <[email protected]> wrote:

>On 06/22/2011 08:47 PM, Grant Likely wrote:
>> On Wed, Jun 22, 2011 at 8:00 PM,<[email protected]> wrote:
>>> From: Dirk Brandewie<[email protected]>
>>>
>>> Expose the platform data structure for use by client drivers. ATM
>>> there are not any in-tree drivers using the driver (that I can
>>> find). This patch exposes the platform data needed for client
>drivers.
>>
>> ? Why would client drivers want to muck with this configuration? I
>> can understand the dw_spi driver being able to have per-spi_device
>> configuration, but spi_drivers absolutely should not have visibility
>> into bus-specific details. Am I misunderstanding something.
>>
>
>Most of these config options don't need to be client configurable IMHO
>but they
>are being used ATM by drivers that aren't upstream and the current
>controller
>driver uses them. This patch is to give a smooth transition
>(bisectable) to my
>change that reworks the core message and transfer handling code.
>
>This allows me to provide patches to the developers of the out of tree
>drivers
>that should be coming in RSN and exposes the interface they are using
>now.

My question still stands. Are you expecting spi_driver code to manipulate this data?

g.

>
>--Dirk
>> g.
>>
>>>
>>> Signed-off-by: Dirk Brandewie<[email protected]>
>>> ---
>>> drivers/spi/spi-dw.c | 3 ---
>>> drivers/spi/spi-dw.h | 18 +-----------------
>>> include/linux/spi/spi-dw.h | 42
>++++++++++++++++++++++++++++++++++++++++++
>>> 3 files changed, 43 insertions(+), 20 deletions(-)
>>> create mode 100644 include/linux/spi/spi-dw.h
>>>
>>> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
>>> index ece5f69..61f7ed8 100644
>>> --- a/drivers/spi/spi-dw.c
>>> +++ b/drivers/spi/spi-dw.c
>>> @@ -38,9 +38,6 @@
>>> #define QUEUE_RUNNING 0
>>> #define QUEUE_STOPPED 1
>>>
>>> -#define MRST_SPI_DEASSERT 0
>>> -#define MRST_SPI_ASSERT 1
>>> -
>>> /* Slave spi_dev related */
>>> struct chip_data {
>>> u16 cr0;
>>> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
>>> index 7a5e78d..92bee30 100644
>>> --- a/drivers/spi/spi-dw.h
>>> +++ b/drivers/spi/spi-dw.h
>>> @@ -3,6 +3,7 @@
>>>
>>> #include<linux/io.h>
>>> #include<linux/scatterlist.h>
>>> +#include<linux/spi/spi-dw.h>
>>>
>>> /* Bit fields in CTRLR0 */
>>> #define SPI_DFS_OFFSET 0
>>> @@ -49,11 +50,6 @@
>>> /* TX RX interrupt level threshold, max can be 256 */
>>> #define SPI_INT_THRESHOLD 32
>>>
>>> -enum dw_ssi_type {
>>> - SSI_MOTO_SPI = 0,
>>> - SSI_TI_SSP,
>>> - SSI_NS_MICROWIRE,
>>> -};
>>>
>>> struct dw_spi_reg {
>>> u32 ctrl0;
>>> @@ -208,18 +204,6 @@ static inline void spi_umask_intr(struct dw_spi
>*dws, u32 mask)
>>> dw_writel(dws, imr, new_mask);
>>> }
>>>
>>> -/*
>>> - * Each SPI slave device to work with dw_api controller should
>>> - * has such a structure claiming its working mode (PIO/DMA etc),
>>> - * which can be save in the "controller_data" member of the
>>> - * struct spi_device
>>> - */
>>> -struct dw_spi_chip {
>>> - u8 poll_mode; /* 0 for contoller polling mode */
>>> - u8 type; /* SPI/SSP/Micrwire */
>>> - u8 enable_dma;
>>> - void (*cs_control)(u32 command);
>>> -};
>>>
>>> extern int dw_spi_add_host(struct dw_spi *dws);
>>> extern void dw_spi_remove_host(struct dw_spi *dws);
>>> diff --git a/include/linux/spi/spi-dw.h b/include/linux/spi/spi-dw.h
>>> new file mode 100644
>>> index 0000000..787b154
>>> --- /dev/null
>>> +++ b/include/linux/spi/spi-dw.h
>>> @@ -0,0 +1,42 @@
>>> +/*
>>> + *
>>> + * Copyright (c) 2009, Intel Corporation.
>>> + *
>>> + * This program is free software; you can redistribute it and/or
>modify it
>>> + * under the terms and conditions of the GNU General Public
>License,
>>> + * version 2, as published by the Free Software Foundation.
>>> + *
>>> + * This program is distributed in the hope it will be useful, but
>WITHOUT
>>> + * ANY WARRANTY; without even the implied warranty of
>MERCHANTABILITY or
>>> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
>License for
>>> + * more details.
>>> + *
>>> + * You should have received a copy of the GNU General Public
>License along with
>>> + * this program; if not, write to the Free Software Foundation,
>Inc.,
>>> + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
>>> + */
>>> +
>>> +#ifndef _SPI_DW_H_
>>> +#define _SPI_DW_H_
>>> +enum spi_dw_ssi_type {
>>> + SSI_MOTO_SPI = 0,
>>> + SSI_TI_SSP,
>>> + SSI_NS_MICROWIRE,
>>> +};
>>> +
>>> +#define MRST_SPI_DEASSERT 0
>>> +#define MRST_SPI_ASSERT 1
>>> +
>>> +/*
>>> + * Each SPI slave device to work with dw_api controller should
>>> + * has such a structure claiming its working mode (PIO/DMA etc),
>>> + * which can be save in the "controller_data" member of the
>>> + * struct spi_device
>>> + */
>>> +struct spi_dw_chip {
>>> + u8 poll_mode; /* 0 for contoller polling mode */
>>> + u8 type; /* SPI/SSP/Micrwire */
>>> + u8 enable_dma;
>>> + void (*cs_control)(u32 command);
>>> +};
>>> +#endif
>>> --
>>> 1.7.3.4
>>>
>>>
>>>
>------------------------------------------------------------------------------
>>> Simplify data backup and recovery for your virtual environment with
>vRanger.
>>> Installation's a snap, and flexible recovery options mean your data
>is safe,
>>> secure and there when you need it. Data protection magic?
>>> Nope - It's vRanger. Get your free trial download today.
>>> http://p.sf.net/sfu/quest-sfdev2dev
>>> _______________________________________________
>>> spi-devel-general mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
>>>
>>
>>
>>

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

2011-06-23 04:13:41

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 06/11] spi-dw: Force error on out of range chip select.

On 06/22/2011 08:51 PM, Grant Likely wrote:
> On Wed, Jun 22, 2011 at 8:00 PM,<[email protected]> wrote:
>> From: Dirk Brandewie<[email protected]>
>>
>> BUG_ON() if the selected chip select is out of range.
>>
>> Signed-off-by: Dirk Brandewie<[email protected]>
>> ---
>> drivers/spi/spi-dw.h | 3 +--
>> 1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
>> index 860bc34..3fa4c13 100644
>> --- a/drivers/spi/spi-dw.h
>> +++ b/drivers/spi/spi-dw.h
>> @@ -178,8 +178,7 @@ static inline void spi_dw_set_clk(struct spi_dw *dws, u16 div)
>>
>> static inline void spi_dw_chip_sel(struct spi_dw *dws, u16 cs)
>> {
>> - if (cs> dws->num_cs)
>> - return;
>> + BUG_ON(cs>= dws->master->num_chipselect);
>
> BUG is rather an over-reaction. The transfer should be rejected if
> the cs# is invalid, and a warning message is appropriate, but BUG() is
> too extreme.

This is extreme I agree, the current driver will fail silently if an out of
range chip select is requested.

We can drop this one for now and I will put a proper check in probe/init so we
won't get here.



>
> g.

2011-06-23 04:20:16

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 08/11] spi-dw: Ensure fifo lenght is set.

On 06/22/2011 08:55 PM, Grant Likely wrote:
> On Wed, Jun 22, 2011 at 8:00 PM,<[email protected]> wrote:
>> From: Dirk Brandewie<[email protected]>
>>
>> Bug on fifo_len not being set. The fifo sizing routine does not work
>> since the txfltr register can not be written while the controller is
>> enabled. The max value of txfltr can be larger than the fifo. The
>> register allows values upto 0x3f (63) the fifo depth on the Intel
>> SOC's if 40
>>
>> Signed-off-by: Dirk Brandewie<[email protected]>
>> ---
>> drivers/spi/spi-dw.c | 18 ++----------------
>> 1 files changed, 2 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
>> index ad92826..cc38aa0 100644
>> --- a/drivers/spi/spi-dw.c
>> +++ b/drivers/spi/spi-dw.c
>> @@ -776,25 +776,11 @@ static int destroy_queue(struct spi_dw *dws)
>> /* Restart the controller, disable all interrupts, clean rx fifo */
>> static void spi_dw_hw_init(struct spi_dw *dws)
>> {
>> + BUG_ON(!dws->fifo_len);
>> +
>
> Ditto here. BUG is too big a reaction. Fail to initialize the
> device, sure, and print a warning, but don't BUG.

Ack, I was trying to make sure the bug got caught while I was working towards
getting the rest of my changes in.

--Dirk

2011-06-23 04:37:34

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 01/11] spi-dw: expose platform data stucture.

On 06/22/2011 09:03 PM, [email protected] wrote:
>
>
> Dirk Brandewie<[email protected]> wrote:
>
>> On 06/22/2011 08:47 PM, Grant Likely wrote:
>>> On Wed, Jun 22, 2011 at 8:00 PM,<[email protected]> wrote:
>>>> From: Dirk Brandewie<[email protected]>
>>>>
>>>> Expose the platform data structure for use by client drivers. ATM
>>>> there are not any in-tree drivers using the driver (that I can
>>>> find). This patch exposes the platform data needed for client
>> drivers.
>>>
>>> ? Why would client drivers want to muck with this configuration? I
>>> can understand the dw_spi driver being able to have per-spi_device
>>> configuration, but spi_drivers absolutely should not have visibility
>>> into bus-specific details. Am I misunderstanding something.
>>>
>>
>> Most of these config options don't need to be client configurable IMHO
>> but they
>> are being used ATM by drivers that aren't upstream and the current
>> controller
>> driver uses them. This patch is to give a smooth transition
>> (bisectable) to my
>> change that reworks the core message and transfer handling code.
>>
>> This allows me to provide patches to the developers of the out of tree
>> drivers
>> that should be coming in RSN and exposes the interface they are using
>> now.
>
> My question still stands. Are you expecting spi_driver code to manipulate this data?
>
>

The current drivers behaviour is driven by this data provided by the client.
This makes the current client drivers work since some have not picked picked up
your change moving dw_spi.h out of include/linux/spi (right answer IMHO) and
provides the interface they are using now.

--Dirk



2011-06-23 05:06:22

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 01/11] spi-dw: expose platform data stucture.



Dirk Brandewie <[email protected]> wrote:

>On 06/22/2011 09:03 PM, [email protected] wrote:
>>
>>
>> Dirk Brandewie<[email protected]> wrote:
>>
>>> On 06/22/2011 08:47 PM, Grant Likely wrote:
>>>> On Wed, Jun 22, 2011 at 8:00 PM,<[email protected]> wrote:
>>>>> From: Dirk Brandewie<[email protected]>
>>>>>
>>>>> Expose the platform data structure for use by client drivers. ATM
>>>>> there are not any in-tree drivers using the driver (that I can
>>>>> find). This patch exposes the platform data needed for client
>>> drivers.
>>>>
>>>> ? Why would client drivers want to muck with this configuration?
>I
>>>> can understand the dw_spi driver being able to have per-spi_device
>>>> configuration, but spi_drivers absolutely should not have
>visibility
>>>> into bus-specific details. Am I misunderstanding something.
>>>>
>>>
>>> Most of these config options don't need to be client configurable
>IMHO
>>> but they
>>> are being used ATM by drivers that aren't upstream and the current
>>> controller
>>> driver uses them. This patch is to give a smooth transition
>>> (bisectable) to my
>>> change that reworks the core message and transfer handling code.
>>>
>>> This allows me to provide patches to the developers of the out of
>tree
>>> drivers
>>> that should be coming in RSN and exposes the interface they are
>using
>>> now.
>>
>> My question still stands. Are you expecting spi_driver code to
>manipulate this data?
>>
>>
>
>The current drivers behaviour is driven by this data provided by the
>client.
>This makes the current client drivers work since some have not picked
>picked up
>your change moving dw_spi.h out of include/linux/spi (right answer
>IMHO) and
>provides the interface they are using now.

So the situation is that certain out-of-tree spi_drivers are reaching into internal details of a specific spi bus driver? If so, then that is wrong and bad, and certainly will not be merged. Especially when there are no in tree users and neither does this series add any.

g.

>
>--Dirk

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

2011-06-23 05:01:38

by Feng Tang

[permalink] [raw]
Subject: Re: [PATCH 09/11] spi-dw: Fix condition in spi_dw_{writer/reader}

On Thu, 23 Jun 2011 11:30:02 +0800
Dirk Brandewie <[email protected]> wrote:

> This patch should have been:
>
> spi-dw: Fix condition in spi_dw_{writer/reader}
>
> From: Dirk Brandewie <[email protected]>
>
> Fix the condition based on whether the current transfer has a tx/rx
> buffer.
>
> Signed-off-by: Dirk Brandewie <[email protected]>
> ---
> drivers/spi/spi-dw.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
> index 96ae4a7..0a848bc 100644
> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -193,15 +193,15 @@ static void spi_dw_writer(struct spi_dw *dws)
> u16 txw = 0;
>
> while (max--) {
> - /* Set the tx word if the transfer's original "tx" is
> not null */
> - if (dws->tx_end - dws->len) {
> + /* Set the tx word if the transfer's "tx" is not null
> */
> + if (dws->tx) {
> if (dws->n_bytes == 1)
> txw = *(u8 *)(dws->tx);
> else
> txw = *(u16 *)(dws->tx);
> + dws->tx += dws->n_bytes;
> }
> dw_writew(dws, dr, txw);
> - dws->tx += dws->n_bytes;
> }
> }

emm, this patch still break the NULL original tx buf case, as it is used in

/* Return the max entries we can fill into tx fifo */
static inline u32 tx_max(struct dw_spi *dws)
{
u32 tx_left, tx_room, rxtx_gap;

tx_left = (dws->tx_end - dws->tx) / dws->n_bytes;
tx_room = dws->fifo_len - dw_readw(dws, txflr);



>
> @@ -213,13 +213,13 @@ static void spi_dw_reader(struct spi_dw *dws)
> while (max--) {
> rxw = dw_readw(dws, dr);
> /* Care rx only if the transfer's original "rx" is
> not null */
> - if (dws->rx_end - dws->len) {
> + if (dws->rx) {
> if (dws->n_bytes == 1)
> *(u8 *)(dws->rx) = rxw;
> else
> *(u16 *)(dws->rx) = rxw;
> + dws->rx += dws->n_bytes;
> }
> - dws->rx += dws->n_bytes;
> }
> }
>

2011-06-23 05:16:15

by Dirk Brandewie

[permalink] [raw]
Subject: Re: [PATCH 01/11] spi-dw: expose platform data stucture.

On 06/22/2011 10:06 PM, [email protected] wrote:
>
>
> Dirk Brandewie<[email protected]> wrote:
>
>> On 06/22/2011 09:03 PM, [email protected] wrote:
>>>
>>>
>>> Dirk Brandewie<[email protected]> wrote:
>>>
>>>> On 06/22/2011 08:47 PM, Grant Likely wrote:
>>>>> On Wed, Jun 22, 2011 at 8:00 PM,<[email protected]> wrote:
>>>>>> From: Dirk Brandewie<[email protected]>
>>>>>>
>>>>>> Expose the platform data structure for use by client drivers. ATM
>>>>>> there are not any in-tree drivers using the driver (that I can
>>>>>> find). This patch exposes the platform data needed for client
>>>> drivers.
>>>>>
>>>>> ? Why would client drivers want to muck with this configuration?
>> I
>>>>> can understand the dw_spi driver being able to have per-spi_device
>>>>> configuration, but spi_drivers absolutely should not have
>> visibility
>>>>> into bus-specific details. Am I misunderstanding something.
>>>>>
>>>>
>>>> Most of these config options don't need to be client configurable
>> IMHO
>>>> but they
>>>> are being used ATM by drivers that aren't upstream and the current
>>>> controller
>>>> driver uses them. This patch is to give a smooth transition
>>>> (bisectable) to my
>>>> change that reworks the core message and transfer handling code.
>>>>
>>>> This allows me to provide patches to the developers of the out of
>> tree
>>>> drivers
>>>> that should be coming in RSN and exposes the interface they are
>> using
>>>> now.
>>>
>>> My question still stands. Are you expecting spi_driver code to
>> manipulate this data?
>>>
>>>
>>
>> The current drivers behaviour is driven by this data provided by the
>> client.
>> This makes the current client drivers work since some have not picked
>> picked up
>> your change moving dw_spi.h out of include/linux/spi (right answer
>> IMHO) and
>> provides the interface they are using now.
>
> So the situation is that certain out-of-tree spi_drivers are reaching into internal details of a specific spi bus driver?
>If so, then that is wrong and bad, and certainly will not be merged. Especially when there are no in tree users and neither
>does this series add any.

OK

Since the current driver used pxa2xx_spi.c as a template I was following the
example provided by include/linux/spi/pxa2xx_spi.h. I have no problem dropping
this patch until I finish the rest of the rework planned. Was trying to limit
the amount of heartburn others on the list had with my changes.

--Dirk
>
> g.
>
>>
>> --Dirk
>