Wed Jul 24 03:10:37 2013 UTC ()
Add 16-bit (RMW) pci_{read,write}_config_word to <linux/pci.h>.


(riastradh)
diff -r1.1.2.8 -r1.1.2.9 src/sys/external/bsd/drm2/include/linux/pci.h

cvs diff -r1.1.2.8 -r1.1.2.9 src/sys/external/bsd/drm2/include/linux/pci.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/include/linux/pci.h 2013/07/24 03:04:18 1.1.2.8
+++ src/sys/external/bsd/drm2/include/linux/pci.h 2013/07/24 03:10:37 1.1.2.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pci.h,v 1.1.2.8 2013/07/24 03:04:18 riastradh Exp $ */ 1/* $NetBSD: pci.h,v 1.1.2.9 2013/07/24 03:10:37 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2013 The NetBSD Foundation, Inc. 4 * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell. 8 * by Taylor R. Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -54,35 +54,59 @@ struct pci_dev { @@ -54,35 +54,59 @@ struct pci_dev {
54 54
55#define PCI_CAP_ID_AGP PCI_CAP_AGP 55#define PCI_CAP_ID_AGP PCI_CAP_AGP
56 56
57static inline int 57static inline int
58pci_find_capability(struct pci_dev *pdev, int cap) 58pci_find_capability(struct pci_dev *pdev, int cap)
59{ 59{
60 return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap, 60 return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap,
61 NULL, NULL); 61 NULL, NULL);
62} 62}
63 63
64static inline void 64static inline void
65pci_read_config_dword(struct pci_dev *pdev, int reg, uint32_t *valuep) 65pci_read_config_dword(struct pci_dev *pdev, int reg, uint32_t *valuep)
66{ 66{
 67 KASSERT(!ISSET(reg, 3));
67 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg); 68 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg);
68} 69}
69 70
70static inline void 71static inline void
71pci_write_config_dword(struct pci_dev *pdev, int reg, uint32_t value) 72pci_write_config_dword(struct pci_dev *pdev, int reg, uint32_t value)
72{ 73{
 74 KASSERT(!ISSET(reg, 3));
73 pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg, value); 75 pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg, value);
74} 76}
75 77
 78static inline void
 79pci_read_config_word(struct pci_dev *pdev, int reg, uint16_t *valuep)
 80{
 81 KASSERT(!ISSET(reg, 1));
 82 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
 83 (reg &~ 3)) >> (ISSET(reg, 3)? 16 : 0);
 84}
 85
 86static inline void
 87pci_write_config_word(struct pci_dev *pdev, int reg, uint16_t value)
 88{
 89 const int reg32 = (reg &~ 3);
 90 const unsigned int shift = (ISSET(reg, 3)? 16 : 0);
 91 uint32_t value32;
 92
 93 KASSERT(!ISSET(reg, 1));
 94 pci_read_config_dword(pdev, reg32, &value32);
 95 value32 &=~ (0xffffUL << shift);
 96 value32 |= (value << shift);
 97 pci_write_config_dword(pdev, reg32, value32);
 98}
 99
76/* 100/*
77 * XXX pci msi 101 * XXX pci msi
78 */ 102 */
79static inline void 103static inline void
80pci_enable_msi(struct pci_dev *pdev) 104pci_enable_msi(struct pci_dev *pdev)
81{ 105{
82 KASSERT(!pdev->msi_enabled); 106 KASSERT(!pdev->msi_enabled);
83 pdev->msi_enabled = true; 107 pdev->msi_enabled = true;
84} 108}
85 109
86static inline void 110static inline void
87pci_disable_msi(struct pci_dev *pdev) 111pci_disable_msi(struct pci_dev *pdev)
88{ 112{