aboutsummaryrefslogtreecommitdiffstats
path: root/meta-steppeeagle/recipes-kernel
diff options
context:
space:
mode:
Diffstat (limited to 'meta-steppeeagle/recipes-kernel')
-rw-r--r--meta-steppeeagle/recipes-kernel/amd-spi/amd-spi_1.0.bb6
-rw-r--r--meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.c51
-rw-r--r--meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.h2
-rw-r--r--meta-steppeeagle/recipes-kernel/amd-spi/files/spirom.h10
4 files changed, 31 insertions, 38 deletions
diff --git a/meta-steppeeagle/recipes-kernel/amd-spi/amd-spi_1.0.bb b/meta-steppeeagle/recipes-kernel/amd-spi/amd-spi_1.0.bb
index f4304d4d..608b99c6 100644
--- a/meta-steppeeagle/recipes-kernel/amd-spi/amd-spi_1.0.bb
+++ b/meta-steppeeagle/recipes-kernel/amd-spi/amd-spi_1.0.bb
@@ -1,9 +1,9 @@
DESCRIPTION = "This kernel module provides support for AMD SPI controller driver"
LICENSE = "BSD | GPLv2"
-LIC_FILES_CHKSUM = "file://spi_amd.c;md5=3cbc6410f1e2b6009f1a74731f6fc557 \
- file://spi_amd.h;md5=2233c2a926f120b07153e3ea0ba7474f \
+LIC_FILES_CHKSUM = "file://spi_amd.c;md5=053ef6a02a8242fbb536a45df556c7a7 \
+ file://spi_amd.h;md5=b73106fb4d18369d420b9de1d1406b3a \
file://spirom.c;md5=1f5bba5ab39fb0759286aab09b55bc84 \
- file://spirom.h;md5=56f117ed31b82b02182c7a491364d112 \
+ file://spirom.h;md5=8de0c535224dbd8ecd2f40ef29c15d0a \
file://Makefile;md5=8ea80a6d4ae15bcf922d090df6cfdd4c \
"
diff --git a/meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.c b/meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.c
index 554bd352..52e1b1a5 100644
--- a/meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.c
+++ b/meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.c
@@ -45,9 +45,9 @@ struct amd_spi {
u32 rom_addr;
struct spi_master *master;
struct amd_platform_data controller_data;
- spinlock_t lock;
struct task_struct *kthread_spi;
struct list_head msg_queue;
+ wait_queue_head_t wq;
};
static struct pci_device_id amd_spi_pci_device_id[] = {
@@ -149,7 +149,9 @@ static void amd_spi_execute_opcode(struct spi_master *master)
spi_busy = (ioread32((u8 *)amd_spi->io_remap_addr +
AMD_SPI_CTRL0_REG) & AMD_SPI_BUSY) == AMD_SPI_BUSY;
while (spi_busy) {
+ set_current_state(TASK_INTERRUPTIBLE);
schedule();
+ set_current_state(TASK_RUNNING);
spi_busy = (ioread32((u8 *)amd_spi->io_remap_addr +
AMD_SPI_CTRL0_REG) & AMD_SPI_BUSY) == AMD_SPI_BUSY;
}
@@ -193,29 +195,17 @@ static int amd_spi_master_setup(struct spi_device *spi)
return 0;
}
-static int amd_spi_master_transfer(struct spi_device *spi,
+static int amd_spi_master_transfer(struct spi_master *master,
struct spi_message *msg)
{
- struct spi_master *master = spi->master;
struct amd_spi *amd_spi = spi_master_get_devdata(master);
/*
- * We will just add this message to the message queue set up by
- * the controller, and let the kernel thread handle it later.
- */
- msg->status = -EINPROGRESS;
- msg->actual_length = 0;
- msg->spi = spi;
- /*
- * There could be a situation when we are running on this processor
- * and trying to add element to the end of the message queue, but
- * at the same time the kernel thread is running on another processor
- * and trying to find out if the list is empty or not. So protect
- * against such contention. Simple spin_lock() should do.
+ * Add new message to the queue and let the kernel thread know
+ * about it.
*/
- spin_lock(&amd_spi->lock);
list_add_tail(&msg->queue, &amd_spi->msg_queue);
- spin_unlock(&amd_spi->lock);
+ wake_up_interruptible(&amd_spi->wq);
return 0;
}
@@ -241,25 +231,19 @@ static int amd_spi_thread(void *t)
* 64-bytes of data and 3-bytes of address.
*/
while (1) {
- /* break condition */
+ /*
+ * Let us wait on a wait queue till the message queue is empty.
+ */
+ wait_event_interruptible(amd_spi->wq,
+ !list_empty(&amd_spi->msg_queue));
+
+ /* stop condition */
if (kthread_should_stop()) {
set_current_state(TASK_RUNNING);
break;
}
/*
- * If the message queue is empty, then there is no need to waste
- * CPU cycles. So we let other processes execute, and continue
- * from the beginning of the loop when we next get to run.
- */
- spin_lock(&amd_spi->lock);
- if (list_empty(&amd_spi->msg_queue)) {
- spin_unlock(&amd_spi->lock);
- schedule();
- continue;
- }
-
- /*
* Else, pull the very first message from the queue and process
* all transfers within that message. And process the messages
* in a pure linear fashion. We also remove the spi_message
@@ -268,7 +252,6 @@ static int amd_spi_thread(void *t)
message = list_entry(amd_spi->msg_queue.next,
struct spi_message, queue);
list_del_init(&message->queue);
- spin_unlock(&amd_spi->lock);
/* We store the CS# line to be used for this spi_message */
amd_spi->controller_data.chip_select =
@@ -372,7 +355,7 @@ static int amd_spi_thread(void *t)
message->actual_length = tx_len + rx_len + 1 ;
/* complete the transaction */
message->status = 0;
- message->complete(message->context);
+ spi_finalize_current_message(master);
}
return 0;
@@ -416,8 +399,8 @@ static int amd_spi_pci_probe(struct pci_dev *pdev,
}
dev_dbg(dev, "io_base_addr: 0x%.8lx, io_remap_address: %p\n",
amd_spi->io_base_addr, amd_spi->io_remap_addr);
- spin_lock_init(&amd_spi->lock);
INIT_LIST_HEAD(&amd_spi->msg_queue);
+ init_waitqueue_head(&amd_spi->wq);
amd_spi->kthread_spi = kthread_run(amd_spi_thread, amd_spi,
"amd_spi_thread");
@@ -430,7 +413,7 @@ static int amd_spi_pci_probe(struct pci_dev *pdev,
master->mode_bits = 0;
master->flags = 0;
master->setup = amd_spi_master_setup;
- master->transfer = amd_spi_master_transfer;
+ master->transfer_one_message = amd_spi_master_transfer;
/* Register the controller with SPI framework */
err = spi_register_master(master);
if (err) {
diff --git a/meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.h b/meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.h
index ea5181d7..21fa972f 100644
--- a/meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.h
+++ b/meta-steppeeagle/recipes-kernel/amd-spi/files/spi_amd.h
@@ -2,7 +2,7 @@
#define SPI_AMD_H
#define DRIVER_NAME "spi_amd"
-#define SPI_VERSION "0.1"
+#define SPI_VERSION "1.0"
#define AMD_SPI_CTRL0_REG 0x00
#define AMD_SPI_EXEC_CMD (0x1 << 16)
diff --git a/meta-steppeeagle/recipes-kernel/amd-spi/files/spirom.h b/meta-steppeeagle/recipes-kernel/amd-spi/files/spirom.h
index 750719a6..941b357a 100644
--- a/meta-steppeeagle/recipes-kernel/amd-spi/files/spirom.h
+++ b/meta-steppeeagle/recipes-kernel/amd-spi/files/spirom.h
@@ -39,5 +39,15 @@ struct spi_ioc_transfer {
? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
#define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)])
+/* SPI ROM command codes */
+#define ROM_WREN 0x06
+#define ROM_WRDI 0x04
+#define ROM_RDSR 0x05
+#define ROM_RDID 0x9F
+#define ROM_CHIP_ERASE 0x60
+#define ROM_SECTOR_ERASE 0x20
+#define ROM_BLOCK_ERASE 0xD8
+#define ROM_READ 0x03
+#define ROM_WRITE 0x02
#endif /* SPIROM_H */