blob: e997d97f619eca5078af11ce3a314a8ae3fd3efd [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// SPDX-License-Identifier: GPL-2.0-only
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * DSM-G600 board-level PCI initialization
4 *
5 * Copyright (C) 2006 Tower Technologies
6 * Author: Alessandro Zummo <a.zummo@towertech.it>
7 *
8 * based on ixdp425-pci.c:
9 * Copyright (C) 2002 Intel Corporation.
10 * Copyright (C) 2003-2004 MontaVista Software, Inc.
11 *
12 * Maintainer: http://www.nslu2-linux.org/
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000013 */
14
15#include <linux/pci.h>
16#include <linux/init.h>
17#include <linux/irq.h>
18#include <asm/mach/pci.h>
19#include <asm/mach-types.h>
20
David Brazdil0f672f62019-12-10 10:32:29 +000021#include "irqs.h"
22
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000023#define MAX_DEV 4
24#define IRQ_LINES 3
25
26/* PCI controller GPIO to IRQ pin mappings */
27#define INTA 11
28#define INTB 10
29#define INTC 9
30#define INTD 8
31#define INTE 7
32#define INTF 6
33
34void __init dsmg600_pci_preinit(void)
35{
36 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTA), IRQ_TYPE_LEVEL_LOW);
37 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTB), IRQ_TYPE_LEVEL_LOW);
38 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTC), IRQ_TYPE_LEVEL_LOW);
39 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTD), IRQ_TYPE_LEVEL_LOW);
40 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTE), IRQ_TYPE_LEVEL_LOW);
41 irq_set_irq_type(IXP4XX_GPIO_IRQ(INTF), IRQ_TYPE_LEVEL_LOW);
42 ixp4xx_pci_preinit();
43}
44
45static int __init dsmg600_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
46{
47 static int pci_irq_table[MAX_DEV][IRQ_LINES] = {
48 { IXP4XX_GPIO_IRQ(INTE), -1, -1 },
49 { IXP4XX_GPIO_IRQ(INTA), -1, -1 },
50 { IXP4XX_GPIO_IRQ(INTB), IXP4XX_GPIO_IRQ(INTC),
51 IXP4XX_GPIO_IRQ(INTD) },
52 { IXP4XX_GPIO_IRQ(INTF), -1, -1 },
53 };
54
55 if (slot >= 1 && slot <= MAX_DEV && pin >= 1 && pin <= IRQ_LINES)
56 return pci_irq_table[slot - 1][pin - 1];
57
58 return -1;
59}
60
61struct hw_pci __initdata dsmg600_pci = {
62 .nr_controllers = 1,
63 .ops = &ixp4xx_ops,
64 .preinit = dsmg600_pci_preinit,
65 .setup = ixp4xx_setup,
66 .map_irq = dsmg600_map_irq,
67};
68
69int __init dsmg600_pci_init(void)
70{
71 if (machine_is_dsmg600())
72 pci_common_init(&dsmg600_pci);
73
74 return 0;
75}
76
77subsys_initcall(dsmg600_pci_init);