18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * arch/arch/mach-ixp4xx/wg302v2-pci.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * PCI setup routines for the Netgear WG302 v2 and WAG302 v2 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 2007 Imre Kaloz <kaloz@openwrt.org> 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * based on coyote-pci.c: 108c2ecf20Sopenharmony_ci * Copyright (C) 2002 Jungo Software Technologies. 118c2ecf20Sopenharmony_ci * Copyright (C) 2003 MontaVista Software, Inc. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * Maintainer: Imre Kaloz <kaloz@openwrt.org> 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/kernel.h> 178c2ecf20Sopenharmony_ci#include <linux/pci.h> 188c2ecf20Sopenharmony_ci#include <linux/init.h> 198c2ecf20Sopenharmony_ci#include <linux/irq.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include <asm/mach-types.h> 228c2ecf20Sopenharmony_ci#include <mach/hardware.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include <asm/mach/pci.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include "irqs.h" 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_civoid __init wg302v2_pci_preinit(void) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci irq_set_irq_type(IRQ_IXP4XX_GPIO8, IRQ_TYPE_LEVEL_LOW); 318c2ecf20Sopenharmony_ci irq_set_irq_type(IRQ_IXP4XX_GPIO9, IRQ_TYPE_LEVEL_LOW); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci ixp4xx_pci_preinit(); 348c2ecf20Sopenharmony_ci} 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic int __init wg302v2_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci if (slot == 1) 398c2ecf20Sopenharmony_ci return IRQ_IXP4XX_GPIO8; 408c2ecf20Sopenharmony_ci else if (slot == 2) 418c2ecf20Sopenharmony_ci return IRQ_IXP4XX_GPIO9; 428c2ecf20Sopenharmony_ci else return -1; 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct hw_pci wg302v2_pci __initdata = { 468c2ecf20Sopenharmony_ci .nr_controllers = 1, 478c2ecf20Sopenharmony_ci .ops = &ixp4xx_ops, 488c2ecf20Sopenharmony_ci .preinit = wg302v2_pci_preinit, 498c2ecf20Sopenharmony_ci .setup = ixp4xx_setup, 508c2ecf20Sopenharmony_ci .map_irq = wg302v2_map_irq, 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciint __init wg302v2_pci_init(void) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci if (machine_is_wg302v2()) 568c2ecf20Sopenharmony_ci pci_common_init(&wg302v2_pci); 578c2ecf20Sopenharmony_ci return 0; 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cisubsys_initcall(wg302v2_pci_init); 61