|
求大神给下面的程序做注解,请稍详细些,谢谢。* O) z6 A, Q2 s2 l4 I
#include <linux/init.h>+ |7 z; S5 h$ `- N1 V7 j
#include <linux/module.h>, A; ?2 u; ^- I+ J8 X7 _' r2 D
#include <linux/kernel.h>
, N4 j7 z* B. \5 v#include <linux/types.h>
: C: |; n) l, |; o3 M& ?: D#include <linux/gpio.h>) y4 u* L% t, m) d6 }
#include <linux/leds.h>
* R) k3 Y) D- f, M) G8 |' P6 E/ [. _#include <linux/platform_device.h>
' z F4 _6 L2 s. t
; f! @: Y+ x+ |$ F0 T#include <asm/mach-types.h>; w6 Z' t1 z7 \9 K. g! D6 ]
#include <asm/mach/arch.h>
) N" j# }$ l, n* T7 t& _#include <mach/da8xx.h>
0 \+ Z P* C9 J$ b$ Y#include <mach/mux.h>
' i8 l/ J+ z. E4 O
% }% @7 X$ A+ |3 V: _+ E* f$ Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 v9 I8 A$ m B* a' _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# G5 J l1 s2 J' U7 w- l9 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' e1 o: _/ z4 V: S1 h. C$ d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. g3 k. \1 t: J" C& D: _/ N6 u/ e0 p( T1 U+ M) X& V6 E: q" _
/* assign the tl som board LED-GPIOs*/
. f. ]( Z$ I* I+ j" \static const short da850_evm_tl_user_led_pins[] = {5 f9 U) W1 ^* y+ b
/* These pins are definition at <mach/mux.h> file */3 R4 x( Q) B0 G P3 x) S: D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# R. m4 c* r: L3 o& s0 f
-1. A: i3 w4 k& ~3 g
};
( J4 c& X$ J9 j' L1 A& S
0 r; |) f6 b8 F! W- q9 Dstatic struct gpio_led da850_evm_tl_leds[] = { h/ P' z' G$ d! v; |1 z
{
& w1 v* _) x4 {8 ]4 P+ E, F, x .active_low = 0,5 p( Z% K; i6 w
.gpio = DA850_USER_LED0,; ^# ^) ` M5 W
.name = "user_led0",
9 A$ M2 X3 s$ n) v$ W2 W$ Y/ t% W .default_trigger = "default-on",7 o3 U% }! ]2 D0 m
},
) `8 B: c- b# g) q. {2 |& T* O {
: u5 S v* p3 h .active_low = 0,- A8 @' ~$ ^ p
.gpio = DA850_USER_LED1,
6 w/ l4 f, K5 p$ D0 l2 q .name = "user_led1",
W, _ u* S( K .default_trigger = "default-on",! y' @- f8 o; D3 g2 W
},+ w+ z, v. B+ R
{& X; ?! j2 [: j2 Q
.active_low = 0,
3 O" q( M1 J+ b2 u/ N# ^ _& s .gpio = DA850_USER_LED2,
b" C! G- S4 E) _0 V% n .name = "user_led2",9 i) R" T3 R/ L' E: T3 ^( c
.default_trigger = "default-on",
; N! g: G( d" u& ], x( Z7 N+ z) | },
9 X# l& u4 u" G5 t: @( A$ b {
# Q2 P3 r' Q$ d .active_low = 0,
) H$ c' S5 v0 i9 ?6 x) e+ L .gpio = DA850_USER_LED3,5 H: ] \: W' R9 L0 K" W
.name = "user_led3",
+ X5 W, W; a7 W: k7 F" Z' v5 A .default_trigger = "default-on",# c8 u4 p0 w# K: ^" L1 I* M
},
7 a7 c$ c' M4 ^4 S( x};
+ `0 `5 A. N" P3 M1 J/ {2 b6 r' G `6 y/ v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, }) L4 @6 d/ h- S
.leds = da850_evm_tl_leds,
* K) P- k O m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 ^9 J! _2 l9 P4 g
};) d7 [3 S2 | v! o9 I1 C6 o7 c
2 `% T4 Q0 a( o4 k6 D% |5 Nstatic void led_dev_release(struct device *dev)
* {% D8 q. H8 w0 @9 \' l# @5 c{
4 i$ F, ?+ g5 `" y5 K5 ]};
# l5 |1 |& r9 a, p% A5 D1 J( o/ U$ \9 H- M
static struct platform_device da850_evm_tl_leds_device = {
' T1 Q+ N& e _) ^( G .name = "leds-gpio",
9 Y# t# C& h" X/ {& O .id = 1,
! W% i* p3 T& R& M; X/ Q3 u& L3 w .dev = {$ U W4 C, K* R, A" j
.platform_data = &da850_evm_tl_leds_pdata,
5 S s5 L2 b7 p! F1 R .release = led_dev_release,( ^5 s7 t5 G9 I; L' i3 r8 m! V4 B
}
' S% s' I& w, \/ Q};
( z/ Z: U* H6 ]1 ^
+ k% k! s0 L$ Tstatic int __init led_platform_init(void)
3 T2 I4 f% r6 k/ H# D: b{/ V7 n1 Y: D$ i+ O6 O/ O4 A0 ?
int ret;9 H% y9 G- V( Q' }, ~, x
#if 0/ u+ [: r4 @! h0 M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 r4 o, X) g' ~" O* K; i
if (ret)
; X5 ]( Y8 N( [# H5 L5 h6 \8 C: O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; I1 }& q1 {6 r6 G, w5 x+ E
"%d\n", ret);; K4 d8 \5 ~6 h- p1 d3 k
#endif
% x: }# t7 U( i. A8 L& X' u; C ret = platform_device_register(&da850_evm_tl_leds_device);
4 O. w# h- ^- l* h9 r if (ret); `/ t N3 N7 p" h( _% s
pr_warning("Could not register som GPIO expander LEDS");. R, m" Q* o2 G& G' v- x
else# c2 t+ u1 Y! H$ H9 F
printk(KERN_INFO "LED register sucessful!\n");
: I! x8 n1 U0 m; S4 |
5 u9 n8 z8 s% |/ y. N return ret;. b7 ~% A: L9 S+ B
}4 @: G& A$ R6 [& }% C
, ~; W! [4 Z X H8 g4 `static void __exit led_platform_exit(void)
2 ^) D2 U& u0 F/ p{
, {# I8 u3 ^8 Q+ g platform_device_unregister(&da850_evm_tl_leds_device);2 B- X0 f( p" z1 Q7 Q3 V: [, C# \: i: {
, ^" _4 _2 ^5 ~- o$ t
printk(KERN_INFO "LED unregister!\n");
3 M, Q! M% d# p! U$ t}
# Q! j) X* j* l4 n7 I/ | L8 r7 {8 Q5 f; |$ _( x) ]; \
module_init(led_platform_init);
" _$ j) n2 x% N( Dmodule_exit(led_platform_exit);
( C4 K, j( J. b$ S: m. Q
6 z! X4 X$ D+ |% f3 p* |: }( U6 OMODULE_DESCRIPTION("Led platform driver");
! B7 w4 R A' B. `5 ZMODULE_AUTHOR("Tronlong");
2 v% J/ T6 G" z) Z( O8 MMODULE_LICENSE("GPL");& M7 S& W1 j7 @
" S8 \3 l) {+ R2 y( d+ _: N |
|