diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-11-24 17:42:03 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-11-24 17:42:03 -0500 |
| commit | 47143b094d4700842e42b0a7cc2548d7ae292690 (patch) | |
| tree | ab1e7fb7cdedd29c8a9b953e58110ff3870946e4 /arch/tile/kernel | |
| parent | 0b9466ccea3c4ec363737288dd9467bf978c9c2d (diff) | |
| parent | f02cbbe657939489347cbda598401a56913ffcbd (diff) | |
Merge branch 'drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
* 'drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile:
pci root complex: support for tile architecture
drivers/net/tile/: on-chip network drivers for the tile architecture
MAINTAINERS: add drivers/char/hvc_tile.c as maintained by tile
Diffstat (limited to 'arch/tile/kernel')
| -rw-r--r-- | arch/tile/kernel/Makefile | 1 | ||||
| -rw-r--r-- | arch/tile/kernel/pci.c | 621 |
2 files changed, 622 insertions, 0 deletions
diff --git a/arch/tile/kernel/Makefile b/arch/tile/kernel/Makefile index 112b1e248f05..b4c8e8ec45dc 100644 --- a/arch/tile/kernel/Makefile +++ b/arch/tile/kernel/Makefile | |||
| @@ -15,3 +15,4 @@ obj-$(CONFIG_SMP) += smpboot.o smp.o tlb.o | |||
| 15 | obj-$(CONFIG_MODULES) += module.o | 15 | obj-$(CONFIG_MODULES) += module.o |
| 16 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | 16 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
| 17 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o | 17 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o |
| 18 | obj-$(CONFIG_PCI) += pci.o | ||
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c new file mode 100644 index 000000000000..a1ee25be9ad9 --- /dev/null +++ b/arch/tile/kernel/pci.c | |||
| @@ -0,0 +1,621 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU General Public License | ||
| 6 | * as published by the Free Software Foundation, version 2. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but | ||
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
| 11 | * NON INFRINGEMENT. See the GNU General Public License for | ||
| 12 | * more details. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/kernel.h> | ||
| 16 | #include <linux/pci.h> | ||
| 17 | #include <linux/delay.h> | ||
| 18 | #include <linux/string.h> | ||
| 19 | #include <linux/init.h> | ||
| 20 | #include <linux/capability.h> | ||
| 21 | #include <linux/sched.h> | ||
| 22 | #include <linux/errno.h> | ||
| 23 | #include <linux/bootmem.h> | ||
| 24 | #include <linux/irq.h> | ||
| 25 | #include <linux/io.h> | ||
| 26 | #include <linux/uaccess.h> | ||
| 27 | |||
| 28 | #include <asm/processor.h> | ||
| 29 | #include <asm/sections.h> | ||
| 30 | #include <asm/byteorder.h> | ||
| 31 | #include <asm/hv_driver.h> | ||
| 32 | #include <hv/drv_pcie_rc_intf.h> | ||
| 33 | |||
| 34 | |||
| 35 | /* | ||
| 36 | * Initialization flow and process | ||
| 37 | * ------------------------------- | ||
| 38 | * | ||
| 39 | * This files containes the routines to search for PCI buses, | ||
| 40 | * enumerate the buses, and configure any attached devices. | ||
| 41 | * | ||
| 42 | * There are two entry points here: | ||
| 43 | * 1) tile_pci_init | ||
| 44 | * This sets up the pci_controller structs, and opens the | ||
| 45 | * FDs to the hypervisor. This is called from setup_arch() early | ||
| 46 | * in the boot process. | ||
| 47 | * 2) pcibios_init | ||
| 48 | * This probes the PCI bus(es) for any attached hardware. It's | ||
| 49 | * called by subsys_initcall. All of the real work is done by the | ||
| 50 | * generic Linux PCI layer. | ||
| 51 | * | ||
| 52 | */ | ||
| 53 | |||
| 54 | /* | ||
| 55 | * This flag tells if the platform is TILEmpower that needs | ||
| 56 | * special configuration for the PLX switch chip. | ||
| 57 | */ | ||
| 58 | int __write_once tile_plx_gen1; | ||
| 59 | |||
| 60 | static struct pci_controller controllers[TILE_NUM_PCIE]; | ||
| 61 | static int num_controllers; | ||
| 62 | |||
| 63 | static struct pci_ops tile_cfg_ops; | ||
| 64 | |||
| 65 | |||
| 66 | /* | ||
| 67 | * We don't need to worry about the alignment of resources. | ||
| 68 | */ | ||
| 69 | resource_size_t pcibios_align_resource(void *data, const struct resource *res, | ||
| 70 | resource_size_t size, resource_size_t align) | ||
| 71 | { | ||
| 72 | return res->start; | ||
| 73 | } | ||
| 74 | EXPORT_SYMBOL(pcibios_align_resource); | ||
| 75 | |||
| 76 | /* | ||
| 77 | * Open a FD to the hypervisor PCI device. | ||
| 78 | * | ||
| 79 | * controller_id is the controller number, config type is 0 or 1 for | ||
| 80 | * config0 or config1 operations. | ||
| 81 | */ | ||
| 82 | static int __init tile_pcie_open(int controller_id, int config_type) | ||
| 83 | { | ||
| 84 | char filename[32]; | ||
| 85 | int fd; | ||
| 86 | |||
| 87 | sprintf(filename, "pcie/%d/config%d", controller_id, config_type); | ||
| 88 | |||
| 89 | fd = hv_dev_open((HV_VirtAddr)filename, 0); | ||
| 90 | |||
| 91 | return fd; | ||
| 92 | } | ||
| 93 | |||
| 94 | |||
| 95 | /* | ||
| 96 | * Get the IRQ numbers from the HV and set up the handlers for them. | ||
| 97 | */ | ||
| 98 | static int __init tile_init_irqs(int controller_id, | ||
| 99 | struct pci_controller *controller) | ||
| 100 | { | ||
| 101 | char filename[32]; | ||
| 102 | int fd; | ||
| 103 | int ret; | ||
| 104 | int x; | ||
| 105 | struct pcie_rc_config rc_config; | ||
| 106 | |||
| 107 | sprintf(filename, "pcie/%d/ctl", controller_id); | ||
| 108 | fd = hv_dev_open((HV_VirtAddr)filename, 0); | ||
| 109 | if (fd < 0) { | ||
| 110 | pr_err("PCI: hv_dev_open(%s) failed\n", filename); | ||
| 111 | return -1; | ||
| 112 | } | ||
| 113 | ret = hv_dev_pread(fd, 0, (HV_VirtAddr)(&rc_config), | ||
| 114 | sizeof(rc_config), PCIE_RC_CONFIG_MASK_OFF); | ||
| 115 | hv_dev_close(fd); | ||
| 116 | if (ret != sizeof(rc_config)) { | ||
| 117 | pr_err("PCI: wanted %zd bytes, got %d\n", | ||
| 118 | sizeof(rc_config), ret); | ||
| 119 | return -1; | ||
| 120 | } | ||
| 121 | /* Record irq_base so that we can map INTx to IRQ # later. */ | ||
| 122 | controller->irq_base = rc_config.intr; | ||
| 123 | |||
| 124 | for (x = 0; x < 4; x++) | ||
| 125 | tile_irq_activate(rc_config.intr + x, | ||
| 126 | TILE_IRQ_HW_CLEAR); | ||
| 127 | |||
| 128 | if (rc_config.plx_gen1) | ||
| 129 | controller->plx_gen1 = 1; | ||
| 130 | |||
| 131 | return 0; | ||
| 132 | } | ||
| 133 | |||
| 134 | /* | ||
| 135 | * First initialization entry point, called from setup_arch(). | ||
| 136 | * | ||
| 137 | * Find valid controllers and fill in pci_controller structs for each | ||
| 138 | * of them. | ||
| 139 | * | ||
| 140 | * Returns the number of controllers discovered. | ||
| 141 | */ | ||
| 142 | int __init tile_pci_init(void) | ||
| 143 | { | ||
| 144 | int i; | ||
| 145 | |||
| 146 | pr_info("PCI: Searching for controllers...\n"); | ||
| 147 | |||
| 148 | /* Do any configuration we need before using the PCIe */ | ||
| 149 | |||
| 150 | for (i = 0; i < TILE_NUM_PCIE; i++) { | ||
| 151 | int hv_cfg_fd0 = -1; | ||
| 152 | int hv_cfg_fd1 = -1; | ||
| 153 | int hv_mem_fd = -1; | ||
| 154 | char name[32]; | ||
| 155 | struct pci_controller *controller; | ||
| 156 | |||
| 157 | /* | ||
| 158 | * Open the fd to the HV. If it fails then this | ||
| 159 | * device doesn't exist. | ||
| 160 | */ | ||
| 161 | hv_cfg_fd0 = tile_pcie_open(i, 0); | ||
| 162 | if (hv_cfg_fd0 < 0) | ||
| 163 | continue; | ||
| 164 | hv_cfg_fd1 = tile_pcie_open(i, 1); | ||
| 165 | if (hv_cfg_fd1 < 0) { | ||
| 166 | pr_err("PCI: Couldn't open config fd to HV " | ||
| 167 | "for controller %d\n", i); | ||
| 168 | goto err_cont; | ||
| 169 | } | ||
| 170 | |||
| 171 | sprintf(name, "pcie/%d/mem", i); | ||
| 172 | hv_mem_fd = hv_dev_open((HV_VirtAddr)name, 0); | ||
| 173 | if (hv_mem_fd < 0) { | ||
| 174 | pr_err("PCI: Could not open mem fd to HV!\n"); | ||
| 175 | goto err_cont; | ||
| 176 | } | ||
| 177 | |||
| 178 | pr_info("PCI: Found PCI controller #%d\n", i); | ||
| 179 | |||
| 180 | controller = &controllers[num_controllers]; | ||
| 181 | |||
| 182 | if (tile_init_irqs(i, controller)) { | ||
| 183 | pr_err("PCI: Could not initialize " | ||
| 184 | "IRQs, aborting.\n"); | ||
| 185 | goto err_cont; | ||
| 186 | } | ||
| 187 | |||
| 188 | controller->index = num_controllers; | ||
