Re: [PATCH] UCC TDM driver for QE based MPC83xx platforms.

2008-01-24 Thread Timur Tabi

Stephen Rothwell wrote:


+   tdm_ctrl[device_num]-ut_info-uf_info.tdm_tx_clk =
+   (char *) of_get_property(np, fsl,tdm-tx-clk, NULL);

^
We don't normall put spaces here.


Since when?

--
Timur Tabi
Linux kernel developer at Freescale
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] UCC TDM driver for QE based MPC83xx platforms.

2008-01-23 Thread Poonam_Aggrwal-b10812

From: Poonam Agarwal-b10812 [EMAIL PROTECTED]

The UCC TDM driver basically multiplexes and demultiplexes data from
different channels. It can interface with for example SLIC kind of devices
to receive TDM data  demultiplex it and send to upper modules. At the
transmit end it receives data for different channels multiplexes it and
sends them on the TDM channel. It internally uses TSA( Time Slot Assigner)
which does multiplexing and demultiplexing, UCC to perform SDMA between
host buffers and the TSA, CMX to connect TSA to UCC.

It can be used by a kernel module which can call tdm_register_client to
get access to a TDM device.

The driver is right now a misc driver with no subsystem as such.
There can be a platform independent TDM layer which is planned to be
done after this. TDM bus sort of thing.

The dts file keeps a track of the TDM devices present on the board.
Depending on them the TDM driver initializes those many driver instances
while coming up.

The driver on the upper level can plug to more than one tdm clients
depending on the availablity of TDM devices. At every new request of a TDM
client to bind with a TDM device, a free driver instance is allocated to 
the client.

The interface can be described as follows.

tdm_register_client(struct tdm_client *)
This API returns a pointer to the structure tdm_client which is of
type
   struct tdm_client {
u32 client_id;
u32 (*tdm_read)(u32 client_id, short chn_id, short
*pcm_buffer, short len);
u32 (*tdm_write)(u32 client_id, short chn_id, short
*pcm_buffer, short len);
wait_queue_head_t *wakeup_event;
}

It consists of:
   - client_id: It is basically to identify the particular TDM
device/driver instance.
   - tdm_read: It is a function pointer returned by the TDM driver to be
used to read TDM data from a particular TDM channel.
   - tdm_write: It is a function pointer returned by the TDM driver to be
used to write TDM data to a particular TDM channel.
   - wakeup_event: It is address of a wait_queue event on which the client
keeps on sleeping, and the TDM driver wakes it up periodically. The driver 
is configured to
wake up the client after every 10ms.

Once the TDM client gets registered to a TDM driver instance and a TDM
device, it interfaces with the driver using tdm_read, tdm_write and 
wakeup_event.

This driver will run on MPC8323E-RDB platforms.

Signed-off-by: Poonam Aggrwal [EMAIL PROTECTED]
Signed-off-by: Ashish Kalra [EMAIL PROTECTED]
Signed-off-by: Kim Phillips [EMAIL PROTECTED]
Signed-off-by: Michael Barkowski [EMAIL PROTECTED]

---
 drivers/misc/Kconfig   |   14 +
 drivers/misc/Makefile  |1 +
 drivers/misc/ucc_tdm.c | 1000 
 drivers/misc/ucc_tdm.h |  221 +++
 4 files changed, 1236 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/ucc_tdm.c
 create mode 100644 drivers/misc/ucc_tdm.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b5e67c0..628b14b 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -232,4 +232,18 @@ config ATMEL_SSC
 
  If unsure, say N.
 
+config UCC_TDM
+   bool Freescale UCC  TDM Driver
+   depends on QUICC_ENGINE  UCC_FAST
+   default n
+   ---help---
+ The TDM driver is for UCC based TDM devices for example, TDM device on
+ MPC832x RDB. Select it to run PowerVoIP on MPC832x RDB board.
+ The TDM driver can interface with SLIC kind of devices to transmit
+ and receive TDM samples. The TDM driver receives Time Division
+ multiplexed samples(for different channels) from the SLIC device,
+ demutiplexes them and sends them to the upper layers. At the transmit
+ end the TDM drivers receives samples for different channels, it
+ multiplexes them and sends them to the SLIC device.
+
 endif # MISC_DEVICES
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 87f2685..6f0c49d 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o
 obj-$(CONFIG_THINKPAD_ACPI)+= thinkpad_acpi.o
 obj-$(CONFIG_FUJITSU_LAPTOP)   += fujitsu-laptop.o
 obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o
+obj-$(CONFIG_UCC_TDM)  += ucc_tdm.o
diff --git a/drivers/misc/ucc_tdm.c b/drivers/misc/ucc_tdm.c
new file mode 100644
index 000..98e7c72
--- /dev/null
+++ b/drivers/misc/ucc_tdm.c
@@ -0,0 +1,1000 @@
+/*
+ * drivers/misc/ucc_tdm.c
+ *
+ * UCC Based Linux TDM Driver
+ * This driver is designed to support UCC based TDM for PowerPC processors.
+ * This driver can interface with SLIC device to run VOIP kind of
+ * applications.
+ *
+ * Author: Ashish Kalra  Poonam Aggrwal
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free 

Re: [PATCH] UCC TDM driver for QE based MPC83xx platforms.

2008-01-23 Thread Stephen Rothwell
On Thu, 24 Jan 2008 10:16:42 +0530 (IST) Poonam_Aggrwal-b10812 [EMAIL 
PROTECTED] wrote:

 +static int ucc_tdm_probe(struct of_device *ofdev,
 +  const struct of_device_id *match)
 +{
 + struct device_node *np = ofdev-node;
 + struct resource res;
 + const unsigned int *prop;
 + u32 ucc_num, device_num, err, ret = 0;
 + struct device_node *np_tmp = NULL;

You don't need to initialise this.

 + dma_addr_t physaddr;
 + void *tdm_buff;
 + struct ucc_tdm_info *ut_info;
 +
 + prop = of_get_property(np, device-id, NULL);

You should check for (prop == NULL).

 + ucc_num = *prop - 1;
 + if ((ucc_num  0) || (ucc_num  7))
 + return -ENODEV;
 +
 + ut_info = utdm_info[ucc_num];
 + if (ut_info == NULL) {

This cannot be NULL as you have just taken the address of an array
element.

 + tdm_ctrl[device_num]-ut_info = ut_info;
 +
 + tdm_ctrl[device_num]-ut_info-uf_info.ucc_num = ucc_num;
^
This is the same as ut_info.

 + tdm_ctrl[device_num]-ut_info-uf_info.tdm_tx_clk =
 + (char *) of_get_property(np, fsl,tdm-tx-clk, NULL);
^
We don't normall put spaces here.

 + tdm_ctrl[device_num]-ut_info-uf_info.tdm_rx_clk =
 + (char *) of_get_property(np, fsl,tdm-rx-clk, NULL);
^
Ditto. And later as well.

 + tdm_ctrl[device_num]-ut_info-uf_info.irq =
 + irq_of_parse_and_map(np, 0);
 + err = of_address_to_resource(np, 0, res);
 + if (err) {
 + ret = EINVAL;

This should be -EINVAL or err.

 + goto get_property_error;

You need to do something about unmapping the irq in the error path.

 + tdm_ctrl[device_num]-uf_regs = of_iomap(np, 0);
 +
 + np_tmp = of_find_compatible_node(np_tmp, slic, legerity-slic);
 + if (np_tmp != NULL)
 + tdm_ctrl[device_num]-leg_slic = 1;
 + else
 + tdm_ctrl[device_num]-leg_slic = 0;

of_node_ut(np_tmp);

 + tdm_buff = dma_alloc_coherent(NULL, 2 * NR_BUFS * SAMPLE_DEPTH *
 + tdm_ctrl[device_num]-cfg_ctrl.active_num_ts,
 + physaddr, GFP_KERNEL);
 + if (!tdm_buff) {
 + printk(KERN_ERR ucc-tdm: could not allocate buffer
 + descriptors\n);
 + ret = -ENOMEM;
 + goto get_property_error;

You need to unmap the uf_regs in the error path.

 +get_property_error:
 + kfree(tdm_ctrl[device_num]);

Do you need to set tdm_ctrl[device_num] to NULL and decrement
num_tdm_devices?

 + return ret;
 +}
 +
 +static int ucc_tdm_remove(struct of_device *ofdev)
 +{
 + struct tdm_ctrl *tdm_c;
 + struct ucc_tdm_info *ut_info;
 + u32 ucc_num;
 +
 + tdm_c = dev_get_drvdata((ofdev-dev));

dev_set_drvdata(of_dev-dev, NULL);

 + ucc_num = tdm_c-ut_info-uf_info.ucc_num;
 + ut_info = utdm_info[ucc_num];
 + tdm_stop(tdm_c);
 + tdm_deinit(tdm_c);
 +
 + ucc_fast_free(tdm_c-uf_private);
 +
 + dma_free_coherent(NULL, 2 * NR_BUFS * SAMPLE_DEPTH *
 + tdm_c-cfg_ctrl.active_num_ts,
 + tdm_c-tdm_input_data,
 + tdm_c-dma_input_addr);
 +

You need to unmap the uf_reg and the irq.

 +static struct of_device_id ucc_tdm_match[] = {

const, please.

 + {
 +  .type = tdm,
 +  .compatible = fsl,ucc-tdm,
 +  }, {},

We euld normall format this like:

{ .type = tdm, .compatible = fsl,ucc-tdm, },
{},

 +static struct of_platform_driver ucc_tdm_driver = {

.driver = {

 + .name = DRV_NAME,

},

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgpm9arTL3BTU.pgp
Description: PGP signature