|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 b0 ?& M( x3 o" d#include <linux/init.h># Y) k" m+ V1 E5 i( C9 F0 S! \/ g7 Z
#include <linux/module.h>: d# U4 u: Q7 j, w
#include <linux/kernel.h>
+ ~: H1 ?( g2 O1 z- Z% y8 F I. g8 E#include <linux/types.h>% M" A" D5 A4 m
#include <linux/gpio.h>& Q5 @$ t- f- |3 g6 I0 C1 L
#include <linux/leds.h>
6 o! {) v) P+ x8 ^' \1 m#include <linux/platform_device.h>
* o( p6 M( d& G! R
4 i% {+ y6 w t/ i. V# V#include <asm/mach-types.h>
: s$ V u6 M0 {6 K4 ?#include <asm/mach/arch.h>0 v4 M* p4 K( S- R* k0 Y
#include <mach/da8xx.h>
$ P8 I! s, ?0 z0 |3 z#include <mach/mux.h>
& {; s, u" _. u1 U$ b* R7 @; C& H" s, z- R8 w" g, u. s- g, u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% j. w9 ]9 r. |0 V6 t& @' _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* F1 r6 O) T; f0 b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 \2 T: k! [& Z1 V( _4 B7 F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" \1 n* z$ x+ P( Y: j0 h9 Q" l5 | l: g! E+ Z
/* assign the tl som board LED-GPIOs*/
6 f- B. i7 E P( b' Fstatic const short da850_evm_tl_user_led_pins[] = {
: g6 z' [) a9 z* F) G /* These pins are definition at <mach/mux.h> file */
/ u$ G& L% Z5 d9 b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 p# v3 w/ [2 h! I; f+ e -1
; ]& k+ X, K$ d5 z7 D};
; z9 P+ n* H; Z2 A x, o6 M
5 d% C& K( f }" ]' hstatic struct gpio_led da850_evm_tl_leds[] = {" m9 G! _2 v) @/ X O
{
1 r9 h) F; M$ d" c! x3 m .active_low = 0,+ \6 b+ v& v; a( N7 E
.gpio = DA850_USER_LED0,$ j- N+ h5 k$ _) M4 s
.name = "user_led0",3 O( A0 U, g, l+ T4 T) b
.default_trigger = "default-on",; \& F9 |3 }: a0 U
},9 O1 U1 m% ?; Y9 ]: ]7 C
{5 U& i0 P( H) ]2 ]3 \
.active_low = 0,$ n- b' h6 m3 f6 f7 l# W7 [
.gpio = DA850_USER_LED1,# D; N* I8 V0 \. N1 _" N
.name = "user_led1",
$ c0 {6 N$ B) W; f2 j .default_trigger = "default-on",
0 d$ i# ]8 L. i7 z }4 k) Z },
& D, @# U. i3 n+ k3 r/ [ {
1 r5 \! ?( O5 w% N .active_low = 0,
% D$ n; O3 H! t& T. a .gpio = DA850_USER_LED2,
5 ]# {1 t6 @- {" L* t Z .name = "user_led2",
: Z$ K# S9 }4 I6 Y( o .default_trigger = "default-on",
* \* S$ R# h( z$ ^ H) s- {" O },
' F3 u* l$ H1 B6 x6 X {
5 Z& a0 T9 Y) r- {: k7 x .active_low = 0,! z, q9 R+ `5 D! A$ j: X
.gpio = DA850_USER_LED3,* R/ `: K* S; @) B8 M* O% Q
.name = "user_led3",8 l% |$ F, e# Z7 m8 `
.default_trigger = "default-on",; z+ ^" g5 ~. U3 H# ]
},
u9 I6 o. r: e U8 A$ h};
! B( d' u3 n+ k1 ]4 X5 |
6 z0 k7 O) f) h1 U r2 mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, d0 k4 a# ]- [" z, i
.leds = da850_evm_tl_leds,# F9 e5 M4 i7 }: F. Z( l- K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% u3 }! K! {! z};
# w$ c+ g& @1 Y- @ M. i* \
2 L! Z! }' s0 G8 P0 {static void led_dev_release(struct device *dev)
/ R/ \- `1 r" L3 ~$ c{. X/ |, A$ Z/ X9 L8 D9 }
};
H5 j' ]% X. F+ f- ~
& F! U. a* k9 r- b0 d7 ^8 Fstatic struct platform_device da850_evm_tl_leds_device = {; c( E8 p% p7 F! a! p7 a
.name = "leds-gpio",
5 `. S" p7 s) s0 C" U .id = 1,
4 |; R. b8 [, W$ q .dev = {
* d: x7 [! Q5 T. R5 V: a3 I .platform_data = &da850_evm_tl_leds_pdata,& t; q& d4 [) q/ J% W% y
.release = led_dev_release,
2 a0 } U1 x) p4 F5 e) Y }
4 E: `4 Q l3 D' c};
A' q% T* h" U( D/ w8 T* S6 C! \( X N6 w8 }4 h! W
static int __init led_platform_init(void) f* Q5 d" T d
{
% V' L6 i- I& E2 u% K8 ? int ret;
$ T, _/ D t2 e2 `. S- ^#if 0
# P3 J" W+ F6 L9 o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 C; V/ ?5 v$ X$ ]/ n
if (ret)0 o3 ^, P3 ?) W* o* d9 s. j( L) r. {* F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: r( _3 g* R5 Q% a& S "%d\n", ret);
; T8 o8 ]) b- @: s#endif2 s7 a0 b* x0 Z. c/ Y* M
ret = platform_device_register(&da850_evm_tl_leds_device);. x) p* I2 T: ]; @
if (ret)$ v# g! J" F( T, {4 X/ O' g
pr_warning("Could not register som GPIO expander LEDS");- L8 h, }0 b- t6 W" W( N
else R8 L1 k" l3 P5 t
printk(KERN_INFO "LED register sucessful!\n");
: I$ @. ?$ S- |& F: n% |0 y& p
$ r2 p8 G- q3 P7 e5 d3 a return ret;& F# P9 |8 a4 ]0 n2 E1 u
}8 z' K* J; t* l3 E
8 l- X# w4 L; S- z1 e( [
static void __exit led_platform_exit(void)
" g2 {1 d, D$ }! |- P{
# b7 H4 `% x/ a O& v" F+ j platform_device_unregister(&da850_evm_tl_leds_device);
$ T# g+ Z/ j# k3 r
7 b {$ d6 R6 G0 b printk(KERN_INFO "LED unregister!\n");8 o# J$ J) i! |0 J% `
}
5 j* R4 m; O+ k, y9 x9 L
9 R8 J/ x( h- Ymodule_init(led_platform_init);) \- E& Y3 P& z5 x
module_exit(led_platform_exit);# z) Q0 B4 |: {# ^& e9 a
* F0 x, N* l6 i, T: |
MODULE_DESCRIPTION("Led platform driver");
7 `$ q8 p1 i( \4 ]8 r3 tMODULE_AUTHOR("Tronlong");
& R. R) G# u2 }( F9 o- ~0 b; MMODULE_LICENSE("GPL");
* B, R* ^0 N% g; A! S( ^& Q; O% E1 D( M& D1 |1 N
|
|