|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* g# F, C2 E* Y# _7 \& f @
#include <linux/init.h>3 Q# ~6 U4 S' K7 k, `
#include <linux/module.h>% _$ a/ d1 Y7 {. ~# P* ~# v' \/ W
#include <linux/kernel.h>
; r* x8 |8 `, e# M Z$ Y#include <linux/types.h>! M L4 j |0 ]/ Y# b- R
#include <linux/gpio.h> \2 P$ G: G- T
#include <linux/leds.h>
1 Q* L' S: f+ `' t8 e#include <linux/platform_device.h>9 R7 ~8 n; [, T M, y* z/ g
% E# M; v3 \0 V) O2 I8 J* ?
#include <asm/mach-types.h>
% ~+ [ |& W( M4 W0 v! b#include <asm/mach/arch.h>1 U, a2 Y4 _7 p6 @4 m' q
#include <mach/da8xx.h>% s3 Y6 W% ]& O/ i, w
#include <mach/mux.h>
/ q9 y) b( i4 t' A7 P z! L& F/ t9 |4 Q" R2 d% o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 E& d9 Y% [3 c" N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ P$ z) h. d, \% L# p2 F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 X, e5 D3 M% P3 W2 n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 ?! u+ ^: g- P1 s: d, T* O
/ y5 h, q! i. V" H
/* assign the tl som board LED-GPIOs*/
6 m( B+ q- O4 s' A" `( z. ?6 k$ estatic const short da850_evm_tl_user_led_pins[] = {
5 ^% [( d* @: K Q3 c" h0 g2 s) q6 s# T- H /* These pins are definition at <mach/mux.h> file */
/ |7 H: w! l5 y$ J/ N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 m B5 U$ H: X \ V -1
- u @; r) C( }9 W7 k};& t5 \$ G2 t* z0 {" p! Q
1 ]6 m/ z/ P( x; m+ H
static struct gpio_led da850_evm_tl_leds[] = {
$ t4 ]. z" h1 _/ j4 ` {& A9 d8 {9 t% q0 Z$ M: t# b
.active_low = 0,0 y" d) {; `0 s
.gpio = DA850_USER_LED0,
; h' A) t* L9 B* M# I .name = "user_led0",
3 _. e/ u0 V' j- b. ~4 ] .default_trigger = "default-on",
1 f% ^' \: D* S* U- f8 a: z },
2 ?' N% m$ j* T' }3 u: ~( ` {
}3 c' [' J$ z2 H! e .active_low = 0,! h/ I* \2 ?& w: x9 w: [1 [
.gpio = DA850_USER_LED1,
$ H. }4 s5 U! E .name = "user_led1",
1 n0 ~) }7 }0 X3 G C .default_trigger = "default-on",
6 k6 ]* i& T. ]5 c },
$ v- t, H+ v* k! ?# r6 R) _ {
" F+ M$ b# p3 l- _5 g$ }' w1 A# q .active_low = 0,
" Q# e% i% Z1 q1 v5 @* Q5 }' m .gpio = DA850_USER_LED2,( m. u4 b: l/ `% t+ \1 k& ~- @
.name = "user_led2",2 w% r& l+ e% ?
.default_trigger = "default-on",3 [7 V% U$ W! V3 E$ [+ V7 I3 G0 m
},
. V! s K4 G- t: E5 W {
0 c- A! N& q2 o! b6 J .active_low = 0,
& v( n5 \- k; E, H8 o: ^ .gpio = DA850_USER_LED3,: e% n0 F0 @: B2 d) y8 |: D. ?
.name = "user_led3",7 V$ F. U* T7 K' h9 Q
.default_trigger = "default-on",/ D% } C( k n3 A5 G: U6 R
},; |# G: h, ^, q" h/ f! [7 N
};
$ M- d5 s) ^+ A
& }. |" p; T& t2 N$ ~6 cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( m8 p( D9 h$ i7 B* ^. O
.leds = da850_evm_tl_leds,
' h1 ?0 e. g' G8 x M) h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 u! s' V; b' V z
};5 Z/ p$ D) G: g/ O9 N4 j# q
7 `# c7 L1 h% Xstatic void led_dev_release(struct device *dev)
8 P- }9 L! J3 h: A{* W( A1 q1 D: N) ?
};1 @. ~7 q+ |1 l# U
, n$ G/ }! N4 X+ o
static struct platform_device da850_evm_tl_leds_device = {
9 U+ F0 q; u1 |4 w7 s6 q: X, W9 _ .name = "leds-gpio",
" w" r8 ] C1 k2 G7 P$ g .id = 1,: C& b# M8 W, a% J4 e+ I
.dev = {4 D- O. J. R$ S4 l- k7 g* S: s- T& X
.platform_data = &da850_evm_tl_leds_pdata,5 \! i+ {0 I0 W
.release = led_dev_release,# O/ `, ^) D8 c, v, m
}
9 Z7 ~. Y( c( K$ G$ Y8 o# i};/ C8 R3 f' O. w% {7 _& a5 w
( w! Q. j/ m) K4 ~# j! L( n9 }
static int __init led_platform_init(void)6 M! U- S" Q( P! c
{5 P: z) `9 I W& U7 ]. p3 @7 C
int ret;
2 ?. K0 M: g% X2 S#if 0
3 E" u8 P2 I4 }; C% M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& W& } j- p/ b3 |" s4 S if (ret)! a9 l4 J* f0 D2 J3 d; C2 C0 `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 ? @, M" j8 C/ S/ R+ D9 Z6 d3 X "%d\n", ret);
( k' J% O, r [7 A; v {' |1 g' P#endif6 l3 q$ X1 k+ k( F/ G: o4 c W3 m
ret = platform_device_register(&da850_evm_tl_leds_device);
' ?' ^6 g2 G* m# ~ w! a/ b" ] if (ret)
9 p/ ?. ^7 p1 i. d pr_warning("Could not register som GPIO expander LEDS");7 z* Z9 [3 p5 M6 L
else9 s! H m4 ^/ N. s& T
printk(KERN_INFO "LED register sucessful!\n");
% Z+ y: L) V% V6 T6 ~5 y- _6 {9 H r9 d& }& i5 q) Y. k
return ret;
$ Y' a! M ?- E6 P9 |( b" k}
( I4 W3 Z4 R K& |$ S2 t- ?: G S9 a0 C2 _7 R2 r# z, d
static void __exit led_platform_exit(void)7 a/ {* E; p, ]6 Y( r
{9 D! g0 O8 D2 O; y1 E2 M6 o
platform_device_unregister(&da850_evm_tl_leds_device);; F, k; ~& R3 k) P& Y7 G
: |. e# k% U! f
printk(KERN_INFO "LED unregister!\n");
2 V2 ~+ Q( ~- O$ Y* S9 ?4 M0 L}
4 J$ e" m, \3 G4 G: ~
6 D; ~! r* D% omodule_init(led_platform_init);2 x. B6 s! `* Q/ c" i8 k& g9 t! }
module_exit(led_platform_exit);
& {/ r i: @7 @+ H5 s \& o. \) F( t% H$ l2 d7 v; k) P
MODULE_DESCRIPTION("Led platform driver");
U4 ^/ J9 h/ w+ N9 eMODULE_AUTHOR("Tronlong");
" y9 L7 ?4 o( }$ pMODULE_LICENSE("GPL");' y" ]* O, w& k' ~1 k- [
$ k: P @% l% l) f+ \) y [% q' j |
|