2 * Bestcomm ATA task driver
5 * Patterned after bestcomm/fec.c by Dale Farnsworth <dfarnsworth@mvista.com>
6 * 2003-2004 (c) MontaVista, Software, Inc.
8 * Copyright (C) 2006-2007 Sylvain Munaut <tnt@246tNt.com>
9 * Copyright (C) 2006 Freescale - John Rigby
11 * This file is licensed under the terms of the GNU General Public License
12 * version 2. This program is licensed "as is" without any warranty of any
13 * kind, whether express or implied.
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/types.h>
22 #include "bestcomm_priv.h"
26 /* ======================================================================== */
27 /* Task image/var/inc */
28 /* ======================================================================== */
31 extern u32 bcom_ata_task[];
33 /* ata task vars that need to be set before enabling the task */
35 u32 enable; /* (u16*) address of task's control register */
36 u32 bd_base; /* (struct bcom_bd*) beginning of ring buffer */
37 u32 bd_last; /* (struct bcom_bd*) end of ring buffer */
38 u32 bd_start; /* (struct bcom_bd*) current bd */
39 u32 buffer_size; /* size of receive buffer */
42 /* ata task incs that need to be set before enabling the task */
53 /* ======================================================================== */
54 /* Task support code */
55 /* ======================================================================== */
58 bcom_ata_init(int queue_len, int maxbufsize)
60 struct bcom_task *tsk;
61 struct bcom_ata_var *var;
62 struct bcom_ata_inc *inc;
64 tsk = bcom_task_alloc(queue_len, sizeof(struct bcom_ata_bd), 0);
68 tsk->flags = BCOM_FLAGS_NONE;
70 bcom_ata_reset_bd(tsk);
72 var = (struct bcom_ata_var *) bcom_task_var(tsk->tasknum);
73 inc = (struct bcom_ata_inc *) bcom_task_inc(tsk->tasknum);
75 if (bcom_load_image(tsk->tasknum, bcom_ata_task)) {
80 var->enable = bcom_eng->regs_base +
81 offsetof(struct mpc52xx_sdma, tcr[tsk->tasknum]);
82 var->bd_base = tsk->bd_pa;
83 var->bd_last = tsk->bd_pa + ((tsk->num_bd-1) * tsk->bd_size);
84 var->bd_start = tsk->bd_pa;
85 var->buffer_size = maxbufsize;
87 /* Configure some stuff */
88 bcom_set_task_pragma(tsk->tasknum, BCOM_ATA_PRAGMA);
89 bcom_set_task_auto_start(tsk->tasknum, tsk->tasknum);
91 out_8(&bcom_eng->regs->ipr[BCOM_INITIATOR_ATA_RX], BCOM_IPR_ATA_RX);
92 out_8(&bcom_eng->regs->ipr[BCOM_INITIATOR_ATA_TX], BCOM_IPR_ATA_TX);
94 out_be32(&bcom_eng->regs->IntPend, 1<<tsk->tasknum); /* Clear ints */
98 EXPORT_SYMBOL_GPL(bcom_ata_init);
100 void bcom_ata_rx_prepare(struct bcom_task *tsk)
102 struct bcom_ata_inc *inc;
104 inc = (struct bcom_ata_inc *) bcom_task_inc(tsk->tasknum);
106 inc->incr_bytes = -(s16)sizeof(u32);
108 inc->incr_dst = sizeof(u32);
110 bcom_set_initiator(tsk->tasknum, BCOM_INITIATOR_ATA_RX);
112 EXPORT_SYMBOL_GPL(bcom_ata_rx_prepare);
114 void bcom_ata_tx_prepare(struct bcom_task *tsk)
116 struct bcom_ata_inc *inc;
118 inc = (struct bcom_ata_inc *) bcom_task_inc(tsk->tasknum);
120 inc->incr_bytes = -(s16)sizeof(u32);
121 inc->incr_src = sizeof(u32);
124 bcom_set_initiator(tsk->tasknum, BCOM_INITIATOR_ATA_TX);
126 EXPORT_SYMBOL_GPL(bcom_ata_tx_prepare);
128 void bcom_ata_reset_bd(struct bcom_task *tsk)
130 struct bcom_ata_var *var;
133 memset(tsk->bd, 0x00, tsk->num_bd * tsk->bd_size);
138 var = (struct bcom_ata_var *) bcom_task_var(tsk->tasknum);
139 var->bd_start = var->bd_base;
141 EXPORT_SYMBOL_GPL(bcom_ata_reset_bd);
143 void bcom_ata_release(struct bcom_task *tsk)
145 /* Nothing special for the ATA tasks */
148 EXPORT_SYMBOL_GPL(bcom_ata_release);
151 MODULE_DESCRIPTION("BestComm ATA task driver");
152 MODULE_AUTHOR("John Rigby");
153 MODULE_LICENSE("GPL v2");