sde_rsc.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #define pr_fmt(fmt) "[sde_rsc:%s:%d]: " fmt, __func__, __LINE__
  6. #include <linux/kernel.h>
  7. #include <linux/debugfs.h>
  8. #include <linux/of.h>
  9. #include <linux/string.h>
  10. #include <linux/of_address.h>
  11. #include <linux/component.h>
  12. #include <linux/slab.h>
  13. #include <linux/mutex.h>
  14. #include <linux/of_platform.h>
  15. #include <linux/module.h>
  16. #include <soc/qcom/rpmh.h>
  17. #include <drm/drmP.h>
  18. #include <drm/drm_irq.h>
  19. #include "sde_rsc_priv.h"
  20. #include "sde_dbg.h"
  21. #include "sde_trace.h"
  22. #define SDE_RSC_DRV_DBG_NAME "sde_rsc_drv"
  23. #define SDE_RSC_WRAPPER_DBG_NAME "sde_rsc_wrapper"
  24. #define SINGLE_TCS_EXECUTION_TIME_V1 1064000
  25. #define SINGLE_TCS_EXECUTION_TIME_V2 930000
  26. #define RSC_MODE_INSTRUCTION_TIME 100
  27. #define RSC_MODE_THRESHOLD_OVERHEAD 2700
  28. /**
  29. * rsc_min_threshold will be set to MIN_THRESHOLD_OVERHEAD_TIME which
  30. * takes into account back off time + overhead from RSC/RSC_WRAPPER. The
  31. * overhead buffer time is required to be greater than 14. Program it
  32. * with a higher value (3.3 ms), so it has sufficient time to complete
  33. * the sequence in rare cases.
  34. */
  35. #define MIN_THRESHOLD_OVERHEAD_TIME 64
  36. #define DEFAULT_PANEL_FPS 60
  37. #define DEFAULT_PANEL_JITTER_NUMERATOR 2
  38. #define DEFAULT_PANEL_JITTER_DENOMINATOR 1
  39. #define DEFAULT_PANEL_PREFILL_LINES 25
  40. #define DEFAULT_PANEL_VTOTAL (480 + DEFAULT_PANEL_PREFILL_LINES)
  41. #define TICKS_IN_NANO_SECOND 1000000000
  42. #define MAX_BUFFER_SIZE 256
  43. #define CMD_MODE_SWITCH_SUCCESS 0xFFFF
  44. #define VID_MODE_SWITCH_SUCCESS 0xFFFE
  45. #define CLK_MODE_SWITCH_SUCCESS 0xFFFD
  46. #define STATE_UPDATE_NOT_ALLOWED 0xFFFC
  47. /* Primary panel worst case VSYNC expected to be no less than 30fps */
  48. #define PRIMARY_VBLANK_WORST_CASE_MS 34
  49. #define DEFAULT_PANEL_MIN_V_PREFILL 35
  50. static struct sde_rsc_priv *rsc_prv_list[MAX_RSC_COUNT];
  51. static struct device *rpmh_dev[MAX_RSC_COUNT];
  52. static void sde_rsc_set_data_bus_mode(struct sde_power_handle *phandle, u32 tag)
  53. {
  54. int i = 0, j = 0;
  55. for (i = 0; i < SDE_POWER_HANDLE_DBUS_ID_MAX; i++) {
  56. if (!phandle->data_bus_handle[i].bus_active_only)
  57. continue;
  58. for (j = 0; j < phandle->data_bus_handle[i].data_paths_cnt; j++)
  59. icc_set_tag(phandle->data_bus_handle[i].data_bus_hdl[j],
  60. tag);
  61. }
  62. }
  63. /**
  64. * sde_rsc_client_create() - create the client for sde rsc.
  65. * Different displays like DSI, HDMI, DP, WB, etc should call this
  66. * api to register their vote for rpmh. They still need to vote for
  67. * power handle to get the clocks.
  68. * @rsc_index: A client will be created on this RSC. As of now only
  69. * SDE_RSC_INDEX is valid rsc index.
  70. * @name: Caller needs to provide some valid string to identify
  71. * the client. "primary", "dp", "hdmi" are suggested name.
  72. * @is_primary: Caller needs to provide information if client is primary
  73. * or not. Primary client votes will be redirected to
  74. * display rsc.
  75. * @vsync_source: This parameter is only valid for primary display. It provides
  76. * vsync source information
  77. *
  78. * Return: client node pointer.
  79. */
  80. struct sde_rsc_client *sde_rsc_client_create(u32 rsc_index, char *client_name,
  81. enum sde_rsc_client_type client_type, u32 vsync_source)
  82. {
  83. struct sde_rsc_client *client;
  84. struct sde_rsc_priv *rsc;
  85. static int id;
  86. if (!client_name) {
  87. pr_err("client name is null- not supported\n");
  88. return ERR_PTR(-EINVAL);
  89. } else if (rsc_index >= MAX_RSC_COUNT) {
  90. pr_err("invalid rsc index\n");
  91. return ERR_PTR(-EINVAL);
  92. } else if (!rsc_prv_list[rsc_index]) {
  93. pr_debug("rsc not probed yet or not available\n");
  94. return NULL;
  95. }
  96. rsc = rsc_prv_list[rsc_index];
  97. client = kzalloc(sizeof(struct sde_rsc_client), GFP_KERNEL);
  98. if (!client)
  99. return ERR_PTR(-ENOMEM);
  100. mutex_lock(&rsc->client_lock);
  101. strlcpy(client->name, client_name, MAX_RSC_CLIENT_NAME_LEN);
  102. client->current_state = SDE_RSC_IDLE_STATE;
  103. client->rsc_index = rsc_index;
  104. client->id = id;
  105. client->client_type = client_type;
  106. if (client->client_type == SDE_RSC_PRIMARY_DISP_CLIENT) {
  107. rsc->primary_client = client;
  108. rsc->vsync_source = vsync_source;
  109. }
  110. pr_debug("client %s rsc index:%d client_type:%d\n", client_name,
  111. rsc_index, client->client_type);
  112. list_add(&client->list, &rsc->client_list);
  113. id++;
  114. mutex_unlock(&rsc->client_lock);
  115. return client;
  116. }
  117. EXPORT_SYMBOL(sde_rsc_client_create);
  118. /**
  119. * sde_rsc_client_destroy() - Destroy the sde rsc client.
  120. *
  121. * @client: Client pointer provided by sde_rsc_client_create().
  122. *
  123. * Return: none
  124. */
  125. void sde_rsc_client_destroy(struct sde_rsc_client *client)
  126. {
  127. struct sde_rsc_priv *rsc;
  128. enum sde_rsc_state state;
  129. if (!client) {
  130. pr_debug("invalid client\n");
  131. goto end;
  132. } else if (client->rsc_index >= MAX_RSC_COUNT) {
  133. pr_err("invalid rsc index\n");
  134. goto end;
  135. }
  136. pr_debug("client %s destroyed\n", client->name);
  137. rsc = rsc_prv_list[client->rsc_index];
  138. if (!rsc)
  139. goto end;
  140. mutex_lock(&rsc->client_lock);
  141. state = client->current_state;
  142. mutex_unlock(&rsc->client_lock);
  143. if (state != SDE_RSC_IDLE_STATE) {
  144. int wait_vblank_crtc_id;
  145. sde_rsc_client_state_update(client, SDE_RSC_IDLE_STATE, NULL,
  146. SDE_RSC_INVALID_CRTC_ID, &wait_vblank_crtc_id);
  147. /* if vblank wait required at shutdown, use a simple sleep */
  148. if (wait_vblank_crtc_id != SDE_RSC_INVALID_CRTC_ID) {
  149. pr_err("unexpected sleep required on crtc %d at rsc client destroy\n",
  150. wait_vblank_crtc_id);
  151. SDE_EVT32(client->id, state, rsc->current_state,
  152. client->crtc_id, wait_vblank_crtc_id,
  153. SDE_EVTLOG_ERROR);
  154. msleep(PRIMARY_VBLANK_WORST_CASE_MS);
  155. }
  156. }
  157. mutex_lock(&rsc->client_lock);
  158. list_del_init(&client->list);
  159. mutex_unlock(&rsc->client_lock);
  160. kfree(client);
  161. end:
  162. return;
  163. }
  164. EXPORT_SYMBOL(sde_rsc_client_destroy);
  165. struct sde_rsc_event *sde_rsc_register_event(int rsc_index, uint32_t event_type,
  166. void (*cb_func)(uint32_t event_type, void *usr), void *usr)
  167. {
  168. struct sde_rsc_event *evt;
  169. struct sde_rsc_priv *rsc;
  170. if (rsc_index >= MAX_RSC_COUNT) {
  171. pr_err("invalid rsc index:%d\n", rsc_index);
  172. return ERR_PTR(-EINVAL);
  173. } else if (!rsc_prv_list[rsc_index]) {
  174. pr_err("rsc idx:%d not probed yet or not available\n",
  175. rsc_index);
  176. return ERR_PTR(-EINVAL);
  177. } else if (!cb_func || !event_type) {
  178. pr_err("no event or cb func\n");
  179. return ERR_PTR(-EINVAL);
  180. }
  181. rsc = rsc_prv_list[rsc_index];
  182. evt = kzalloc(sizeof(struct sde_rsc_event), GFP_KERNEL);
  183. if (!evt)
  184. return ERR_PTR(-ENOMEM);
  185. evt->event_type = event_type;
  186. evt->rsc_index = rsc_index;
  187. evt->usr = usr;
  188. evt->cb_func = cb_func;
  189. pr_debug("event register type:%d rsc index:%d\n",
  190. event_type, rsc_index);
  191. mutex_lock(&rsc->client_lock);
  192. list_add(&evt->list, &rsc->event_list);
  193. mutex_unlock(&rsc->client_lock);
  194. return evt;
  195. }
  196. EXPORT_SYMBOL(sde_rsc_register_event);
  197. void sde_rsc_unregister_event(struct sde_rsc_event *event)
  198. {
  199. struct sde_rsc_priv *rsc;
  200. if (!event) {
  201. pr_debug("invalid event client\n");
  202. goto end;
  203. } else if (event->rsc_index >= MAX_RSC_COUNT) {
  204. pr_err("invalid rsc index\n");
  205. goto end;
  206. }
  207. pr_debug("event client destroyed\n");
  208. rsc = rsc_prv_list[event->rsc_index];
  209. if (!rsc)
  210. goto end;
  211. mutex_lock(&rsc->client_lock);
  212. list_del_init(&event->list);
  213. mutex_unlock(&rsc->client_lock);
  214. kfree(event);
  215. end:
  216. return;
  217. }
  218. EXPORT_SYMBOL(sde_rsc_unregister_event);
  219. bool is_sde_rsc_available(int rsc_index)
  220. {
  221. if (rsc_index >= MAX_RSC_COUNT) {
  222. pr_err("invalid rsc index:%d\n", rsc_index);
  223. return false;
  224. } else if (!rsc_prv_list[rsc_index]) {
  225. pr_debug("rsc idx:%d not probed yet or not available\n",
  226. rsc_index);
  227. return false;
  228. }
  229. return true;
  230. }
  231. EXPORT_SYMBOL(is_sde_rsc_available);
  232. enum sde_rsc_state get_sde_rsc_current_state(int rsc_index)
  233. {
  234. struct sde_rsc_priv *rsc;
  235. if (rsc_index >= MAX_RSC_COUNT) {
  236. pr_err("invalid rsc index:%d\n", rsc_index);
  237. return SDE_RSC_IDLE_STATE;
  238. } else if (!rsc_prv_list[rsc_index]) {
  239. pr_err("rsc idx:%d not probed yet or not available\n",
  240. rsc_index);
  241. return SDE_RSC_IDLE_STATE;
  242. }
  243. rsc = rsc_prv_list[rsc_index];
  244. return rsc->current_state;
  245. }
  246. EXPORT_SYMBOL(get_sde_rsc_current_state);
  247. static u32 sde_rsc_timer_calculate(struct sde_rsc_priv *rsc,
  248. struct sde_rsc_cmd_config *cmd_config, enum sde_rsc_state state)
  249. {
  250. const u32 cxo_period_ns = 52;
  251. u64 rsc_backoff_time_ns = rsc->backoff_time_ns;
  252. u64 rsc_mode_threshold_time_ns = rsc->mode_threshold_time_ns;
  253. u64 rsc_time_slot_0_ns = rsc->time_slot_0_ns;
  254. u64 rsc_time_slot_1_ns;
  255. const u64 pdc_jitter = 20; /* 20% more */
  256. u64 frame_time_ns, frame_jitter;
  257. u64 line_time_ns, prefill_time_ns;
  258. u64 pdc_backoff_time_ns;
  259. s64 total;
  260. int ret = 0;
  261. u32 default_prefill_lines;
  262. if (cmd_config)
  263. memcpy(&rsc->cmd_config, cmd_config, sizeof(*cmd_config));
  264. /* calculate for 640x480 60 fps resolution by default */
  265. if (!rsc->cmd_config.fps)
  266. rsc->cmd_config.fps = DEFAULT_PANEL_FPS;
  267. if (!rsc->cmd_config.jitter_numer)
  268. rsc->cmd_config.jitter_numer = DEFAULT_PANEL_JITTER_NUMERATOR;
  269. if (!rsc->cmd_config.jitter_denom)
  270. rsc->cmd_config.jitter_denom = DEFAULT_PANEL_JITTER_DENOMINATOR;
  271. if (!rsc->cmd_config.vtotal)
  272. rsc->cmd_config.vtotal = DEFAULT_PANEL_VTOTAL;
  273. default_prefill_lines = (rsc->cmd_config.fps *
  274. DEFAULT_PANEL_MIN_V_PREFILL) / DEFAULT_PANEL_FPS;
  275. if ((state == SDE_RSC_CMD_STATE) || !rsc->cmd_config.prefill_lines)
  276. rsc->cmd_config.prefill_lines = default_prefill_lines;
  277. pr_debug("frame fps:%d jitter_numer:%d jitter_denom:%d vtotal:%d prefill lines:%d\n",
  278. rsc->cmd_config.fps, rsc->cmd_config.jitter_numer,
  279. rsc->cmd_config.jitter_denom, rsc->cmd_config.vtotal,
  280. rsc->cmd_config.prefill_lines);
  281. /* 1 nano second */
  282. frame_time_ns = TICKS_IN_NANO_SECOND;
  283. frame_time_ns = div_u64(frame_time_ns, rsc->cmd_config.fps);
  284. frame_jitter = frame_time_ns * rsc->cmd_config.jitter_numer;
  285. frame_jitter = div_u64(frame_jitter, rsc->cmd_config.jitter_denom);
  286. /* convert it to percentage */
  287. frame_jitter = div_u64(frame_jitter, 100);
  288. line_time_ns = frame_time_ns;
  289. line_time_ns = div_u64(line_time_ns, rsc->cmd_config.vtotal);
  290. prefill_time_ns = line_time_ns * rsc->cmd_config.prefill_lines;
  291. /* only take jitter into account for CMD mode */
  292. if (state == SDE_RSC_CMD_STATE)
  293. total = frame_time_ns - frame_jitter - prefill_time_ns;
  294. else
  295. total = frame_time_ns - prefill_time_ns;
  296. if (total < 0) {
  297. pr_err("invalid total time period time:%llu jiter_time:%llu blanking time:%llu\n",
  298. frame_time_ns, frame_jitter, prefill_time_ns);
  299. total = 0;
  300. }
  301. total = div_u64(total, cxo_period_ns);
  302. rsc->timer_config.static_wakeup_time_ns = total;
  303. pr_debug("frame time:%llu frame jiter_time:%llu\n",
  304. frame_time_ns, frame_jitter);
  305. pr_debug("line time:%llu prefill time ps:%llu\n",
  306. line_time_ns, prefill_time_ns);
  307. pr_debug("static wakeup time:%lld cxo:%u\n", total, cxo_period_ns);
  308. pdc_backoff_time_ns = rsc_backoff_time_ns;
  309. rsc_backoff_time_ns = div_u64(rsc_backoff_time_ns, cxo_period_ns);
  310. rsc->timer_config.rsc_backoff_time_ns = (u32) rsc_backoff_time_ns;
  311. pdc_backoff_time_ns *= pdc_jitter;
  312. pdc_backoff_time_ns = div_u64(pdc_backoff_time_ns, 100);
  313. rsc->timer_config.pdc_backoff_time_ns = (u32) pdc_backoff_time_ns;
  314. rsc_mode_threshold_time_ns =
  315. div_u64(rsc_mode_threshold_time_ns, cxo_period_ns);
  316. rsc->timer_config.rsc_mode_threshold_time_ns
  317. = (u32) rsc_mode_threshold_time_ns;
  318. /* time_slot_0 for mode0 latency */
  319. rsc_time_slot_0_ns = div_u64(rsc_time_slot_0_ns, cxo_period_ns);
  320. rsc->timer_config.rsc_time_slot_0_ns = (u32) rsc_time_slot_0_ns;
  321. /* time_slot_1 for mode1 latency */
  322. rsc_time_slot_1_ns = frame_time_ns;
  323. rsc_time_slot_1_ns = div_u64(rsc_time_slot_1_ns, cxo_period_ns);
  324. rsc->timer_config.rsc_time_slot_1_ns = (u32) rsc_time_slot_1_ns;
  325. /* mode 2 is infinite */
  326. rsc->timer_config.rsc_time_slot_2_ns = 0xFFFFFFFF;
  327. rsc->timer_config.min_threshold_time_ns = MIN_THRESHOLD_OVERHEAD_TIME;
  328. rsc->timer_config.bwi_threshold_time_ns =
  329. rsc->timer_config.rsc_time_slot_0_ns;
  330. /* timer update should be called with client call */
  331. if (cmd_config && rsc->hw_ops.timer_update) {
  332. ret = rsc->hw_ops.timer_update(rsc);
  333. if (ret)
  334. pr_err("sde rsc: hw timer update failed ret:%d\n", ret);
  335. /* rsc init should be called during rsc probe - one time only */
  336. } else if (rsc->hw_ops.init) {
  337. ret = rsc->hw_ops.init(rsc);
  338. if (ret)
  339. pr_err("sde rsc: hw init failed ret:%d\n", ret);
  340. }
  341. return ret;
  342. }
  343. static int sde_rsc_resource_disable(struct sde_rsc_priv *rsc)
  344. {
  345. struct sde_power_handle *phandle;
  346. struct dss_module_power *mp;
  347. if (!rsc) {
  348. pr_err("invalid drv data\n");
  349. return -EINVAL;
  350. }
  351. if (atomic_read(&rsc->resource_refcount) == 0) {
  352. pr_err("%pS: invalid rsc resource disable call\n",
  353. __builtin_return_address(0));
  354. return -EINVAL;
  355. }
  356. if (atomic_dec_return(&rsc->resource_refcount) != 0)
  357. return 0;
  358. phandle = &rsc->phandle;
  359. mp = &phandle->mp;
  360. msm_dss_enable_clk(mp->clk_config, mp->num_clk, false);
  361. if (phandle->reg_bus_hdl)
  362. sde_power_scale_reg_bus(phandle, VOTE_INDEX_DISABLE, false);
  363. msm_dss_enable_vreg(mp->vreg_config, mp->num_vreg, false);
  364. return 0;
  365. }
  366. static int sde_rsc_resource_enable(struct sde_rsc_priv *rsc)
  367. {
  368. struct sde_power_handle *phandle;
  369. struct dss_module_power *mp;
  370. int rc = 0;
  371. if (!rsc) {
  372. pr_err("invalid drv data\n");
  373. return -EINVAL;
  374. }
  375. if (atomic_inc_return(&rsc->resource_refcount) != 1)
  376. return 0;
  377. phandle = &rsc->phandle;
  378. mp = &phandle->mp;
  379. rc = msm_dss_enable_vreg(mp->vreg_config, mp->num_vreg, true);
  380. if (rc) {
  381. pr_err("failed to enable vregs rc=%d\n", rc);
  382. goto end;
  383. }
  384. if (phandle->reg_bus_hdl) {
  385. rc = sde_power_scale_reg_bus(phandle, VOTE_INDEX_LOW, false);
  386. if (rc) {
  387. pr_err("failed to set reg bus vote rc=%d\n", rc);
  388. goto reg_bus_hdl_err;
  389. }
  390. }
  391. rc = msm_dss_enable_clk(mp->clk_config, mp->num_clk, true);
  392. if (rc) {
  393. pr_err("clock enable failed rc:%d\n", rc);
  394. goto clk_err;
  395. }
  396. return rc;
  397. clk_err:
  398. if (phandle->reg_bus_hdl)
  399. sde_power_scale_reg_bus(phandle, VOTE_INDEX_DISABLE, false);
  400. reg_bus_hdl_err:
  401. msm_dss_enable_vreg(mp->vreg_config, mp->num_vreg, false);
  402. end:
  403. atomic_dec(&rsc->resource_refcount);
  404. return rc;
  405. }
  406. static int sde_rsc_switch_to_cmd(struct sde_rsc_priv *rsc,
  407. struct sde_rsc_cmd_config *config,
  408. struct sde_rsc_client *caller_client,
  409. int *wait_vblank_crtc_id)
  410. {
  411. struct sde_rsc_client *client;
  412. int rc = STATE_UPDATE_NOT_ALLOWED;
  413. if (!rsc->primary_client) {
  414. pr_err("primary client not available for cmd state switch\n");
  415. rc = -EINVAL;
  416. goto end;
  417. } else if (caller_client != rsc->primary_client) {
  418. pr_err("primary client state:%d not cmd state request\n",
  419. rsc->primary_client->current_state);
  420. rc = -EINVAL;
  421. goto end;
  422. }
  423. /* update timers - might not be available at next switch */
  424. if (config)
  425. sde_rsc_timer_calculate(rsc, config, SDE_RSC_CMD_STATE);
  426. /**
  427. * rsc clients can still send config at any time. If a config is
  428. * received during cmd_state then vsync_wait will execute with the logic
  429. * below. If a config is received when rsc is in AMC mode; A mode
  430. * switch will do the vsync wait. updated checks still support all cases
  431. * for dynamic mode switch and inline rotation.
  432. */
  433. if (rsc->current_state == SDE_RSC_CMD_STATE) {
  434. rc = 0;
  435. if (config && rsc->version < SDE_RSC_REV_3)
  436. goto vsync_wait;
  437. else
  438. goto end;
  439. }
  440. /* any non-primary clk state client blocks the cmd state switch */
  441. list_for_each_entry(client, &rsc->client_list, list)
  442. if (client->current_state == SDE_RSC_CLK_STATE &&
  443. client->client_type == SDE_RSC_EXTERNAL_DISP_CLIENT)
  444. goto end;
  445. if (rsc->hw_ops.state_update) {
  446. rc = rsc->hw_ops.state_update(rsc, SDE_RSC_CMD_STATE);
  447. if (!rc) {
  448. rpmh_mode_solver_set(rsc->rpmh_dev, true);
  449. sde_rsc_set_data_bus_mode(&rsc->phandle,
  450. QCOM_ICC_TAG_WAKE);
  451. }
  452. }
  453. vsync_wait:
  454. /* indicate wait for vsync for vid to cmd state switch & cfg update */
  455. if (!rc && (rsc->current_state == SDE_RSC_VID_STATE ||
  456. rsc->current_state == SDE_RSC_CMD_STATE)) {
  457. /* clear VSYNC timestamp for indication when update completes */
  458. if (rsc->hw_ops.hw_vsync)
  459. rsc->hw_ops.hw_vsync(rsc, VSYNC_ENABLE, NULL, 0, 0);
  460. if (!wait_vblank_crtc_id) {
  461. pr_err("invalid crtc id wait pointer, client %d\n",
  462. caller_client->id);
  463. SDE_EVT32(caller_client->id, rsc->current_state,
  464. caller_client->crtc_id,
  465. wait_vblank_crtc_id, SDE_EVTLOG_ERROR);
  466. msleep(PRIMARY_VBLANK_WORST_CASE_MS);
  467. } else {
  468. *wait_vblank_crtc_id = rsc->primary_client->crtc_id;
  469. }
  470. }
  471. end:
  472. return rc;
  473. }
  474. static int sde_rsc_switch_to_clk(struct sde_rsc_priv *rsc,
  475. int *wait_vblank_crtc_id)
  476. {
  477. struct sde_rsc_client *client;
  478. int rc = STATE_UPDATE_NOT_ALLOWED;
  479. bool multi_display_active = false;
  480. bool vid_display_active = false, cmd_display_active = false;
  481. list_for_each_entry(client, &rsc->client_list, list) {
  482. if (client->current_state == SDE_RSC_CLK_STATE &&
  483. client->client_type == SDE_RSC_EXTERNAL_DISP_CLIENT)
  484. multi_display_active = true;
  485. else if (client->current_state == SDE_RSC_VID_STATE)
  486. vid_display_active = true;
  487. else if (client->current_state == SDE_RSC_CMD_STATE)
  488. cmd_display_active = true;
  489. }
  490. pr_debug("multi_display:%d vid_display:%d cmd_display:%d\n",
  491. multi_display_active, vid_display_active, cmd_display_active);
  492. if (!multi_display_active && (vid_display_active || cmd_display_active))
  493. goto end;
  494. if (rsc->hw_ops.state_update) {
  495. rc = rsc->hw_ops.state_update(rsc, SDE_RSC_CLK_STATE);
  496. if (!rc) {
  497. rpmh_mode_solver_set(rsc->rpmh_dev, false);
  498. sde_rsc_set_data_bus_mode(&rsc->phandle,
  499. QCOM_ICC_TAG_AMC);
  500. }
  501. }
  502. /* indicate wait for vsync for cmd/vid to clk state switch */
  503. if (!rc && rsc->primary_client &&
  504. (rsc->current_state == SDE_RSC_CMD_STATE ||
  505. rsc->current_state == SDE_RSC_VID_STATE)) {
  506. /* clear VSYNC timestamp for indication when update completes */
  507. if (rsc->hw_ops.hw_vsync)
  508. rsc->hw_ops.hw_vsync(rsc, VSYNC_ENABLE, NULL, 0, 0);
  509. if (!wait_vblank_crtc_id) {
  510. pr_err("invalid crtc id wait pointer provided\n");
  511. msleep(PRIMARY_VBLANK_WORST_CASE_MS);
  512. } else {
  513. *wait_vblank_crtc_id = rsc->primary_client->crtc_id;
  514. /* increase refcount, so we wait for the next vsync */
  515. atomic_inc(&rsc->rsc_vsync_wait);
  516. SDE_EVT32(atomic_read(&rsc->rsc_vsync_wait));
  517. }
  518. } else if (atomic_read(&rsc->rsc_vsync_wait)) {
  519. SDE_EVT32(rsc->primary_client, rsc->current_state,
  520. atomic_read(&rsc->rsc_vsync_wait));
  521. /* Wait for the vsync, if the refcount is set */
  522. rc = wait_event_timeout(rsc->rsc_vsync_waitq,
  523. atomic_read(&rsc->rsc_vsync_wait) == 0,
  524. msecs_to_jiffies(PRIMARY_VBLANK_WORST_CASE_MS*2));
  525. if (!rc) {
  526. pr_err("Timeout waiting for vsync\n");
  527. rc = -ETIMEDOUT;
  528. SDE_EVT32(atomic_read(&rsc->rsc_vsync_wait), rc,
  529. SDE_EVTLOG_ERROR);
  530. } else {
  531. SDE_EVT32(atomic_read(&rsc->rsc_vsync_wait), rc);
  532. rc = 0;
  533. }
  534. }
  535. end:
  536. return rc;
  537. }
  538. static int sde_rsc_switch_to_vid(struct sde_rsc_priv *rsc,
  539. struct sde_rsc_cmd_config *config,
  540. struct sde_rsc_client *caller_client,
  541. int *wait_vblank_crtc_id)
  542. {
  543. struct sde_rsc_client *client;
  544. int rc = STATE_UPDATE_NOT_ALLOWED;
  545. if (!rsc->primary_client) {
  546. pr_err("primary client not available for vid state switch\n");
  547. rc = -EINVAL;
  548. goto end;
  549. } else if (caller_client != rsc->primary_client) {
  550. pr_err("primary client state:%d not vid state request\n",
  551. rsc->primary_client->current_state);
  552. rc = -EINVAL;
  553. goto end;
  554. }
  555. /* update timers - might not be available at next switch */
  556. if (config)
  557. sde_rsc_timer_calculate(rsc, config, SDE_RSC_VID_STATE);
  558. /**
  559. * rsc clients can still send config at any time. If a config is
  560. * received during vid_state then vsync_wait will execute with the logic
  561. * below.
  562. */
  563. if (rsc->current_state == SDE_RSC_VID_STATE) {
  564. rc = 0;
  565. if (config && rsc->version < SDE_RSC_REV_3)
  566. goto vsync_wait;
  567. else
  568. goto end;
  569. }
  570. /* any non-primary clk state client blocks the vid state switch */
  571. list_for_each_entry(client, &rsc->client_list, list)
  572. if (client->current_state == SDE_RSC_CLK_STATE &&
  573. client->client_type == SDE_RSC_EXTERNAL_DISP_CLIENT)
  574. goto end;
  575. if (rsc->hw_ops.state_update) {
  576. rc = rsc->hw_ops.state_update(rsc, SDE_RSC_VID_STATE);
  577. if (!rc) {
  578. rpmh_mode_solver_set(rsc->rpmh_dev,
  579. rsc->version == SDE_RSC_REV_3 ? true : false);
  580. sde_rsc_set_data_bus_mode(&rsc->phandle,
  581. rsc->version == SDE_RSC_REV_3 ?
  582. QCOM_ICC_TAG_WAKE : QCOM_ICC_TAG_AMC);
  583. }
  584. }
  585. vsync_wait:
  586. /* indicate wait for vsync for vid to cmd state switch & cfg update */
  587. if (!rc && (rsc->current_state == SDE_RSC_VID_STATE ||
  588. rsc->current_state == SDE_RSC_CMD_STATE)) {
  589. /* clear VSYNC timestamp for indication when update completes */
  590. if (rsc->hw_ops.hw_vsync)
  591. rsc->hw_ops.hw_vsync(rsc, VSYNC_ENABLE, NULL, 0, 0);
  592. if (!wait_vblank_crtc_id) {
  593. pr_err("invalid crtc id wait pointer, client %d\n",
  594. caller_client->id);
  595. SDE_EVT32(caller_client->id, rsc->current_state,
  596. caller_client->crtc_id,
  597. wait_vblank_crtc_id, SDE_EVTLOG_ERROR);
  598. msleep(PRIMARY_VBLANK_WORST_CASE_MS);
  599. } else {
  600. *wait_vblank_crtc_id = rsc->primary_client->crtc_id;
  601. }
  602. }
  603. end:
  604. return rc;
  605. }
  606. static int sde_rsc_switch_to_idle(struct sde_rsc_priv *rsc,
  607. struct sde_rsc_cmd_config *config,
  608. struct sde_rsc_client *caller_client,
  609. int *wait_vblank_crtc_id)
  610. {
  611. struct sde_rsc_client *client;
  612. int rc = STATE_UPDATE_NOT_ALLOWED;
  613. bool clk_client_active = false, multi_display_active = false;
  614. bool vid_display_active = false, cmd_display_active = false;
  615. /*
  616. * following code needs to run the loop through each
  617. * client because they might be in different order
  618. * sorting is not possible; only preference is available
  619. */
  620. list_for_each_entry(client, &rsc->client_list, list) {
  621. if (client->current_state == SDE_RSC_CLK_STATE &&
  622. client->client_type == SDE_RSC_EXTERNAL_DISP_CLIENT)
  623. multi_display_active = true;
  624. else if (client->current_state == SDE_RSC_CLK_STATE &&
  625. client->client_type == SDE_RSC_CLK_CLIENT)
  626. clk_client_active = true;
  627. else if (client->current_state == SDE_RSC_VID_STATE)
  628. vid_display_active = true;
  629. else if (client->current_state == SDE_RSC_CMD_STATE)
  630. cmd_display_active = true;
  631. pr_debug("client state:%d type:%d\n",
  632. client->current_state, client->client_type);
  633. }
  634. pr_debug("multi_display:%d clk_client:%d vid_display:%d cmd_display:%d\n",
  635. multi_display_active, clk_client_active, vid_display_active,
  636. cmd_display_active);
  637. if (vid_display_active && !multi_display_active) {
  638. rc = sde_rsc_switch_to_vid(rsc, NULL, rsc->primary_client,
  639. wait_vblank_crtc_id);
  640. if (!rc)
  641. rc = VID_MODE_SWITCH_SUCCESS;
  642. } else if (cmd_display_active && !multi_display_active) {
  643. rc = sde_rsc_switch_to_cmd(rsc, NULL, rsc->primary_client,
  644. wait_vblank_crtc_id);
  645. if (!rc)
  646. rc = CMD_MODE_SWITCH_SUCCESS;
  647. } else if (clk_client_active) {
  648. rc = sde_rsc_switch_to_clk(rsc, wait_vblank_crtc_id);
  649. if (!rc)
  650. rc = CLK_MODE_SWITCH_SUCCESS;
  651. } else if (rsc->hw_ops.state_update) {
  652. rc = rsc->hw_ops.state_update(rsc, SDE_RSC_IDLE_STATE);
  653. if (!rc) {
  654. rpmh_mode_solver_set(rsc->rpmh_dev, true);
  655. sde_rsc_set_data_bus_mode(&rsc->phandle,
  656. QCOM_ICC_TAG_WAKE);
  657. }
  658. }
  659. return rc;
  660. }
  661. /**
  662. * sde_rsc_client_get_vsync_refcount() - returns the status of the vsync
  663. * refcount, to signal if the client needs to reset the refcounting logic
  664. * @client: Client pointer provided by sde_rsc_client_create().
  665. *
  666. * Return: value of the vsync refcount.
  667. */
  668. int sde_rsc_client_get_vsync_refcount(
  669. struct sde_rsc_client *caller_client)
  670. {
  671. struct sde_rsc_priv *rsc;
  672. if (!caller_client) {
  673. pr_err("invalid client for rsc state update\n");
  674. return -EINVAL;
  675. } else if (caller_client->rsc_index >= MAX_RSC_COUNT) {
  676. pr_err("invalid rsc index\n");
  677. return -EINVAL;
  678. }
  679. rsc = rsc_prv_list[caller_client->rsc_index];
  680. if (!rsc)
  681. return 0;
  682. return atomic_read(&rsc->rsc_vsync_wait);
  683. }
  684. /**
  685. * sde_rsc_client_reset_vsync_refcount() - reduces the refcounting
  686. * logic that waits for the vsync.
  687. * @client: Client pointer provided by sde_rsc_client_create().
  688. *
  689. * Return: zero if refcount was already zero.
  690. */
  691. int sde_rsc_client_reset_vsync_refcount(
  692. struct sde_rsc_client *caller_client)
  693. {
  694. struct sde_rsc_priv *rsc;
  695. int ret;
  696. if (!caller_client) {
  697. pr_err("invalid client for rsc state update\n");
  698. return -EINVAL;
  699. } else if (caller_client->rsc_index >= MAX_RSC_COUNT) {
  700. pr_err("invalid rsc index\n");
  701. return -EINVAL;
  702. }
  703. rsc = rsc_prv_list[caller_client->rsc_index];
  704. if (!rsc)
  705. return 0;
  706. ret = atomic_add_unless(&rsc->rsc_vsync_wait, -1, 0);
  707. wake_up_all(&rsc->rsc_vsync_waitq);
  708. SDE_EVT32(atomic_read(&rsc->rsc_vsync_wait));
  709. return ret;
  710. }
  711. /**
  712. * sde_rsc_client_is_state_update_complete() - check if state update is complete
  713. * RSC state transition is not complete until HW receives VBLANK signal. This
  714. * function checks RSC HW to determine whether that signal has been received.
  715. * @client: Client pointer provided by sde_rsc_client_create().
  716. *
  717. * Return: true if the state update has completed.
  718. */
  719. bool sde_rsc_client_is_state_update_complete(
  720. struct sde_rsc_client *caller_client)
  721. {
  722. struct sde_rsc_priv *rsc;
  723. u32 vsync_timestamp0 = 0;
  724. if (!caller_client) {
  725. pr_err("invalid client for rsc state update\n");
  726. return false;
  727. } else if (caller_client->rsc_index >= MAX_RSC_COUNT) {
  728. pr_err("invalid rsc index\n");
  729. return false;
  730. }
  731. rsc = rsc_prv_list[caller_client->rsc_index];
  732. if (!rsc)
  733. return false;
  734. /**
  735. * state updates clear VSYNC timestamp, check if a new one arrived.
  736. * use VSYNC mode 0 (CMD TE) always for this, per HW recommendation.
  737. */
  738. if (rsc->hw_ops.hw_vsync)
  739. vsync_timestamp0 = rsc->hw_ops.hw_vsync(rsc, VSYNC_READ_VSYNC0,
  740. NULL, 0, 0);
  741. return vsync_timestamp0 != 0;
  742. }
  743. /**
  744. * sde_rsc_client_state_update() - rsc client state update
  745. * Video mode, cmd mode and clk state are suppoed as modes. A client need to
  746. * set this property during panel config time. A switching client can set the
  747. * property to change the state
  748. *
  749. * @client: Client pointer provided by sde_rsc_client_create().
  750. * @state: Client state - video/cmd
  751. * @config: fps, vtotal, porches, etc configuration for command mode
  752. * panel
  753. * @crtc_id: current client's crtc id
  754. * @wait_vblank_crtc_id: Output parameter. If set to non-zero, rsc hw
  755. * state update requires a wait for one vblank on
  756. * the primary crtc. In that case, this output
  757. * param will be set to the crtc on which to wait.
  758. * If SDE_RSC_INVALID_CRTC_ID, no wait necessary
  759. *
  760. * Return: error code.
  761. */
  762. int sde_rsc_client_state_update(struct sde_rsc_client *caller_client,
  763. enum sde_rsc_state state,
  764. struct sde_rsc_cmd_config *config, int crtc_id,
  765. int *wait_vblank_crtc_id)
  766. {
  767. int rc = 0;
  768. struct sde_rsc_priv *rsc;
  769. if (!caller_client) {
  770. pr_err("invalid client for rsc state update\n");
  771. return -EINVAL;
  772. } else if (caller_client->rsc_index >= MAX_RSC_COUNT) {
  773. pr_err("invalid rsc index\n");
  774. return -EINVAL;
  775. }
  776. rsc = rsc_prv_list[caller_client->rsc_index];
  777. if (!rsc)
  778. return -EINVAL;
  779. if (wait_vblank_crtc_id)
  780. *wait_vblank_crtc_id = SDE_RSC_INVALID_CRTC_ID;
  781. mutex_lock(&rsc->client_lock);
  782. SDE_EVT32_VERBOSE(caller_client->id, caller_client->current_state,
  783. state, rsc->current_state, SDE_EVTLOG_FUNC_ENTRY);
  784. caller_client->crtc_id = crtc_id;
  785. caller_client->current_state = state;
  786. if (rsc->master_drm == NULL) {
  787. pr_err("invalid master component binding\n");
  788. rc = -EINVAL;
  789. goto end;
  790. } else if ((rsc->current_state == state) && !config) {
  791. pr_debug("no state change: %d\n", state);
  792. goto end;
  793. }
  794. pr_debug("%pS: rsc state:%d request client:%s state:%d\n",
  795. __builtin_return_address(0), rsc->current_state,
  796. caller_client->name, state);
  797. if (rsc->current_state == SDE_RSC_IDLE_STATE)
  798. sde_rsc_resource_enable(rsc);
  799. switch (state) {
  800. case SDE_RSC_IDLE_STATE:
  801. rc = sde_rsc_switch_to_idle(rsc, NULL, rsc->primary_client,
  802. wait_vblank_crtc_id);
  803. if (rc == CMD_MODE_SWITCH_SUCCESS) {
  804. state = SDE_RSC_CMD_STATE;
  805. rc = 0;
  806. } else if (rc == VID_MODE_SWITCH_SUCCESS) {
  807. state = SDE_RSC_VID_STATE;
  808. rc = 0;
  809. } else if (rc == CLK_MODE_SWITCH_SUCCESS) {
  810. state = SDE_RSC_CLK_STATE;
  811. rc = 0;
  812. }
  813. break;
  814. case SDE_RSC_CMD_STATE:
  815. rc = sde_rsc_switch_to_cmd(rsc, config, caller_client,
  816. wait_vblank_crtc_id);
  817. break;
  818. case SDE_RSC_VID_STATE:
  819. rc = sde_rsc_switch_to_vid(rsc, config, caller_client,
  820. wait_vblank_crtc_id);
  821. break;
  822. case SDE_RSC_CLK_STATE:
  823. rc = sde_rsc_switch_to_clk(rsc, wait_vblank_crtc_id);
  824. break;
  825. default:
  826. pr_err("invalid state handling %d\n", state);
  827. break;
  828. }
  829. if (rc == STATE_UPDATE_NOT_ALLOWED) {
  830. rc = 0;
  831. SDE_EVT32(caller_client->id, caller_client->current_state,
  832. state, rsc->current_state, rc, SDE_EVTLOG_FUNC_CASE1);
  833. goto clk_disable;
  834. } else if (rc) {
  835. pr_debug("state:%d update failed rc:%d\n", state, rc);
  836. SDE_EVT32(caller_client->id, caller_client->current_state,
  837. state, rsc->current_state, rc, SDE_EVTLOG_FUNC_CASE2);
  838. goto clk_disable;
  839. }
  840. pr_debug("state switch successfully complete: %d\n", state);
  841. SDE_ATRACE_INT("rsc_state", state);
  842. rsc->current_state = state;
  843. SDE_EVT32(caller_client->id, caller_client->current_state,
  844. state, rsc->current_state, SDE_EVTLOG_FUNC_EXIT);
  845. clk_disable:
  846. if (rsc->current_state == SDE_RSC_IDLE_STATE)
  847. sde_rsc_resource_disable(rsc);
  848. end:
  849. mutex_unlock(&rsc->client_lock);
  850. return rc;
  851. }
  852. EXPORT_SYMBOL(sde_rsc_client_state_update);
  853. /**
  854. * sde_rsc_client_vote() - ab/ib vote from rsc client
  855. *
  856. * @client: Client pointer provided by sde_rsc_client_create().
  857. * @bus_id: data bus for which to be voted
  858. * @ab: aggregated bandwidth vote from client.
  859. * @ib: instant bandwidth vote from client.
  860. *
  861. * Return: error code.
  862. */
  863. int sde_rsc_client_vote(struct sde_rsc_client *caller_client,
  864. u32 bus_id, u64 ab_vote, u64 ib_vote)
  865. {
  866. int rsc_index;
  867. struct sde_rsc_priv *rsc;
  868. if (caller_client && caller_client->rsc_index >= MAX_RSC_COUNT) {
  869. pr_err("invalid rsc client or client index\n");
  870. return -EINVAL;
  871. }
  872. rsc_index = caller_client ? caller_client->rsc_index : SDE_RSC_INDEX;
  873. rsc = rsc_prv_list[rsc_index];
  874. if (!rsc || bus_id >= SDE_POWER_HANDLE_DBUS_ID_MAX)
  875. return -EINVAL;
  876. pr_debug("client:%s ab:%llu ib:%llu\n",
  877. caller_client ? caller_client->name : "unknown",
  878. ab_vote, ib_vote);
  879. mutex_lock(&rsc->client_lock);
  880. rsc->bw_config.new_ab_vote[bus_id] = ab_vote;
  881. rsc->bw_config.new_ib_vote[bus_id] = ib_vote;
  882. mutex_unlock(&rsc->client_lock);
  883. return 0;
  884. }
  885. EXPORT_SYMBOL(sde_rsc_client_vote);
  886. int sde_rsc_client_trigger_vote(struct sde_rsc_client *caller_client,
  887. bool delta_vote)
  888. {
  889. int rc = 0, rsc_index, i;
  890. struct sde_rsc_priv *rsc;
  891. bool bw_increase = false;
  892. if (caller_client && caller_client->rsc_index >= MAX_RSC_COUNT) {
  893. pr_err("invalid rsc index\n");
  894. return -EINVAL;
  895. }
  896. rsc_index = caller_client ? caller_client->rsc_index : SDE_RSC_INDEX;
  897. rsc = rsc_prv_list[rsc_index];
  898. if (!rsc)
  899. return -EINVAL;
  900. pr_debug("client:%s trigger bw delta vote:%d\n",
  901. caller_client ? caller_client->name : "unknown", delta_vote);
  902. mutex_lock(&rsc->client_lock);
  903. for (i = 0; i < SDE_POWER_HANDLE_DBUS_ID_MAX && delta_vote; i++) {
  904. if (rsc->bw_config.new_ab_vote[i] > rsc->bw_config.ab_vote[i] ||
  905. rsc->bw_config.new_ib_vote[i] > rsc->bw_config.ib_vote[i])
  906. bw_increase = true;
  907. rsc->bw_config.ab_vote[i] = rsc->bw_config.new_ab_vote[i];
  908. rsc->bw_config.ib_vote[i] = rsc->bw_config.new_ib_vote[i];
  909. }
  910. rc = sde_rsc_resource_enable(rsc);
  911. if (rc < 0)
  912. goto clk_enable_fail;
  913. if (delta_vote) {
  914. if (rsc->hw_ops.tcs_wait) {
  915. rc = rsc->hw_ops.tcs_wait(rsc);
  916. if (rc) {
  917. pr_err("tcs is still busy; can't send command\n");
  918. if (rsc->hw_ops.tcs_use_ok)
  919. rsc->hw_ops.tcs_use_ok(rsc);
  920. goto end;
  921. }
  922. }
  923. rpmh_invalidate(rsc->rpmh_dev);
  924. for (i = 0; i < SDE_POWER_HANDLE_DBUS_ID_MAX; i++)
  925. sde_power_data_bus_set_quota(&rsc->phandle,
  926. i, rsc->bw_config.ab_vote[i],
  927. rsc->bw_config.ib_vote[i]);
  928. rpmh_flush(rsc->rpmh_dev);
  929. }
  930. if (rsc->hw_ops.bwi_status &&
  931. (rsc->current_state == SDE_RSC_CMD_STATE ||
  932. rsc->current_state == SDE_RSC_VID_STATE))
  933. rsc->hw_ops.bwi_status(rsc, bw_increase);
  934. else if (rsc->hw_ops.tcs_use_ok)
  935. rsc->hw_ops.tcs_use_ok(rsc);
  936. end:
  937. sde_rsc_resource_disable(rsc);
  938. clk_enable_fail:
  939. mutex_unlock(&rsc->client_lock);
  940. return rc;
  941. }
  942. EXPORT_SYMBOL(sde_rsc_client_trigger_vote);
  943. #if defined(CONFIG_DEBUG_FS)
  944. void sde_rsc_debug_dump(u32 mux_sel)
  945. {
  946. struct sde_rsc_priv *rsc;
  947. rsc = rsc_prv_list[SDE_RSC_INDEX];
  948. if (!rsc)
  949. return;
  950. /* this must be called with rsc clocks enabled */
  951. if (rsc->hw_ops.debug_dump)
  952. rsc->hw_ops.debug_dump(rsc, mux_sel);
  953. }
  954. #endif /* defined(CONFIG_DEBUG_FS) */
  955. static int _sde_debugfs_status_show(struct seq_file *s, void *data)
  956. {
  957. struct sde_rsc_priv *rsc;
  958. struct sde_rsc_client *client;
  959. int ret;
  960. if (!s || !s->private)
  961. return -EINVAL;
  962. rsc = s->private;
  963. mutex_lock(&rsc->client_lock);
  964. seq_printf(s, "rsc current state:%d\n", rsc->current_state);
  965. seq_printf(s, "wraper backoff time(ns):%d\n",
  966. rsc->timer_config.static_wakeup_time_ns);
  967. seq_printf(s, "rsc backoff time(ns):%d\n",
  968. rsc->timer_config.rsc_backoff_time_ns);
  969. seq_printf(s, "pdc backoff time(ns):%d\n",
  970. rsc->timer_config.pdc_backoff_time_ns);
  971. seq_printf(s, "rsc mode threshold time(ns):%d\n",
  972. rsc->timer_config.rsc_mode_threshold_time_ns);
  973. seq_printf(s, "rsc time slot 0(ns):%d\n",
  974. rsc->timer_config.rsc_time_slot_0_ns);
  975. seq_printf(s, "rsc time slot 1(ns):%d\n",
  976. rsc->timer_config.rsc_time_slot_1_ns);
  977. seq_printf(s, "frame fps:%d jitter_numer:%d jitter_denom:%d vtotal:%d prefill lines:%d\n",
  978. rsc->cmd_config.fps, rsc->cmd_config.jitter_numer,
  979. rsc->cmd_config.jitter_denom,
  980. rsc->cmd_config.vtotal, rsc->cmd_config.prefill_lines);
  981. seq_puts(s, "\n");
  982. list_for_each_entry(client, &rsc->client_list, list)
  983. seq_printf(s, "\t client:%s state:%d\n",
  984. client->name, client->current_state);
  985. if (rsc->current_state == SDE_RSC_IDLE_STATE) {
  986. pr_debug("debug node is not supported during idle state\n");
  987. seq_puts(s, "hw state is not supported during idle pc\n");
  988. goto end;
  989. }
  990. if (rsc->hw_ops.debug_show) {
  991. ret = rsc->hw_ops.debug_show(s, rsc);
  992. if (ret)
  993. pr_err("sde rsc: hw debug failed ret:%d\n", ret);
  994. }
  995. end:
  996. mutex_unlock(&rsc->client_lock);
  997. return 0;
  998. }
  999. static int _sde_debugfs_status_open(struct inode *inode, struct file *file)
  1000. {
  1001. return single_open(file, _sde_debugfs_status_show, inode->i_private);
  1002. }
  1003. static int _sde_debugfs_generic_noseek_open(struct inode *inode,
  1004. struct file *file)
  1005. {
  1006. /* non-seekable */
  1007. file->private_data = inode->i_private;
  1008. return nonseekable_open(inode, file);
  1009. }
  1010. static ssize_t _sde_debugfs_mode_ctrl_read(struct file *file, char __user *buf,
  1011. size_t count, loff_t *ppos)
  1012. {
  1013. struct sde_rsc_priv *rsc = file->private_data;
  1014. char buffer[MAX_BUFFER_SIZE];
  1015. int blen = 0;
  1016. if (*ppos || !rsc || !rsc->hw_ops.mode_ctrl)
  1017. return 0;
  1018. mutex_lock(&rsc->client_lock);
  1019. if (rsc->current_state == SDE_RSC_IDLE_STATE) {
  1020. pr_debug("debug node is not supported during idle state\n");
  1021. blen = snprintf(buffer, MAX_BUFFER_SIZE,
  1022. "hw state is not supported during idle pc\n");
  1023. goto end;
  1024. }
  1025. blen = rsc->hw_ops.mode_ctrl(rsc, MODE_READ, buffer,
  1026. MAX_BUFFER_SIZE, 0);
  1027. end:
  1028. mutex_unlock(&rsc->client_lock);
  1029. if (blen <= 0)
  1030. return 0;
  1031. if (blen > count)
  1032. blen = count;
  1033. blen = min_t(size_t, blen, MAX_BUFFER_SIZE);
  1034. if (copy_to_user(buf, buffer, blen))
  1035. return -EFAULT;
  1036. *ppos += blen;
  1037. return blen;
  1038. }
  1039. static ssize_t _sde_debugfs_mode_ctrl_write(struct file *file,
  1040. const char __user *p, size_t count, loff_t *ppos)
  1041. {
  1042. struct sde_rsc_priv *rsc = file->private_data;
  1043. char *input;
  1044. u32 mode_state = 0;
  1045. int rc;
  1046. if (!rsc || !rsc->hw_ops.mode_ctrl || !count ||
  1047. count > MAX_COUNT_SIZE_SUPPORTED)
  1048. return 0;
  1049. input = kmalloc(count + 1, GFP_KERNEL);
  1050. if (!input)
  1051. return -ENOMEM;
  1052. if (copy_from_user(input, p, count)) {
  1053. kfree(input);
  1054. return -EFAULT;
  1055. }
  1056. input[count] = '\0';
  1057. rc = kstrtoint(input, 0, &mode_state);
  1058. if (rc) {
  1059. pr_err("mode_state: int conversion failed rc:%d\n", rc);
  1060. goto end;
  1061. }
  1062. pr_debug("mode_state: %d\n", mode_state);
  1063. mode_state &= 0x7;
  1064. if (mode_state != ALL_MODES_DISABLED &&
  1065. mode_state != ALL_MODES_ENABLED &&
  1066. mode_state != ONLY_MODE_0_ENABLED &&
  1067. mode_state != ONLY_MODE_0_1_ENABLED) {
  1068. pr_err("invalid mode:%d combination\n", mode_state);
  1069. goto end;
  1070. }
  1071. mutex_lock(&rsc->client_lock);
  1072. if (rsc->current_state == SDE_RSC_IDLE_STATE) {
  1073. pr_debug("debug node is not supported during idle state\n");
  1074. goto state_check;
  1075. }
  1076. rsc->hw_ops.mode_ctrl(rsc, MODE_UPDATE, NULL, 0, mode_state);
  1077. state_check:
  1078. mutex_unlock(&rsc->client_lock);
  1079. end:
  1080. kfree(input);
  1081. return count;
  1082. }
  1083. static ssize_t _sde_debugfs_vsync_mode_read(struct file *file, char __user *buf,
  1084. size_t count, loff_t *ppos)
  1085. {
  1086. struct sde_rsc_priv *rsc = file->private_data;
  1087. char buffer[MAX_BUFFER_SIZE];
  1088. int blen = 0;
  1089. if (*ppos || !rsc || !rsc->hw_ops.hw_vsync)
  1090. return 0;
  1091. mutex_lock(&rsc->client_lock);
  1092. if (rsc->current_state == SDE_RSC_IDLE_STATE) {
  1093. pr_debug("debug node is not supported during idle state\n");
  1094. blen = snprintf(buffer, MAX_BUFFER_SIZE,
  1095. "hw state is not supported during idle pc\n");
  1096. goto end;
  1097. }
  1098. blen = rsc->hw_ops.hw_vsync(rsc, VSYNC_READ, buffer,
  1099. MAX_BUFFER_SIZE, 0);
  1100. end:
  1101. mutex_unlock(&rsc->client_lock);
  1102. if (blen <= 0)
  1103. return 0;
  1104. if (blen > count)
  1105. blen = count;
  1106. blen = min_t(size_t, blen, MAX_BUFFER_SIZE);
  1107. if (copy_to_user(buf, buffer, blen))
  1108. return -EFAULT;
  1109. *ppos += blen;
  1110. return blen;
  1111. }
  1112. static ssize_t _sde_debugfs_vsync_mode_write(struct file *file,
  1113. const char __user *p, size_t count, loff_t *ppos)
  1114. {
  1115. struct sde_rsc_priv *rsc = file->private_data;
  1116. char *input;
  1117. u32 vsync_state = 0;
  1118. int rc;
  1119. if (!rsc || !rsc->hw_ops.hw_vsync || !count ||
  1120. count > MAX_COUNT_SIZE_SUPPORTED)
  1121. return 0;
  1122. input = kmalloc(count + 1, GFP_KERNEL);
  1123. if (!input)
  1124. return -ENOMEM;
  1125. if (copy_from_user(input, p, count)) {
  1126. kfree(input);
  1127. return -EFAULT;
  1128. }
  1129. input[count] = '\0';
  1130. rc = kstrtoint(input, 0, &vsync_state);
  1131. if (rc) {
  1132. pr_err("vsync_state: int conversion failed rc:%d\n", rc);
  1133. goto end;
  1134. }
  1135. pr_debug("vsync_state: %d\n", vsync_state);
  1136. vsync_state &= 0x7;
  1137. mutex_lock(&rsc->client_lock);
  1138. if (rsc->current_state == SDE_RSC_IDLE_STATE) {
  1139. pr_debug("debug node is not supported during idle state\n");
  1140. goto state_check;
  1141. }
  1142. if (vsync_state)
  1143. rsc->hw_ops.hw_vsync(rsc, VSYNC_ENABLE, NULL,
  1144. 0, vsync_state - 1);
  1145. else
  1146. rsc->hw_ops.hw_vsync(rsc, VSYNC_DISABLE, NULL, 0, 0);
  1147. state_check:
  1148. mutex_unlock(&rsc->client_lock);
  1149. end:
  1150. kfree(input);
  1151. return count;
  1152. }
  1153. static const struct file_operations debugfs_status_fops = {
  1154. .open = _sde_debugfs_status_open,
  1155. .read = seq_read,
  1156. .llseek = seq_lseek,
  1157. .release = single_release,
  1158. };
  1159. static const struct file_operations mode_control_fops = {
  1160. .open = _sde_debugfs_generic_noseek_open,
  1161. .read = _sde_debugfs_mode_ctrl_read,
  1162. .write = _sde_debugfs_mode_ctrl_write,
  1163. };
  1164. static const struct file_operations vsync_status_fops = {
  1165. .open = _sde_debugfs_generic_noseek_open,
  1166. .read = _sde_debugfs_vsync_mode_read,
  1167. .write = _sde_debugfs_vsync_mode_write,
  1168. };
  1169. static void _sde_rsc_init_debugfs(struct sde_rsc_priv *rsc, char *name)
  1170. {
  1171. rsc->debugfs_root = debugfs_create_dir(name, NULL);
  1172. if (!rsc->debugfs_root)
  1173. return;
  1174. /* don't error check these */
  1175. debugfs_create_file("status", 0400, rsc->debugfs_root, rsc,
  1176. &debugfs_status_fops);
  1177. debugfs_create_file("mode_control", 0600, rsc->debugfs_root, rsc,
  1178. &mode_control_fops);
  1179. debugfs_create_file("vsync_mode", 0600, rsc->debugfs_root, rsc,
  1180. &vsync_status_fops);
  1181. debugfs_create_x32("debug_mode", 0600, rsc->debugfs_root,
  1182. &rsc->debug_mode);
  1183. }
  1184. static void sde_rsc_deinit(struct platform_device *pdev,
  1185. struct sde_rsc_priv *rsc)
  1186. {
  1187. if (!rsc)
  1188. return;
  1189. sde_rsc_resource_disable(rsc);
  1190. if (rsc->sw_fs_enabled)
  1191. regulator_disable(rsc->fs);
  1192. if (rsc->fs)
  1193. devm_regulator_put(rsc->fs);
  1194. if (rsc->wrapper_io.base)
  1195. msm_dss_iounmap(&rsc->wrapper_io);
  1196. if (rsc->drv_io.base)
  1197. msm_dss_iounmap(&rsc->drv_io);
  1198. sde_power_resource_deinit(pdev, &rsc->phandle);
  1199. debugfs_remove_recursive(rsc->debugfs_root);
  1200. kfree(rsc);
  1201. }
  1202. /**
  1203. * sde_rsc_bind - bind rsc device with controlling device
  1204. * @dev: Pointer to base of platform device
  1205. * @master: Pointer to container of drm device
  1206. * @data: Pointer to private data
  1207. * Returns: Zero on success
  1208. */
  1209. static int sde_rsc_bind(struct device *dev,
  1210. struct device *master,
  1211. void *data)
  1212. {
  1213. struct sde_rsc_priv *rsc;
  1214. struct drm_device *drm;
  1215. struct platform_device *pdev = to_platform_device(dev);
  1216. if (!dev || !pdev || !master) {
  1217. pr_err("invalid param(s), dev %pK, pdev %pK, master %pK\n",
  1218. dev, pdev, master);
  1219. return -EINVAL;
  1220. }
  1221. drm = dev_get_drvdata(master);
  1222. rsc = platform_get_drvdata(pdev);
  1223. if (!drm || !rsc) {
  1224. pr_err("invalid param(s), drm %pK, rsc %pK\n",
  1225. drm, rsc);
  1226. return -EINVAL;
  1227. }
  1228. mutex_lock(&rsc->client_lock);
  1229. rsc->master_drm = drm;
  1230. mutex_unlock(&rsc->client_lock);
  1231. sde_dbg_reg_register_base(SDE_RSC_DRV_DBG_NAME, rsc->drv_io.base,
  1232. rsc->drv_io.len);
  1233. sde_dbg_reg_register_base(SDE_RSC_WRAPPER_DBG_NAME,
  1234. rsc->wrapper_io.base, rsc->wrapper_io.len);
  1235. return 0;
  1236. }
  1237. /**
  1238. * sde_rsc_unbind - unbind rsc from controlling device
  1239. * @dev: Pointer to base of platform device
  1240. * @master: Pointer to container of drm device
  1241. * @data: Pointer to private data
  1242. */
  1243. static void sde_rsc_unbind(struct device *dev,
  1244. struct device *master, void *data)
  1245. {
  1246. struct sde_rsc_priv *rsc;
  1247. struct platform_device *pdev = to_platform_device(dev);
  1248. if (!dev || !pdev) {
  1249. pr_err("invalid param(s)\n");
  1250. return;
  1251. }
  1252. rsc = platform_get_drvdata(pdev);
  1253. if (!rsc) {
  1254. pr_err("invalid display rsc\n");
  1255. return;
  1256. }
  1257. mutex_lock(&rsc->client_lock);
  1258. rsc->master_drm = NULL;
  1259. mutex_unlock(&rsc->client_lock);
  1260. }
  1261. static const struct component_ops sde_rsc_comp_ops = {
  1262. .bind = sde_rsc_bind,
  1263. .unbind = sde_rsc_unbind,
  1264. };
  1265. static int sde_rsc_probe(struct platform_device *pdev)
  1266. {
  1267. int ret;
  1268. struct sde_rsc_priv *rsc;
  1269. static int counter;
  1270. char name[MAX_RSC_CLIENT_NAME_LEN];
  1271. if (counter >= MAX_RSC_COUNT) {
  1272. pr_err("sde rsc supports probe till MAX_RSC_COUNT=%d devices\n",
  1273. MAX_RSC_COUNT);
  1274. return -EINVAL;
  1275. }
  1276. rsc = kzalloc(sizeof(*rsc), GFP_KERNEL);
  1277. if (!rsc) {
  1278. ret = -ENOMEM;
  1279. goto rsc_alloc_fail;
  1280. }
  1281. platform_set_drvdata(pdev, rsc);
  1282. rsc->dev = &pdev->dev;
  1283. of_property_read_u32(pdev->dev.of_node, "qcom,sde-rsc-version",
  1284. &rsc->version);
  1285. if (rsc->version == SDE_RSC_REV_2)
  1286. rsc->single_tcs_execution_time = SINGLE_TCS_EXECUTION_TIME_V2;
  1287. else
  1288. rsc->single_tcs_execution_time = SINGLE_TCS_EXECUTION_TIME_V1;
  1289. if (rsc->version == SDE_RSC_REV_3) {
  1290. rsc->time_slot_0_ns = rsc->single_tcs_execution_time
  1291. + RSC_MODE_INSTRUCTION_TIME;
  1292. rsc->backoff_time_ns = RSC_MODE_INSTRUCTION_TIME;
  1293. rsc->mode_threshold_time_ns = rsc->time_slot_0_ns;
  1294. } else {
  1295. rsc->time_slot_0_ns = (rsc->single_tcs_execution_time * 2)
  1296. + RSC_MODE_INSTRUCTION_TIME;
  1297. rsc->backoff_time_ns = rsc->single_tcs_execution_time
  1298. + RSC_MODE_INSTRUCTION_TIME;
  1299. rsc->mode_threshold_time_ns = rsc->backoff_time_ns
  1300. + RSC_MODE_THRESHOLD_OVERHEAD;
  1301. }
  1302. ret = sde_power_resource_init(pdev, &rsc->phandle);
  1303. if (ret) {
  1304. pr_err("sde rsc:power resource init failed ret:%d\n", ret);
  1305. goto sde_rsc_fail;
  1306. }
  1307. rsc->rpmh_dev = rpmh_dev[SDE_RSC_INDEX + counter];
  1308. if (IS_ERR_OR_NULL(rsc->rpmh_dev)) {
  1309. ret = !rsc->rpmh_dev ? -EINVAL : PTR_ERR(rsc->rpmh_dev);
  1310. rsc->rpmh_dev = NULL;
  1311. pr_err("rpmh device node is not available ret:%d\n", ret);
  1312. goto sde_rsc_fail;
  1313. }
  1314. ret = msm_dss_ioremap_byname(pdev, &rsc->wrapper_io, "wrapper");
  1315. if (ret) {
  1316. pr_err("sde rsc: wrapper io data mapping failed ret=%d\n", ret);
  1317. goto sde_rsc_fail;
  1318. }
  1319. ret = msm_dss_ioremap_byname(pdev, &rsc->drv_io, "drv");
  1320. if (ret) {
  1321. pr_err("sde rsc: drv io data mapping failed ret:%d\n", ret);
  1322. goto sde_rsc_fail;
  1323. }
  1324. rsc->fs = devm_regulator_get(&pdev->dev, "vdd");
  1325. if (IS_ERR_OR_NULL(rsc->fs)) {
  1326. rsc->fs = NULL;
  1327. pr_err("unable to get regulator\n");
  1328. goto sde_rsc_fail;
  1329. }
  1330. if (rsc->version >= SDE_RSC_REV_3)
  1331. ret = sde_rsc_hw_register_v3(rsc);
  1332. else
  1333. ret = sde_rsc_hw_register(rsc);
  1334. if (ret) {
  1335. pr_err("sde rsc: hw register failed ret:%d\n", ret);
  1336. goto sde_rsc_fail;
  1337. }
  1338. ret = regulator_enable(rsc->fs);
  1339. if (ret) {
  1340. pr_err("sde rsc: fs on failed ret:%d\n", ret);
  1341. goto sde_rsc_fail;
  1342. }
  1343. rsc->sw_fs_enabled = true;
  1344. ret = sde_rsc_resource_enable(rsc);
  1345. if (ret < 0) {
  1346. pr_err("failed to enable sde rsc power resources rc:%d\n", ret);
  1347. goto sde_rsc_fail;
  1348. }
  1349. if (sde_rsc_timer_calculate(rsc, NULL, SDE_RSC_IDLE_STATE))
  1350. goto sde_rsc_fail;
  1351. sde_rsc_resource_disable(rsc);
  1352. INIT_LIST_HEAD(&rsc->client_list);
  1353. INIT_LIST_HEAD(&rsc->event_list);
  1354. mutex_init(&rsc->client_lock);
  1355. init_waitqueue_head(&rsc->rsc_vsync_waitq);
  1356. atomic_set(&rsc->resource_refcount, 0);
  1357. pr_info("sde rsc index:%d probed successfully\n",
  1358. SDE_RSC_INDEX + counter);
  1359. rsc_prv_list[SDE_RSC_INDEX + counter] = rsc;
  1360. snprintf(name, MAX_RSC_CLIENT_NAME_LEN, "%s%d", "sde_rsc", counter);
  1361. _sde_rsc_init_debugfs(rsc, name);
  1362. counter++;
  1363. ret = component_add(&pdev->dev, &sde_rsc_comp_ops);
  1364. if (ret)
  1365. pr_debug("component add failed, ret=%d\n", ret);
  1366. ret = 0;
  1367. return ret;
  1368. sde_rsc_fail:
  1369. sde_rsc_deinit(pdev, rsc);
  1370. rsc_alloc_fail:
  1371. return ret;
  1372. }
  1373. static int sde_rsc_remove(struct platform_device *pdev)
  1374. {
  1375. struct sde_rsc_priv *rsc = platform_get_drvdata(pdev);
  1376. sde_rsc_deinit(pdev, rsc);
  1377. return 0;
  1378. }
  1379. static int sde_rsc_rpmh_probe(struct platform_device *pdev)
  1380. {
  1381. int ret = 0;
  1382. uint32_t index = 0;
  1383. ret = of_property_read_u32(pdev->dev.of_node, "cell-index", &index);
  1384. if (ret) {
  1385. pr_err("unable to find sde rsc cell index\n");
  1386. return ret;
  1387. } else if (index >= MAX_RSC_COUNT) {
  1388. pr_err("invalid cell index for sde rsc:%d\n", index);
  1389. return -EINVAL;
  1390. }
  1391. rpmh_dev[index] = &pdev->dev;
  1392. return 0;
  1393. }
  1394. int sde_rsc_rpmh_remove(struct platform_device *pdev)
  1395. {
  1396. int i;
  1397. for (i = 0; i < MAX_RSC_COUNT; i++)
  1398. rpmh_dev[i] = NULL;
  1399. return 0;
  1400. }
  1401. static const struct of_device_id dt_match[] = {
  1402. { .compatible = "qcom,sde-rsc"},
  1403. {},
  1404. };
  1405. MODULE_DEVICE_TABLE(of, dt_match);
  1406. static struct platform_driver sde_rsc_platform_driver = {
  1407. .probe = sde_rsc_probe,
  1408. .remove = sde_rsc_remove,
  1409. .driver = {
  1410. .name = "sde_rsc",
  1411. .of_match_table = dt_match,
  1412. .suppress_bind_attrs = true,
  1413. },
  1414. };
  1415. static const struct of_device_id sde_rsc_rpmh_match[] = {
  1416. {.compatible = "qcom,sde-rsc-rpmh"},
  1417. {},
  1418. };
  1419. static struct platform_driver sde_rsc_rpmh_driver = {
  1420. .probe = sde_rsc_rpmh_probe,
  1421. .remove = sde_rsc_rpmh_remove,
  1422. .driver = {
  1423. .name = "sde_rsc_rpmh",
  1424. .of_match_table = sde_rsc_rpmh_match,
  1425. },
  1426. };
  1427. static int __init sde_rsc_register(void)
  1428. {
  1429. return platform_driver_register(&sde_rsc_platform_driver);
  1430. }
  1431. static void __exit sde_rsc_unregister(void)
  1432. {
  1433. platform_driver_unregister(&sde_rsc_platform_driver);
  1434. }
  1435. static int __init sde_rsc_rpmh_register(void)
  1436. {
  1437. return platform_driver_register(&sde_rsc_rpmh_driver);
  1438. }
  1439. subsys_initcall(sde_rsc_rpmh_register);
  1440. module_init(sde_rsc_register);
  1441. module_exit(sde_rsc_unregister);