|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 V L' h' C: L4 j' G( L#include <linux/init.h>8 @1 F2 d, P8 [
#include <linux/module.h>
: S4 f1 n5 ?" C7 m* L, _#include <linux/kernel.h>. I0 u# Y8 i( b1 @
#include <linux/types.h>
+ d: Z8 M& B, Q- Z#include <linux/gpio.h>
( V7 e# u1 S+ n. o7 d# M- } i#include <linux/leds.h>
# v; v! d0 J6 o" i( s#include <linux/platform_device.h>. A8 Y5 e5 o: @* H/ v& v6 o
/ e' t7 q E* H0 L#include <asm/mach-types.h>
" o9 c# s0 a/ d- t0 u) i' [& ~; ^( d#include <asm/mach/arch.h>
* g7 ^' D: T9 t3 Z# A#include <mach/da8xx.h>
' O( Q2 s8 q2 c! T3 g#include <mach/mux.h>- a. U8 ]& e# H d" a6 \2 Z
2 N% w. B5 g; U. G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ G" Y9 y1 Z; l* w1 X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. L- ^8 W/ B% H% \' Z4 m9 r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) O& u! y/ ]" s2 N! O) |8 c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- |# s6 R8 e! A- V4 J
3 S& p3 J S! u, c; H$ }/* assign the tl som board LED-GPIOs*/
! V. T; t% f. V- J' m$ Z5 Gstatic const short da850_evm_tl_user_led_pins[] = {5 L+ k! d$ A" q- c; x/ k; Q
/* These pins are definition at <mach/mux.h> file */
8 j, D' f- L; z+ N; u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
C, |/ C, m8 e! D, h0 t2 @ -1
; \/ h2 {* V$ {- q" Y- |};6 E: z% A& x" W( D
]1 r6 B1 p! n; {& i
static struct gpio_led da850_evm_tl_leds[] = {
7 {2 c; _& W- n P3 [9 z: L/ p- S {; i0 R1 l! L+ q! S3 e/ s
.active_low = 0,9 H0 A8 B6 b, _; e
.gpio = DA850_USER_LED0,
4 u" W- h3 u7 f9 Z0 I .name = "user_led0",
' v7 f& F; F4 N$ I .default_trigger = "default-on",
, f7 B% D9 @3 q1 ]! o. T( @; C- E },; U* K1 ^1 M y1 d0 C
{
8 v4 \" z. w! w .active_low = 0,
S$ J: }! F; X' g8 q .gpio = DA850_USER_LED1,$ X: D1 L3 o# x2 F: G
.name = "user_led1",; S# J+ v A( L
.default_trigger = "default-on",5 p! x! n' J$ i0 u6 ` v. ?/ E/ V
},
& p' L U; c' ~8 g {
7 |2 b$ i1 {6 _# }7 y .active_low = 0,
0 Y! [- |! Z' w .gpio = DA850_USER_LED2,
6 C& N4 T' \% A, z0 a3 J0 i% y .name = "user_led2",6 P! I8 l$ {0 k' ?0 } b
.default_trigger = "default-on",) {! g' O x4 X& X9 F7 R2 j
},. O: ?) |* D/ q4 e0 y! R _
{
1 L& t) D# e+ t) u, [8 V' t& a .active_low = 0,
/ n; M9 \% Q* _" U5 {' B .gpio = DA850_USER_LED3,
6 z# m0 j( A" I, `; x .name = "user_led3",( J4 y: N3 \! U; g
.default_trigger = "default-on",7 M+ T2 f6 J. ?# {: V% p( q, a
}," T( @6 p* U7 H* y1 w( _( ?: ]) a! F% }
};. H7 I& l5 E* X) v) b
1 K8 \% X2 E- f6 F3 r: i. s" Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) f, w! {. T9 `) e$ F- } .leds = da850_evm_tl_leds,1 w7 V0 O% F3 g- C% \+ w
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. c3 e1 _+ W: r4 N! T9 r};
& j& z0 C/ y4 v, r. f% q9 C' N& a! X h- A$ v
static void led_dev_release(struct device *dev): w6 g/ L9 w* Q4 ^: ?' }
{
) o2 ^ ?# f1 o}; J# ^ A. y Q) v" J8 d
: v% X8 ]+ E' ]$ Y- {; R8 U5 Q
static struct platform_device da850_evm_tl_leds_device = {( ^% o' X4 b' b6 z) q, h; S
.name = "leds-gpio",2 \) j* P7 Z( p# h1 l" X
.id = 1,
' c4 K' L7 B/ W8 ] .dev = {
/ M6 {: F; G1 Z2 r9 Q .platform_data = &da850_evm_tl_leds_pdata,
7 ?/ e5 e5 p+ d6 S# Q .release = led_dev_release,' j9 E u, J, b" t+ Q
}5 s6 C# x0 i, t4 ]) g) A
};
3 L7 Y6 D) b! n# C6 _4 r
! U$ U# a( C& Z7 A$ cstatic int __init led_platform_init(void)6 Y5 X3 \8 R6 n) O9 Y
{
6 Z; m3 I' X b int ret;
* p' a5 |1 r1 ~' M! w#if 0
1 e8 ]4 Y* a% b2 y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# h& i4 x, j" \* r+ n. \2 g
if (ret)7 g2 c% }+ B# l' \7 z: C; u2 A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& _+ f! S( a6 n1 h* c "%d\n", ret);4 @ t, c* j4 d1 {
#endif7 h1 D! F* S* E
ret = platform_device_register(&da850_evm_tl_leds_device);" c% j9 ], ~5 M7 ]+ T# f& z
if (ret)/ p7 A8 W1 {* _, ?3 I) J. t
pr_warning("Could not register som GPIO expander LEDS");/ c* _2 O2 I% T; T0 x& E
else
* V6 B7 y* ]! r) G: {& b' p printk(KERN_INFO "LED register sucessful!\n");
5 u- @" l3 A- f# ?2 a8 ^5 K8 _6 o* K- P0 f/ y6 Y3 N! x3 s4 [3 Y
return ret;- {& X' {3 m3 y4 _, t0 R/ J
}
5 B" H- f! i# a& E& Z# A. Y/ u; |
c7 @( ^/ p: ~9 t* F" K& V1 Ystatic void __exit led_platform_exit(void)4 w6 U, ~ t6 d3 G3 q( j
{! F3 m; b: s8 I/ ?
platform_device_unregister(&da850_evm_tl_leds_device);- y( Z, M- l# F% V& e9 R& y; z
8 p# a& G2 o- K6 n; {5 H0 m/ r printk(KERN_INFO "LED unregister!\n");
' `' G" u: _9 Z5 `}
7 M, s2 h4 z- g2 r. ^, \$ |# R N( q2 r6 y
module_init(led_platform_init);
- Z" G/ |" m+ u9 L+ c0 z |module_exit(led_platform_exit);
2 M) A9 ?7 N) a% @+ f4 i5 a" f; D- J7 f4 j; v& u
MODULE_DESCRIPTION("Led platform driver");
% `) ?0 P5 I9 g, [9 M2 f$ J9 bMODULE_AUTHOR("Tronlong");
3 q. f T4 I7 m2 d# n7 IMODULE_LICENSE("GPL");2 f, v0 F5 z* m6 \
/ Q+ F4 i c2 _) q: W) P
|
|