LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pru_can_emulation_api.c
Go to the documentation of this file.
1 /*
2  * linux/<file location within the kernel tree>
3  *
4  * Copyright (C) 2010 Texas Instruments Incorporated
5  * Author: Wilfred Felix
6  *
7  * Based on <Give reference of old kernel file from which this file is derived from>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation version 2.
12  *
13  * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
14  * whether express or implied; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  */
18 
19 /* *********************************************************************************************************
20  FILE : PRU_CAN_Emulation_APIs.c
21  PROJECT : DA8xx/OMAP-L138/C674x PRU Development
22  DESC : PRU Load , Run , Can Interface APIs
23  VERSION : 1.0
24 * **********************************************************************************************************/
25 
26 #include "pru_can_emulation_api.h"
27 #include "pru.h"
29 
37 
48 short pru_can_enable(void) {
50  CSL_SyscfgRegsOvly sysCfg0;
51  short s16returncapture;
52 
53  /* Set pru to Alternate mode for timer interrupts */
54  sysCfg0 =
56 
57  sysCfg0->KICK0R = 0x83E70B13;
58  sysCfg0->KICK1R = 0x95A4F1E0;
60  sysCfg0->KICK0R = 0x0;
61  sysCfg0->KICK1R = 0x0;
62 
63  /******* Enable PRU Sub System ******/
64  s16returncapture = pru_can_psc_enable();
65  if (s16returncapture == -1) {
66  return -1;
67  }
68 
69  /******* Reset PRU 0 ******/
70  hPru =
72  hPru->CONTROL = CSL_PRUCORE_CONTROL_RESETVAL;
73 
74  /******* Reset PRU 0 ******/
75  hPru =
77  hPru->CONTROL = CSL_PRUCORE_CONTROL_RESETVAL;
78 
79  return 0;
80 }
81 
92 short pru_can_disable(void) {
94  short s16returncapture;
95 
96  /******* DisablePRU 0 ******/
97  hPru =
99  CSL_FINST(hPru->CONTROL, PRUCORE_CONTROL_COUNTENABLE, DISABLE);
100  CSL_FINST(hPru->CONTROL, PRUCORE_CONTROL_ENABLE, DISABLE);
101 
102  /******* Reset PRU 0 ******/
103  hPru->CONTROL = CSL_PRUCORE_CONTROL_RESETVAL;
104  /******* Disable PRU 1 ******/
105  hPru =
107  CSL_FINST(hPru->CONTROL, PRUCORE_CONTROL_COUNTENABLE, DISABLE);
108  CSL_FINST(hPru->CONTROL, PRUCORE_CONTROL_ENABLE, DISABLE);
109 
110  /******* Reset PRU 1 ******/
111  hPru->CONTROL = CSL_PRUCORE_CONTROL_RESETVAL;
112  /******* Disable PRU Sub System ******/
113  s16returncapture = pru_can_psc_disable();
114  if (s16returncapture == -1) {
115  return -1;
116  }
117 
118  return 0;
119 }
120 
131 short pru_can_run(u8 u8prunum) {
132  CSL_PrucoreRegsOvly hPru;
133 
134  /******* Choose the PRU to RUN *******/
135  if (u8prunum == CSL_PRUCORE_0) {
136  hPru =
139  } else if (u8prunum == CSL_PRUCORE_1) {
140  hPru =
143  } else {
144  return -1;
145  }
146 
147  /******* Enable PRU Clock, *******/
148  CSL_FINST(hPru->CONTROL, PRUCORE_CONTROL_COUNTENABLE, ENABLE);
149  CSL_FINST(hPru->CONTROL, PRUCORE_CONTROL_ENABLE, ENABLE);
150 
151  return 0;
152 }
153 
164 short pru_can_psc_enable(void) {
165  u32 u32timeout;
166  bool btransitioncomplete;
168 
169  u32timeout = 0;
170  btransitioncomplete = false;
171 
173  while (btransitioncomplete == false) {
174  if (CSL_FEXT(PSC->PTSTAT, PSC_PTSTAT_GOSTAT0) ==
176  btransitioncomplete = true;
177  }
179  u32timeout++;
180  if (u32timeout == PRU_CAN_INIT_MAX_TIMEOUT) {
181  return -1;
182  }
183  }
184 
186  if (CSL_FEXT(PSC->MDSTAT[CSL_PSC_PRU], PSC_MDSTAT_STATE) ==
188  return 0;
189  }
190 
192  CSL_FINST(PSC->MDCTL[CSL_PSC_PRU], PSC_MDCTL_NEXT, ENABLE);
193  CSL_FINST(PSC->PTCMD, PSC_PTCMD_GO0, SET);
194 
195  u32timeout = 0;
196  btransitioncomplete = false;
197 
199  while (btransitioncomplete == false) {
200  if (CSL_FEXT(PSC->PTSTAT, PSC_PTSTAT_GOSTAT0) ==
202  btransitioncomplete = true;
203  }
205  u32timeout++;
206  if (u32timeout == PRU_CAN_INIT_MAX_TIMEOUT) {
207  return -1;
208  }
209  }
210 
211  u32timeout = 0;
212  btransitioncomplete = false;
213 
215  while (btransitioncomplete == false) {
216  if (CSL_FEXT(PSC->MDSTAT[CSL_PSC_PRU], PSC_MDSTAT_STATE) !=
218  btransitioncomplete = true;
219  }
221  u32timeout++;
222  if (u32timeout == PRU_CAN_INIT_MAX_TIMEOUT) {
223  return -1;
224  }
225  }
226 
227  return 0;
228 }
229 
240 short pru_can_psc_disable(void) {
241 
242  u32 u32timeout;
243  bool btransitioncomplete;
245 
246  u32timeout = 0;
247  btransitioncomplete = false;
248 
250  while (btransitioncomplete == false) {
251  if (CSL_FEXT(PSC->PTSTAT, PSC_PTSTAT_GOSTAT0) ==
253  btransitioncomplete = true;
254  }
256  u32timeout++;
257  if (u32timeout == PRU_CAN_INIT_MAX_TIMEOUT) {
258  return -1;
259  }
260  }
261 
263  if (CSL_FEXT(PSC->MDSTAT[CSL_PSC_PRU], PSC_MDSTAT_STATE) ==
265  return 0;
266  }
267 
269  CSL_FINST(PSC->MDCTL[CSL_PSC_PRU], PSC_MDCTL_NEXT, SYNCRST);
270  CSL_FINST(PSC->PTCMD, PSC_PTCMD_GO0, SET);
271 
272  u32timeout = 0;
273  btransitioncomplete = false;
274 
276  while (btransitioncomplete == false) {
277  if (CSL_FEXT(PSC->PTSTAT, PSC_PTSTAT_GOSTAT0) ==
279  btransitioncomplete = true;
280  }
282  u32timeout++;
283  if (u32timeout == PRU_CAN_INIT_MAX_TIMEOUT) {
284  return -1;
285  }
286  }
287 
288  u32timeout = 0;
289  btransitioncomplete = false;
290 
292  while (btransitioncomplete == false) {
293  if (CSL_FEXT(PSC->MDSTAT[CSL_PSC_PRU], PSC_MDSTAT_STATE) !=
295  btransitioncomplete = true;
296  }
298  u32timeout++;
299  if (u32timeout == PRU_CAN_INIT_MAX_TIMEOUT) {
300  return -1;
301  }
302  }
303 
304  return 0;
305 }
306 
320  (u32 u32offset, u32 * pu32datatowrite, u16 u16wordstowrite) {
321 
322  u32 *pu32addresstowrite;
323  u16 u16loop;
324 
325  pu32addresstowrite = (u32 *) (u32offset);
326 
327  for (u16loop = 0; u16loop < u16wordstowrite; u16loop++) {
328  *pu32addresstowrite = *pu32datatowrite;
329  pu32datatowrite++;
330  pu32addresstowrite++;
331  }
332 
333  return 0;
334 }
335 
349  (u32 u32offset, u32 * pu32datatoread, u16 u16wordstoread) {
350 
351  u32 *pu32addresstoread;
352  u16 u16loop;
353 
354  pu32addresstoread = (u32 *) (u32offset);
355 
356  for (u16loop = 0; u16loop < u16wordstoread; u16loop++) {
357  *pu32datatoread = *pu32addresstoread;
358  pu32datatoread++;
359  pu32addresstoread++;
360  }
361 
362  return 0;
363 }
364 
378  (pru_can_firmware_structure * pstrfirmwaredata, u8 u8prunum) {
379 
380  u32 *pu32pruinstructionram;
381  u32 u32codesizeinwords;
382  u32 *pu32prucode;
383  u32 u32counter;
384 
385  pu32pruinstructionram = NULL;
386  u32codesizeinwords = 0;
387 
389  if (pstrfirmwaredata == NULL) {
390  return -1;
391  }
393  if (u8prunum == CSL_PRUCORE_0) {
394  pu32pruinstructionram =
396  pu32prucode = (u32 *) pstrfirmwaredata->ptr_pru0;
397  u32codesizeinwords = pstrfirmwaredata->u32_pru0_code_size;
398  } else if (u8prunum == CSL_PRUCORE_1) {
399  pu32pruinstructionram =
401  pu32prucode = (u32 *) pstrfirmwaredata->ptr_pru1;
402  u32codesizeinwords = pstrfirmwaredata->u32_pru1_code_size;
403  } else {
404  return -1;
405  }
406 
408  for (u32counter = 0; u32counter < u32codesizeinwords; u32counter++) {
409  pu32pruinstructionram[u32counter] = pu32prucode[u32counter];
410  }
411 
412  return 0;
413 }
414 
425 short pru_can_set_brp(u16 u16bitrateprescaler) {
426 
427  u32 u32offset;
428 
429  if (u16bitrateprescaler > 255) {
430  return -1;
431  }
432 
434  pru_can_ram_write_data(u32offset, (u32 *) & u16bitrateprescaler, 1);
435 
437  pru_can_ram_write_data(u32offset, (u32 *) & u16bitrateprescaler, 1);
438 
439  return 0;
440 
441 }
442 
456 
457  u32 u32offset;
458  u32 u32serregister;
459 
460  u32serregister = 0;
461 
462  if (pstrcanbittiming == NULL) {
463  return -1;
464  }
465 
466  if ((pstrcanbittiming->u8syncjumpwidth > PRU_CAN_MAX_SJW) ||
467  (pstrcanbittiming->u8phseg1 > PRU_CAN_MAX_PHSEG1) ||
468  (pstrcanbittiming->u8phseg2 > PRU_CAN_MAX_PHSEG2)) {
469  return -1;
470  }
471 
472  u32serregister = u32serregister |
473  ((pstrcanbittiming->u8syncjumpwidth << 7) |
474  (pstrcanbittiming->u8phseg1 << 3) | (pstrcanbittiming->u8phseg2));
475 
477  pru_can_ram_write_data(u32offset, (u32 *) & u32serregister, 1);
478 
480  pru_can_ram_write_data(u32offset, (u32 *) & u32serregister, 1);
481 
482  return 0;
483 }
484 
498 short pru_can_calculatetiming(u32 pru_freq, u32 bit_rate) {
499  u16 u16phaseseg1;
500  u16 u16phaseseg2;
501  u32 u32offset;
502  u32 u32TimingValue;
503  u32 u32SetupValue;
504 // u32TimingValue = (u32bitrateprescaler - 1) / 3;
505 // u32TimingValue -= 20; //Adjust the STATIC delay
506  u32TimingValue = TIMER_CLK_FREQ/bit_rate;
507 
509  pru_can_ram_write_data(u32offset, (u32 *) & u32TimingValue, 4);
510  pru_can_ram_read_data(u32offset, (u32 *) & u32TimingValue, 4);
511 
512  u32SetupValue = (GPIO_SETUP_DELAY*(pru_freq/1000000)/1000)/DELAY_LOOP_LENGTH;
514  pru_can_ram_write_data(u32offset, (u32 *) & u32SetupValue, 4);
515 
516  u16phaseseg1 = (u16) (u32TimingValue / 2);
517  u16phaseseg2 = u32TimingValue - u16phaseseg1;
518  u16phaseseg1 -= TIMER_SETUP_DELAY;
519  u16phaseseg2 -= TIMER_SETUP_DELAY;
520  u32SetupValue = (u16phaseseg1 << 16) | u16phaseseg2;
521 
523  pru_can_ram_write_data(u32offset, (u32 *) & u32SetupValue, 4);
524 
525  u32offset = (gu32canpruiomapaddress | (PRU_CAN_TIMING_VAL_RX+4)) ;
526  pru_can_ram_write_data(u32offset, (u32 *) & u32TimingValue, 4);
527 
528 
529  return 0;
530 }
531 
546  short s16subrtnretval;
547  u32 u32offset;
548 
549  if (pstrcanemuapphndl == NULL) {
550  return -1;
551  }
552 
553  switch ((u8) pstrcanemuapphndl->ecanmailboxnumber) {
554  case 0:
556  break;
557  case 1:
559  break;
560  case 2:
562  break;
563  case 3:
565  break;
566  case 4:
568  break;
569  case 5:
571  break;
572  case 6:
574  break;
575  case 7:
577  break;
578  default:
579  return -1;
580  }
581 
582  s16subrtnretval =
583  pru_can_ram_write_data(u32offset,
584  (u32 *) & (pstrcanemuapphndl->strcanmailbox), 4);
585  if (s16subrtnretval == -1) {
586  return -1;
587  }
588  return 0;
589 }
590 
605  (can_emulation_app_hndl * pstrcanemuapphndl) {
606 
607  short s16subrtnretval;
608  u32 u32offset;
609 
610  if (pstrcanemuapphndl == NULL) {
611  return -1;
612  }
613 
614  switch ((u8) pstrcanemuapphndl->ecanmailboxnumber) {
615  case 0:
617  break;
618  case 1:
620  break;
621  case 2:
623  break;
624  case 3:
626  break;
627  case 4:
629  break;
630  case 5:
632  break;
633  case 6:
635  break;
636  case 7:
638  break;
639  case 8:
641  break;
642  default:
643  return -1;
644  }
645 
646  s16subrtnretval =
647  pru_can_ram_read_data(u32offset,
648  (u32 *) & (pstrcanemuapphndl->strcanmailbox), 4);
649  if (s16subrtnretval == -1) {
650  return -1;
651  }
652  return 0;
653 }
654 
668 short pru_can_receive_id_map(u32 u32nodeid, can_mailbox_number ecanmailboxno) {
669 
671  (PRU_CAN_ID_MAP + (((u8) ecanmailboxno) * 4))),
672  (u32 *) & u32nodeid, 1);
673 
674  return 0;
675 }
676 
691  u32 u32offset;
692  short s16subrtnretval = -1;
693 
694  if (pstrcanemuapphndl == NULL) {
695  return -1;
696  }
697 
698  if (pstrcanemuapphndl->u8prunumber == CSL_PRUCORE_1) {
699  u32offset =
702  } else if (pstrcanemuapphndl->u8prunumber == CSL_PRUCORE_0) {
703  u32offset =
706  } else {
707  return -1;
708  }
709 
710  s16subrtnretval =
711  pru_can_ram_read_data(u32offset,
712  (u32 *) & pstrcanemuapphndl->u32interruptstatus,
713  1);
714  if (s16subrtnretval == -1) {
715  return -1;
716  }
717 
718  return 0;
719 }
720 
735  u32 u32offset;
736  int s16subrtnretval = -1;
737 
738  if (pstrcanemuapphndl == NULL) {
739  return -1;
740  }
741 
742  if (pstrcanemuapphndl->u8prunumber == CSL_PRUCORE_1) {
743  u32offset =
746  }
747 
748  else if (pstrcanemuapphndl->u8prunumber == CSL_PRUCORE_0) {
749  u32offset =
752  }
753 
754  else {
755  return -1;
756  }
757 
758  s16subrtnretval =
759  pru_can_ram_read_data(u32offset,
760  (u32 *) & pstrcanemuapphndl->u32globalstatus, 1);
761  if (s16subrtnretval == -1) {
762  return -1;
763  }
764 
765  return 0;
766 }
767 
782  u32 u32offset;
783  short s16subrtnretval = -1;
784 
785  if (pstrcanemuapphndl == NULL) {
786  return -1;
787  }
788 
789  if (pstrcanemuapphndl->u8prunumber == CSL_PRUCORE_1) {
790  switch (pstrcanemuapphndl->ecanmailboxnumber) {
791  case 0:
792  u32offset =
795  break;
796  case 1:
797  u32offset =
800  break;
801  case 2:
802  u32offset =
805  break;
806  case 3:
807  u32offset =
810  break;
811  case 4:
812  u32offset =
815  break;
816  case 5:
817  u32offset =
820  break;
821  case 6:
822  u32offset =
825  break;
826  case 7:
827  u32offset =
830  break;
831  default:
832  return -1;
833  }
834  }
835 
836  else if (pstrcanemuapphndl->u8prunumber == CSL_PRUCORE_0) {
837  switch (pstrcanemuapphndl->ecanmailboxnumber) {
838  case 0:
839  u32offset =
842  break;
843  case 1:
844  u32offset =
847  break;
848  case 2:
849  u32offset =
852  break;
853  case 3:
854  u32offset =
857  break;
858  case 4:
859  u32offset =
862  break;
863  case 5:
864  u32offset =
867  break;
868  case 6:
869  u32offset =
872  break;
873  case 7:
874  u32offset =
877  break;
878  case 8:
879  u32offset =
882  break;
883  default:
884  return -1;
885  }
886  }
887 
888  else {
889  return -1;
890  }
891 
892  s16subrtnretval =
893  pru_can_ram_read_data(u32offset,
894  (u32 *) & pstrcanemuapphndl->u32mailboxstatus, 1);
895  if (s16subrtnretval == -1) {
896  return -1;
897  }
898 
899  return 0;
900 }
901 
905  (bool btransfer_flag, can_transfer_direction ecan_trx) {
906  u32 u32offset;
907  u32 u32value;
908 
909  if (ecan_trx == ecantransmit) {
910  u32offset =
913  pru_can_ram_read_data(u32offset, &u32value, 1);
914  if (btransfer_flag == true) {
915  u32value &= 0x1F;
916  u32value |= 0x80;
917  } else {
918  u32value &= 0x7F;
919  }
920  pru_can_ram_write_data(u32offset, &u32value, 1);
921  u32offset =
924  pru_can_ram_write_data(u32offset, &u32value, 1);
925  } else if (ecan_trx == ecanreceive) {
926  u32offset =
929  pru_can_ram_read_data(u32offset, &u32value, 1);
930  if (btransfer_flag == true) {
931  u32value &= 0x1F;
932  u32value |= 0x40;
933  } else {
934  u32value &= 0xBF;
935  }
936  pru_can_ram_write_data(u32offset, &u32value, 1);
937  u32offset =
940  pru_can_ram_write_data(u32offset, &u32value, 1);
941  } else
942  return -1;
943 
944  return 0;
945 }
946 
957 short pru_can_configuration_mode_set(bool bconfigmodeenabledisableflag) {
958 
959  u32 u32bitrateprescaler;
960  u32 u32canbittiming;
961 
964  (u32 *) & u32bitrateprescaler, 1);
966  (u32 *) & u32canbittiming, 1);
967 
968  if (bconfigmodeenabledisableflag == 1) {
969  pru_can_calculatetiming(u32canbittiming, u32bitrateprescaler);
970  }
971 
972  else {
974  }
975 
976  return 0;
977 }
978 
992 short pru_can_emulation_init(arm_pru_iomap * pstr_pru_iomap, u32 u32pruclock)
993 {
994  u32 u32offset;
995  u32 u32value;
996  short s16subrtnretval = -1;
997  u8 u8loop;
998 
999  for (u8loop = 0; u8loop < (u8) ecanmaxinst; u8loop++) {
1000  gstrcanemulationinst[u8loop].bcaninststate = (bool) 0;
1001  gstrcanemulationinst[u8loop].ecantransferdirection =
1003  gstrcanemulationinst[u8loop].u32apphandlerptr = 0;
1004  }
1005 
1006 
1007  gu32canpruiomapaddress = (u32) pstr_pru_iomap->pru_io_addr;
1008  gu32canpsc0mapaddress = (u32) pstr_pru_iomap->psc0_io_addr;
1009  gu32canpsc1mapaddress = (u32) pstr_pru_iomap->psc1_io_addr;
1010  gu32cansyscfgmapaddress = (u32) pstr_pru_iomap->syscfg_io_addr;
1011  gu32pruclock = u32pruclock;
1012 
1013 
1014  u32offset =
1016  0xFFFF);
1017  u32value = 0x00000000;
1018  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1019  if (s16subrtnretval == -1) {
1020  return -1;
1021  }
1022 
1023  u32offset =
1025  0xFFFF);
1026  u32value = 0x00000040;
1027  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1028  if (s16subrtnretval == -1) {
1029  return -1;
1030  }
1031  u32offset =
1033  0xFFFF);
1034  u32value = 0x00000040;
1035  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1036  if (s16subrtnretval == -1) {
1037  return -1;
1038  }
1039 
1040  u32offset =
1042  0xFFFF);
1043  u32value = 0x00004000;
1044  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1045  if (s16subrtnretval == -1) {
1046  return -1;
1047  }
1048 
1049  u32offset =
1051  0xFFFF);
1052  u32value = 0x00000000;
1053  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1054  if (s16subrtnretval == -1) {
1055  return -1;
1056  }
1057 
1058  u32offset =
1060  0xFFFF);
1061  u32value = 0x00000001;
1062  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1063  if (s16subrtnretval == -1) {
1064  return -1;
1065  }
1066 
1067  u32offset =
1069  0xFFFF);
1070  u32value = 0x00000001;
1071  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1072  if (s16subrtnretval == -1) {
1073  return -1;
1074  }
1075 
1076  u32offset =
1078  0xFFFF);
1079  u32value = 0x00000001;
1080  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1081  if (s16subrtnretval == -1) {
1082  return -1;
1083  }
1084 
1085  u32offset =
1087  0xFFFF);
1088  u32value = 0x00000001;
1089  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1090  if (s16subrtnretval == -1) {
1091  return -1;
1092  }
1093 
1094  u32offset =
1096  0xFFFF);
1097  u32value = 0x00000001;
1098  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1099  if (s16subrtnretval == -1) {
1100  return -1;
1101  }
1102 
1103  u32offset =
1105  0xFFFF);
1106  u32value = 0x00000001;
1107  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1108  if (s16subrtnretval == -1) {
1109  return -1;
1110  }
1111 
1112  u32offset =
1114  0xFFFF);
1115  u32value = 0x00000001;
1116  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1117  if (s16subrtnretval == -1) {
1118  return -1;
1119  }
1120 
1121  u32offset =
1123  0xFFFF);
1124  u32value = 0x00000001;
1125  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1126  if (s16subrtnretval == -1) {
1127  return -1;
1128  }
1129 
1130  u32offset =
1132  0xFFFF);
1133  u32value = 0x00000000;
1134  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1135  if (s16subrtnretval == -1) {
1136  return -1;
1137  }
1138 
1139  u32offset =
1141  u32value = 0x00000000;
1142  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1143  if (s16subrtnretval == -1) {
1144  return -1;
1145  }
1146 
1147  u32offset =
1149  u32value = 0x00000000;
1150  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1151  if (s16subrtnretval == -1) {
1152  return -1;
1153  }
1154 
1155  u32offset =
1157  0xFFFF);
1158  u32value = 0x00000000;
1159  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1160  if (s16subrtnretval == -1) {
1161  return -1;
1162  }
1163 
1164  u32offset =
1166  0xFFFF);
1167  u32value = 0xFFFFFFFF;
1168  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1169  if (s16subrtnretval == -1) {
1170  return -1;
1171  }
1172  u32offset =
1174  0xFFFF);
1175  u32value = 0xFFFFFFFF;
1176  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1177  if (s16subrtnretval == -1) {
1178  return -1;
1179  }
1180  u32offset =
1182  0xFFFF);
1183  u32value = 0x1C000000;
1184  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1185  if (s16subrtnretval == -1) {
1186  return -1;
1187  }
1188  u32offset =
1190  0xFFFF);
1191  u32value = 0x00000000;
1192  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1193  if (s16subrtnretval == -1) {
1194  return -1;
1195  }
1196 
1197 
1198  u32offset = gu32canpruiomapaddress | (PRU_INTC_HSTINTENIDXCLR & 0xFFFF);
1199  u32value = 0x0;
1200  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1201  if (s16subrtnretval == -1) {
1202  return -1;
1203  }
1204 
1205 
1206  u32offset = gu32canpruiomapaddress | (PRU_INTC_GLBLEN & 0xFFFF);
1207  u32value = 0x1;
1208  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1209  if (s16subrtnretval == -1) {
1210  return -1;
1211  }
1212  /* tx intr map arm->pru */
1213  u32offset = gu32canpruiomapaddress | (PRU_INTC_HSTINTENIDXSET & 0xFFFF);
1214  u32value = 0x0;
1215  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1216  if (s16subrtnretval == -1) {
1217  return -1;
1218  }
1219 
1220  u32offset = gu32canpruiomapaddress | (PRU_INTC_HOSTMAP0 & 0xFFFF);
1221  u32value = 0x03020100;
1222  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1223  if (s16subrtnretval == -1) {
1224  return -1;
1225  }
1226 
1227  u32offset = gu32canpruiomapaddress | (PRU_INTC_HOSTMAP1 & 0xFFFF);
1228  u32value = 0x07060504;
1229  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1230  if (s16subrtnretval == -1) {
1231  return -1;
1232  }
1233 
1234  u32offset = gu32canpruiomapaddress | (PRU_INTC_HOSTMAP2 & 0xFFFF);
1235  u32value = 0x0000908;
1236  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1237  if (s16subrtnretval == -1) {
1238  return -1;
1239  }
1240 
1241  u32offset = gu32canpruiomapaddress | (PRU_INTC_CHANMAP0 & 0xFFFF);
1242  u32value = 0;
1243  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1244  if (s16subrtnretval == -1) {
1245  return -1;
1246  }
1247 
1248  u32offset = gu32canpruiomapaddress | (PRU_INTC_CHANMAP8 & 0xFFFF);
1249  u32value = 0x00020200;
1250  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1251  if (s16subrtnretval == -1) {
1252  return -1;
1253  }
1254 
1255  u32offset = gu32canpruiomapaddress | (PRU_INTC_STATIDXCLR & 0xFFFF);
1256  u32value = 32;
1257  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1258  if (s16subrtnretval == -1) {
1259  return -1;
1260  }
1261 #if 1
1262  u32offset = gu32canpruiomapaddress | (PRU_INTC_STATIDXCLR & 0xFFFF);
1263  u32value = 19;
1264  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1265  if (s16subrtnretval == -1) {
1266  return -1;
1267  }
1268 
1269  u32offset = gu32canpruiomapaddress | (PRU_INTC_ENIDXSET & 0xFFFF);
1270  u32value = 19;
1271  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1272  if (s16subrtnretval == -1) {
1273  return -1;
1274  }
1275  u32offset = gu32canpruiomapaddress | (PRU_INTC_STATIDXCLR & 0xFFFF);
1276  u32value = 18;
1277  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1278  if (s16subrtnretval == -1) {
1279  return -1;
1280  }
1281 
1282  u32offset = gu32canpruiomapaddress | (PRU_INTC_ENIDXSET & 0xFFFF);
1283  u32value = 18;
1284  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1285  if (s16subrtnretval == -1) {
1286  return -1;
1287  }
1288 
1289  u32offset = gu32canpruiomapaddress | (PRU_INTC_STATIDXCLR & 0xFFFF);
1290  u32value = 34;
1291  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1292  if (s16subrtnretval == -1) {
1293  return -1;
1294  }
1295 
1296  u32offset = gu32canpruiomapaddress | (PRU_INTC_ENIDXSET & 0xFFFF);
1297  u32value = 34;
1298  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1299  if (s16subrtnretval == -1) {
1300  return -1;
1301  }
1302 
1303 #endif
1304 
1305  u32offset = gu32canpruiomapaddress | (PRU_INTC_ENIDXSET & 0xFFFF);
1306  u32value = 32;
1307  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1308  if (s16subrtnretval == -1) {
1309  return -1;
1310  }
1311 
1312 
1313  u32offset = gu32canpruiomapaddress | (PRU_INTC_HOSTINTEN & 0xFFFF);
1314  u32value = 0x5;
1315  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1316  if (s16subrtnretval == -1) {
1317  return -1;
1318  }
1319 
1320 /* PRU0 - Rx Internal Registers Initializations */
1321 
1322  u32offset =
1324  0xFFFF);
1325  u32value = 0x00000000;
1326  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1327  if (s16subrtnretval == -1) {
1328  return -1;
1329  }
1330 
1331  u32offset =
1333  0xFFFF);
1334  u32value = 0x00000040;
1335  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1336  if (s16subrtnretval == -1) {
1337  return -1;
1338  }
1339 
1340  u32offset =
1342  0xFFFF);
1343  u32value = 0x00004000;
1344  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1345  if (s16subrtnretval == -1) {
1346  return -1;
1347  }
1348 
1349  u32offset =
1351  0xFFFF);
1352  u32value = 0x00000000;
1353  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1354  if (s16subrtnretval == -1) {
1355  return -1;
1356  }
1357 
1358  u32offset =
1360  0xFFFF);
1361  u32value = 0x00000000;
1362  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1363  if (s16subrtnretval == -1) {
1364  return -1;
1365  }
1366 
1367  u32offset =
1369  0xFFFF);
1370  u32value = 0x0000000;
1371  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1372  if (s16subrtnretval == -1) {
1373  return -1;
1374  }
1375 
1376  u32offset =
1378  0xFFFF);
1379  u32value = 0x00000000;
1380  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1381  if (s16subrtnretval == -1) {
1382  return -1;
1383  }
1384 
1385  u32offset =
1387  0xFFFF);
1388  u32value = 0x00000000;
1389  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1390  if (s16subrtnretval == -1) {
1391  return -1;
1392  }
1393 
1394  u32offset =
1396  0xFFFF);
1397  u32value = 0x00000000;
1398  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1399  if (s16subrtnretval == -1) {
1400  return -1;
1401  }
1402 
1403  u32offset =
1405  0xFFFF);
1406  u32value = 0x00000000;
1407  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1408  if (s16subrtnretval == -1) {
1409  return -1;
1410  }
1411 
1412  u32offset =
1414  0xFFFF);
1415  u32value = 0x00000000;
1416  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1417  if (s16subrtnretval == -1) {
1418  return -1;
1419  }
1420 
1421  u32offset =
1423  0xFFFF);
1424  u32value = 0x00000000;
1425  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1426  if (s16subrtnretval == -1) {
1427  return -1;
1428  }
1429 
1430  u32offset =
1432  0xFFFF);
1433  u32value = 0x00000000;
1434  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1435  if (s16subrtnretval == -1) {
1436  return -1;
1437  }
1438 
1439  u32offset =
1441  u32value = 0x0000000;
1442  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1443  if (s16subrtnretval == -1) {
1444  return -1;
1445  }
1446 
1447  u32offset =
1449  u32value = 0x00000000;
1450  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1451  if (s16subrtnretval == -1) {
1452  return -1;
1453  }
1454  return 0;
1455 }
1456 
1470 {
1471 
1472  if (pstrcanemuapphndl == NULL) {
1473  return -1;
1474  }
1475 
1476  if (gstrcanemulationinst[pstrcanemuapphndl->ecaninstance].
1477  bcaninststate == 1) {
1478  return -1;
1479  }
1480 
1481  gstrcanemulationinst[(u8) pstrcanemuapphndl->ecaninstance].bcaninststate
1482  = (bool) 1;
1483  gstrcanemulationinst[(u8) pstrcanemuapphndl->ecaninstance].
1484  ecantransferdirection =
1485  (can_transfer_direction) (u8) pstrcanemuapphndl->
1486  ecantransferdirection;
1487  gstrcanemulationinst[(u8) pstrcanemuapphndl->ecaninstance].
1488  u32apphandlerptr = (u32) pstrcanemuapphndl;
1489 
1490  return 0;
1491 }
1492 
1506 {
1507 
1508  if (pstrcanemuapphndl == NULL) {
1509  return -1;
1510  }
1511  if (gstrcanemulationinst[pstrcanemuapphndl->ecaninstance].
1512  bcaninststate == 0) {
1513  return -1;
1514  }
1515  if ((u32) pstrcanemuapphndl !=
1516  gstrcanemulationinst[(u8) pstrcanemuapphndl->ecaninstance].
1517  u32apphandlerptr) {
1518  return -1;
1519  }
1520 
1521  gstrcanemulationinst[(u8) pstrcanemuapphndl->ecaninstance].bcaninststate
1522  = (bool) 0;
1523  gstrcanemulationinst[(u8) pstrcanemuapphndl->ecaninstance].
1524  ecantransferdirection = (can_transfer_direction) 0;
1525  gstrcanemulationinst[(u8) pstrcanemuapphndl->ecaninstance].
1526  u32apphandlerptr = 0;
1527 
1528  return 0;
1529 }
1530 
1544  ) {
1545  short s16subrtnretval;
1546 
1547  s16subrtnretval = pru_can_disable();
1548  if (s16subrtnretval == -1) {
1549  return -1;
1550  }
1551 
1552  return 0;
1553 }
1554 
1558  return 0;
1559 }
1560 
1561 short pru_can_transfer(u8 u8mailboxnumber, u8 u8prunumber) {
1562  u32 u32offset = 0;
1563  u32 u32value = 0;
1564  short s16subrtnretval = -1;
1565 
1566  if (CSL_PRUCORE_1 == u8prunumber) {
1567  switch (u8mailboxnumber) {
1568  case 0:
1569  u32offset =
1572  u32value = 0x00000080;
1573  s16subrtnretval =
1574  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1575  1);
1576  if (s16subrtnretval == -1) {
1577  return -1;
1578  }
1579  break;
1580  case 1:
1581  u32offset =
1584  u32value = 0x00000080;
1585  s16subrtnretval =
1586  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1587  1);
1588  if (s16subrtnretval == -1) {
1589  return -1;
1590  }
1591  break;
1592  case 2:
1593  u32offset =
1596  u32value = 0x00000080;
1597  s16subrtnretval =
1598  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1599  1);
1600  if (s16subrtnretval == -1) {
1601  return -1;
1602  }
1603  break;
1604  case 3:
1605  u32offset =
1608  u32value = 0x00000080;
1609  s16subrtnretval =
1610  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1611  1);
1612  if (s16subrtnretval == -1) {
1613  return -1;
1614  }
1615  break;
1616  case 4:
1617  u32offset =
1620  u32value = 0x00000080;
1621  s16subrtnretval =
1622  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1623  1);
1624  if (s16subrtnretval == -1) {
1625  return -1;
1626  }
1627  break;
1628  case 5:
1629  u32offset =
1632  u32value = 0x00000080;
1633  s16subrtnretval =
1634  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1635  1);
1636  if (s16subrtnretval == -1) {
1637  return -1;
1638  }
1639  break;
1640  case 6:
1641  u32offset =
1644  u32value = 0x00000080;
1645  s16subrtnretval =
1646  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1647  1);
1648  if (s16subrtnretval == -1) {
1649  return -1;
1650  }
1651  break;
1652  case 7:
1653  u32offset =
1656  u32value = 0x00000080;
1657  s16subrtnretval =
1658  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1659  1);
1660  if (s16subrtnretval == -1) {
1661  return -1;
1662  }
1663  break;
1664  default:
1665  return -1;
1666  }
1667  } else {
1668 
1669  u32offset =
1672  u32value = 0x00000000;
1673  s16subrtnretval =
1674  pru_can_ram_read_data(u32offset, (u32 *) & u32value, 1);
1675  if (s16subrtnretval == -1) {
1676  return -1;
1677  }
1678  u32value = u32value & ~(1 << u8mailboxnumber);
1679  s16subrtnretval =
1680  pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1681  if (s16subrtnretval == -1) {
1682  return -1;
1683  }
1684 
1685  switch (u8mailboxnumber) {
1686  case 0:
1687  u32offset =
1690  u32value = 0x00000000;
1691  s16subrtnretval =
1692  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1693  1);
1694  if (s16subrtnretval == -1) {
1695  return -1;
1696  }
1697  break;
1698  case 1:
1699  u32offset =
1702  u32value = 0x00000000;
1703  s16subrtnretval =
1704  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1705  1);
1706  if (s16subrtnretval == -1) {
1707  return -1;
1708  }
1709  break;
1710  case 2:
1711  u32offset =
1714  u32value = 0x00000000;
1715  s16subrtnretval =
1716  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1717  1);
1718  if (s16subrtnretval == -1) {
1719  return -1;
1720  }
1721  break;
1722  case 3:
1723  u32offset =
1726  u32value = 0x00000000;
1727  s16subrtnretval =
1728  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1729  1);
1730  if (s16subrtnretval == -1) {
1731  return -1;
1732  }
1733  break;
1734  case 4:
1735  u32offset =
1738  u32value = 0x00000000;
1739  s16subrtnretval =
1740  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1741  1);
1742  if (s16subrtnretval == -1) {
1743  return -1;
1744  }
1745  break;
1746  case 5:
1747  u32offset =
1750  u32value = 0x00000000;
1751  s16subrtnretval =
1752  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1753  1);
1754  if (s16subrtnretval == -1) {
1755  return -1;
1756  }
1757  break;
1758  case 6:
1759  u32offset =
1762  u32value = 0x00000000;
1763  s16subrtnretval =
1764  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1765  1);
1766  if (s16subrtnretval == -1) {
1767  return -1;
1768  }
1769  break;
1770  case 7:
1771  u32offset =
1774  u32value = 0x00000000;
1775  s16subrtnretval =
1776  pru_can_ram_write_data(u32offset, (u32 *) & u32value,
1777  1);
1778  if (s16subrtnretval == -1) {
1779  return -1;
1780  }
1781  break;
1782  default:
1783  return -1;
1784  }
1785  }
1786  return 0;
1787 }
1788 
1789 short pru_can_start_or_abort_transmission(bool bcantransmitabortflag) {
1790  u32 u32offset;
1791  u32 u32value;
1792  short s16subrtnretval;
1793  u32offset = gu32canpruiomapaddress | (PRU_INTC_STATIDXCLR & 0xFFFF);
1794  u32value = 32;
1795  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1796 
1797  u32offset = gu32canpruiomapaddress | (PRU_INTC_ENIDXSET & 0xFFFF);
1798  u32value = 32;
1799  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1800 
1801  u32offset = gu32canpruiomapaddress | (PRU_INTC_STATIDXSET & 0xFFFF);
1802  u32value = 32;
1803  s16subrtnretval = pru_can_ram_write_data(u32offset, (u32 *) & u32value, 1);
1804  if (s16subrtnretval == -1) {
1805  return -1;
1806  }
1807  return 0;
1808 }
1809 
1811  return 0;
1812 }
1813 
1814 short pru_can_mask_ints(u32 int_mask) {
1815  return 0;
1816 }
1817 
1818 int pru_can_get_error_cnt(u8 u8prunumber) {
1819  return 0;
1820 }
1821 
1823 {
1824  u32 u32offset = 0;
1825  u32 u32getvalue = 0;
1826  u32 u32clrvalue = 0;
1827 
1828  u32offset = gu32canpruiomapaddress | (PRU_INTC_STATCLRINT1 & 0xFFFF);
1829  pru_ram_read_data_4byte(u32offset, (u32 *)&u32getvalue, 1);
1830 
1831  if (u32getvalue & 4)
1832  u32clrvalue = 34; //CLR Event 34
1833 
1834  if (u32getvalue & 2)
1835  u32clrvalue = 33; //CLR Event 33
1836 
1837  if (u32clrvalue){
1838  u32offset = gu32canpruiomapaddress | (PRU_INTC_STATIDXCLR & 0xFFFF);
1839  pru_ram_write_data_4byte(u32offset, &u32clrvalue, 1);
1840  } else
1841  return -1;
1842 
1843  return u32getvalue;
1844 }
short pru_can_emulation_exit(void)
pru_can_emulation_exit() Diables all the PRUs
#define PRU_CAN_RX_TIMING_REGISTER
#define PRU0_PROG_RAM_START_OFFSET
short pru_can_enable(void)
pru_can_enable() Configure and Enable PRU0 and PRU1 of OMAP L138.
#define PRU_CAN_TX_MAILBOX2
#define PRU_INTC_STATCLRINT1
Definition: pru.h:51
can_transfer_direction
#define CSL_FEXT(reg, PER_REG_FIELD)
#define PRU_INTC_STATIDXCLR
Definition: pru.h:42
short pru_can_set_bit_timing(can_bit_timing_consts *pstrcanbittiming)
pru_can_set_bit_timing() Updates the timing register of PRU0 and PRU1 of OMAP L138.
#define CSL_SYSCFG_CFGCHIP3_PRUEVTSEL_ALTERNATE
Definition: c_i2c.c:95
#define PRU_INTC_HOSTMAP2
Definition: pru.h:74
#define CSL_PRUCORE_CONTROL_RESETVAL
can_transfer_direction ecantransferdirection
#define PRU_CAN_TX_CLOCK_BRP_REGISTER
short pru_can_emulation_open(can_emulation_app_hndl *pstrcanemuapphndl)
pru_can_emulation_open() Opens the can emulation for application to use
#define PRU_INTC_HOSTINTEN
Definition: pru.h:99
#define PRU_INTC_GLBLEN
Definition: pru.h:39
#define PRU_INTC_HSTINTENIDXSET
Definition: pru.h:45
short pru_can_get_mailbox_status(can_emulation_app_hndl *pstrcanemuapphndl)
pru_can_get_mailbox_status() Gets the mailbox status register value
unsigned char bool
short pru_can_disable(void)
pru_can_disable() Disable PRU0 and PRU1 of OMAP L138.
#define PRU_INTC_POLARITY0
Definition: pru.h:85
short pru_can_ram_read_data(u32 u32offset, u32 *pu32datatoread, u16 u16wordstoread)
pru_can_ram_read_data() Download the data into data RAM of PRU0 or PRU1 of OMAP L138.
uint8_t u8
Definition: common.h:160
#define PRU_CAN_TX_MAILBOX7
#define PRU_CAN_TX_MAILBOX5
short pru_can_transfer_mode_set(bool btransfer_flag, can_transfer_direction ecan_trx)
#define CSL_PRUCANCORE_0_REGS
#define PRU_CAN_ID_MAP
#define PRU_CAN_TX_MAILBOX1
#define PRU_CAN_RX_CLOCK_BRP_REGISTER
#define CSL_PSC_MDSTAT_STATE_SYNCRST
#define PRU_CAN_RX_INTERRUPT_MASK_REGISTER
#define PRU_CAN_RX_MAILBOX3
#define PRU_CAN_RX_MAILBOX2
#define PRU_CAN_RX_MAILBOX1
#define PRU1_PROG_RAM_START_OFFSET
#define PRU_CAN_RX_MAILBOX3_STATUS_REGISTER
#define PRU_CAN_TX_MAILBOX1_STATUS_REGISTER
#define PRU_CAN_RX_MAILBOX6
short pru_can_psc_disable(void)
pru_can_psc_disable () Disable state transition of PRU
short pru_can_set_brp(u16 u16bitrateprescaler)
pru_can_set_brp() Updates the BRP register of PRU0 and PRU1 of OMAP L138.
short pru_can_emulation_close(can_emulation_app_hndl *pstrcanemuapphndl)
pru_can_emulation_close() Closes the can emulation for other applications to use
short pru_can_download_firmware(pru_can_firmware_structure *pstrfirmwaredata, u8 u8prunum)
pru_can_download_firmware() Download the firmware into PRU0 and PRU1 of OMAP L138.
u32 gu32canpsc0mapaddress
can_instance_enum ecaninstance
#define PRU_CAN_RX_GLOBAL_CONTROL_REGISTER
#define PRU_CAN_TX_MAILBOX3
#define PRU_CAN_RX_MAILBOX7
can_mailbox_number ecanmailboxnumber
#define TIMER_SETUP_DELAY
#define PRU_CAN_RX_MAILBOX7_STATUS_REGISTER
short pru_can_write_data_to_mailbox(can_emulation_app_hndl *pstrcanemuapphndl)
pru_can_write_data_to_mailbox() Updates the transmit mailboxes of PRU1 of OMAP L138.
#define PRU_CAN_RX_MAILBOX5_STATUS_REGISTER
#define PRU_INTC_TYPE1
Definition: pru.h:88
#define CSL_PSC_PTSTAT_GOSTAT0_IN_TRANSITION
short pru_can_start_or_abort_transmission(bool bcantransmitabortflag)
#define PRU_CAN_MAX_PHSEG2
short pru_ram_read_data_4byte(unsigned int u32offset, unsigned int *pu32datatoread, short u16wordstoread)
pru_ram_read_data_4byte() Download the data into data RAM of PRU0 or PRU1 of OMAP L138...
Definition: pru.c:306
void * psc0_io_addr
Definition: pru.h:113
volatile CSL_SyscfgRegs * CSL_SyscfgRegsOvly
#define PRU_CAN_TX_GLOBAL_STATUS_REGISTER
short pru_can_get_interrupt_status(can_emulation_app_hndl *pstrcanemuapphndl)
pru_can_get_interrupt_status() Gets the interrupts status register value
short pru_can_calculatetiming(u32 pru_freq, u32 bit_rate)
pru_can_calculatetiming() Updates the timing values of PRU0 and PRU1 of OMAP L138.
#define PRU_CAN_TX_INTERRUPT_MASK_REGISTER
#define PRU_INTC_STATIDXSET
Definition: pru.h:41
#define PRU_CAN_RX_MAILBOX5
#define PRU_INTC_CHANMAP0
Definition: pru.h:56
short pru_can_psc_enable(void)
pru_can_psc_enable () Enable state transition of PRU
#define PRU_CAN_TX_MAILBOX4_STATUS_REGISTER
#define PRU_CAN_RX_MAILBOX4_STATUS_REGISTER
#define CSL_PRUCORE_1
Definition: soc_OMAPL138.h:205
#define PRU_CAN_TIMING_VAL_TX_SJW
short pru_can_mask_ints(u32 int_mask)
#define PRU_CAN_RX_MAILBOX0_STATUS_REGISTER
u32 gu32pruclock
#define PRU_CAN_RX_MAILBOX2_STATUS_REGISTER
#define PRU_CAN_TX_INTERRUPT_STATUS_REGISTER
void * psc1_io_addr
Definition: pru.h:114
short pru_can_check_init_status(void)
#define PRU_INTC_HOSTMAP0
Definition: pru.h:72
#define PRU_CAN_TX_MAILBOX6_STATUS_REGISTER
uint16_t u16
Definition: common.h:159
#define PRU_CAN_MAX_PHSEG1
#define CSL_SYSCFG_CFGCHIP3_PRUEVTSEL_SHIFT
#define PRU_CAN_RX_MAILBOX6_STATUS_REGISTER
#define CSL_PRUCORE_0
Peripheral Instance of PRU CORE instances.
Definition: soc_OMAPL138.h:204
#define PRU_CAN_TX_MAILBOX6
#define DELAY_LOOP_LENGTH
#define PRU_CAN_INIT_MAX_TIMEOUT
#define PRU_CAN_TX_MAILBOX7_STATUS_REGISTER
#define PRU_CAN_TX_MAILBOX0_STATUS_REGISTER
short pru_can_receive_id_map(u32 u32nodeid, can_mailbox_number ecanmailboxno)
pru_can_receive_id_map() Receive mailboxes ID Mapping of PRU0 of OMAP L138.
u32 gu32canpsc1mapaddress
short pru_can_run(u8 u8prunum)
pru_can_run () Allows the PRU0 or PRU1 of OMAP L138 to execute the code loaded into its Instruction R...
#define PRU_INTC_POLARITY1
Definition: pru.h:86
volatile CSL_PscRegs * CSL_PscRegsOvly
can_mailbox_number
#define GPIO_SETUP_DELAY
#define PRU_CAN_TIMING_VAL_TX
#define PRU_CAN_RX_MAILBOX4
int pru_can_get_error_cnt(u8 u8prunumber)
#define PRU_CAN_RX_MAILBOX0
short pru_can_get_data_from_mailbox(can_emulation_app_hndl *pstrcanemuapphndl)
pru_can_get_data_from_mailbox() Receive data from the receive mailboxes of PRU0 of OMAP L138...
#define PRU_INTC_HOSTMAP1
Definition: pru.h:73
short pru_can_emulation_sreset(void)
int pru_can_intc_status_get(void)
short pru_can_transfer(u8 u8mailboxnumber, u8 u8prunumber)
#define PRU_CAN_TX_TIMING_REGISTER
#define PRU_CAN_RX_GLOBAL_STATUS_REGISTER
#define PRU_CAN_RX_MAILBOX8
#define CSL_FINST(reg, PER_REG_FIELD, TOKEN)
short pru_can_ram_write_data(u32 u32offset, u32 *pu32datatowrite, u16 u16wordstowrite)
pru_can_ram_write_data() Download the data into data RAM of PRU0 or PRU1 of OMAP L138.
short pru_can_get_global_status(can_emulation_app_hndl *pstrcanemuapphndl)
pru_can_get_global_status() Gets the globalstatus register value
#define PRU_INTC_HSTINTENIDXCLR
Definition: pru.h:46
#define PRU_CAN_RX_MAILBOX8_STATUS_REGISTER
#define PRU_INTC_ENIDXSET
Definition: pru.h:43
#define PRU_CAN_TX_MAILBOX0
void * syscfg_io_addr
Definition: pru.h:115
can_mail_box_structure strcanmailbox
#define PRU_CAN_TX_MAILBOX2_STATUS_REGISTER
#define PRU_CAN_TX_MAILBOX3_STATUS_REGISTER
arm_pru_iomap str_pru_iomap
#define PRU_CAN_MAX_SJW
#define PRU_CAN_RX_ERROR_COUNTER_REGISTER
void * pru_io_addr
Definition: pru.h:111
#define PRU_CAN_RX_MAILBOX1_STATUS_REGISTER
short pru_ram_write_data_4byte(unsigned int u32offset, unsigned int *pu32datatoread, short u16wordstoread)
pru_ram_write_data_4byte() Download the data into data RAM of PRU0 or PRU1 of OMAP L138...
Definition: pru.c:278
uint32_t u32
Definition: common.h:158
#define PRU_INTC_TYPE0
Definition: pru.h:87
can_emulation_drv_inst gstrcanemulationinst[ecanmaxinst]
#define PRU_CAN_TX_MAILBOX4
short pru_can_configuration_mode_set(bool bconfigmodeenabledisableflag)
pru_can_configuration_mode_set() Sets the timing value for data transfer
#define PRU_CAN_TX_MAILBOX5_STATUS_REGISTER
#define PRU_CAN_TX_ERROR_COUNTER_REGISTER
#define TIMER_CLK_FREQ
#define PRU_CAN_TX_GLOBAL_CONTROL_REGISTER
volatile CSL_PrucoreRegs * CSL_PrucoreRegsOvly
Definition: cslr_prucore.h:106
#define CSL_PSC_MDSTAT_STATE_ENABLE
#define CSL_PRUCANCORE_1_REGS
short pru_can_emulation_init(arm_pru_iomap *pstr_pru_iomap, u32 u32pruclock)
pru_can_emulation_init() Initializes the Can Emulation Parameters
#define PRU_INTC_CHANMAP8
Definition: pru.h:64
#define PRU_CAN_TIMING_VAL_RX
#define PRU_CAN_RX_INTERRUPT_STATUS_REGISTER
u32 gu32cansyscfgmapaddress
u32 gu32canpruiomapaddress
#define NULL