static void par_close(PROGRAMMER * pgm) { /* * Restore pin values before closing, * but ensure that buffers are turned off. */ ppi_setall(&pgm->fd, PPIDATA, pgm->ppidata); ppi_setall(&pgm->fd, PPICTRL, pgm->ppictrl); par_setmany(pgm, pgm->pinno[PPI_AVR_BUFF], 1); /* * Handle exit specs. */ switch (pgm->exit_reset) { case EXIT_RESET_ENABLED: par_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0); break; case EXIT_RESET_DISABLED: par_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 1); break; case EXIT_RESET_UNSPEC: /* Leave it alone. */ break; } switch (pgm->exit_datahigh) { case EXIT_DATAHIGH_ENABLED: ppi_setall(&pgm->fd, PPIDATA, 0xff); break; case EXIT_DATAHIGH_DISABLED: ppi_setall(&pgm->fd, PPIDATA, 0x00); break; case EXIT_DATAHIGH_UNSPEC: /* Leave it alone. */ break; } switch (pgm->exit_vcc) { case EXIT_VCC_ENABLED: par_setmany(pgm, pgm->pinno[PPI_AVR_VCC], 1); break; case EXIT_VCC_DISABLED: par_setmany(pgm, pgm->pinno[PPI_AVR_VCC], 0); break; case EXIT_VCC_UNSPEC: /* Leave it alone. */ break; } ppi_close(&pgm->fd); pgm->fd.ifd = -1; }
static int __init ppi_adc_init(void) { int ret; ret = dma_init(); if(ret) { return ret; } ret = ppi_init(); if(ret) { dma_close(); return ret; } ret = device_init(); if(ret) { ppi_close(); dma_close(); return ret; } /* Disable everything */ disable_dma(CH_PPI); bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() & (~PORT_EN)); SSYNC(); return 0; }
static void __exit ppi_adc_close(void) { device_close(); ppi_close(); dma_close(); }