|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; f7 i* M9 b0 O. y) _8 y* v. S( `#include <linux/init.h>; `, j7 P2 ^( n% s4 O- s" H
#include <linux/module.h>
9 x% w3 d4 [, _/ S" D#include <linux/kernel.h>8 g8 r% M+ z- |* @( [
#include <linux/types.h>
0 ^( e5 s1 b0 [+ g#include <linux/gpio.h>' A0 O1 ?$ O K9 h" V0 q9 Q
#include <linux/leds.h>
% v* s- t% h7 N& Y U3 L! V+ V#include <linux/platform_device.h>
$ x/ p' i$ s0 r$ z
9 s7 R5 @6 B, \ H#include <asm/mach-types.h>
7 y. v5 v7 X& t5 N0 k3 Z#include <asm/mach/arch.h>
; ]8 G0 d" g# E6 R#include <mach/da8xx.h>
2 K& H; ^% j: `" n! r2 x0 h4 o#include <mach/mux.h>5 c# m% Z5 x3 a$ o8 j6 F6 I( M
- O E3 Z% k4 [- m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 ^: I: R6 J% L# O" _; u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% M0 ~; G& Q) ~( V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 q1 t5 G' t' ]/ C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# u# |& P8 l: p9 l1 f$ ^$ L, |0 }9 P& Z H+ C# ~4 W
/* assign the tl som board LED-GPIOs*/; m f! h9 C5 M1 @* ?/ `
static const short da850_evm_tl_user_led_pins[] = {
) ]$ f2 b& Z, E /* These pins are definition at <mach/mux.h> file */
4 H4 Q. V7 i% i+ C) ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' B3 Y1 w- m- ~
-14 C" t. w/ r, B+ ^( `; b
};
2 k$ v$ j$ d v0 n& [! `
- n! q3 t. O& c5 T4 lstatic struct gpio_led da850_evm_tl_leds[] = {; J6 B$ K- a* x# q) l+ o; f
{
/ Q: P7 M% p; N# B' L; G .active_low = 0,6 u& x& c. Y" a, z# Q& ?* T
.gpio = DA850_USER_LED0,
) l& X, A1 Y7 s .name = "user_led0",
$ A7 s) A! D) I3 Y .default_trigger = "default-on",
( E% E1 Q# ?; } },/ ^- y1 t$ G0 i/ ?% H# u" K
{
, G# L1 M: s6 g8 p# V6 n; d .active_low = 0,, k8 Y: w) [2 i) B* Y4 E
.gpio = DA850_USER_LED1," ?1 ?: C+ v# L K. A
.name = "user_led1",3 F1 ]1 \% M- h8 W- E
.default_trigger = "default-on",( X2 G/ D- n$ j, n- A
},
) y: ]& |. p- q( [% _4 w {6 W, ^' V I; t( W. K5 B }8 U
.active_low = 0,% S( X6 o! f% @/ E2 s
.gpio = DA850_USER_LED2,6 c& H' N- ]1 w3 E" p
.name = "user_led2",
, [8 m; ~& m3 m% p; q j .default_trigger = "default-on",- X5 u! T% |$ T4 I/ B
},
/ O; D. _( w/ y5 e( [ {
% o& \; |/ T: |2 t& J1 b4 J! |4 D .active_low = 0,) N$ C8 i/ t) I0 c! h B* _
.gpio = DA850_USER_LED3,1 v0 }4 G( J1 X4 {0 ~
.name = "user_led3",: a, B! l( v* r% e
.default_trigger = "default-on",
, p, ~. u( W% T },
) D. d; i! i" J1 z};
8 A* `. x! w2 I/ U0 h7 t6 _5 p
* T+ R, d3 H* B) L$ Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 W2 l5 \4 k$ j* }% j/ s: N .leds = da850_evm_tl_leds,) d) n/ i4 c9 J; G9 G& N! w3 `% v$ m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 F- c! }: `* M# v' S- Y
};0 ?2 _0 V+ _+ b
y" h' N# [+ z- N# o4 @1 H4 ~9 N
static void led_dev_release(struct device *dev)
8 H3 }" K1 J& Y; O( y/ J7 d{8 k6 [0 |% k; U% g5 O- r! H
};
6 O4 \+ ~- N/ V. P% b( |2 E1 a- L+ G3 n) @+ d! u; v
static struct platform_device da850_evm_tl_leds_device = {
3 E& l# t0 z# _( g a5 r .name = "leds-gpio",9 r( e" u5 L5 H4 [0 E' k& @
.id = 1,, d* E) [8 y# D, w- W& A- k6 m
.dev = {3 l6 ~& U: A$ D& j# d' ?
.platform_data = &da850_evm_tl_leds_pdata,$ H" \# N+ o) O1 I- R
.release = led_dev_release,% ]; R$ u- d' y* P$ p
}
% {0 K. ?. O( G6 e# Y};0 ~+ u3 k/ ]8 I: V2 w1 r
- [8 b+ `/ K! ~3 M8 d" r
static int __init led_platform_init(void)0 w( a9 H; V/ y- \' }) @
{; P; ?; ?0 @# J0 ?7 K2 `, D
int ret;, o2 d8 q! @# n8 x' o
#if 00 C/ S& @& K/ `* N) t A8 y4 I# f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ ]" G- K7 l) d
if (ret)7 I+ J/ A8 t* W# H; ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 J+ y' g1 a! Z* E
"%d\n", ret);) P5 {, I# [% d
#endif+ M' s. S4 P' ~/ \9 j/ C+ c
ret = platform_device_register(&da850_evm_tl_leds_device);
, E% W8 [8 A$ P$ S7 A# G z if (ret)
) `2 R! m0 d" W* E pr_warning("Could not register som GPIO expander LEDS");/ W7 S) O* Z% z
else/ M' ]- W/ L! L# J. @* Y2 _3 I" g
printk(KERN_INFO "LED register sucessful!\n");6 j# g' t% Y/ z+ s/ F O( _. V
, @. M2 Z7 F! D/ R return ret;
+ K& Y! b# G P9 b- ~}9 _4 x. g" Q& Y6 }6 o
# m9 W8 x% X& e2 }
static void __exit led_platform_exit(void)
# J) K1 ^! G+ L5 P1 c5 H{
5 b' X1 ^+ o3 i platform_device_unregister(&da850_evm_tl_leds_device);1 V" r6 ^$ _1 Z) J" {7 Z( s0 U+ n
- Y1 t o$ P8 @. L0 c6 S$ k printk(KERN_INFO "LED unregister!\n");
. F/ x+ ?) M- j, A}* d' t3 A4 b! r+ K0 C: Z
8 W# S) E. O- ^9 U4 M
module_init(led_platform_init);
1 z' E8 n3 Q3 H5 hmodule_exit(led_platform_exit);
: m. F3 E) O, K5 Q
4 O0 L0 e- N6 F2 |7 ]MODULE_DESCRIPTION("Led platform driver");
2 b" }( D6 ~ G8 P; |MODULE_AUTHOR("Tronlong");
& h' m, N& H4 a7 v" v" F$ ]) `MODULE_LICENSE("GPL");) p3 v8 Y+ v- H, {0 Z0 s
$ k9 V \" t( A
|
|