static int ifxmips_pci_config_access(unsigned char access_type, struct pci_bus *bus, unsigned int devfn, unsigned int where, u32 *data) { unsigned long cfg_base; unsigned long flags; u32 temp; /* IFXMips support slot from 0 to 15 */ /* dev_fn 0&0x68 (AD29) is ifxmips itself */ if ((bus->number != 0) || ((devfn & 0xf8) > 0x78) || ((devfn & 0xf8) == 0) || ((devfn & 0xf8) == 0x68)) return 1; spin_lock_irqsave(&ebu_lock, flags); cfg_base = ifxmips_pci_mapped_cfg; cfg_base |= (bus->number << IFXMIPS_PCI_CFG_BUSNUM_SHF) | (devfn << IFXMIPS_PCI_CFG_FUNNUM_SHF) | (where & ~0x3); /* Perform access */ if (access_type == PCI_ACCESS_WRITE) { #ifdef CONFIG_SWAP_IO_SPACE ifxmips_w32(swab32(*data), ((u32*)cfg_base)); #else ifxmips_w32(*data, ((u32*)cfg_base)); #endif } else { *data = ifxmips_r32(((u32*)(cfg_base))); #ifdef CONFIG_SWAP_IO_SPACE *data = swab32(*data); #endif } wmb(); /* clean possible Master abort */ cfg_base = (ifxmips_pci_mapped_cfg | (0x0 << IFXMIPS_PCI_CFG_FUNNUM_SHF)) + 4; temp = ifxmips_r32(((u32*)(cfg_base))); #ifdef CONFIG_SWAP_IO_SPACE temp = swab32 (temp); #endif cfg_base = (ifxmips_pci_mapped_cfg | (0x68 << IFXMIPS_PCI_CFG_FUNNUM_SHF)) + 4; ifxmips_w32(temp, ((u32*)cfg_base)); spin_unlock_irqrestore(&ebu_lock, flags); if (((*data) == 0xffffffff) && (access_type == PCI_ACCESS_READ)) return 1; return 0; }
unsigned short ifxmips_read_mdio(u32 phy_addr, u32 phy_reg) { u32 val = MDIO_ACC_REQUEST | MDIO_ACC_READ | ((phy_addr & MDIO_ACC_ADDR_MASK) << MDIO_ACC_ADDR_OFFSET) | ((phy_reg & MDIO_ACC_REG_MASK) << MDIO_ACC_REG_OFFSET); while (ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST) ; ifxmips_w32(val, IFXMIPS_PPE32_MDIO_ACC); while (ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST) ; val = ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_VAL_MASK; return val; }
void ifxmips_write_mdio(u32 phy_addr, u32 phy_reg, u16 phy_data) { u32 val = MDIO_ACC_REQUEST | ((phy_addr & MDIO_ACC_ADDR_MASK) << MDIO_ACC_ADDR_OFFSET) | ((phy_reg & MDIO_ACC_REG_MASK) << MDIO_ACC_REG_OFFSET) | phy_data; while (ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST) ; ifxmips_w32(val, IFXMIPS_PPE32_MDIO_ACC); }
static int ifxmips_led_probe(struct platform_device *dev) { int i = 0; ifxmips_led_setup_gpio(); ifxmips_w32(0, IFXMIPS_LED_AR); ifxmips_w32(0, IFXMIPS_LED_CPU0); ifxmips_w32(0, IFXMIPS_LED_CPU1); ifxmips_w32(LED_CON0_SWU, IFXMIPS_LED_CON0); ifxmips_w32(0, IFXMIPS_LED_CON1); /* setup the clock edge that the shift register is triggered on */ ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & ~IFXMIPS_LED_EDGE_MASK, IFXMIPS_LED_CON0); ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_CLK_EDGE, IFXMIPS_LED_CON0); /* per default leds 15-0 are set */ ifxmips_w32(IFXMIPS_LED_GROUP1 | IFXMIPS_LED_GROUP0, IFXMIPS_LED_CON1); /* leds are update periodically by the FPID */ ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_UPD_MASK, IFXMIPS_LED_CON1); ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_UPD_SRC_FPI, IFXMIPS_LED_CON1); /* set led update speed */ ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_MASK, IFXMIPS_LED_CON1); ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_SPEED, IFXMIPS_LED_CON1); /* adsl 0 and 1 leds are updated by the arc */ ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_ADSL_SRC, IFXMIPS_LED_CON0); /* per default, the leds are turned on */ ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_LED); for (i = 0; i < IFXMIPS_MAX_LED; i++) { struct ifxmips_led *tmp = kzalloc(sizeof(struct ifxmips_led), GFP_KERNEL); tmp->cdev.brightness_set = ifxmips_ledapi_set; tmp->cdev.name = kmalloc(sizeof("ifxmips:led:00"), GFP_KERNEL); sprintf((char *)tmp->cdev.name, "ifxmips:led:%02d", i); tmp->cdev.default_trigger = NULL; tmp->bit = i; led_classdev_register(&dev->dev, &tmp->cdev); } return 0; }
void ifxmips_led_blink_clear(unsigned int led) { led = ~(led & 0xffffff); ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & led, IFXMIPS_LED_CON0); }
void ifxmips_led_blink_set(unsigned int led) { led &= 0xffffff; ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | led, IFXMIPS_LED_CON0); }
static inline u32 asc_r32(unsigned long r) { return ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_DIFF + r)); }