projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'locking-arch-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git]
/
drivers
/
spi
/
spi-dw.c
diff --git
a/drivers/spi/spi-dw.c
b/drivers/spi/spi-dw.c
index 0dd0623319b08d708a2e869443618f43436e81aa..72921588525008a0f4eaf615980eb884b8614108 100644
(file)
--- a/
drivers/spi/spi-dw.c
+++ b/
drivers/spi/spi-dw.c
@@
-11,10
+11,6
@@
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
* 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.
*/
#include <linux/dma-mapping.h>
*/
#include <linux/dma-mapping.h>
@@
-59,22
+55,20
@@
struct chip_data {
#ifdef CONFIG_DEBUG_FS
#define SPI_REGS_BUFSIZE 1024
#ifdef CONFIG_DEBUG_FS
#define SPI_REGS_BUFSIZE 1024
-static ssize_t
spi_show_regs(struct file *file, char __user *user_buf,
-
size_t count, loff_t *ppos)
+static ssize_t
dw_
spi_show_regs(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
{
{
- struct dw_spi *dws;
+ struct dw_spi *dws
= file->private_data
;
char *buf;
u32 len = 0;
ssize_t ret;
char *buf;
u32 len = 0;
ssize_t ret;
- dws = file->private_data;
-
buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL);
if (!buf)
return 0;
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL);
if (!buf)
return 0;
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
- "
MRST SPI0 registers:\n"
);
+ "
%s registers:\n", dev_name(&dws->master->dev)
);
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
"=================================\n");
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
"=================================\n");
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
@@
-110,42
+104,41
@@
static ssize_t spi_show_regs(struct file *file, char __user *user_buf,
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
"=================================\n");
len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
"=================================\n");
- ret =
simple_read_from_buffer(user_buf, count, ppos, buf, len);
+ ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
kfree(buf);
return ret;
}
kfree(buf);
return ret;
}
-static const struct file_operations
mrst
_spi_regs_ops = {
+static const struct file_operations
dw
_spi_regs_ops = {
.owner = THIS_MODULE,
.open = simple_open,
.owner = THIS_MODULE,
.open = simple_open,
- .read = spi_show_regs,
+ .read =
dw_
spi_show_regs,
.llseek = default_llseek,
};
.llseek = default_llseek,
};
-static int
mrst
_spi_debugfs_init(struct dw_spi *dws)
+static int
dw
_spi_debugfs_init(struct dw_spi *dws)
{
{
- dws->debugfs = debugfs_create_dir("
mrst
_spi", NULL);
+ dws->debugfs = debugfs_create_dir("
dw
_spi", NULL);
if (!dws->debugfs)
return -ENOMEM;
debugfs_create_file("registers", S_IFREG | S_IRUGO,
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, &
dw
_spi_regs_ops);
return 0;
}
return 0;
}
-static void
mrst
_spi_debugfs_remove(struct dw_spi *dws)
+static void
dw
_spi_debugfs_remove(struct dw_spi *dws)
{
{
- if (dws->debugfs)
- debugfs_remove_recursive(dws->debugfs);
+ debugfs_remove_recursive(dws->debugfs);
}
#else
}
#else
-static inline int
mrst
_spi_debugfs_init(struct dw_spi *dws)
+static inline int
dw
_spi_debugfs_init(struct dw_spi *dws)
{
return 0;
}
{
return 0;
}
-static inline void
mrst
_spi_debugfs_remove(struct dw_spi *dws)
+static inline void
dw
_spi_debugfs_remove(struct dw_spi *dws)
{
}
#endif /* CONFIG_DEBUG_FS */
{
}
#endif /* CONFIG_DEBUG_FS */
@@
-177,7
+170,7
@@
static inline u32 rx_max(struct dw_spi *dws)
{
u32 rx_left = (dws->rx_end - dws->rx) / dws->n_bytes;
{
u32 rx_left = (dws->rx_end - dws->rx) / dws->n_bytes;
- return min
(rx_left, (u32)
dw_readw(dws, DW_SPI_RXFLR));
+ return min
_t(u32, rx_left,
dw_readw(dws, DW_SPI_RXFLR));
}
static void dw_writer(struct dw_spi *dws)
}
static void dw_writer(struct dw_spi *dws)
@@
-228,8
+221,9
@@
static void *next_transfer(struct dw_spi *dws)
struct spi_transfer,
transfer_list);
return RUNNING_STATE;
struct spi_transfer,
transfer_list);
return RUNNING_STATE;
- } else
- return DONE_STATE;
+ }
+
+ return DONE_STATE;
}
/*
}
/*
@@
-396,7
+390,7
@@
static void pump_transfers(unsigned long data)
goto early_exit;
}
goto early_exit;
}
- /* Delay if requested at end of transfer*/
+ /* Delay if requested at end of transfer
*/
if (message->state == RUNNING_STATE) {
previous = list_entry(transfer->transfer_list.prev,
struct spi_transfer,
if (message->state == RUNNING_STATE) {
previous = list_entry(transfer->transfer_list.prev,
struct spi_transfer,
@@
-471,10
+465,12
@@
static void pump_transfers(unsigned long data)
*/
if (!dws->dma_mapped && !chip->poll_mode) {
int templen = dws->len / dws->n_bytes;
*/
if (!dws->dma_mapped && !chip->poll_mode) {
int templen = dws->len / dws->n_bytes;
+
txint_level = dws->fifo_len / 2;
txint_level = (templen > txint_level) ? txint_level : templen;
txint_level = dws->fifo_len / 2;
txint_level = (templen > txint_level) ? txint_level : templen;
- imask |= SPI_INT_TXEI | SPI_INT_TXOI | SPI_INT_RXUI | SPI_INT_RXOI;
+ imask |= SPI_INT_TXEI | SPI_INT_TXOI |
+ SPI_INT_RXUI | SPI_INT_RXOI;
dws->transfer_handler = interrupt_transfer;
}
dws->transfer_handler = interrupt_transfer;
}
@@
-515,7
+511,6
@@
static void pump_transfers(unsigned long data)
early_exit:
giveback(dws);
early_exit:
giveback(dws);
- return;
}
static int dw_spi_transfer_one_message(struct spi_master *master,
}
static int dw_spi_transfer_one_message(struct spi_master *master,
@@
-524,7
+519,7
@@
static int dw_spi_transfer_one_message(struct spi_master *master,
struct dw_spi *dws = spi_master_get_devdata(master);
dws->cur_msg = msg;
struct dw_spi *dws = spi_master_get_devdata(master);
dws->cur_msg = msg;
- /* Initial message state*/
+ /* Initial message state
*/
dws->cur_msg->state = START_STATE;
dws->cur_transfer = list_entry(dws->cur_msg->transfers.next,
struct spi_transfer,
dws->cur_msg->state = START_STATE;
dws->cur_transfer = list_entry(dws->cur_msg->transfers.next,
struct spi_transfer,
@@
-595,6
+590,9
@@
static int dw_spi_setup(struct spi_device *spi)
| (spi->mode << SPI_MODE_OFFSET)
| (chip->tmode << SPI_TMOD_OFFSET);
| (spi->mode << SPI_MODE_OFFSET)
| (chip->tmode << SPI_TMOD_OFFSET);
+ if (spi->mode & SPI_LOOP)
+ chip->cr0 |= 1 << SPI_SRL_OFFSET;
+
if (gpio_is_valid(spi->cs_gpio)) {
ret = gpio_direction_output(spi->cs_gpio,
!(spi->mode & SPI_CS_HIGH));
if (gpio_is_valid(spi->cs_gpio)) {
ret = gpio_direction_output(spi->cs_gpio,
!(spi->mode & SPI_CS_HIGH));
@@
-626,6
+624,7
@@
static void spi_hw_init(struct dw_spi *dws)
*/
if (!dws->fifo_len) {
u32 fifo;
*/
if (!dws->fifo_len) {
u32 fifo;
+
for (fifo = 2; fifo <= 257; fifo++) {
dw_writew(dws, DW_SPI_TXFLTR, fifo);
if (fifo != dw_readw(dws, DW_SPI_TXFLTR))
for (fifo = 2; fifo <= 257; fifo++) {
dw_writew(dws, DW_SPI_TXFLTR, fifo);
if (fifo != dw_readw(dws, DW_SPI_TXFLTR))
@@
-653,8
+652,7
@@
int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
dws->prev_chip = NULL;
dws->dma_inited = 0;
dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60);
dws->prev_chip = NULL;
dws->dma_inited = 0;
dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60);
- snprintf(dws->name, sizeof(dws->name), "dw_spi%d",
- dws->bus_num);
+ snprintf(dws->name, sizeof(dws->name), "dw_spi%d", dws->bus_num);
ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED,
dws->name, dws);
ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED,
dws->name, dws);
@@
-663,7
+661,7
@@
int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
goto err_free_master;
}
goto err_free_master;
}
- master->mode_bits = SPI_CPOL | SPI_CPHA;
+ master->mode_bits = SPI_CPOL | SPI_CPHA
| SPI_LOOP
;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
master->bus_num = dws->bus_num;
master->num_chipselect = dws->num_cs;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
master->bus_num = dws->bus_num;
master->num_chipselect = dws->num_cs;
@@
-692,7
+690,7
@@
int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
goto err_dma_exit;
}
goto err_dma_exit;
}
-
mrst
_spi_debugfs_init(dws);
+
dw
_spi_debugfs_init(dws);
return 0;
err_dma_exit:
return 0;
err_dma_exit:
@@
-709,7
+707,7
@@
void dw_spi_remove_host(struct dw_spi *dws)
{
if (!dws)
return;
{
if (!dws)
return;
-
mrst
_spi_debugfs_remove(dws);
+
dw
_spi_debugfs_remove(dws);
if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws);
if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws);