|
求大神给下面的程序做注解,请稍详细些,谢谢。' u. z, x, ^7 P9 r. E( \
#include <linux/init.h>
' d7 c, r$ Z6 e#include <linux/module.h>
: i9 q" M2 B! z$ o' s. \$ [#include <linux/kernel.h>4 r9 s* W* e4 W; N
#include <linux/types.h>
r# ^! Y* }2 s' a' i6 s) o4 Q/ C4 k#include <linux/gpio.h>
. |! R5 y8 @, L#include <linux/leds.h>! V" U. W( u {/ j; _- d
#include <linux/platform_device.h>& G, T- q0 h8 @3 @: d
1 h3 ?) |- M8 F* Z( U
#include <asm/mach-types.h>
) M6 J; V, r" Q; f' U0 o#include <asm/mach/arch.h>% X7 f7 E2 s% j
#include <mach/da8xx.h> |" r. a, j2 D# F8 W0 U' m
#include <mach/mux.h>+ E* o% e: p; m8 ~* W
% m4 `" g/ `) R( k, u7 W+ G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! G" ~; F4 i8 Y2 }# \# ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) k3 J P2 P6 D0 @ }0 k/ y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). a4 a# J6 C% |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% P/ B Y* Z# g5 Q( c3 [2 f
" j6 j5 U8 _4 G( C- d- H/* assign the tl som board LED-GPIOs*/. k7 i% K* S6 n0 T/ e1 o2 Q' i
static const short da850_evm_tl_user_led_pins[] = {, d0 I- g% d+ y
/* These pins are definition at <mach/mux.h> file */0 u% }1 K7 a* Z4 M& m3 _1 v7 O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, w6 G1 h. M) C
-1
- s6 J$ D1 b& j2 F0 a: ~2 M};) L5 g$ k% b) y$ ~& I
" O6 `& ]: O- D* s/ |+ f/ C; ^
static struct gpio_led da850_evm_tl_leds[] = {
' x" q Q& B0 D9 p# V {7 e, c0 V9 S& ?" v# k% ^2 X; ^4 G
.active_low = 0,
) t3 { `# y6 C3 M; @2 K1 _ .gpio = DA850_USER_LED0,) w% `/ T3 L6 b2 X1 Y: z/ s- Y
.name = "user_led0",; J/ ]1 z. V6 c% `/ B) Z
.default_trigger = "default-on",
9 B+ Y$ [/ T$ f% Z% I9 Y: l },% Y5 _$ c W7 U# h7 z+ e8 X
{
/ r: }' ?+ Z: ?1 z l6 L .active_low = 0,2 {8 f7 a& g* z! g
.gpio = DA850_USER_LED1,
- R4 w# |, [1 B .name = "user_led1",
! l( m# o. k6 E- { f: u .default_trigger = "default-on",, e8 } Y+ z) G% v/ @
},
0 z8 x) Y! K* B& |1 | {
+ I; c; l) m' W5 C, o% a" u6 l .active_low = 0, N7 ]' U, D/ S6 K7 ~
.gpio = DA850_USER_LED2,. o0 W, h8 t, G t
.name = "user_led2",
1 \+ H2 C9 m" q2 j$ p .default_trigger = "default-on",: U& ]# `: O. _; N
},) r, Q- L: x0 z# g
{
' p+ H+ a, X$ S& F) b/ g: H .active_low = 0,4 R6 C7 m8 y! X( s i- N+ _
.gpio = DA850_USER_LED3,
7 {: f) v4 c3 y2 @ .name = "user_led3",
7 z# `& }: _$ b7 I4 d! W: o .default_trigger = "default-on",( b- ?5 S% V2 c$ f- `3 @
},
?: g, ]6 { u1 Q6 C* _' G, }};
8 D' j$ G9 M7 [7 b4 m4 Q( a+ z
6 K: v9 e; `4 a8 }. C) estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 y- h# n- Q. F$ Q% B- w" L9 | .leds = da850_evm_tl_leds,
( N7 t& h& H3 S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
V5 z* q: w5 r; K};' I. {$ ]+ \# C
( l& e/ M2 Y8 p+ U2 u
static void led_dev_release(struct device *dev)# b8 p } P1 e8 g, t0 J
{
% _1 a$ K0 \# \# U e% U};
: H3 I0 A4 o; m" X: T) Q8 G0 [0 {* r! O4 i
static struct platform_device da850_evm_tl_leds_device = {
1 z( ~) W! J) ~% f( B .name = "leds-gpio",/ [+ ~9 P" M9 }7 Z
.id = 1,8 @' |1 |) [+ T% Q d7 f9 ]9 |* j- {
.dev = {; E# X! l( y; P4 t- O# ?$ F, A
.platform_data = &da850_evm_tl_leds_pdata,
1 A. S1 T& l3 x8 V5 q Y .release = led_dev_release,
3 u8 j" Q- U! P' M; n) F* u7 @& u. w! J }. C& I( J6 q: W) w/ y6 |8 v
};
8 l# c0 ^. b0 c0 d2 G, Z, D* _ X* l6 C( L
static int __init led_platform_init(void): X0 u3 |/ x. K
{
' m% C# \( u# Q! |" q int ret;
. N# J) K$ M: y/ ]#if 0
5 l$ s, ? I: p4 K2 Z2 n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 ] w9 l' ~" E, i if (ret)
+ f+ M# j- T$ `( c& V5 H& U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 d& x7 \ n! k9 ]; v
"%d\n", ret);% Z4 H# z( [& Q* S) T2 z- y L
#endif
( X+ v9 y1 T" d ret = platform_device_register(&da850_evm_tl_leds_device);( G- a) |3 F. B- m) G! \' [2 V5 W' T
if (ret)
+ n# ^0 {5 D; T! O8 w2 e0 `* m pr_warning("Could not register som GPIO expander LEDS");9 l; k9 W' Z! O/ c/ o
else+ _. E/ O) |( @# D" y* T
printk(KERN_INFO "LED register sucessful!\n");" g9 k2 G! Y4 ~# l5 Y3 m& X0 Z, Y- j
- q4 v0 c! G. r: _3 |: ?
return ret;& K1 U A- E2 f \7 M! `; Y( ~
}+ `8 b6 B5 B& c8 @' ~& I
; _0 n8 r, z6 t3 S
static void __exit led_platform_exit(void)
& x2 I/ L9 r* W7 ?& I0 g/ C{
6 J8 A4 o1 d b- ~& q2 [% B platform_device_unregister(&da850_evm_tl_leds_device);
# I4 b! N8 r5 X& p- \6 Z, W( \8 o8 f6 [) r) W
printk(KERN_INFO "LED unregister!\n");: n# A# u- S+ s, [
}: _: T* Y r% q; n
: D/ L$ i% H3 y- u; i, Amodule_init(led_platform_init);
; m: N% u3 L# o% L8 x7 j( fmodule_exit(led_platform_exit);
0 j9 ~& d. s* u# i ]7 h6 U* | M5 _8 E+ L# ? W0 Q$ H
MODULE_DESCRIPTION("Led platform driver");
& u3 f" w+ k ?2 k; Y' |! yMODULE_AUTHOR("Tronlong");
' b( o1 |3 H8 T) r; O+ lMODULE_LICENSE("GPL");* }2 @9 W* l! }) f1 [4 E, m7 P
6 ^, [; ?- v8 i2 N8 P5 [1 r |
|