Skip to content

Commit 3b1ce1e

Browse files
authored
[components][drivers]legacy fdt (#9062)
* legacy fdt * update fdt
1 parent 7250301 commit 3b1ce1e

36 files changed

+379
-217
lines changed

components/drivers/Kconfig

-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ rsource "ktime/Kconfig"
3030
rsource "clk/Kconfig"
3131
rsource "hwtimer/Kconfig"
3232
rsource "usb/Kconfig"
33-
rsource "fdt/Kconfig"
3433

3534
endmenu

components/drivers/fdt/Kconfig

Whitespace-only changes.

components/legacy/Kconfig

+2-200
Original file line numberDiff line numberDiff line change
@@ -1,200 +1,2 @@
1-
menu "Using USB legacy version"
2-
config RT_USING_USB
3-
bool
4-
default n
5-
6-
config RT_USING_USB_HOST
7-
bool "Using USB host"
8-
default n
9-
select RT_USING_USB
10-
11-
if RT_USING_USB_HOST
12-
config RT_USBH_MSTORAGE
13-
bool "Enable Udisk Drivers"
14-
default n
15-
if RT_USBH_MSTORAGE
16-
config UDISK_MOUNTPOINT
17-
string "Udisk mount dir"
18-
default "/"
19-
endif
20-
config RT_USBH_HID
21-
bool "Enable HID Drivers"
22-
default n
23-
if RT_USBH_HID
24-
config RT_USBH_HID_MOUSE
25-
bool "Enable HID mouse protocol"
26-
default n
27-
config RT_USBH_HID_KEYBOARD
28-
bool "Enable HID keyboard protocol"
29-
default n
30-
endif
31-
endif
32-
config RT_USING_USB_DEVICE
33-
bool "Using USB device"
34-
default n
35-
select RT_USING_USB
36-
37-
if RT_USING_USB_DEVICE || RT_USING_USB_HOST
38-
config RT_USBD_THREAD_STACK_SZ
39-
int "usb thread stack size"
40-
default 4096
41-
endif
42-
if RT_USING_USB_DEVICE
43-
config USB_VENDOR_ID
44-
hex "USB Vendor ID"
45-
default 0x0FFE
46-
config USB_PRODUCT_ID
47-
hex "USB Product ID"
48-
default 0x0001
49-
50-
config RT_USB_DEVICE_COMPOSITE
51-
bool "Enable composite device"
52-
default n
53-
choice
54-
prompt "Device type"
55-
default _RT_USB_DEVICE_NONE
56-
depends on !RT_USB_DEVICE_COMPOSITE
57-
config _RT_USB_DEVICE_NONE
58-
bool "Using custom class by register interface"
59-
select RT_USB_DEVICE_NONE
60-
config _RT_USB_DEVICE_CDC
61-
bool "Enable to use device as CDC device"
62-
select RT_USB_DEVICE_CDC
63-
config _RT_USB_DEVICE_MSTORAGE
64-
bool "Enable to use device as Mass Storage device"
65-
select RT_USB_DEVICE_MSTORAGE
66-
config _RT_USB_DEVICE_HID
67-
bool "Enable to use device as HID device"
68-
select RT_USB_DEVICE_HID
69-
config _RT_USB_DEVICE_RNDIS
70-
bool "Enable to use device as rndis device"
71-
select RT_USB_DEVICE_RNDIS
72-
depends on RT_USING_LWIP
73-
config _RT_USB_DEVICE_ECM
74-
bool "Enable to use device as ecm device"
75-
select RT_USB_DEVICE_ECM
76-
depends on RT_USING_LWIP
77-
config _RT_USB_DEVICE_WINUSB
78-
bool "Enable to use device as winusb device"
79-
select RT_USB_DEVICE_WINUSB
80-
config _RT_USB_DEVICE_AUDIO
81-
bool "Enable to use device as audio device"
82-
select RT_USB_DEVICE_AUDIO
83-
endchoice
84-
if RT_USB_DEVICE_COMPOSITE
85-
config RT_USB_DEVICE_CDC
86-
bool "Enable to use device as CDC device"
87-
default n
88-
config RT_USB_DEVICE_NONE
89-
bool
90-
default y
91-
config RT_USB_DEVICE_MSTORAGE
92-
bool "Enable to use device as Mass Storage device"
93-
default n
94-
config RT_USB_DEVICE_HID
95-
bool "Enable to use device as HID device"
96-
default n
97-
config RT_USB_DEVICE_RNDIS
98-
bool "Enable to use device as rndis device"
99-
default n
100-
depends on RT_USING_LWIP
101-
config RT_USB_DEVICE_ECM
102-
bool "Enable to use device as ecm device"
103-
default n
104-
depends on RT_USING_LWIP
105-
config RT_USB_DEVICE_WINUSB
106-
bool "Enable to use device as winusb device"
107-
default n
108-
config RT_USB_DEVICE_AUDIO
109-
bool "Enable to use device as audio device"
110-
default n
111-
endif
112-
if RT_USB_DEVICE_CDC
113-
config RT_VCOM_TASK_STK_SIZE
114-
int "virtual com thread stack size"
115-
default 512
116-
config RT_CDC_RX_BUFSIZE
117-
int "virtual com rx buffer size"
118-
default 128
119-
config RT_VCOM_TX_USE_DMA
120-
bool "Enable to use dma for vcom tx"
121-
default n
122-
config RT_VCOM_SERNO
123-
string "serial number of virtual com"
124-
default "32021919830108"
125-
config RT_VCOM_SER_LEN
126-
int "serial number length of virtual com"
127-
default 14
128-
config RT_VCOM_TX_TIMEOUT
129-
int "tx timeout(ticks) of virtual com"
130-
default 1000
131-
endif
132-
if RT_USB_DEVICE_WINUSB
133-
config RT_WINUSB_GUID
134-
string "Guid for winusb"
135-
default "{6860DC3C-C05F-4807-8807-1CA861CC1D66}"
136-
endif
137-
if RT_USB_DEVICE_MSTORAGE
138-
config RT_USB_MSTORAGE_DISK_NAME
139-
string "msc class disk name"
140-
default "flash0"
141-
endif
142-
143-
if RT_USB_DEVICE_RNDIS
144-
config RNDIS_DELAY_LINK_UP
145-
bool "Delay linkup media connection"
146-
select RT_USING_TIMER_SOFT
147-
default n
148-
endif
149-
150-
if RT_USB_DEVICE_HID
151-
config RT_USB_DEVICE_HID_KEYBOARD
152-
bool "Use to HID device as Keyboard"
153-
default n
154-
if RT_USB_DEVICE_HID_KEYBOARD
155-
config RT_USB_DEVICE_HID_KEYBOARD_NUMBER
156-
int "Number of Keyboard(max 3)"
157-
default 1
158-
range 1 3
159-
endif
160-
config RT_USB_DEVICE_HID_MOUSE
161-
bool "Use to HID device as Mouse"
162-
default n
163-
config RT_USB_DEVICE_HID_GENERAL
164-
bool "Use to HID device as General HID device"
165-
default y
166-
if RT_USB_DEVICE_HID_GENERAL
167-
config RT_USB_DEVICE_HID_GENERAL_OUT_REPORT_LENGTH
168-
int "General HID device out report length"
169-
default 63
170-
range 0 63
171-
172-
config RT_USB_DEVICE_HID_GENERAL_IN_REPORT_LENGTH
173-
int "General HID device in report length"
174-
default 63
175-
range 0 63
176-
endif
177-
config RT_USB_DEVICE_HID_MEDIA
178-
bool "Use to HID device as media keyboard"
179-
default y
180-
endif
181-
if RT_USB_DEVICE_AUDIO
182-
config RT_USB_DEVICE_AUDIO_MIC
183-
bool "Use usb mic device as audio device"
184-
default n
185-
if RT_USB_DEVICE_AUDIO_MIC
186-
config RT_USBD_MIC_DEVICE_NAME
187-
string "audio mic device name"
188-
default "mic0"
189-
endif
190-
config RT_USB_DEVICE_AUDIO_SPEAKER
191-
bool "Use usb speaker device as audio device"
192-
default n
193-
if RT_USB_DEVICE_AUDIO_SPEAKER
194-
config RT_USBD_SPEAKER_DEVICE_NAME
195-
string "audio speaker device name"
196-
default "sound0"
197-
endif
198-
endif
199-
endif
200-
endmenu
1+
rsource "usb/Kconfig"
2+
rsource "fdt/Kconfig"

components/legacy/fdt/Kconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
config RT_USING_FDT
2+
bool "Using fdt legacy version"
3+
default n
4+
if RT_USING_FDT
5+
config RT_USING_FDTLIB
6+
bool "Using fdt lib for device drivers"
7+
default y
8+
config RT_USING_FDT_FWNODE
9+
bool "Using fdt fwnode for device drivers"
10+
default n
11+
config FDT_USING_DEBUG
12+
bool "Using fdt debug function "
13+
default n
14+
15+
endif
File renamed without changes.
File renamed without changes.
+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#ifndef __DTB_FWNODE_H__
2+
#define __DTB_FWNODE_H__
3+
4+
#include "libfdt_env.h"
5+
#include <rtthread.h>
6+
#include <stdint.h>
7+
#include <stdbool.h>
8+
9+
struct fwnode_operations;
10+
struct rt_device;
11+
12+
#define FWNODE_FLAG_LINKS_ADDED 0x01
13+
#define FWNODE_FLAG_NOT_DEVICE 0x02
14+
#define FWNODE_FLAG_INITIALIZED 0x04
15+
16+
#define NR_FWNODE_REFERENCE_ARGS 8
17+
18+
struct fwnode_handle
19+
{
20+
struct fwnode_handle *secondary;
21+
const struct fwnode_operations *ops;
22+
struct rt_device *dev;
23+
struct rt_list_node suppliers;
24+
struct rt_list_node consumers;
25+
uint8_t flags;
26+
};
27+
28+
struct fwnode_link
29+
{
30+
struct fwnode_handle *supplier;
31+
struct rt_list_node s_hook;
32+
struct fwnode_handle *consumer;
33+
struct rt_list_node c_hook;
34+
};
35+
36+
struct fwnode_endpoint
37+
{
38+
unsigned int port;
39+
unsigned int id;
40+
const struct fwnode_handle *local_fwnode;
41+
};
42+
43+
struct fwnode_reference_args
44+
{
45+
struct fwnode_handle *fwnode;
46+
unsigned int nargs;
47+
uint64_t args[NR_FWNODE_REFERENCE_ARGS];
48+
};
49+
50+
struct fwnode_operations
51+
{
52+
struct fwnode_handle *(*get)(struct fwnode_handle *fwnode);
53+
void (*put)(struct fwnode_handle *fwnode);
54+
bool (*device_is_available)(const struct fwnode_handle *fwnode);
55+
const void *(*device_get_match_data)(const struct fwnode_handle *fwnode,
56+
const struct rt_device *dev);
57+
bool (*property_present)(const struct fwnode_handle *fwnode,
58+
const char *propname);
59+
int (*property_read_int_array)(const struct fwnode_handle *fwnode,
60+
const char *propname,
61+
unsigned int elem_size, void *val,
62+
size_t nval);
63+
int (*property_read_string_array)(const struct fwnode_handle *fwnode_handle,
64+
const char *propname, const char **val,
65+
size_t nval);
66+
const char *(*get_name)(const struct fwnode_handle *fwnode);
67+
const char *(*get_name_prefix)(const struct fwnode_handle *fwnode);
68+
struct fwnode_handle *(*get_parent)(const struct fwnode_handle *fwnode);
69+
struct fwnode_handle *(*get_next_child_node)(const struct fwnode_handle *fwnode,
70+
struct fwnode_handle *child);
71+
struct fwnode_handle *(*get_named_child_node)(const struct fwnode_handle *fwnode,
72+
const char *name);
73+
int (*get_reference_args)(const struct fwnode_handle *fwnode,
74+
const char *prop, const char *nargs_prop,
75+
unsigned int nargs, unsigned int index,
76+
struct fwnode_reference_args *args);
77+
struct fwnode_handle *(*graph_get_next_endpoint)(const struct fwnode_handle *fwnode,
78+
struct fwnode_handle *prev);
79+
struct fwnode_handle *(*graph_get_remote_endpoint)(const struct fwnode_handle *fwnode);
80+
struct fwnode_handle *(*graph_get_port_parent)(struct fwnode_handle *fwnode);
81+
int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,
82+
struct fwnode_endpoint *endpoint);
83+
int (*add_links)(struct fwnode_handle *fwnode);
84+
};
85+
86+
#define fwnode_has_op(fwnode, op) \
87+
((fwnode) && (fwnode)->ops && (fwnode)->ops->op)
88+
#define fwnode_call_int_op(fwnode, op, ...) \
89+
(fwnode ? (fwnode_has_op(fwnode, op) ? (fwnode)->ops->op(fwnode, ##__VA_ARGS__) : -ENXIO) : -EINVAL)
90+
91+
#define fwnode_call_bool_op(fwnode, op, ...) \
92+
(fwnode_has_op(fwnode, op) ? (fwnode)->ops->op(fwnode, ##__VA_ARGS__) : false)
93+
94+
#define fwnode_call_ptr_op(fwnode, op, ...) \
95+
(fwnode_has_op(fwnode, op) ? (fwnode)->ops->op(fwnode, ##__VA_ARGS__) : NULL)
96+
#define fwnode_call_void_op(fwnode, op, ...) \
97+
do \
98+
{ \
99+
if (fwnode_has_op(fwnode, op)) \
100+
(fwnode)->ops->op(fwnode, ##__VA_ARGS__); \
101+
} while (false)
102+
103+
#define get_dev_from_fwnode(fwnode) ((fwnode)->dev)
104+
105+
static inline void fwnode_init(struct fwnode_handle *fwnode,
106+
const struct fwnode_operations *ops)
107+
{
108+
fwnode->ops = ops;
109+
rt_list_init(&fwnode->consumers);
110+
rt_list_init(&fwnode->suppliers);
111+
}
112+
113+
static inline void fwnode_dev_initialized(struct fwnode_handle *fwnode,
114+
bool initialized)
115+
{
116+
if (!fwnode)
117+
return;
118+
119+
if (initialized)
120+
fwnode->flags |= FWNODE_FLAG_INITIALIZED;
121+
else
122+
fwnode->flags &= ~FWNODE_FLAG_INITIALIZED;
123+
}
124+
125+
#endif //__DTB_FWNODE_H__

0 commit comments

Comments
 (0)