/** * \brief Initialize and configure the I2S module. * * \param dev_inst Device structure pointer. * \param i2sc Base address of the I2SC instance. * \param cfg Pointer to I2S configuration. * * \return status */ enum status_code i2s_init(struct i2s_dev_inst *const dev_inst, I2sc *i2sc, struct i2s_config *const cfg) { /* Sanity check arguments */ Assert(dev_inst); Assert(i2sc); Assert(cfg); dev_inst->hw_dev = i2sc; dev_inst->cfg = cfg; /* Enable PMC clock for I2SC */ #ifdef ID_I2SC1 if (dev_inst->hw_dev == I2SC1) { sysclk_enable_peripheral_clock(ID_I2SC1); } else #endif #ifdef ID_I2SC0 if (dev_inst->hw_dev == I2SC0) { sysclk_enable_peripheral_clock(ID_I2SC0); } else #endif { Assert(false); } i2s_reset(dev_inst); return _i2s_set_config(dev_inst); }
/* * Initialise the PP I2C and I2S. */ void audiohw_init(void) { #ifdef CPU_PP502x /* normal outputs for CDI and I2S pin groups */ DEV_INIT2 &= ~0x300; /*mini2?*/ DEV_INIT1 &=~0x3000000; /*mini2?*/ /* I2S device reset */ DEV_RS |= DEV_I2S; DEV_RS &=~DEV_I2S; /* I2S device enable */ DEV_EN |= DEV_I2S; /* enable external dev clock clocks */ DEV_EN |= DEV_EXTCLOCKS; /* external dev clock to 24MHz */ outl(inl(0x70000018) & ~0xc, 0x70000018); #else /* device reset */ outl(inl(0xcf005030) | 0x80, 0xcf005030); outl(inl(0xcf005030) & ~0x80, 0xcf005030); /* device enable */ outl(inl(0xcf005000) | 0x80, 0xcf005000); /* GPIO D06 enable for output */ outl(inl(0xcf00000c) | 0x40, 0xcf00000c); outl(inl(0xcf00001c) & ~0x40, 0xcf00001c); #ifdef IPOD_1G2G /* bits 11,10 == 10 */ outl(inl(0xcf004040) & ~0x400, 0xcf004040); outl(inl(0xcf004040) | 0x800, 0xcf004040); #else /* IPOD_3G */ /* bits 11,10 == 01 */ outl(inl(0xcf004040) | 0x400, 0xcf004040); outl(inl(0xcf004040) & ~0x800, 0xcf004040); outl(inl(0xcf004048) & ~0x1, 0xcf004048); outl(inl(0xcf000004) & ~0xf, 0xcf000004); outl(inl(0xcf004044) & ~0xf, 0xcf004044); /* C03 = 0 */ outl(inl(0xcf000008) | 0x8, 0xcf000008); outl(inl(0xcf000018) | 0x8, 0xcf000018); outl(inl(0xcf000028) & ~0x8, 0xcf000028); #endif /* IPOD_1G2G/3G */ #endif /* reset the I2S controller into known state */ i2s_reset(); audiohw_preinit(); }