|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# x1 Q6 R8 F6 I
#include <linux/init.h>: J, A8 b2 W9 t. ~
#include <linux/module.h>
( w' p: K" A1 m+ ]2 `1 y#include <linux/kernel.h>: L. E3 {+ y6 i, y2 f; y, n
#include <linux/types.h>% o e6 z/ {" ^3 q: J3 Z& B
#include <linux/gpio.h>4 u% ^! [8 ]% c; R' J
#include <linux/leds.h>
' G. o; n0 ~9 B7 Z% l* w#include <linux/platform_device.h>
9 ^: J. j4 B( ?0 q8 Y( i( W8 i* A* M9 v! J, j
#include <asm/mach-types.h>4 j" e2 D! E5 ^$ D% O d" N% K
#include <asm/mach/arch.h>
5 M0 Z% N6 K+ R" G8 z+ _: w#include <mach/da8xx.h>
2 e! B& E- B) a# I1 e: E. X) T' p#include <mach/mux.h>
! Q$ U$ r( W7 O- C, H+ S- ?0 ~
+ D) `& l9 i! E7 \+ Q9 X6 S, {5 G* X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 l: D6 H# ^) t$ a2 t2 K% J$ m. x/ @" r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; M D( c6 w. _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# T) G1 A' C6 r) V& l; \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% m( a6 x0 e8 u% d1 j% L
: ~; y4 T! f0 @! W8 i' R5 q/* assign the tl som board LED-GPIOs*/
+ i- N% ^0 `3 [8 w: F0 M' ]1 g6 wstatic const short da850_evm_tl_user_led_pins[] = {
$ j) Z i& S) N3 i /* These pins are definition at <mach/mux.h> file */2 l! P Y+ M" \9 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 I4 B( K" }4 _+ T8 d& V
-1
5 p* }* A2 ^2 l' H0 H$ c1 ~};2 q. @- r* C9 L
3 S7 z; S0 b* y$ B: Dstatic struct gpio_led da850_evm_tl_leds[] = {8 R& Z, g) S# h+ p$ m, v
{( D! h3 v! d" M
.active_low = 0,
( [- ]) \- h% k8 D3 R2 [ .gpio = DA850_USER_LED0,
: `$ `- O+ C7 Z; S, } .name = "user_led0",
; V# v8 E4 f' L .default_trigger = "default-on",
3 e/ M! x! H5 i: i! Z% J. H% { },; n0 [. x4 I9 K4 ^ v
{" @9 t2 `6 {# ]! `. h
.active_low = 0,% L" ]" [" U' Y3 Y9 C8 \, W. D
.gpio = DA850_USER_LED1,
- j9 c# q/ s0 j9 I6 l$ ? .name = "user_led1",
( ?+ s) S0 L) b, p9 f/ ~ .default_trigger = "default-on",: m5 l; Z3 `# B% y7 y
},
! m+ L' s% {6 R1 a {
, V! z3 A, r r, V8 ^4 V8 Y$ ] .active_low = 0,* x# Q F- Y+ e1 L+ Q3 f! E
.gpio = DA850_USER_LED2,
: M: t0 f V) v6 G% v& }! K .name = "user_led2",
7 w. W k" z5 M" n7 f& D .default_trigger = "default-on",4 ~5 ^/ z+ O _4 j
},
- [6 c, h0 i8 L% ~( n {! ?# a- k3 P2 L9 z- |
.active_low = 0,/ r/ t O& V% H1 ~, P3 m( y
.gpio = DA850_USER_LED3,+ A3 j( q6 z6 Q) Q# n
.name = "user_led3",0 b% q2 b; j9 Q9 _
.default_trigger = "default-on",! Q) b% C8 v* M% Z* F! m' g
},
% x2 d0 @; a0 f; C& _, w$ {};
# s- D& r: U+ z
2 R& t/ D, A. ]: Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 g$ l& T+ z+ w0 o
.leds = da850_evm_tl_leds,( \, f5 U8 u% G1 F+ \( n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& S% R1 L' c2 @};
! a& Q" J8 v0 P2 M
$ K( a c- }! B4 gstatic void led_dev_release(struct device *dev)
3 B- c' V( w6 P{
9 T+ S4 z( A5 J$ W( {, q4 s; ~};
/ P' _5 f+ @; o" X, H
- C5 J5 I' g" P( xstatic struct platform_device da850_evm_tl_leds_device = {
& f0 o7 p/ y, b; n6 N! T6 M .name = "leds-gpio",# c- E9 Q7 {0 \. L: h" ?% T- r8 h) v1 Z
.id = 1, N6 ^! T& @8 T: t' k
.dev = {
4 w t( l4 z1 w) n1 c8 E) v+ c .platform_data = &da850_evm_tl_leds_pdata,' ~3 p; k/ x. O# \8 i0 I- u
.release = led_dev_release,
0 j4 d, v! a) @2 e+ X6 I }
" D7 g3 o3 j6 B: \+ D};8 q" ?' H! c$ Q; H/ ^9 U. x1 j
$ V4 x, N$ [% ]& c r- gstatic int __init led_platform_init(void)
) P7 Z' {5 I$ j8 r. l3 x2 g{( L' ?1 w$ W8 L* S
int ret;
8 s+ R* _) S; N4 M$ F#if 0
* R! }4 W6 }1 a1 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ B& F+ c) p, i' K5 y5 t if (ret)# F+ V* ]4 P" f" }" G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, ~7 W8 ]( [% y/ i. |+ P! ~ "%d\n", ret);
3 Y% l* @6 [) W, F#endif2 Z B$ d# Z& `7 l5 c5 i3 m+ q
ret = platform_device_register(&da850_evm_tl_leds_device);
) @5 O" [. j9 b/ b7 k if (ret)3 T9 H' A# P2 y3 y
pr_warning("Could not register som GPIO expander LEDS");
x) Q6 k8 r6 R else3 |. R: f- @. ^
printk(KERN_INFO "LED register sucessful!\n");; O5 Z7 U Y3 F0 |; r1 |0 j. j( R
. g3 o4 @0 o D return ret;6 |% x- S! O7 R7 d& a2 R; H& b
}
3 B2 \6 c j3 T
8 m2 B! v( v* Z) vstatic void __exit led_platform_exit(void)/ q7 d/ W0 r8 x2 @4 W; ]! m! u
{
4 p" A5 h. N; A/ E* T platform_device_unregister(&da850_evm_tl_leds_device);
6 V* _" C1 u% Z0 I* H7 P' s- @; v& [! s$ A, D6 Z2 H
printk(KERN_INFO "LED unregister!\n");7 R5 A$ D$ G; l2 P( t" e# b. {
}# ^5 g" X- `8 K1 k! {8 D4 a8 v
) v# O) Y4 J. g; S7 u
module_init(led_platform_init);0 j/ k/ j M/ g7 g2 Q
module_exit(led_platform_exit);$ J% X, [* \/ q$ j& Y
1 Z+ S; w1 m( S5 F5 D. TMODULE_DESCRIPTION("Led platform driver");
% Q2 l) i2 F7 qMODULE_AUTHOR("Tronlong");# }! `& L) U5 O. K1 S+ [+ c9 n
MODULE_LICENSE("GPL");3 s7 r, J: A9 L3 H
" b; D/ v. f# X- z* q8 K0 x
|
|