|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 d& \2 \) @! o m, D! U#include <linux/init.h>
/ `. Q: q! c5 R" P5 C, Z& |#include <linux/module.h>
0 r4 A. G2 J" L6 A& K#include <linux/kernel.h>* q$ y- L) q$ R' P1 P' x( T6 T' n- s% S# S
#include <linux/types.h>( \* p/ i/ B4 M* L
#include <linux/gpio.h>
& @- S- R( Q& B) N1 W#include <linux/leds.h>
2 s' T* ~$ {* U#include <linux/platform_device.h>
- [: r4 d5 w* T W$ O% ^( M$ e$ v: `* \) p. q
#include <asm/mach-types.h>
8 H2 X7 O" B0 c6 K#include <asm/mach/arch.h> b( \2 O1 ~6 t( f
#include <mach/da8xx.h>
" v! O& S+ `/ i9 }* Z#include <mach/mux.h>
! A& c- U7 m9 W$ ?& w1 p$ _# E5 c1 r# O4 F V, G. [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). S; a1 r) q- {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 b1 H) u4 D0 D; j" S7 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) J9 ^5 P/ w A- z# k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& \" c# }2 F8 \0 h' _
! z7 d0 A# Y3 o) ~* M, u/* assign the tl som board LED-GPIOs*/
6 h+ d3 j2 L& H/ u0 Gstatic const short da850_evm_tl_user_led_pins[] = {
- f/ G2 Y i- ` /* These pins are definition at <mach/mux.h> file */
; M' }% |7 J$ i! e; M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! z. n' d$ w# f/ C
-1
+ x: Y8 ~$ D3 E# v- |$ Z};
1 e& C9 ~3 }- J# ~+ ~3 L! S, `4 y4 C1 `4 t$ g: v' D4 _
static struct gpio_led da850_evm_tl_leds[] = {
; y G2 K' }; I+ B, y {
% c+ a2 @! a q& }6 u .active_low = 0,
; @$ t, J a: P3 d* G; c! w/ `! s .gpio = DA850_USER_LED0,
0 f( d- [2 I1 D+ P7 P .name = "user_led0",
) _+ N0 `# |' X( Q% w+ V) b .default_trigger = "default-on",
( f# R) n# [5 q! M) c0 @, i },0 W( x$ a4 O; q7 b; w- s5 s
{- U, b! h! Y2 o
.active_low = 0,
) t4 h) ~% H/ B/ H# n' J2 T .gpio = DA850_USER_LED1,6 W! [# {* Y$ j$ i2 [/ y
.name = "user_led1",2 d! b5 A0 I9 V# [9 M
.default_trigger = "default-on",: E5 s1 b3 o- G( z& g& f
},* z) X7 n6 G0 J1 Q/ r7 ^% f5 S
{
0 O: k) X( G' \; @- x .active_low = 0,; q1 r6 z4 v/ g' p( i* { m* Z
.gpio = DA850_USER_LED2,
0 C0 {8 m3 G5 |& i; G .name = "user_led2",
" b: S* d) K: D' h; _. E; `. B: n: F .default_trigger = "default-on",
4 T5 o% N9 W1 a8 n9 B M0 t },
8 \6 x! s/ P4 v/ X {
* H5 S2 E8 G- \+ r! H9 F! g .active_low = 0,
5 }0 S- N7 [3 T, D. k( ]9 p .gpio = DA850_USER_LED3,
1 `+ x% G7 `) x m1 x .name = "user_led3",1 t1 D) f# h9 W
.default_trigger = "default-on",
" z' e" u) {+ j+ C% S },* o5 j Q" j" M- O- ]; {" {3 R, v
};! Y! [5 l' ~8 _) h$ W7 Y' j
8 s% t6 ~1 E( m$ lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 d# l+ ?8 C/ q3 V5 W/ l7 e
.leds = da850_evm_tl_leds,' q( {0 c! R% d* h6 p. ~$ y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; U& \' {0 g" S4 ^% z, ^+ B! E0 N};9 R; A3 Q+ T1 A* N; _
8 @, V! M# A2 Ustatic void led_dev_release(struct device *dev)
5 K$ k! s* U" c- Y7 \{
( C% K- X4 }, D- c) l$ k7 i. P1 ~};
: M. v: r: X/ Q) D) g8 O R ?0 T! b% ?+ y: O! p. x. Y3 ?
static struct platform_device da850_evm_tl_leds_device = {
% h0 [8 p6 y& i .name = "leds-gpio", |( s4 R2 {' _2 X, {2 |) m" S
.id = 1,
9 e' V. n+ {9 h! ^8 X! i .dev = {9 Y* K; G; |! A
.platform_data = &da850_evm_tl_leds_pdata,
4 E( X2 E. o$ _' J3 x% L5 t9 ] .release = led_dev_release,
5 e1 ]0 H) B* N3 O) d }$ k0 Z, D" c U6 H% X y* P- l
};
8 B, k& y% W1 y
3 e3 @, k/ \ z I7 S/ |/ Ystatic int __init led_platform_init(void)
, Q& G" I! @+ w4 }" _{: |+ A2 p, U( n& o7 Z8 a
int ret; ]) S6 q9 }3 R5 Z+ P
#if 0
! U ^* \( ?! `/ E/ \+ O& f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* Y/ G, T/ C) Y( r: P
if (ret)% x. d2 d- j' C# @6 E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" M1 ~/ l1 r5 b& m. |2 C
"%d\n", ret);) {8 u: G* H# A( A( L6 s
#endif
0 J- V6 O; N1 O# `. {: ? ret = platform_device_register(&da850_evm_tl_leds_device);' V& w6 ^, {2 g4 h7 b+ P, `5 s9 L0 S' F
if (ret)9 D4 @2 [& m l
pr_warning("Could not register som GPIO expander LEDS");
5 B$ O6 S b3 @; m- R$ d else- R/ m: Y' h* B T
printk(KERN_INFO "LED register sucessful!\n");( F6 j3 t4 n9 C/ |# s7 Y1 q
6 S; d' g3 n+ P, j, u, x3 m return ret;
b# D. `( i [% H2 M9 G: I; n7 M7 X}
( `) M& s- t5 ?" I" _
1 ], O8 P \) istatic void __exit led_platform_exit(void)
! H+ |6 o6 K6 C- D) H{* S: ^( l3 U& } I! ]6 ~
platform_device_unregister(&da850_evm_tl_leds_device);+ S3 V, q# a9 e! n# }3 L' M
# M; Y* {+ U' `1 z printk(KERN_INFO "LED unregister!\n");
" u! V/ R; n5 s9 D2 l N}
8 x6 f( ^* N) {% |3 Z: D
6 H( Q; _6 y4 N* U$ Z- @8 _9 ~module_init(led_platform_init);6 J' L5 h. f5 @) U9 w1 X
module_exit(led_platform_exit);
- S- V- s6 j2 P3 B) Z5 v9 i
% i6 n/ A' V7 Q2 Y& eMODULE_DESCRIPTION("Led platform driver");# D# \2 e4 l8 h
MODULE_AUTHOR("Tronlong");, T3 C# Y- G' V( e$ F$ P
MODULE_LICENSE("GPL");0 b! {3 M ?: ^7 A4 K
7 z8 Q1 |/ m- s9 Y, E$ B5 Y: A1 A- S |
|