]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
powerpc/mpc5200: Add PSC helpers for bestcomm engine
authorGrant Likely <grant.likely@secretlab.ca>
Wed, 2 Jul 2008 03:38:16 +0000 (21:38 -0600)
committerGrant Likely <grant.likely@secretlab.ca>
Sat, 12 Jul 2008 18:10:53 +0000 (12:10 -0600)
Simplify the interface for setting up bestcomm DMA to PSCs by adding
some helper functions.  The helper function sets the correct values
for the initator and ipr values in PSC DMA tasks based on the PSC
number.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
arch/powerpc/sysdev/bestcomm/gen_bd.c
arch/powerpc/sysdev/bestcomm/gen_bd.h

index 8d33eafbb3f4d5188fc5234cc5645f567effc532..a3a134c35b0ab436f1e54bdf7e41c67f3e4b294e 100644 (file)
@@ -20,6 +20,7 @@
 #include <asm/io.h>
 
 #include <asm/mpc52xx.h>
+#include <asm/mpc52xx_psc.h>
 
 #include "bestcomm.h"
 #include "bestcomm_priv.h"
@@ -253,6 +254,100 @@ bcom_gen_bd_tx_release(struct bcom_task *tsk)
 }
 EXPORT_SYMBOL_GPL(bcom_gen_bd_tx_release);
 
+/* ---------------------------------------------------------------------
+ * PSC support code
+ */
+
+/**
+ * bcom_psc_parameters - Bestcomm initialization value table for PSC devices
+ *
+ * This structure is only used internally.  It is a lookup table for PSC
+ * specific parameters to bestcomm tasks.
+ */
+static struct bcom_psc_params {
+       int rx_initiator;
+       int rx_ipr;
+       int tx_initiator;
+       int tx_ipr;
+} bcom_psc_params[] = {
+       [0] = {
+               .rx_initiator = BCOM_INITIATOR_PSC1_RX,
+               .rx_ipr = BCOM_IPR_PSC1_RX,
+               .tx_initiator = BCOM_INITIATOR_PSC1_TX,
+               .tx_ipr = BCOM_IPR_PSC1_TX,
+       },
+       [1] = {
+               .rx_initiator = BCOM_INITIATOR_PSC2_RX,
+               .rx_ipr = BCOM_IPR_PSC2_RX,
+               .tx_initiator = BCOM_INITIATOR_PSC2_TX,
+               .tx_ipr = BCOM_IPR_PSC2_TX,
+       },
+       [2] = {
+               .rx_initiator = BCOM_INITIATOR_PSC3_RX,
+               .rx_ipr = BCOM_IPR_PSC3_RX,
+               .tx_initiator = BCOM_INITIATOR_PSC3_TX,
+               .tx_ipr = BCOM_IPR_PSC3_TX,
+       },
+       [3] = {
+               .rx_initiator = BCOM_INITIATOR_PSC4_RX,
+               .rx_ipr = BCOM_IPR_PSC4_RX,
+               .tx_initiator = BCOM_INITIATOR_PSC4_TX,
+               .tx_ipr = BCOM_IPR_PSC4_TX,
+       },
+       [4] = {
+               .rx_initiator = BCOM_INITIATOR_PSC5_RX,
+               .rx_ipr = BCOM_IPR_PSC5_RX,
+               .tx_initiator = BCOM_INITIATOR_PSC5_TX,
+               .tx_ipr = BCOM_IPR_PSC5_TX,
+       },
+       [5] = {
+               .rx_initiator = BCOM_INITIATOR_PSC6_RX,
+               .rx_ipr = BCOM_IPR_PSC6_RX,
+               .tx_initiator = BCOM_INITIATOR_PSC6_TX,
+               .tx_ipr = BCOM_IPR_PSC6_TX,
+       },
+};
+
+/**
+ * bcom_psc_gen_bd_rx_init - Allocate a receive bcom_task for a PSC port
+ * @psc_num:   Number of the PSC to allocate a task for
+ * @queue_len: number of buffer descriptors to allocate for the task
+ * @fifo:      physical address of FIFO register
+ * @maxbufsize:        Maximum receive data size in bytes.
+ *
+ * Allocate a bestcomm task structure for receiving data from a PSC.
+ */
+struct bcom_task * bcom_psc_gen_bd_rx_init(unsigned psc_num, int queue_len,
+                                          phys_addr_t fifo, int maxbufsize)
+{
+       if (psc_num >= MPC52xx_PSC_MAXNUM)
+               return NULL;
+
+       return bcom_gen_bd_rx_init(queue_len, fifo,
+                                  bcom_psc_params[psc_num].rx_initiator,
+                                  bcom_psc_params[psc_num].rx_ipr,
+                                  maxbufsize);
+}
+EXPORT_SYMBOL_GPL(bcom_psc_gen_bd_rx_init);
+
+/**
+ * bcom_psc_gen_bd_tx_init - Allocate a transmit bcom_task for a PSC port
+ * @psc_num:   Number of the PSC to allocate a task for
+ * @queue_len: number of buffer descriptors to allocate for the task
+ * @fifo:      physical address of FIFO register
+ *
+ * Allocate a bestcomm task structure for transmitting data to a PSC.
+ */
+struct bcom_task *
+bcom_psc_gen_bd_tx_init(unsigned psc_num, int queue_len, phys_addr_t fifo)
+{
+       struct psc;
+       return bcom_gen_bd_tx_init(queue_len, fifo,
+                                  bcom_psc_params[psc_num].tx_initiator,
+                                  bcom_psc_params[psc_num].tx_ipr);
+}
+EXPORT_SYMBOL_GPL(bcom_psc_gen_bd_tx_init);
+
 
 MODULE_DESCRIPTION("BestComm General Buffer Descriptor tasks driver");
 MODULE_AUTHOR("Jeff Gibbons <jeff.gibbons@appspec.com>");
index 5b6fa803c6aa697729c9aca9d61ae32241718d8e..de47260e69daa6423be73d990f83fa8115baba88 100644 (file)
@@ -44,5 +44,10 @@ extern void
 bcom_gen_bd_tx_release(struct bcom_task *tsk);
 
 
+/* PSC support utility wrappers */
+struct bcom_task * bcom_psc_gen_bd_rx_init(unsigned psc_num, int queue_len,
+                                          phys_addr_t fifo, int maxbufsize);
+struct bcom_task * bcom_psc_gen_bd_tx_init(unsigned psc_num, int queue_len,
+                                          phys_addr_t fifo);
 #endif  /* __BESTCOMM_GEN_BD_H__ */