coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pnp_ops.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __DEVICE_PNP_OPS_H__
4 #define __DEVICE_PNP_OPS_H__
5 
6 #include <stdint.h>
7 #include <device/pnp.h>
8 
9 #if ENV_PNP_SIMPLE_DEVICE
10 
12  pnp_devfn_t dev, uint8_t reg, uint8_t value)
13 {
14  pnp_write_index(dev >> 8, reg, value);
15 }
16 
18  pnp_devfn_t dev, uint8_t reg)
19 {
20  return pnp_read_index(dev >> 8, reg);
21 }
22 
24  pnp_devfn_t dev, uint8_t reg, uint8_t unset, uint8_t set)
25 {
26  pnp_unset_and_set_index(dev >> 8, reg, unset, set);
27 }
28 
29 static __always_inline
31 {
32  unsigned int device = dev & 0xff;
33  pnp_write_config(dev, 0x07, device);
34 }
35 
36 static __always_inline
37 void pnp_set_enable(pnp_devfn_t dev, int enable)
38 {
39  pnp_write_config(dev, PNP_IDX_EN, enable?0x1:0x0);
40 }
41 
42 static __always_inline
44 {
45  return !!pnp_read_config(dev, PNP_IDX_EN);
46 }
47 
48 static __always_inline
49 void pnp_set_iobase(pnp_devfn_t dev, unsigned int index, unsigned int iobase)
50 {
51  pnp_write_config(dev, index + 0, (iobase >> 8) & 0xff);
52  pnp_write_config(dev, index + 1, iobase & 0xff);
53 }
54 
55 static __always_inline
56 uint16_t pnp_read_iobase(pnp_devfn_t dev, unsigned int index)
57 {
58  return ((uint16_t)(pnp_read_config(dev, index)) << 8)
59  | pnp_read_config(dev, index + 1);
60 }
61 
62 static __always_inline
63 void pnp_set_irq(pnp_devfn_t dev, unsigned int index, unsigned int irq)
64 {
65  pnp_write_config(dev, index, irq);
66 }
67 
68 static __always_inline
69 void pnp_set_drq(pnp_devfn_t dev, unsigned int index, unsigned int drq)
70 {
71  pnp_write_config(dev, index, drq & 0xff);
72 }
73 
74 #endif
75 
76 #endif
pte_t value
Definition: mmu.c:91
#define __always_inline
Definition: compiler.h:35
static void pnp_write_index(u16 port, u8 reg, u8 value)
Definition: pnp.h:132
static u8 pnp_read_index(u16 port, u8 reg)
Definition: pnp.h:114
static void pnp_unset_and_set_index(u16 port, u8 reg, u8 unset, u8 set)
Definition: pnp.h:161
#define PNP_IDX_EN
Definition: pnp_def.h:4
int pnp_read_enable(struct device *dev)
Definition: pnp_device.c:81
void pnp_set_irq(struct device *dev, u8 index, u8 irq)
Definition: pnp_device.c:100
void pnp_set_logical_device(struct device *dev)
Definition: pnp_device.c:59
void pnp_set_enable(struct device *dev, int enable)
Definition: pnp_device.c:64
void pnp_set_drq(struct device *dev, u8 index, u8 drq)
Definition: pnp_device.c:106
u8 pnp_read_config(struct device *dev, u8 reg)
Definition: pnp_device.c:44
void pnp_unset_and_set_config(struct device *dev, u8 reg, u8 unset, u8 set)
Definition: pnp_device.c:50
void pnp_set_iobase(struct device *dev, u8 index, u16 iobase)
Definition: pnp_device.c:93
void pnp_write_config(struct device *dev, u8 reg, u8 value)
Definition: pnp_device.c:38
u32 pnp_devfn_t
Definition: pnp_type.h:8
unsigned short uint16_t
Definition: stdint.h:11
unsigned char uint8_t
Definition: stdint.h:8
Definition: device.h:107