|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 l; V/ p8 C$ F" y/ g" Y' p
#include <linux/init.h>' u/ S5 p& b& M4 D" h, j
#include <linux/module.h>
# ~, e G& \" O8 [6 W1 j4 d: C3 T#include <linux/kernel.h>( U7 J( K# H; _9 D- P
#include <linux/types.h>, i% J j1 V9 a1 K1 O6 N
#include <linux/gpio.h>) F8 w- z$ N$ G$ W% y
#include <linux/leds.h>8 b8 F, B p( b
#include <linux/platform_device.h>
: ]6 L' D8 u$ S5 w. {
, ?" b3 Y& k; s1 E#include <asm/mach-types.h>
3 K* e* V o: z5 L#include <asm/mach/arch.h>
' @* H0 [) v% p9 H#include <mach/da8xx.h>
7 B5 M. u3 T% S$ `% q( _9 [3 o) D#include <mach/mux.h>; L1 N7 D! h8 _6 q; T/ T) x- ~$ V6 C
$ X4 Z" Z! n$ L4 O% j0 z7 @5 u, }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 t+ S6 `7 V1 {2 @) z' U* E% N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* O# y3 Q4 g! V8 e7 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 q5 O- H; Q9 J2 t* N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 Y( ?6 r* V* P! y7 A
: g( Q5 X( [% k1 {' ?& D! x' E' R
/* assign the tl som board LED-GPIOs*/
4 c! [2 X7 M. E( A2 D) {static const short da850_evm_tl_user_led_pins[] = {+ I% _- r5 i$ X5 c+ p% ]" Q/ z" d
/* These pins are definition at <mach/mux.h> file */, X. }- W7 |1 b- R, A$ ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& a3 j! X1 @/ c2 h
-16 k6 g- H; s) ~2 u( s1 {3 I0 p
};0 y- j. b* j9 X1 R! o
9 G- q$ f6 f$ T* T5 tstatic struct gpio_led da850_evm_tl_leds[] = {
& }% }0 l* J: x$ k1 o {4 a$ u( E; Q O/ T. A
.active_low = 0,; C% m# J4 {3 Q- G
.gpio = DA850_USER_LED0,' X/ d, O: E5 y& l1 {# B( M) g
.name = "user_led0",
8 ?$ T# G' I2 O/ X% g6 K7 V7 K# i .default_trigger = "default-on", P* l* e) C* M: C) r! }
},
1 e- s& v" c( g) D5 x# u: o/ w {
. V: e7 R- o' |% r$ L .active_low = 0,; e+ B2 X0 d9 M0 i* e3 x3 O
.gpio = DA850_USER_LED1,
6 x# a+ h+ X1 B7 E .name = "user_led1",
& V! v$ ]" O7 @. z- r b! D .default_trigger = "default-on",' @6 D& r9 U- i7 ]! ^% n
},4 H( W2 x# n7 A6 l7 L1 n1 {
{
, o) g8 B! W, c6 o. D) m+ h .active_low = 0,/ O8 s2 K' o' ~. t+ ~4 L& w/ n: ^$ ~
.gpio = DA850_USER_LED2,
' {' U9 b4 w2 K) X3 ] .name = "user_led2",- c6 m- T3 u6 k2 ~8 ]6 f
.default_trigger = "default-on",
2 f; _" J- V' e ^6 x6 V! {) F' k },
( @0 E! Q2 z! A7 F. n0 b: u9 f {
. o0 H% ^* K9 w* `* f$ E# g .active_low = 0,- u% [7 p7 h9 a8 d
.gpio = DA850_USER_LED3,; g" C5 K# a7 U2 C1 `/ B3 ^4 y
.name = "user_led3",: G9 ~. p( w2 E' L5 e
.default_trigger = "default-on",/ Z; r( h5 v1 d$ V
},, t# a: L8 h P' N! P- d( G
};
. ?& K9 G4 [1 m* R1 R7 Z- S$ Q1 V7 t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# T; D5 ?8 {9 O" p# X .leds = da850_evm_tl_leds,
4 r4 { @9 l$ @1 ^0 U F* k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% q( B& l' v3 a( ^; j
};, g2 Q- }8 ~7 p, E9 s& K# S* K
% V j1 w! |) h9 \ v5 C
static void led_dev_release(struct device *dev)+ A; s' p- o) Y
{8 {9 f. |: W+ N. C3 W' N# ?8 |
};" ?# e" f# L1 ?
; f" T6 ]7 [2 W9 U' A* w- `static struct platform_device da850_evm_tl_leds_device = {
5 C; E y, _4 F8 g0 S .name = "leds-gpio",
, s; X' O2 f7 k$ v5 v .id = 1,
$ S$ C. F7 z6 J" ]1 A: B" u .dev = { H. \( N7 r2 }2 Q
.platform_data = &da850_evm_tl_leds_pdata,3 B3 X w2 s/ Y2 V5 ~% V
.release = led_dev_release,; f' R. e# z" J( A& `( s
}# _- k! G4 b( E8 D$ _9 s
};
* C2 l' c2 C- g3 t
% k; M0 E* U$ {- a) K1 T1 E. Astatic int __init led_platform_init(void)
8 u- v3 r# ~7 d0 q+ J" l2 A1 W' L{
% c& H! c: a N/ r. R int ret;( N3 ?" w: z9 V% I# q) M2 \" M
#if 0
, f+ L8 F2 S4 U# H, ]. E# A) \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. p* u! R, D5 P& {8 D4 J3 i
if (ret)
1 x4 Y, l9 t. k7 U' e$ N; A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 f# M% l. g" F( \3 M "%d\n", ret);( Q( d' ]; r* u& V- A' s
#endif! W' Y3 e0 K& B# w, P, ~' ]4 h" i
ret = platform_device_register(&da850_evm_tl_leds_device);
[; P8 e: f t; K% |+ i1 U: H if (ret)7 z0 a# G, [* U" ^0 A1 B
pr_warning("Could not register som GPIO expander LEDS");' ]3 e n! |1 l' n& v$ P
else
L2 c, N- m! [5 x3 K @ printk(KERN_INFO "LED register sucessful!\n");
2 y5 n: f; u6 X! `, H: A, t6 ^. l# }/ C: O+ K- J7 R
return ret;
# v3 q: [3 ^4 i9 ?2 J$ W- ?. J}
/ e U, r6 r4 _0 s+ J1 S: S
5 D7 I/ Y7 \2 v2 ~' H- Jstatic void __exit led_platform_exit(void)& O9 S6 ?- |' |: X/ m9 L) V" L
{
% z, Y8 g7 q2 q# v5 ^ platform_device_unregister(&da850_evm_tl_leds_device);$ G; I" f1 L* i0 f% k; [* e9 A8 T
s. t4 e5 M7 U
printk(KERN_INFO "LED unregister!\n");: n% e+ P; L$ a2 S4 ]. u
}
) O+ U- R$ X& z: }% } R2 X; e$ n
$ p1 ^) Y; d' b }( g2 s! M amodule_init(led_platform_init);
3 R6 a9 M0 R a s, m. Wmodule_exit(led_platform_exit);
! |2 J* n3 `8 p1 @
0 ?+ {# L( X+ o1 G5 ^MODULE_DESCRIPTION("Led platform driver");
; A9 I9 z6 d1 E+ m# \: pMODULE_AUTHOR("Tronlong");
' ]8 q' L" @* D, e& r9 PMODULE_LICENSE("GPL");/ q: X- U4 N: a' J
* P3 o& V- b3 K |
|