mdm_common.c 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604
  1. /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #include <linux/module.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/err.h>
  16. #include <linux/slab.h>
  17. #include <linux/io.h>
  18. #include <linux/mutex.h>
  19. #include <linux/miscdevice.h>
  20. #include <linux/fs.h>
  21. #include <linux/gpio.h>
  22. #include <linux/kernel.h>
  23. #include <linux/irq.h>
  24. #include <linux/ioctl.h>
  25. #include <linux/delay.h>
  26. #include <linux/reboot.h>
  27. #include <linux/debugfs.h>
  28. #include <linux/completion.h>
  29. #include <linux/workqueue.h>
  30. #include <linux/clk.h>
  31. #include <linux/mfd/pmic8058.h>
  32. #include <linux/msm_charm.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/uaccess.h>
  35. #include "mdm2.h"
  36. #include <mach/restart.h>
  37. #include <mach/subsystem_notif.h>
  38. #include <mach/subsystem_restart.h>
  39. #include <mach/rpm.h>
  40. #include <mach/gpiomux.h>
  41. #include <mach/msm_serial_hs.h>
  42. #include <mach/socinfo.h>
  43. #include <linux/of.h>
  44. #include <linux/of_device.h>
  45. #include <linux/of_gpio.h>
  46. #include <linux/of_platform.h>
  47. #include <mach/../../msm_watchdog.h>
  48. #include "mdm_private.h"
  49. #include <mach/../../sysmon.h>
  50. #ifdef CONFIG_SEC_DEBUG
  51. #include <mach/sec_debug.h>
  52. #endif
  53. // #define CONFIG_STATUS_IRQ_BY_LEVEL_TRIG
  54. #define CONFIG_STATUS_IRQ_WAKEUP_ENA
  55. // #define CONFIG_ABNORMAL_RESET_SKIP_RAMPDUMP
  56. extern int subsys_set_flag_skip_ramdump(struct subsys_device *dev, bool flag);
  57. extern int poweroff_charging;
  58. #define MDM_MODEM_TIMEOUT 6000
  59. #define MDM_MODEM_DELTA 100
  60. #define MDM_BOOT_TIMEOUT 60000L
  61. #define MDM_RDUMP_TIMEOUT 120000L
  62. #define MDM2AP_STATUS_TIMEOUT_MS 60000L
  63. /* Allow a maximum device id of this many digits */
  64. #define MAX_DEVICE_DIGITS 10
  65. #define EXTERNAL_MODEM "external_modem"
  66. #define SUBSYS_NAME_LENGTH \
  67. (sizeof(EXTERNAL_MODEM) + MAX_DEVICE_DIGITS)
  68. #define DEVICE_BASE_NAME "mdm"
  69. #define DEVICE_NAME_LENGTH \
  70. (sizeof(DEVICE_BASE_NAME) + MAX_DEVICE_DIGITS)
  71. #define RD_BUF_SIZE 100
  72. #define SFR_MAX_RETRIES 10
  73. #define SFR_RETRY_INTERVAL 1000
  74. enum gpio_update_config {
  75. GPIO_UPDATE_BOOTING_CONFIG = 1,
  76. GPIO_UPDATE_RUNNING_CONFIG,
  77. };
  78. #define NORMAL_MODES_STR "normal"
  79. #define NORMAL_MODES_VALUE 0x03
  80. struct mdm_device {
  81. struct list_head link;
  82. struct mdm_modem_drv mdm_data;
  83. struct platform_device *pdev;
  84. int mdm2ap_status_valid_old_config;
  85. struct gpiomux_setting mdm2ap_status_old_config;
  86. int first_boot;
  87. struct workqueue_struct *mdm_queue;
  88. struct workqueue_struct *mdm_sfr_queue;
  89. unsigned int dump_timeout_ms;
  90. char subsys_name[SUBSYS_NAME_LENGTH];
  91. struct subsys_desc mdm_subsys;
  92. struct subsys_device *mdm_subsys_dev;
  93. char device_name[DEVICE_NAME_LENGTH];
  94. struct miscdevice misc_device;
  95. struct completion mdm_needs_reload;
  96. struct completion mdm_boot;
  97. struct completion mdm_ram_dumps;
  98. int mdm_errfatal_irq;
  99. int mdm_status_irq;
  100. int mdm_pblrdy_irq;
  101. struct delayed_work mdm2ap_status_check_work;
  102. struct work_struct mdm_status_work;
  103. struct work_struct sfr_reason_work;
  104. int ssr_started_internally;
  105. struct mdm_vddmin_resource vddmin_resource;
  106. };
  107. #if 0
  108. static struct mdm_platform_data sglte_platform_data = {
  109. .mdm_version = "3.0",
  110. .ramdump_delay_ms = 2000,
  111. .ramdump_timeout_ms = 600000,
  112. .no_powerdown_after_ramdumps = 1,
  113. .image_upgrade_supported = 1,
  114. .no_a2m_errfatal_on_ssr = 1,
  115. .no_reset_on_first_powerup = 1,
  116. .kpd_not_inverted = 1,
  117. .subsys_name = "external_modem",
  118. };
  119. #endif
  120. static struct list_head mdm_devices;
  121. static DEFINE_SPINLOCK(mdm_devices_lock);
  122. static int ssr_count;
  123. static DEFINE_SPINLOCK(ssr_lock);
  124. static unsigned int mdm_debug_mask;
  125. int vddmin_gpios_sent;
  126. static struct mdm_ops *mdm_ops;
  127. /* Required gpios */
  128. static const int required_gpios[] = {
  129. MDM2AP_ERRFATAL,
  130. AP2MDM_ERRFATAL,
  131. MDM2AP_STATUS,
  132. AP2MDM_STATUS,
  133. AP2MDM_SOFT_RESET
  134. };
  135. static struct gpio_map {
  136. const char *name;
  137. int index;
  138. } gpio_map[] = {
  139. {"qcom,mdm2ap-errfatal-gpio", MDM2AP_ERRFATAL},
  140. {"qcom,ap2mdm-errfatal-gpio", AP2MDM_ERRFATAL},
  141. {"qcom,mdm2ap-status-gpio", MDM2AP_STATUS},
  142. {"qcom,ap2mdm-status-gpio", AP2MDM_STATUS},
  143. {"qcom,mdm2ap-pblrdy-gpio", MDM2AP_PBLRDY},
  144. {"qcom,ap2mdm-wakeup-gpio", AP2MDM_WAKEUP},
  145. {"qcom,ap2mdm-chnlrdy-gpio", AP2MDM_CHNLRDY},
  146. {"qcom,mdm2ap-wakeup-gpio", MDM2AP_WAKEUP},
  147. {"qcom,ap2mdm-vddmin-gpio", AP2MDM_VDDMIN},
  148. {"qcom,mdm2ap-vddmin-gpio", MDM2AP_VDDMIN},
  149. {"qcom,ap2mdm-pmic-pwr-en-gpio", AP2MDM_PMIC_PWR_EN},
  150. {"qcom,use-usb-port-gpio", USB_SW},
  151. };
  152. void mdm_raise_mdm_errfatal(void)
  153. {
  154. printk(KERN_ERR "%s: Raise MDM forced errfatal\n", __func__);
  155. gpio_set_value(115, 1);
  156. }
  157. EXPORT_SYMBOL(mdm_raise_mdm_errfatal);
  158. static void mdm_debug_gpio_show(struct mdm_device *mdev)
  159. {
  160. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  161. pr_debug("%s: MDM2AP_ERRFATAL gpio = %d\n",
  162. __func__, MDM_GPIO(MDM2AP_ERRFATAL));
  163. pr_debug("%s: AP2MDM_ERRFATAL gpio = %d\n",
  164. __func__, MDM_GPIO(AP2MDM_ERRFATAL));
  165. pr_debug("%s: MDM2AP_STATUS gpio = %d\n",
  166. __func__, MDM_GPIO(MDM2AP_STATUS));
  167. pr_debug("%s: AP2MDM_STATUS gpio = %d\n",
  168. __func__, MDM_GPIO(AP2MDM_STATUS));
  169. pr_debug("%s: AP2MDM_SOFT_RESET gpio = %d\n",
  170. __func__, MDM_GPIO(AP2MDM_SOFT_RESET));
  171. pr_debug("%s: MDM2AP_WAKEUP gpio = %d\n",
  172. __func__, MDM_GPIO(MDM2AP_WAKEUP));
  173. pr_debug("%s: AP2MDM_WAKEUP gpio = %d\n",
  174. __func__, MDM_GPIO(AP2MDM_WAKEUP));
  175. pr_debug("%s: AP2MDM_KPDPWR gpio = %d\n",
  176. __func__, MDM_GPIO(AP2MDM_KPDPWR));
  177. pr_debug("%s: AP2MDM_PMIC_PWR_EN gpio = %d\n",
  178. __func__, MDM_GPIO(AP2MDM_PMIC_PWR_EN));
  179. pr_debug("%s: MDM2AP_PBLRDY gpio = %d\n",
  180. __func__, MDM_GPIO(MDM2AP_PBLRDY));
  181. pr_debug("%s: USB_SW gpio = %d\n",
  182. __func__, MDM_GPIO(USB_SW));
  183. pr_debug("%s: AP2MDM_VDDMIN gpio = %d\n",
  184. __func__, MDM_GPIO(AP2MDM_VDDMIN));
  185. pr_debug("%s: MDM2AP_VDDMIN gpio = %d\n",
  186. __func__, MDM_GPIO(MDM2AP_VDDMIN));
  187. }
  188. static void mdm_device_list_add(struct mdm_device *mdev)
  189. {
  190. unsigned long flags;
  191. spin_lock_irqsave(&mdm_devices_lock, flags);
  192. list_add_tail(&mdev->link, &mdm_devices);
  193. spin_unlock_irqrestore(&mdm_devices_lock, flags);
  194. }
  195. static void mdm_device_list_remove(struct mdm_device *mdev)
  196. {
  197. unsigned long flags;
  198. struct mdm_device *lmdev, *tmp;
  199. spin_lock_irqsave(&mdm_devices_lock, flags);
  200. list_for_each_entry_safe(lmdev, tmp, &mdm_devices, link) {
  201. if (mdev && mdev == lmdev) {
  202. pr_debug("%s: removing device id %d\n",
  203. __func__, mdev->mdm_data.device_id);
  204. list_del(&mdev->link);
  205. break;
  206. }
  207. }
  208. spin_unlock_irqrestore(&mdm_devices_lock, flags);
  209. }
  210. /* If the platform's cascading_ssr flag is set, the subsystem
  211. * restart module will restart the other modems so stop
  212. * monitoring them as well.
  213. * This function can be called from interrupt context.
  214. */
  215. static void mdm_start_ssr(struct mdm_device *mdev)
  216. {
  217. unsigned long flags;
  218. int start_ssr = 1;
  219. dump_stack();
  220. pr_info("%s: %d \n",__func__,__LINE__);
  221. spin_lock_irqsave(&ssr_lock, flags);
  222. if (mdev->mdm_data.pdata->cascading_ssr &&
  223. ssr_count > 0) {
  224. start_ssr = 0;
  225. } else {
  226. ssr_count++;
  227. mdev->ssr_started_internally = 1;
  228. }
  229. spin_unlock_irqrestore(&ssr_lock, flags);
  230. if (start_ssr) {
  231. atomic_set(&mdev->mdm_data.mdm_ready, 0);
  232. pr_info("%s: Resetting mdm id %d due to mdm error\n",
  233. __func__, mdev->mdm_data.device_id);
  234. subsystem_restart_dev(mdev->mdm_subsys_dev);
  235. } else {
  236. pr_info("%s: Another modem is already in SSR\n",
  237. __func__);
  238. }
  239. }
  240. /* Increment the reference count to handle the case where
  241. * subsystem restart is initiated by the SSR service.
  242. */
  243. static void mdm_ssr_started(struct mdm_device *mdev)
  244. {
  245. unsigned long flags;
  246. pr_info("%s: %d \n",__func__,__LINE__);
  247. spin_lock_irqsave(&ssr_lock, flags);
  248. ssr_count++;
  249. atomic_set(&mdev->mdm_data.mdm_ready, 0);
  250. spin_unlock_irqrestore(&ssr_lock, flags);
  251. pr_info("%s: %d \n",__func__,__LINE__);
  252. }
  253. /* mdm_ssr_completed assumes that mdm_ssr_started has previously
  254. * been called.
  255. */
  256. static void mdm_ssr_completed(struct mdm_device *mdev)
  257. {
  258. unsigned long flags;
  259. spin_lock_irqsave(&ssr_lock, flags);
  260. ssr_count--;
  261. if (mdev->ssr_started_internally) {
  262. mdev->ssr_started_internally = 0;
  263. ssr_count--;
  264. }
  265. if (ssr_count < 0) {
  266. pr_err("%s: ssr_count = %d\n",
  267. __func__, ssr_count);
  268. panic("%s: ssr_count = %d < 0\n",
  269. __func__, ssr_count);
  270. }
  271. spin_unlock_irqrestore(&ssr_lock, flags);
  272. }
  273. static irqreturn_t mdm_vddmin_change(int irq, void *dev_id)
  274. {
  275. struct mdm_device *mdev = (struct mdm_device *)dev_id;
  276. struct mdm_vddmin_resource *vddmin_res;
  277. int value;
  278. if (!mdev)
  279. goto handled;
  280. vddmin_res = mdev->mdm_data.pdata->vddmin_resource;
  281. if (!vddmin_res)
  282. goto handled;
  283. value = gpio_get_value(
  284. vddmin_res->mdm2ap_vddmin_gpio);
  285. if (value == 0)
  286. pr_debug("External Modem id %d entered Vddmin\n",
  287. mdev->mdm_data.device_id);
  288. else
  289. pr_debug("External Modem id %d exited Vddmin\n",
  290. mdev->mdm_data.device_id);
  291. handled:
  292. return IRQ_HANDLED;
  293. }
  294. /* The vddmin_res resource may not be supported by some platforms. */
  295. static void mdm_setup_vddmin_gpios(void)
  296. {
  297. unsigned long flags;
  298. struct msm_rpm_iv_pair req;
  299. struct mdm_device *mdev;
  300. struct mdm_vddmin_resource *vddmin_res;
  301. int irq, ret;
  302. spin_lock_irqsave(&mdm_devices_lock, flags);
  303. list_for_each_entry(mdev, &mdm_devices, link) {
  304. vddmin_res = mdev->mdm_data.pdata->vddmin_resource;
  305. if (!vddmin_res)
  306. continue;
  307. pr_debug("Enabling vddmin logging on modem id %d\n",
  308. mdev->mdm_data.device_id);
  309. req.id = vddmin_res->rpm_id;
  310. req.value =
  311. ((uint32_t)vddmin_res->ap2mdm_vddmin_gpio & 0x0000FFFF)
  312. << 16;
  313. req.value |= ((uint32_t)vddmin_res->modes & 0x000000FF) << 8;
  314. req.value |= (uint32_t)vddmin_res->drive_strength & 0x000000FF;
  315. msm_rpm_set(MSM_RPM_CTX_SET_0, &req, 1);
  316. /* Start monitoring low power gpio from mdm */
  317. irq = platform_get_irq_byname(mdev->pdev, "mdm2ap_vddmin_irq");
  318. if (irq < 0)
  319. pr_err("%s: could not get LPM POWER IRQ resource mdm id %d.\n",
  320. __func__, mdev->mdm_data.device_id);
  321. else {
  322. ret = request_threaded_irq(irq, NULL, mdm_vddmin_change,
  323. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  324. "mdm lpm", mdev);
  325. if (ret < 0)
  326. pr_err("%s: MDM LPM IRQ#%d request failed with error=%d",
  327. __func__, irq, ret);
  328. }
  329. }
  330. spin_unlock_irqrestore(&mdm_devices_lock, flags);
  331. return;
  332. }
  333. static void mdm_restart_reason_fn(struct work_struct *work)
  334. {
  335. int ret, ntries = 0;
  336. char sfr_buf[RD_BUF_SIZE];
  337. struct mdm_platform_data *pdata;
  338. struct mdm_device *mdev = container_of(work,
  339. struct mdm_device, sfr_reason_work);
  340. pdata = mdev->mdm_data.pdata;
  341. if (pdata->sysmon_subsys_id_valid) {
  342. do {
  343. ret = sysmon_get_reason(pdata->sysmon_subsys_id,
  344. sfr_buf, sizeof(sfr_buf));
  345. if (!ret) {
  346. pr_err("mdm restart reason: %s\n", sfr_buf);
  347. return;
  348. }
  349. /* Wait for the modem to be fully booted after a
  350. * subsystem restart. This may take several seconds.
  351. */
  352. msleep(SFR_RETRY_INTERVAL);
  353. } while (++ntries < SFR_MAX_RETRIES);
  354. pr_debug("%s: Error retrieving restart reason: %d\n",
  355. __func__, ret);
  356. }
  357. }
  358. static void mdm2ap_status_check(struct work_struct *work)
  359. {
  360. struct mdm_device *mdev =
  361. container_of(work, struct mdm_device,
  362. mdm2ap_status_check_work.work);
  363. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  364. subsys_set_flag_skip_ramdump(mdev->mdm_subsys_dev, false);
  365. /*
  366. * If the mdm modem did not pull the MDM2AP_STATUS gpio
  367. * high then call subsystem_restart.
  368. */
  369. pr_info("%s: %d\n",__func__, __LINE__);
  370. if (!mdm_drv->disable_status_check) {
  371. if (gpio_get_value(MDM_GPIO(MDM2AP_STATUS)) == 0) {
  372. pr_info("%s: MDM2AP_STATUS did not go high on mdm id %d\n",
  373. __func__, mdev->mdm_data.device_id);
  374. // subsys_set_flag_skip_ramdump(mdev->mdm_subsys_dev ,true);
  375. mdm_start_ssr(mdev);
  376. }
  377. }
  378. pr_info("%s: %d\n",__func__, __LINE__);
  379. }
  380. static void mdm_update_gpio_configs(struct mdm_device *mdev,
  381. enum gpio_update_config gpio_config)
  382. {
  383. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  384. /* Some gpio configuration may need updating after modem bootup.*/
  385. switch (gpio_config) {
  386. case GPIO_UPDATE_RUNNING_CONFIG:
  387. if (mdm_drv->pdata->mdm2ap_status_gpio_run_cfg) {
  388. if (msm_gpiomux_write(MDM_GPIO(MDM2AP_STATUS),
  389. GPIOMUX_ACTIVE,
  390. mdm_drv->pdata->mdm2ap_status_gpio_run_cfg,
  391. &mdev->mdm2ap_status_old_config))
  392. pr_err("%s: failed updating running gpio config mdm id %d\n",
  393. __func__, mdev->mdm_data.device_id);
  394. else
  395. mdev->mdm2ap_status_valid_old_config = 1;
  396. }
  397. break;
  398. case GPIO_UPDATE_BOOTING_CONFIG:
  399. if (mdev->mdm2ap_status_valid_old_config) {
  400. msm_gpiomux_write(MDM_GPIO(MDM2AP_STATUS),
  401. GPIOMUX_ACTIVE,
  402. &mdev->mdm2ap_status_old_config,
  403. NULL);
  404. mdev->mdm2ap_status_valid_old_config = 0;
  405. }
  406. break;
  407. default:
  408. pr_err("%s: called with no config\n", __func__);
  409. break;
  410. }
  411. }
  412. static long mdm_modem_ioctl(struct file *filp, unsigned int cmd,
  413. unsigned long arg)
  414. {
  415. int status, ret = 0;
  416. struct mdm_device *mdev = filp->private_data;
  417. struct mdm_modem_drv *mdm_drv;
  418. pr_info("%s %d \n", __func__, __LINE__);
  419. if (_IOC_TYPE(cmd) != CHARM_CODE) {
  420. pr_err("%s: invalid ioctl code to mdm id %d\n",
  421. __func__, mdev->mdm_data.device_id);
  422. return -EINVAL;
  423. }
  424. pr_info("%s %d \n", __func__, __LINE__);
  425. mdm_drv = &mdev->mdm_data;
  426. pr_info("%s: Entering ioctl cmd = %d, mdm id = %d\n",
  427. __func__, _IOC_NR(cmd), mdev->mdm_data.device_id);
  428. switch (cmd) {
  429. case WAKE_CHARM:
  430. pr_debug("%s: Powering on mdm id %d\n",
  431. __func__, mdev->mdm_data.device_id);
  432. mdm_ops->power_on_mdm_cb(mdm_drv);
  433. break;
  434. case CHECK_FOR_BOOT:
  435. if (gpio_get_value(MDM_GPIO(MDM2AP_STATUS)) == 0)
  436. put_user(1, (unsigned long __user *) arg);
  437. else
  438. put_user(0, (unsigned long __user *) arg);
  439. break;
  440. case NORMAL_BOOT_DONE:
  441. pr_debug("%s: check if mdm id %d is booted up\n",
  442. __func__, mdev->mdm_data.device_id);
  443. get_user(status, (unsigned long __user *) arg);
  444. if (status) {
  445. pr_debug("%s: normal boot of mdm id %d failed\n",
  446. __func__, mdev->mdm_data.device_id);
  447. mdm_drv->mdm_boot_status = -EIO;
  448. } else {
  449. pr_debug("%s: normal boot of mdm id %d done\n",
  450. __func__, mdev->mdm_data.device_id);
  451. mdm_drv->mdm_boot_status = 0;
  452. }
  453. atomic_set(&mdm_drv->mdm_ready, 1);
  454. if (mdm_ops->normal_boot_done_cb != NULL)
  455. mdm_ops->normal_boot_done_cb(mdm_drv);
  456. if (!mdev->first_boot)
  457. complete(&mdev->mdm_boot);
  458. else
  459. mdev->first_boot = 0;
  460. /* If userspace has reset the peripheral device then
  461. * inform the modem here.
  462. */
  463. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_CHNLRDY)))
  464. gpio_direction_output(
  465. MDM_GPIO(AP2MDM_CHNLRDY), 1);
  466. /* If successful, start a timer to check that the mdm2ap_status
  467. * gpio goes high.
  468. */
  469. if (!status && gpio_get_value(MDM_GPIO(MDM2AP_STATUS)) == 0)
  470. schedule_delayed_work(&mdev->mdm2ap_status_check_work,
  471. msecs_to_jiffies(MDM2AP_STATUS_TIMEOUT_MS));
  472. break;
  473. case RAM_DUMP_DONE:
  474. pr_info("%s: mdm done collecting RAM dumps\n", __func__);
  475. get_user(status, (unsigned long __user *) arg);
  476. if (status)
  477. mdm_drv->mdm_ram_dump_status = -EIO;
  478. else {
  479. pr_debug("%s: ramdump collection completed\n",
  480. __func__);
  481. mdm_drv->mdm_ram_dump_status = 0;
  482. #ifdef CONFIG_SEC_DEBUG_MDM_FILE_INFO
  483. if (sec_debug_is_enabled()) {
  484. panic("external_modem QSC err-fatal");
  485. }
  486. #endif
  487. }
  488. complete(&mdev->mdm_ram_dumps);
  489. break;
  490. case WAIT_FOR_RESTART:
  491. pr_info("%s: wait for mdm to need images reloaded\n",
  492. __func__);
  493. ret = wait_for_completion_interruptible(
  494. &mdev->mdm_needs_reload);
  495. pr_info("%s: wait returned(ret:%d)\n",
  496. __func__, ret);
  497. if (!ret)
  498. put_user(mdm_drv->boot_type,
  499. (unsigned long __user *) arg);
  500. init_completion(&mdev->mdm_needs_reload);
  501. break;
  502. case GET_DLOAD_STATUS:
  503. pr_debug("getting status of mdm2ap_errfatal_gpio\n");
  504. if (gpio_get_value(MDM_GPIO(MDM2AP_ERRFATAL)) == 1 &&
  505. !atomic_read(&mdm_drv->mdm_ready))
  506. put_user(1, (unsigned long __user *) arg);
  507. else
  508. put_user(0, (unsigned long __user *) arg);
  509. break;
  510. case IMAGE_UPGRADE:
  511. pr_info("%s Image upgrade ioctl recieved\n", __func__);
  512. mdm_drv->pdata->image_upgrade_supported =1;
  513. if (mdm_drv->pdata->image_upgrade_supported &&
  514. mdm_ops->image_upgrade_cb) {
  515. pr_info("%s enter dload\n", __func__);
  516. get_user(status, (unsigned long __user *) arg);
  517. mdm_ops->image_upgrade_cb(mdm_drv, status);
  518. } else
  519. pr_info("%s Image upgrade not supported, %d\n", __func__, mdm_drv->pdata->image_upgrade_supported);
  520. break;
  521. case SHUTDOWN_CHARM:
  522. if (!mdm_drv->pdata->send_shdn)
  523. break;
  524. atomic_set(&mdm_drv->mdm_ready, 0);
  525. if (mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG)
  526. pr_debug("Sending shutdown request to mdm\n");
  527. ret = sysmon_send_shutdown(mdm_drv->pdata->sysmon_subsys_id);
  528. if (ret)
  529. pr_err("%s:Graceful shutdown of mdm failed, ret = %d\n",
  530. __func__, ret);
  531. break;
  532. default:
  533. pr_err("%s: invalid ioctl cmd = %d\n", __func__, _IOC_NR(cmd));
  534. ret = -EINVAL;
  535. break;
  536. }
  537. return ret;
  538. }
  539. static void mdm_status_fn(struct work_struct *work)
  540. {
  541. struct mdm_device *mdev =
  542. container_of(work, struct mdm_device, mdm_status_work);
  543. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  544. int value = gpio_get_value(MDM_GPIO(MDM2AP_STATUS));
  545. pr_debug("%s: status:%d\n", __func__, value);
  546. if (atomic_read(&mdm_drv->mdm_ready) && mdm_ops->status_cb)
  547. mdm_ops->status_cb(mdm_drv, value);
  548. /* Update gpio configuration to "running" config. */
  549. mdm_update_gpio_configs(mdev, GPIO_UPDATE_RUNNING_CONFIG);
  550. }
  551. static void mdm_disable_irqs(struct mdm_device *mdev)
  552. {
  553. if (!mdev)
  554. return;
  555. disable_irq_nosync(mdev->mdm_errfatal_irq);
  556. disable_irq_nosync(mdev->mdm_status_irq);
  557. #ifdef USE_MDM_MODEM
  558. disable_irq_nosync(mdev->mdm_pblrdy_irq);
  559. #endif
  560. }
  561. static irqreturn_t mdm_errfatal(int irq, void *dev_id)
  562. {
  563. struct mdm_modem_drv *mdm_drv;
  564. struct mdm_device *mdev = (struct mdm_device *)dev_id;
  565. pr_info("%s: %d\n",__func__, __LINE__);
  566. if (!mdev)
  567. return IRQ_HANDLED;
  568. mdelay(2); //ADD THIS LINE
  569. pr_info("%s: mdm id %d sent errfatal interrupt\n",
  570. __func__, mdev->mdm_data.device_id);
  571. mdm_drv = &mdev->mdm_data;
  572. if (atomic_read(&mdm_drv->mdm_ready) &&
  573. (gpio_get_value(MDM_GPIO(MDM2AP_STATUS)) == 1)) {
  574. pr_info("%s: Received err fatal from mdm id %d\n",
  575. __func__, mdev->mdm_data.device_id);
  576. mdm_start_ssr(mdev);
  577. }
  578. return IRQ_HANDLED;
  579. }
  580. /* set the mdm_device as the file's private data */
  581. static int mdm_modem_open(struct inode *inode, struct file *file)
  582. {
  583. struct miscdevice *misc = file->private_data;
  584. struct mdm_device *mdev = container_of(misc,
  585. struct mdm_device, misc_device);
  586. file->private_data = mdev;
  587. return 0;
  588. }
  589. static void mdm_crash_shutdown(const struct subsys_desc *mdm_subsys)
  590. {
  591. int i;
  592. struct mdm_modem_drv *mdm_drv;
  593. struct mdm_device *mdev = container_of(mdm_subsys, struct mdm_device,
  594. mdm_subsys);
  595. mdm_drv = &mdev->mdm_data;
  596. pr_debug("%s: setting AP2MDM_ERRFATAL high for a non graceful reset\n",
  597. __func__);
  598. mdm_disable_irqs(mdev);
  599. gpio_set_value(MDM_GPIO(AP2MDM_ERRFATAL), 1);
  600. for (i = MDM_MODEM_TIMEOUT; i > 0; i -= MDM_MODEM_DELTA) {
  601. pet_watchdog();
  602. mdelay(MDM_MODEM_DELTA);
  603. if (gpio_get_value(MDM_GPIO(MDM2AP_STATUS)) == 0)
  604. break;
  605. }
  606. if (i <= 0) {
  607. pr_err("%s: MDM2AP_STATUS never went low\n", __func__);
  608. /* Reset the modem so that it will go into download mode. */
  609. if (mdm_drv && mdm_ops->atomic_reset_mdm_cb)
  610. mdm_ops->atomic_reset_mdm_cb(mdm_drv);
  611. }
  612. }
  613. static void mdm_print_all_pin(struct mdm_modem_drv *mdm_drv)
  614. {
  615. pr_info("============================\n");
  616. pr_info("AP2MDM_KPDPWR :%d\n", gpio_get_value(MDM_GPIO(AP2MDM_KPDPWR)));
  617. pr_info("AP2MDM_STATUS :%d\n", gpio_get_value(MDM_GPIO(AP2MDM_STATUS)));
  618. pr_info("AP2MDM_ERRFATAL :%d\n", gpio_get_value(MDM_GPIO(AP2MDM_ERRFATAL)));
  619. pr_info("AP2MDM_PMIC_PWR_EN :%d\n", gpio_get_value(MDM_GPIO(AP2MDM_PMIC_PWR_EN)));
  620. pr_info("AP2MDM_SOFT_RESET :%d\n", gpio_get_value(MDM_GPIO(AP2MDM_SOFT_RESET)));
  621. pr_info("AP2MDM_WAKEUP :%d\n", gpio_get_value(MDM_GPIO(AP2MDM_WAKEUP)));
  622. pr_info("MDM2AP_STATUS :%d\n", gpio_get_value(MDM_GPIO(MDM2AP_STATUS)));
  623. pr_info("MDM2AP_ERRFATAL :%d\n", gpio_get_value(MDM_GPIO(MDM2AP_ERRFATAL)));
  624. pr_info("============================\n");
  625. }
  626. static irqreturn_t mdm_status_change(int irq, void *dev_id)
  627. {
  628. struct mdm_modem_drv *mdm_drv;
  629. struct mdm_device *mdev = (struct mdm_device *)dev_id;
  630. int value;
  631. if (!mdev)
  632. return IRQ_HANDLED;
  633. pr_info("%s: MDM2AP_STATUS(irq:%d)\n",__func__,
  634. mdev->mdm_status_irq);
  635. /*delay to ensure the status gpio value is correct (i.e not caused by some noise) */
  636. mdelay(2);
  637. mdm_drv = &mdev->mdm_data;
  638. value = gpio_get_value(MDM_GPIO(MDM2AP_STATUS));
  639. pr_info("%s: MDM2AP_STATUS(irq:%d):%d\n",__func__,
  640. mdev->mdm_status_irq, value);
  641. mdm_print_all_pin(mdm_drv);
  642. if ((mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG) && (value == 0))
  643. pr_info("%s: mdm2ap_status went low\n", __func__);
  644. if (value == 0 && atomic_read(&mdm_drv->mdm_ready)) {
  645. pr_info("%s: unexpected reset external modem id %d\n",
  646. __func__, mdev->mdm_data.device_id);
  647. #ifdef CONFIG_ABNORMAL_RESET_SKIP_RAMPDUMP
  648. pr_info("%s: forced skip_rampdump\n", __func__);
  649. mdm_drv->need_clean_reset = true;
  650. subsys_set_flag_skip_ramdump(mdev->mdm_subsys_dev, true);
  651. #endif
  652. mdm_drv->mdm_unexpected_reset_occurred = 1;
  653. mdm_start_ssr(mdev);
  654. } else if (value == 1) {
  655. cancel_delayed_work(&mdev->mdm2ap_status_check_work);
  656. pr_info("%s: status = 1: mdm id %d is now ready\n",
  657. __func__, mdev->mdm_data.device_id);
  658. queue_work(mdev->mdm_queue, &mdev->mdm_status_work);
  659. }
  660. #ifdef CONFIG_STATUS_IRQ_BY_LEVEL_TRIG
  661. if (value)
  662. irq_set_irq_type(irq, IRQF_TRIGGER_LOW | IRQF_ONESHOT);
  663. else
  664. irq_set_irq_type(irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT);
  665. #endif
  666. return IRQ_HANDLED;
  667. }
  668. #ifdef USE_MDM_MODEM
  669. static irqreturn_t mdm_pblrdy_change(int irq, void *dev_id)
  670. {
  671. struct mdm_modem_drv *mdm_drv;
  672. struct mdm_device *mdev = (struct mdm_device *)dev_id;
  673. if (!mdev)
  674. return IRQ_HANDLED;
  675. mdm_drv = &mdev->mdm_data;
  676. pr_debug("%s: mdm id %d: pbl ready:%d\n",
  677. __func__, mdev->mdm_data.device_id,
  678. gpio_get_value(MDM_GPIO(MDM2AP_PBLRDY)));
  679. return IRQ_HANDLED;
  680. }
  681. #endif
  682. static int mdm_subsys_shutdown(const struct subsys_desc *crashed_subsys)
  683. {
  684. struct mdm_device *mdev =
  685. container_of(crashed_subsys, struct mdm_device, mdm_subsys);
  686. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  687. pr_info("%s: ssr on modem id %d\n", __func__,
  688. mdev->mdm_data.device_id);
  689. mdm_ssr_started(mdev);
  690. cancel_delayed_work(&mdev->mdm2ap_status_check_work);
  691. if (!mdm_drv->pdata->no_a2m_errfatal_on_ssr)
  692. gpio_direction_output(MDM_GPIO(AP2MDM_ERRFATAL), 1);
  693. if (mdm_drv->pdata->ramdump_delay_ms > 0) {
  694. /* Wait for the external modem to complete
  695. * its preparation for ramdumps.
  696. */
  697. msleep(mdm_drv->pdata->ramdump_delay_ms);
  698. }
  699. if (!mdm_drv->mdm_unexpected_reset_occurred) {
  700. mdm_ops->reset_mdm_cb(mdm_drv);
  701. mdm_update_gpio_configs(mdev, GPIO_UPDATE_BOOTING_CONFIG);
  702. }
  703. else
  704. mdm_drv->mdm_unexpected_reset_occurred = 0;
  705. return 0;
  706. }
  707. static int mdm_subsys_powerup(const struct subsys_desc *crashed_subsys)
  708. {
  709. struct mdm_device *mdev =
  710. container_of(crashed_subsys, struct mdm_device,
  711. mdm_subsys);
  712. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  713. pr_debug("%s: ssr on modem id %d\n",
  714. __func__, mdev->mdm_data.device_id);
  715. gpio_direction_output(MDM_GPIO(AP2MDM_ERRFATAL), 0);
  716. gpio_direction_output(MDM_GPIO(AP2MDM_STATUS), 1);
  717. if (mdm_drv->pdata->ps_hold_delay_ms > 0)
  718. msleep(mdm_drv->pdata->ps_hold_delay_ms);
  719. mdm_ops->power_on_mdm_cb(mdm_drv);
  720. mdm_drv->boot_type = CHARM_NORMAL_BOOT;
  721. complete(&mdev->mdm_needs_reload);
  722. if (!wait_for_completion_timeout(&mdev->mdm_boot,
  723. msecs_to_jiffies(MDM_BOOT_TIMEOUT))) {
  724. mdm_drv->mdm_boot_status = -ETIMEDOUT;
  725. pr_debug("%s: mdm modem restart timed out.\n", __func__);
  726. } else {
  727. pr_debug("%s: id %d: mdm modem has been restarted\n",
  728. __func__, mdm_drv->device_id);
  729. /* Log the reason for the restart */
  730. if (mdm_drv->pdata->sfr_query)
  731. queue_work(mdev->mdm_sfr_queue, &mdev->sfr_reason_work);
  732. }
  733. init_completion(&mdev->mdm_boot);
  734. return mdm_drv->mdm_boot_status;
  735. }
  736. static int mdm_subsys_ramdumps(int want_dumps,
  737. const struct subsys_desc *crashed_subsys)
  738. {
  739. struct mdm_device *mdev =
  740. container_of(crashed_subsys, struct mdm_device,
  741. mdm_subsys);
  742. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  743. pr_info("%s: ssr on modem id %d\n", __func__,
  744. mdev->mdm_data.device_id);
  745. mdm_drv->mdm_ram_dump_status = 0;
  746. cancel_delayed_work(&mdev->mdm2ap_status_check_work);
  747. if (want_dumps) {
  748. /* DEBUG: Disable the IPC logging */
  749. //msm_hs_disable_ipc_log();
  750. mdm_drv->boot_type = CHARM_RAM_DUMPS;
  751. complete(&mdev->mdm_needs_reload);
  752. if (!wait_for_completion_timeout(&mdev->mdm_ram_dumps,
  753. msecs_to_jiffies(mdev->dump_timeout_ms))) {
  754. mdm_drv->mdm_ram_dump_status = -ETIMEDOUT;
  755. mdm_ssr_completed(mdev);
  756. pr_err("%s: mdm modem ramdumps timed out.\n",
  757. __func__);
  758. } else
  759. pr_debug("%s: mdm modem ramdumps completed.\n",
  760. __func__);
  761. init_completion(&mdev->mdm_ram_dumps);
  762. if (!mdm_drv->pdata->no_powerdown_after_ramdumps) {
  763. mdm_ops->power_down_mdm_cb(mdm_drv);
  764. /* Update gpio configuration to "booting" config. */
  765. mdm_update_gpio_configs(mdev,
  766. GPIO_UPDATE_BOOTING_CONFIG);
  767. }
  768. }
  769. return mdm_drv->mdm_ram_dump_status;
  770. }
  771. /* Once the gpios are sent to RPM and debugging
  772. * starts, there is no way to stop it without
  773. * rebooting the device.
  774. */
  775. static int mdm_debug_mask_set(void *data, u64 val)
  776. {
  777. if (!vddmin_gpios_sent &&
  778. (val & MDM_DEBUG_MASK_VDDMIN_SETUP)) {
  779. mdm_setup_vddmin_gpios();
  780. vddmin_gpios_sent = 1;
  781. }
  782. mdm_debug_mask = val;
  783. if (mdm_ops->debug_state_changed_cb)
  784. mdm_ops->debug_state_changed_cb(mdm_debug_mask);
  785. return 0;
  786. }
  787. static int mdm_debug_mask_get(void *data, u64 *val)
  788. {
  789. *val = mdm_debug_mask;
  790. return 0;
  791. }
  792. DEFINE_SIMPLE_ATTRIBUTE(mdm_debug_mask_fops,
  793. mdm_debug_mask_get,
  794. mdm_debug_mask_set, "%llu\n");
  795. static int mdm_debugfs_init(void)
  796. {
  797. struct dentry *dent;
  798. dent = debugfs_create_dir("mdm_dbg", 0);
  799. if (IS_ERR(dent))
  800. return PTR_ERR(dent);
  801. debugfs_create_file("debug_mask", 0644, dent, NULL,
  802. &mdm_debug_mask_fops);
  803. return 0;
  804. }
  805. static const struct file_operations mdm_modem_fops = {
  806. .owner = THIS_MODULE,
  807. .open = mdm_modem_open,
  808. .unlocked_ioctl = mdm_modem_ioctl,
  809. };
  810. /* Fail if any of the required gpios is absent. */
  811. static int mdm_dt_to_gpio_rscs(struct device_node *node,
  812. struct mdm_device *mdev)
  813. {
  814. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  815. int i, val, rc = 0;
  816. enum of_gpio_flags flags = OF_GPIO_ACTIVE_LOW;
  817. for (i = 0; i < GPIO_TOTAL; i++)
  818. mdm_drv->gpios[i] = INVALID_GPIO;
  819. for (i = 0; i < ARRAY_SIZE(gpio_map); i++) {
  820. val = of_get_named_gpio(node, gpio_map[i].name, 0);
  821. if (val >= 0)
  822. MDM_GPIO(gpio_map[i].index) = val;
  823. }
  824. /* These two are special because they can be inverted. */
  825. val = of_get_named_gpio_flags(node, "qcom,ap2mdm-soft-reset-gpio",
  826. 0, &flags);
  827. if (val >= 0) {
  828. MDM_GPIO(AP2MDM_SOFT_RESET) = val;
  829. if (flags & OF_GPIO_ACTIVE_LOW)
  830. mdm_drv->pdata->soft_reset_inverted = 1;
  831. }
  832. val = of_get_named_gpio_flags(node, "qcom,ap2mdm-kpdpwr-gpio",
  833. 0, &flags);
  834. if (val >= 0) {
  835. MDM_GPIO(AP2MDM_KPDPWR) = val;
  836. if (!(flags & OF_GPIO_ACTIVE_LOW))
  837. mdm_drv->pdata->kpd_not_inverted = 1;
  838. }
  839. /* Verify that the required gpios have valid values */
  840. for (i = 0; i < ARRAY_SIZE(required_gpios); i++) {
  841. if (MDM_GPIO(required_gpios[i]) == INVALID_GPIO) {
  842. rc = -ENXIO;
  843. break;
  844. }
  845. }
  846. mdm_debug_gpio_show(mdev);
  847. return rc;
  848. }
  849. static int mdm_dt_to_vddmin_rscs(struct device_node *node,
  850. struct mdm_device *mdev)
  851. {
  852. int ret;
  853. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  854. const char *modes_str;
  855. /* vddmin resources may be absent */
  856. if ((MDM_GPIO(AP2MDM_VDDMIN) == INVALID_GPIO) ||
  857. (MDM_GPIO(MDM2AP_VDDMIN) == INVALID_GPIO))
  858. return -ENXIO;
  859. ret = of_property_read_string(node, "qcom,vddmin-modes", &modes_str);
  860. if (ret < 0) {
  861. pr_info("%s: vddmin_modes not set.\n", __func__);
  862. return -ENXIO;
  863. } else {
  864. if (!strcmp(modes_str, NORMAL_MODES_STR))
  865. mdev->vddmin_resource.modes = NORMAL_MODES_VALUE;
  866. else
  867. return -ENXIO;
  868. }
  869. ret = of_property_read_u32(node, "qcom,vddmin-drive-strength",
  870. &mdev->vddmin_resource.drive_strength);
  871. if (ret < 0) {
  872. pr_info("%s: vddmin_drive_strength not set.\n", __func__);
  873. return -ENXIO;
  874. }
  875. mdev->vddmin_resource.ap2mdm_vddmin_gpio =
  876. MDM_GPIO(AP2MDM_VDDMIN);
  877. mdev->vddmin_resource.mdm2ap_vddmin_gpio =
  878. MDM_GPIO(MDM2AP_VDDMIN);
  879. return 0;
  880. }
  881. static int mdm_dt_to_pdata(struct device_node *node,
  882. struct mdm_device *mdev)
  883. {
  884. struct mdm_platform_data *pdata = mdev->mdm_data.pdata;
  885. int ret;
  886. ret = mdm_dt_to_gpio_rscs(node, mdev);
  887. if (ret)
  888. return ret;
  889. ret = of_property_read_u32(node, "qcom,ramdump-delay-ms",
  890. &pdata->ramdump_delay_ms);
  891. if (ret < 0)
  892. pr_info("%s: ramdump_delay not set.\n", __func__);
  893. ret = of_property_read_u32(node, "qcom,ps-hold-delay-ms",
  894. &pdata->ps_hold_delay_ms);
  895. if (ret < 0)
  896. pr_info("%s: ps_hold_delay not set.\n", __func__);
  897. pdata->early_power_on = of_property_read_bool(node,
  898. "qcom,early-power-on");
  899. pdata->sfr_query = of_property_read_bool(node,
  900. "qcom,sfr-query");
  901. ret = of_property_read_u32(node, "qcom,ramdump-timeout-ms",
  902. &pdata->ramdump_timeout_ms);
  903. if (ret < 0)
  904. pr_info("%s: ramdump_timeout not set.\n", __func__);
  905. pdata->image_upgrade_supported = of_property_read_bool(node,
  906. "qcom,image-upgrade-supported");
  907. pdata->send_shdn = of_property_read_bool(node,
  908. "qcom,support-shutdown");
  909. ret = of_property_read_u32(node, "qcom,sysmon-subsys-id",
  910. &pdata->sysmon_subsys_id);
  911. if (ret < 0)
  912. pr_info("%s: sysmon_subsys_id not set.\n", __func__);
  913. else if (pdata->sysmon_subsys_id >= 0)
  914. pdata->sysmon_subsys_id_valid = 1;
  915. pdata->no_a2m_errfatal_on_ssr = of_property_read_bool(node,
  916. "qcom,no-a2m-errfatal-on-ssr");
  917. pdata->no_reset_on_first_powerup = of_property_read_bool(node,
  918. "qcom,no-reset-on-first-powerup");
  919. /* vddmin resources may be absent */
  920. if (!mdm_dt_to_vddmin_rscs(node, mdev))
  921. pdata->vddmin_resource = &mdev->vddmin_resource;
  922. return 0;
  923. }
  924. static int mdm_gpios_from_resources(struct platform_device *pdev,
  925. struct mdm_device *mdev)
  926. {
  927. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  928. struct resource *pres;
  929. /* MDM2AP_ERRFATAL */
  930. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  931. "MDM2AP_ERRFATAL");
  932. MDM_GPIO(MDM2AP_ERRFATAL) = pres ? pres->start : -1;
  933. /* AP2MDM_ERRFATAL */
  934. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  935. "AP2MDM_ERRFATAL");
  936. MDM_GPIO(AP2MDM_ERRFATAL) = pres ? pres->start : -1;
  937. /* MDM2AP_STATUS */
  938. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  939. "MDM2AP_STATUS");
  940. MDM_GPIO(MDM2AP_STATUS) = pres ? pres->start : -1;
  941. /* AP2MDM_STATUS */
  942. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  943. "AP2MDM_STATUS");
  944. MDM_GPIO(AP2MDM_STATUS) = pres ? pres->start : -1;
  945. /* MDM2AP_WAKEUP */
  946. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  947. "MDM2AP_WAKEUP");
  948. MDM_GPIO(MDM2AP_WAKEUP) = pres ? pres->start : -1;
  949. /* AP2MDM_WAKEUP */
  950. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  951. "AP2MDM_WAKEUP");
  952. MDM_GPIO(AP2MDM_WAKEUP) = pres ? pres->start : -1;
  953. /* AP2MDM_SOFT_RESET */
  954. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  955. "AP2MDM_SOFT_RESET");
  956. MDM_GPIO(AP2MDM_SOFT_RESET) = pres ? pres->start : -1;
  957. /* AP2MDM_KPDPWR_N */
  958. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  959. "AP2MDM_KPDPWR_N");
  960. MDM_GPIO(AP2MDM_KPDPWR) = pres ? pres->start : -1;
  961. /* AP2MDM_PMIC_PWR_EN */
  962. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  963. "AP2MDM_PMIC_PWR_EN");
  964. MDM_GPIO(AP2MDM_PMIC_PWR_EN) = pres ? pres->start : -1;
  965. #ifdef USE_MDM_MODEM
  966. /* MDM2AP_PBLRDY */
  967. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  968. "MDM2AP_PBLRDY");
  969. MDM_GPIO(MDM2AP_PBLRDY) = pres ? pres->start : -1;
  970. #endif
  971. /*USB_SW*/
  972. pres = platform_get_resource_byname(pdev, IORESOURCE_IO,
  973. "USB_SW");
  974. MDM_GPIO(USB_SW) = pres ? pres->start : -1;
  975. return 0;
  976. }
  977. static struct mdm_device
  978. *mdm_create_device_data(struct platform_device *pdev)
  979. {
  980. struct mdm_device *mdev = NULL;
  981. struct mdm_modem_drv *mdm_drv;
  982. struct mdm_platform_data *pdata = NULL;
  983. int ret = -1;
  984. mdev = devm_kzalloc(&pdev->dev, sizeof(struct mdm_device), GFP_KERNEL);
  985. if (!mdev) {
  986. dev_err(&pdev->dev, "unable to allocate memory for device data\n");
  987. return ERR_PTR(-ENOMEM);
  988. }
  989. if (pdev->dev.of_node) {
  990. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  991. if (!pdata) {
  992. dev_err(&pdev->dev, "unable to allocate memory for platform data\n");
  993. return ERR_PTR(-ENOMEM);
  994. }
  995. pdev->dev.platform_data = pdata;
  996. }
  997. mdm_drv = &mdev->mdm_data;
  998. mdm_drv->pdata = pdev->dev.platform_data;
  999. mdev->pdev = pdev;
  1000. if (pdev->dev.of_node)
  1001. ret = mdm_dt_to_pdata(pdev->dev.of_node, mdev);
  1002. else
  1003. ret = mdm_gpios_from_resources(pdev, mdev);
  1004. if (ret) {
  1005. dev_err(&pdev->dev, "invalid platform resources\n");
  1006. return ERR_PTR(ret);
  1007. }
  1008. if (pdev->id < 0)
  1009. mdm_drv->device_id = 0;
  1010. else
  1011. mdm_drv->device_id = pdev->id;
  1012. if (mdev->mdm_data.device_id <= 0)
  1013. snprintf(mdev->subsys_name, sizeof(mdev->subsys_name),
  1014. "%s", EXTERNAL_MODEM);
  1015. else
  1016. snprintf(mdev->subsys_name, sizeof(mdev->subsys_name),
  1017. "%s.%d", EXTERNAL_MODEM, mdev->mdm_data.device_id);
  1018. mdev->mdm_subsys.shutdown = mdm_subsys_shutdown;
  1019. mdev->mdm_subsys.ramdump = mdm_subsys_ramdumps;
  1020. mdev->mdm_subsys.powerup = mdm_subsys_powerup;
  1021. mdev->mdm_subsys.name = mdev->subsys_name;
  1022. mdev->mdm_subsys.crash_shutdown = mdm_crash_shutdown;
  1023. mdev->mdm_subsys.dev = &pdev->dev;
  1024. if (mdev->mdm_data.device_id <= 0)
  1025. snprintf(mdev->device_name, sizeof(mdev->device_name),
  1026. "%s", DEVICE_BASE_NAME);
  1027. else
  1028. snprintf(mdev->device_name, sizeof(mdev->device_name),
  1029. "%s%d", DEVICE_BASE_NAME, mdev->mdm_data.device_id);
  1030. mdev->misc_device.minor = MISC_DYNAMIC_MINOR;
  1031. mdev->misc_device.name = mdev->device_name;
  1032. mdev->misc_device.fops = &mdm_modem_fops;
  1033. mdm_drv->boot_type = CHARM_NORMAL_BOOT;
  1034. mdev->dump_timeout_ms = mdm_drv->pdata->ramdump_timeout_ms > 0 ?
  1035. mdm_drv->pdata->ramdump_timeout_ms : MDM_RDUMP_TIMEOUT;
  1036. init_completion(&mdev->mdm_needs_reload);
  1037. init_completion(&mdev->mdm_boot);
  1038. init_completion(&mdev->mdm_ram_dumps);
  1039. mdev->first_boot = 1;
  1040. mutex_init(&mdm_drv->peripheral_status_lock);
  1041. if (pdev->dev.of_node)
  1042. mdm_drv->peripheral_status = 1;
  1043. return mdev;
  1044. }
  1045. static void mdm_deconfigure_ipc(struct mdm_device *mdev)
  1046. {
  1047. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  1048. int i;
  1049. for (i = 0; i < GPIO_TOTAL; ++i) {
  1050. if (GPIO_IS_VALID(MDM_GPIO(i)))
  1051. gpio_free(MDM_GPIO(i));
  1052. }
  1053. if (mdev->mdm_queue) {
  1054. destroy_workqueue(mdev->mdm_queue);
  1055. mdev->mdm_queue = NULL;
  1056. }
  1057. if (mdev->mdm_sfr_queue) {
  1058. destroy_workqueue(mdev->mdm_sfr_queue);
  1059. mdev->mdm_sfr_queue = NULL;
  1060. }
  1061. }
  1062. static int mdm_configure_ipc(struct mdm_device *mdev)
  1063. {
  1064. struct mdm_modem_drv *mdm_drv = &mdev->mdm_data;
  1065. int ret = -1, irq;
  1066. pr_info("%s 1\n", __func__);
  1067. /* Multilple gpio_request calls are allowed */
  1068. if (gpio_request(MDM_GPIO(AP2MDM_STATUS), "AP2MDM_STATUS"))
  1069. pr_err("%s Failed to configure AP2MDM_STATUS gpio\n",
  1070. __func__);
  1071. /* Multilple gpio_request calls are allowed */
  1072. if (gpio_request(MDM_GPIO(AP2MDM_ERRFATAL), "AP2MDM_ERRFATAL"))
  1073. pr_err("%s Failed to configure AP2MDM_ERRFATAL gpio\n",
  1074. __func__);
  1075. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_KPDPWR))) {
  1076. if (gpio_request(MDM_GPIO(AP2MDM_KPDPWR), "AP2MDM_KPDPWR_N")) {
  1077. pr_err("%s Failed to configure AP2MDM_KPDPWR gpio\n",
  1078. __func__);
  1079. goto fatal_err;
  1080. }
  1081. }
  1082. if (gpio_request(MDM_GPIO(MDM2AP_STATUS), "MDM2AP_STATUS")) {
  1083. pr_err("%s Failed to configure MDM2AP_STATUS gpio\n",
  1084. __func__);
  1085. goto fatal_err;
  1086. }
  1087. if (gpio_request(MDM_GPIO(MDM2AP_ERRFATAL), "MDM2AP_ERRFATAL")) {
  1088. pr_err("%s Failed to configure MDM2AP_ERRFATAL gpio\n",
  1089. __func__);
  1090. goto fatal_err;
  1091. }
  1092. #ifdef USE_MDM_MODEM
  1093. if (GPIO_IS_VALID(MDM_GPIO(MDM2AP_PBLRDY))) {
  1094. if (gpio_request(MDM_GPIO(MDM2AP_PBLRDY), "MDM2AP_PBLRDY")) {
  1095. pr_err("%s Failed to configure MDM2AP_PBLRDY gpio\n",
  1096. __func__);
  1097. goto fatal_err;
  1098. }
  1099. }
  1100. #endif
  1101. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_PMIC_PWR_EN))) {
  1102. if (gpio_request(MDM_GPIO(AP2MDM_PMIC_PWR_EN),
  1103. "AP2MDM_PMIC_PWR_EN")) {
  1104. pr_err("%s Failed to configure AP2MDM_PMIC_PWR_EN gpio\n",
  1105. __func__);
  1106. goto fatal_err;
  1107. }
  1108. }
  1109. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_SOFT_RESET))) {
  1110. if (gpio_request(MDM_GPIO(AP2MDM_SOFT_RESET),
  1111. "AP2MDM_SOFT_RESET")) {
  1112. pr_err("%s Failed to configure AP2MDM_SOFT_RESET gpio\n",
  1113. __func__);
  1114. goto fatal_err;
  1115. }
  1116. }
  1117. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_WAKEUP))) {
  1118. if (gpio_request(MDM_GPIO(AP2MDM_WAKEUP), "AP2MDM_WAKEUP")) {
  1119. pr_err("%s Failed to configure AP2MDM_WAKEUP gpio\n",
  1120. __func__);
  1121. goto fatal_err;
  1122. }
  1123. }
  1124. if (GPIO_IS_VALID(MDM_GPIO(USB_SW))) {
  1125. if (gpio_request(MDM_GPIO(USB_SW), "USB_SW"))
  1126. pr_err("%s Failed to configure usb switch gpio\n",
  1127. __func__);
  1128. goto fatal_err;
  1129. }
  1130. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_CHNLRDY))) {
  1131. if (gpio_request(MDM_GPIO(AP2MDM_CHNLRDY), "AP2MDM_CHNLRDY")) {
  1132. pr_err("%s Failed to configure AP2MDM_CHNLRDY gpio\n",
  1133. __func__);
  1134. goto fatal_err;
  1135. }
  1136. }
  1137. gpio_direction_output(MDM_GPIO(AP2MDM_STATUS), 0);
  1138. gpio_direction_output(MDM_GPIO(AP2MDM_ERRFATAL), 0);
  1139. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_CHNLRDY)))
  1140. gpio_direction_output(MDM_GPIO(AP2MDM_CHNLRDY), 0);
  1141. gpio_direction_input(MDM_GPIO(MDM2AP_STATUS));
  1142. gpio_direction_input(MDM_GPIO(MDM2AP_ERRFATAL));
  1143. mdev->mdm_queue = alloc_workqueue("mdm_queue", 0, 0);
  1144. if (!mdev->mdm_queue) {
  1145. pr_err("%s: could not create mdm_queue for mdm id %d\n",
  1146. __func__, mdev->mdm_data.device_id);
  1147. ret = -ENOMEM;
  1148. goto fatal_err;
  1149. }
  1150. mdev->mdm_sfr_queue = alloc_workqueue("mdm_sfr_queue", 0, 0);
  1151. if (!mdev->mdm_sfr_queue) {
  1152. pr_err("%s: could not create mdm_sfr_queue for mdm id %d\n",
  1153. __func__, mdev->mdm_data.device_id);
  1154. ret = -ENOMEM;
  1155. goto fatal_err;
  1156. }
  1157. /* Register subsystem handlers */
  1158. mdev->mdm_subsys_dev = subsys_register(&mdev->mdm_subsys);
  1159. pr_err("%s: %d\n", __func__, __LINE__);
  1160. if (IS_ERR(mdev->mdm_subsys_dev)) {
  1161. ret = PTR_ERR(mdev->mdm_subsys_dev);
  1162. pr_err("%s: %d\n", __func__, ret);
  1163. goto fatal_err;
  1164. }
  1165. subsys_default_online(mdev->mdm_subsys_dev);
  1166. // subsys_default_online(mdev->mdm_subsys_dev);
  1167. /* ERR_FATAL irq. */
  1168. irq = platform_get_irq_byname(mdev->pdev, "err_fatal_irq");
  1169. if (irq < 0) {
  1170. pr_err("%s: bad MDM2AP_ERRFATAL IRQ resource, err = %d\n",
  1171. __func__, irq);
  1172. goto errfatal_err;
  1173. }
  1174. ret = request_irq(irq, mdm_errfatal,
  1175. IRQF_TRIGGER_RISING , "mdm errfatal", mdev);
  1176. if (ret < 0) {
  1177. pr_err("%s: MDM2AP_ERRFATAL IRQ#%d request failed, err=%d\n",
  1178. __func__, irq, ret);
  1179. goto errfatal_err;
  1180. }
  1181. mdev->mdm_errfatal_irq = irq;
  1182. #ifdef CONFIG_STATUS_IRQ_WAKEUP_ENA
  1183. /* enable wake up irq */
  1184. irq_set_irq_wake(irq, 1);
  1185. #endif
  1186. errfatal_err:
  1187. /* status irq */
  1188. irq = platform_get_irq_byname(mdev->pdev, "status_irq");
  1189. if (irq < 0) {
  1190. pr_err("%s: bad MDM2AP_STATUS IRQ resource, err = %d\n",
  1191. __func__, irq);
  1192. goto status_err;
  1193. }
  1194. #ifdef CONFIG_STATUS_IRQ_BY_LEVEL_TRIG
  1195. ret = request_threaded_irq(irq, NULL, mdm_status_change,
  1196. IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
  1197. "mdm status", mdev);
  1198. #else
  1199. ret = request_threaded_irq(irq, NULL, mdm_status_change,
  1200. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
  1201. "mdm status", mdev);
  1202. #endif
  1203. if (ret < 0) {
  1204. pr_err("%s: MDM2AP_STATUS IRQ#%d request failed, err=%d",
  1205. __func__, irq, ret);
  1206. goto status_err;
  1207. }
  1208. mdev->mdm_status_irq = irq;
  1209. #ifdef CONFIG_STATUS_IRQ_WAKEUP_ENA
  1210. /* enable wake up irq */
  1211. irq_set_irq_wake(irq, 1);
  1212. #endif
  1213. status_err:
  1214. #ifdef USE_MDM_MODEM
  1215. if (GPIO_IS_VALID(MDM_GPIO(MDM2AP_PBLRDY))) {
  1216. irq = platform_get_irq_byname(mdev->pdev, "plbrdy_irq");
  1217. if (irq < 0) {
  1218. pr_err("%s: could not get MDM2AP_PBLRDY IRQ resource\n",
  1219. __func__);
  1220. goto pblrdy_err;
  1221. }
  1222. ret = request_threaded_irq(irq, NULL, mdm_pblrdy_change,
  1223. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
  1224. IRQF_ONESHOT,
  1225. "mdm pbl ready", mdev);
  1226. if (ret < 0) {
  1227. pr_err("%s: MDM2AP_PBL IRQ#%d request failed error=%d\n",
  1228. __func__, irq, ret);
  1229. goto pblrdy_err;
  1230. }
  1231. mdev->mdm_pblrdy_irq = irq;
  1232. }
  1233. pblrdy_err:
  1234. #endif
  1235. /*
  1236. * Don't pull AP2MDM_PMIC_PWR_EN high right now.
  1237. * We'll assert it on 'mdm_do_first_power_on'
  1238. */
  1239. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_PMIC_PWR_EN))) {
  1240. gpio_direction_output(MDM_GPIO(AP2MDM_PMIC_PWR_EN), 0);
  1241. }
  1242. return 0;
  1243. fatal_err:
  1244. mdm_deconfigure_ipc(mdev);
  1245. return ret;
  1246. }
  1247. static int mdm_modem_probe(struct platform_device *pdev)
  1248. {
  1249. struct mdm_device *mdev = NULL;
  1250. int ret = -1;
  1251. pr_info("%s \n", __func__);
  1252. mdev = mdm_create_device_data(pdev);
  1253. if (IS_ERR(mdev))
  1254. return PTR_ERR(mdev);
  1255. pr_info("%s 1\n", __func__);
  1256. #if 0 //TEST_HS
  1257. pdev->dev.platform_data=&sglte_platform_data;
  1258. pdev->id=1;
  1259. pdev->name = "mdm2_modem";
  1260. #endif
  1261. pr_info("%s 2\n", __func__);
  1262. platform_set_drvdata(pdev, mdev);
  1263. pr_info("%s 3\n", __func__);
  1264. if (mdm_ops->debug_state_changed_cb)
  1265. mdm_ops->debug_state_changed_cb(mdm_debug_mask);
  1266. ret = mdm_configure_ipc(mdev);
  1267. if (ret) {
  1268. pr_err("%s: mdm_configure_ipc failed, id = %d\n",
  1269. __func__, mdev->mdm_data.device_id);
  1270. goto end;
  1271. }
  1272. ret = misc_register(&mdev->misc_device);
  1273. pr_info("%s 4 : %d\n", __func__, ret);
  1274. if (ret) {
  1275. pr_info("%s: 1 registered mdm id %d\n",
  1276. __func__, mdev->mdm_data.device_id);
  1277. mdm_deconfigure_ipc(mdev);
  1278. goto end;
  1279. } else {
  1280. pr_err("%s: 2 registered mdm id %d\n",
  1281. __func__, mdev->mdm_data.device_id);
  1282. mdm_device_list_add(mdev);
  1283. INIT_DELAYED_WORK(&mdev->mdm2ap_status_check_work,
  1284. mdm2ap_status_check);
  1285. INIT_WORK(&mdev->mdm_status_work, mdm_status_fn);
  1286. INIT_WORK(&mdev->sfr_reason_work, mdm_restart_reason_fn);
  1287. pr_info("%s 6\n", __func__);
  1288. /* Perform early powerup of the external modem in order to
  1289. * allow tabla devices to be found.
  1290. */
  1291. if (mdev->mdm_data.pdata->early_power_on)
  1292. {
  1293. pr_info("%s 7\n", __func__);
  1294. mdm_ops->power_on_mdm_cb(&mdev->mdm_data);
  1295. }
  1296. #if 0 //TEST_HS
  1297. else{
  1298. pr_info("%s 8\n", __func__);
  1299. mdm_ops->power_on_mdm_cb(&mdev->mdm_data);
  1300. }
  1301. #endif
  1302. }
  1303. end:
  1304. return ret;
  1305. }
  1306. static int mdm_modem_remove(struct platform_device *pdev)
  1307. {
  1308. int ret;
  1309. struct mdm_device *mdev = platform_get_drvdata(pdev);
  1310. mdm_deconfigure_ipc(mdev);
  1311. ret = misc_deregister(&mdev->misc_device);
  1312. mdm_device_list_remove(mdev);
  1313. return ret;
  1314. }
  1315. static void mdm_modem_shutdown(struct platform_device *pdev)
  1316. {
  1317. struct mdm_modem_drv *mdm_drv;
  1318. struct mdm_device *mdev = platform_get_drvdata(pdev);
  1319. pr_debug("%s: shutting down device id %d\n",
  1320. __func__, mdev->mdm_data.device_id);
  1321. mdm_disable_irqs(mdev);
  1322. mdm_drv = &mdev->mdm_data;
  1323. mdm_ops->power_down_mdm_cb(mdm_drv);
  1324. if (GPIO_IS_VALID(MDM_GPIO(AP2MDM_PMIC_PWR_EN)))
  1325. gpio_direction_output(MDM_GPIO(AP2MDM_PMIC_PWR_EN), 0);
  1326. }
  1327. static const struct of_device_id mdm_match_table[] = {
  1328. {.compatible = "qcom,mdm2-modem"},
  1329. {},
  1330. };
  1331. static struct platform_driver mdm_modem_driver = {
  1332. .probe = mdm_modem_probe,
  1333. .remove = __devexit_p(mdm_modem_remove),
  1334. .shutdown = mdm_modem_shutdown,
  1335. .driver = {
  1336. .name = "mdm2_modem",
  1337. .owner = THIS_MODULE,
  1338. .of_match_table = mdm_match_table,
  1339. },
  1340. };
  1341. static int __init mdm_modem_init(void)
  1342. {
  1343. int ret;
  1344. ret = mdm_get_ops(&mdm_ops);
  1345. if (ret)
  1346. return ret;
  1347. INIT_LIST_HEAD(&mdm_devices);
  1348. mdm_debugfs_init();
  1349. pr_info("%s \n", __func__);
  1350. return platform_driver_register(&mdm_modem_driver);
  1351. }
  1352. static void __exit mdm_modem_exit(void)
  1353. {
  1354. platform_driver_unregister(&mdm_modem_driver);
  1355. }
  1356. module_init(mdm_modem_init);
  1357. module_exit(mdm_modem_exit);
  1358. MODULE_LICENSE("GPL v2");
  1359. MODULE_DESCRIPTION("mdm modem driver");
  1360. MODULE_ALIAS("mdm2_modem");