SHOW:
|
|
- or go back to the newest paste.
1 | << uart.comp >> | |
2 | extra_setup = yes; | |
3 | ... | |
4 | variable char *name; // UART name | |
5 | ... | |
6 | ;; | |
7 | ||
8 | char *uart_chans[18] = {0,}; | |
9 | RTAPI_MP_ARRAY_STRING(uart_chans, 16, "BSPI Channel names"); | |
10 | ... | |
11 | EXTRA_SETUP(){ | |
12 | name = uart_chans[extra_arg]; | |
13 | HM2_ERR_NO_LL("uart name = %s\n", name); | |
14 | hm2_uart_setup(name, 115000); | |
15 | return 0; | |
16 | } | |
17 | ||
18 | << hm2_uart_setup >> | |
19 | ||
20 | ||
21 | ||
22 | EXPORT_SYMBOL_GPL(hm2_uart_setup); | |
23 | int hm2_uart_setup(char *name, int bitrate){ | |
24 | hostmot2_t *hm2; | |
25 | hm2_uart_instance_t *inst = 0; | |
26 | float clock_low; | |
27 | u32 buff; | |
28 | int i,r; | |
29 | ||
30 | HM2_ERR_NO_LL("name seems to be %s\n", name); | |
31 | ||
32 | i = hm2_get_uart(&hm2, name); | |
33 | if (i < 0){ | |
34 | HM2_ERR_NO_LL("Can not find UART instance %s.\n", name); | |
35 | return -1; | |
36 | } | |
37 | *inst = hm2->uart.instance[i]; | |
38 | ||
39 | clock_low = 1 / inst->clock_freq; | |
40 | ||
41 | buff = (u32)((float)bitrate/(1048576.0 * clock_low)); //20 bits in this version | |
42 | if (buff != inst->bitrate){ | |
43 | r = hm2->llio->write(hm2->llio, inst->rx_bitrate_addr, &buff, sizeof(u32)); | |
44 | r += hm2->llio->write(hm2->llio, inst->tx_bitrate_addr, &buff, sizeof(u32)); | |
45 | if (r < 0) { | |
46 | HM2_ERR("UART: hm2->llio->write failure %s\n", name); | |
47 | return -1; | |
48 | } | |
49 | inst->bitrate = buff; | |
50 | } | |
51 | return 0; | |
52 | } | |
53 | ||
54 | << hostmot2.c >> | |
55 | ||
56 | EXPORT_SYMBOL_GPL(hm2_get_uart); | |
57 | int hm2_get_uart(hostmot2_t** hm2, char *name){ | |
58 | struct list_head *ptr; | |
59 | int i; | |
60 | list_for_each(ptr, &hm2_list) { | |
61 | *hm2 = list_entry(ptr, hostmot2_t, list); | |
62 | if ((*hm2)->uart.num_instances > 0) { | |
63 | for (i = 0; i <= (*hm2)->uart.num_instances ; i++) { | |
64 | if (!strcmp((*hm2)->uart.instance[i].name, name)) {return i;} | |
65 | } | |
66 | } | |
67 | } | |
68 | return -1; | |
69 | } | |
70 | ||
71 | << And the dmesg…>> | |
72 | ||
73 | [ 1329.462501] hm2/hm2_5i23.0: registered | |
74 | [ 1329.462507] hm2_5i23.0: initialized AnyIO board at 0000:05:00.0 | |
75 | [ 1329.470433] hm2: uart name = hm2_5i23.0.uart.0 | |
76 | [ 1329.470443] hm2: name seems to be hm2_5i23.0.uart.0 | |
77 | [ 1329.470473] BUG: unable to handle kernel NULL pointer dereference at (null) | |
78 | [ 1329.470484] IP: [<fa0bd4d3>] hm2_uart_setup+0x79/0x146 [hostmot2] | |
79 | [ 1329.470502] *pde = 253de067 *pte = 00000000 | |
80 | [ 1329.470511] Oops: 0002 [#1] SMP | |
81 | [ 1329.470518] last sysfs file: /sys/devices/hm2_5i23.0/firmware/hm2_5i23.0/loading | |
82 | [ 1329.470525] Modules linked in: mesa_uart(+) hm2_pci hostmot2 threads hal_lib rtapi rtai_math rtai_sem rtai_fifos rtai_sched rtai_hal binfmt_misc nfsd exportfs snd_hda_codec_realtek nfs lockd nfs_acl snd_hda_intel auth_rpcgss snd_hda_codec sunrpc snd_hwdep snd_pcm_oss snd_mixer_oss fbcon tileblit font bitblit softcursor snd_pcm vga16fb vgastate snd_seq_dummy snd_seq_oss snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer snd_seq_device w83627hf hwmon_vid i915 coretemp drm_kms_helper joydev snd ppdev usbhid drm lp soundcore usbtouchscreen parport_pc i2c_algo_bit video hid psmouse serio_raw parport snd_page_alloc intel_agp output agpgart r8169 mii [last unloaded: rtai_hal] | |
83 | [ 1329.470644] | |
84 | [ 1329.470652] Pid: 7859, comm: insmod Not tainted (2.6.32-122-rtai #rtai) | |
85 | [ 1329.470659] EIP: 0060:[<fa0bd4d3>] EFLAGS: 00010246 CPU: 0 | |
86 | [ 1329.470669] EIP is at hm2_uart_setup+0x79/0x146 [hostmot2] | |
87 | [ 1329.470676] EAX: 00000001 EBX: e51c0680 ECX: 00000023 EDX: 00000000 | |
88 | [ 1329.470682] ESI: fa03c560 EDI: 00000000 EBP: e53c1ed4 ESP: e53c1e98 | |
89 | [ 1329.470688] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 | |
90 | [ 1329.470695] Process insmod (pid: 7859, ti=e53c0000 task=f5ff8000 task.ti=e53c0000) | |
91 | [ 1329.470700] I-pipe domain Linux | |
92 | [ 1329.470704] Stack: | |
93 | [ 1329.470708] 00000001 fa0c6bd7 e51c0680 e53c1f4b 0001c138 f0959000 00000014 e53c1f22 | |
94 | [ 1329.470724] <0> e53c1ed4 fa02d92f e53c1f22 f0959000 fa03ce70 e53c1f22 fa03ce84 e53c1f5c | |
95 | [ 1329.470740] <0> fa12c0d6 00000001 fa12c34f e51c0680 00000000 3c653cc8 00000001 00000000 | |
96 | [ 1329.470757] Call Trace: | |
97 | [ 1329.470770] [<fa02d92f>] ? hal_malloc+0x3e/0x74 [hal_lib] | |
98 | [ 1329.470794] [<fa12c0d6>] ? init_module+0xc2/0x255 [mesa_uart] | |
99 | [ 1329.470808] [<c019f706>] ? ring_buffer_time_stamp+0x6/0x10 | |
100 | [ 1329.470817] [<c01a48de>] ? ftrace_now+0x2e/0x50 | |
101 | [ 1329.470826] [<c019b157>] ? tracepoint_module_notify+0x27/0x30 | |
102 | [ 1329.470836] [<c056c373>] ? notifier_call_chain+0x43/0x60 | |
103 | [ 1329.470845] [<c0101041>] ? do_one_initcall+0x31/0x1b0 | |
104 | [ 1329.470855] [<fa12c014>] ? init_module+0x0/0x255 [mesa_uart] | |
105 | [ 1329.470866] [<c0179781>] ? sys_init_module+0xb1/0x220 | |
106 | [ 1329.470874] [<c010340d>] ? syscall_call+0x7/0xb | |
107 | [ 1329.470879] Code: e8 5b f7 f4 ff e9 d6 00 00 00 8b 54 24 2c 69 f0 8c 00 00 00 31 c0 89 c7 b9 23 00 00 00 b0 01 89 54 24 14 03 b2 9c 07 00 00 31 d2 <f3> a5 f7 35 00 00 00 00 31 d2 89 54 24 20 d9 7c 24 1a db 44 24 | |
108 | [ 1329.470970] EIP: [<fa0bd4d3>] hm2_uart_setup+0x79/0x146 [hostmot2] SS:ESP 0068:e53c1e98 | |
109 | [ 1329.470985] CR2: 0000000000000000 | |
110 | [ 1329.470992] ---[ end trace 58b595c30e337326 ]--- |