|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; O% K8 ~0 g! \9 G) z+ A- N#include <linux/init.h>. m4 f* |- Q' [2 u
#include <linux/module.h>$ }6 @ {5 E' P- U8 J1 ]
#include <linux/kernel.h>/ Z8 N% o( t: ^# X) P% Q
#include <linux/types.h>
. R! [0 T& y; v. ~8 j#include <linux/gpio.h>6 H# ^, `4 q+ m) i: y
#include <linux/leds.h>
4 e8 V; {' T, h# c( {#include <linux/platform_device.h>
. K* ?$ \$ q3 l* p
* o9 f P7 f, X, s0 g% q% V2 X. G#include <asm/mach-types.h>
, J2 l; ]5 z. a5 I#include <asm/mach/arch.h>& v! s6 N9 `) l0 w8 Y
#include <mach/da8xx.h>. m: v+ l5 L* U4 \6 y2 m6 }8 R8 U
#include <mach/mux.h> [/ G* d+ G" i$ m) |& Z, X
5 d# c( X3 R4 t! }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% r0 X& G/ d! m( p) T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ s( y# {/ [* I4 W# W) Y5 l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# }- ~$ l S5 N3 S, I' r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
r, ~) V; x8 M; D3 j# J, m6 V% n! |2 s! E. b& ] |& v
/* assign the tl som board LED-GPIOs*/7 y( t: h8 n6 V5 C# l
static const short da850_evm_tl_user_led_pins[] = {
9 y, U9 g) g9 g- I% F /* These pins are definition at <mach/mux.h> file */' F( v+ I: u* j! K* m) e0 c0 b( D& G* a$ s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ M0 j/ z1 a9 l6 @5 d/ w) N
-1
- [9 t3 U' u$ F8 j4 u4 F7 M" ]. k};! W+ o! {: i3 u8 i
+ V# n1 X- K' C5 ustatic struct gpio_led da850_evm_tl_leds[] = {
- K% R5 J* W, {2 F% i L& x/ J {8 D; U9 g# g- f/ o
.active_low = 0,
4 q/ ^5 I* O. | u/ W% U& E .gpio = DA850_USER_LED0,7 [ t* h: l+ e8 U
.name = "user_led0",) R) d! H5 O9 s5 s% l1 v
.default_trigger = "default-on",
7 B. T! V; w. w) R# `' [. H+ G# Y },
7 M1 `3 }5 e$ }1 A9 ]* U {' w8 _. E S; M f
.active_low = 0,
+ `. A' t( E1 M1 V# D .gpio = DA850_USER_LED1,
0 Q# _" f1 A) V" z: {( |2 X! G+ y .name = "user_led1",
9 I9 r. m, p4 Z5 A/ [: f3 n .default_trigger = "default-on",
2 t* ^4 z8 H8 J; P# ` },
" O' }# C4 E! P2 e/ R/ l {
- r2 m x6 V' X% W" L' M4 k' A .active_low = 0,$ c( z0 z3 s# |5 z) B& G
.gpio = DA850_USER_LED2,
7 n; `7 J7 V' r4 o$ Z# O .name = "user_led2",
: S z3 s: [" o5 l/ x) u5 | .default_trigger = "default-on",
" C- ^8 V' q) i& T# h+ ] },+ o" S; P% B, P! L+ v% H+ F; [
{
, x5 P- N9 \+ h# X0 ^: t* t# } .active_low = 0,$ g) W+ e B2 _( b6 k) t/ G
.gpio = DA850_USER_LED3,9 i+ s! g( l9 ]* \: g) B) w" m. F
.name = "user_led3",, n( G7 `: @( j. `# _' N
.default_trigger = "default-on",! i# e4 T6 i- b: F' y0 K
},9 \8 {' o: k, S+ n& z
};
E0 s; O: z! R) m6 T4 ^' |) |# v$ G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
u0 L1 _& ~6 I& n- o. ~ .leds = da850_evm_tl_leds,
! S0 G4 g, f& S0 I& ~5 m: R& p4 h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; F# Y6 A: ]! z
};
! r: x# v' p2 r: s+ ~0 C$ U. C; O
static void led_dev_release(struct device *dev)
" D; Z2 L$ I3 C; u5 w+ _. i6 d7 K! Z% F: @{- n1 m1 E0 f B6 Z6 S4 N: k' j
};
& R. M; F9 y; @8 G; S% ?
& S) q; O8 f+ w w3 A$ c& e, F; ostatic struct platform_device da850_evm_tl_leds_device = {
. x9 F: R% ~9 S1 F# K, g9 L: F" i8 c .name = "leds-gpio",
: `: k i& U# W .id = 1,
2 [. i/ l( Q7 |0 n6 i .dev = {
2 s9 U2 X6 O* V, x3 [, D7 \9 p .platform_data = &da850_evm_tl_leds_pdata,
6 _/ J0 ^2 r) I# t .release = led_dev_release,/ y. W/ @* G( P( z0 R# w. s
}
" D; z/ R0 k: N# ~+ a};
* i% Z6 R" `) }! ~& [. }6 k7 r7 c$ m1 ^+ }
static int __init led_platform_init(void)7 \6 O9 S4 q' g# y9 p+ H- A
{# @% g' {" s; X0 V
int ret;
) p2 d/ r1 H: ^/ w#if 0
; n3 {! J3 w9 j( m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 ?8 ?! t% U3 V7 S! L% p" [ if (ret)
9 f4 `' J. M/ J, U" d I pr_warning("da850_evm_tl_leds_init : User LED mux failed :") h* n3 f* \2 }7 o/ B
"%d\n", ret);5 j7 v7 ?( a/ y
#endif
/ J+ t3 N4 c; W; ^' l- O ret = platform_device_register(&da850_evm_tl_leds_device);) U; g& N2 c! E' H, L
if (ret)
& z- H( h! B" ]9 @9 w pr_warning("Could not register som GPIO expander LEDS");* `; L3 [6 G! ?6 R5 i
else3 o1 K( m) d! q K& E4 e% J; B
printk(KERN_INFO "LED register sucessful!\n");
: ^1 e: l6 T% ~1 S9 _" T: I& g3 s- v: L! ?% F k
return ret;
) ^# A6 K+ a0 v, J# x" d! w2 i}7 A+ s+ G" o, G6 B2 _6 U! I3 y
9 I# h/ r. |4 V3 a+ X" vstatic void __exit led_platform_exit(void)
9 l$ m0 c7 ?+ E% M( c{
5 k+ c. m7 x/ q! k' j: n platform_device_unregister(&da850_evm_tl_leds_device);
- c+ e, g( f. z0 w+ j. j# V, U$ ^( i' F6 T+ n* l9 m% j
printk(KERN_INFO "LED unregister!\n");
& d7 T6 m e9 H3 x3 G! a; y}4 D, v9 h2 T' E+ C. h6 ~2 |
/ ?, S; x5 I5 F
module_init(led_platform_init);, S/ F( D: Q" l$ u" Y; h, o( r
module_exit(led_platform_exit);
, C( x9 D5 _. j: e
0 @( G G9 r1 k" B0 }0 QMODULE_DESCRIPTION("Led platform driver");
" D9 ~* m; H/ }5 jMODULE_AUTHOR("Tronlong");% Z7 |$ m5 I: @
MODULE_LICENSE("GPL");
8 F7 d& s& F; T/ T' w
8 b7 `9 l! F4 p" Y" D |
|