|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
@3 H2 G B% C5 V7 _* e#include <linux/init.h>
6 Y* r3 p; P! V- ]+ R#include <linux/module.h>) F4 _4 l3 f% `4 ~4 `* E
#include <linux/kernel.h>
. N0 q2 H4 D2 H# Z; ~3 w#include <linux/types.h>
1 |/ o: P& l( L8 O#include <linux/gpio.h>
2 Q$ U1 \9 g/ s( M+ W% s7 f* C8 z#include <linux/leds.h>& Q9 F3 P9 J# A: Y9 Y4 ~9 ]: h1 b" V' t% ^6 N
#include <linux/platform_device.h>
1 }+ A9 a2 P3 A9 ]8 D
& v1 J5 z2 |/ F#include <asm/mach-types.h>9 }+ Z1 v/ ]3 e& I: o* p D
#include <asm/mach/arch.h>8 @- I2 c6 W$ S4 X+ E- ?4 ?+ r# M
#include <mach/da8xx.h>
2 M5 g- P C. F0 _; d. R+ P#include <mach/mux.h>
0 x Z* W3 e& d, \8 S) f! M3 j4 N
4 Q( }7 [6 T0 A7 S: a) P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* R6 _+ j9 W3 J, W6 Z# |. R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 R7 s1 _6 [9 [( r" o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% l) I1 ^4 f, P* C, F" V8 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 l) f- n5 ]7 `! X+ W" T# a& l; `
9 T) v9 _* w" s, r1 b/* assign the tl som board LED-GPIOs*/
0 @; [1 @. ]7 a9 U" ^1 F3 zstatic const short da850_evm_tl_user_led_pins[] = {
# u; R8 Z% o% p6 M; r1 q( } /* These pins are definition at <mach/mux.h> file */3 C( P+ P) f5 x9 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, r/ v1 ?, @2 K& i5 s
-18 F4 w( @" v E C/ y7 x' |
};
1 l/ c+ K6 f5 q* y: x' e1 C. Z2 Z% o% Q" C+ ~9 I' R
static struct gpio_led da850_evm_tl_leds[] = {# b2 P& i; X# X
{/ g; Z F0 k" G
.active_low = 0,4 q9 O5 z3 U+ H/ q* |. P$ Z
.gpio = DA850_USER_LED0,
% {" x9 X0 J) M9 D( b# [ .name = "user_led0",- L$ T3 Z* k, ^
.default_trigger = "default-on",, `% ^& B: K+ i3 H; F, \# [
},9 Q$ T9 X5 N$ m# o: h/ g, {! H
{8 f, \6 _2 A* X! j. F( E* Z
.active_low = 0,
* J- a* G3 d" d6 V4 A! F# _; H .gpio = DA850_USER_LED1,3 ]! i: v% k0 o1 A& r! W1 l
.name = "user_led1",
c6 Z' `' D9 R! Q .default_trigger = "default-on",
9 g7 e0 L* `# r, k }, k: E8 H! C- I" C9 e
{$ ~' w! M) g6 Q# ^: F/ T' {- B
.active_low = 0,
3 [0 r% O; r( C; V6 Y .gpio = DA850_USER_LED2,' |1 N' f: A4 J; o8 w6 Z
.name = "user_led2",4 a! @- R5 S0 n% S* U! e
.default_trigger = "default-on",
, K! ]+ c4 t4 u; F$ ?# I c },
" o; H" h# j0 {2 A5 G {/ Y3 U8 I% J. n6 b8 x
.active_low = 0,
% [" I' x# a. h5 z) `7 a .gpio = DA850_USER_LED3,2 N: k/ E& L4 H0 C6 e' Q% j' _
.name = "user_led3"," X% J% }4 C% {$ S
.default_trigger = "default-on",# U; L6 l" x+ J& Q8 x( n
},9 I3 s- ~/ F9 I: y3 o4 O' }
};
, [* w. {% c2 ~$ x& f* g( v, P, `- F4 ?& s3 p; {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ A$ w' Z/ I- t3 z V7 h& p
.leds = da850_evm_tl_leds,( \! p6 \* D" r# u8 t. m5 K6 v# [+ d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& r+ B, a3 p2 l0 C7 c5 K8 _};3 a$ A! X6 b) P. Z1 W
3 s j: o/ I' ?3 N, \6 y
static void led_dev_release(struct device *dev)
0 N* j6 y: ~* j0 ]1 P- w{
T/ M, M1 ]! _0 M$ i};
1 c5 N4 Y' s% V* m1 e; P* W* F' S9 A+ ^) i& e6 U# A" |& j
static struct platform_device da850_evm_tl_leds_device = {* `( Y# B$ D7 _+ M1 D. P2 D/ ~
.name = "leds-gpio",9 ] V( n9 U5 D5 R" T; T$ `# z6 o8 Y
.id = 1,- B/ {7 {! m/ x
.dev = {
1 W( \4 U# k, K' u v .platform_data = &da850_evm_tl_leds_pdata,% d' d) U) a" n) y
.release = led_dev_release, o: n$ C3 U+ d8 j6 D f/ `" \1 X, w7 v$ V9 C
}' l" K. F3 j" r6 D2 h! _
};% F |9 @7 e5 z t
0 A4 [- w7 O% H& D N0 n+ M$ m2 |
static int __init led_platform_init(void)
! t8 j( S( u" |4 H7 ~. o{
0 O& ^& l; i3 J s# D U4 o int ret;
1 U8 z* F i9 y/ v% t7 D: [% m' G) Q4 e; P#if 07 [' D; \; J# k9 e( M7 Y D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 J# T. {1 U8 E! j7 p if (ret)8 G+ @) A. Y8 w. E2 k5 ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 {' ]' K( V9 _' R
"%d\n", ret);
; b- Y) `7 l, P7 _, x) G+ u#endif
9 P M2 l% U4 u# R8 N& }9 g( c ret = platform_device_register(&da850_evm_tl_leds_device);" I: H" ~' f) ^: A( d8 R7 U7 G
if (ret)
+ D: t3 Q/ W9 D$ \' y pr_warning("Could not register som GPIO expander LEDS");
0 v! P- H/ H2 O# t6 ^1 L else
' M- h1 L, Q- l6 |2 L printk(KERN_INFO "LED register sucessful!\n");9 b' ]% N0 d2 V% s# n* a
. ~. h. t6 b$ _# Z5 H4 y
return ret;0 h/ M' W( t* C1 B, ^. W4 C! }
}! U8 a: P: u- y% ^
1 W/ M4 g' K4 e j: V z2 z' S, t2 `static void __exit led_platform_exit(void). R" c: c% Y% e* M
{
# B' j& C1 O4 \4 _ platform_device_unregister(&da850_evm_tl_leds_device);
" Y0 u g: Q) w- V
- a! K5 A( D B/ X- _0 v ] printk(KERN_INFO "LED unregister!\n");2 i! P% X! r' s7 L
}) n' {& K) y7 B4 g: |1 p2 A
. ]8 K/ U2 U- H5 q, y" D5 s6 kmodule_init(led_platform_init);0 S$ k" ?: x3 K; H
module_exit(led_platform_exit);
9 F4 J' r, ~; k* ~: e& g3 D0 ~. R r0 O# ^9 a" V* h
MODULE_DESCRIPTION("Led platform driver");
; B* r( I, c8 T2 O: I1 z# t/ rMODULE_AUTHOR("Tronlong");. Z- u9 N/ `5 v1 ~. p) H6 A
MODULE_LICENSE("GPL");* e3 k0 U5 U @4 \- Y
% G+ L! y5 e3 p/ D7 I |
|