]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/extres/clk/clkdev_if.m
Update to bmake-201802222
[FreeBSD/FreeBSD.git] / sys / dev / extres / clk / clkdev_if.m
1 #-
2 # Copyright 2016 Michal Meloun <mmel@FreeBSD.org>
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 # SUCH DAMAGE.
25 #
26 # $FreeBSD$
27 #
28
29 #include <machine/bus.h>
30
31 INTERFACE clkdev;
32
33 CODE {
34         #include <sys/systm.h>
35         #include <sys/bus.h>
36         static int
37         clkdev_default_write_4(device_t dev, bus_addr_t addr, uint32_t val)
38         {
39                 device_t pdev;
40
41                 pdev = device_get_parent(dev);
42                 if (pdev == NULL)
43                         return (ENXIO);
44
45                 return (CLKDEV_WRITE_4(pdev, addr, val));
46         }
47
48         static int
49         clkdev_default_read_4(device_t dev, bus_addr_t addr, uint32_t *val)
50         {
51                 device_t pdev;
52
53                 pdev = device_get_parent(dev);
54                 if (pdev == NULL)
55                         return (ENXIO);
56
57                 return (CLKDEV_READ_4(pdev, addr, val));
58         }
59
60         static int
61         clkdev_default_modify_4(device_t dev, bus_addr_t addr,
62             uint32_t clear_mask, uint32_t set_mask)
63         {
64                 device_t pdev;
65
66                 pdev = device_get_parent(dev);
67                 if (pdev == NULL)
68                         return (ENXIO);
69
70                 return (CLKDEV_MODIFY_4(pdev, addr, clear_mask, set_mask));
71         }
72
73         static void
74         clkdev_default_device_lock(device_t dev)
75         {
76                 device_t pdev;
77
78                 pdev = device_get_parent(dev);
79                 if (pdev == NULL)
80                         panic("clkdev_device_lock not implemented");
81
82                 CLKDEV_DEVICE_LOCK(pdev);
83         }
84
85         static void
86         clkdev_default_device_unlock(device_t dev)
87         {
88                 device_t pdev;
89
90                 pdev = device_get_parent(dev);
91                 if (pdev == NULL)
92                         panic("clkdev_device_unlock not implemented");
93
94                 CLKDEV_DEVICE_UNLOCK(pdev);
95         }
96 }
97
98 #
99 # Write single register
100 #
101 METHOD int write_4 {
102         device_t        dev;
103         bus_addr_t      addr;
104         uint32_t        val;
105 } DEFAULT clkdev_default_write_4;
106
107 #
108 # Read single register
109 #
110 METHOD int read_4 {
111         device_t        dev;
112         bus_addr_t      addr;
113         uint32_t        *val;
114 } DEFAULT clkdev_default_read_4;
115
116 #
117 # Modify single register
118 #
119 METHOD int modify_4 {
120         device_t        dev;
121         bus_addr_t      addr;
122         uint32_t        clear_mask;
123         uint32_t        set_mask;
124 } DEFAULT clkdev_default_modify_4;
125
126 #
127 # Get exclusive access to underlying device
128 #
129 METHOD void device_lock {
130         device_t        dev;
131 } DEFAULT clkdev_default_device_lock;
132
133 #
134 # Release exclusive access to underlying device
135 #
136 METHOD void device_unlock {
137         device_t        dev;
138 } DEFAULT clkdev_default_device_unlock;