• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 // Copyright (C) 2022 Beken Corporation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <common/bk_include.h>
16 #include "bk_arm_arch.h"
17 #include "dd_pub.h"
18 #include "bk_sdio.h"
19 #include "bk_uart.h"
20 #include "bk_gpio.h"
21 #include "bk_icu.h"
22 #include "bk_usb.h"
23 #if CONFIG_FLASH_ORIGIN_API
24 #include "bk_flash.h"
25 #endif
26 #include "bk_fft.h"
27 #include "bk_i2s.h"
28 #include "bk_saradc.h"
29 #include "bk_irda.h"
30 #include "bk_mac_phy_bypass.h"
31 #include "bk_timer.h"
32 #include "bk_sys_ctrl.h"
33 
34 #if CONFIG_DSP
35 #include "bk_dsp.h"
36 #endif
37 
38 #if CONFIG_MAILBOX
39 #include "bk_mailbox.h"
40 #include <driver/mailbox.h>
41 #endif
42 
43 #if (CONFIG_BT)
44 #include "bk_bt.h"
45 #endif
46 
47 #if CONFIG_AUDIO
48 #include "audio_pub.h"
49 #endif
50 
51 #if CONFIG_SDCARD_HOST
52 #include "sdcard_pub.h"
53 #endif
54 
55 #if CONFIG_SDCARD_HOST
56 #include "sdcard_pub.h"
57 #endif
58 
59 #if CONFIG_BLE
60 #include <modules/ble.h>
61 #endif
62 
63 typedef struct _dd_init_s_ {
64 	dd_device_type dev;
65 
66 	void (*init)(void);
67 	void (*exit)(void);
68 } DD_INIT_S;
69 
70 #if (!CONFIG_SOC_BK7256XX)
71 static const DD_INIT_S dd_init_tbl[] = {
72 	/* name*/              /* init function*/          /* exit function*/
73 #if !CONFIG_SYSTEM_CTRL
74 	{DD_DEV_TYPE_SCTRL,        sctrl_init,                 sctrl_exit},
75 #endif
76 
77 #if CONFIG_FLASH
78 #if CONFIG_FLASH_ORIGIN_API
79 	{DD_DEV_TYPE_FLASH,        flash_init,                 flash_exit},
80 #endif
81 #endif
82 
83 #if CONFIG_DSP
84 	{DD_DEV_TYPE_DSP,          dsp_init,                   dsp_exit},
85 #endif
86 
87 #if CONFIG_MAILBOX
88 	{DD_DEV_TYPE_MAILBOX,      mailbox_driver_init,        mailbox_driver_deinit},
89 #endif
90 
91 #if (CONFIG_BT)
92 	{DD_DEV_TYPE_BT,           bt_init,                    bt_exit},
93 #endif
94 
95 #if CONFIG_AUDIO
96 	{DD_DEV_TYPE_AUD_DAC,      audio_init,                 audio_exit},
97 #endif
98 
99 #if CONFIG_SDIO || CONFIG_SDIO_TRANS
100 	{DD_DEV_TYPE_SDIO,         sdio_init,                  sdio_exit},
101 #endif
102 
103 #if CONFIG_USB
104 	{DD_DEV_TYPE_USB,          usb_init,                   usb_exit},
105 #endif
106 
107 #if CONFIG_USB_PLUG_IN_OUT
108 	{DD_DEV_TYPE_USB_PLUG,     usb_plug_inout_init,        usb_plug_inout_exit},
109 #endif
110 
111 #if CONFIG_FFT
112 	{DD_DEV_TYPE_FFT,          fft_init,                   fft_exit},
113 #endif
114 
115 #if CONFIG_SUPPORT_IRDA
116 	{DD_DEV_TYPE_IRDA,         irda_init,                  irda_exit},
117 #endif
118 
119 #if CONFIG_MAC_PHY_BYPASS
120 	{DD_DEV_TYPE_MPB,          mpb_init,                   mpb_exit},
121 #endif
122 
123 #if CONFIG_SDCARD_HOST
124 	{DD_DEV_TYPE_SDCARD,       sdcard_init,                sdcard_exit},
125 #endif
126 
127 	{DD_DEV_TYPE_NONE,         NULLPTR,                    NULLPTR}
128 };
129 #else
130 static const DD_INIT_S dd_init_tbl[] = {
131 	/* name*/              /* init function*/          /* exit function*/
132 #if CONFIG_FLASH
133 #if CONFIG_FLASH_ORIGIN_API
134 	{DD_DEV_TYPE_FLASH,        flash_init,                 flash_exit},
135 #endif
136 #endif
137 };
138 #endif
139 
g_dd_init(void)140 void g_dd_init(void)
141 {
142 	UINT32 i;
143 	UINT32 tbl_count;
144 	const DD_INIT_S *dd_element;
145 
146 	tbl_count = sizeof(dd_init_tbl) / sizeof(DD_INIT_S);
147 	for (i = 0; i < tbl_count; i ++) {
148 		dd_element = &dd_init_tbl[i];
149 		if (dd_element->dev && dd_element->init)
150 			(dd_element->init)();
151 		else
152 			return;
153 	}
154 }
155 
g_dd_exit(void)156 void g_dd_exit(void)
157 {
158 	UINT32 i;
159 	UINT32 tbl_count;
160 	const DD_INIT_S *dd_element;
161 
162 	tbl_count = sizeof(dd_init_tbl) / sizeof(DD_INIT_S);
163 	for (i = 0; i < tbl_count; i ++) {
164 		dd_element = &dd_init_tbl[i];
165 		if (dd_element->dev && dd_element->exit)
166 			(dd_element->exit)();
167 		else
168 			return;
169 	}
170 }
171 
172