void ath_usb1_initial_config(void) { #define unset(a) (~(a)) ath_reg_wr_nf(SWITCH_CLOCK_SPARE_ADDRESS, ath_reg_rd(SWITCH_CLOCK_SPARE_ADDRESS) | SWITCH_CLOCK_SPARE_USB_REFCLK_FREQ_SEL_SET(5)); udelay(1000); ath_reg_rmw_set(RST_RESET_ADDRESS, RST_RESET_USB_PHY_SUSPEND_OVERRIDE_SET(1)); udelay(1000); ath_reg_rmw_clear(RST_RESET_ADDRESS, RST_RESET_USB_PHY_RESET_SET(1)); udelay(1000); ath_reg_rmw_clear(RST_RESET_ADDRESS, RST_RESET_USB_PHY_ARESET_SET(1)); udelay(1000); ath_reg_rmw_clear(RST_RESET_ADDRESS, RST_RESET_USB_HOST_RESET_SET(1)); udelay(1000); ath_reg_rmw_clear(RST_RESET_ADDRESS, RST_RESET_USB_PHY_PLL_PWD_EXT_SET(1)); udelay(10); ath_reg_rmw_set(RST_RESET2_ADDRESS, RST_RESET2_USB1_EXT_PWR_SEQ_SET(1)); udelay(10); }
void ap_usb_led_on(void) { #ifdef CONFIG_MACH_AR934x #if !defined(CONFIG_I2S) && defined(AP_USB_LED_GPIO) unsigned int rddata; if(AP_USB_LED_GPIO == 4) { rddata = ath_reg_rd(ATH_GPIO_OUT_FUNCTION1); //87- for USB suspend rddata = rddata & 0xffffff00; rddata = rddata | ATH_GPIO_OUT_FUNCTION1_ENABLE_GPIO_4(0x0); ath_reg_wr(ATH_GPIO_OUT_FUNCTION1, rddata); }else if(AP_USB_LED_GPIO == 11) { rddata = ath_reg_rd(ATH_GPIO_OUT_FUNCTION2); //87- for USB suspend rddata = rddata & 0x00ffffff; rddata = rddata | ATH_GPIO_OUT_FUNCTION2_ENABLE_GPIO_11(0x0); ath_reg_wr(ATH_GPIO_OUT_FUNCTION2, rddata); } ath_reg_rmw_clear(ATH_GPIO_OE, (1<<AP_USB_LED_GPIO)); ath_reg_rmw_clear(ATH_GPIO_OUT, (1<<AP_USB_LED_GPIO)); #endif #else ath_gpio_out_val(AP_USB_LED_GPIO, USB_LED_ON); #endif }
int __init ath_simple_config_init(void) { #if 0 #ifdef CONFIG_CUS100 u32 mask = 0; #endif int req, ret; ret = misc_register(&athfr_miscdev); if (ret < 0) { printk("*** ath misc_register failed %d *** \n", ret); return -1; } #ifdef CONFIG_CUS100 mask = ath_reg_rd(ATH_MISC_INT_MASK); ath_reg_wr(ATH_MISC_INT_MASK, mask | (1 << 2)); ath_gpio_config_int(JUMPSTART_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_HIGH); ath_gpio_intr_enable(JUMPSTART_GPIO); ath_gpio_config_input(JUMPSTART_GPIO); #else ath_gpio_config_input(JUMPSTART_GPIO); /* configure Jumpstart GPIO as level triggered interrupt */ ath_gpio_config_int(JUMPSTART_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW); printk("%s JUMPSTART_GPIO: %d\n", __func__, JUMPSTART_GPIO); #ifndef CONFIG_MACH_AR934x ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 2)); ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 16)); ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 20)); #endif #endif req = request_irq(ATH_GPIO_IRQn(JUMPSTART_GPIO), jumpstart_irq, 0, "SW JUMPSTART/FACTORY RESET", NULL); if (req != 0) { printk("request_irq for jumpstart failed (error %d)\n", req); misc_deregister(&athfr_miscdev); ath_gpio_intr_shutdown(ATH_GPIO_IRQn(JUMPSTART_GPIO)); return -1; } #if !defined(CONFIG_I2S) && defined(AP_USB_LED_GPIO) ath_gpio_config_output(AP_USB_LED_GPIO); #endif init_waitqueue_head(&ath_fr_wq); #endif create_simple_config_led_proc_entry(); return 0; }
void pci_rc2_init_board (void) { uint32_t cmd; ath_reg_rmw_set(RST_RESET2_ADDRESS, RST_RESET2_PCIE2_PHY_RESET_SET(1)); udelay(10000); ath_reg_rmw_set(RST_RESET2_ADDRESS, RST_RESET2_PCIE2_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY2_SET(1)); udelay(10000); ath_reg_wr_nf(PCIE2_RESET_ADDRESS, 0); // Put endpoint in reset udelay(100000); ath_reg_rmw_set(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY2_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET2_ADDRESS, RST_RESET_PCIE_PHY_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET2_ADDRESS, RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_wr_nf(PCIE2_APP_ADDRESS, PCIE2_APP_PCIE2_BAR_MSN_SET(1) | PCIE2_APP_CFG_BE_SET(0xf) | PCIE2_APP_SLV_RESP_ERR_MAP_SET(0x3f) | PCIE2_APP_LTSSM_ENABLE_SET(1)); cmd = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK; ath_local_write_config_rc2(PCI_COMMAND, 4, cmd); ath_local_write_config_rc2(0x20, 4, 0x1ff01000); ath_local_write_config_rc2(0x24, 4, 0x1ff01000); ath_reg_wr_nf(PCIE2_RESET_ADDRESS, 4); // Pull endpoint out of reset udelay(100000); /* * Check if the WLAN PCI-E H/W is present, If the * WLAN H/W is not present, skip the PCI platform * initialization code and return */ if (((ath_reg_rd(PCIE2_RESET_ADDRESS)) & 0x1) == 0x0) { printf("*** Warning *** : PCIe WLAN Module not found !!!\n"); return; } }
static void ath_pci_irq_disable(unsigned int irq) { #ifdef CONFIG_PERICOM /* Copied from NetBSD */ if (irq == ATH_PCI_IRQ_DEV0) { ath_reg_rmw_clear(ATH_PCI_INT_MASK, ATH_PCI_INT_B_L); } else if (irq == ATH_PCI_IRQ_DEV1) { ath_reg_rmw_clear(ATH_PCI_INT_MASK, ATH_PCI_INT_C_L); } #else ath_reg_rmw_clear(ATH_PCI_INT_MASK, ATH_PCI_INT_A_L); ath_reg_rmw_clear(ATH_PCI_INT_STATUS, ATH_PCI_INT_A_L); #endif /* CONFIG_PERICOM */ }
void uart_gpio_init_qca953x(void) { uint32_t val; ath_reg_rmw_set(GPIO_OE_ADDRESS, (1<<9)); ath_reg_rmw_clear(GPIO_OE_ADDRESS, (1<<10)); ath_reg_rmw_set(GPIO_OUT_FUNCTION2_ADDRESS, GPIO_OUT_FUNCTION2_ENABLE_GPIO_10_SET(0x16)); ath_reg_rmw_clear(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0xff)); ath_reg_rmw_set(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0x9)); }
static void ath_config_eth_led(void) { uint32_t reg_value; /*WAN, GPIO19, DS3*/ ath_gpio_config_output(19); ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<24); reg_value = ath_reg_rd(ATH_GPIO_OUT_FUNCTION4); reg_value = reg_value | (41 << 24); ath_reg_wr(ATH_GPIO_OUT_FUNCTION4, reg_value); printk("ATH_GPIO_OUT_FUNCTION4: 0x%x\n", ath_reg_rd(ATH_GPIO_OUT_FUNCTION4)); /* LAN1, GPIO20, DS4 */ ath_gpio_config_output(20); ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION5, 0xff<<0); reg_value = ath_reg_rd(ATH_GPIO_OUT_FUNCTION5); reg_value = reg_value | (42 << 0); ath_reg_wr(ATH_GPIO_OUT_FUNCTION5, reg_value); /* it's ok */ /* LAN2, GPIO21, DS5 */ ath_gpio_config_output(21); ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION5, 0xff<<8); reg_value = ath_reg_rd(ATH_GPIO_OUT_FUNCTION5); reg_value = reg_value | (43 << 8); ath_reg_wr(ATH_GPIO_OUT_FUNCTION5, reg_value); printk("ATH_GPIO_OUT_FUNCTION5: 0x%x\n", ath_reg_rd(ATH_GPIO_OUT_FUNCTION5)); /* LAN3, GPIO12, DS6 */ ath_gpio_config_output(12); ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<0); reg_value = ath_reg_rd(ATH_GPIO_OUT_FUNCTION3); reg_value = reg_value | (44 << 0); ath_reg_wr(ATH_GPIO_OUT_FUNCTION3, reg_value); /* it's ok */ /* LAN4, GPIO18, DS7 */ ath_gpio_config_output(18); ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<16); reg_value = ath_reg_rd(ATH_GPIO_OUT_FUNCTION4); reg_value = reg_value | (45 << 16); ath_reg_wr(ATH_GPIO_OUT_FUNCTION4, reg_value); printk("ATH_GPIO_OUT_FUNCTION4: 0x%x\n", ath_reg_rd(ATH_GPIO_OUT_FUNCTION4)); }
void ath_gpio_out_val(int gpio, int val) { if (val & 0x1) { ath_reg_rmw_set(ATH_GPIO_OUT, (1 << gpio)); } else { ath_reg_rmw_clear(ATH_GPIO_OUT, (1 << gpio)); } }
void ath_gpio_config_input(int gpio) { #ifdef CONFIG_MACH_AR934x ath_reg_rmw_set(ATH_GPIO_OE, (1 << gpio)); #else ath_reg_rmw_clear(ATH_GPIO_OE, (1 << gpio)); #endif }
void ath_gpio_config_input(int gpio) { #if defined(CONFIG_MACH_AR934x) || \ defined(CONFIG_MACH_QCA955x) || \ defined(CONFIG_MACH_QCA953x) || \ defined(CONFIG_MACH_QCA956x) ath_reg_rmw_set(ATH_GPIO_OE, (1 << gpio)); #else ath_reg_rmw_clear(ATH_GPIO_OE, (1 << gpio)); #endif }
void ath_usb2_initial_config(void) { ath_reg_rmw_set(RST_RESET2_ADDRESS, RST_RESET2_USB2_MODE_SET(1)); udelay(10); ath_reg_rmw_set(RST_RESET2_ADDRESS, RST_RESET2_USB_PHY2_SUSPEND_OVERRIDE_SET(1)); udelay(1000); ath_reg_rmw_clear(RST_RESET2_ADDRESS, RST_RESET2_USB_PHY2_RESET_SET(1)); udelay(1000); ath_reg_rmw_clear(RST_RESET2_ADDRESS, RST_RESET2_USB_PHY2_ARESET_SET(1)); udelay(1000); ath_reg_rmw_clear(RST_RESET2_ADDRESS, RST_RESET2_USB_HOST2_RESET_SET(1)); udelay(1000); ath_reg_rmw_clear(RST_RESET2_ADDRESS, RST_RESET2_USB_PHY2_PLL_PWD_EXT_SET(1)); udelay(10); ath_reg_rmw_set(RST_RESET2_ADDRESS, RST_RESET2_USB2_EXT_PWR_SEQ_SET(1)); udelay(10); }
void pci_rc2_init_board (void) { #if defined(CONFIG_MACH_QCA956x) ath_reg_rmw_clear(GPIO_OE_ADDRESS, 0x1); udelay(10000); ath_reg_rmw_set(GPIO_OUT_FUNCTION0_ADDRESS, GPIO_OUT_FUNCTION0_ENABLE_GPIO_0_SET(0x73)); udelay(10000); ath_reg_rmw_set(RST_RESET_ADDRESS,RST_RESET_PCIE_PHY_RESET_SET(1) | RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET_ADDRESS,RST_RESET_PCIE_PHY_RESET_SET(1) | RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_rmw_set(RST_RESET2_ADDRESS,RST_RESET_PCIE_PHY_RESET_SET(1) | RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET2_ADDRESS,RST_RESET_PCIE_PHY_RESET_SET(1) | RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_wr(PCIE2_RESET_ADDRESS,PCIE2_RESET_EP_RESET_L_SET(1)); udelay(10000); ath_reg_wr(ATH_PCI_CRP_WRDATA,0x6); udelay(10000); ath_reg_wr(PCIE_APP_ADDRESS,PCIE_APP_LTSSM_ENABLE_SET(1) | PCIE_APP_SLV_RESP_ERR_MAP_SET(0x3f) | PCIE_APP_CFG_BE_SET(0xf) | PCIE_APP_PCIE_BAR_MSN_SET(1)); udelay(10000); ath_reg_wr(PCIE_INT_MASK_ADDRESS,PCIE_INT_MASK_CORR_ERR_SET(1) | PCIE_INT_MASK_NONFATAL_ERR_SET(1) | PCIE_INT_MASK_FATAL_ERR_SET(1) | PCIE_INT_MASK_GM_COMP_LOOKUP_ERR_SET(1) | PCIE_INT_MASK_RADMX_COMP_LOOKUP_ERR_SET(1) | PCIE_INT_MASK_INTA_SET(1) | PCIE_INT_MASK_INTB_SET(1) | PCIE_INT_MASK_INTC_SET(1) | PCIE_INT_MASK_INTD_SET(1) | PCIE_INT_MASK_MSI_SET(1) | PCIE_INT_MASK_MSI_ERR_SET(1) | PCIE_INT_MASK_AER_INT_SET(1) | PCIE_INT_MASK_AER_MSI_SET(1) | PCIE_INT_MASK_SYS_ERR_SET(1) | PCIE_INT_MASK_INTAL_SET(1) | PCIE_INT_MASK_INTBL_SET(1) | PCIE_INT_MASK_INTCL_SET(1) | PCIE_INT_MASK_INTDL_SET(1)); udelay(10000); ath_local_write_config_rc2(0x70c, 4, 0x1b403200); udelay(10000); ath_reg_wr(PCIE_DEBUG_ADDRESS,PCIE_DEBUG_BYTESWAP_SET(1)); udelay(10000); ath_reg_rmw_set(XTAL2_SEC_ADDRESS, XTAL2_SEC_SPARE_SET(0xc)); udelay(10000); ath_reg_rmw_clear(PCIe_DPLL2_ADDRESS, PCIe_DPLL2_KI_SET(0x3) | PCIe_DPLL2_KD_SET(0xF)); udelay(10000); ath_reg_rmw_set(PCIe_DPLL2_ADDRESS, PCIe_DPLL2_KD_SET(0x4)); udelay(10000); #else uint32_t cmd; ath_reg_rmw_set(RST_RESET2_ADDRESS, RST_RESET2_PCIE2_PHY_RESET_SET(1)); udelay(10000); ath_reg_rmw_set(RST_RESET2_ADDRESS, RST_RESET2_PCIE2_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY2_SET(1)); udelay(10000); ath_reg_wr_nf(PCIE2_RESET_ADDRESS, 0); // Put endpoint in reset udelay(100000); ath_reg_rmw_set(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY2_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET2_ADDRESS, RST_RESET_PCIE_PHY_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET2_ADDRESS, RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_wr_nf(PCIE2_APP_ADDRESS, PCIE2_APP_PCIE2_BAR_MSN_SET(1) | PCIE2_APP_CFG_BE_SET(0xf) | PCIE2_APP_SLV_RESP_ERR_MAP_SET(0x3f) | PCIE2_APP_LTSSM_ENABLE_SET(1)); cmd = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK; ath_local_write_config_rc2(PCI_COMMAND, 4, cmd); ath_local_write_config_rc2(0x20, 4, 0x1ff01000); ath_local_write_config_rc2(0x24, 4, 0x1ff01000); ath_reg_wr_nf(PCIE2_RESET_ADDRESS, 4); // Pull endpoint out of reset udelay(100000); #endif /* * Check if the WLAN PCI-E H/W is present, If the * WLAN H/W is not present, skip the PCI platform * initialization code and return */ if (((ath_reg_rd(PCIE2_RESET_ADDRESS)) & 0x1) == 0x0) { prmsg("*** Warning *** : PCIe WLAN Module not found !!!\n"); return; } }
PCI_INIT_RET_TYPE pci_init_board (void) { #ifdef CONFIG_ATH_EMULATION prmsg("--- Skipping %s for emulation\n", __func__); #else uint32_t cmd; if (is_drqfn() && !is_qca953x()) { /* * Dont enable PCIe in DRQFN package as it has some issues * related to PCIe */ PCI_INIT_RETURN; } #if defined(CONFIG_MACH_QCA953x) if (ath_reg_rd(RST_BOOTSTRAP_ADDRESS) & RST_BOOTSTRAP_TESTROM_ENABLE_MASK) { ath_reg_rmw_clear(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY_SET(1)); ath_reg_wr(PCIE_PHY_REG_1_ADDRESS, PCIE_PHY_REG_1_RESET_1); ath_reg_wr(PCIE_PHY_REG_3_ADDRESS, PCIE_PHY_REG_3_RESET_1); ath_reg_rmw_set(PCIE_PWR_MGMT_ADDRESS, PCIE_PWR_MGMT_ASSERT_CLKREQN_SET(1)); ath_reg_rmw_set(PCIE_PLL_CONFIG_ADDRESS, PCIE_PLL_CONFIG_PLLPWD_SET(1)); ath_reg_rmw_set(RST_RESET_ADDRESS, RST_RESET_PCIE_RESET_SET(1)); ath_reg_rmw_set(RST_RESET_ADDRESS, RST_RESET_PCIE_PHY_RESET_SET(1)); ath_reg_rmw_clear(RST_CLKGAT_EN_ADDRESS, RST_CLKGAT_EN_PCIE_RC_SET(1)); PCI_INIT_RETURN; } else { /* Honeybee -The PCIe reference clock frequency is being changed to vary from 99.968MHz to 99.999MHz using SS modulation */ ath_reg_wr_nf(PCIE_PLL_DITHER_DIV_MAX_ADDRESS, PCIE_PLL_DITHER_DIV_MAX_EN_DITHER_SET(0x1) | PCIE_PLL_DITHER_DIV_MAX_USE_MAX_SET(0x1) | PCIE_PLL_DITHER_DIV_MAX_DIV_MAX_INT_SET(0x17) | PCIE_PLL_DITHER_DIV_MAX_DIV_MAX_FRAC_SET(0x3fff)); ath_reg_wr_nf(PCIE_PLL_DITHER_DIV_MIN_ADDRESS, PCIE_PLL_DITHER_DIV_MIN_DIV_MIN_FRAC_SET(0x3f84)| PCIE_PLL_DITHER_DIV_MIN_DIV_MIN_INT_SET(0x17)); } #else #if defined(CONFIG_MACH_QCA956x) ath_reg_rmw_set(PCIE_PHY_REG_1_ADDRESS, PCIE_PHY_REG_1_S_SET(PCIE_PHY_REG_1_S_RESET)); ath_reg_wr_nf(PCIE_PLL_DITHER_DIV_MAX_ADDRESS, PCIE_PLL_DITHER_DIV_MAX_USE_MAX_SET(0x1) | PCIE_PLL_DITHER_DIV_MAX_DIV_MAX_INT_SET(0x17) | PCIE_PLL_DITHER_DIV_MAX_DIV_MAX_FRAC_SET(0x3fff)); ath_reg_wr_nf(PCIE_PLL_DITHER_DIV_MIN_ADDRESS, PCIE_PLL_DITHER_DIV_MIN_DIV_MIN_FRAC_SET(0x3f84) | PCIE_PLL_DITHER_DIV_MIN_DIV_MIN_INT_SET(0x17)); #else // common for rc1 and rc2 ath_reg_wr_nf(PCIE_PLL_DITHER_DIV_MAX_ADDRESS, PCIE_PLL_DITHER_DIV_MAX_EN_DITHER_SET(0x1) | PCIE_PLL_DITHER_DIV_MAX_USE_MAX_SET(0x1) | PCIE_PLL_DITHER_DIV_MAX_DIV_MAX_INT_SET(0x14) | PCIE_PLL_DITHER_DIV_MAX_DIV_MAX_FRAC_SET(0x3ff)); ath_reg_wr_nf(PCIE_PLL_DITHER_DIV_MIN_ADDRESS, PCIE_PLL_DITHER_DIV_MIN_DIV_MIN_INT_SET(0x14)); #endif #endif ath_reg_wr_nf(PCIE_PLL_CONFIG_ADDRESS, PCIE_PLL_CONFIG_REFDIV_SET(1) | PCIE_PLL_CONFIG_BYPASS_SET(1) | PCIE_PLL_CONFIG_PLLPWD_SET(1)); udelay(10000); ath_reg_rmw_clear(PCIE_PLL_CONFIG_ADDRESS, PCIE_PLL_CONFIG_PLLPWD_SET(1)); udelay(1000); ath_reg_rmw_clear(PCIE_PLL_CONFIG_ADDRESS, PCIE_PLL_CONFIG_BYPASS_SET(1)); udelay(1000); #if !defined(CONFIG_MACH_QCA956x) #ifdef PCIE2_APP_ADDRESS if (!(ath_reg_rd(RST_BOOTSTRAP_ADDRESS) & RST_BOOTSTRAP_PCIE_RC_EP_SELECT_MASK)) { pci_rc2_init_board(); return; } #endif ath_reg_rmw_set(RST_RESET_ADDRESS, RST_RESET_PCIE_PHY_RESET_SET(1)); udelay(10000); ath_reg_rmw_set(RST_RESET_ADDRESS, RST_RESET_PCIE_RESET_SET(1)); udelay(10000); #ifdef PCIE2_APP_ADDRESS ath_reg_rmw_clear(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY_SET(1)); udelay(10000); #endif ath_reg_wr_nf(PCIE_RESET_ADDRESS, 0); // Put endpoint in reset udelay(100000); #ifdef PCIE2_APP_ADDRESS ath_reg_rmw_set(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY_SET(1)); udelay(10000); #endif ath_reg_rmw_clear(RST_RESET_ADDRESS, RST_RESET_PCIE_PHY_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET_ADDRESS, RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_wr_nf(PCIE_APP_ADDRESS, PCIE_APP_PCIE_BAR_MSN_SET(1) | PCIE_APP_CFG_BE_SET(0xf) | PCIE_APP_SLV_RESP_ERR_MAP_SET(0x3f) | PCIE_APP_LTSSM_ENABLE_SET(1)); cmd = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK; ath_local_write_config(PCI_COMMAND, 4, cmd); ath_local_write_config(0x20, 4, 0x1ff01000); ath_local_write_config(0x24, 4, 0x1ff01000); ath_reg_wr_nf(PCIE_RESET_ADDRESS, 4); // Pull endpoint out of reset udelay(100000); /* * Check if the WLAN PCI-E H/W is present, If the * WLAN H/W is not present, skip the PCI platform * initialization code and return */ if (((ath_reg_rd(PCIE_RESET_ADDRESS)) & 0x1) == 0x0) { prmsg("*** Warning *** : PCIe WLAN Module not found !!!\n"); } #endif #ifdef PCIE2_APP_ADDRESS pci_rc2_init_board(); #endif #ifndef COMPRESSED_UBOOT /* * Now, configure for u-boot tools */ hose.first_busno = 0; hose.last_busno = 0xff; /* System space */ pci_set_region( &hose.regions[0], 0x80000000, 0x00000000, 32 * 1024 * 1024, PCI_REGION_MEM | PCI_REGION_MEMORY); /* PCI memory space */ pci_set_region( &hose.regions[1], 0x10000000, 0x10000000, 128 * 1024 * 1024, PCI_REGION_MEM); hose.region_count = 2; pci_register_hose(&hose); pci_set_ops( &hose, pci_hose_read_config_byte_via_dword, pci_hose_read_config_word_via_dword, ath_pci_read_config, pci_hose_write_config_byte_via_dword, pci_hose_write_config_word_via_dword, ath_pci_write_config); #endif plat_dev_init(); #endif /* CONFIG_ATH_EMULATION */ PCI_INIT_RETURN; }
int __init ar7240_simple_config_init(void) { int req; /* restore factory default and system led */ dev_t dev; int rt; int current_wifi_value; int ar7240_gpio_major = gpio_major; int ar7240_gpio_minor = gpio_minor; init_timer(&rst_timer); rst_timer.function = check_rst; /* config gpio 11, 12, 14, 15, 16, 17 as normal gpio function */ /* gpio11 */ ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION2, 0xff<<24); /* gpio12 */ ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<0); /* gpio14 */ ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<16); /* gpio15 */ ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION3, 0xff<<24); /* gpio16 */ ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<0); /* gpio17 */ ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<8); #ifndef CONFIG_MUX_RESET_WPS_BUTTON /* This is NECESSARY, lsz 090109 */ ath_gpio_config_input(WPS_BUTTON_GPIO); /* configure JUMPSTART_GPIO as level triggered interrupt */ ath_gpio_config_int (WPS_BUTTON_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW); req = request_irq (ATH_GPIO_IRQn(WPS_BUTTON_GPIO), wpsStart_irq, 0, "SW_WPSSTART", NULL); if (req != 0) { printk (KERN_ERR "unable to request IRQ for SWWPSSTART GPIO (error %d)\n", req); } #endif create_simple_config_led_proc_entry (); ath_gpio_config_input(RST_DFT_GPIO); /* configure GPIO RST_DFT_GPIO as level triggered interrupt */ ath_gpio_config_int (RST_DFT_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW); rt = request_irq (ATH_GPIO_IRQn(RST_DFT_GPIO), rst_irq, 0, "RESTORE_FACTORY_DEFAULT", NULL); if (rt != 0) { printk (KERN_ERR "unable to request IRQ for RESTORE_FACTORY_DEFAULT GPIO (error %d)\n", rt); } /* wifi switch! */ ath_gpio_config_input(WIFI_RADIO_SW_GPIO); current_wifi_value = ath_reg_rd(ATH_GPIO_IN) & (1 << WIFI_RADIO_SW_GPIO); /* configure GPIO RST_DFT_GPIO as level triggered interrupt */ if(current_wifi_value == 0) { ignore_wifibutton = 1; ath_gpio_config_int (WIFI_RADIO_SW_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW); } else { ignore_wifibutton =0; ath_gpio_config_int (WIFI_RADIO_SW_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_HIGH); } req = request_irq (ATH_GPIO_IRQn(WIFI_RADIO_SW_GPIO), wifi_sw_irq, 0, "WIFI_RADIO_SWITCH", NULL); if (req != 0) { printk (KERN_ERR "unable to request IRQ for WIFI_RADIO_SWITCH GPIO (error %d)\n", req); } if (ar7240_gpio_major) { dev = MKDEV(ar7240_gpio_major, ar7240_gpio_minor); rt = register_chrdev_region(dev, 1, "ar7240_gpio_chrdev"); } else { rt = alloc_chrdev_region(&dev, ar7240_gpio_minor, 1, "ar7240_gpio_chrdev"); ar7240_gpio_major = MAJOR(dev); } if (rt < 0) { printk(KERN_WARNING "ar7240_gpio_chrdev : can`t get major %d\n", ar7240_gpio_major); return rt; } cdev_init (&gpio_device_cdev, &gpio_device_op); rt = cdev_add(&gpio_device_cdev, dev, 1); if (rt < 0) printk(KERN_NOTICE "Error %d adding ar7240_gpio_chrdev ", rt); #ifdef AP_USB_LED_GPIO ath_gpio_config_output(AP_USB_LED_GPIO); #endif #ifdef AP_USB_1_LED_GPIO ath_gpio_config_output(AP_USB_1_LED_GPIO); #endif ath_gpio_config_output(SYS_LED_GPIO); /* for USB 3G by lyj, 31Aug11 */ #ifdef USB_POWER_SW_GPIO ath_gpio_config_output(USB_POWER_SW_GPIO); #endif #ifdef USB_1_POWER_SW_GPIO ath_gpio_config_output(USB_1_POWER_SW_GPIO); #endif /* s27 will use the gpio 18 19 as ethernet led */ #ifdef CONFIG_SUPPORT_S17 /* GPIO18-19 by lyj, 27Sep11 */ ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<16); ath_reg_rmw_clear(ATH_GPIO_OUT_FUNCTION4, 0xff<<24); /* config GPIO18-19 as output by lyj, 27Sep11 */ ath_gpio_config_output(18); ath_gpio_config_output(19); /* set GPIO18-19, for AR9344 art (LNA) by lyj, 27Sep11 */ ath_reg_rmw_set(ATH_GPIO_OUT_FUNCTION4, 0x2f2e0000); #endif ath_gpio_out_val(SYS_LED_GPIO, SYS_LED_OFF); #ifdef AP_USB_LED_GPIO ath_gpio_out_val(AP_USB_LED_GPIO, USB_LED_OFF); #endif #ifdef AP_USB_1_LED_GPIO ath_gpio_out_val(AP_USB_1_LED_GPIO, USB_1_LED_OFF); #endif ath_gpio_out_val (TRICOLOR_LED_GREEN_PIN, OFF); /* for USB 3G by lyj, 31Aug11 */ #ifdef USB_POWER_SW_GPIO ath_gpio_out_val(USB_POWER_SW_GPIO, USB_POWER_ON); #endif #ifdef USB_1_POWER_SW_GPIO ath_gpio_out_val(USB_1_POWER_SW_GPIO, USB_1_POWER_ON); #endif return 0; }
void uart_gpio_init_qca956x(void) { #ifdef CONFIG_MACH_QCA956x #if defined(UART_RX20_TX22) val = (ath_reg_rd(GPIO_OE_ADDRESS) & (~0x400000)); ath_reg_wr(GPIO_OE_ADDRESS, val); ath_reg_rmw_clear(GPIO_OUT_FUNCTION5_ADDRESS, GPIO_OUT_FUNCTION5_ENABLE_GPIO_22_MASK); ath_reg_rmw_set(GPIO_OUT_FUNCTION5_ADDRESS, GPIO_OUT_FUNCTION5_ENABLE_GPIO_22_SET(0x16)); ath_reg_rmw_clear(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_MASK); ath_reg_rmw_set(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0x14)); #elif defined(UART_RX18_TX22) val = (ath_reg_rd(GPIO_OE_ADDRESS) & (~0x400000)) | 0x40000; ath_reg_wr(GPIO_OE_ADDRESS, val); ath_reg_rmw_clear(GPIO_OUT_FUNCTION5_ADDRESS, GPIO_OUT_FUNCTION5_ENABLE_GPIO_22_MASK); ath_reg_rmw_set(GPIO_OUT_FUNCTION5_ADDRESS, GPIO_OUT_FUNCTION5_ENABLE_GPIO_22_SET(0x16)); ath_reg_rmw_clear(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_MASK); ath_reg_rmw_set(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0x12)); #elif defined(UART_RX18_TX20) val = (ath_reg_rd(GPIO_OE_ADDRESS) & (~0x100000)) | 0x40000; ath_reg_wr(GPIO_OE_ADDRESS, val); val = ath_reg_rd(GPIO_OUT_ADDRESS) | 0xeffff6; ath_reg_wr(GPIO_OUT_ADDRESS, val); ath_reg_rmw_clear(GPIO_OUT_FUNCTION5_ADDRESS, GPIO_OUT_FUNCTION5_ENABLE_GPIO_20_MASK); ath_reg_rmw_set(GPIO_OUT_FUNCTION5_ADDRESS, GPIO_OUT_FUNCTION5_ENABLE_GPIO_20_SET(0x16)); ath_reg_rmw_clear(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_MASK); ath_reg_rmw_set(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0x12)); #elif defined(UART_RX24_TX20) // Turn off LED before XLNA swap to GPO val = ath_reg_rd(GPIO_OUT_ADDRESS) | 0xaffff6; ath_reg_wr(GPIO_OUT_ADDRESS, val); //Switch GPI and GPO and XPA, XLNA ath_reg_wr(GPIO_FUNCTION_ADDRESS, 0x8000); val = (ath_reg_rd(GPIO_OE_ADDRESS) & (~0x100000)) | 0x1000000; ath_reg_wr(GPIO_OE_ADDRESS, val); ath_reg_rmw_set(GPIO_OUT_FUNCTION5_ADDRESS, GPIO_OUT_FUNCTION5_ENABLE_GPIO_20_SET(0x16)); ath_reg_rmw_clear(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0xff)); ath_reg_rmw_set(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0x18)); #elif defined(TEST_BOARD_UART) //Switch GPI and GPO and XPA1, ANTC ath_reg_wr(GPIO_FUNCTION_ADDRESS, 0xc000); val = ath_reg_rd(GPIO_OE_ADDRESS) & (~0x2000); ath_reg_wr(GPIO_OE_ADDRESS, val); ath_reg_rmw_clear(GPIO_OUT_FUNCTION3_ADDRESS, GPIO_OUT_FUNCTION3_ENABLE_GPIO_13_MASK); ath_reg_rmw_set(GPIO_OUT_FUNCTION3_ADDRESS, GPIO_OUT_FUNCTION3_ENABLE_GPIO_13_SET(0x16)); ath_reg_rmw_clear(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0xff)); ath_reg_rmw_set(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0x17)); #else val = (ath_reg_rd(GPIO_OE_ADDRESS) & (~0x100000)) | 0x80000; ath_reg_wr(GPIO_OE_ADDRESS, val); ath_reg_rmw_set(GPIO_OUT_FUNCTION5_ADDRESS, GPIO_OUT_FUNCTION5_ENABLE_GPIO_20_SET(0x16)); ath_reg_rmw_clear(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0xff)); ath_reg_rmw_set(GPIO_IN_ENABLE0_ADDRESS, GPIO_IN_ENABLE0_UART_SIN_SET(0x13)); #endif val = ath_reg_rd(GPIO_OUT_ADDRESS) | 0xaffff6; ath_reg_wr(GPIO_OUT_ADDRESS, val); val = ath_reg_rd(GPIO_SPARE_ADDRESS); ath_reg_wr(GPIO_SPARE_ADDRESS, (val | 0x8402)); #endif }
static void ath_gpio_intr_disable(unsigned int irq) { ath_reg_rmw_clear(ATH_GPIO_INT_MASK, (1 << (irq - ATH_GPIO_IRQ_BASE))); }
int pci_init_board (void) { #ifdef CONFIG_ATH_EMULATION printf("--- Skipping %s for emulation\n", __func__); #else uint32_t cmd; // common for rc1 and rc2 ath_reg_wr_nf(PCIE_PLL_DITHER_DIV_MAX_ADDRESS, PCIE_PLL_DITHER_DIV_MAX_EN_DITHER_SET(1) | PCIE_PLL_DITHER_DIV_MAX_USE_MAX_SET(1) | PCIE_PLL_DITHER_DIV_MAX_DIV_MAX_INT_SET(0x14) | PCIE_PLL_DITHER_DIV_MAX_DIV_MAX_FRAC_SET(0x3ff)); ath_reg_wr_nf(PCIE_PLL_DITHER_DIV_MIN_ADDRESS, PCIE_PLL_DITHER_DIV_MIN_DIV_MIN_INT_SET(0x14)); ath_reg_wr_nf(PCIE_PLL_CONFIG_ADDRESS, PCIE_PLL_CONFIG_REFDIV_SET(1) | PCIE_PLL_CONFIG_BYPASS_SET(1) | PCIE_PLL_CONFIG_PLLPWD_SET(1)); udelay(10000); ath_reg_rmw_clear(PCIE_PLL_CONFIG_ADDRESS, PCIE_PLL_CONFIG_PLLPWD_SET(1)); udelay(1000); ath_reg_rmw_clear(PCIE_PLL_CONFIG_ADDRESS, PCIE_PLL_CONFIG_BYPASS_SET(1)); udelay(1000); if (!(ath_reg_rd(RST_BOOTSTRAP_ADDRESS) & RST_BOOTSTRAP_PCIE_RC_EP_SELECT_MASK)) { pci_rc2_init_board(); return 0; } ath_reg_rmw_set(RST_RESET_ADDRESS, RST_RESET_PCIE_PHY_RESET_SET(1)); udelay(10000); ath_reg_rmw_set(RST_RESET_ADDRESS, RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY_SET(1)); udelay(10000); ath_reg_wr_nf(PCIE_RESET_ADDRESS, 0); // Put endpoint in reset udelay(100000); ath_reg_rmw_set(RST_MISC2_ADDRESS, RST_MISC2_PERSTN_RCPHY_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET_ADDRESS, RST_RESET_PCIE_PHY_RESET_SET(1)); udelay(10000); ath_reg_rmw_clear(RST_RESET_ADDRESS, RST_RESET_PCIE_RESET_SET(1)); udelay(10000); ath_reg_wr_nf(PCIE_APP_ADDRESS, PCIE_APP_PCIE_BAR_MSN_SET(1) | PCIE_APP_CFG_BE_SET(0xf) | PCIE_APP_SLV_RESP_ERR_MAP_SET(0x3f) | PCIE_APP_LTSSM_ENABLE_SET(1)); cmd = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK; ath_local_write_config(PCI_COMMAND, 4, cmd); ath_local_write_config(0x20, 4, 0x1ff01000); ath_local_write_config(0x24, 4, 0x1ff01000); ath_reg_wr_nf(PCIE_RESET_ADDRESS, 4); // Pull endpoint out of reset udelay(100000); /* training reset */ ath_reg_rmw_set(PCIE_APP_ADDRESS, PCIE_APP_INIT_RST_SET(1)); udelay(1000); /* * Check if the WLAN PCI-E H/W is present, If the * WLAN H/W is not present, skip the PCI platform * initialization code and return */ if (((ath_reg_rd(PCIE_RESET_ADDRESS)) & 0x1) == 0x0) { printf("*** Warning *** : PCIe WLAN Module not found !!!\n"); } pci_rc2_init_board(); #endif /* CONFIG_ATH_EMULATION */ return 0; }
int __init ath_simple_config_init(void) { #ifdef CONFIG_CUS100 u32 mask = 0; #endif #ifdef JUMPSTART_GPIO int req; #endif int ret; #ifdef AP_RESET_GPIO int req2; #endif ret = misc_register(&athfr_miscdev); if (ret < 0) { printk("*** ath misc_register failed %d *** \n", ret); return -1; } #ifdef AP_RESET_GPIO ath_gpio_config_input(AP_RESET_GPIO); ath_gpio_config_int(AP_RESET_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW); printk("%s (%s) AP_RESET_GPIO: %d\n", __FILE__, __func__, AP_RESET_GPIO); #endif #ifdef JUMPSTART_GPIO #ifdef CONFIG_CUS100 mask = ath_reg_rd(ATH_MISC_INT_MASK); ath_reg_wr(ATH_MISC_INT_MASK, mask | (1 << 2)); ath_gpio_config_int(JUMPSTART_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_HIGH); ath_gpio_intr_enable(JUMPSTART_GPIO); ath_gpio_config_input(JUMPSTART_GPIO); #else ath_gpio_config_input(JUMPSTART_GPIO); /* configure Jumpstart GPIO as level triggered interrupt */ ath_gpio_config_int(JUMPSTART_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW); printk("%s (%s) JUMPSTART_GPIO: %d\n", __FILE__, __func__, JUMPSTART_GPIO); #ifndef CONFIG_MACH_AR934x ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 2)); ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 16)); ath_reg_rmw_clear(ATH_GPIO_FUNCTIONS, (1 << 20)); #endif #endif req = request_irq(ATH_GPIO_IRQn(JUMPSTART_GPIO), jumpstart_irq, 0, #ifdef AP_RESET_GPIO "SW JUMPSTART", NULL); #else "SW JUMPSTART/FACTORY RESET", NULL); #endif if (req != 0) { printk("request_irq for jumpstart failed (error %d)\n", req); misc_deregister(&athfr_miscdev); ath_gpio_intr_shutdown(ATH_GPIO_IRQn(JUMPSTART_GPIO)); return -1; } #endif /* #ifdef JUMPSTART_GPIO */ #ifdef AP_RESET_GPIO req2 = request_irq(ATH_GPIO_IRQn(AP_RESET_GPIO), ath_reset_irq, 0, "FACTORY RESET", NULL); if (req2 != 0) { printk("request_irq for factory reset failed (error %d)\n", req); misc_deregister(&athfr_miscdev); free_irq(req, NULL); return -1; } #endif #ifdef ATH_S17INT_GPIO ath_gpio_config_input(ATH_S17INT_GPIO); /* configure S17 interrupt GPIO as level triggered interrupt */ ath_gpio_config_int(ATH_S17INT_GPIO, INT_TYPE_LEVEL, INT_POL_ACTIVE_LOW); printk("%s (%s) ATH_S17INT_GPIO: %d\n", __FILE__, __func__, ATH_S17INT_GPIO); #endif #if !defined(CONFIG_I2S) && defined(AP_USB_LED_GPIO) ath_gpio_config_output(AP_USB_LED_GPIO); #endif init_waitqueue_head(&ath_fr_wq); #ifdef WPS_LED_GPIO create_simple_config_led_proc_entry(); #endif #ifdef POWER_ON_GLED_GPIO printk("%s (%s) POWER_ON_GLED_GPIO: %d\n", __FILE__, __func__, POWER_ON_GLED_GPIO); ath_gpio_config_output(POWER_ON_GLED_GPIO); ath_gpio_out_val(POWER_ON_GLED_GPIO, POWER_LED_ON); #endif #ifdef POWER_ON_RLED_GPIO printk("%s (%s) POWER_ON_RLED_GPIO: %d\n", __FILE__, __func__, POWER_ON_RLED_GPIO); ath_gpio_config_output(POWER_ON_RLED_GPIO); ath_gpio_out_val(POWER_ON_RLED_GPIO, POWER_LED_OFF); OS_INIT_TIMER(NULL, &power_on_timer, power_led_blink, NULL); OS_SET_TIMER(&power_on_timer, POWER_LED_BLINK_INTERVAL); #endif return 0; }