Hi to all,
I have few problems in writing the sound driver,the codec registers are accessed thru SPI,codec(tsc2301) is interfaced to I2S ,and SPI and I2S are in PSC controller(I2S is in PSC0 and SPI to PSC1 in Au1200 MIPS processor).Thru SPI frame the codec registers are accessed.But the hack is I could not access the SPI functions from codec driver(/sound/oss).Let me show the part the coding which I am using in codec
.
tsc2301-spi.c(/drivers/spi/)

u16 tsc2301_read_reg(struct tsc2301 *tsc, int reg)
{ struct spi_transfer t;
struct spi_message m;
u16 data[2] = {0}, cmd;
u16 dataread[2];
cmd = reg;
cmd |= 0x8000;
memset(&t, 0, sizeof(t));
spi_message_init(&m);
m.spi = tsc->spi;
dataread[0] = cmd;
dataread[1] = 0;
t.tx_buf = dataread;
t.rx_buf = &data;
t.len = 4;
spi_message_add_tail(&t, &m);
spi_sync(m.spi, &m);
return data[1];
}

void tsc2301_write_reg(struct tsc2301 *tsc, int reg, u16 val)
{ struct spi_transfer t;
struct spi_message m;
u16 data[2];
/* Now we prepare the command for transferring */
data[0] = reg;
data[1] = val;
spi_message_init(&m);
m.spi = tsc->spi;
memset(&t, 0, sizeof(t));
t.tx_buf = data;
t.rx_buf = NULL;
t.len = 4;
spi_message_add_tail(&t, &m);
spi_sync(m.spi, &m);
}

tsc2301.h(include/linux/spi)

struct tsc2301 {
struct spi_device *spi;
s16 reset_gpio;
u16 config2_shadow;
struct tsc2301_ts *ts;
int (*enable_clock)(struct device *dev);
void (*disable_clock)(struct device *dev);
};

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/sound.h>
#include <linux/slab.h>
#include <linux/soundcard.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/hardirq.h>
#include <linux/sched.h>
#include <linux/device.h>
#include <linux/tsc2301-i2s.h>
#include <linux/spi/tsc2301.h>
#include <linux/spi/spi.h>
#include <linux/init.h>

#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/mach-au1x00/au1xxx.h>
#include <asm/mach-au1x00/au1xxx_psc.h>
#include <asm/mach-au1x00/au1550_spi.h>

#include "au1550_i2s.h"
static void tsc2301_codec_init(struct i2s_hw *hw)
{
struct spi_device *spi;
struct tsc2301 *tsc = dev_get_drvdata(&spi->dev);
//struct tsc2301 *xyz = dev_get_drvdata(&spi->dev);
int a,b;
//b = get_tsc(xyz);
//tsc2301_write_reg(b,TSC2301_REG_PD_MISC,0xFF80);
tsc2301_write_reg(tsc,TSC2301_REG_PD_MISC,0xFF80);
//tsc2301_write_reg(b,TSC2301_REG_AUDCNTL,0x0003);
a = tsc2301_read_reg(tsc,TSC2301_REG_PD_MISC);
printk("power control reg 0x%x\n",a);
//Setup some default mixer settings
hw->set_mixer(hw, SOUND_MIXER_PCM, (54<<|54);
hw->set_mixer(hw, SOUND_MIXER_MIC, (74<<|74);
hw->set_mixer(hw, SOUND_MIXER_LINE, (74<<|74);
/* Activate codec */
//tsc2301_write_reg(b,TSC2301_REG_PD_MISC,0x0040);
}
static struct i2s_hw _i2s = {
.name = "TSC2301 i2s Audio Codec",
.input_mask = SOUND_MASK_LINE | SOUND_MASK_MIC,
.output_mask = SOUND_MASK_PCM,
.codec_init = tsc2301_codec_init,
.set_rates = tsc2301_set_rates,
.get_mixer = tsc2301_read_mixer,
.set_mixer = tsc2301_write_mixer,
.set_recsrc = tsc2301_set_recsrc,
.get_recsrc = tsc2301_get_recsrc,
#ifdef CONFIG_PM
, .power = tsc2301_power,
#endif
};

struct i2s_hw * AMD_PbDb_setup(u32 psc, u32 clock)
{
volatile psc_i2s_t *ip = (volatile psc_i2s_t *)psc;
u32 val;
struct i2s_hw *i2s=&_i2s;

i2s->psc = ip;
ip->psc_ctrl = PSC_CTRL_DISABLE; /* Disable PSC */
au_sync();
/* Codec must be initialized here, after codec_is_master is determined. */
i2s->codec_init(i2s);

ip->psc_sel = (clock | PSC_SEL_PS_I2SMODE);
au_sync();

/* Enable PSC
*/
ip->psc_ctrl = PSC_CTRL_ENABLE;
au_sync();

/* Wait for PSC ready.
*/
do {
val = ip->psc_i2sstat;
printk("inside while %x",val);
au_sync();
} while ((val & PSC_I2SSTAT_SR) == 0);

/* Configure I2S controller.
* Deep FIFO, 16-bit sample, DMA, make sure DMA matches fifo size.
* Actual I2S mode (first bit delayed by one clock).
*/
val = PSC_I2SCFG_RT_FIFO8 | PSC_I2SCFG_TT_FIFO8 | PSC_I2SCFG_BI | PSC_I2SCFG_XM | PSC_I2SCFG_SET_LEN(16);
ip->psc_i2scfg = val | PSC_I2SCFG_DE_ENABLE;
au_sync();

/* Wait for device enabled */
while ((ip->psc_i2sstat & PSC_I2SSTAT_DR) == 0);
return i2s;
}
struct i2s_hw * i2s_hw_init(void)
{
/*
* Already initialized?
*/
if (!request_region(CPHYSADDR(I2S_PSC_BASE),
0x30, AU1XXX_MODULE_NAME)) {
err("I2S Audio ports in use");
return NULL;
}

return(AMD_PbDb_setup(I2S_PSC_BASE, PSC_SEL_CLK_SERCLK));
#endif

}

How could I access the tsc structure is the problem ,If the information provided is not enough I will send you as per you required.

Thanks & Regards
Umamahesh