|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" e$ r1 ]. a- ^7 g6 X
#include <linux/init.h>
+ ^& z! ?% L1 U6 r8 X#include <linux/module.h>4 H2 e" e( p2 E2 p- `% K1 T$ B
#include <linux/kernel.h>
( D8 E7 e& B- k+ j! W$ {#include <linux/types.h>
9 e/ r$ y1 `7 x. r$ W#include <linux/gpio.h>- d$ }) l. c* X1 T8 f4 g
#include <linux/leds.h>
" K) Q* y7 e# X% }( [# i s9 w#include <linux/platform_device.h>5 \2 q- Y& ~) ^+ F! f
: H. R9 F0 J7 g% o+ k, N#include <asm/mach-types.h>6 [/ Q t! B9 f! c
#include <asm/mach/arch.h>
% X0 F- t+ [; w9 ]1 q#include <mach/da8xx.h>( H" A0 O% A- ~% a2 S( [$ [/ R
#include <mach/mux.h>
+ w. e# o5 k$ ?8 |/ f0 P: d
6 W4 P9 A' i1 Z2 a) {+ v$ ^- B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# b0 f. Q* k# r+ [! y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, o7 _: _* {( Q& P: K0 j6 u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) K1 {& e* Q, U* ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" z4 W7 | E5 L7 F3 O4 z
1 ]6 }6 D- o6 J e/ U
/* assign the tl som board LED-GPIOs*/
" w9 A$ I# F/ u$ B. x( [) Z Sstatic const short da850_evm_tl_user_led_pins[] = {% f/ O1 g! a) j$ d3 t
/* These pins are definition at <mach/mux.h> file */
; {1 O8 d* E- w' T" r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# T3 {: S- C! {* T; h1 \
-1
1 v' y l1 ~1 a};
' K/ ~5 a% E' _( }) `4 v; \/ N- |8 d% L1 S5 Y
static struct gpio_led da850_evm_tl_leds[] = {
% o. ]! Y" B7 M2 [5 @- g; ^1 b* ^+ ` {- n* s; N/ O& ], O
.active_low = 0,: ?9 c0 f, l, \ u4 k
.gpio = DA850_USER_LED0,7 f) p' y M* _1 S4 \( u3 b4 Q
.name = "user_led0",
/ n' E$ o6 S% j' [ .default_trigger = "default-on",) P' b; {( j0 L& [# x
},
* @9 |8 M- A4 g3 B {/ W, @4 E+ F. r* N4 E0 X a1 ~
.active_low = 0,# w4 W+ J+ x4 u; e1 r& ~. ~: o
.gpio = DA850_USER_LED1,5 }) x# q- `/ C3 t
.name = "user_led1",
' P4 G/ D) F0 Q3 S .default_trigger = "default-on",+ K1 q& z8 l+ K4 B
},5 e0 [" ~7 y0 ~9 D1 ~
{% P1 R7 e& `! J
.active_low = 0,* r# e' D' |4 _4 |' Y4 D
.gpio = DA850_USER_LED2,
& e" v- X, Y9 {% m2 g$ | e( j3 c .name = "user_led2",
( y: k; \! f* t. t' i0 t+ | d .default_trigger = "default-on",2 w$ V. [3 {8 d6 q# C) h5 {9 z8 y
},2 E2 [6 r, w9 j4 ?5 X
{
$ V+ R/ ^. o" M) Z; B' u .active_low = 0,0 E% Q- I" x$ {' F1 G; \2 o! v" Y- r
.gpio = DA850_USER_LED3,, ?2 `9 B! K7 X. K' |9 U' u
.name = "user_led3",/ L" p2 d. w' h7 U: k7 u. J
.default_trigger = "default-on",
/ v# b9 N |/ X1 y. W },/ ~+ O6 J7 D9 W2 y7 ~: h
};
1 k8 u( c) c$ k1 ~' }1 V$ [& ^: w
4 s6 M3 P- }9 z* I0 pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( q& z. ^( U: P& s/ b% ?$ u7 I .leds = da850_evm_tl_leds,
1 ]6 N0 ?: T$ g0 Y& d2 R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) x* i0 {8 |- W};
8 d& o+ f e: }
* p9 K9 M, V- D8 E6 W# w' [static void led_dev_release(struct device *dev)
$ b0 k3 q' v. N6 k! T" X2 O{% N/ [3 b9 a( K$ _" l
};
& \, ]. F/ q, H
" w7 |, q/ I% H: {8 j) G% a* ]static struct platform_device da850_evm_tl_leds_device = { x" d( \- e$ x5 c
.name = "leds-gpio",
0 x0 Y4 }8 L: Q" ?. D2 I1 n, A8 w .id = 1,/ U3 } M1 @! K* `4 q5 L) \
.dev = {
0 C0 V. e; q$ M0 y3 `( N' A8 I- ] .platform_data = &da850_evm_tl_leds_pdata,8 J7 ` P; E! U P
.release = led_dev_release,3 X8 I: [" V+ _* V5 Q
}
8 U! I8 T# k% r3 E# k2 a0 I, Z};' U. Y* t: a% e. e
2 t5 a+ {( L* J* W: f, s
static int __init led_platform_init(void)
: [ n r% w& ^& [; B{, b; I6 o. c+ O
int ret;% e/ G% e( k' A6 z3 ]& T& s% ?/ A
#if 0
9 M$ Z e( q; L$ B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* k: d! b; [) Q, G) @. q if (ret)$ T9 n. A" a% x1 B. j; ^1 g2 t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# S# f: P2 y. ?" R; M' Y2 T "%d\n", ret);
E+ J) N4 C" R#endif+ u0 c n( U. M& ~ t* J, Y4 v
ret = platform_device_register(&da850_evm_tl_leds_device);
2 F) I4 ` A6 V6 H" t if (ret)
, A8 V2 a5 t# F) q- B pr_warning("Could not register som GPIO expander LEDS");
* M9 i/ t! c- x1 C+ e else2 X7 f& @& p8 b
printk(KERN_INFO "LED register sucessful!\n");( z0 l7 z1 X4 G5 W$ i+ z
; p3 g/ S% A3 M" C+ |
return ret;# u$ t4 q% ?9 [6 ?6 a* R& b! k, ^
}
+ R1 d3 [/ s" _7 ?. m. T' {0 ~, O" Y0 M/ U: H
static void __exit led_platform_exit(void)
9 J. v5 n5 K9 l+ U{" Y/ ~! r+ F8 P
platform_device_unregister(&da850_evm_tl_leds_device);
9 k- F9 n7 t$ k4 z1 Q5 q0 q8 Q i5 w
printk(KERN_INFO "LED unregister!\n");9 a% T. |9 n0 E# Y* w) I4 |
}' e. \+ y$ u8 P9 @
7 T0 Z: O, E; @) \ i$ Ymodule_init(led_platform_init);8 r7 T, k2 ^# d0 d1 T
module_exit(led_platform_exit);( \" `% R: t! f% v% U
9 L3 O- {4 a* R. h8 n3 oMODULE_DESCRIPTION("Led platform driver");
/ F/ \6 F/ `( t5 E+ w, V" Z# dMODULE_AUTHOR("Tronlong");
+ q3 H5 }; M" s8 K/ R3 m- |MODULE_LICENSE("GPL");; Q/ i' l% o, @# M- I
( [# Y/ M6 s& C6 |: i
|
|