1 /* 2 * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 /* 25 * Copyright (c) 2012 Intel Corporation. All rights reserved. 26 */ 27 28 #ifndef __DRM_SUN_PCI_H__ 29 #define __DRM_SUN_PCI_H__ 30 31 #include <sys/sunddi.h> 32 #include "drm_linux.h" 33 #define PCI_CONFIG_REGION_NUMS 6 34 35 struct pci_config_region { 36 unsigned long start; 37 unsigned long size; 38 }; 39 40 struct pci_dev { 41 struct drm_device *dev; 42 ddi_acc_handle_t pci_cfg_acc_handle; 43 44 uint16_t vendor; 45 uint16_t device; 46 struct pci_config_region regions[PCI_CONFIG_REGION_NUMS]; 47 int domain; 48 int bus; 49 int slot; 50 int func; 51 int irq; 52 53 ddi_iblock_cookie_t intr_block; 54 55 int msi_enabled; 56 ddi_intr_handle_t *msi_handle; 57 int msi_size; 58 int msi_actual; 59 uint_t msi_pri; 60 int msi_flag; 61 }; 62 63 #define pci_resource_start(pdev, bar) ((pdev)->regions[(bar)].start) 64 #define pci_resource_len(pdev, bar) ((pdev)->regions[(bar)].size) 65 #define pci_resource_end(pdev, bar) \ 66 ((pci_resource_len((pdev), (bar)) == 0 && \ 67 pci_resource_start((pdev), (bar)) == 0) ? 0 : \ 68 (pci_resource_start((pdev), (bar)) + \ 69 pci_resource_len((pdev), (bar)) - 1)) 70 71 extern uint8_t* pci_map_rom(struct pci_dev *pdev, size_t *size); 72 extern void pci_unmap_rom(struct pci_dev *pdev, uint8_t *base); 73 extern void pci_read_config_byte(struct pci_dev *dev, int where, u8 *val); 74 extern void pci_read_config_word(struct pci_dev *dev, int where, u16 *val); 75 extern void pci_read_config_dword(struct pci_dev *dev, int where, u32 *val); 76 extern void pci_write_config_byte(struct pci_dev *dev, int where, u8 val); 77 extern void pci_write_config_word(struct pci_dev *dev, int where, u16 val); 78 extern void pci_write_config_dword(struct pci_dev *dev, int where, u32 val); 79 80 extern int pci_find_capability(struct pci_dev *pdev, int capid); 81 extern struct pci_dev * pci_dev_create(struct drm_device *dev); 82 extern void pci_dev_destroy(struct pci_dev *pdev); 83 84 #endif /* __DRM_SUN_PCI_H__ */ 85