|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ ^0 S/ K6 U; w8 s" s1 r7 g#include <linux/init.h>
4 O* p1 y8 D j- q9 B" S0 b#include <linux/module.h>3 n: f6 m, A. W- b. g3 h! g
#include <linux/kernel.h>
; u% \, R- \, z, r9 a {9 r( r#include <linux/types.h>, `/ \0 }) h' @! r
#include <linux/gpio.h>
9 Y5 R" Y2 e7 D7 k#include <linux/leds.h>
$ l1 x8 r& ?' D$ S#include <linux/platform_device.h>
5 | U$ v- c' n E0 e, N5 p) h5 t0 y! D, U" b
#include <asm/mach-types.h>
% f7 T/ L5 ~* s; n#include <asm/mach/arch.h>
: b: A$ I) ]" P, G D, i# d$ Z+ t2 h/ G#include <mach/da8xx.h>" l0 z- D9 Y& \3 c; H) a g, |8 N
#include <mach/mux.h>4 v; f$ A1 a: z/ C0 n- Z
2 i2 Z. P3 [" e% G D+ n8 G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 M+ F8 r' k! U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# m( H# e0 T/ N# L, V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 {6 v8 s' ~, d, h) O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ N0 V5 t7 R5 D2 r( B- ^9 v( F# @. Y
/* assign the tl som board LED-GPIOs*/
J) F t2 o5 M6 bstatic const short da850_evm_tl_user_led_pins[] = {/ v" L# Q) M ~9 {6 `( S; J
/* These pins are definition at <mach/mux.h> file */; X2 O( B; G) o' q7 m2 ]0 O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ y8 e u& _5 C6 u( Z
-1+ r* }+ ?3 {. K
};: q2 {5 C I1 Q( A
+ w- j7 b3 p" Mstatic struct gpio_led da850_evm_tl_leds[] = {5 |7 x5 Q" C: c" j1 E% j5 A
{
+ B, u5 y* K* G$ G; Q .active_low = 0,6 _" o1 {' g7 Y# T1 F
.gpio = DA850_USER_LED0,
& y) |* P% y$ x .name = "user_led0",
2 N5 S) h0 }4 ]( F2 p .default_trigger = "default-on",
) o7 C( x/ }1 l },$ I7 z" U3 h/ E( K: w' ~: |
{! T2 ]' E2 A p# {! T J# {/ j* T
.active_low = 0,; j: }: L1 c( M9 a4 h3 T- Z
.gpio = DA850_USER_LED1,
% v3 p9 b; i6 z& F/ g1 t .name = "user_led1",$ E, G4 |3 Y: B: O4 x
.default_trigger = "default-on",/ ^; l, `- V( ~/ Y1 g+ G0 H: y
},
% i" e6 L/ h8 a( T; f5 f9 t6 {1 F {
4 h) L+ c/ d* d# B .active_low = 0,7 u: @7 z% x4 |* g8 @; ?
.gpio = DA850_USER_LED2,+ P* P: H: D3 F5 r1 V O: X1 F5 p
.name = "user_led2",8 _7 r% s$ T, _# m+ W9 q1 o
.default_trigger = "default-on",
3 }! v3 G) V' p+ p8 { },
( H5 l' h( D4 X8 y( g {9 h( V, Q) d2 l3 V6 {
.active_low = 0,
2 {% ?) ?% c6 \3 A# I6 J .gpio = DA850_USER_LED3,
( ?2 \/ S$ _9 Q .name = "user_led3",# S1 |9 D" A- n1 M( s a2 R
.default_trigger = "default-on",
! V" N5 K* u" ?; W },
) C& C: [# `9 A};( y4 y. b. E4 f( K
8 j1 e# p+ R2 [3 W/ [- S; |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" J! Z5 ~* n |! l .leds = da850_evm_tl_leds,
* G5 C; l2 J$ `. [0 J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' v: j/ U J# L; V};& s) ~6 R# Y! o7 e {% D
3 _+ O- V' z/ p' Q
static void led_dev_release(struct device *dev)
5 L6 ?. z, ^$ h3 s6 W7 L{; c9 n4 L" v5 _5 L4 }9 o( C
};7 D. p8 [# N0 a' G
& X& F" b) ^0 W- @" h5 xstatic struct platform_device da850_evm_tl_leds_device = {
% S9 H6 _9 N0 v2 K .name = "leds-gpio",
4 M) f, n5 ^& K .id = 1,
6 y1 C$ Q1 ^1 G5 F* T6 ? .dev = {
" o$ t% V" l5 }5 ], k' T .platform_data = &da850_evm_tl_leds_pdata,
& y, B) g7 g2 B+ K, o5 H6 M8 k$ { .release = led_dev_release,7 Q7 p# u7 x% O8 n
}- ?# L' ~! E1 o+ r0 M
};0 g1 Y( p0 D$ i% W) h- _
+ O, ]) h- f$ X
static int __init led_platform_init(void), l$ G0 C+ ?- y( {5 f- Q$ ]" n
{5 ~ x! W, N8 H# c5 I9 `
int ret;
/ R7 M& \# `7 _1 w# K: {#if 0( d% o, t* R. u8 n9 R& j! n- g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 e7 E, p+ z4 k
if (ret)
" o/ b7 K7 {% { pr_warning("da850_evm_tl_leds_init : User LED mux failed :") s4 N1 d! Y5 {5 w
"%d\n", ret);' h, L$ t; `9 F" m* K" D
#endif
8 ?' K% A2 b' E2 e6 B ret = platform_device_register(&da850_evm_tl_leds_device);
' [) |4 ^7 ~8 S( c if (ret)
, U: a% M( P6 L- B6 S5 M3 b pr_warning("Could not register som GPIO expander LEDS");2 b X; a% B+ W
else' M6 G1 p2 ^1 W# f( J
printk(KERN_INFO "LED register sucessful!\n");
- U* O* [" v6 u$ Z2 h. |7 \% ^ D) l& ]" ~% ?7 Z( }
return ret;
4 k" S* t& b3 U}
7 {$ i, l, M6 _' C3 F, A! D2 S; L# q2 q E! h+ ^, X
static void __exit led_platform_exit(void); B* M& E% [# h V. j$ m
{" T3 f2 j8 [( |/ G
platform_device_unregister(&da850_evm_tl_leds_device);" e1 b% ^6 }3 {6 b/ `7 Q T/ w
* ]7 h& \/ v1 x. K. ^* w- ?9 u& ~$ @ printk(KERN_INFO "LED unregister!\n");1 Z" K6 [5 \7 I N
}$ |" D! h. W1 x; X$ |0 N* _
- I- V3 u; ~7 g9 l2 h6 j. m4 O
module_init(led_platform_init);! @: H2 X. ~/ ]( D- H8 o% E
module_exit(led_platform_exit);
8 g2 S' U( s+ K
) _, n2 G' t2 G2 D4 {/ LMODULE_DESCRIPTION("Led platform driver");
) G1 D! H+ J% R# g* Q2 Z$ |; YMODULE_AUTHOR("Tronlong");
7 r6 o% u; F# ]* H- W- p& j6 w# `3 kMODULE_LICENSE("GPL");
0 M3 Q: I5 y* x- T8 O5 v8 g9 w. A0 P
|
|