Subject: RE: I2S driver

From: Angelo <[email-masked]>
Date: Fri, 14 Mar 2008 14:21:18 +0000 (GMT)

Hi Pedro, i'm Angelo.

You just send me this mail:
start mail

As I told you, here is the configuration routine for the I2S module.
Please, notice that this module whas built to work on the old 2.6.16
kernel and old dma driver:

static int I2S_setup(void) {
int i;
//     u32 val32;
// CDM
struct mpc52xx_cdm __iomem *cdm;
//
//     /* GPIO Modification */
struct mpc52xx_gpio __iomem *gpio;

//     /* END GPIO Modification */
//
cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE);
gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE);
//
switch(psc_num) {
case
1:
initiator_tx = SDMA_INITIATOR_PSC1_TX;
initiator_rx = SDMA_INITIATOR_PSC1_RX;
break;
case 2:
initiator_tx = SDMA_INITIATOR_PSC2_TX;
initiator_rx = SDMA_INITIATOR_PSC2_RX;
break;
default:
panic("snd-I2Smgt.o: invalid value for psc_num
(%i)\n",psc_num);
break;
};

/* 528MHz/(0x1f+1)=16.5 MHz */
cdm->mclken_div_psc2 = 0x8001; //
Mhz MCLK ( Khz * )
psc->command = (MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE);
/* PSC2 CODEC with Master Clock */
gpio->port_config |= 0x70;
/* PSC2 clock enable */
cdm->clk_enables |= 0x40;

// PSC reset
psc->command = MPC52xx_PSC_RST_RX;
psc->command = MPC52xx_PSC_RST_TX;
psc->command = MPC52xx_PSC_SEL_MODE_REG_1;
psc->command = MPC52xx_PSC_RST_ERR_STAT;

// PSC setup I2S
psc->mode = 0;
psc->rfalarm = RX_ALARM;
psc->tfalarm = TX_ALARM;
psc->rfcntl = RX_GRAN;
psc->tfcntl = TX_GRAN;
psc->mpc52xx_psc_imr =
0x0000;

psc->sicr = 0x0FE00000;
psc->ctur = 0x1f; //Frame length 0x17

psc->ccr = 0x3f5D; //LRCK  KHz, BitCLK  MHz  0x3f05!

//     psc->sicr |= /* DELAY_TIME_SLOT |*/ MULTIWD_ENABLE | CLK_POL_RISING;
//
//     psc->sicr |= GEN_CLK_INT;

psc->command = MPC52xx_PSC_RST_RX;
psc->command = MPC52xx_PSC_RST_TX;
psc->command = MPC52xx_PSC_SEL_MODE_REG_1;
psc->command = MPC52xx_PSC_RST_ERR_STAT;
//
//     // setup the sdma tasks
tx_sdma = sdma_alloc(PERIODS_HW+1);
rx_sdma = sdma_alloc(PERIODS_HW+1);

if (!tx_sdma || !rx_sdma) {
printk("sdma_alloc
failed\n");
return -ENOMEM;
}
//
//     sdma_gen_bd_rx_init(rx_sdma, (phys_addr_t)&(psc->rfdata),
PERIODSIZE_HW, initiator_rx, 6);
sdma_gen_bd_rx_init(0, rx_sdma, (phys_addr_t)&(psc->rfdata),
initiator_rx, 6, PERIODSIZE_HW);
//     sdma_gen_bd_tx_init(tx_sdma, (phys_addr_t)&(psc->tfdata),
PERIODSIZE_HW, initiator_tx, 6);
sdma_gen_bd_tx_init(0, tx_sdma, (phys_addr_t)&(psc->tfdata),
initiator_tx, 6);

printk("txtask is %d rxtask is %d\n", tx_sdma->tasknum,
rx_sdma->tasknum);
//
// prepare the ring buffers
for(i=0;itasknum %d\n", sdma_irq(rx_sdma), MPC52xx_SDMA_IRQ_BASE +
rx_sdma->tasknum);
if (request_irq(sdma_irq(rx_sdma), I2S_rx_irq, 0, "SPI rx dma",
NULL))
{
printk(KERN_ERR "SPI: SDMA rx irq allocation failed\n");
return -EINVAL;
} else printk("SPI: SDA rx irq allocation succeded\n");
if (request_irq(sdma_irq(tx_sdma), I2S_tx_irq, 0, "SPI tx dma",
NULL)) {
printk(KERN_ERR "SPI: SDMA tx irq allocation failed\n");
return -EINVAL;
} else printk("SPI: SDA tx irq allocation succeded\n");

//
//     // clear any pending interrupts
sdma_clear_irq(tx_sdma);
sdma_clear_irq(rx_sdma);
//
printk("Before activating the tasks\n");
//     // activate the tasks
//     sdma_enable(tx_sdma);
//     sdma_enable(rx_sdma);
//

//     printk("about to enable SPI psc\n");
udelay(100);
//
//     // enable transmitter and receiver
psc->command = MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE;
// //    psc->command = MPC52xx_PSC_TX_ENABLE;
//
//
// //     I2S_print(__FUNCTION__);
//
// //     pcm1680_read();
// //         pcm1680_configure(44100);
// //     pcm1680_read();

return 0;
};
end mail

I solved my proplems of porting from 2.6.17 to 2.16.22 kernel
version, but in the module static int I2S_setup(void) i found
the sequent problems.

In this piece of code:

switch(psc_num) {
case 1:
initiator_tx =
SDMA_INITIATOR_PSC1_TX;
initiator_rx = SDMA_INITIATOR_PSC1_RX;
break;
case 2:
initiator_tx = SDMA_INITIATOR_PSC2_TX;
initiator_rx = SDMA_INITIATOR_PSC2_RX;
break;
default:
panic("snd-I2Smgt.o: invalid value for psc_num
(%i)\n",psc_num);
break;
};

This define are undeclared:
SDMA_INITIATOR_PSC1_TX
SDMA_INITIATOR_PSC1_RX
SDMA_INITIATOR_PSC2_TX
SDMA_INITIATOR_PSC2_RX

so perhaps i don't have some header
files.

Also this variable are undefined:
psc_num, tx_sdma, rx_sdma.

And where i can found this function:
- sdma_gen_bd_rx_init
- sdma_gen_bd_tx_init

However there are some other errors like:
//
// prepare the ring buffers
for(i=0;itasknum %d\n", sdma_irq(rx_sdma), MPC52xx_SDMA_IRQ_BASE +
rx_sdma->tasknum);
if (request_irq(sdma_irq(rx_sdma), I2S_rx_irq, 0, "SPI rx dma", NULL))
{
.....
I think there are some mistakes in your copy and paste operation, so
i don't know how solve it.

Thanks for help.

Inviato da Yahoo! Mail.

Il servizio di posta con lo spazio illimitato.