int misc_init_r(void) { struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "can")) { clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN1_TDM | MPC85xx_PMUXCR_CAN1_UART | MPC85xx_PMUXCR_CAN2_TDM | MPC85xx_PMUXCR_CAN2_UART); out_8(&cpld_data->tdm_can_sel, MUX_CPLD_CAN_UART); } else if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "tdm")) { clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN2_UART | MPC85xx_PMUXCR_CAN1_UART); setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN2_TDM | MPC85xx_PMUXCR_CAN1_TDM); clrbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_GPIO); setbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_TDM); out_8(&cpld_data->tdm_can_sel, MUX_CPLD_TDM); out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_SLIC); } else { /* defaultly spi_cs_sel to flash */ out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_FLASH); } return 0; }
void dtimer_intr_setup(void) { int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE); out_8(&intp->icr0[CONFIG_SYS_TMRINTR_NO], CONFIG_SYS_TMRINTR_PRI); clrbits_be32(&intp->imrl0, 0x00000001); clrbits_be32(&intp->imrl0, CONFIG_SYS_TMRINTR_MASK); }
void board_gpio_init(void) { #ifdef CONFIG_QE ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); par_io_t *par_io = (par_io_t *) &(gur->qe_par_io); #if defined(CONFIG_TARGET_P1021RDB) && !defined(CONFIG_SYS_RAMBOOT) /* reset DDR3 */ setbits_be32(&par_io[GPIO_DDR_RST_PORT].cpdat, GPIO_DDR_RST_DATA); udelay(1000); clrbits_be32(&par_io[GPIO_DDR_RST_PORT].cpdat, GPIO_DDR_RST_DATA); udelay(1000); setbits_be32(&par_io[GPIO_DDR_RST_PORT].cpdat, GPIO_DDR_RST_DATA); /* disable CE_PB8 */ clrbits_be32(&par_io[GPIO_DDR_RST_PORT].cpdir1, GPIO_2BIT_MASK); #endif /* Enable VSC7385 switch */ setbits_be32(&par_io[GPIO_GETH_SW_PORT].cpdat, GPIO_GETH_SW_DATA); /* Enable SLIC */ setbits_be32(&par_io[GPIO_SLIC_PORT].cpdat, GPIO_SLIC_DATA); #else ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR); /* * GPIO10 DDR Reset, open drain * GPIO7 LOAD_DEFAULT_N Input * GPIO11 WDI (watchdog input) * GPIO12 Ethernet Switch Reset * GPIO13 SLIC Reset */ setbits_be32(&pgpio->gpdir, 0x02130000); #if !defined(CONFIG_SYS_RAMBOOT) && !defined(CONFIG_SPL) /* init DDR3 reset signal */ setbits_be32(&pgpio->gpdir, 0x00200000); setbits_be32(&pgpio->gpodr, 0x00200000); clrbits_be32(&pgpio->gpdat, 0x00200000); udelay(1000); setbits_be32(&pgpio->gpdat, 0x00200000); udelay(1000); clrbits_be32(&pgpio->gpdir, 0x00200000); #endif #ifdef CONFIG_VSC7385_ENET /* reset VSC7385 Switch */ setbits_be32(&pgpio->gpdir, 0x00080000); setbits_be32(&pgpio->gpdat, 0x00080000); #endif #ifdef CONFIG_SLIC /* reset SLIC */ setbits_be32(&pgpio->gpdir, 0x00040000); setbits_be32(&pgpio->gpdat, 0x00040000); #endif #endif }
static void setports(int gpio) { ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); if (gpio) { clrbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); clrbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); } else { setbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); clrbits_be32(&iop->pdir, (SDA_MASK | SCL_MASK)); setbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); } }
int board_early_init_f(void) { ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); setbits_be32(&gur->pmuxcr, (MPC85xx_PMUXCR_SDHC_CD | MPC85xx_PMUXCR_SDHC_WP)); clrbits_be32(&gur->sdhcdcr, SDHCDCR_CD_INV); clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_SD_DATA); setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TDM_ENA); board_gpio_init(); board_cpld_init(); return 0; }
int board_early_init_f(void) { struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR; #ifdef CONFIG_TSEC_ENET /* clear BD & FR bits for BE BD's and frame data */ clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR); out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125); #endif #ifdef CONFIG_FSL_IFC init_early_memctl_regs(); #endif arch_soc_init(); #if defined(CONFIG_DEEP_SLEEP) if (is_warm_boot()) { timer_init(); dram_init(); } #endif return 0; }
/* Input: <dev_addr> I2C address of EEPROM device to enable. * <state> -1: deliver current state * 0: disable write * 1: enable write * Returns: -1: wrong device address * 0: dis-/en- able done * 0/1: current state if <state> was -1. */ int eeprom_write_enable(unsigned dev_addr, int state) { struct ppc4xx_gpio *gpio0 = (struct ppc4xx_gpio *)GPIO_BASE; if (CONFIG_SYS_I2C_EEPROM_ADDR != dev_addr) { return -1; } else { switch (state) { case 1: /* Enable write access, clear bit GPIO0. */ clrbits_be32(&gpio0->or, CONFIG_SYS_GPIO_EEPROM_WP); state = 0; break; case 0: /* Disable write access, set bit GPIO0. */ setbits_be32(&gpio0->or, CONFIG_SYS_GPIO_EEPROM_WP); state = 0; break; default: /* Read current status back. */ state = (0 == (in_be32(&gpio0->or) & CONFIG_SYS_GPIO_EEPROM_WP)); break; } } return state; }
static void fsl_upm_end_pattern(struct fsl_upm *upm) { clrbits_be32(upm->mxmr, MxMR_OP_RUNP); while (in_be32(upm->mxmr) & MxMR_OP_RUNP) eieio(); }
/* * CPM interrupt handler */ static void cpm_interrupt(void *regs) { immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR; uint vec; /* * Get the vector by setting the ACK bit * and then reading the register. */ out_be16(&immr->im_cpic.cpic_civr, 1); vec = in_be16(&immr->im_cpic.cpic_civr); vec >>= 11; if (cpm_vecs[vec].handler != NULL) { (*cpm_vecs[vec].handler) (cpm_vecs[vec].arg); } else { clrbits_be32(&immr->im_cpic.cpic_cimr, 1 << vec); printf("Masking bogus CPM interrupt vector 0x%x\n", vec); } /* * After servicing the interrupt, * we have to remove the status indicator. */ setbits_be32(&immr->im_cpic.cpic_cisr, 1 << vec); }
int misc_init_r(void) { int i; struct ppc4xx_gpio *gpio0 = (struct ppc4xx_gpio *)GPIO_BASE; struct pmc405de_cpld *cpld = (struct pmc405de_cpld *)CONFIG_SYS_CPLD_BASE; if (!is_monarch()) { /* PCI configuration done: release EREADY */ setbits_be32(&gpio0->or, CONFIG_SYS_GPIO_EREADY); setbits_be32(&gpio0->tcr, CONFIG_SYS_GPIO_EREADY); } /* turn off POST LED */ out_8(&cpld->control, CPLD_CONTROL_POSTLED_N | CPLD_CONTROL_POSTLED_GATE); /* turn on LEDs: RUN, A, B */ clrbits_be32(&gpio0->or, CONFIG_SYS_GPIO_LEDRUN_N | CONFIG_SYS_GPIO_LEDA_N | CONFIG_SYS_GPIO_LEDB_N); for (i=0; i < 200; i++) udelay(1000); /* turn off LEDs: A, B */ setbits_be32(&gpio0->or, CONFIG_SYS_GPIO_LEDA_N | CONFIG_SYS_GPIO_LEDB_N); return (0); }
void spi_cs_activate(struct spi_slave *slave) { immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; /* active low */ clrbits_be32(&immr->gpio[0].dat, SPI_CS_MASK); }
void cfspi_release_bus(uint bus, uint cs) { dspi_t *dspi = (dspi_t *) MMAP_DSPI; gpio_t *gpio = (gpio_t *) MMAP_GPIO; /* Clear FIFO */ clrbits_be32(&dspi->mcr, DSPI_MCR_CTXF | DSPI_MCR_CRXF); #ifdef CONFIG_MCF5445x switch (cs) { case 0: clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0); break; case 1: clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1); break; case 2: clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2); break; case 3: clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK); break; case 5: clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5); break; } #endif #ifdef CONFIG_MCF5441x if (cs == 1) clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1); #endif }
void dtimer_intr_setup(void) { intctrl_t *intp = (intctrl_t *) (CONFIG_SYS_INTR_BASE); clrbits_be32(&intp->int_icr1, INT_ICR1_TMR3MASK); setbits_be32(&intp->int_icr1, CONFIG_SYS_TMRINTR_PRI); }
static int get_pin(unsigned long mask, int port) { ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, port); clrbits_be32(&iop->pdir, mask); return 0 != (in_be32(&iop->pdat) & mask); }
static void phy_change(struct eth_device *dev) { uec_private_t *uec = (uec_private_t *)dev->priv; #if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025) ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); /* QE9 and QE12 need to be set for enabling QE MII managment signals */ setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE9); setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12); #endif /* Update the link, speed, duplex */ uec->mii_info->phyinfo->read_status(uec->mii_info); #if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025) /* * QE12 is muxed with LBCTL, it needs to be released for enabling * LBCTL signal for LBC usage. */ clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12); #endif /* Adjust the interface according to speed */ adjust_link(dev); }
void irq_free_handler(int vec) { immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR; if ((vec & CPMVEC_OFFSET) != 0) { /* CPM interrupt */ vec &= 0xffff; clrbits_be32(&immr->im_cpic.cpic_cimr, 1 << vec); cpm_vecs[vec].handler = NULL; cpm_vecs[vec].arg = NULL; } else { /* SIU interrupt */ clrbits_be32(&immr->im_siu_conf.sc_simask, 1 << (31 - vec)); irq_vecs[vec].handler = NULL; irq_vecs[vec].arg = NULL; } }
/* Stop the interface */ static void tsec_halt(struct eth_device *dev) { struct tsec_private *priv = (struct tsec_private *)dev->priv; tsec_t *regs = priv->regs; clrbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS); setbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS); while ((in_be32(®s->ievent) & (IEVENT_GRSC | IEVENT_GTSC)) != (IEVENT_GRSC | IEVENT_GTSC)) ; clrbits_be32(®s->maccfg1, MACCFG1_TX_EN | MACCFG1_RX_EN); /* Shut down the PHY, as needed */ phy_shutdown(priv->phydev); }
/* * Initialize device structure. Returns success if * initialization succeeded. */ static int gfar_probe(struct device_d *dev) { struct gfar_info_struct *gfar_info = dev->platform_data; struct eth_device *edev; struct gfar_private *priv; size_t size; char *p; priv = xzalloc(sizeof(struct gfar_private)); if (NULL == priv) return -ENODEV; edev = &priv->edev; priv->regs = dev_request_mem_region(dev, 0); priv->phyregs = dev_request_mem_region(dev, 1); priv->phyregs_sgmii = dev_request_mem_region(dev, 2); priv->phyaddr = gfar_info->phyaddr; priv->tbicr = gfar_info->tbicr; priv->tbiana = gfar_info->tbiana; /* * Allocate descriptors 64-bit aligned. Descriptors * are 8 bytes in size. */ size = ((TX_BUF_CNT * sizeof(struct txbd8)) + (RX_BUF_CNT * sizeof(struct rxbd8))) + BUF_ALIGN; p = (char *)xmemalign(BUF_ALIGN, size); priv->txbd = (struct txbd8 *)p; priv->rxbd = (struct rxbd8 *)(p + (TX_BUF_CNT * sizeof(struct txbd8))); edev->priv = priv; edev->init = gfar_init; edev->open = gfar_open; edev->halt = gfar_halt; edev->send = gfar_send; edev->recv = gfar_recv; edev->get_ethaddr = gfar_get_ethaddr; edev->set_ethaddr = gfar_set_ethaddr; edev->parent = dev; setbits_be32(priv->regs + GFAR_MACCFG1_OFFSET, GFAR_MACCFG1_SOFT_RESET); udelay(2); clrbits_be32(priv->regs + GFAR_MACCFG1_OFFSET, GFAR_MACCFG1_SOFT_RESET); priv->miibus.read = gfar_miiphy_read; priv->miibus.write = gfar_miiphy_write; priv->miibus.priv = priv; priv->miibus.parent = dev; gfar_init_phy(edev); mdiobus_register(&priv->miibus); return eth_register(edev); }
static void fmc_tx_port_graceful_stop_disable(struct fm_eth *fm_eth) { struct fm_port_global_pram *pram; pram = fm_eth->tx_pram; /* re-enable transmission of frames */ clrbits_be32(&pram->mode, PRAM_MODE_GRACEFUL_STOP); sync(); }
static int bcm6345_reset_assert(struct reset_ctl *rst) { struct bcm6345_reset_priv *priv = dev_get_priv(rst->dev); clrbits_be32(priv->regs, BIT(rst->id)); mdelay(20); return 0; }
static void gpio_selectrow(gpio512x_t *gpioregs, u32 row) { if (row) setbits_be32(&gpioregs->gpdat, GPIOKEY_ROW_BITMASK); else clrbits_be32(&gpioregs->gpdat, GPIOKEY_ROW_BITMASK); udelay(10); }
int board_early_init_f(void) { ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR; clrbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_CTS_B0_GPIO42); setbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_CTS_B0_DSP_TMS); clrbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_RTS_B0_GPIO43); setbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_RTS_B0_DSP_TCK | MPC85xx_PMUXCR2_UART_CTS_B1_SIM_PD); setbits_be32(&gur->halt_req_mask, HALTED_TO_HALT_REQ_MASK_0); clrsetbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_IFC_AD_GPIO_MASK | MPC85xx_PMUXCR_IFC_AD17_GPO_MASK, MPC85xx_PMUXCR_IFC_AD_GPIO | MPC85xx_PMUXCR_IFC_AD17_GPO | MPC85xx_PMUXCR_SDHC_USIM); return 0; }
int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { /* Everything after the first generation of PQ3 parts has RSTCR */ #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ defined(CONFIG_MPC8555) || defined(CONFIG_MPC8560) unsigned long val, msr; /* * Initiate hard reset in debug control register DBCR0 * Make sure MSR[DE] = 1. This only resets the core. */ msr = mfmsr (); msr |= MSR_DE; mtmsr (msr); val = mfspr(DBCR0); val |= 0x70000000; mtspr(DBCR0,val); #else #if 0 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); /* Attempt board-specific reset */ board_reset(); /* Next try asserting HRESET_REQ */ out_be32(&gur->rstcr, 0x2); udelay(100); #endif /* add by tianzhy 2015-06-24 */ ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR); clrbits_be32(&pgpio->gpdat, 0x10000000); /* cancel long set */ clrbits_be32(&pgpio->gpdir, 0x40000000); /* cancel long set */ /* cancel wdi */ for(;;); #endif return 1; }
static int bcm6345_gpio_set_direction(void __iomem *dirout, unsigned offset, bool input) { if (input) clrbits_be32(dirout, BIT(offset)); else setbits_be32(dirout, BIT(offset)); return 0; }
static void bmi_rx_port_disable(struct fm_bmi_rx_port *rx_port) { int timeout = 1000000; clrbits_be32(&rx_port->fmbm_rcfg, FMBM_RCFG_EN); /* wait until the rx port is not busy */ while ((in_be32(&rx_port->fmbm_rst) & FMBM_RST_BSY) && timeout--) ; }
static void bmi_tx_port_disable(struct fm_bmi_tx_port *tx_port) { int timeout = 1000000; clrbits_be32(&tx_port->fmbm_tcfg, FMBM_TCFG_EN); /* wait until the tx port is not busy */ while ((in_be32(&tx_port->fmbm_tst) & FMBM_TST_BSY) && timeout--) ; }
static void set_pin(int state, unsigned long mask, int port) { ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, port); if (state) setbits_be32(&iop->pdat, mask); else clrbits_be32(&iop->pdat, mask); setbits_be32(&iop->pdir, mask); }
int fpga_wr_fn(int assert_write, int flush, int cookie) { struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO; if (assert_write) setbits_be32(&gpio->simple_dvo, FPGA_DIN); else clrbits_be32(&gpio->simple_dvo, FPGA_DIN); return assert_write; }
int fpga_clk_fn(int assert_clk, int flush, int cookie) { struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO; if (assert_clk) setbits_be32(&gpio->simple_dvo, FPGA_CCLK); else clrbits_be32(&gpio->simple_dvo, FPGA_CCLK); return assert_clk; }
int board_early_init_f(void) { struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR; struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR; unsigned int major; #ifdef CONFIG_TSEC_ENET /* clear BD & FR bits for BE BD's and frame data */ clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR); out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125); #endif #ifdef CONFIG_FSL_IFC init_early_memctl_regs(); #endif #ifdef CONFIG_FSL_DCU_FB out_be32(&scfg->pixclkcr, SCFG_PIXCLKCR_PXCKEN); #endif #ifdef CONFIG_FSL_QSPI out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL); #endif /* Configure Little endian for SAI, ASRC and SPDIF */ out_be32(&scfg->endiancr, SCFG_ENDIANCR_LE); /* * Enable snoop requests and DVM message requests for * Slave insterface S4 (A7 core cluster) */ out_le32(&cci->slave[4].snoop_ctrl, CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN); major = get_soc_major_rev(); if (major == SOC_MAJOR_VER_1_0) { /* * Set CCI-400 Slave interface S1, S2 Shareable Override * Register All transactions are treated as non-shareable */ out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE); out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE); } #if defined(CONFIG_DEEP_SLEEP) if (is_warm_boot()) { timer_init(); dram_init(); } #endif return 0; }